Merge branch '3.0' into cpwu/3.0
This commit is contained in:
commit
34aa146c55
117
README-CN.md
117
README-CN.md
|
@ -14,7 +14,6 @@
|
|||
[](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master)
|
||||
[](https://coveralls.io/github/taosdata/TDengine?branch=develop)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/4201)
|
||||
[](https://snapcraft.io/tdengine)
|
||||
|
||||
简体中文 | [English](README.md) | 很多职位正在热招中,请看[这里](https://www.taosdata.com/cn/careers/)
|
||||
|
||||
|
@ -36,11 +35,13 @@ TDengine 是一款开源、高性能、云原生的时序数据库 (Time-Series
|
|||
|
||||
# 文档
|
||||
|
||||
关于完整的使用手册,系统架构和更多细节,请参考 [TDengine 文档](https://docs.taosdata.com) 或者 [English Version](https://docs.tdengine.com)。
|
||||
关于完整的使用手册,系统架构和更多细节,请参考 [TDengine 文档](https://docs.taosdata.com) 或者 [English Documents](https://docs.tdengine.com)。
|
||||
|
||||
# 构建
|
||||
|
||||
TDengine 目前 2.0 版服务器仅能在 Linux 系统上安装和运行,后续会支持 Windows、macOS 等系统。客户端可以在 Windows 或 Linux 上安装和运行。任何 OS 的应用也可以选择 RESTful 接口连接服务器 taosd。CPU 支持 X64/ARM64/MIPS64/Alpha64,后续会支持 ARM32、RISC-V 等 CPU 架构。用户可根据需求选择通过源码或者[安装包](https://docs.taosdata.com/get-started/package/)来安装。本快速指南仅适用于通过源码安装。
|
||||
TDengine 目前可以在 Linux、 Windows 等平台上安装和运行。任何 OS 的应用也可以选择 taosAdapter 的 RESTful 接口连接服务端 taosd。CPU 支持 X64/ARM64,后续会支持 MIPS64、Alpha64、ARM32、RISC-V 等 CPU 架构。
|
||||
|
||||
用户可根据需求选择通过[源码](https://www.taosdata.com/cn/getting-started/#通过源码安装)或者[安装包](https://www.taosdata.com/cn/getting-started/#通过安装包安装)来安装。本快速指南仅适用于通过源码安装。
|
||||
|
||||
## 安装工具
|
||||
|
||||
|
@ -50,20 +51,6 @@ TDengine 目前 2.0 版服务器仅能在 Linux 系统上安装和运行,后
|
|||
sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
||||
```
|
||||
|
||||
编译或打包 JDBC 驱动源码,需安装 Java JDK 8 或以上版本和 Apache Maven 2.7 或以上版本。
|
||||
|
||||
安装 OpenJDK 8:
|
||||
|
||||
```bash
|
||||
sudo apt-get install -y openjdk-8-jdk
|
||||
```
|
||||
|
||||
安装 Apache Maven:
|
||||
|
||||
```bash
|
||||
sudo apt-get install -y maven
|
||||
```
|
||||
|
||||
#### 为 taos-tools 安装编译需要的软件
|
||||
|
||||
taosTools 是用于 TDengine 的辅助工具软件集合。目前它包含 taosBenchmark(曾命名为 taosdemo)和 taosdump 两个软件。
|
||||
|
@ -79,19 +66,10 @@ sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-d
|
|||
### CentOS 7.9:
|
||||
|
||||
```bash
|
||||
sudo yum install -y gcc gcc-c++ make cmake git openssl-devel
|
||||
```
|
||||
|
||||
安装 OpenJDK 8:
|
||||
|
||||
```bash
|
||||
sudo yum install -y java-1.8.0-openjdk
|
||||
```
|
||||
|
||||
安装 Apache Maven:
|
||||
|
||||
```bash
|
||||
sudo yum install -y maven
|
||||
sudo yum install epel-release
|
||||
sudo yum update
|
||||
sudo yum install -y gcc gcc-c++ make cmake3 git openssl-devel
|
||||
sudo ln -sf /usr/bin/cmake3 /usr/bin/cmake
|
||||
```
|
||||
|
||||
### CentOS 8 & Fedora
|
||||
|
@ -100,29 +78,29 @@ sudo yum install -y maven
|
|||
sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel
|
||||
```
|
||||
|
||||
安装 OpenJDK 8:
|
||||
|
||||
```bash
|
||||
sudo dnf install -y java-1.8.0-openjdk
|
||||
```
|
||||
|
||||
安装 Apache Maven:
|
||||
|
||||
```bash
|
||||
sudo dnf install -y maven
|
||||
```
|
||||
|
||||
#### 在 CentOS 上构建 taosTools 安装依赖软件
|
||||
|
||||
为了在 CentOS 上构建 [taosTools](https://github.com/taosdata/taos-tools) 需要安装如下依赖软件
|
||||
#### For CentOS 7/RHEL
|
||||
|
||||
```bash
|
||||
sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
||||
```
|
||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
||||
```
|
||||
|
||||
注意:由于 snappy 缺乏 pkg-config 支持
|
||||
(参考 [链接](https://github.com/google/snappy/pull/86)),会导致
|
||||
cmake 提示无法发现 libsnappy,实际上工作正常。
|
||||
#### For CentOS 8/Rocky Linux
|
||||
|
||||
```
|
||||
sudo yum install -y epel-release
|
||||
sudo yum install -y dnf-plugins-core
|
||||
sudo yum config-manager --set-enabled powertools
|
||||
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
||||
```
|
||||
|
||||
注意:由于 snappy 缺乏 pkg-config 支持(参考 [链接](https://github.com/google/snappy/pull/86)),会导致 cmake 提示无法发现 libsnappy,实际上工作正常。
|
||||
|
||||
若 powertools 安装失败,可以尝试改用:
|
||||
```
|
||||
sudo yum config-manager --set-enabled Powertools
|
||||
```
|
||||
|
||||
### 设置 golang 开发环境
|
||||
|
||||
|
@ -135,6 +113,12 @@ go env -w GO111MODULE=on
|
|||
go env -w GOPROXY=https://goproxy.cn,direct
|
||||
```
|
||||
|
||||
默认情况下,内嵌的 http 服务仍然可以从 TDengine 源码构建。当然您也可以使用以下命令选择构建 taosAdapter 作为 RESTful 接口的服务。
|
||||
|
||||
```
|
||||
cmake .. -DBUILD_HTTP=false
|
||||
```
|
||||
|
||||
### 设置 rust 开发环境
|
||||
|
||||
TDengine 包含数个使用 Rust 语言开发的组件. 请参考 rust-lang.org 官方文档设置 rust 开发环境。
|
||||
|
@ -275,24 +259,6 @@ nmake install
|
|||
sudo make install
|
||||
```
|
||||
|
||||
安装成功后,如果想以服务形式启动,先配置 `.plist` 文件,在终端中执行:
|
||||
|
||||
```bash
|
||||
sudo cp ../packaging/macOS/com.taosdata.tdengine.plist /Library/LaunchDaemons
|
||||
```
|
||||
|
||||
在终端中启动 TDengine 服务:
|
||||
|
||||
```bash
|
||||
sudo launchctl load /Library/LaunchDaemons/com.taosdata.tdengine.plist
|
||||
```
|
||||
|
||||
在终端中停止 TDengine 服务:
|
||||
|
||||
```bash
|
||||
sudo launchctl unload /Library/LaunchDaemons/com.taosdata.tdengine.plist
|
||||
```
|
||||
|
||||
## 快速运行
|
||||
|
||||
如果不希望以服务方式运行 TDengine,也可以在终端中直接运行它。也即在生成完成后,执行以下命令(在 Windows 下,生成的可执行文件会带有 .exe 后缀,例如会名为 taosd.exe ):
|
||||
|
@ -342,21 +308,6 @@ TDengine 提供了丰富的应用程序开发接口,其中包括 C/C++、Java
|
|||
- [C#](https://docs.taosdata.com/reference/connector/csharp/)
|
||||
- [RESTful API](https://docs.taosdata.com/reference/rest-api/)
|
||||
|
||||
## 第三方连接器
|
||||
|
||||
TDengine 社区生态中也有一些非常友好的第三方连接器,可以通过以下链接访问它们的源码。
|
||||
|
||||
- [Rust Bindings](https://github.com/songtianyi/tdengine-rust-bindings/tree/master/examples)
|
||||
- [.Net Core Connector](https://github.com/maikebing/Maikebing.EntityFrameworkCore.Taos)
|
||||
- [Lua Connector](https://github.com/taosdata/TDengine/tree/develop/examples/lua)
|
||||
- [PHP](https://www.taosdata.com/en/documentation/connector#c-cpp)
|
||||
|
||||
# 运行和添加测试例
|
||||
|
||||
TDengine 的测试框架和所有测试例全部开源。
|
||||
|
||||
点击 [这里](https://github.com/taosdata/TDengine/blob/develop/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md),了解如何运行测试例和添加新的测试例。
|
||||
|
||||
# 成为社区贡献者
|
||||
|
||||
点击 [这里](https://www.taosdata.com/cn/contributor/),了解如何成为 TDengine 的贡献者。
|
||||
|
@ -364,7 +315,3 @@ TDengine 的测试框架和所有测试例全部开源。
|
|||
# 加入技术交流群
|
||||
|
||||
TDengine 官方社群「物联网大数据群」对外开放,欢迎您加入讨论。搜索微信号 "tdengine",加小 T 为好友,即可入群。
|
||||
|
||||
# [谁在使用 TDengine](https://github.com/taosdata/TDengine/issues/2432)
|
||||
|
||||
欢迎所有 TDengine 用户及贡献者在 [这里](https://github.com/taosdata/TDengine/issues/2432) 分享您在当前工作中开发/使用 TDengine 的故事。
|
||||
|
|
79
README.md
79
README.md
|
@ -20,7 +20,7 @@ English | [简体中文](README-CN.md) | We are hiring, check [here](https://tde
|
|||
|
||||
# What is TDengine?
|
||||
|
||||
TDengine is an open source, cloud native time-series database optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time data ingestion, processing, and monitoring of TB and even PB scale data per day, generated by billions of sensors and data collectors. Below are the most outstanding advantages of TDengine:
|
||||
TDengine is an open source, cloud native time-series database optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time data ingestion, processing, and monitoring of TB and even PB scale data per day, generated by billions of sensors and data collectors. TDengine differentiates itself from other TSDBs with the following advantages.:
|
||||
|
||||
- High-Performance: 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.
|
||||
|
||||
|
@ -28,7 +28,7 @@ TDengine is an open source, cloud native time-series database optimized for Inte
|
|||
|
||||
- Cloud Native: Through native distributed design, sharding and partitioning, separation of compute and storage, RAFT, support for kubernetes deployment and full observability, TDengine can be deployed on public, private or hybrid clouds.
|
||||
|
||||
- Open Source: TDengine’s core modules, including cluster feature, are all available under open source licenses. It has gathered 18.7k stars on GitHub, an active developer community, and over 137k running instances worldwide.
|
||||
- Open Source: TDengine’s core modules, including cluster feature, are all available under open source licenses. It has gathered 18.8k stars on GitHub, an active developer community, and over 137k running instances worldwide.
|
||||
|
||||
- Ease of Use: For administrators, TDengine significantly reduces the effort to deploy and maintain. For developers, it provides a simple interface, simplified solution and seamless integrations for third party tools. For data users, it gives easy data access.
|
||||
|
||||
|
@ -40,7 +40,7 @@ For user manual, system design and architecture, please refer to [TDengine Docum
|
|||
|
||||
# Building
|
||||
|
||||
At the moment, TDengine server only supports running on Linux systems. You can choose to [install from packages](https://www.taosdata.com/en/getting-started/#Install-from-Package) or build it from the source code. This quick guide is for installation from the source only.
|
||||
At the moment, TDengine server supports running on Linux, Windows, and macOS systems. You can choose to [install from packages](https://www.taosdata.com/en/getting-started/#Install-from-Package) or build it from the source code. This quick guide is for installation from the source only.
|
||||
|
||||
To build TDengine, use [CMake](https://cmake.org/) 3.0.2 or higher versions in the project directory.
|
||||
|
||||
|
@ -52,20 +52,6 @@ To build TDengine, use [CMake](https://cmake.org/) 3.0.2 or higher versions in t
|
|||
sudo apt-get install -y gcc cmake build-essential git libssl-dev
|
||||
```
|
||||
|
||||
To compile and package the JDBC driver source code, you should have a Java jdk-8 or higher and Apache Maven 2.7 or higher installed.
|
||||
|
||||
To install openjdk-8:
|
||||
|
||||
```bash
|
||||
sudo apt-get install -y openjdk-8-jdk
|
||||
```
|
||||
|
||||
To install Apache Maven:
|
||||
|
||||
```bash
|
||||
sudo apt-get install -y maven
|
||||
```
|
||||
|
||||
#### Install build dependencies for taosTools
|
||||
|
||||
We provide a few useful tools such as taosBenchmark (was named taosdemo) and taosdump. They were part of TDengine. From TDengine 2.4.0.0, taosBenchmark and taosdump were not released together with TDengine.
|
||||
|
@ -86,36 +72,12 @@ sudo yum install -y gcc gcc-c++ make cmake3 git openssl-devel
|
|||
sudo ln -sf /usr/bin/cmake3 /usr/bin/cmake
|
||||
```
|
||||
|
||||
To install openjdk-8:
|
||||
|
||||
```bash
|
||||
sudo yum install -y java-1.8.0-openjdk
|
||||
```
|
||||
|
||||
To install Apache Maven:
|
||||
|
||||
```bash
|
||||
sudo yum install -y maven
|
||||
```
|
||||
|
||||
### CentOS 8 & Fedora
|
||||
|
||||
```bash
|
||||
sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel
|
||||
```
|
||||
|
||||
To install openjdk-8:
|
||||
|
||||
```bash
|
||||
sudo dnf install -y java-1.8.0-openjdk
|
||||
```
|
||||
|
||||
To install Apache Maven:
|
||||
|
||||
```bash
|
||||
sudo dnf install -y maven
|
||||
```
|
||||
|
||||
#### Install build dependencies for taosTools on CentOS
|
||||
|
||||
To build the [taosTools](https://github.com/taosdata/taos-tools) on CentOS, the following packages need to be installed.
|
||||
|
@ -124,11 +86,11 @@ To build the [taosTools](https://github.com/taosdata/taos-tools) on CentOS, the
|
|||
sudo yum install zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
|
||||
```
|
||||
|
||||
Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it lead a cmake prompt libsnappy not found. But snappy will works well.
|
||||
Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it leads a cmake prompt libsnappy not found. But snappy still works well.
|
||||
|
||||
### Setup golang environment
|
||||
|
||||
TDengine includes few components developed by Go language. Please refer to golang.org official documentation for golang environment setup.
|
||||
TDengine includes a few components developed by Go language. Please refer to golang.org official documentation for golang environment setup.
|
||||
|
||||
Please use version 1.14+. For the user in China, we recommend using a proxy to accelerate package downloading.
|
||||
|
||||
|
@ -139,7 +101,7 @@ go env -w GOPROXY=https://goproxy.cn,direct
|
|||
|
||||
### Setup rust environment
|
||||
|
||||
TDengine includees few compoments developed by Rust language. Please refer to rust-lang.org official documentation for rust environment setup.
|
||||
TDengine includees a few compoments developed by Rust language. Please refer to rust-lang.org official documentation for rust environment setup.
|
||||
|
||||
## Get the source codes
|
||||
|
||||
|
@ -152,7 +114,7 @@ cd TDengine
|
|||
|
||||
The connectors for go & Grafana and some tools have been moved to separated repositories.
|
||||
|
||||
You can modify the file ~/.gitconfig to use ssh protocol instead of https for better download speed. You need to upload ssh public key to GitHub first. Please refer to GitHub official documentation for detail.
|
||||
You can modify the file ~/.gitconfig to use ssh protocol instead of https for better download speed. You will need to upload ssh public key to GitHub first. Please refer to GitHub official documentation for detail.
|
||||
|
||||
```
|
||||
[url "git@github.com:"]
|
||||
|
@ -304,24 +266,6 @@ After building successfully, TDengine can be installed by:
|
|||
sudo make install
|
||||
```
|
||||
|
||||
To start the service after installation, config `.plist` file first, in a terminal, use:
|
||||
|
||||
```bash
|
||||
sudo cp ../packaging/macOS/com.taosdata.tdengine.plist /Library/LaunchDaemons
|
||||
```
|
||||
|
||||
To start the service, in a terminal, use:
|
||||
|
||||
```bash
|
||||
sudo launchctl load /Library/LaunchDaemons/com.taosdata.tdengine.plist
|
||||
```
|
||||
|
||||
To stop the service, in a terminal, use:
|
||||
|
||||
```bash
|
||||
sudo launchctl unload /Library/LaunchDaemons/com.taosdata.tdengine.plist
|
||||
```
|
||||
|
||||
## Quick Run
|
||||
|
||||
If you don't want to run TDengine as a service, you can run it in current shell. For example, to quickly start a TDengine server after building, run the command below in terminal: (We take Linux as an example, command on Windows will be `taosd.exe`)
|
||||
|
@ -371,15 +315,6 @@ TDengine provides abundant developing tools for users to develop on TDengine. Fo
|
|||
- [C#](https://docs.taosdata.com/reference/connector/csharp/)
|
||||
- [RESTful API](https://docs.taosdata.com/reference/rest-api/)
|
||||
|
||||
## Third Party Connectors
|
||||
|
||||
The TDengine community has also kindly built some of their own connectors! Follow the links below to find the source code for them.
|
||||
|
||||
- [Rust Bindings](https://github.com/songtianyi/tdengine-rust-bindings/tree/master/examples)
|
||||
- [.Net Core Connector](https://github.com/maikebing/Maikebing.EntityFrameworkCore.Taos)
|
||||
- [Lua Connector](https://github.com/taosdata/TDengine/tree/develop/tests/examples/lua)
|
||||
- [PHP](https://www.taosdata.com/en/documentation/connector#c-cpp)
|
||||
|
||||
# How to run the test cases and how to add a new test case
|
||||
|
||||
TDengine's test framework and all test cases are fully open source.
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
IF (TD_LINUX)
|
||||
IF (EXISTS /var/lib/taos/dnode/dnodeCfg.json)
|
||||
INSTALL(CODE "MESSAGE(\"The default data directory /var/lib/taos contains old data of tdengine 2.x, please clear it before installing!\")")
|
||||
ELSEIF (EXISTS C:/TDengine/data/dnode/dnodeCfg.json)
|
||||
INSTALL(CODE "MESSAGE(\"The default data directory C:/TDengine/data contains old data of tdengine 2.x, please clear it before installing!\")")
|
||||
ELSEIF (TD_LINUX)
|
||||
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.sh")
|
||||
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||
INSTALL(CODE "execute_process(COMMAND bash ${TD_MAKE_INSTALL_SH} ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Linux ${TD_VER_NUMBER})")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 11d23e5
|
||||
GIT_TAG 43924b8
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
---
|
||||
sidebar_label: Docker
|
||||
title: 通过 Docker 快速体验 TDengine
|
||||
---
|
||||
:::info
|
||||
如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装.
|
||||
:::
|
||||
|
||||
本节首先介绍如何通过 Docker 快速体验 TDengine,然后介绍如何在 Docker 环境下体验 TDengine 的写入和查询功能。
|
||||
|
||||
## 启动 TDengine
|
||||
|
||||
如果已经安装了 docker, 只需执行下面的命令。
|
||||
|
||||
```shell
|
||||
docker run -d -p 6030:6030 -p 6041/6041 -p 6043-6049/6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
|
||||
```
|
||||
|
||||
注意:TDengine 3.0 服务端仅使用 6030 TCP 端口。6041 为 taosAdapter 所使用提供 REST 服务端口。6043-6049 为 taosAdapter 提供第三方应用接入所使用端口,可根据需要选择是否打开。
|
||||
|
||||
确定该容器已经启动并且在正常运行
|
||||
|
||||
```shell
|
||||
docker ps
|
||||
```
|
||||
|
||||
进入该容器并执行 bash
|
||||
|
||||
```shell
|
||||
docker exec -it <container name> bash
|
||||
```
|
||||
|
||||
然后就可以执行相关的 Linux 命令操作和访问 TDengine
|
||||
|
||||
:::info
|
||||
|
||||
Docker 工具自身的下载请参考 [Docker 官网文档](https://docs.docker.com/get-docker/)。
|
||||
|
||||
安装完毕后可以在命令行终端查看 Docker 版本。如果版本号正常输出,则说明 Docker 环境已经安装成功。
|
||||
|
||||
```bash
|
||||
$ docker -v
|
||||
Docker version 20.10.3, build 48d30b5
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## 运行 TDengine CLI
|
||||
|
||||
进入容器,执行 taos
|
||||
|
||||
```
|
||||
$ taos
|
||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
Server is Community Edition.
|
||||
|
||||
taos>
|
||||
|
||||
```
|
||||
|
||||
## 写入数据
|
||||
|
||||
可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入。
|
||||
|
||||
进入容器,启动 taosBenchmark:
|
||||
|
||||
```bash
|
||||
$ taosBenchmark
|
||||
|
||||
```
|
||||
|
||||
该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "San Francisco" 或者 "Los Angeles"等城市名称。
|
||||
|
||||
这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能。
|
||||
|
||||
taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [taosBenchmark 参考手册](../../reference/taosbenchmark)。
|
||||
|
||||
## 体验查询
|
||||
|
||||
使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。。
|
||||
|
||||
查询超级表下记录总条数:
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters;
|
||||
```
|
||||
|
||||
查询 1 亿条记录的平均值、最大值、最小值等:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters;
|
||||
```
|
||||
|
||||
查询 location="San Francisco" 的记录总条数:
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters where location="San Francisco";
|
||||
```
|
||||
|
||||
查询 groupId=10 的所有记录的平均值、最大值、最小值等:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
|
||||
```
|
||||
|
||||
对表 d10 按 10s 进行平均值、最大值和最小值聚合统计:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
|
||||
```
|
||||
|
||||
## 其它
|
||||
|
||||
更多关于在 Docker 环境下使用 TDengine 的细节,请参考 [在 Docker 下使用 TDengine](../../reference/docker)
|
|
@ -0,0 +1,221 @@
|
|||
---
|
||||
sidebar_label: 安装包
|
||||
title: 使用安装包立即开始
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
:::info
|
||||
如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装.
|
||||
|
||||
:::
|
||||
|
||||
TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包,也支持通过 `apt-get` 工具从线上进行安装。
|
||||
|
||||
## 安装
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="apt-get" label="apt-get">
|
||||
可以使用 apt-get 工具从官方仓库安装。
|
||||
|
||||
**安装包仓库**
|
||||
|
||||
```bash
|
||||
wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
|
||||
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-stable stable main" | sudo tee /etc/apt/sources.list.d/tdengine-stable.list
|
||||
```
|
||||
|
||||
如果安装 Beta 版需要安装包仓库
|
||||
|
||||
```bash
|
||||
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list
|
||||
```
|
||||
|
||||
**使用 apt-get 命令安装**
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
apt-cache policy tdengine
|
||||
sudo apt-get install tdengine
|
||||
```
|
||||
|
||||
:::tip
|
||||
apt-get 方式只适用于 Debian 或 Ubuntu 系统
|
||||
::::
|
||||
</TabItem>
|
||||
<TabItem label="Deb 安装" value="debinst">
|
||||
|
||||
1、从官网下载获得 deb 安装包,例如 TDengine-server-3.0.0.0-Linux-x64.deb;
|
||||
2、进入到 TDengine-server-3.0.0.0-Linux-x64.deb 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
```bash
|
||||
sudo dpkg -i TDengine-server-3.0.0.0-Linux-x64.deb
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="RPM 安装" value="rpminst">
|
||||
|
||||
1、从官网下载获得 rpm 安装包,例如 TDengine-server-3.0.0.0-Linux-x64.rpm;
|
||||
2、进入到 TDengine-server-3.0.0.0-Linux-x64.rpm 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
```bash
|
||||
sudo rpm -ivh TDengine-server-3.0.0.0-Linux-x64.rpm
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="tar.gz 安装" value="tarinst">
|
||||
|
||||
1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-3.0.0.0-Linux-x64.tar.gz;
|
||||
2、进入到 TDengine-server-3.0.0.0-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本:
|
||||
|
||||
```bash
|
||||
tar -zxvf TDengine-server-3.0.0.0-Linux-x64.tar.gz
|
||||
```
|
||||
|
||||
解压后进入相应路径,执行
|
||||
|
||||
```bash
|
||||
sudo ./install.sh
|
||||
```
|
||||
|
||||
:::info
|
||||
install.sh 安装脚本在执行过程中,会通过命令行交互界面询问一些配置信息。如果希望采取无交互安装方式,那么可以用 -e no 参数来执行 install.sh 脚本。运行 `./install.sh -h` 指令可以查看所有参数的详细说明信息。
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
当安装第一个节点时,出现 Enter FQDN:提示的时候,不需要输入任何内容。只有当安装第二个或以后更多的节点时,才需要输入已有集群中任何一个可用节点的 FQDN,支持该新节点加入集群。当然也可以不输入,而是在新节点启动前,配置到新节点的配置文件中。
|
||||
|
||||
:::
|
||||
|
||||
## 启动
|
||||
|
||||
安装后,请使用 `systemctl` 命令来启动 TDengine 的服务进程。
|
||||
|
||||
```bash
|
||||
systemctl start taosd
|
||||
```
|
||||
|
||||
检查服务是否正常工作:
|
||||
|
||||
```bash
|
||||
systemctl status taosd
|
||||
```
|
||||
|
||||
如果服务进程处于活动状态,则 status 指令会显示如下的相关信息:
|
||||
|
||||
```
|
||||
Active: active (running)
|
||||
```
|
||||
|
||||
如果后台服务进程处于停止状态,则 status 指令会显示如下的相关信息:
|
||||
|
||||
```
|
||||
Active: inactive (dead)
|
||||
```
|
||||
|
||||
如果 TDengine 服务正常工作,那么您可以通过 TDengine 的命令行程序 `taos` 来访问并体验 TDengine。
|
||||
|
||||
systemctl 命令汇总:
|
||||
|
||||
- 启动服务进程:`systemctl start taosd`
|
||||
|
||||
- 停止服务进程:`systemctl stop taosd`
|
||||
|
||||
- 重启服务进程:`systemctl restart taosd`
|
||||
|
||||
- 查看服务状态:`systemctl status taosd`
|
||||
|
||||
:::info
|
||||
|
||||
- systemctl 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 sudo 。
|
||||
- `systemctl stop taosd` 指令在执行后并不会马上停止 TDengine 服务,而是会等待系统中必要的落盘工作正常完成。在数据量很大的情况下,这可能会消耗较长时间。
|
||||
- 如果系统中不支持 `systemd`,也可以用手动运行 `/usr/local/taos/bin/taosd` 方式启动 TDengine 服务。
|
||||
|
||||
:::
|
||||
|
||||
## TDengine 命令行 (CLI)
|
||||
|
||||
为便于检查 TDengine 的状态,执行数据库 (Database) 的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI) taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可。
|
||||
|
||||
```bash
|
||||
taos
|
||||
```
|
||||
|
||||
如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。 TDengine CLI 的提示符号如下:
|
||||
|
||||
```cmd
|
||||
taos>
|
||||
```
|
||||
|
||||
在 TDengine CLI 中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行数据库(database)插入查询操作。在终端中运行的 SQL 语句需要以分号结束来运行。示例:
|
||||
|
||||
```sql
|
||||
create database demo;
|
||||
use demo;
|
||||
create table t (ts timestamp, speed int);
|
||||
insert into t values ('2019-07-15 00:00:00', 10);
|
||||
insert into t values ('2019-07-15 01:00:00', 20);
|
||||
select * from t;
|
||||
ts | speed |
|
||||
========================================
|
||||
2019-07-15 00:00:00.000 | 10 |
|
||||
2019-07-15 01:00:00.000 | 20 |
|
||||
Query OK, 2 row(s) in set (0.003128s)
|
||||
```
|
||||
|
||||
除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../../reference/taos-shell/)
|
||||
|
||||
## 使用 taosBenchmark 体验写入速度
|
||||
|
||||
启动 TDengine 的服务,在 Linux 终端执行 `taosBenchmark` (曾命名为 `taosdemo`):
|
||||
|
||||
```bash
|
||||
taosBenchmark
|
||||
```
|
||||
|
||||
该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "California.SanFrancisco" 或者 "California.LosAngeles"。
|
||||
|
||||
这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能,即使在一台普通的 PC 服务器往往也仅需十几秒。
|
||||
|
||||
taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)。
|
||||
|
||||
## 使用 TDengine CLI 体验查询速度
|
||||
|
||||
使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。
|
||||
|
||||
查询超级表下记录总条数:
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters;
|
||||
```
|
||||
|
||||
查询 1 亿条记录的平均值、最大值、最小值等:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters;
|
||||
```
|
||||
|
||||
查询 location="California.SanFrancisco" 的记录总条数:
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters where location="California.SanFrancisco";
|
||||
```
|
||||
|
||||
查询 groupId=10 的所有记录的平均值、最大值、最小值等:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
|
||||
```
|
||||
|
||||
对表 d10 按 10s 进行平均值、最大值和最小值聚合统计:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
|
||||
```
|
|
@ -1,19 +1,19 @@
|
|||
`apt-get` can be used to install TDengine from official package repository.
|
||||
可以使用 apt-get 工具从官方仓库安装。
|
||||
|
||||
**Package Repository**
|
||||
**安装包仓库**
|
||||
|
||||
```
|
||||
wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
|
||||
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-stable stable main" | sudo tee /etc/apt/sources.list.d/tdengine-stable.list
|
||||
```
|
||||
|
||||
The repository required for installing beta versions can be configured as below:
|
||||
如果安装 Beta 版需要安装包仓库
|
||||
|
||||
```
|
||||
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list
|
||||
```
|
||||
|
||||
**Install With apt-get**
|
||||
**使用 apt-get 命令安装**
|
||||
|
||||
```
|
||||
sudo apt-get update
|
||||
|
@ -22,5 +22,5 @@ sudo apt-get install tdengine
|
|||
```
|
||||
|
||||
:::tip
|
||||
`apt-get` can only be used on Debian or Ubuntu Linux.
|
||||
apt-get 方式只适用于 Debian 或 Ubuntu 系统
|
||||
::::
|
||||
|
|
|
@ -1 +1 @@
|
|||
label: Get Started
|
||||
label: 立即开始
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import PkgList from "/components/PkgList";
|
||||
|
||||
It's very easy to install TDengine and would take you only a few minutes from downloading to finishing installation.
|
||||
TDengine 的安装非常简单,从下载到安装成功仅仅只要几秒钟。
|
||||
|
||||
For the convenience of users, from version 2.4.0.10, the standard server side installation package includes `taos`, `taosd`, `taosAdapter`, `taosBenchmark` and sample code. If only the `taosd` server and C/C++ connector are required, you can also choose to download the lite package.
|
||||
为方便使用,从 2.4.0.10 开始,标准的服务端安装包包含了 taos、taosd、taosAdapter、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码;如果您只需要用到服务端程序和客户端连接的 C/C++ 语言支持,也可以仅下载 lite 版本的安装包。
|
||||
|
||||
Three kinds of packages are provided, tar.gz, rpm and deb. Especially the tar.gz package is provided for the convenience of enterprise customers on different kinds of operating systems, it includes `taosdump` and TDinsight installation script which are normally only provided in taos-tools rpm and deb packages.
|
||||
在安装包格式上,我们提供 tar.gz, rpm 和 deb 格式,为企业客户提供 tar.gz 格式安装包,以方便在特定操作系统上使用。需要注意的是,rpm 和 deb 包不含 taosdump、taosBenchmark 和 TDinsight 安装脚本,这些工具需要通过安装 taosTool 包获得。
|
||||
|
||||
Between two major release versions, some beta versions may be delivered for users to try some new features.
|
||||
发布版本包括稳定版和 Beta 版,Beta 版含有更多新功能。正式上线或测试建议安装稳定版。您可以根据需要选择下载:
|
||||
|
||||
<PkgList type={0}/>
|
||||
|
||||
For the details please refer to [Install and Uninstall](/operation/pkg-install)。
|
||||
|
||||
To see the details of versions, please refer to [Download List](https://tdengine.com/all-downloads) and [Release Notes](https://github.com/taosdata/TDengine/releases).
|
||||
具体的安装方法,请参见[安装包的安装和卸载](/operation/pkg-install)。
|
||||
|
||||
下载其他组件、最新 Beta 版及之前版本的安装包,请点击[这里](https://www.taosdata.com/all-downloads)
|
||||
|
||||
查看 Release Notes, 请点击[这里](https://github.com/taosdata/TDengine/releases)
|
||||
|
|
|
@ -1,171 +1,15 @@
|
|||
---
|
||||
title: Get Started
|
||||
description: 'Install TDengine from Docker image, apt-get or package, and run TDengine CLI and taosBenchmark to experience the features'
|
||||
title: 立即开始
|
||||
description: '快速设置 TDengine 环境并体验其高效写入和查询'
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
import PkgInstall from "./\_pkg_install.mdx";
|
||||
import AptGetInstall from "./\_apt_get_install.mdx";
|
||||
TDengine 完整的软件包包括服务端(taosd)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、应用驱动(taosc)、命令行程序 (CLI,taos) 和一些工具软件。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](/reference/taosadapter) 提供 [RESTful 接口](/reference/rest-api)。
|
||||
|
||||
## Quick Install
|
||||
本章主要介绍如何利用 Docker 或者安装包快速设置 TDengine 环境并体验其高效写入和查询。
|
||||
|
||||
The full package of TDengine includes the server(taosd), taosAdapter for connecting with third-party systems and providing a RESTful interface, client driver(taosc), command-line program(CLI, taos) and some tools. For the current version, the server taosd and taosAdapter can only be installed and run on Linux systems. In the future taosd and taosAdapter will also be supported on Windows, macOS and other systems. The client driver taosc and TDengine CLI can be installed and run on Windows or Linux. In addition to connectors for multiple languages, TDengine also provides a [RESTful interface](/reference/rest-api) through [taosAdapter](/reference/taosadapter). Prior to version 2.4.0.0, taosAdapter did not exist and the RESTful interface was provided by the built-in HTTP service of taosd.
|
||||
```mdx-code-block
|
||||
import DocCardList from '@theme/DocCardList';
|
||||
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
||||
|
||||
TDengine supports X64/ARM64/MIPS64/Alpha64 hardware platforms, and will support ARM32, RISC-V and other CPU architectures in the future.
|
||||
|
||||
<Tabs defaultValue="apt-get">
|
||||
<TabItem value="docker" label="Docker">
|
||||
If docker is already installed on your computer, execute the following command:
|
||||
|
||||
```shell
|
||||
docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine
|
||||
```
|
||||
|
||||
Make sure the container is running
|
||||
|
||||
```shell
|
||||
docker ps
|
||||
```
|
||||
|
||||
Enter into container and execute bash
|
||||
|
||||
```shell
|
||||
docker exec -it <container name> bash
|
||||
```
|
||||
|
||||
Then you can execute the Linux commands and access TDengine.
|
||||
|
||||
For detailed steps, please visit [Experience TDengine via Docker](/train-faq/docker)。
|
||||
|
||||
:::info
|
||||
Starting from 2.4.0.10,besides taosd,TDengine docker image includes: taos,taosAdapter,taosdump,taosBenchmark,TDinsight, scripts and sample code. Once the TDengine container is started,it will start both taosAdapter and taosd automatically to support RESTful interface.
|
||||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="apt-get" label="apt-get">
|
||||
<AptGetInstall />
|
||||
</TabItem>
|
||||
<TabItem value="pkg" label="Package">
|
||||
<PkgInstall />
|
||||
</TabItem>
|
||||
<TabItem value="src" label="Source Code">
|
||||
|
||||
If you like to check the source code, build the package by yourself or contribute to the project, please check [TDengine GitHub Repository](https://github.com/taosdata/TDengine)
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Quick Launch
|
||||
|
||||
After installation, you can launch the TDengine service by the 'systemctl' command to start 'taosd'.
|
||||
|
||||
```bash
|
||||
systemctl start taosd
|
||||
```
|
||||
|
||||
Check if taosd is running:
|
||||
|
||||
```bash
|
||||
systemctl status taosd
|
||||
```
|
||||
|
||||
If everything is fine, you can run TDengine command-line interface `taos` to access TDengine and test it out yourself.
|
||||
|
||||
:::info
|
||||
|
||||
- systemctl requires _root_ privileges,if you are not _root_ ,please add sudo before the command.
|
||||
- To get feedback and keep improving the product, TDengine is collecting some basic usage information, but you can turn it off by setting telemetryReporting to 0 in configuration file taos.cfg.
|
||||
- TDengine uses FQDN (usually hostname)as the ID for a node. To make the system work, you need to configure the FQDN for the server running taosd, and configure the DNS service or hosts file on the the machine where the application or TDengine CLI runs to ensure that the FQDN can be resolved.
|
||||
- `systemctl stop taosd` won't stop the server right away, it will wait until all the data in memory are flushed to disk. It may takes time depending on the cache size.
|
||||
|
||||
TDengine supports the installation on system which runs [`systemd`](https://en.wikipedia.org/wiki/Systemd) for process management,use `which systemctl` to check if the system has `systemd` installed:
|
||||
|
||||
```bash
|
||||
which systemctl
|
||||
```
|
||||
|
||||
If the system does not have `systemd`,you can start TDengine manually by executing `/usr/local/taos/bin/taosd`
|
||||
|
||||
:::note
|
||||
|
||||
## Command Line Interface
|
||||
|
||||
To manage the TDengine running instance,or execute ad-hoc queries, TDengine provides a Command Line Interface (hereinafter referred to as TDengine CLI) taos. To enter into the interactive CLI,execute `taos` on a Linux terminal where TDengine is installed.
|
||||
|
||||
```bash
|
||||
taos
|
||||
```
|
||||
|
||||
If it connects to the TDengine server successfully, it will print out the version and welcome message. If it fails, it will print out the error message, please check [FAQ](/train-faq/faq) for trouble shooting connection issue. TDengine CLI's prompt is:
|
||||
|
||||
```cmd
|
||||
taos>
|
||||
```
|
||||
|
||||
Inside TDengine CLI,you can execute SQL commands to create/drop database/table, and run queries. The SQL command must be ended with a semicolon. For example:
|
||||
|
||||
```sql
|
||||
create database demo;
|
||||
use demo;
|
||||
create table t (ts timestamp, speed int);
|
||||
insert into t values ('2019-07-15 00:00:00', 10);
|
||||
insert into t values ('2019-07-15 01:00:00', 20);
|
||||
select * from t;
|
||||
ts | speed |
|
||||
========================================
|
||||
2019-07-15 00:00:00.000 | 10 |
|
||||
2019-07-15 01:00:00.000 | 20 |
|
||||
Query OK, 2 row(s) in set (0.003128s)
|
||||
```
|
||||
|
||||
Besides executing SQL commands, system administrators can check running status, add/drop user accounts and manage the running instances. TDengine CLI with client driver can be installed and run on either Linux or Windows machines. For more details on CLI, please [check here](../reference/taos-shell/).
|
||||
|
||||
## Experience the blazing fast speed
|
||||
|
||||
After TDengine server is running,execute `taosBenchmark` (previously named taosdemo) from a Linux terminal:
|
||||
|
||||
```bash
|
||||
taosBenchmark
|
||||
```
|
||||
|
||||
This command will create a super table "meters" under database "test". Under "meters", 10000 tables are created with names from "d0" to "d9999". Each table has 10000 rows and each row has four columns (ts, current, voltage, phase). Time stamp is starting from "2017-07-14 10:40:00 000" to "2017-07-14 10:40:09 999". Each table has tags "location" and "groupId". groupId is set 1 to 10 randomly, and location is set to "California.SanFrancisco" or "California.SanDiego".
|
||||
|
||||
This command will insert 100 million rows into the database quickly. Time to insert depends on the hardware configuration, it only takes a dozen seconds for a regular PC server.
|
||||
|
||||
taosBenchmark provides command-line options and a configuration file to customize the scenarios, like number of tables, number of rows per table, number of columns and more. Please execute `taosBenchmark --help` to list them. For details on running taosBenchmark, please check [reference for taosBenchmark](/reference/taosbenchmark)
|
||||
|
||||
## Experience query speed
|
||||
|
||||
After using taosBenchmark to insert a number of rows data, you can execute queries from TDengine CLI to experience the lightning fast query speed.
|
||||
|
||||
query the total number of rows under super table "meters":
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters;
|
||||
```
|
||||
|
||||
query the average, maximum, minimum of 100 million rows:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters;
|
||||
```
|
||||
|
||||
query the total number of rows with location="California.SanFrancisco":
|
||||
|
||||
```sql
|
||||
taos> select count(*) from test.meters where location="California.SanFrancisco";
|
||||
```
|
||||
|
||||
query the average, maximum, minimum of all rows with groupId=10:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
|
||||
```
|
||||
|
||||
query the average, maximum, minimum for table d10 in 10 seconds time interval:
|
||||
|
||||
```sql
|
||||
taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
|
||||
<DocCardList items={useCurrentSidebarCategory().items}/>
|
||||
```
|
|
@ -55,9 +55,6 @@ For more details please refer to [InfluxDB Line Protocol](https://docs.influxdat
|
|||
<TabItem label="Go" value="go">
|
||||
<GoLine />
|
||||
</TabItem>
|
||||
<TabItem label="Rust" value="rust">
|
||||
<RustLine />
|
||||
</TabItem>
|
||||
<TabItem label="Node.js" value="nodejs">
|
||||
<NodeLine />
|
||||
</TabItem>
|
||||
|
|
|
@ -46,9 +46,6 @@ Please refer to [OpenTSDB Telnet API](http://opentsdb.net/docs/build/html/api_te
|
|||
<TabItem label="Go" value="go">
|
||||
<GoTelnet />
|
||||
</TabItem>
|
||||
<TabItem label="Rust" value="rust">
|
||||
<RustTelnet />
|
||||
</TabItem>
|
||||
<TabItem label="Node.js" value="nodejs">
|
||||
<NodeTelnet />
|
||||
</TabItem>
|
||||
|
|
|
@ -63,9 +63,6 @@ Please refer to [OpenTSDB HTTP API](http://opentsdb.net/docs/build/html/api_http
|
|||
<TabItem label="Go" value="go">
|
||||
<GoJson />
|
||||
</TabItem>
|
||||
<TabItem label="Rust" value="rust">
|
||||
<RustJson />
|
||||
</TabItem>
|
||||
<TabItem label="Node.js" value="nodejs">
|
||||
<NodeJson />
|
||||
</TabItem>
|
||||
|
|
|
@ -10,7 +10,7 @@ TDengine 充分利用了时序数据的特点,提出了“一个数据采集
|
|||
|
||||
如果你是开发者,请一定仔细阅读[开发指南](./develop)一章,该部分对数据库连接、建模、插入数据、查询、流式计算、缓存、数据订阅、用户自定义函数等功能都做了详细介绍,并配有各种编程语言的示例代码。大部分情况下,你只要把示例代码拷贝粘贴,针对自己的应用稍作改动,就能跑起来。
|
||||
|
||||
我们已经生活在大数据的时代,纵向扩展已经无法满足日益增长的业务需求,任何系统都必须具有水平扩展的能力,集群成为大数据以及 database 系统的不可缺失功能。TDengine 团队不仅实现了集群功能,而且将这一重要核心功能开源。怎么部署、管理和维护 TDengine 集群,请参考[集群管理](./cluster)一章。
|
||||
我们已经生活在大数据的时代,纵向扩展已经无法满足日益增长的业务需求,任何系统都必须具有水平扩展的能力,集群成为大数据以及 database 系统的不可缺失功能。TDengine 团队不仅实现了集群功能,而且将这一重要核心功能开源。怎么部署、管理和维护 TDengine 集群,请参考[部署集群](./deployment)一章。
|
||||
|
||||
TDengine 采用 SQL 作为其查询语言,大大降低学习成本、降低迁移成本,但同时针对时序数据场景,又做了一些扩展,以支持插值、降采样、时间加权平均等操作。[SQL 手册](./taos-sql)一章详细描述了 SQL 语法、详细列出了各种支持的命令和函数。
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ title: 产品简介
|
|||
toc_max_heading_level: 2
|
||||
---
|
||||
|
||||
TDengine 是一款[开源](https://www.taosdata.com/tdengine/open_source_time-series_database)、[高性能](https://www.taosdata.com/tdengine/fast)、[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)的时序数据库 (Time-Series Database, TSDB)。TDengine 能被广泛运用于物联网、工业互联网、车联网、IT 运维、金融等领域。除核心的时序数据库功能外,TDengine 还提供[缓存](/develop/cache/)、[数据订阅](/develop/subscribe)、[流式计算](/develop/continuous-query)等功能,是一极简的时序数据处理平台,最大程度的减小系统设计的复杂度,降低研发和运营成本。
|
||||
TDengine 是一款[开源](https://www.taosdata.com/tdengine/open_source_time-series_database)、[高性能](https://www.taosdata.com/tdengine/fast)、[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)的时序数据库 (Time-Series Database, TSDB)。TDengine 能被广泛运用于物联网、工业互联网、车联网、IT 运维、金融等领域。除核心的时序数据库功能外,TDengine 还提供[缓存](../develop/cache/)、[数据订阅](../develop/tmq)、[流式计算](../develop/stream)等功能,是一极简的时序数据处理平台,最大程度的减小系统设计的复杂度,降低研发和运营成本。
|
||||
|
||||
本章节介绍TDengine的主要功能、竞争优势、适用场景、与其他数据库的对比测试等等,让大家对TDengine有个整体的了解。
|
||||
|
||||
|
@ -11,21 +11,22 @@ TDengine 是一款[开源](https://www.taosdata.com/tdengine/open_source_time-se
|
|||
|
||||
TDengine的主要功能如下:
|
||||
|
||||
1. 高速数据写入,除 [SQL 写入](/develop/insert-data/sql-writing)外,还支持 [Schemaless 写入](/reference/schemaless/),支持 [InfluxDB LINE 协议](/develop/insert-data/influxdb-line),[OpenTSDB Telnet](/develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](/develop/insert-data/opentsdb-json)等协议写入;
|
||||
2. 第三方数据采集工具 [Telegraf](/third-party/telegraf),[Prometheus](/third-party/prometheus),[StatsD](/third-party/statsd),[collectd](/third-party/collectd),[icinga2](/third-party/icinga2), [TCollector](/third-party/tcollector), [EMQ](/third-party/emq-broker), [HiveMQ](/third-party/hive-mq-broker) 等都可以进行配置后,不用任何代码,即可将数据写入;
|
||||
3. 支持[各种查询](/develop/query-data),包括聚合查询、嵌套查询、降采样查询、插值等
|
||||
4. 支持[用户自定义函数](/develop/udf)
|
||||
5. 支持[缓存](/develop/cache),将每张表的最后一条记录缓存起来,这样无需 Redis
|
||||
6. 支持[流式计算](/develop/continuous-query)(Stream Processing)
|
||||
7. 支持[数据订阅](/develop/subscribe),而且可以指定过滤条件
|
||||
8. 支持[集群](/cluster/),可以通过多节点进行水平扩展,并通过多副本实现高可靠
|
||||
9. 提供[命令行程序](/reference/taos-shell),便于管理集群,检查系统状态,做即席查询
|
||||
10. 提供多种数据的[导入](/operation/import)、[导出](/operation/export)
|
||||
11. 支持对[TDengine 集群本身的监控](/operation/monitor)
|
||||
12. 提供 [C/C++](/reference/connector/cpp), [Java](/reference/connector/java), [Python](/reference/connector/python), [Go](/reference/connector/go), [Rust](/reference/connector/rust), [Node.js](/reference/connector/node) 等多种编程语言的[连接器](/reference/connector/)
|
||||
13. 支持 [REST 接口](/reference/rest-api/)
|
||||
14. 支持与[ Grafana 无缝集成](/third-party/grafana)
|
||||
1. 高速数据写入,除 [SQL 写入](../develop/insert-data/sql-writing)外,还支持 [Schemaless 写入](../reference/schemaless/),支持 [InfluxDB LINE 协议](../develop/insert-data/influxdb-line),[OpenTSDB Telnet](../develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](../develop/insert-data/opentsdb-json)等协议写入;
|
||||
2. 第三方数据采集工具 [Telegraf](../third-party/telegraf),[Prometheus](../third-party/prometheus),[StatsD](../third-party/statsd),[collectd](../third-party/collectd),[icinga2](../third-party/icinga2), [TCollector](../third-party/tcollector), [EMQ](../third-party/emq-broker), [HiveMQ](../third-party/hive-mq-broker) 等都可以进行配置后,不用任何代码,即可将数据写入;
|
||||
3. 支持[各种查询](../develop/query-data),包括聚合查询、嵌套查询、降采样查询、插值等
|
||||
4. 支持[用户自定义函数](../develop/udf)
|
||||
5. 支持[缓存](../develop/cache),将每张表的最后一条记录缓存起来,这样无需 Redis
|
||||
6. 支持[流式计算](../develop/stream)(Stream Processing)
|
||||
7. 支持[数据订阅](../develop/tmq),而且可以指定过滤条件
|
||||
8. 支持[集群](../deployment/),可以通过多节点进行水平扩展,并通过多副本实现高可靠
|
||||
9. 提供[命令行程序](../reference/taos-shell),便于管理集群,检查系统状态,做即席查询
|
||||
10. 提供多种数据的[导入](../operation/import)、[导出](../operation/export)
|
||||
11. 支持对[TDengine 集群本身的监控](../operation/monitor)
|
||||
12. 提供 [C/C++](../reference/connector/cpp), [Java](../reference/connector/java), [Python](../reference/connector/python), [Go](../reference/connector/go), [Rust](../reference/connector/rust), [Node.js](../reference/connector/node) 等多种编程语言的[连接器](../reference/connector/)
|
||||
13. 支持 [REST 接口](../reference/rest-api/)
|
||||
14. 支持与[ Grafana 无缝集成](../third-party/grafana)
|
||||
15. 支持与 Google Data Studio 无缝集成
|
||||
16. 支持 [Kubernetes 部署](../deployment/k8s)
|
||||
|
||||
更多细小的功能,请阅读整个文档。
|
||||
|
||||
|
|
|
@ -51,10 +51,6 @@ Docker version 20.10.3, build 48d30b5
|
|||
|
||||
```
|
||||
$ taos
|
||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
Server is Community Edition.
|
||||
|
||||
taos>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import TabItem from "@theme/TabItem";
|
|||
|
||||
:::
|
||||
|
||||
TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包,也支持通过 `apt-get` 工具从线上进行安装。
|
||||
在 Linux 系统上,TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包,也支持通过 `apt-get` 工具从线上进行安装。TDengine 也提供 Windows x64 平台的安装包。
|
||||
|
||||
## 安装
|
||||
|
||||
|
@ -21,20 +21,20 @@ TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自
|
|||
|
||||
**安装包仓库**
|
||||
|
||||
```
|
||||
```bash
|
||||
wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
|
||||
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-stable stable main" | sudo tee /etc/apt/sources.list.d/tdengine-stable.list
|
||||
```
|
||||
|
||||
如果安装 Beta 版需要安装包仓库
|
||||
|
||||
```
|
||||
```bash
|
||||
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list
|
||||
```
|
||||
|
||||
**使用 apt-get 命令安装**
|
||||
|
||||
```
|
||||
```bash
|
||||
sudo apt-get update
|
||||
apt-cache policy tdengine
|
||||
sudo apt-get install tdengine
|
||||
|
@ -46,122 +46,39 @@ apt-get 方式只适用于 Debian 或 Ubuntu 系统
|
|||
</TabItem>
|
||||
<TabItem label="Deb 安装" value="debinst">
|
||||
|
||||
1、从官网下载获得 deb 安装包,例如 TDengine-server-3.0.0.10002-Linux-x64.deb;
|
||||
2、进入到 TDengine-server-3.0.0.10002-Linux-x64.deb 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
```
|
||||
$ sudo dpkg -i TDengine-server-3.0.0.10002-Linux-x64.deb
|
||||
Selecting previously unselected package tdengine.
|
||||
(Reading database ... 119653 files and directories currently installed.)
|
||||
Preparing to unpack TDengine-server-3.0.0.10002-Linux-x64.deb ...
|
||||
Unpacking tdengine (3.0.0.10002) ...
|
||||
Setting up tdengine (3.0.0.10002) ...
|
||||
Start to install TDengine...
|
||||
|
||||
System hostname is: v3cluster-0002
|
||||
|
||||
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
||||
OR leave it blank to build one:
|
||||
|
||||
Enter your email address for priority support or enter empty to skip:
|
||||
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To start TDengine : sudo systemctl start taosd
|
||||
To access TDengine : taos -h v3cluster-0002 to login into TDengine server
|
||||
|
||||
|
||||
TDengine is installed successfully!
|
||||
1、从官网下载获得 deb 安装包,例如 TDengine-server-3.0.0.0-Linux-x64.deb;
|
||||
2、进入到 TDengine-server-3.0.0.0-Linux-x64.deb 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
```bash
|
||||
sudo dpkg -i TDengine-server-3.0.0.0-Linux-x64.deb
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="RPM 安装" value="rpminst">
|
||||
|
||||
1、从官网下载获得 rpm 安装包,例如 TDengine-server-3.0.0.10002-Linux-x64.rpm;
|
||||
2、进入到 TDengine-server-3.0.0.10002-Linux-x64.rpm 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
```
|
||||
$ sudo rpm -ivh TDengine-server-3.0.0.10002-Linux-x64.rpm
|
||||
Preparing... ################################# [100%]
|
||||
Stop taosd service success!
|
||||
Updating / installing...
|
||||
1:tdengine-3.0.0.10002-3 ################################# [100%]
|
||||
Start to install TDengine...
|
||||
|
||||
System hostname is: chenhaoran01
|
||||
|
||||
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
||||
OR leave it blank to build one:
|
||||
|
||||
Enter your email address for priority support or enter empty to skip:
|
||||
Created symlink from /etc/systemd/system/multi-user.target.wants/taosd.service to /etc/systemd/system/taosd.service.
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To start TDengine : sudo systemctl start taosd
|
||||
To access TDengine : taos -h chenhaoran01 to login into TDengine server
|
||||
|
||||
|
||||
TDengine is installed successfully!
|
||||
1、从官网下载获得 rpm 安装包,例如 TDengine-server-3.0.0.0-Linux-x64.rpm;
|
||||
2、进入到 TDengine-server-3.0.0.0-Linux-x64.rpm 安装包所在目录,执行如下的安装命令:
|
||||
|
||||
```bash
|
||||
sudo rpm -ivh TDengine-server-3.0.0.0-Linux-x64.rpm
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="tar.gz 安装" value="tarinst">
|
||||
|
||||
1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-3.0.0.10002-Linux-x64.tar.gz;
|
||||
2、进入到 TDengine-server-3.0.0.10002-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本:
|
||||
1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-3.0.0.0-Linux-x64.tar.gz;
|
||||
2、进入到 TDengine-server-3.0.0.0-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本:
|
||||
|
||||
```bash
|
||||
tar -zxvf TDengine-server-3.0.0.0-Linux-x64.tar.gz
|
||||
```
|
||||
$ tar -zxvf TDengine-server-3.0.0.10002-Linux-x64.tar.gz
|
||||
TDengine-server-3.0.0.10002/
|
||||
TDengine-server-3.0.0.10002/driver/
|
||||
TDengine-server-3.0.0.10002/driver/libtaos.so.3.0.0.10002
|
||||
TDengine-server-3.0.0.10002/driver/vercomp.txt
|
||||
TDengine-server-3.0.0.10002/release_note
|
||||
TDengine-server-3.0.0.10002/taos.tar.gz
|
||||
TDengine-server-3.0.0.10002/install.sh
|
||||
...
|
||||
|
||||
$ ll
|
||||
total 56832
|
||||
drwxr-xr-x 3 root root 4096 Aug 8 10:29 ./
|
||||
drwxrwxrwx 6 root root 4096 Aug 5 16:45 ../
|
||||
drwxr-xr-x 4 root root 4096 Aug 4 18:03 TDengine-server-3.0.0.10002/
|
||||
-rwxr-xr-x 1 root root 58183066 Aug 8 10:28 TDengine-server-3.0.0.10002-Linux-x64.tar.gz*
|
||||
解压后进入相应路径,执行
|
||||
|
||||
$ cd TDengine-server-3.0.0.10002/
|
||||
|
||||
$ ll
|
||||
total 51612
|
||||
drwxr-xr-x 4 root root 4096 Aug 4 18:03 ./
|
||||
drwxr-xr-x 3 root root 4096 Aug 8 10:29 ../
|
||||
drwxr-xr-x 2 root root 4096 Aug 4 18:03 driver/
|
||||
drwxr-xr-x 11 root root 4096 Aug 4 18:03 examples/
|
||||
-rwxr-xr-x 1 root root 30980 Aug 4 18:03 install.sh*
|
||||
-rw-r--r-- 1 root root 6724 Aug 4 18:03 release_note
|
||||
-rw-r--r-- 1 root root 52793079 Aug 4 18:03 taos.tar.gz
|
||||
|
||||
$ sudo ./install.sh
|
||||
|
||||
Start to install TDengine...
|
||||
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
|
||||
|
||||
System hostname is: v3cluster-0002
|
||||
|
||||
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
|
||||
OR leave it blank to build one:
|
||||
|
||||
Enter your email address for priority support or enter empty to skip:
|
||||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To configure taosadapter (if has) : edit /etc/taos/taosadapter.toml
|
||||
To start TDengine : sudo systemctl start taosd
|
||||
To access TDengine : taos -h v3cluster-0002 to login into TDengine server
|
||||
|
||||
TDengine is installed successfully!
|
||||
```bash
|
||||
sudo ./install.sh
|
||||
```
|
||||
|
||||
:::info
|
||||
|
@ -169,6 +86,11 @@ install.sh 安装脚本在执行过程中,会通过命令行交互界面询问
|
|||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Windows 安装" value="windows">
|
||||
TODO
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -179,6 +101,9 @@ install.sh 安装脚本在执行过程中,会通过命令行交互界面询问
|
|||
|
||||
## 启动
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="Linux 系统" value="linux">
|
||||
|
||||
安装后,请使用 `systemctl` 命令来启动 TDengine 的服务进程。
|
||||
|
||||
```bash
|
||||
|
@ -223,6 +148,15 @@ systemctl 命令汇总:
|
|||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Windows 系统" value="windows">
|
||||
|
||||
TODO
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## TDengine 命令行 (CLI)
|
||||
|
||||
为便于检查 TDengine 的状态,执行数据库 (Database) 的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI) taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可。
|
||||
|
|
|
@ -54,9 +54,6 @@ meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0
|
|||
<TabItem label="Go" value="go">
|
||||
<GoLine />
|
||||
</TabItem>
|
||||
<TabItem label="Rust" value="rust">
|
||||
<RustLine />
|
||||
</TabItem>
|
||||
<TabItem label="Node.js" value="nodejs">
|
||||
<NodeLine />
|
||||
</TabItem>
|
||||
|
|
|
@ -46,9 +46,6 @@ meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3
|
|||
<TabItem label="Go" value="go">
|
||||
<GoTelnet />
|
||||
</TabItem>
|
||||
<TabItem label="Rust" value="rust">
|
||||
<RustTelnet />
|
||||
</TabItem>
|
||||
<TabItem label="Node.js" value="nodejs">
|
||||
<NodeTelnet />
|
||||
</TabItem>
|
||||
|
|
|
@ -63,9 +63,6 @@ OpenTSDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据
|
|||
<TabItem label="Go" value="go">
|
||||
<GoJson />
|
||||
</TabItem>
|
||||
<TabItem label="Rust" value="rust">
|
||||
<RustJson />
|
||||
</TabItem>
|
||||
<TabItem label="Node.js" value="nodejs">
|
||||
<NodeJson />
|
||||
</TabItem>
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
```rust
|
||||
{{#include docs/examples/rust/schemalessexample/examples/influxdb_line_example.rs}}
|
||||
```
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
```rust
|
||||
{{#include docs/examples/rust/schemalessexample/examples/opentsdb_json_example.rs}}
|
||||
```
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
```rust
|
||||
{{#include docs/examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}}
|
||||
```
|
||||
|
|
|
@ -4,11 +4,11 @@ title: UDF(用户定义函数)
|
|||
description: "支持用户编码的聚合函数和标量函数,在查询中嵌入并使用用户定义函数,拓展查询的能力和功能。"
|
||||
---
|
||||
|
||||
在有些应用场景中,应用逻辑需要的查询无法直接使用系统内置的函数来表示。利用 UDF 功能,TDengine 可以插入用户编写的处理代码并在查询中使用它们,就能够很方便地解决特殊应用场景中的使用需求。 UDF 通常以数据表中的一列数据做为输入,同时支持以嵌套子查询的结果作为输入。
|
||||
在有些应用场景中,应用逻辑需要的查询无法直接使用系统内置的函数来表示。利用 UDF(User Defined Function) 功能,TDengine 可以插入用户编写的处理代码并在查询中使用它们,就能够很方便地解决特殊应用场景中的使用需求。 UDF 通常以数据表中的一列数据做为输入,同时支持以嵌套子查询的结果作为输入。
|
||||
|
||||
TDengine 支持通过 C/C++ 语言进行 UDF 定义。接下来结合示例讲解 UDF 的使用方法。
|
||||
|
||||
用户可以通过 UDF 实现两类函数: 标量函数和聚合函数。标量函数对每行数据返回一个值,如求绝对值 abs,正弦函数 sin,字符串拼接函数 concat 等。聚合函数对多行数据进行返回一个值,如求平均数 avg,最大值 max 等。
|
||||
用户可以通过 UDF 实现两类函数:标量函数和聚合函数。标量函数对每行数据输出一个值,如求绝对值 abs,正弦函数 sin,字符串拼接函数 concat 等。聚合函数对多行数据进行输出一个值,如求平均数 avg,最大值 max 等。
|
||||
|
||||
实现 UDF 时,需要实现规定的接口函数
|
||||
- 标量函数需要实现标量接口函数 scalarfn 。
|
||||
|
@ -104,7 +104,7 @@ aggfn为函数名的占位符,需要修改为自己的函数名,如l2norm。
|
|||
|
||||
接口函数的名称是 udf 名称,或者是 udf 名称和特定后缀(_start, _finish, _init, _destroy)的连接。以下描述中函数名称中的 scalarfn,aggfn, udf 需要替换成udf函数名。
|
||||
|
||||
接口函数返回值表示是否成功,如果错误返回错误代码,错误代码见taoserror.h。
|
||||
接口函数返回值表示是否成功。如果返回值是 TSDB_CODE_SUCCESS,表示操作成功,否则返回的是错误代码。错误代码定义在 taoserror.h,和 taos.h 中的API共享错误码的定义。例如, TSDB_CODE_UDF_INVALID_INPUT 表示输入无效输入。TSDB_CODE_OUT_OF_MEMORY 表示内存不足。
|
||||
|
||||
接口函数参数类型见数据结构定义。
|
||||
|
||||
|
@ -214,7 +214,7 @@ gcc -g -O0 -fPIC -shared add_one.c -o add_one.so
|
|||
这样就准备好了动态链接库 add_one.so 文件,可以供后文创建 UDF 时使用了。为了保证可靠的系统运行,编译器 GCC 推荐使用 7.5 及以上版本。
|
||||
|
||||
## 管理和使用UDF
|
||||
关于如何管理和使用UDF,参见[UDF使用说明](../12-taos-sql/26-udf.md)
|
||||
编译好的UDF,还需要将其加入到系统才能被正常的SQL调用。关于如何管理和使用UDF,参见[UDF使用说明](../12-taos-sql/26-udf.md)
|
||||
|
||||
## 示例代码
|
||||
|
||||
|
|
|
@ -73,11 +73,6 @@ serverPort 6030
|
|||
按照《立即开始》里的步骤,启动第一个数据节点,例如 h1.taosdata.com,然后执行 taos,启动 taos shell,从 shell 里执行命令“SHOW DNODES”,如下所示:
|
||||
|
||||
```
|
||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
Server is Enterprise trial Edition, ver:3.0.0.0 and will never expire.
|
||||
|
||||
taos> show dnodes;
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||
============================================================================================================================================
|
||||
|
|
|
@ -3,11 +3,20 @@ sidebar_label: Kubernetes
|
|||
title: 在 Kubernetes 上部署 TDengine 集群
|
||||
---
|
||||
|
||||
以下配置文件可以从 [GitHub 仓库](https://github.com/taosdata/TDengine-Operator/tree/3.0/src/tdengine) 下载。
|
||||
作为面向云原生架构设计的时序数据库,TDengine 支持 Kubernetes 部署。这里介绍如何使用 YAML 文件一步一步从头创建一个 TDengine 集群,并重点介绍 Kubernetes 环境下 TDengine 的常用操作。
|
||||
|
||||
## 前置条件
|
||||
|
||||
要使用 Kubernetes 部署管理 TDengine 集群,需要做好如下准备工作。
|
||||
|
||||
* 本文和下一章使用 minikube、kubectl 和 helm 等工具进行安装部署,请提前安装好相应软件
|
||||
* Kubernetes 已经安装部署并能正常访问使用或更新必要的容器仓库或其他服务
|
||||
|
||||
以下配置文件也可以从 [GitHub 仓库](https://github.com/taosdata/TDengine-Operator/tree/3.0/src/tdengine) 下载。
|
||||
|
||||
## 配置 Service 服务
|
||||
|
||||
创建一个 Service 配置文件:`taosd-service.yaml`,服务名称 `metadata.name` (此处为 "taosd") 将在下一步中使用到。添加 TDengine 所用到的所有端口:
|
||||
创建一个 Service 配置文件:`taosd-service.yaml`,服务名称 `metadata.name` (此处为 "taosd") 将在下一步中使用到。添加 TDengine 所用到的端口:
|
||||
|
||||
```yaml
|
||||
---
|
||||
|
@ -31,7 +40,8 @@ spec:
|
|||
|
||||
## 有状态服务 StatefulSet
|
||||
|
||||
根据 Kubernetes 对各类部署的说明,我们将使用 StatefulSet 作为 TDengine 的服务类型,创建文件 `tdengine.yaml`:
|
||||
根据 Kubernetes 对各类部署的说明,我们将使用 StatefulSet 作为 TDengine 的服务类型。
|
||||
创建文件 `tdengine.yaml`,其中 replicas 定义集群节点的数量为 3。节点时区为中国(Asia/Shanghai),每个节点分配 10G 标准(standard)存储。你也可以根据实际情况进行相应修改。
|
||||
|
||||
```yaml
|
||||
---
|
||||
|
@ -43,7 +53,7 @@ metadata:
|
|||
app: "tdengine"
|
||||
spec:
|
||||
serviceName: "taosd"
|
||||
replicas: 2
|
||||
replicas: 3
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
selector:
|
||||
|
@ -58,10 +68,7 @@ spec:
|
|||
containers:
|
||||
- name: "tdengine"
|
||||
image: "tdengine/tdengine:3.0.0.0"
|
||||
imagePullPolicy: "Always"
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: taoscfg
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
ports:
|
||||
- name: tcp6030
|
||||
protocol: "TCP"
|
||||
|
@ -130,10 +137,9 @@ spec:
|
|||
```bash
|
||||
kubectl apply -f taosd-service.yaml
|
||||
kubectl apply -f tdengine.yaml
|
||||
|
||||
```
|
||||
|
||||
上面的配置将生成一个三节点的 TDengine 集群,dnode 是自动配置的,可以使用 show dnodes 命令查看当前集群的节点:
|
||||
上面的配置将生成一个三节点的 TDengine 集群,dnode 为自动配置,可以使用 show dnodes 命令查看当前集群的节点:
|
||||
|
||||
```bash
|
||||
kubectl exec -i -t tdengine-0 -- taos -s "show dnodes"
|
||||
|
@ -144,9 +150,6 @@ kubectl exec -i -t tdengine-2 -- taos -s "show dnodes"
|
|||
输出如下:
|
||||
|
||||
```
|
||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show dnodes
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||
============================================================================================================================================
|
||||
|
@ -224,9 +227,6 @@ kubectl exec -i -t tdengine-3 -- taos -s "show dnodes"
|
|||
扩容后的四节点 TDengine 集群的 dnode 列表:
|
||||
|
||||
```
|
||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show dnodes
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||
============================================================================================================================================
|
||||
|
@ -250,9 +250,6 @@ $ kubectl exec -i -t tdengine-0 -- taos -s "drop dnode 4"
|
|||
```bash
|
||||
$ kubectl exec -it tdengine-0 -- taos -s "show dnodes"
|
||||
|
||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show dnodes
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | note |
|
||||
============================================================================================================================================
|
||||
|
@ -303,11 +300,6 @@ tdengine-2 1/1 Running 0 12m
|
|||
tdengine-3 0/1 Running 0 7s
|
||||
it@k8s-2:~/TDengine-Operator/src/tdengine$ kubectl exec -it tdengine-0 -- taos -s "show dnodes"
|
||||
|
||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
Server is Community Edition.
|
||||
|
||||
taos> show dnodes
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
|
@ -339,11 +331,6 @@ kubectl delete configmap taoscfg
|
|||
```
|
||||
$ kubectl exec -it tdengine-0 -- taos -s "show dnodes"
|
||||
|
||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
Server is Community Edition.
|
||||
|
||||
taos> show dnodes
|
||||
id | endpoint | vnodes | support_vnodes | status | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
```text
|
||||
$ taos
|
||||
Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
Server is Community Edition.
|
||||
|
||||
taos> show databases;
|
||||
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size |
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
在 cmd 下进入到 C:\TDengine 目录下直接执行 `taos.exe`,连接到 TDengine 服务,进入到 TDengine CLI 界面,示例如下:
|
||||
|
||||
```text
|
||||
Welcome to the TDengine shell from Windows, Client Version:3.0.0.0
|
||||
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
Server is Community Edition.
|
||||
|
||||
taos> show databases;
|
||||
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size |
|
||||
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================
|
||||
|
|
|
@ -54,10 +54,11 @@ Rust 连接器仍然在快速开发中,1.0 之前无法保证其向后兼容
|
|||
taos = "*"
|
||||
```
|
||||
|
||||
<Tabs defaultValue="native">
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="native" label="仅原生连接">
|
||||
|
||||
在 `Cargo.toml` 文件中添加 [taos][taos]:
|
||||
在 `Cargo.toml` 文件中添加 [taos][taos],并启用 `native` 特性:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
|
|
|
@ -24,9 +24,6 @@ curl -u root:taosdata -d "show databases" localhost:6041/rest/sql
|
|||
```shell
|
||||
$ docker exec -it tdengine taos
|
||||
|
||||
Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
|
||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show databases;
|
||||
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
|
||||
====================================================================================================================================================================================================================================================================================
|
||||
|
@ -47,9 +44,6 @@ docker run -d --name tdengine --network host tdengine/tdengine
|
|||
```shell
|
||||
$ taos
|
||||
|
||||
Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
|
||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show dnodes;
|
||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
|
@ -353,9 +347,6 @@ password: taosdata
|
|||
```shell
|
||||
$ docker-compose exec td-1 taos -s "show dnodes"
|
||||
|
||||
Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
|
||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show dnodes
|
||||
id | end_point | vnodes | cores | status | role | create_time | offline reason |
|
||||
======================================================================================================================================
|
||||
|
|
|
@ -84,6 +84,9 @@ $ rmtaos
|
|||
TDengine is removed successfully!
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="Windows 卸载" value="windows">
|
||||
TODO
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
|
|
@ -39,9 +39,6 @@ $ echo "foo:1|c" | nc -u -w0 127.0.0.1 8125
|
|||
使用 TDengine CLI 验证从 StatsD 向 TDengine 写入数据并能够正确读出:
|
||||
|
||||
```
|
||||
Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
|
||||
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
|
||||
|
||||
taos> show databases;
|
||||
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
|
||||
====================================================================================================================================================================================================================================================================================
|
||||
|
|
|
@ -249,6 +249,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf);
|
|||
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataBlocks, STSchema* pTSchema, int32_t vgId,
|
||||
tb_uid_t suid);
|
||||
|
||||
|
||||
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
|
||||
|
||||
static FORCE_INLINE int32_t blockGetEncodeSize(const SSDataBlock* pBlock) {
|
||||
|
|
|
@ -154,7 +154,7 @@
|
|||
#define TK_ACCOUNTS 136
|
||||
#define TK_APPS 137
|
||||
#define TK_CONNECTIONS 138
|
||||
#define TK_LICENCE 139
|
||||
#define TK_LICENCES 139
|
||||
#define TK_GRANTS 140
|
||||
#define TK_QUERIES 141
|
||||
#define TK_SCORES 142
|
||||
|
@ -266,12 +266,60 @@
|
|||
#define TK_OFFSET 248
|
||||
#define TK_ASC 249
|
||||
#define TK_NULLS 250
|
||||
#define TK_ID 251
|
||||
#define TK_NK_BITNOT 252
|
||||
#define TK_VALUES 253
|
||||
#define TK_IMPORT 254
|
||||
#define TK_NK_SEMI 255
|
||||
#define TK_FILE 256
|
||||
#define TK_ABORT 251
|
||||
#define TK_AFTER 252
|
||||
#define TK_ATTACH 253
|
||||
#define TK_BEFORE 254
|
||||
#define TK_BEGIN 255
|
||||
#define TK_BITAND 256
|
||||
#define TK_BITNOT 257
|
||||
#define TK_BITOR 258
|
||||
#define TK_BLOCKS 259
|
||||
#define TK_CHANGE 260
|
||||
#define TK_COMMA 261
|
||||
#define TK_COMPACT 262
|
||||
#define TK_CONCAT 263
|
||||
#define TK_CONFLICT 264
|
||||
#define TK_COPY 265
|
||||
#define TK_DEFERRED 266
|
||||
#define TK_DELIMITERS 267
|
||||
#define TK_DETACH 268
|
||||
#define TK_DIVIDE 269
|
||||
#define TK_DOT 270
|
||||
#define TK_EACH 271
|
||||
#define TK_END 272
|
||||
#define TK_FAIL 273
|
||||
#define TK_FILE 274
|
||||
#define TK_FOR 275
|
||||
#define TK_GLOB 276
|
||||
#define TK_ID 277
|
||||
#define TK_IMMEDIATE 278
|
||||
#define TK_IMPORT 279
|
||||
#define TK_INITIALLY 280
|
||||
#define TK_INSTEAD 281
|
||||
#define TK_ISNULL 282
|
||||
#define TK_KEY 283
|
||||
#define TK_NK_BITNOT 284
|
||||
#define TK_NK_SEMI 285
|
||||
#define TK_NOTNULL 286
|
||||
#define TK_OF 287
|
||||
#define TK_PLUS 288
|
||||
#define TK_PRIVILEGE 289
|
||||
#define TK_RAISE 290
|
||||
#define TK_REPLACE 291
|
||||
#define TK_RESTRICT 292
|
||||
#define TK_ROW 293
|
||||
#define TK_SEMI 294
|
||||
#define TK_STAR 295
|
||||
#define TK_STATEMENT 296
|
||||
#define TK_STRING 297
|
||||
#define TK_TIMES 298
|
||||
#define TK_UPDATE 299
|
||||
#define TK_VALUES 300
|
||||
#define TK_VARIABLE 301
|
||||
#define TK_VIEW 302
|
||||
#define TK_VNODES 303
|
||||
#define TK_WAL 304
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -172,27 +172,24 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_SHOW_TABLES_STMT,
|
||||
QUERY_NODE_SHOW_TAGS_STMT,
|
||||
QUERY_NODE_SHOW_USERS_STMT,
|
||||
QUERY_NODE_SHOW_LICENCE_STMT,
|
||||
QUERY_NODE_SHOW_LICENCES_STMT,
|
||||
QUERY_NODE_SHOW_VGROUPS_STMT,
|
||||
QUERY_NODE_SHOW_TOPICS_STMT,
|
||||
QUERY_NODE_SHOW_CONSUMERS_STMT,
|
||||
QUERY_NODE_SHOW_SUBSCRIBES_STMT,
|
||||
QUERY_NODE_SHOW_SMAS_STMT,
|
||||
QUERY_NODE_SHOW_CONFIGS_STMT,
|
||||
QUERY_NODE_SHOW_CONNECTIONS_STMT,
|
||||
QUERY_NODE_SHOW_QUERIES_STMT,
|
||||
QUERY_NODE_SHOW_VNODES_STMT,
|
||||
QUERY_NODE_SHOW_APPS_STMT,
|
||||
QUERY_NODE_SHOW_SCORES_STMT,
|
||||
QUERY_NODE_SHOW_VARIABLES_STMT,
|
||||
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT,
|
||||
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT,
|
||||
QUERY_NODE_SHOW_TRANSACTIONS_STMT,
|
||||
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_TABLE_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
||||
QUERY_NODE_SHOW_TRANSACTIONS_STMT,
|
||||
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT,
|
||||
QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT,
|
||||
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT,
|
||||
QUERY_NODE_SHOW_VNODES_STMT,
|
||||
QUERY_NODE_SHOW_SCORES_STMT,
|
||||
QUERY_NODE_KILL_CONNECTION_STMT,
|
||||
QUERY_NODE_KILL_QUERY_STMT,
|
||||
QUERY_NODE_KILL_TRANSACTION_STMT,
|
||||
|
|
|
@ -269,6 +269,7 @@ typedef struct SSelectStmt {
|
|||
bool hasInterpFunc;
|
||||
bool hasLastRowFunc;
|
||||
bool hasTimeLineFunc;
|
||||
bool hasUdaf;
|
||||
bool onlyHasKeepOrderFunc;
|
||||
bool groupSort;
|
||||
} SSelectStmt;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Package: tdengine
|
||||
Version: 1.0.0
|
||||
Version: 3.0.0
|
||||
Section: utils
|
||||
Priority: optional
|
||||
#Essential: no
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -f /var/lib/taos/dnode/dnodeCfg.json ]; then
|
||||
echo -e "The default data directory \033[41;37m/var/lib/taos\033[0m contains old data of tdengine 2.x, please clear it before installing!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
csudo=""
|
||||
if command -v sudo > /dev/null; then
|
||||
csudo="sudo "
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $1 -eq "abort-upgrade" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
insmetaPath="/usr/local/taos/script"
|
||||
|
||||
csudo=""
|
||||
|
|
|
@ -132,6 +132,10 @@ fi
|
|||
|
||||
#Scripts executed before installation
|
||||
%pre
|
||||
if [ -f /var/lib/taos/dnode/dnodeCfg.json ]; then
|
||||
echo -e "The default data directory \033[41;37m/var/lib/taos\033[0m contains old data of tdengine 2.x, please clear it before installing!"
|
||||
exit 1
|
||||
fi
|
||||
csudo=""
|
||||
if command -v sudo > /dev/null; then
|
||||
csudo="sudo "
|
||||
|
|
|
@ -346,7 +346,7 @@ static const SSysTableMeta perfsMeta[] = {
|
|||
{TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)},
|
||||
{TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)},
|
||||
{TSDB_PERFS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema)},
|
||||
{TSDB_PERFS_TABLE_OFFSETS, offsetSchema, tListLen(offsetSchema)},
|
||||
// {TSDB_PERFS_TABLE_OFFSETS, offsetSchema, tListLen(offsetSchema)},
|
||||
{TSDB_PERFS_TABLE_TRANS, transSchema, tListLen(transSchema)},
|
||||
{TSDB_PERFS_TABLE_SMAS, smaSchema, tListLen(smaSchema)},
|
||||
{TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)},
|
||||
|
|
|
@ -1713,7 +1713,7 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) {
|
|||
char pBuf[128] = {0};
|
||||
int32_t sz = taosArrayGetSize(dataBlocks);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
SSDataBlock* pDataBlock = taosArrayGet(dataBlocks, i);
|
||||
SSDataBlock* pDataBlock = taosArrayGetP(dataBlocks, i);
|
||||
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
|
||||
int32_t rows = pDataBlock->info.rows;
|
||||
|
@ -1870,7 +1870,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
|||
* @brief TODO: Assume that the final generated result it less than 3M
|
||||
*
|
||||
* @param pReq
|
||||
* @param pDataBlock
|
||||
* @param pDataBlocks
|
||||
* @param vgId
|
||||
* @param suid
|
||||
*
|
||||
|
|
|
@ -337,6 +337,7 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_CONTINUE, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_RSMA, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_FETCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_FETCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -347,7 +348,6 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_RSMA, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -54,7 +54,7 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
if (IsReq(pMsg)) {
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
dGError("msg:%p, failed to process since %s", pMsg, terrstr());
|
||||
dGError("msg:%p, failed to process since %s", pMsg, terrstr(code));
|
||||
}
|
||||
vmSendRsp(pMsg, code);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
int32_t code = vnodeProcessQueryMsg(pVnode->pImpl, pMsg);
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
dGError("vgId:%d, msg:%p failed to query since %s", pVnode->vgId, pMsg, terrstr());
|
||||
dGError("vgId:%d, msg:%p failed to query since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
vmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo);
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
dGError("vgId:%d, msg:%p failed to process stream since %s", pVnode->vgId, pMsg, terrstr());
|
||||
dGError("vgId:%d, msg:%p failed to process stream since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
vmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ static void vmProcessFetchQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
|||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo);
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
dGError("vgId:%d, msg:%p failed to fetch since %s", pVnode->vgId, pMsg, terrstr());
|
||||
dGError("vgId:%d, msg:%p failed to fetch since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
vmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
if ((pMsg->msgType == TDMT_SCH_QUERY) && (grantCheck(TSDB_GRANT_TIME) != TSDB_CODE_SUCCESS)) {
|
||||
terrno = TSDB_CODE_GRANT_EXPIRED;
|
||||
code = terrno;
|
||||
dDebug("vgId:%d, msg:%p put into vnode-query queue failed since %s", pVnode->vgId, pMsg, terrstr());
|
||||
dDebug("vgId:%d, msg:%p put into vnode-query queue failed since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
} else {
|
||||
vnodePreprocessQueryMsg(pVnode->pImpl, pMsg);
|
||||
dGTrace("vgId:%d, msg:%p put into vnode-query queue", pVnode->vgId, pMsg);
|
||||
|
@ -179,11 +179,11 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
if (!osDataSpaceAvailable()) {
|
||||
terrno = TSDB_CODE_VND_NO_DISKSPACE;
|
||||
code = terrno;
|
||||
dError("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr());
|
||||
dError("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
} else if ((pMsg->msgType == TDMT_VND_SUBMIT) && (grantCheck(TSDB_GRANT_STORAGE) != TSDB_CODE_SUCCESS)) {
|
||||
terrno = TSDB_CODE_VND_NO_WRITE_AUTH;
|
||||
code = terrno;
|
||||
dDebug("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr());
|
||||
dDebug("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr(code));
|
||||
} else {
|
||||
dGTrace("vgId:%d, msg:%p put into vnode-write queue", pVnode->vgId, pMsg);
|
||||
taosWriteQitem(pVnode->pWriteQ, pMsg);
|
||||
|
|
|
@ -293,7 +293,9 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
|||
if (pItem->maxDelay > TSDB_MAX_ROLLUP_MAX_DELAY) {
|
||||
pItem->maxDelay = TSDB_MAX_ROLLUP_MAX_DELAY;
|
||||
}
|
||||
|
||||
pItem->level = idx == 0 ? TSDB_RETENTION_L1 : TSDB_RETENTION_L2;
|
||||
taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||
smaInfo("vgId:%d, table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64
|
||||
", finally maxdelay:%" PRIi32,
|
||||
TD_VID(pVnode), pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx], pItem->maxDelay);
|
||||
|
@ -614,33 +616,37 @@ static int32_t tdRSmaFetchAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSm
|
|||
uint64_t ts;
|
||||
int32_t code = qExecTaskOpt(taskInfo, pResList, &ts);
|
||||
if (code < 0) {
|
||||
smaError("vgId:%d, qExecTask for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid,
|
||||
pItem->level, terrstr(code));
|
||||
goto _err;
|
||||
if (code == TSDB_CODE_QRY_IN_EXEC) {
|
||||
break;
|
||||
} else {
|
||||
smaError("vgId:%d, qExecTask for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid,
|
||||
pItem->level, terrstr(code));
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
if (taosArrayGetSize(pResList) == 0) {
|
||||
if (terrno == 0) {
|
||||
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level);
|
||||
// smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level);
|
||||
} else {
|
||||
smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, terrstr());
|
||||
goto _err;
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
smaDebug("vgId:%d, rsma %" PRIi8 " data fetched", SMA_VID(pSma), pItem->level);
|
||||
}
|
||||
|
||||
#if 1
|
||||
char flag[10] = {0};
|
||||
snprintf(flag, 10, "level %" PRIi8, pItem->level);
|
||||
blockDebugShowDataBlocks(pResList, flag);
|
||||
#endif
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pResList); ++i) {
|
||||
SSDataBlock *output = taosArrayGetP(pResList, i);
|
||||
|
||||
#if 1
|
||||
char flag[10] = {0};
|
||||
snprintf(flag, 10, "level %" PRIi8, pItem->level);
|
||||
// blockDebugShowDataBlocks(output, flag);
|
||||
// taosArrayDestroy(pResult);
|
||||
#endif
|
||||
STsdb * sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
||||
SSubmitReq *pReq = NULL;
|
||||
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
||||
SSubmitReq *pReq = NULL;
|
||||
|
||||
// TODO: the schema update should be handled later(TD-17965)
|
||||
if (buildSubmitReqFromDataBlock(&pReq, output, pTSchema, SMA_VID(pSma), suid) < 0) {
|
||||
|
@ -655,11 +661,11 @@ static int32_t tdRSmaFetchAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSm
|
|||
SMA_VID(pSma), suid, pItem->level, terrstr());
|
||||
goto _err;
|
||||
}
|
||||
taosMemoryFreeClear(pReq);
|
||||
|
||||
smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%" PRIi64,
|
||||
SMA_VID(pSma), suid, pItem->level, output->info.version);
|
||||
|
||||
taosMemoryFreeClear(pReq);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -692,15 +698,12 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
|
|||
}
|
||||
|
||||
SRSmaInfoItem *pItem = RSMA_INFO_ITEM(pInfo, idx);
|
||||
|
||||
tdRSmaFetchAndSubmitResult(pSma, RSMA_INFO_QTASK(pInfo, idx), pItem, pInfo->pTSchema, suid,
|
||||
STREAM_INPUT__DATA_SUBMIT);
|
||||
atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE);
|
||||
|
||||
if (smaMgmt.tmrHandle) {
|
||||
taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -746,7 +749,6 @@ static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// clone the SRSmaInfo from iRsmaInfoHash to rsmaInfoHash if in committing stat
|
||||
SRSmaInfo *pCowRSmaInfo = NULL;
|
||||
// lock
|
||||
|
@ -793,13 +795,7 @@ static FORCE_INLINE void tdReleaseRSmaInfo(SSma *pSma, SRSmaInfo *pInfo) {
|
|||
static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb_uid_t suid) {
|
||||
SRSmaInfo *pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, suid);
|
||||
if (!pRSmaInfo) {
|
||||
smaDebug("vgId:%d, execute rsma, no rsma info for suid:%" PRIu64, SMA_VID(pSma), suid);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (!RSMA_INFO_QTASK(pRSmaInfo, 0)) {
|
||||
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||
smaDebug("vgId:%d, execute rsma, no rsma qTaskInfo for suid:%" PRIu64, SMA_VID(pSma), suid);
|
||||
smaError("vgId:%d, execute rsma, no rsma info for suid:%" PRIu64, SMA_VID(pSma), suid);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1331,14 +1327,16 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
SRSmaInfo *pRSmaInfo = tdGetRSmaInfoByItem(pItem);
|
||||
|
||||
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
|
||||
smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId,
|
||||
pRSmaInfo->refId);
|
||||
return;
|
||||
}
|
||||
|
||||
SRSmaStat *pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaInfo->refId);
|
||||
|
||||
if (!pStat) {
|
||||
smaDebug("rsma fetch task not start since already destroyed, rsetId rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId,
|
||||
pRSmaInfo->refId);
|
||||
smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%" PRIi64 " refId:%d)",
|
||||
smaMgmt.rsetId, pRSmaInfo->refId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1350,8 +1348,8 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
case TASK_TRIGGER_STAT_PAUSED:
|
||||
case TASK_TRIGGER_STAT_CANCELLED: {
|
||||
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaInfo->refId);
|
||||
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data since stat is %" PRIi8 ", rsetId rsetId:%" PRIi64
|
||||
" refId:%d",
|
||||
smaDebug("vgId:%d, rsma fetch task not start for level %" PRIi8 " since stat is %" PRIi8
|
||||
", rsetId rsetId:%" PRIi64 " refId:%d",
|
||||
SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaInfo->refId);
|
||||
if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) {
|
||||
taosTmrReset(tdRSmaFetchTrigger, 5000, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||
|
@ -1366,30 +1364,31 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE);
|
||||
switch (fetchTriggerStat) {
|
||||
case TASK_TRIGGER_STAT_ACTIVE: {
|
||||
smaDebug("vgId:%d, fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is active", SMA_VID(pSma),
|
||||
pItem->level, pRSmaInfo->suid);
|
||||
smaDebug("vgId:%d, rsma fetch task started for level:%" PRIi8 " suid:%" PRIi64 " since stat is active",
|
||||
SMA_VID(pSma), pItem->level, pRSmaInfo->suid);
|
||||
// async process
|
||||
tdRSmaFetchSend(pSma, pRSmaInfo, pItem->level);
|
||||
} break;
|
||||
case TASK_TRIGGER_STAT_PAUSED: {
|
||||
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is paused",
|
||||
smaDebug("vgId:%d, rsma fetch task not start for level:%" PRIi8 " suid:%" PRIi64 " since stat is paused",
|
||||
SMA_VID(pSma), pItem->level, pRSmaInfo->suid);
|
||||
} break;
|
||||
case TASK_TRIGGER_STAT_INACTIVE: {
|
||||
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is inactive",
|
||||
smaDebug("vgId:%d, rsma fetch task not start for level:%" PRIi8 " suid:%" PRIi64 " since stat is inactive",
|
||||
SMA_VID(pSma), pItem->level, pRSmaInfo->suid);
|
||||
} break;
|
||||
case TASK_TRIGGER_STAT_INIT: {
|
||||
smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is init", SMA_VID(pSma),
|
||||
pItem->level, pRSmaInfo->suid);
|
||||
smaDebug("vgId:%d, rsma fetch task not start for level:%" PRIi8 " suid::%" PRIi64 " since stat is init",
|
||||
SMA_VID(pSma), pItem->level, pRSmaInfo->suid);
|
||||
} break;
|
||||
default: {
|
||||
smaWarn("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is unknown",
|
||||
smaWarn("vgId:%d, rsma fetch task not start for level:%" PRIi8 " suid:%" PRIi64 " since stat is unknown",
|
||||
SMA_VID(pSma), pItem->level, pRSmaInfo->suid);
|
||||
} break;
|
||||
}
|
||||
|
||||
_end:
|
||||
// taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaInfo->refId);
|
||||
}
|
||||
|
||||
|
@ -1402,7 +1401,7 @@ _end:
|
|||
* @return int32_t
|
||||
*/
|
||||
int32_t tdRSmaFetchSend(SSma *pSma, SRSmaInfo *pInfo, int8_t level) {
|
||||
SRSmaFetchMsg fetchMsg = { .suid = pInfo->suid, .level = level};
|
||||
SRSmaFetchMsg fetchMsg = {.suid = pInfo->suid, .level = level};
|
||||
int32_t ret = 0;
|
||||
int32_t contLen = 0;
|
||||
SEncoder encoder = {0};
|
||||
|
@ -1431,7 +1430,7 @@ int32_t tdRSmaFetchSend(SSma *pSma, SRSmaInfo *pInfo, int8_t level) {
|
|||
.contLen = contLen,
|
||||
};
|
||||
|
||||
if ((terrno = tmsgPutToQueue(&pSma->pVnode->msgCb, FETCH_QUEUE, &rpcMsg)) != 0) {
|
||||
if ((terrno = tmsgPutToQueue(&pSma->pVnode->msgCb, QUERY_QUEUE, &rpcMsg)) != 0) {
|
||||
smaError("vgId:%d, failed to put rsma fetch msg into fetch-queue for suid:%" PRIi64 " level:%" PRIi8 " since %s",
|
||||
SMA_VID(pSma), pInfo->suid, level, terrstr());
|
||||
goto _err;
|
||||
|
@ -1462,7 +1461,7 @@ int32_t smaProcessFetch(SSma *pSma, void *pMsg) {
|
|||
|
||||
if (!pRpcMsg || pRpcMsg->contLen < sizeof(SMsgHead)) {
|
||||
terrno = TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP;
|
||||
return -1;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
pBuf = POINTER_SHIFT(pRpcMsg->pCont, sizeof(SMsgHead));
|
||||
|
@ -1479,7 +1478,7 @@ int32_t smaProcessFetch(SSma *pSma, void *pMsg) {
|
|||
terrno = TSDB_CODE_RSMA_EMPTY_INFO;
|
||||
}
|
||||
smaWarn("vgId:%d, failed to process rsma fetch msg for suid:%" PRIi64 " level:%" PRIi8 " since %s", SMA_VID(pSma),
|
||||
req.suid, req.level, terrstr());
|
||||
req.suid, req.level, terrstr());
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
|
|
@ -293,6 +293,8 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||
case TDMT_SCH_QUERY_CONTINUE:
|
||||
return qWorkerProcessCQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||
case TDMT_VND_FETCH_RSMA:
|
||||
return smaProcessFetch(pVnode->pSma, pMsg);
|
||||
default:
|
||||
vError("unknown msg type:%d in query queue", pMsg->msgType);
|
||||
return TSDB_CODE_VND_APP_ERROR;
|
||||
|
@ -329,8 +331,6 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
return vnodeGetTableCfg(pVnode, pMsg, true);
|
||||
case TDMT_VND_BATCH_META:
|
||||
return vnodeGetBatchMeta(pVnode, pMsg);
|
||||
case TDMT_VND_FETCH_RSMA:
|
||||
return smaProcessFetch(pVnode->pSma, pMsg);
|
||||
case TDMT_VND_CONSUME:
|
||||
return tqProcessPollReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_TASK_RUN:
|
||||
|
@ -357,7 +357,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
// TODO: remove the function
|
||||
void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
|
||||
// TODO
|
||||
blockDebugShowDataBlocks(data, __func__);
|
||||
// blockDebugShowDataBlocks(data, __func__);
|
||||
tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn, size_t keyLen, size_t
|
|||
*/
|
||||
int32_t tSimpleHashGetSize(const SSHashObj *pHashObj);
|
||||
|
||||
int32_t tSimpleHashPrint(const SSHashObj *pHashObj);
|
||||
|
||||
/**
|
||||
* put element into hash table, if the element with the same key exists, update it
|
||||
* @param pHashObj
|
||||
|
@ -98,6 +100,15 @@ size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj);
|
|||
*/
|
||||
void *tSimpleHashGetKey(const SSHashObj* pHashObj, void *data, size_t* keyLen);
|
||||
|
||||
/**
|
||||
* Create the hash table iterator
|
||||
* @param pHashObj
|
||||
* @param data
|
||||
* @param iter
|
||||
* @return void*
|
||||
*/
|
||||
void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -529,7 +529,6 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t* useconds) {
|
|||
cleanUpUdfs();
|
||||
qDebug("%s task abort due to error/cancel occurs, code:%s", GET_TASKID(pTaskInfo), tstrerror(pTaskInfo->code));
|
||||
atomic_store_64(&pTaskInfo->owner, 0);
|
||||
|
||||
return pTaskInfo->code;
|
||||
}
|
||||
|
||||
|
|
|
@ -3612,11 +3612,16 @@ void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) {
|
|||
taosRemoveRef(exchangeObjRefPool, pExInfo->self);
|
||||
}
|
||||
|
||||
void freeSourceDataInfo(void *p) {
|
||||
SSourceDataInfo* pInfo = (SSourceDataInfo*)p;
|
||||
taosMemoryFreeClear(pInfo->pRsp);
|
||||
}
|
||||
|
||||
void doDestroyExchangeOperatorInfo(void* param) {
|
||||
SExchangeInfo* pExInfo = (SExchangeInfo*)param;
|
||||
|
||||
taosArrayDestroy(pExInfo->pSources);
|
||||
taosArrayDestroy(pExInfo->pSourceDataInfo);
|
||||
taosArrayDestroyEx(pExInfo->pSourceDataInfo, freeSourceDataInfo);
|
||||
|
||||
if (pExInfo->pResultBlockList != NULL) {
|
||||
taosArrayDestroyEx(pExInfo->pResultBlockList, freeBlock);
|
||||
|
|
|
@ -2215,6 +2215,7 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
|||
colDataAppend(pDst, rows, (char *)current.val, false);
|
||||
}
|
||||
|
||||
taosMemoryFree(current.val);
|
||||
pResBlock->info.rows += 1;
|
||||
break;
|
||||
}
|
||||
|
@ -2437,10 +2438,10 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
|||
// if its the last point in data block, no need to fill, but reserve this point as the start value and do
|
||||
// the interpolation when processing next data block.
|
||||
if (pSliceInfo->fillType == TSDB_FILL_LINEAR) {
|
||||
doKeepLinearInfo(pSliceInfo, pBlock, i, false);
|
||||
pSliceInfo->current =
|
||||
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
|
||||
if (i < pBlock->info.rows - 1) {
|
||||
doKeepLinearInfo(pSliceInfo, pBlock, i, false);
|
||||
int64_t nextTs = *(int64_t*)colDataGetData(pTsCol, i + 1);
|
||||
if (nextTs > pSliceInfo->current) {
|
||||
while (pSliceInfo->current < nextTs && pSliceInfo->current <= pSliceInfo->win.ekey) {
|
||||
|
@ -2478,11 +2479,11 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
|||
doKeepPrevRows(pSliceInfo, pBlock, i);
|
||||
|
||||
if (pSliceInfo->fillType == TSDB_FILL_LINEAR) {
|
||||
doKeepLinearInfo(pSliceInfo, pBlock, i, false);
|
||||
// no need to increate pSliceInfo->current here
|
||||
//pSliceInfo->current =
|
||||
// taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
|
||||
if (i < pBlock->info.rows - 1) {
|
||||
doKeepLinearInfo(pSliceInfo, pBlock, i, false);
|
||||
int64_t nextTs = *(int64_t*)colDataGetData(pTsCol, i + 1);
|
||||
if (nextTs > pSliceInfo->current) {
|
||||
while (pSliceInfo->current < nextTs && pSliceInfo->current <= pSliceInfo->win.ekey) {
|
||||
|
@ -2558,10 +2559,10 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
|||
|
||||
|
||||
if (pSliceInfo->fillType == TSDB_FILL_LINEAR) {
|
||||
doKeepLinearInfo(pSliceInfo, pBlock, i, false);
|
||||
pSliceInfo->current =
|
||||
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
|
||||
if (i < pBlock->info.rows - 1) {
|
||||
doKeepLinearInfo(pSliceInfo, pBlock, i, false);
|
||||
int64_t nextTs = *(int64_t*)colDataGetData(pTsCol, i + 1);
|
||||
if (nextTs > pSliceInfo->current) {
|
||||
while (pSliceInfo->current < nextTs && pSliceInfo->current <= pSliceInfo->win.ekey) {
|
||||
|
@ -2618,6 +2619,35 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
|
|||
return pResBlock->info.rows == 0 ? NULL : pResBlock;
|
||||
}
|
||||
|
||||
void destroyTimeSliceOperatorInfo(void* param, int32_t numOfOutput) {
|
||||
STimeSliceOperatorInfo* pInfo = (STimeSliceOperatorInfo*)param;
|
||||
|
||||
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->pPrevRow); ++i) {
|
||||
SGroupKeys* pKey = taosArrayGet(pInfo->pPrevRow, i);
|
||||
taosMemoryFree(pKey->pData);
|
||||
}
|
||||
taosArrayDestroy(pInfo->pPrevRow);
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->pNextRow); ++i) {
|
||||
SGroupKeys* pKey = taosArrayGet(pInfo->pNextRow, i);
|
||||
taosMemoryFree(pKey->pData);
|
||||
}
|
||||
taosArrayDestroy(pInfo->pNextRow);
|
||||
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->pLinearInfo); ++i) {
|
||||
SFillLinearInfo* pKey = taosArrayGet(pInfo->pLinearInfo, i);
|
||||
taosMemoryFree(pKey->start.val);
|
||||
taosMemoryFree(pKey->end.val);
|
||||
}
|
||||
taosArrayDestroy(pInfo->pLinearInfo);
|
||||
|
||||
taosMemoryFree(pInfo->pFillColInfo);
|
||||
taosMemoryFreeClear(param);
|
||||
}
|
||||
|
||||
|
||||
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo) {
|
||||
STimeSliceOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STimeSliceOperatorInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
|
@ -2665,7 +2695,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
|
|||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, NULL, destroyBasicOperatorInfo, NULL, NULL, NULL);
|
||||
createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, NULL, destroyTimeSliceOperatorInfo, NULL, NULL, NULL);
|
||||
|
||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn, size_t keyLen, size_t
|
|||
}
|
||||
|
||||
SSHashObj *pHashObj = (SSHashObj *)taosMemoryCalloc(1, sizeof(SSHashObj));
|
||||
if (pHashObj == NULL) {
|
||||
if (!pHashObj) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn, size_t keyLen, size_t
|
|||
pHashObj->dataLen = dataLen;
|
||||
|
||||
pHashObj->hashList = (SHNode **)taosMemoryCalloc(pHashObj->capacity, sizeof(void *));
|
||||
if (pHashObj->hashList == NULL) {
|
||||
if (!pHashObj->hashList) {
|
||||
taosMemoryFree(pHashObj);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
|
@ -87,7 +87,7 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn, size_t keyLen, size_t
|
|||
}
|
||||
|
||||
int32_t tSimpleHashGetSize(const SSHashObj *pHashObj) {
|
||||
if (pHashObj == NULL) {
|
||||
if (!pHashObj) {
|
||||
return 0;
|
||||
}
|
||||
return (int32_t)atomic_load_64((int64_t *)&pHashObj->size);
|
||||
|
@ -95,7 +95,7 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj) {
|
|||
|
||||
static SHNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, size_t dsize, uint32_t hashVal) {
|
||||
SHNode *pNewNode = taosMemoryMalloc(sizeof(SHNode) + keyLen + dsize);
|
||||
if (pNewNode == NULL) {
|
||||
if (!pNewNode) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ static void taosHashTableResize(SSHashObj *pHashObj) {
|
|||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
void *pNewEntryList = taosMemoryRealloc(pHashObj->hashList, sizeof(void *) * newCapacity);
|
||||
if (pNewEntryList == NULL) {
|
||||
if (!pNewEntryList) {
|
||||
// qWarn("hash resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity);
|
||||
return;
|
||||
}
|
||||
|
@ -133,22 +133,21 @@ static void taosHashTableResize(SSHashObj *pHashObj) {
|
|||
|
||||
for (int32_t idx = 0; idx < pHashObj->capacity; ++idx) {
|
||||
SHNode *pNode = pHashObj->hashList[idx];
|
||||
if (pNode == NULL) {
|
||||
if (!pNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SHNode *pNext;
|
||||
SHNode *pNext = NULL;
|
||||
SHNode *pPrev = NULL;
|
||||
|
||||
|
||||
while (pNode != NULL) {
|
||||
void *key = GET_SHASH_NODE_KEY(pNode, pHashObj->dataLen);
|
||||
uint32_t hashVal = (*pHashObj->hashFp)(key, (uint32_t)pHashObj->dataLen);
|
||||
uint32_t hashVal = (*pHashObj->hashFp)(key, (uint32_t)pHashObj->keyLen);
|
||||
|
||||
int32_t newIdx = HASH_INDEX(hashVal, pHashObj->capacity);
|
||||
pNext = pNode->next;
|
||||
if (newIdx != idx) {
|
||||
if (pPrev == NULL) {
|
||||
if (!pPrev) {
|
||||
pHashObj->hashList[idx] = pNext;
|
||||
} else {
|
||||
pPrev->next = pNext;
|
||||
|
@ -172,7 +171,7 @@ static void taosHashTableResize(SSHashObj *pHashObj) {
|
|||
}
|
||||
|
||||
int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, const void *data) {
|
||||
if (pHashObj == NULL || key == NULL) {
|
||||
if (!pHashObj || !key) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -186,13 +185,14 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, const void *data) {
|
|||
int32_t slot = HASH_INDEX(hashVal, pHashObj->capacity);
|
||||
|
||||
SHNode *pNode = pHashObj->hashList[slot];
|
||||
if (pNode == NULL) {
|
||||
SHNode *pNewNode = doCreateHashNode(key, pHashObj->keyLen, data, pHashObj->size, hashVal);
|
||||
if (pNewNode == NULL) {
|
||||
if (!pNode) {
|
||||
SHNode *pNewNode = doCreateHashNode(key, pHashObj->keyLen, data, pHashObj->dataLen, hashVal);
|
||||
if (!pNewNode) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pHashObj->hashList[slot] = pNewNode;
|
||||
atomic_add_fetch_64(&pHashObj->size, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -203,9 +203,9 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, const void *data) {
|
|||
pNode = pNode->next;
|
||||
}
|
||||
|
||||
if (pNode == NULL) {
|
||||
SHNode *pNewNode = doCreateHashNode(key, pHashObj->keyLen, data, pHashObj->size, hashVal);
|
||||
if (pNewNode == NULL) {
|
||||
if (!pNode) {
|
||||
SHNode *pNewNode = doCreateHashNode(key, pHashObj->keyLen, data, pHashObj->dataLen, hashVal);
|
||||
if (!pNewNode) {
|
||||
return -1;
|
||||
}
|
||||
pNewNode->next = pHashObj->hashList[slot];
|
||||
|
@ -234,7 +234,7 @@ static FORCE_INLINE SHNode *doSearchInEntryList(SSHashObj *pHashObj, const void
|
|||
static FORCE_INLINE bool taosHashTableEmpty(const SSHashObj *pHashObj) { return tSimpleHashGetSize(pHashObj) == 0; }
|
||||
|
||||
void *tSimpleHashGet(SSHashObj *pHashObj, const void *key) {
|
||||
if (pHashObj == NULL || taosHashTableEmpty(pHashObj) || key == NULL) {
|
||||
if (!pHashObj || taosHashTableEmpty(pHashObj) || !key) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ void *tSimpleHashGet(SSHashObj *pHashObj, const void *key) {
|
|||
|
||||
int32_t slot = HASH_INDEX(hashVal, pHashObj->capacity);
|
||||
SHNode *pNode = pHashObj->hashList[slot];
|
||||
if (pNode == NULL) {
|
||||
if (!pNode) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -256,19 +256,43 @@ void *tSimpleHashGet(SSHashObj *pHashObj, const void *key) {
|
|||
}
|
||||
|
||||
int32_t tSimpleHashRemove(SSHashObj *pHashObj, const void *key) {
|
||||
// todo
|
||||
if (!pHashObj || !key) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
uint32_t hashVal = (*pHashObj->hashFp)(key, (uint32_t)pHashObj->keyLen);
|
||||
|
||||
int32_t slot = HASH_INDEX(hashVal, pHashObj->capacity);
|
||||
|
||||
SHNode *pNode = pHashObj->hashList[slot];
|
||||
SHNode *pPrev = NULL;
|
||||
while (pNode) {
|
||||
if ((*(pHashObj->equalFp))(GET_SHASH_NODE_KEY(pNode, pHashObj->dataLen), key, pHashObj->keyLen) == 0) {
|
||||
if (!pPrev) {
|
||||
pHashObj->hashList[slot] = pNode->next;
|
||||
} else {
|
||||
pPrev->next = pNode->next;
|
||||
}
|
||||
FREE_HASH_NODE(pNode);
|
||||
atomic_sub_fetch_64(&pHashObj->size, 1);
|
||||
break;
|
||||
}
|
||||
pPrev = pNode;
|
||||
pNode = pNode->next;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void tSimpleHashClear(SSHashObj *pHashObj) {
|
||||
if (pHashObj == NULL) {
|
||||
if (!pHashObj || taosHashTableEmpty(pHashObj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SHNode *pNode, *pNext;
|
||||
SHNode *pNode = NULL, *pNext = NULL;
|
||||
for (int32_t i = 0; i < pHashObj->capacity; ++i) {
|
||||
pNode = pHashObj->hashList[i];
|
||||
if (pNode == NULL) {
|
||||
if (!pNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -278,11 +302,11 @@ void tSimpleHashClear(SSHashObj *pHashObj) {
|
|||
pNode = pNext;
|
||||
}
|
||||
}
|
||||
pHashObj->size = 0;
|
||||
atomic_store_64(&pHashObj->size, 0);
|
||||
}
|
||||
|
||||
void tSimpleHashCleanup(SSHashObj *pHashObj) {
|
||||
if (pHashObj == NULL) {
|
||||
if (!pHashObj) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -291,7 +315,7 @@ void tSimpleHashCleanup(SSHashObj *pHashObj) {
|
|||
}
|
||||
|
||||
size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj) {
|
||||
if (pHashObj == NULL) {
|
||||
if (!pHashObj) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -299,11 +323,58 @@ size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj) {
|
|||
}
|
||||
|
||||
void *tSimpleHashGetKey(const SSHashObj *pHashObj, void *data, size_t *keyLen) {
|
||||
#if 0
|
||||
int32_t offset = offsetof(SHNode, data);
|
||||
SHNode *node = ((SHNode *)(char *)data - offset);
|
||||
if (keyLen != NULL) {
|
||||
if (keyLen) {
|
||||
*keyLen = pHashObj->keyLen;
|
||||
}
|
||||
|
||||
return POINTER_SHIFT(data, pHashObj->dataLen);
|
||||
|
||||
return GET_SHASH_NODE_KEY(node, pHashObj->dataLen);
|
||||
#endif
|
||||
if (keyLen) {
|
||||
*keyLen = pHashObj->keyLen;
|
||||
}
|
||||
|
||||
return POINTER_SHIFT(data, pHashObj->dataLen);
|
||||
}
|
||||
|
||||
void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter) {
|
||||
if (!pHashObj) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SHNode *pNode = NULL;
|
||||
|
||||
if (!data) {
|
||||
for (int32_t i = 0; i < pHashObj->capacity; ++i) {
|
||||
pNode = pHashObj->hashList[i];
|
||||
if (!pNode) {
|
||||
continue;
|
||||
}
|
||||
*iter = i;
|
||||
return GET_SHASH_NODE_DATA(pNode);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pNode = (SHNode *)((char *)data - offsetof(SHNode, data));
|
||||
|
||||
if (pNode->next) {
|
||||
return GET_SHASH_NODE_DATA(pNode->next);
|
||||
}
|
||||
|
||||
++(*iter);
|
||||
for (int32_t i = *iter; i < pHashObj->capacity; ++i) {
|
||||
pNode = pHashObj->hashList[i];
|
||||
if (!pNode) {
|
||||
continue;
|
||||
}
|
||||
*iter = i;
|
||||
return GET_SHASH_NODE_DATA(pNode);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -18,3 +18,18 @@ IF(NOT TD_DARWIN)
|
|||
PRIVATE "${TD_SOURCE_DIR}/source/libs/executor/inc"
|
||||
)
|
||||
ENDIF ()
|
||||
|
||||
# SET(CMAKE_CXX_STANDARD 11)
|
||||
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||
|
||||
# ADD_EXECUTABLE(tSimpleHashTest tSimpleHashTests.cpp)
|
||||
# TARGET_LINK_LIBRARIES(
|
||||
# tSimpleHashTest
|
||||
# PRIVATE os util common executor gtest_main
|
||||
# )
|
||||
|
||||
# TARGET_INCLUDE_DIRECTORIES(
|
||||
# tSimpleHashTest
|
||||
# PUBLIC "${TD_SOURCE_DIR}/include/common"
|
||||
# PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
# )
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include "taos.h"
|
||||
#include "thash.h"
|
||||
#include "tsimplehash.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
|
||||
// int main(int argc, char **argv) {
|
||||
// testing::InitGoogleTest(&argc, argv);
|
||||
// return RUN_ALL_TESTS();
|
||||
// }
|
||||
|
||||
TEST(testCase, tSimpleHashTest) {
|
||||
SSHashObj *pHashObj =
|
||||
tSimpleHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), sizeof(int64_t), sizeof(int64_t));
|
||||
|
||||
assert(pHashObj != nullptr);
|
||||
|
||||
ASSERT_EQ(0, tSimpleHashGetSize(pHashObj));
|
||||
|
||||
int64_t originKeySum = 0;
|
||||
for (int64_t i = 1; i <= 100; ++i) {
|
||||
originKeySum += i;
|
||||
tSimpleHashPut(pHashObj, (const void *)&i, (const void *)&i);
|
||||
ASSERT_EQ(i, tSimpleHashGetSize(pHashObj));
|
||||
}
|
||||
|
||||
for (int64_t i = 1; i <= 100; ++i) {
|
||||
void *data = tSimpleHashGet(pHashObj, (const void *)&i);
|
||||
ASSERT_EQ(i, *(int64_t *)data);
|
||||
}
|
||||
|
||||
|
||||
void *data = NULL;
|
||||
int32_t iter = 0;
|
||||
int64_t keySum = 0;
|
||||
int64_t dataSum = 0;
|
||||
while ((data = tSimpleHashIterate(pHashObj, data, &iter))) {
|
||||
void *key = tSimpleHashGetKey(pHashObj, data, NULL);
|
||||
keySum += *(int64_t *)key;
|
||||
dataSum += *(int64_t *)data;
|
||||
}
|
||||
|
||||
ASSERT_EQ(keySum, dataSum);
|
||||
ASSERT_EQ(keySum, originKeySum);
|
||||
|
||||
for (int64_t i = 1; i <= 100; ++i) {
|
||||
tSimpleHashRemove(pHashObj, (const void *)&i);
|
||||
ASSERT_EQ(100 - i, tSimpleHashGetSize(pHashObj));
|
||||
}
|
||||
|
||||
tSimpleHashCleanup(pHashObj);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
|
@ -49,7 +49,7 @@ typedef struct SBuiltinFuncDefinition {
|
|||
} SBuiltinFuncDefinition;
|
||||
|
||||
extern const SBuiltinFuncDefinition funcMgtBuiltins[];
|
||||
extern const int funcMgtBuiltinsNum;
|
||||
extern const int32_t funcMgtBuiltinsNum;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "ShowTagsStmt";
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
return "ShowUsersStmt";
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCES_STMT:
|
||||
return "ShowGrantsStmt";
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
return "ShowVgroupsStmt";
|
||||
|
@ -171,10 +171,6 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "ShowTopicsStmt";
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
return "ShowConsumersStmt";
|
||||
case QUERY_NODE_SHOW_SUBSCRIBES_STMT:
|
||||
return "ShowSubscribesStmt";
|
||||
case QUERY_NODE_SHOW_SMAS_STMT:
|
||||
return "ShowSmasStmt";
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
return "ShowQueriesStmt";
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
|
|
|
@ -201,12 +201,10 @@ SNode* nodesMakeNode(ENodeType type) {
|
|||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCES_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIBES_STMT:
|
||||
case QUERY_NODE_SHOW_SMAS_STMT:
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
|
@ -687,12 +685,10 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCES_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIBES_STMT:
|
||||
case QUERY_NODE_SHOW_SMAS_STMT:
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
|
|
|
@ -391,8 +391,8 @@ cmd ::= SHOW STREAMS.
|
|||
cmd ::= SHOW ACCOUNTS. { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
cmd ::= SHOW APPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); }
|
||||
cmd ::= SHOW CONNECTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); }
|
||||
cmd ::= SHOW LICENCE. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); }
|
||||
cmd ::= SHOW GRANTS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); }
|
||||
cmd ::= SHOW LICENCES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
|
||||
cmd ::= SHOW GRANTS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
|
||||
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
|
||||
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
|
||||
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); }
|
||||
|
@ -998,4 +998,6 @@ null_ordering_opt(A) ::= .
|
|||
null_ordering_opt(A) ::= NULLS FIRST. { A = NULL_ORDER_FIRST; }
|
||||
null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; }
|
||||
|
||||
%fallback ID NK_BITNOT VALUES IMPORT NK_SEMI FILE.
|
||||
%fallback ABORT AFTER ATTACH BEFORE BEGIN BITAND BITNOT BITOR BLOCKS CHANGE COMMA COMPACT CONCAT CONFLICT COPY DEFERRED DELIMITERS DETACH DIVIDE DOT EACH END FAIL
|
||||
FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE REPLACE RESTRICT ROW SEMI STAR STATEMENT STRING
|
||||
TIMES UPDATE VALUES VARIABLE VIEW VNODES WAL.
|
||||
|
|
|
@ -570,7 +570,7 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
|||
return collectMetaKeyFromShowTags(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
return collectMetaKeyFromShowUsers(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCES_STMT:
|
||||
return collectMetaKeyFromShowLicence(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
return collectMetaKeyFromShowVgroups(pCxt, (SShowStmt*)pStmt);
|
||||
|
|
|
@ -43,8 +43,8 @@ static SKeyword keywordTable[] = {
|
|||
{"AT_ONCE", TK_AT_ONCE},
|
||||
{"BALANCE", TK_BALANCE},
|
||||
{"BETWEEN", TK_BETWEEN},
|
||||
{"BINARY", TK_BINARY},
|
||||
{"BIGINT", TK_BIGINT},
|
||||
{"BINARY", TK_BINARY},
|
||||
{"BNODE", TK_BNODE},
|
||||
{"BNODES", TK_BNODES},
|
||||
{"BOOL", TK_BOOL},
|
||||
|
@ -60,9 +60,9 @@ static SKeyword keywordTable[] = {
|
|||
{"COLUMN", TK_COLUMN},
|
||||
{"COMMENT", TK_COMMENT},
|
||||
{"COMP", TK_COMP},
|
||||
{"CONNS", TK_CONNS},
|
||||
{"CONNECTION", TK_CONNECTION},
|
||||
{"CONNECTIONS", TK_CONNECTIONS},
|
||||
{"CONNS", TK_CONNS},
|
||||
{"CONSUMER", TK_CONSUMER},
|
||||
{"CONSUMERS", TK_CONSUMERS},
|
||||
{"CONTAINS", TK_CONTAINS},
|
||||
|
@ -106,8 +106,8 @@ static SKeyword keywordTable[] = {
|
|||
{"INDEX", TK_INDEX},
|
||||
{"INDEXES", TK_INDEXES},
|
||||
{"INNER", TK_INNER},
|
||||
{"INT", TK_INT},
|
||||
{"INSERT", TK_INSERT},
|
||||
{"INT", TK_INT},
|
||||
{"INTEGER", TK_INTEGER},
|
||||
{"INTERVAL", TK_INTERVAL},
|
||||
{"INTO", TK_INTO},
|
||||
|
@ -118,7 +118,7 @@ static SKeyword keywordTable[] = {
|
|||
{"KILL", TK_KILL},
|
||||
{"LAST", TK_LAST},
|
||||
{"LAST_ROW", TK_LAST_ROW},
|
||||
{"LICENCE", TK_LICENCE},
|
||||
{"LICENCES", TK_LICENCES},
|
||||
{"LIKE", TK_LIKE},
|
||||
{"LIMIT", TK_LIMIT},
|
||||
{"LINEAR", TK_LINEAR},
|
||||
|
@ -147,10 +147,10 @@ static SKeyword keywordTable[] = {
|
|||
{"OR", TK_OR},
|
||||
{"ORDER", TK_ORDER},
|
||||
{"OUTPUTTYPE", TK_OUTPUTTYPE},
|
||||
{"PARTITION", TK_PARTITION},
|
||||
{"PASS", TK_PASS},
|
||||
{"PAGES", TK_PAGES},
|
||||
{"PAGESIZE", TK_PAGESIZE},
|
||||
{"PARTITION", TK_PARTITION},
|
||||
{"PASS", TK_PASS},
|
||||
{"PORT", TK_PORT},
|
||||
{"PPS", TK_PPS},
|
||||
{"PRECISION", TK_PRECISION},
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#define generateDealNodeErrMsg(pCxt, code, ...) \
|
||||
(pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, code, ##__VA_ARGS__), DEAL_RES_ERROR)
|
||||
|
||||
#define SYSTABLE_SHOW_TYPE_OFFSET QUERY_NODE_SHOW_DNODES_STMT
|
||||
|
||||
typedef struct STranslateContext {
|
||||
SParseContext* pParseCxt;
|
||||
int32_t errCode;
|
||||
|
@ -51,6 +53,201 @@ typedef struct SFullDatabaseName {
|
|||
char fullDbName[TSDB_DB_FNAME_LEN];
|
||||
} SFullDatabaseName;
|
||||
|
||||
typedef struct SSysTableShowAdapter {
|
||||
ENodeType showType;
|
||||
const char* pDbName;
|
||||
const char* pTableName;
|
||||
int32_t numOfShowCols;
|
||||
const char* pShowCols[2];
|
||||
} SSysTableShowAdapter;
|
||||
|
||||
// clang-format off
|
||||
static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_DNODES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_DNODES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_MNODES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_MNODES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_MODULES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_MODULES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_QNODES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_QNODES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_SNODES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_SNODES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_BNODES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_BNODES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_CLUSTER_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_CLUSTER,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_DATABASES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_DATABASES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"name"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_FUNCTIONS_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_FUNCTIONS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"name"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_INDEXES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_INDEXES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_STABLES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_STABLES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"stable_name"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_STREAMS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_STREAMS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"stream_name"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_TABLES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_TABLES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"table_name"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_TAGS_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_TAGS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_USERS_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_USERS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_LICENCES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_LICENCES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_VGROUPS_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_VGROUPS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_TOPICS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_TOPICS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"topic_name"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_CONSUMERS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_CONSUMERS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_CONNECTIONS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_CONNECTIONS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_QUERIES_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_QUERIES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_APPS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_APPS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_VARIABLES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_CONFIGS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_DNODE_VARIABLES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_DNODE_VARIABLES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_TRANSACTIONS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_TRANS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_SUBSCRIPTIONS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode);
|
||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode);
|
||||
static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal);
|
||||
|
@ -1350,6 +1547,7 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) {
|
|||
pSelect->hasInterpFunc = pSelect->hasInterpFunc ? true : (FUNCTION_TYPE_INTERP == pFunc->funcType);
|
||||
pSelect->hasLastRowFunc = pSelect->hasLastRowFunc ? true : (FUNCTION_TYPE_LAST_ROW == pFunc->funcType);
|
||||
pSelect->hasTimeLineFunc = pSelect->hasTimeLineFunc ? true : fmIsTimelineFunc(pFunc->funcId);
|
||||
pSelect->hasUdaf = pSelect->hasUdaf ? true : fmIsUserDefinedFunc(pFunc->funcId) && fmIsAggFunc(pFunc->funcId);
|
||||
pSelect->onlyHasKeepOrderFunc = pSelect->onlyHasKeepOrderFunc ? fmIsKeepOrderFunc(pFunc->funcId) : false;
|
||||
}
|
||||
}
|
||||
|
@ -2644,6 +2842,11 @@ static int32_t translateInterp(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (NULL == pSelect->pRange || NULL == pSelect->pEvery || NULL == pSelect->pFill) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_INTERP_CLAUSE,
|
||||
"Missing RANGE clause, EVERY clause or FILL clause");
|
||||
}
|
||||
|
||||
int32_t code = translateExpr(pCxt, &pSelect->pRange);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateExpr(pCxt, &pSelect->pEvery);
|
||||
|
@ -4734,6 +4937,11 @@ static bool crossTableWithoutAggOper(SSelectStmt* pSelect) {
|
|||
!isPartitionByTbname(pSelect->pPartitionByList);
|
||||
}
|
||||
|
||||
static bool crossTableWithUdaf(SSelectStmt* pSelect) {
|
||||
return pSelect->hasUdaf && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
||||
!isPartitionByTbname(pSelect->pPartitionByList);
|
||||
}
|
||||
|
||||
static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
|
||||
if (NULL != pStmt->pOptions->pWatermark &&
|
||||
(DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark))) {
|
||||
|
@ -4785,7 +4993,8 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
|
|||
|
||||
static int32_t checkStreamQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (TSDB_DATA_TYPE_TIMESTAMP != ((SExprNode*)nodesListGetNode(pSelect->pProjectionList, 0))->resType.type ||
|
||||
!pSelect->isTimeLineResult || crossTableWithoutAggOper(pSelect)) {
|
||||
!pSelect->isTimeLineResult || crossTableWithoutAggOper(pSelect) || NULL != pSelect->pOrderByList ||
|
||||
crossTableWithUdaf(pSelect)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query");
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -5350,102 +5559,6 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
static const char* getSysDbName(ENodeType type) {
|
||||
switch (type) {
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
return TSDB_INFORMATION_SCHEMA_DB;
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_APPS_STMT:
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
return TSDB_PERFORMANCE_SCHEMA_DB;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char* getSysTableName(ENodeType type) {
|
||||
switch (type) {
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
return TSDB_INS_TABLE_DATABASES;
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
return TSDB_INS_TABLE_TABLES;
|
||||
case QUERY_NODE_SHOW_TAGS_STMT:
|
||||
return TSDB_INS_TABLE_TAGS;
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
return TSDB_INS_TABLE_STABLES;
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
return TSDB_INS_TABLE_USERS;
|
||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||
return TSDB_INS_TABLE_DNODES;
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
return TSDB_INS_TABLE_VGROUPS;
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
return TSDB_INS_TABLE_MNODES;
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
return TSDB_INS_TABLE_MODULES;
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
return TSDB_INS_TABLE_QNODES;
|
||||
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||
return TSDB_INS_TABLE_FUNCTIONS;
|
||||
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||
return TSDB_INS_TABLE_INDEXES;
|
||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
return TSDB_PERFS_TABLE_STREAMS;
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
return TSDB_INS_TABLE_BNODES;
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
return TSDB_INS_TABLE_SNODES;
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
return TSDB_INS_TABLE_LICENCES;
|
||||
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||
return TSDB_INS_TABLE_CLUSTER;
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
return TSDB_PERFS_TABLE_CONNECTIONS;
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
return TSDB_PERFS_TABLE_QUERIES;
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
return TSDB_PERFS_TABLE_TOPICS;
|
||||
case QUERY_NODE_SHOW_TRANSACTIONS_STMT:
|
||||
return TSDB_PERFS_TABLE_TRANS;
|
||||
case QUERY_NODE_SHOW_VARIABLES_STMT:
|
||||
return TSDB_INS_TABLE_CONFIGS;
|
||||
case QUERY_NODE_SHOW_APPS_STMT:
|
||||
return TSDB_PERFS_TABLE_APPS;
|
||||
case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
|
||||
return TSDB_INS_TABLE_DNODE_VARIABLES;
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
return TSDB_PERFS_TABLE_CONSUMERS;
|
||||
case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT:
|
||||
return TSDB_PERFS_TABLE_SUBSCRIPTIONS;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SNode* createStarCol() {
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
|
@ -5455,7 +5568,33 @@ static SNode* createStarCol() {
|
|||
return (SNode*)pCol;
|
||||
}
|
||||
|
||||
static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSelectStmt** pStmt) {
|
||||
static SNode* createProjectCol(const char* pProjCol) {
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
}
|
||||
strcpy(pCol->colName, pProjCol);
|
||||
return (SNode*)pCol;
|
||||
}
|
||||
|
||||
static SNodeList* createProjectCols(int32_t ncols, const char* const pCols[]) {
|
||||
SNodeList* pProjections = NULL;
|
||||
if (ncols <= 0) {
|
||||
nodesListMakeStrictAppend(&pProjections, createStarCol());
|
||||
return pProjections;
|
||||
}
|
||||
for (int32_t i = 0; i < ncols; ++i) {
|
||||
int32_t code = nodesListMakeStrictAppend(&pProjections, createProjectCol(pCols[i]));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pProjections);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return pProjections;
|
||||
}
|
||||
|
||||
static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, int32_t numOfProjs,
|
||||
const char* const pProjCol[], SSelectStmt** pStmt) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||
if (NULL == pSelect) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -5472,7 +5611,8 @@ static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSele
|
|||
strcpy(pRealTable->table.tableAlias, pTable);
|
||||
pSelect->pFromTable = (SNode*)pRealTable;
|
||||
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pSelect->pProjectionList, createStarCol())) {
|
||||
pSelect->pProjectionList = createProjectCols(numOfProjs, pProjCol);
|
||||
if (NULL == pSelect->pProjectionList) {
|
||||
nodesDestroyNode((SNode*)pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -5483,11 +5623,12 @@ static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, SSele
|
|||
}
|
||||
|
||||
static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt) {
|
||||
return createSimpleSelectStmt(getSysDbName(showType), getSysTableName(showType), pStmt);
|
||||
const SSysTableShowAdapter* pShow = &sysTableShowAdapter[showType - SYSTABLE_SHOW_TYPE_OFFSET];
|
||||
return createSimpleSelectStmt(pShow->pDbName, pShow->pTableName, pShow->numOfShowCols, pShow->pShowCols, pStmt);
|
||||
}
|
||||
|
||||
static int32_t createSelectStmtForShowTableDist(SShowTableDistributedStmt* pStmt, SSelectStmt** pOutput) {
|
||||
return createSimpleSelectStmt(pStmt->dbName, pStmt->tableName, pOutput);
|
||||
return createSimpleSelectStmt(pStmt->dbName, pStmt->tableName, 0, NULL, pOutput);
|
||||
}
|
||||
|
||||
static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SNode* pRight, SNode** pOp) {
|
||||
|
@ -6675,7 +6816,7 @@ static int32_t rewriteFlushDatabase(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pQuery->pRoot)) {
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCES_STMT:
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,25 +35,25 @@ void generateInformationSchema(MockCatalogService* mcs) {
|
|||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
.addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MNODES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
.addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MODULES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
.addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_QNODES, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||
.addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
|
@ -70,7 +70,8 @@ void generateInformationSchema(MockCatalogService* mcs) {
|
|||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_INDEXES, TSDB_SYSTEM_TABLE, 2)
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_INDEXES, TSDB_SYSTEM_TABLE, 3)
|
||||
.addColumn("index_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN)
|
||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
|
@ -98,7 +99,7 @@ void generateInformationSchema(MockCatalogService* mcs) {
|
|||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USERS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
||||
builder.done();
|
||||
}
|
||||
{
|
||||
|
@ -122,7 +123,7 @@ void generateInformationSchema(MockCatalogService* mcs) {
|
|||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CLUSTER, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("id", TSDB_DATA_TYPE_BIGINT);
|
||||
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN);
|
||||
builder.done();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -294,16 +294,6 @@ TEST_F(ParserSelectTest, intervalSemanticCheck) {
|
|||
TEST_F(ParserSelectTest, interp) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT INTERP(c1) FROM t1");
|
||||
|
||||
run("SELECT INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00')");
|
||||
|
||||
run("SELECT INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') FILL(LINEAR)");
|
||||
|
||||
run("SELECT INTERP(c1) FROM t1 EVERY(5s)");
|
||||
|
||||
run("SELECT INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') EVERY(5s)");
|
||||
|
||||
run("SELECT INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR)");
|
||||
}
|
||||
|
||||
|
|
|
@ -1615,6 +1615,9 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
|
|||
if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode)) {
|
||||
TSWAP(((SPartitionLogicNode*)pNode)->pPartitionKeys, pScan->pGroupTags);
|
||||
int32_t code = replaceLogicNode(pLogicSubplan, pNode, (SLogicNode*)pScan);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = adjustLogicNodeDataRequirement((SLogicNode*)pScan, pNode->resultDataOrder);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
NODES_CLEAR_LIST(pNode->pChildren);
|
||||
nodesDestroyNode((SNode*)pNode);
|
||||
|
|
|
@ -93,8 +93,6 @@ TEST_F(PlanBasicTest, tailFunc) {
|
|||
TEST_F(PlanBasicTest, interpFunc) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("SELECT INTERP(c1) FROM t1");
|
||||
|
||||
run("SELECT INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR)");
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 0, 8)
|
||||
tdSql.query("select count(*) from db.stb2")
|
||||
tdSql.checkData(0, 0, 160)
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkData(2, 14, "us")
|
||||
|
||||
tdSql.execute("reset query cache")
|
||||
|
@ -128,7 +128,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 0, 8)
|
||||
tdSql.query("select count(*) from db.stb3")
|
||||
tdSql.checkData(0, 0, 160)
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkData(2, 14, "ns")
|
||||
|
||||
tdSql.execute("reset query cache")
|
||||
|
|
|
@ -97,7 +97,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -85,7 +85,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -86,7 +86,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -96,7 +96,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -96,7 +96,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -92,7 +92,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -92,7 +92,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -g" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -94,7 +94,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -94,7 +94,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -90,7 +90,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -90,7 +90,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -90,7 +90,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -90,7 +90,7 @@ class TDTestCase:
|
|||
|
||||
os.system("%staosdump -i %s -T 1 -g" % (binPath, self.tmpdir))
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
|
|
@ -24,11 +24,11 @@ class TDTestCase:
|
|||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def run(self):
|
||||
tdSql.query("show users")
|
||||
tdSql.query("select * from information_schema.ins_users")
|
||||
rows = tdSql.queryRows
|
||||
|
||||
tdSql.execute("create user test PASS 'test' ")
|
||||
tdSql.query("show users")
|
||||
tdSql.query("select * from information_schema.ins_users")
|
||||
tdSql.checkRows(rows + 1)
|
||||
|
||||
tdSql.error("create user tdenginetdenginetdengine PASS 'test' ")
|
||||
|
|
|
@ -41,7 +41,7 @@ class TDTestCase:
|
|||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,15,0)
|
||||
buildPath = self.getBuildPath()
|
||||
if (buildPath == ""):
|
||||
|
@ -68,7 +68,7 @@ class TDTestCase:
|
|||
for i in range(5):
|
||||
#switch lastRow to off and check
|
||||
tdSql.execute('alter database db cachemodel 'none'')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,15,0)
|
||||
|
||||
#run last_row(*) query 500 times
|
||||
|
@ -80,7 +80,7 @@ class TDTestCase:
|
|||
|
||||
#switch lastRow to on and check
|
||||
tdSql.execute('alter database db cachemodel 'last_row'')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,15,1)
|
||||
|
||||
#run last_row(*) query 500 times
|
||||
|
|
|
@ -49,7 +49,7 @@ class TDTestCase:
|
|||
tdSql.error('create database db keep "3650"')
|
||||
tdSql.error('create database db wal_fsync_period "3650"')
|
||||
tdSql.execute('create database db precision "us"')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,16,'us')
|
||||
tdSql.execute('drop database if exists db')
|
||||
|
||||
|
@ -79,7 +79,7 @@ class TDTestCase:
|
|||
tdSql.error('alter database db keep ,,60,')
|
||||
tdSql.error('alter database db keep \t')
|
||||
tdSql.execute('alter database db keep \t50')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'50,50,50')
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -37,7 +37,7 @@ class TDTestCase:
|
|||
if randomFlag != 131 and randomFlag != 135 and randomFlag != 143:
|
||||
tdSql.error("alter local %s %d" % (flag, randomFlag))
|
||||
|
||||
tdSql.query("show dnodes")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
dnodeId = tdSql.getData(0, 0)
|
||||
|
||||
for flag in flagList:
|
||||
|
|
|
@ -27,12 +27,12 @@ class TDTestCase:
|
|||
tdLog.notice('running Keep Test, Community Version')
|
||||
tdLog.notice('running parameter test for keep during create')
|
||||
#testing keep parameter during create
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'3650')
|
||||
tdSql.execute('drop database db')
|
||||
|
||||
tdSql.execute('create database db keep 100')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'100')
|
||||
tdSql.execute('drop database db')
|
||||
|
||||
|
@ -47,7 +47,7 @@ class TDTestCase:
|
|||
tdLog.notice('running parameter test for keep during alter')
|
||||
|
||||
tdSql.execute('alter database db keep 100')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'100')
|
||||
|
||||
tdSql.error('alter database db keep ')
|
||||
|
@ -55,7 +55,7 @@ class TDTestCase:
|
|||
tdSql.error('alter database db keep 10,20')
|
||||
tdSql.error('alter database db keep 10,20,30')
|
||||
tdSql.error('alter database db keep 20,30,40,50')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'100')
|
||||
|
||||
def alterKeepEnterprise(self):
|
||||
|
@ -63,22 +63,22 @@ class TDTestCase:
|
|||
#testing keep parameter during create
|
||||
tdLog.notice('running parameter test for keep during create')
|
||||
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'3650,3650,3650')
|
||||
tdSql.execute('drop database db')
|
||||
|
||||
tdSql.execute('create database db keep 100')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'100,100,100')
|
||||
tdSql.execute('drop database db')
|
||||
|
||||
tdSql.execute('create database db keep 20, 30')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'20,30,30')
|
||||
tdSql.execute('drop database db')
|
||||
|
||||
tdSql.execute('create database db keep 30,40,50')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'30,40,50')
|
||||
tdSql.execute('drop database db')
|
||||
|
||||
|
@ -95,15 +95,15 @@ class TDTestCase:
|
|||
tdLog.notice('running parameter test for keep during alter')
|
||||
|
||||
tdSql.execute('alter database db keep 10')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'10,10,10')
|
||||
|
||||
tdSql.execute('alter database db keep 20,30')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'20,30,30')
|
||||
|
||||
tdSql.execute('alter database db keep 100,200,300')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'100,200,300')
|
||||
|
||||
tdSql.error('alter database db keep ')
|
||||
|
@ -113,7 +113,7 @@ class TDTestCase:
|
|||
tdSql.error('alter database db keep 100,40,50')
|
||||
tdSql.error('alter database db keep 20,100,50')
|
||||
tdSql.error('alter database db keep 50,60,20')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'100,200,300')
|
||||
|
||||
|
||||
|
@ -148,7 +148,7 @@ class TDTestCase:
|
|||
#test case for TD-4459 and TD-4445
|
||||
tdLog.notice('testing keep will be altered changing from small to big')
|
||||
tdSql.execute('alter database db keep 40,40,40')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'40,40,40')
|
||||
tdSql.error('insert into tb values (now-60d, 10)')
|
||||
tdSql.execute('insert into tb values (now-30d, 10)')
|
||||
|
@ -160,7 +160,7 @@ class TDTestCase:
|
|||
rowNum += 1
|
||||
tdSql.execute('alter database db keep 20,20,20')
|
||||
tdSql.execute('alter database db keep 40,40,40')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'40,40,40')
|
||||
tdSql.error('insert into tb values (now-60d, 10)')
|
||||
tdSql.execute('insert into tb values (now-30d, 10)')
|
||||
|
@ -169,7 +169,7 @@ class TDTestCase:
|
|||
|
||||
tdLog.notice('testing keep will be altered changing from big to small')
|
||||
tdSql.execute('alter database db keep 10,10,10')
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkData(0,7,'10,10,10')
|
||||
tdSql.error('insert into tb values (now-15d, 10)')
|
||||
tdSql.query('select * from tb')
|
||||
|
|
|
@ -21,7 +21,7 @@ class TDTestCase:
|
|||
# check default update value
|
||||
sql = "create database if not exists db"
|
||||
tdSql.execute(sql)
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,0)
|
||||
|
||||
|
@ -29,14 +29,14 @@ class TDTestCase:
|
|||
|
||||
# check update value
|
||||
tdSql.execute(sql)
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,1)
|
||||
|
||||
|
||||
sql = "alter database db update 0"
|
||||
tdSql.execute(sql)
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,0)
|
||||
|
||||
|
@ -46,7 +46,7 @@ class TDTestCase:
|
|||
sql = "alter database db update 100"
|
||||
tdSql.error(sql)
|
||||
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,0)
|
||||
|
||||
|
@ -56,7 +56,7 @@ class TDTestCase:
|
|||
|
||||
tdSql.execute('create database db update 1')
|
||||
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,16,1)
|
||||
|
||||
|
|
|
@ -29,18 +29,18 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 0, "db")
|
||||
|
||||
tdSql.execute("alter database db comp 2")
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkData(0, 14, 2)
|
||||
|
||||
tdSql.execute("alter database db keep 365,365,365")
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkData(0, 7, "365,365,365")
|
||||
|
||||
tdSql.error("alter database db quorum 2")
|
||||
|
||||
|
||||
tdSql.execute("alter database db blocks 100")
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkData(0, 9, 100)
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class TDTestCase:
|
|||
|
||||
time.sleep(1)
|
||||
|
||||
ret = tdSql.query('show dnodes')
|
||||
ret = tdSql.query('select * from information_schema.ins_dnodes')
|
||||
|
||||
dnodeId = tdSql.getData(0, 0);
|
||||
dnodeEndpoint = tdSql.getData(0, 1);
|
||||
|
@ -47,7 +47,7 @@ class TDTestCase:
|
|||
|
||||
time.sleep(1)
|
||||
|
||||
ret = tdSql.query('show mnodes')
|
||||
ret = tdSql.query('select * from information_schema.ins_mnodes')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 2, "master")
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class ClusterTestcase:
|
|||
tdSql.init(ctest.conn.cursor(), False)
|
||||
|
||||
nodes.node1.stopTaosd()
|
||||
tdSql.query("show dnodes")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0, 4, "offline")
|
||||
tdSql.checkData(1, 4, "ready")
|
||||
|
@ -43,7 +43,7 @@ class ClusterTestcase:
|
|||
tdSql.checkData(2, 4, "ready")
|
||||
|
||||
nodes.node2.stopTaosd()
|
||||
tdSql.query("show dnodes")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0, 4, "ready")
|
||||
tdSql.checkData(1, 4, "offline")
|
||||
|
@ -56,7 +56,7 @@ class ClusterTestcase:
|
|||
tdSql.checkData(2, 4, "ready")
|
||||
|
||||
nodes.node3.stopTaosd()
|
||||
tdSql.query("show dnodes")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0, 4, "ready")
|
||||
tdSql.checkData(1, 4, "ready")
|
||||
|
|
|
@ -33,7 +33,7 @@ class ClusterTestcase:
|
|||
nodes.node3.stopTaosd()
|
||||
|
||||
tdLog.sleep(10)
|
||||
tdSql.query("show dnodes")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(2, 4, "offline")
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class ClusterTestcase:
|
|||
tdSql.execute("drop database %s" % ctest.dbName)
|
||||
|
||||
nodes.node2.startTaosd()
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.close()
|
||||
|
|
|
@ -26,19 +26,19 @@ class ClusterTestcase:
|
|||
ctest = ClusterTest(nodes.node1.hostName)
|
||||
tdSql.init(ctest.conn.cursor(), False)
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
count = tdSql.queryRows;
|
||||
|
||||
nodes.stopAllTaosd()
|
||||
nodes.node1.startTaosd()
|
||||
tdSql.error("show databases")
|
||||
tdSql.error("select * from information_schema.ins_databases")
|
||||
|
||||
nodes.node2.startTaosd()
|
||||
tdSql.error("show databases")
|
||||
tdSql.error("select * from information_schema.ins_databases")
|
||||
|
||||
nodes.node3.startTaosd()
|
||||
tdLog.sleep(10)
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(count)
|
||||
|
||||
ct = ClusterTestcase()
|
||||
|
|
|
@ -29,19 +29,19 @@ class ClusterTestcase:
|
|||
ctest.run()
|
||||
tdSql.init(ctest.conn.cursor(), False)
|
||||
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
count = tdSql.queryRows;
|
||||
tdSql.execute("use %s" % ctest.dbName)
|
||||
tdSql.execute("alter database %s replica 3" % ctest.dbName)
|
||||
nodes.node2.stopTaosd()
|
||||
nodes.node3.stopTaosd()
|
||||
tdSql.error("show databases")
|
||||
tdSql.error("select * from information_schema.ins_databases")
|
||||
|
||||
nodes.node2.startTaosd()
|
||||
tdSql.error("show databases")
|
||||
tdSql.error("select * from information_schema.ins_databases")
|
||||
|
||||
nodes.node3.startTaosd()
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkRows(count)
|
||||
|
||||
ct = ClusterTestcase()
|
||||
|
|
|
@ -996,7 +996,7 @@ class StateMechine:
|
|||
return # do nothing
|
||||
|
||||
# this should show up in the server log, separating steps
|
||||
dbc.execute("show dnodes")
|
||||
dbc.execute("select * from information_schema.ins_dnodes")
|
||||
|
||||
# Generic Checks, first based on the start state
|
||||
if not Config.getConfig().ignore_errors: # verify state, only if we are asked not to ignore certain errors.
|
||||
|
@ -2042,7 +2042,7 @@ class TaskRestartService(StateTransitionTask):
|
|||
|
||||
if Dice.throw(self.CHANCE_TO_RESTART_SERVICE) == 0: # 1 in N chance
|
||||
dbc = wt.getDbConn()
|
||||
dbc.execute("show databases") # simple delay, align timing with other workers
|
||||
dbc.execute("select * from information_schema.ins_databases") # simple delay, align timing with other workers
|
||||
gSvcMgr.restart()
|
||||
|
||||
self._isRunning = False
|
||||
|
@ -2335,7 +2335,7 @@ class ClientManager:
|
|||
# def _printLastNumbers(self): # to verify data durability
|
||||
# dbManager = DbManager()
|
||||
# dbc = dbManager.getDbConn()
|
||||
# if dbc.query("show databases") <= 1: # no database (we have a default called "log")
|
||||
# if dbc.query("select * from information_schema.ins_databases") <= 1: # no database (we have a default called "log")
|
||||
# return
|
||||
# dbc.execute("use db")
|
||||
# if dbc.query("show tables") == 0: # no tables
|
||||
|
|
|
@ -185,7 +185,7 @@ quorum 2
|
|||
return ["exec " + self.getExecFile(), '-c', self.getCfgDir()] # used in subproce.Popen()
|
||||
|
||||
def _getDnodes(self, dbc):
|
||||
dbc.query("show dnodes")
|
||||
dbc.query("select * from information_schema.ins_dnodes")
|
||||
cols = dbc.getQueryResult() # id,end_point,vnodes,cores,status,role,create_time,offline reason
|
||||
return {c[1]:c[4] for c in cols} # {'xxx:6030':'ready', 'xxx:6130':'ready'}
|
||||
|
||||
|
@ -768,7 +768,7 @@ class ServiceManagerThread:
|
|||
def _verifyDnode(self, tInst: TdeInstance):
|
||||
dbc = DbConn.createNative(tInst.getDbTarget())
|
||||
dbc.open()
|
||||
dbc.query("show dnodes")
|
||||
dbc.query("select * from information_schema.ins_dnodes")
|
||||
# dbc.query("DESCRIBE {}.{}".format(dbName, self._stName))
|
||||
cols = dbc.getQueryResult() # id,end_point,vnodes,cores,status,role,create_time,offline reason
|
||||
# ret = {row[0]:row[1] for row in stCols if row[3]=='TAG'} # name:type
|
||||
|
|
|
@ -114,7 +114,7 @@ class DbConn:
|
|||
|
||||
def existsDatabase(self, dbName: str):
|
||||
''' Check if a certain database exists '''
|
||||
self.query("show databases")
|
||||
self.query("select * from information_schema.ins_databases")
|
||||
dbs = [v[0] for v in self.getQueryResult()] # ref: https://stackoverflow.com/questions/643823/python-list-transformation
|
||||
# ret2 = dbName in dbs
|
||||
# print("dbs = {}, str = {}, ret2={}, type2={}".format(dbs, dbName,ret2, type(dbName)))
|
||||
|
@ -157,7 +157,7 @@ class DbConn:
|
|||
def getResultCols(self):
|
||||
raise RuntimeError("Unexpected execution, should be overriden")
|
||||
|
||||
# Sample: curl -u root:taosdata -d "show databases" localhost:6020/rest/sql
|
||||
# Sample: curl -u root:taosdata -d "select * from information_schema.ins_databases" localhost:6020/rest/sql
|
||||
|
||||
|
||||
class DbConnRest(DbConn):
|
||||
|
|
|
@ -47,7 +47,7 @@ class TDTestCase:
|
|||
tdLog.info('create database %s' % db_name)
|
||||
tdSql.execute('create database %s' % db_name)
|
||||
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0, db_name.lower())
|
||||
|
||||
|
@ -57,7 +57,7 @@ class TDTestCase:
|
|||
tdLog.info('create database %s' % db_name)
|
||||
tdSql.execute('create database %s' % db_name)
|
||||
|
||||
tdSql.query('show databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 0, db_name.lower())
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class TDTestCase:
|
|||
tdSql.execute('reset query cache')
|
||||
tdSql.execute('drop database if exists db')
|
||||
tdSql.execute('create database db precision "ns";')
|
||||
tdSql.query('show databases;')
|
||||
tdSql.query('select * from information_schema.ins_databases;')
|
||||
tdSql.checkData(0,16,'ns')
|
||||
tdSql.execute('use db')
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class TDTestCase:
|
|||
tdSql.query("show variables")
|
||||
tdSql.checkData(26, 1, -1)
|
||||
|
||||
tdSql.query("show dnodes")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
index = tdSql.getData(0, 0)
|
||||
|
||||
tdDnodes.stop(index)
|
||||
|
@ -269,7 +269,7 @@ class TDTestCase:
|
|||
tdSql.execute("create database if not exists db")
|
||||
tdSql.query("show variables")
|
||||
tdSql.checkData(38, 1, 3650)
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkData(0,7,"3650,3650,3650")
|
||||
|
||||
days = tdSql.getData(0, 6)
|
||||
|
@ -288,12 +288,12 @@ class TDTestCase:
|
|||
tdSql.error("alter database db keep0 36500")
|
||||
|
||||
tdSql.execute("alter database db keep 36500")
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkData(0, 7, "3650,3650,36500")
|
||||
tdSql.execute("drop database if exists db")
|
||||
|
||||
tdSql.execute("create database if not exists db1")
|
||||
tdSql.query("show databases")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.checkData(0, 7, "3650,3650,3650")
|
||||
tdSql.query("show variables")
|
||||
tdSql.checkData(38, 1, 3650)
|
||||
|
@ -311,7 +311,7 @@ class TDTestCase:
|
|||
maxTablesPerVnode = 10
|
||||
maxVgroupsPerDb = 100
|
||||
|
||||
tdSql.query("show dnodes")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
index = tdSql.getData(0, 0)
|
||||
|
||||
tdDnodes.stop(index)
|
||||
|
@ -334,7 +334,7 @@ class TDTestCase:
|
|||
for i in range(100):
|
||||
tdSql.execute(f"create table db.t1{i} using db.stb1 tags({i})")
|
||||
insert_sql += f" t1{i} values({1604298064000 + i*1000}, {i})"
|
||||
tdSql.query("show dnodes")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
vnode_count = tdSql.getData(0, 2)
|
||||
if vnode_count <= 1:
|
||||
tdLog.exit("vnode is less than 2")
|
||||
|
@ -443,7 +443,7 @@ class TDTestCase:
|
|||
# f50, f51, f52, f53 = tdSql.getData(0,1), tdSql.getData(0,2), tdSql.getData(0,3), tdSql.getData(0,4)
|
||||
|
||||
# 关闭服务并获取未开启压缩情况下的数据容量
|
||||
tdSql.query("show dnodes")
|
||||
tdSql.query("select * from information_schema.ins_dnodes")
|
||||
index = tdSql.getData(0, 0)
|
||||
tdDnodes.stop(index)
|
||||
|
||||
|
|
|
@ -174,9 +174,9 @@ class TDTestCase:
|
|||
# TSIM: sql drop database $db
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
# TSIM: sql show databases
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
# TSIM: sql select * from information_schema.ins_databases
|
||||
tdLog.info('select * from information_schema.ins_databases')
|
||||
tdSql.query('select * from information_schema.ins_databases')
|
||||
# TSIM: if $rows != 0 then
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
|
|
|
@ -33,7 +33,7 @@ class TDTestCase:
|
|||
tdLog.info("\n\n----------step1 : drop db and create db----------\n")
|
||||
tdSql.execute('''drop database if exists db ;''')
|
||||
tdSql.execute('''create database db ;''')
|
||||
sql = '''show databases;'''
|
||||
sql = '''select * from information_schema.ins_databases;'''
|
||||
tdSql.query(sql)
|
||||
tdSql.checkRows(1)
|
||||
|
||||
|
@ -41,7 +41,7 @@ class TDTestCase:
|
|||
tdSql.execute('''create stable
|
||||
db.stable_1 (ts timestamp, payload binary(256))
|
||||
tags(t1 binary(16),t2 int);''')
|
||||
sql = '''show db.stables;'''
|
||||
sql = '''select * from information_schema.ins_stables where db_name = 'db';'''
|
||||
tdSql.query(sql)
|
||||
tdSql.checkRows(1)
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue