diff --git a/.gitmodules b/.gitmodules index 34a2da2894..9d649bcdd3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule "tools/taosadapter"] path = tools/taosadapter url = https://github.com/taosdata/taosadapter.git +[submodule "tools/taosws-rs"] + path = tools/taosws-rs + url = https://github.com/taosdata/taosws-rs.git diff --git a/README-CN.md b/README-CN.md index c78050c7bc..39d979c123 100644 --- a/README-CN.md +++ b/README-CN.md @@ -1,38 +1,59 @@ +

+

+ + TDengine + +

+

+ [![Build Status](https://travis-ci.org/taosdata/TDengine.svg?branch=master)](https://travis-ci.org/taosdata/TDengine) [![Build status](https://ci.appveyor.com/api/projects/status/kf3pwh2or5afsgl9/branch/master?svg=true)](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master) [![Coverage Status](https://coveralls.io/repos/github/taosdata/TDengine/badge.svg?branch=develop)](https://coveralls.io/github/taosdata/TDengine?branch=develop) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4201/badge)](https://bestpractices.coreinfrastructure.org/projects/4201) [![tdengine](https://snapcraft.io//tdengine/badge.svg)](https://snapcraft.io/tdengine) -[![TDengine](TDenginelogo.png)](https://www.taosdata.com) - -简体中文 | [English](./README.md) +简体中文 | [English](README.md) | 很多职位正在热招中,请看[这里](https://www.taosdata.com/cn/careers/) # TDengine 简介 -TDengine是涛思数据专为物联网、车联网、工业互联网、IT运维等设计和优化的大数据平台。除核心的快10倍以上的时序数据库功能外,还提供缓存、数据订阅、流式计算等功能,最大程度减少研发和运维的复杂度,且核心代码,包括集群功能全部开源(开源协议,AGPL v3.0)。 +TDengine 是一款高性能、分布式、支持 SQL 的时序数据库(Time-Series Database)。而且除时序数据库功能外,它还提供缓存、数据订阅、流式计算等功能,最大程度减少研发和运维的复杂度,且核心代码,包括集群功能全部开源(开源协议,AGPL v3.0)。与其他时序数据数据库相比,TDengine 有以下特点: -- 10 倍以上性能提升。定义了创新的数据存储结构,单核每秒就能处理至少2万次请求,插入数百万个数据点,读出一千万以上数据点,比现有通用数据库快了十倍以上。 -- 硬件或云服务成本降至1/5。由于超强性能,计算资源不到通用大数据方案的1/5;通过列式存储和先进的压缩算法,存储空间不到通用数据库的1/10。 -- 全栈时序数据处理引擎。将数据库、消息队列、缓存、流式计算等功能融合一起,应用无需再集成Kafka/Redis/HBase/Spark等软件,大幅降低应用开发和维护成本。 -- 强大的分析功能。无论是十年前还是一秒钟前的数据,指定时间范围即可查询。数据可在时间轴上或多个设备上进行聚合。即席查询可通过Shell/Python/R/Matlab随时进行。 -- 与第三方工具无缝连接。不用一行代码,即可与Telegraf, Grafana, EMQ X, Prometheus, Matlab, R集成。后续还将支持MQTT, OPC, Hadoop,Spark等, BI工具也将无缝连接。 -- 零运维成本、零学习成本。安装、集群一秒搞定,无需分库分表,实时备份。标准SQL,支持JDBC,RESTful,支持Python/Java/C/C++/Go/Node.JS, 与MySQL相似,零学习成本。 +- **高性能**:通过创新的存储引擎设计,无论是数据写入还是查询,TDengine 的性能比通用数据库快 10 倍以上,也远超其他时序数据库,而且存储空间也大为节省。 + +- **分布式**:通过原生分布式的设计,TDengine 提供了水平扩展的能力,只需要增加节点就能获得更强的数据处理能力,同时通过多副本机制保证了系统的高可用。 + +- **支持 SQL**:TDengine 采用 SQL 作为数据查询语言,减少学习和迁移成本,同时提供 SQL 扩展来处理时序数据特有的分析,而且支持方便灵活的 schemaless 数据写入。 + +- **All in One**:将数据库、消息队列、缓存、流式计算等功能融合一起,应用无需再集成 Kafka/Redis/HBase/Spark 等软件,大幅降低应用开发和维护成本。 + +- **零管理**:安装、集群几秒搞定,无任何依赖,不用分库分表,系统运行状态监测能与 Grafana 或其他运维工具无缝集成。 + +- **零学习成本**:采用 SQL 查询语言,支持 Python、Java、C/C++、Go、Rust、Node.js 等多种编程语言,与 MySQL 相似,零学习成本。 + +- **无缝集成**:不用一行代码,即可与 Telegraf、Grafana、EMQX、Prometheus、StatsD、collectd、Matlab、R 等第三方工具无缝集成。 + +- **互动 Console**: 通过命令行 console,不用编程,执行 SQL 语句就能做即席查询、各种数据库的操作、管理以及集群的维护. + +TDengine 可以广泛应用于物联网、工业互联网、车联网、IT 运维、能源、金融等领域,让大量设备、数据采集器每天产生的高达 TB 甚至 PB 级的数据能得到高效实时的处理,对业务的运行状态进行实时的监测、预警,从大数据中挖掘出商业价值。 # 文档 -TDengine是一个高效的存储、查询、分析时序大数据的平台,专为物联网、车联网、工业互联网、运维监测等优化而设计。您可以像使用关系型数据库MySQL一样来使用它,但建议您在使用前仔细阅读一遍下面的文档,特别是 [数据模型](https://www.taosdata.com/cn/documentation/architecture) 与 [数据建模](https://www.taosdata.com/cn/documentation/model)。除本文档之外,欢迎 [下载产品白皮书](https://www.taosdata.com/downloads/TDengine%20White%20Paper.pdf)。 +TDengine 采用传统的关系数据库模型,您可以像使用关系型数据库 MySQL 一样来使用它。但由于引入了超级表,一个采集点一张表的概念,建议您在使用前仔细阅读一遍下面的文档,特别是 [数据模型](https://www.taosdata.com/cn/documentation/architecture) 与 [数据建模](https://www.taosdata.com/cn/documentation/model)。除本文档之外,欢迎 [下载产品白皮书](https://www.taosdata.com/downloads/TDengine%20White%20Paper.pdf)。 # 构建 -TDengine目前2.0版服务器仅能在Linux系统上安装和运行,后续会支持Windows、macOS等系统。客户端可以在Windows或Linux上安装和运行。任何OS的应用也可以选择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/#通过安装包安装)来安装。本快速指南仅适用于通过源码安装。 +TDengine 目前 2.0 版服务器仅能在 Linux 系统上安装和运行,后续会支持 Windows、macOS 等系统。客户端可以在 Windows 或 Linux 上安装和运行。任何 OS 的应用也可以选择 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/#通过安装包安装)来安装。本快速指南仅适用于通过源码安装。 ## 安装工具 ### Ubuntu 16.04 及以上版本 & Debian: ```bash -sudo apt-get install -y gcc cmake build-essential git +sudo apt-get install -y gcc cmake build-essential git libssl-dev ``` ### Ubuntu 14.04: @@ -56,10 +77,22 @@ sudo apt-get install -y openjdk-8-jdk sudo apt-get install -y maven ``` +#### 为 taos-tools 安装编译需要的软件 + +taosTools 是用于 TDengine 的辅助工具软件集合。目前它包含 taosBenchmark(曾命名为 taosdemo)和 taosdump 两个软件。 + +默认 TDengine 编译不包含 taosTools。您可以在编译 TDengine 时使用`cmake .. -DBUILD_TOOLS=true` 来同时编译 taosTools。 + +为了在 Ubuntu/Debian 系统上编译 [taos-tools](https://github.com/taosdata/taos-tools) 需要安装如下软件: + +```bash +sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config +``` + ### CentOS 7: ```bash -sudo yum install -y gcc gcc-c++ make cmake git +sudo yum install -y gcc gcc-c++ make cmake git openssl-devel ``` 安装 OpenJDK 8: @@ -74,10 +107,10 @@ sudo yum install -y java-1.8.0-openjdk sudo yum install -y maven ``` -### CentOS 8 & Fedora: +### CentOS 8 & Fedora ```bash -sudo dnf install -y gcc gcc-c++ make cmake epel-release git +sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel ``` 安装 OpenJDK 8: @@ -92,6 +125,33 @@ sudo dnf install -y java-1.8.0-openjdk sudo dnf install -y maven ``` +#### 在 CentOS 上构建 taosTools 安装依赖软件 + +为了在 CentOS 上构建 [taosTools](https://github.com/taosdata/taos-tools) 需要安装如下依赖软件 + +```bash +sudo yum install 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,实际上工作正常。 + +### 设置 golang 开发环境 + +TDengine 包含数个使用 Go 语言开发的组件,请参考 golang.org 官方文档设置 go 开发环境。 + +请使用 1.14 及以上版本。对于中国用户,我们建议使用代理来加速软件包下载。 + +``` +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.cn,direct +``` + +### 设置 rust 开发环境 + +TDengine 包含数个使用 Rust 语言开发的组件. 请参考 rust-lang.org 官方文档设置 rust 开发环境。 + ## 获取源码 首先,你需要从 GitHub 克隆源码: @@ -107,22 +167,41 @@ Go 连接器和 Grafana 插件在其他独立仓库,如果安装它们的话 git submodule update --init --recursive ``` +如果使用 https 协议下载比较慢,可以通过修改 ~/.gitconfig 文件添加以下两行设置使用 ssh 协议下载。需要首先上传 ssh 密钥到 GitHub,详细方法请参考 GitHub 官方文档。 + +``` +[url "git@github.com:"] + insteadOf = https://github.com/ +``` + ## 构建 TDengine ### Linux 系统 +可以运行代码仓库中的 `build.sh` 脚本编译出 TDengine 和 taosTools(包含 taosBenchmark 和 taosdump)。 + ```bash -mkdir debug && cd debug -cmake .. && cmake --build . +./build.sh ``` -您可以选择使用 Jemalloc 作为内存分配器,替代默认的 glibc: +这个脚本等价于执行如下命令: + +```bash +git submodule update --init --recursive +mkdir debug +cd debug +cmake .. -DBUILD_TOOLS=true +make +``` + +您也可以选择使用 jemalloc 作为内存分配器,替代默认的 glibc: + ```bash apt install autoconf cmake .. -DJEMALLOC_ENABLED=true ``` -在X86-64、X86、arm64、arm32 和 mips64 平台上,TDengine 生成脚本可以自动检测机器架构。也可以手动配置 CPUTYPE 参数来指定 CPU 类型,如 aarch64 或 aarch32 等。 +在 X86-64、X86、arm64、arm32 和 mips64 平台上,TDengine 生成脚本可以自动检测机器架构。也可以手动配置 CPUTYPE 参数来指定 CPU 类型,如 aarch64 或 aarch32 等。 aarch64: @@ -157,7 +236,7 @@ nmake 如果你使用的是 Visual Studio 2019 或 2017 版本: -打开cmd.exe,执行 vcvarsall.bat 时,为 64 位操作系统指定“x64”,为 32 位操作系统指定“x86”。 +打开 cmd.exe,执行 vcvarsall.bat 时,为 64 位操作系统指定“x64”,为 32 位操作系统指定“x86”。 ```bash mkdir debug && cd debug @@ -174,9 +253,7 @@ cmake .. -G "NMake Makefiles" nmake ``` -如果你使用的是 Visual Studio 2022 版本, 脚本 `vcvarsall.bat` 的默认安装路径是 `C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat`。 - -### Mac OS X 系统 +### macOS 系统 安装 Xcode 命令行工具和 cmake. 在 Catalina 和 Big Sur 操作系统上,需要安装 XCode 11.4+ 版本。 @@ -187,13 +264,17 @@ cmake .. && cmake --build . # 安装 -生成完成后,安装 TDengine(下文给出的指令以 Linux 为例,如果是在 Windows 下,那么对应的指令会是 `nmake install`): +## Linux 系统 + +生成完成后,安装 TDengine: ```bash sudo make install ``` 用户可以在[文件目录结构](https://www.taosdata.com/cn/documentation/administrator#directories)中了解更多在操作系统中生成的目录或文件。 +从 2.0 版本开始, 从源代码安装也会为 TDengine 配置服务管理。 +用户也可以选择[从安装包中安装](https://www.taosdata.com/en/getting-started/#Install-from-Package)。 安装成功后,在终端中启动 TDengine 服务: @@ -209,6 +290,40 @@ taos 如果 TDengine Shell 连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印出错误消息。 +## Windows 系统 + +生成完成后,安装 TDengine: + +```cmd +nmake install +``` + +## macOS 系统 + +生成完成后,安装 TDengine: + +```bash +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 ): @@ -227,15 +342,15 @@ taos # 体验 TDengine -在TDengine终端中,用户可以通过SQL命令来创建/删除数据库、表等,并进行插入查询操作。 +在 TDengine 终端中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行插入查询操作。 -```bash -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; +```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 | =================================== 19-07-15 00:00:00.000| 10| @@ -247,33 +362,35 @@ Query OK, 2 row(s) in set (0.001700s) ## 官方连接器 -TDengine 提供了丰富的应用程序开发接口,其中包括C/C++、Java、Python、Go、Node.js、C# 、RESTful 等,便于用户快速开发应用: +TDengine 提供了丰富的应用程序开发接口,其中包括 C/C++、Java、Python、Go、Node.js、C# 、RESTful 等,便于用户快速开发应用: -- Java +- [Java](https://www.taosdata.com/cn/documentation/connector/java) -- C/C++ +- [C/C++](https://www.taosdata.com/cn/documentation/connector#c-cpp) -- Python +- [Python](https://www.taosdata.com/cn/documentation/connector#python) -- Go +- [Go](https://www.taosdata.com/cn/documentation/connector#go) -- RESTful API +- [RESTful API](https://www.taosdata.com/cn/documentation/connector#restful) -- Node.js +- [Node.js](https://www.taosdata.com/cn/documentation/connector#nodejs) + +- [Rust](https://www.taosdata.com/cn/documentation/connector/rust) ## 第三方连接器 TDengine 社区生态中也有一些非常友好的第三方连接器,可以通过以下链接访问它们的源码。 -- [Rust Connector](https://github.com/taosdata/TDengine/tree/master/tests/examples/rust) +- [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) +- [Lua Connector](https://github.com/taosdata/TDengine/tree/develop/examples/lua) # 运行和添加测试例 TDengine 的测试框架和所有测试例全部开源。 -点击 [这里](tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md),了解如何运行测试例和添加新的测试例。 +点击 [这里](https://github.com/taosdata/TDengine/blob/develop/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md),了解如何运行测试例和添加新的测试例。 # 成为社区贡献者 @@ -281,8 +398,8 @@ TDengine 的测试框架和所有测试例全部开源。 # 加入技术交流群 -TDengine 官方社群「物联网大数据群」对外开放,欢迎您加入讨论。搜索微信号 "tdengine",加小T为好友,即可入群。 +TDengine 官方社群「物联网大数据群」对外开放,欢迎您加入讨论。搜索微信号 "tdengine",加小 T 为好友,即可入群。 -# [谁在使用TDengine](https://github.com/taosdata/TDengine/issues/2432) +# [谁在使用 TDengine](https://github.com/taosdata/TDengine/issues/2432) -欢迎所有 TDengine 用户及贡献者在 [这里](https://github.com/taosdata/TDengine/issues/2432) 分享您在当前工作中开发/使用 TDengine 的故事。 +欢迎所有 TDengine 用户及贡献者在 [这里](https://github.com/taosdata/TDengine/issues/2432) 分享您在当前工作中开发/使用 TDengine 的故事。 diff --git a/README.md b/README.md index 48349e891e..d4b8321813 100644 --- a/README.md +++ b/README.md @@ -1,116 +1,218 @@ +

+

+ + TDengine + +

+

+ [![Build Status](https://cloud.drone.io/api/badges/taosdata/TDengine/status.svg?ref=refs/heads/master)](https://cloud.drone.io/taosdata/TDengine) [![Build status](https://ci.appveyor.com/api/projects/status/kf3pwh2or5afsgl9/branch/master?svg=true)](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master) [![Coverage Status](https://coveralls.io/repos/github/taosdata/TDengine/badge.svg?branch=develop)](https://coveralls.io/github/taosdata/TDengine?branch=develop) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4201/badge)](https://bestpractices.coreinfrastructure.org/projects/4201) [![tdengine](https://snapcraft.io//tdengine/badge.svg)](https://snapcraft.io/tdengine) -[![TDengine](TDenginelogo.png)](https://www.taosdata.com) - -English | [简体中文](./README-CN.md) +English | [简体中文](README-CN.md) | We are hiring, check [here](https://tdengine.com/careers) # What is TDengine? -TDengine is an open-sourced big data platform under [GNU AGPL v3.0](http://www.gnu.org/licenses/agpl-3.0.html), designed and optimized for the Internet of Things (IoT), Connected Cars, Industrial IoT, and IT Infrastructure and Application Monitoring. Besides the 10x faster time-series database, it provides caching, stream computing, message queuing and other functionalities to reduce the complexity and cost of development and operation. +TDengine is a high-performance, scalable time-series database with SQL support. Its code including cluster feature is open source under [GNU AGPL v3.0](http://www.gnu.org/licenses/agpl-3.0.html). Besides the database, it provides caching, stream processing, data subscription and other functionalities to reduce the complexity and cost of development and operation. TDengine differentiates itself from other TSDBs with the following advantages. -- **10x Faster on Insert/Query Speeds**: Through the innovative design on storage, on a single-core machine, over 20K requests can be processed, millions of data points can be ingested, and over 10 million data points can be retrieved in a second. It is 10 times faster than other databases. +- **High Performance**: TDengine outperforms other time series databases in data ingestion and querying while significantly reducing storage cost and compute costs, with an innovatively designed and purpose-built storage engine. -- **1/5 Hardware/Cloud Service Costs**: Compared with typical big data solutions, less than 1/5 of computing resources are required. Via column-based storage and tuned compression algorithms for different data types, less than 1/10 of storage space is needed. +- **Scalable**: TDengine provides out-of-box scalability and high-availability through its native distributed design. Nodes can be added through simple configuration to achieve greater data processing power. In addition, this feature is open source. -- **Full Stack for Time-Series Data**: By integrating a database with message queuing, caching, and stream computing features together, it is no longer necessary to integrate Kafka/Redis/HBase/Spark or other software. It makes the system architecture much simpler and more robust. +- **SQL Support**: TDengine uses SQL as the query language, thereby reducing learning and migration costs, while adding SQL extensions to handle time-series data better, and supporting convenient and flexible schemaless data ingestion. -- **Powerful Data Analysis**: Whether it is 10 years or one minute ago, data can be queried just by specifying the time range. Data can be aggregated over time, multiple time streams or both. Ad Hoc queries or analyses can be executed via TDengine shell, Python, R or Matlab. +- **All in One**: TDengine has built-in caching, stream processing and data subscription functions, it is no longer necessary to integrate Kafka/Redis/HBase/Spark or other software in some scenarios. It makes the system architecture much simpler and easy to maintain. -- **Seamless Integration with Other Tools**: Telegraf, Grafana, Matlab, R, and other tools can be integrated with TDengine without a line of code. MQTT, OPC, Hadoop, Spark, and many others will be integrated soon. +- **Seamless Integration**: Without a single line of code, TDengine provide seamless integration with third-party tools such as Telegraf, Grafana, EMQX, Prometheus, StatsD, collectd, etc. More will be integrated. -- **Zero Management, No Learning Curve**: It takes only seconds to download, install, and run it successfully; there are no other dependencies. Automatic partitioning on tables or DBs. Standard SQL is used, with C/C++, Python, JDBC, Go and RESTful connectors. +- **Zero Management**: Installation and cluster setup can be done in seconds. Data partitioning and sharding are executed automatically. TDengine’s running status can be monitored via Grafana or other DevOps tools. + +- **Zero Learning Cost**: With SQL as the query language, support for ubiquitous tools like Python, Java, C/C++, Go, Rust, Node.js connectors, there is zero learning cost. + +- **Interactive Console**: TDengine provides convenient console access to the database to run ad hoc queries, maintain the database, or manage the cluster without any programming. + +TDengine can be widely applied to Internet of Things (IoT), Connected Vehicles, Industrial IoT, DevOps, energy, finance and many other scenarios. # Documentation + For user manual, system design and architecture, engineering blogs, refer to [TDengine Documentation](https://www.taosdata.com/en/documentation/)(中文版请点击[这里](https://www.taosdata.com/cn/documentation20/)) - for details. The documentation from our website can also be downloaded locally from *documentation/tdenginedocs-en* or *documentation/tdenginedocs-cn*. +for details. The documentation from our website can also be downloaded locally from _documentation/tdenginedocs-en_ or _documentation/tdenginedocs-cn_. # Building -At the moment, TDengine only supports building and running on Linux systems. You can choose to [install from packages](https://www.taosdata.com/en/getting-started/#Install-from-Package) or from the source code. This quick guide is for installation from the source only. -To build TDengine, use [CMake](https://cmake.org/) 2.8.12.x or higher versions in the project directory. +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. -## Install tools +To build TDengine, use [CMake](https://cmake.org/) 3.0.2 or higher versions in the project directory. + +## Install build dependencies + +### Ubuntu 16.04 and above or Debian -### Ubuntu 16.04 and above & Debian: ```bash -sudo apt-get install -y gcc cmake build-essential git +sudo apt-get install -y gcc cmake build-essential git libssl-dev ``` -### Ubuntu 14.04: +### Ubuntu 14.04 + ```bash sudo apt-get install -y gcc cmake3 build-essential git binutils-2.26 export PATH=/usr/lib/binutils-2.26/bin:$PATH ``` -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 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 +sudo apt-get install -y maven ``` -### Centos 7: +#### 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. +By default, TDengine compiling does not include taosTools. You can use 'cmake .. -DBUILD_TOOLS=true' to make them be compiled with TDengine. + +To build the [taosTools](https://github.com/taosdata/taos-tools) on Ubuntu/Debian, the following packages need to be installed. + ```bash -sudo yum install -y gcc gcc-c++ make cmake git +sudo apt install build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev pkg-config +``` + +### CentOS 7 + +```bash +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 ``` 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: +### CentOS 8 & Fedora + ```bash -sudo dnf install -y gcc gcc-c++ make cmake epel-release git +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. + +```bash +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. + +### Setup golang environment + +TDengine includes 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. + +``` +go env -w GO111MODULE=on +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. + ## Get the source codes First of all, you may clone the source codes from github: + ```bash git clone https://github.com/taosdata/TDengine.git cd TDengine ``` -The connectors for go & grafana have been moved to separated repositories, +The connectors for go & Grafana and some tools have been moved to separated repositories, so you should run this command in the TDengine directory to install them: + ```bash git submodule update --init --recursive ``` +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. + +``` +[url "git@github.com:"] + insteadOf = https://github.com/ +``` + ## Build TDengine ### On Linux platform +You can run the bash script `build.sh` to build both TDengine and taosTools including taosBenchmark and taosdump as below: + ```bash -mkdir debug && cd debug -cmake .. && cmake --build . +./build.sh +``` + +It equals to execute following commands: + +```bash +git submodule update --init --recursive +mkdir debug +cd debug +cmake .. -DBUILD_TOOLS=true +make +``` + +Note TDengine 2.3.x.0 and later use a component named 'taosAdapter' to play http daemon role by default instead of the http daemon embedded in the early version of TDengine. The taosAdapter is programmed by go language. If you pull TDengine source code to the latest from an existing codebase, please execute 'git submodule update --init --recursive' to pull taosAdapter source code. Please install go language version 1.14 or above for compiling taosAdapter. If you meet difficulties regarding 'go mod', especially you are from China, you can use a proxy to solve the problem. + +``` +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.cn,direct +``` + +The embedded http daemon still be built from TDengine source code by default. Or you can use the following command to choose to build taosAdapter. + +``` +cmake .. -DBUILD_HTTP=false ``` You can use Jemalloc as memory allocator instead of glibc: + ``` apt install autoconf cmake .. -DJEMALLOC_ENABLED=true @@ -120,24 +222,28 @@ TDengine build script can detect the host machine's architecture on X86-64, X86, You can also specify CPUTYPE option like aarch64 or aarch32 too if the detection result is not correct: aarch64: + ```bash cmake .. -DCPUTYPE=aarch64 && cmake --build . ``` aarch32: + ```bash cmake .. -DCPUTYPE=aarch32 && cmake --build . ``` mips64: + ```bash cmake .. -DCPUTYPE=mips64 && cmake --build . ``` ### On Windows platform -If you use Visual Studio 2013, please open a command window by executing "cmd.exe". +If you use the Visual Studio 2013, please open a command window by executing "cmd.exe". Please specify "amd64" for 64 bits Windows or specify "x86" is for 32 bits Windows when you execute vcvarsall.bat. + ```cmd mkdir debug && cd debug "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" < amd64 | x86 > @@ -145,7 +251,7 @@ cmake .. -G "NMake Makefiles" nmake ``` -If you use Visual Studio 2019 or 2017: +If you use the Visual Studio 2019 or 2017: please open a command window by executing "cmd.exe". Please specify "x64" for 64 bits Windows or specify "x86" is for 32 bits Windows when you execute vcvarsall.bat. @@ -158,15 +264,14 @@ nmake ``` Or, you can simply open a command window by clicking Windows Start -> "Visual Studio < 2019 | 2017 >" folder -> "x64 Native Tools Command Prompt for VS < 2019 | 2017 >" or "x86 Native Tools Command Prompt for VS < 2019 | 2017 >" depends what architecture your Windows is, then execute commands as follows: + ```cmd mkdir debug && cd debug cmake .. -G "NMake Makefiles" nmake ``` -If you use Visual Studio 2022, the only change is the default path of `vcvarsall.bat`, which is `C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat`. - -### On Mac OS X platform +### On macOS platform Please install XCode command line tools and cmake. Verified with XCode 11.4+ on Catalina and Big Sur. @@ -177,7 +282,10 @@ cmake .. && cmake --build . # Installing -After building successfully, TDengine can be installed by: (On Windows platform, the following command should be `nmake install`) +## On Linux platform + +After building successfully, TDengine can be installed by + ```bash sudo make install ``` @@ -186,68 +294,129 @@ Users can find more information about directories installed on the system in the Users can also choose to [install from packages](https://www.taosdata.com/en/getting-started/#Install-from-Package) for it. To start the service after installation, in a terminal, use: + ```bash sudo systemctl start taosd ``` Then users can use the [TDengine shell](https://www.taosdata.com/en/getting-started/#TDengine-Shell) to connect the TDengine server. In a terminal, use: + ```bash taos ``` If TDengine shell connects the server successfully, welcome messages and version info are printed. Otherwise, an error message is shown. +### Install TDengine by apt-get + +If you use Debian or Ubuntu system, you can use 'apt-get' command to install TDengine from official repository. Please use following commands to setup: + +``` +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 +[Optional] echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list +sudo apt-get update +apt-cache policy tdengine +sudo apt-get install tdengine +``` + +## On Windows platform + +After building successfully, TDengine can be installed by: + +```cmd +nmake install +``` + +## On macOS platform + +After building successfully, TDengine can be installed by: + +```bash +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`) + ```bash ./build/bin/taosd -c test/cfg ``` In another terminal, use the TDengine shell to connect the server: + ```bash ./build/bin/taos -c test/cfg ``` -option "-c test/cfg" specifies the system configuration file directory. +option "-c test/cfg" specifies the system configuration file directory. # Try TDengine + It is easy to run SQL commands from TDengine shell which is the same as other SQL databases. + ```sql -create database db; -use db; -create table t (ts timestamp, a int); -insert into t values ('2019-07-15 00:00:00', 1); -insert into t values ('2019-07-15 01:00:00', 2); -select * from t; -drop database db; +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 | +=================================== + 19-07-15 00:00:00.000| 10| + 19-07-15 01:00:00.000| 20| +Query OK, 2 row(s) in set (0.001700s) ``` # Developing with TDengine -### Official Connectors + +## Official Connectors TDengine provides abundant developing tools for users to develop on TDengine. Follow the links below to find your desired connectors and relevant documentation. -- [Java](https://www.taosdata.com/en/documentation/connector/#Java-Connector) -- [C/C++](https://www.taosdata.com/en/documentation/connector/#C/C++-Connector) -- [Python](https://www.taosdata.com/en/documentation/connector/#Python-Connector) -- [Go](https://www.taosdata.com/en/documentation/connector/#Go-Connector) -- [RESTful API](https://www.taosdata.com/en/documentation/connector/#RESTful-Connector) -- [Node.js](https://www.taosdata.com/en/documentation/connector/#Node.js-Connector) +- [Java](https://www.taosdata.com/en/documentation/connector/java) +- [C/C++](https://www.taosdata.com/en/documentation/connector#c-cpp) +- [Python](https://www.taosdata.com/en/documentation/connector#python) +- [Go](https://www.taosdata.com/en/documentation/connector#go) +- [RESTful API](https://www.taosdata.com/en/documentation/connector#restful) +- [Node.js](https://www.taosdata.com/en/documentation/connector#nodejs) +- [Rust](https://www.taosdata.com/en/documentation/connector/rust) -### Third Party Connectors +## 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 Connector](https://github.com/taosdata/TDengine/tree/master/tests/examples/rust) +- [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) -# 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. - Please refer to [this document](tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md) for how to run test and develop new test case. +# 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. +Please refer to [this document](https://github.com/taosdata/TDengine/blob/develop/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md) for how to run test and develop new test case. # TDengine Roadmap + - Support event-driven stream computing - Support user defined functions - Support MQTT connection diff --git a/cmake/cmake.define b/cmake/cmake.define index b5d5c6d957..a33db902ca 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -18,6 +18,14 @@ if (NOT DEFINED TD_GRANT) SET(TD_GRANT FALSE) endif() +IF ("${WEBSOCKET}" MATCHES "true") + SET(TD_WEBSOCKET TRUE) + MESSAGE("Enable websocket") + ADD_DEFINITIONS(-DWEBSOCKET) +ELSE () + SET(TD_WEBSOCKET FALSE) +ENDIF () + IF ("${BUILD_HTTP}" STREQUAL "") IF (TD_LINUX) IF (TD_ARM_32) @@ -97,10 +105,10 @@ ELSE () SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}") ENDIF () - IF (${SANITIZER} MATCHES "true") + IF (${BUILD_SANITIZER}) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0") - MESSAGE(STATUS "Will compile with Address Sanitizer!") + MESSAGE(STATUS "Will compile with Address Sanitizer!") ELSE () SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=0") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=0") diff --git a/cmake/cmake.options b/cmake/cmake.options index 09236a5b87..e013ff7592 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -77,6 +77,12 @@ ELSE () ENDIF () ENDIF () +option( + BUILD_SANITIZER + "If build addr2line" + OFF + ) + option( BUILD_ADDR2LINE "If build addr2line" diff --git a/docs/en/25-application/03-immigrate.md b/docs/en/25-application/03-immigrate.md index 4d47aec1d7..fe67f97389 100644 --- a/docs/en/25-application/03-immigrate.md +++ b/docs/en/25-application/03-immigrate.md @@ -379,11 +379,11 @@ We still use the hypothetical environment from Chapter 4. There are three measur ### Storage resource estimation -Assuming that the number of sensor devices that generate data and need to be stored is `n`, the frequency of data generation is `t` per second, and the length of each record is `L` bytes, the scale of data generated per day is `n * t * L` bytes. Assuming the compression ratio is `C`, the daily data size is `(n * t * L)/C` bytes. The storage resources are estimated to accommodate the data scale for 1.5 years. In the production environment, the compression ratio C of TDengine is generally between 5 and 7. +Assuming that the number of sensor devices that generate data and need to be stored is `n`, the frequency of data generation is `t` per second, and the length of each record is `L` bytes, the scale of data generated per day is `86400 * n * t * L` bytes. Assuming the compression ratio is `C`, the daily data size is `(86400 * n * t * L)/C` bytes. The storage resources are estimated to accommodate the data scale for 1.5 years. In the production environment, the compression ratio C of TDengine is generally between 5 and 7. With additional 20% redundancy, you can calculate the required storage resources: ```matlab -(n * t * L) * (365 * 1.5) * (1+20%)/C +(86400 * n * t * L) * (365 * 1.5) * (1+20%)/C ```` Substituting in the above formula, the raw data generated every year is 11.8TB without considering the label information. Note that tag information is associated with each timeline in TDengine, not every record. The amount of data to be recorded is somewhat reduced relative to the generated data, and label data can be ignored as a whole. Assuming a compression ratio of 5, the size of the retained data ends up being 2.56 TB. diff --git a/docs/zh/25-application/03-immigrate.md b/docs/zh/25-application/03-immigrate.md index 9d8946bc4a..d1c9caea09 100644 --- a/docs/zh/25-application/03-immigrate.md +++ b/docs/zh/25-application/03-immigrate.md @@ -367,10 +367,10 @@ WHERE ts>=1510560000 AND ts<=1515000009 ### 存储资源估算 -假设产生数据并需要存储的传感器设备数量为 `n`,数据生成的频率为`t`条/秒,每条记录的长度为 `L` bytes,则每天产生的数据规模为 `n×t×L` bytes。假设压缩比为 C,则每日产生数据规模为 `(n×t×L)/C` bytes。存储资源预估为能够容纳 1.5 年的数据规模,生产环境下 TDengine 的压缩比 C 一般在 5 ~ 7 之间,同时为最后结果增加 20% 的冗余,可计算得到需要存储资源: +假设产生数据并需要存储的传感器设备数量为 `n`,数据生成的频率为`t`条/秒,每条记录的长度为 `L` bytes,则每天产生的数据规模为 `86400×n×t×L` bytes。假设压缩比为 C,则每日产生数据规模为 `(86400×n×t×L)/C` bytes。存储资源预估为能够容纳 1.5 年的数据规模,生产环境下 TDengine 的压缩比 C 一般在 5 ~ 7 之间,同时为最后结果增加 20% 的冗余,可计算得到需要存储资源: ```matlab -(n×t×L)×(365×1.5)×(1+20%)/C +(86400×n×t×L)×(365×1.5)×(1+20%)/C ``` 结合以上的计算公式,将参数带入计算公式,在不考虑标签信息的情况下,每年产生的原始数据规模是 11.8TB。需要注意的是,由于标签信息在 TDengine 中关联到每个时间线,并不是每条记录。所以需要记录的数据量规模相对于产生的数据有一定的降低,而这部分标签数据整体上可以忽略不记。假设压缩比为 5,则保留的数据规模最终为 2.56 TB。 diff --git a/examples/c/tmq.c b/examples/c/tmq.c index 74efb4c026..5d7f1bbe70 100644 --- a/examples/c/tmq.c +++ b/examples/c/tmq.c @@ -28,15 +28,23 @@ static void msg_process(TAOS_RES* msg) { printf("db: %s\n", tmq_get_db_name(msg)); printf("vg: %d\n", tmq_get_vgroup_id(msg)); if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) { - void* meta; - int32_t metaLen; - tmq_get_raw_meta(msg, &meta, &metaLen); + tmq_raw_data *raw = tmq_get_raw_meta(msg); + if(raw){ + TAOS* pConn = taos_connect("192.168.1.86", "root", "taosdata", "abc1", 0); + if (pConn == NULL) { + return; + } + int32_t ret = taos_write_raw_meta(pConn, raw); + printf("write raw data: %s\n", tmq_err2str(ret)); + free(raw); + taos_close(pConn); + } char* result = tmq_get_json_meta(msg); if(result){ printf("meta result: %s\n", result); free(result); } - printf("meta, len is %d\n", metaLen); + printf("meta:%p\n", raw); return; } while (1) { diff --git a/include/client/taos.h b/include/client/taos.h index 216a5832b0..362782b420 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -260,15 +260,16 @@ enum tmq_res_t { }; typedef enum tmq_res_t tmq_res_t; +typedef struct tmq_raw_data tmq_raw_data; -DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res); -DLL_EXPORT int32_t tmq_get_raw_meta(TAOS_RES *res, void **raw_meta, int32_t *raw_meta_len); -DLL_EXPORT int32_t taos_write_raw_meta(TAOS *res, void *raw_meta, int32_t raw_meta_len); -DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed. -DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res); -DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res); -DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res); -DLL_EXPORT const char *tmq_get_table_name(TAOS_RES *res); +DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res); +DLL_EXPORT tmq_raw_data *tmq_get_raw_meta(TAOS_RES *res); +DLL_EXPORT int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta); +DLL_EXPORT char *tmq_get_json_meta(TAOS_RES *res); // Returning null means error. Returned result need to be freed. +DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res); +DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res); +DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res); +DLL_EXPORT const char *tmq_get_table_name(TAOS_RES *res); /* ------------------------------ TMQ END -------------------------------- */ diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 63167bd834..28d771bbbd 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -55,7 +55,8 @@ enum { enum { STREAM_INPUT__DATA_SUBMIT = 1, STREAM_INPUT__DATA_BLOCK, - STREAM_INPUT__DATA_SCAN, + STREAM_INPUT__TABLE_SCAN, + STREAM_INPUT__TQ_SCAN, STREAM_INPUT__DATA_RETRIEVE, STREAM_INPUT__TRIGGER, STREAM_INPUT__CHECKPOINT, @@ -88,8 +89,6 @@ typedef struct { #pragma pack(push, 1) typedef struct SColumnDataAgg { int16_t colId; - int16_t minIndex; - int16_t maxIndex; int16_t numOfNull; int64_t sum; int64_t max; @@ -124,7 +123,8 @@ enum { }; typedef struct { - int8_t fetchType; + int8_t fetchType; + STqOffsetVal offset; union { SSDataBlock data; void* meta; diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 8b64287033..af333f72aa 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -231,7 +231,7 @@ SSDataBlock* createDataBlock(); int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData); SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId); -SColumnInfoData* bdGetColumnInfoData(SSDataBlock* pBlock, int32_t index); +SColumnInfoData* bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index); void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress); const char* blockDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData); diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 49cee753d8..03b456b212 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -57,8 +57,8 @@ extern int32_t tMsgDict[]; #define TMSG_SEG_SEQ(TYPE) ((TYPE)&0xff) #define TMSG_INFO(TYPE) \ ((TYPE) >= 0 && \ - ((TYPE) < TDMT_DND_MAX_MSG | (TYPE) < TDMT_MND_MAX_MSG | (TYPE) < TDMT_VND_MAX_MSG | (TYPE) < TDMT_SCH_MAX_MSG | \ - (TYPE) < TDMT_STREAM_MAX_MSG | (TYPE) < TDMT_MON_MAX_MSG | (TYPE) < TDMT_SYNC_MAX_MSG)) \ + ((TYPE) < TDMT_DND_MAX_MSG || (TYPE) < TDMT_MND_MAX_MSG || (TYPE) < TDMT_VND_MAX_MSG || (TYPE) < TDMT_SCH_MAX_MSG || \ + (TYPE) < TDMT_STREAM_MAX_MSG || (TYPE) < TDMT_MON_MAX_MSG || (TYPE) < TDMT_SYNC_MAX_MSG)) \ ? tMsgInfo[tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)] \ : 0 #define TMSG_INDEX(TYPE) (tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)) @@ -169,6 +169,9 @@ typedef enum _mgmt_table { #define TD_CHILD_TABLE TSDB_CHILD_TABLE #define TD_NORMAL_TABLE TSDB_NORMAL_TABLE +#define TD_REQ_FROM_APP 0 +#define TD_REQ_FROM_TAOX 1 + typedef struct { int32_t vgId; char* dbFName; @@ -432,25 +435,30 @@ static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaW STSchema* tdGetSTSChemaFromSSChema(SSchema** pSchema, int32_t nCols); typedef struct { - char name[TSDB_TABLE_FNAME_LEN]; - int8_t igExists; - int64_t delay1; - int64_t delay2; - int64_t watermark1; - int64_t watermark2; - int32_t ttl; - int32_t numOfColumns; - int32_t numOfTags; - int32_t numOfFuncs; - int32_t commentLen; - int32_t ast1Len; - int32_t ast2Len; - SArray* pColumns; // array of SField - SArray* pTags; // array of SField - SArray* pFuncs; - char* pComment; - char* pAst1; - char* pAst2; + char name[TSDB_TABLE_FNAME_LEN]; + int8_t igExists; + int8_t source; // 1-taosX or 0-taosClient + int8_t reserved[6]; + tb_uid_t suid; + int64_t delay1; + int64_t delay2; + int64_t watermark1; + int64_t watermark2; + int32_t ttl; + int32_t colVer; + int32_t tagVer; + int32_t numOfColumns; + int32_t numOfTags; + int32_t numOfFuncs; + int32_t commentLen; + int32_t ast1Len; + int32_t ast2Len; + SArray* pColumns; // array of SField + SArray* pTags; // array of SField + SArray* pFuncs; + char* pComment; + char* pAst1; + char* pAst2; } SMCreateStbReq; int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq); @@ -458,8 +466,11 @@ int32_t tDeserializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pR void tFreeSMCreateStbReq(SMCreateStbReq* pReq); typedef struct { - char name[TSDB_TABLE_FNAME_LEN]; - int8_t igNotExists; + char name[TSDB_TABLE_FNAME_LEN]; + int8_t igNotExists; + int8_t source; // 1-taosX or 0-taosClient + int8_t reserved[6]; + tb_uid_t suid; } SMDropStbReq; int32_t tSerializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq); @@ -468,8 +479,6 @@ int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq); typedef struct { char name[TSDB_TABLE_FNAME_LEN]; int8_t alterType; - int32_t tagVer; - int32_t colVer; int32_t numOfFields; SArray* pFields; int32_t ttl; @@ -665,6 +674,7 @@ typedef struct { char tbFName[TSDB_TABLE_FNAME_LEN]; int32_t sversion; int32_t tversion; + int64_t affectedRows; } SQueryTableRsp; int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp); @@ -1510,6 +1520,7 @@ typedef struct SSubQueryMsg { int32_t execId; int8_t taskType; int8_t explain; + int8_t needFetch; uint32_t sqlLen; // the query sql, uint32_t phyLen; char msg[]; diff --git a/include/common/tname.h b/include/common/tname.h index 3bf1cee870..77965947ad 100644 --- a/include/common/tname.h +++ b/include/common/tname.h @@ -37,6 +37,8 @@ typedef struct SName { char tname[TSDB_TABLE_NAME_LEN]; } SName; +SName* toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName); + int32_t tNameExtractFullName(const SName* name, char* dst); int32_t tNameLen(const SName* name); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index a5651f96f4..5deec2d5f6 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -79,195 +79,196 @@ #define TK_EXISTS 61 #define TK_BUFFER 62 #define TK_CACHELAST 63 -#define TK_COMP 64 -#define TK_DURATION 65 -#define TK_NK_VARIABLE 66 -#define TK_FSYNC 67 -#define TK_MAXROWS 68 -#define TK_MINROWS 69 -#define TK_KEEP 70 -#define TK_PAGES 71 -#define TK_PAGESIZE 72 -#define TK_PRECISION 73 -#define TK_REPLICA 74 -#define TK_STRICT 75 -#define TK_WAL 76 -#define TK_VGROUPS 77 -#define TK_SINGLE_STABLE 78 -#define TK_RETENTIONS 79 -#define TK_SCHEMALESS 80 -#define TK_NK_COLON 81 -#define TK_TABLE 82 -#define TK_NK_LP 83 -#define TK_NK_RP 84 -#define TK_STABLE 85 -#define TK_ADD 86 -#define TK_COLUMN 87 -#define TK_MODIFY 88 -#define TK_RENAME 89 -#define TK_TAG 90 -#define TK_SET 91 -#define TK_NK_EQ 92 -#define TK_USING 93 -#define TK_TAGS 94 -#define TK_COMMENT 95 -#define TK_BOOL 96 -#define TK_TINYINT 97 -#define TK_SMALLINT 98 -#define TK_INT 99 -#define TK_INTEGER 100 -#define TK_BIGINT 101 -#define TK_FLOAT 102 -#define TK_DOUBLE 103 -#define TK_BINARY 104 -#define TK_TIMESTAMP 105 -#define TK_NCHAR 106 -#define TK_UNSIGNED 107 -#define TK_JSON 108 -#define TK_VARCHAR 109 -#define TK_MEDIUMBLOB 110 -#define TK_BLOB 111 -#define TK_VARBINARY 112 -#define TK_DECIMAL 113 -#define TK_MAX_DELAY 114 -#define TK_WATERMARK 115 -#define TK_ROLLUP 116 -#define TK_TTL 117 -#define TK_SMA 118 -#define TK_FIRST 119 -#define TK_LAST 120 -#define TK_SHOW 121 -#define TK_DATABASES 122 -#define TK_TABLES 123 -#define TK_STABLES 124 -#define TK_MNODES 125 -#define TK_MODULES 126 -#define TK_QNODES 127 -#define TK_FUNCTIONS 128 -#define TK_INDEXES 129 -#define TK_ACCOUNTS 130 -#define TK_APPS 131 -#define TK_CONNECTIONS 132 -#define TK_LICENCE 133 -#define TK_GRANTS 134 -#define TK_QUERIES 135 -#define TK_SCORES 136 -#define TK_TOPICS 137 -#define TK_VARIABLES 138 -#define TK_BNODES 139 -#define TK_SNODES 140 -#define TK_CLUSTER 141 -#define TK_TRANSACTIONS 142 -#define TK_DISTRIBUTED 143 -#define TK_CONSUMERS 144 -#define TK_SUBSCRIPTIONS 145 -#define TK_LIKE 146 -#define TK_INDEX 147 -#define TK_FUNCTION 148 -#define TK_INTERVAL 149 -#define TK_TOPIC 150 -#define TK_AS 151 -#define TK_WITH 152 -#define TK_META 153 -#define TK_CONSUMER 154 -#define TK_GROUP 155 -#define TK_DESC 156 -#define TK_DESCRIBE 157 -#define TK_RESET 158 -#define TK_QUERY 159 -#define TK_CACHE 160 -#define TK_EXPLAIN 161 -#define TK_ANALYZE 162 -#define TK_VERBOSE 163 -#define TK_NK_BOOL 164 -#define TK_RATIO 165 -#define TK_NK_FLOAT 166 -#define TK_COMPACT 167 -#define TK_VNODES 168 -#define TK_IN 169 -#define TK_OUTPUTTYPE 170 -#define TK_AGGREGATE 171 -#define TK_BUFSIZE 172 -#define TK_STREAM 173 -#define TK_INTO 174 -#define TK_TRIGGER 175 -#define TK_AT_ONCE 176 -#define TK_WINDOW_CLOSE 177 -#define TK_IGNORE 178 -#define TK_EXPIRED 179 -#define TK_KILL 180 -#define TK_CONNECTION 181 -#define TK_TRANSACTION 182 -#define TK_BALANCE 183 -#define TK_VGROUP 184 -#define TK_MERGE 185 -#define TK_REDISTRIBUTE 186 -#define TK_SPLIT 187 -#define TK_SYNCDB 188 -#define TK_DELETE 189 -#define TK_INSERT 190 -#define TK_NULL 191 -#define TK_NK_QUESTION 192 -#define TK_NK_ARROW 193 -#define TK_ROWTS 194 -#define TK_TBNAME 195 -#define TK_QSTARTTS 196 -#define TK_QENDTS 197 -#define TK_WSTARTTS 198 -#define TK_WENDTS 199 -#define TK_WDURATION 200 -#define TK_CAST 201 -#define TK_NOW 202 -#define TK_TODAY 203 -#define TK_TIMEZONE 204 -#define TK_CLIENT_VERSION 205 -#define TK_SERVER_VERSION 206 -#define TK_SERVER_STATUS 207 -#define TK_CURRENT_USER 208 -#define TK_COUNT 209 -#define TK_LAST_ROW 210 -#define TK_BETWEEN 211 -#define TK_IS 212 -#define TK_NK_LT 213 -#define TK_NK_GT 214 -#define TK_NK_LE 215 -#define TK_NK_GE 216 -#define TK_NK_NE 217 -#define TK_MATCH 218 -#define TK_NMATCH 219 -#define TK_CONTAINS 220 -#define TK_JOIN 221 -#define TK_INNER 222 -#define TK_SELECT 223 -#define TK_DISTINCT 224 -#define TK_WHERE 225 -#define TK_PARTITION 226 -#define TK_BY 227 -#define TK_SESSION 228 -#define TK_STATE_WINDOW 229 -#define TK_SLIDING 230 -#define TK_FILL 231 -#define TK_VALUE 232 -#define TK_NONE 233 -#define TK_PREV 234 -#define TK_LINEAR 235 -#define TK_NEXT 236 -#define TK_HAVING 237 -#define TK_RANGE 238 -#define TK_EVERY 239 -#define TK_ORDER 240 -#define TK_SLIMIT 241 -#define TK_SOFFSET 242 -#define TK_LIMIT 243 -#define TK_OFFSET 244 -#define TK_ASC 245 -#define TK_NULLS 246 -#define TK_ID 247 -#define TK_NK_BITNOT 248 -#define TK_VALUES 249 -#define TK_IMPORT 250 -#define TK_NK_SEMI 251 -#define TK_FILE 252 +#define TK_CACHELASTSIZE 64 +#define TK_COMP 65 +#define TK_DURATION 66 +#define TK_NK_VARIABLE 67 +#define TK_FSYNC 68 +#define TK_MAXROWS 69 +#define TK_MINROWS 70 +#define TK_KEEP 71 +#define TK_PAGES 72 +#define TK_PAGESIZE 73 +#define TK_PRECISION 74 +#define TK_REPLICA 75 +#define TK_STRICT 76 +#define TK_WAL 77 +#define TK_VGROUPS 78 +#define TK_SINGLE_STABLE 79 +#define TK_RETENTIONS 80 +#define TK_SCHEMALESS 81 +#define TK_NK_COLON 82 +#define TK_TABLE 83 +#define TK_NK_LP 84 +#define TK_NK_RP 85 +#define TK_STABLE 86 +#define TK_ADD 87 +#define TK_COLUMN 88 +#define TK_MODIFY 89 +#define TK_RENAME 90 +#define TK_TAG 91 +#define TK_SET 92 +#define TK_NK_EQ 93 +#define TK_USING 94 +#define TK_TAGS 95 +#define TK_COMMENT 96 +#define TK_BOOL 97 +#define TK_TINYINT 98 +#define TK_SMALLINT 99 +#define TK_INT 100 +#define TK_INTEGER 101 +#define TK_BIGINT 102 +#define TK_FLOAT 103 +#define TK_DOUBLE 104 +#define TK_BINARY 105 +#define TK_TIMESTAMP 106 +#define TK_NCHAR 107 +#define TK_UNSIGNED 108 +#define TK_JSON 109 +#define TK_VARCHAR 110 +#define TK_MEDIUMBLOB 111 +#define TK_BLOB 112 +#define TK_VARBINARY 113 +#define TK_DECIMAL 114 +#define TK_MAX_DELAY 115 +#define TK_WATERMARK 116 +#define TK_ROLLUP 117 +#define TK_TTL 118 +#define TK_SMA 119 +#define TK_FIRST 120 +#define TK_LAST 121 +#define TK_SHOW 122 +#define TK_DATABASES 123 +#define TK_TABLES 124 +#define TK_STABLES 125 +#define TK_MNODES 126 +#define TK_MODULES 127 +#define TK_QNODES 128 +#define TK_FUNCTIONS 129 +#define TK_INDEXES 130 +#define TK_ACCOUNTS 131 +#define TK_APPS 132 +#define TK_CONNECTIONS 133 +#define TK_LICENCE 134 +#define TK_GRANTS 135 +#define TK_QUERIES 136 +#define TK_SCORES 137 +#define TK_TOPICS 138 +#define TK_VARIABLES 139 +#define TK_BNODES 140 +#define TK_SNODES 141 +#define TK_CLUSTER 142 +#define TK_TRANSACTIONS 143 +#define TK_DISTRIBUTED 144 +#define TK_CONSUMERS 145 +#define TK_SUBSCRIPTIONS 146 +#define TK_LIKE 147 +#define TK_INDEX 148 +#define TK_FUNCTION 149 +#define TK_INTERVAL 150 +#define TK_TOPIC 151 +#define TK_AS 152 +#define TK_WITH 153 +#define TK_META 154 +#define TK_CONSUMER 155 +#define TK_GROUP 156 +#define TK_DESC 157 +#define TK_DESCRIBE 158 +#define TK_RESET 159 +#define TK_QUERY 160 +#define TK_CACHE 161 +#define TK_EXPLAIN 162 +#define TK_ANALYZE 163 +#define TK_VERBOSE 164 +#define TK_NK_BOOL 165 +#define TK_RATIO 166 +#define TK_NK_FLOAT 167 +#define TK_COMPACT 168 +#define TK_VNODES 169 +#define TK_IN 170 +#define TK_OUTPUTTYPE 171 +#define TK_AGGREGATE 172 +#define TK_BUFSIZE 173 +#define TK_STREAM 174 +#define TK_INTO 175 +#define TK_TRIGGER 176 +#define TK_AT_ONCE 177 +#define TK_WINDOW_CLOSE 178 +#define TK_IGNORE 179 +#define TK_EXPIRED 180 +#define TK_KILL 181 +#define TK_CONNECTION 182 +#define TK_TRANSACTION 183 +#define TK_BALANCE 184 +#define TK_VGROUP 185 +#define TK_MERGE 186 +#define TK_REDISTRIBUTE 187 +#define TK_SPLIT 188 +#define TK_SYNCDB 189 +#define TK_DELETE 190 +#define TK_INSERT 191 +#define TK_NULL 192 +#define TK_NK_QUESTION 193 +#define TK_NK_ARROW 194 +#define TK_ROWTS 195 +#define TK_TBNAME 196 +#define TK_QSTARTTS 197 +#define TK_QENDTS 198 +#define TK_WSTARTTS 199 +#define TK_WENDTS 200 +#define TK_WDURATION 201 +#define TK_CAST 202 +#define TK_NOW 203 +#define TK_TODAY 204 +#define TK_TIMEZONE 205 +#define TK_CLIENT_VERSION 206 +#define TK_SERVER_VERSION 207 +#define TK_SERVER_STATUS 208 +#define TK_CURRENT_USER 209 +#define TK_COUNT 210 +#define TK_LAST_ROW 211 +#define TK_BETWEEN 212 +#define TK_IS 213 +#define TK_NK_LT 214 +#define TK_NK_GT 215 +#define TK_NK_LE 216 +#define TK_NK_GE 217 +#define TK_NK_NE 218 +#define TK_MATCH 219 +#define TK_NMATCH 220 +#define TK_CONTAINS 221 +#define TK_JOIN 222 +#define TK_INNER 223 +#define TK_SELECT 224 +#define TK_DISTINCT 225 +#define TK_WHERE 226 +#define TK_PARTITION 227 +#define TK_BY 228 +#define TK_SESSION 229 +#define TK_STATE_WINDOW 230 +#define TK_SLIDING 231 +#define TK_FILL 232 +#define TK_VALUE 233 +#define TK_NONE 234 +#define TK_PREV 235 +#define TK_LINEAR 236 +#define TK_NEXT 237 +#define TK_HAVING 238 +#define TK_RANGE 239 +#define TK_EVERY 240 +#define TK_ORDER 241 +#define TK_SLIMIT 242 +#define TK_SOFFSET 243 +#define TK_LIMIT 244 +#define TK_OFFSET 245 +#define TK_ASC 246 +#define TK_NULLS 247 +#define TK_ID 248 +#define TK_NK_BITNOT 249 +#define TK_VALUES 250 +#define TK_IMPORT 251 +#define TK_NK_SEMI 252 +#define TK_FILE 253 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/executor/dataSinkMgt.h b/include/libs/executor/dataSinkMgt.h index 957c40f21e..8d5a8abcb4 100644 --- a/include/libs/executor/dataSinkMgt.h +++ b/include/libs/executor/dataSinkMgt.h @@ -45,6 +45,10 @@ typedef struct SDeleterParam { SArray* pUidList; } SDeleterParam; +typedef struct SInserterParam { + SReadHandle* readHandle; +} SInserterParam; + typedef struct SDataSinkStat { uint64_t cachedSize; } SDataSinkStat; @@ -96,7 +100,7 @@ void dsEndPut(DataSinkHandle handle, uint64_t useconds); * @param handle * @param pLen data length */ -void dsGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd); +void dsGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd); /** * Get data, the caller needs to allocate data memory. diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index 0094afef12..cff4b0234c 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -157,7 +157,7 @@ int64_t qGetQueriedTableUid(qTaskInfo_t tinfo); */ int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t tagCondLen, SArray* pTableIdList); -void qProcessFetchRsp(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet); +void qProcessRspMsg(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet); int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t* resNum, SExplainExecInfo** pRes); @@ -174,7 +174,13 @@ int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t le */ int32_t qGetStreamScanStatus(qTaskInfo_t tinfo, uint64_t* uid, int64_t* ts); -int32_t qStreamPrepareScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts); +int32_t qStreamPrepareTsdbScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts); + +int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset); + +int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset); + +void* qStreamExtractMetaMsg(qTaskInfo_t tinfo); void* qExtractReaderFromStreamScanner(void* scanner); int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner); diff --git a/include/libs/function/function.h b/include/libs/function/function.h index a569c8de54..4d27325d75 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -172,7 +172,13 @@ typedef struct tExprNode { void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)); +typedef enum { + SHOULD_FREE_COLDATA = 0x1, // the newly created column data needs to be destroyed. + DELEGATED_MGMT_COLDATA = 0x2, // input column data should not be released. +} ECOLDATA_MGMT_TYPE_E; + struct SScalarParam { + ECOLDATA_MGMT_TYPE_E type; SColumnInfoData *columnData; SHashObj *pHashFilter; int32_t hashValueType; diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 90ccbb60cf..2187a7b03a 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -51,7 +51,8 @@ extern "C" { typedef struct SDatabaseOptions { ENodeType type; int32_t buffer; - int8_t cachelast; + int8_t cacheLast; + int32_t cacheLastSize; int8_t compressionLevel; int32_t daysPerFile; SValueNode* pDaysPerFile; diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index c3007306ae..a4aec72d4f 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -96,6 +96,9 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols char* tableName, char* msgBuf, int16_t msgBufLen); int32_t smlBuildOutput(void* handle, SHashObj* pVgHash); +int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray); +SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap); +SArray* serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap); #ifdef __cplusplus } #endif diff --git a/include/libs/qworker/qworker.h b/include/libs/qworker/qworker.h index 71f7622f49..87aefe5187 100644 --- a/include/libs/qworker/qworker.h +++ b/include/libs/qworker/qworker.h @@ -67,7 +67,7 @@ int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, in int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts); -int32_t qWorkerProcessFetchRsp(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts); +int32_t qWorkerProcessRspMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts); int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 8a6d6b7722..bef26cb310 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -163,9 +163,6 @@ typedef struct SSyncLogStore { // return commit index of log SyncIndex (*getCommitIndex)(struct SSyncLogStore* pLogStore); - // refactor, log[0 .. n] ==> log[m .. n] - // int32_t (*syncLogSetBeginIndex)(struct SSyncLogStore* pLogStore, SyncIndex beginIndex); - SyncIndex (*syncLogBeginIndex)(struct SSyncLogStore* pLogStore); SyncIndex (*syncLogEndIndex)(struct SSyncLogStore* pLogStore); bool (*syncLogIsEmpty)(struct SSyncLogStore* pLogStore); diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index d59a0a64b3..d8dea8a1be 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -27,7 +27,7 @@ extern "C" { #define TAOS_CONN_SERVER 0 #define TAOS_CONN_CLIENT 1 -#define IsReq(pMsg) (pMsg->msgType & 1U) +#define IsReq(pMsg) (pMsg->msgType & 1U) extern int32_t tsRpcHeadSize; diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index 43792b5415..9b94864a05 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -24,42 +24,14 @@ extern "C" { #endif -#define wFatal(...) \ - { \ - if (wDebugFlag & DEBUG_FATAL) { \ - taosPrintLog("WAL FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); \ - } \ - } -#define wError(...) \ - { \ - if (wDebugFlag & DEBUG_ERROR) { \ - taosPrintLog("WAL ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); \ - } \ - } -#define wWarn(...) \ - { \ - if (wDebugFlag & DEBUG_WARN) { \ - taosPrintLog("WAL WARN ", DEBUG_WARN, 255, __VA_ARGS__); \ - } \ - } -#define wInfo(...) \ - { \ - if (wDebugFlag & DEBUG_INFO) { \ - taosPrintLog("WAL ", DEBUG_INFO, 255, __VA_ARGS__); \ - } \ - } -#define wDebug(...) \ - { \ - if (wDebugFlag & DEBUG_DEBUG) { \ - taosPrintLog("WAL ", DEBUG_DEBUG, wDebugFlag, __VA_ARGS__); \ - } \ - } -#define wTrace(...) \ - { \ - if (wDebugFlag & DEBUG_TRACE) { \ - taosPrintLog("WAL ", DEBUG_TRACE, wDebugFlag, __VA_ARGS__); \ - } \ - } +// clang-format off +#define wFatal(...) { if (wDebugFlag & DEBUG_FATAL) { taosPrintLog("WAL FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} +#define wError(...) { if (wDebugFlag & DEBUG_ERROR) { taosPrintLog("WAL ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} +#define wWarn(...) { if (wDebugFlag & DEBUG_WARN) { taosPrintLog("WAL WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} +#define wInfo(...) { if (wDebugFlag & DEBUG_INFO) { taosPrintLog("WAL ", DEBUG_INFO, 255, __VA_ARGS__); }} +#define wDebug(...) { if (wDebugFlag & DEBUG_DEBUG) { taosPrintLog("WAL ", DEBUG_DEBUG, wDebugFlag, __VA_ARGS__); }} +#define wTrace(...) { if (wDebugFlag & DEBUG_TRACE) { taosPrintLog("WAL ", DEBUG_TRACE, wDebugFlag, __VA_ARGS__); }} +// clang-format on #define WAL_PROTO_VER 0 #define WAL_NOSUFFIX_LEN 20 @@ -161,6 +133,7 @@ typedef struct { int64_t curFileFirstVer; int64_t curVersion; int64_t capacity; + int8_t curInvalid; TdThreadMutex mutex; SWalFilterCond cond; SWalCkHead *pHead; @@ -194,6 +167,7 @@ int32_t walRestoreFromSnapshot(SWal *, int64_t ver); SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond); void walCloseReader(SWalReader *pRead); int32_t walReadVer(SWalReader *pRead, int64_t ver); +int32_t walReadSeekVer(SWalReader *pRead, int64_t ver); int32_t walNextValidMsg(SWalReader *pRead); // only for tq usage diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 41d5910625..fcc00d0d80 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -247,9 +247,11 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE) #define TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03AF) #define TSDB_CODE_MND_SINGLE_STB_MODE_DB TAOS_DEF_ERROR_CODE(0, 0x03B0) +#define TSDB_CODE_MND_INVALID_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x03B1) +#define TSDB_CODE_MND_STABLE_UID_NOT_MATCH TAOS_DEF_ERROR_CODE(0, 0x03B2) // mnode-infoSchema -#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x03BA) +#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x03BA) // mnode-func #define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0) diff --git a/include/util/tencode.h b/include/util/tencode.h index a13afd4448..e318d4f240 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -477,22 +477,6 @@ static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) { return n; \ } while (0) -#define tGetV(p, v) \ - do { \ - int32_t n = 0; \ - if (v) *v = 0; \ - for (;;) { \ - if (p[n] <= 0x7f) { \ - if (v) (*v) |= (p[n] << (7 * n)); \ - n++; \ - break; \ - } \ - if (v) (*v) |= ((p[n] & 0x7f) << (7 * n)); \ - n++; \ - } \ - return n; \ - } while (0) - // PUT static FORCE_INLINE int32_t tPutU8(uint8_t* p, uint8_t v) { if (p) ((uint8_t*)p)[0] = v; @@ -607,7 +591,22 @@ static FORCE_INLINE int32_t tGetI64(uint8_t* p, int64_t* v) { return sizeof(int64_t); } -static FORCE_INLINE int32_t tGetU16v(uint8_t* p, uint16_t* v) { tGetV(p, v); } +static FORCE_INLINE int32_t tGetU16v(uint8_t* p, uint16_t* v) { + int32_t n = 0; + + if (v) *v = 0; + for (;;) { + if (p[n] <= 0x7f) { + if (v) (*v) |= (((uint16_t)p[n]) << (7 * n)); + n++; + break; + } + if (v) (*v) |= (((uint16_t)(p[n] & 0x7f)) << (7 * n)); + n++; + } + + return n; +} static FORCE_INLINE int32_t tGetI16v(uint8_t* p, int16_t* v) { int32_t n; @@ -619,7 +618,22 @@ static FORCE_INLINE int32_t tGetI16v(uint8_t* p, int16_t* v) { return n; } -static FORCE_INLINE int32_t tGetU32v(uint8_t* p, uint32_t* v) { tGetV(p, v); } +static FORCE_INLINE int32_t tGetU32v(uint8_t* p, uint32_t* v) { + int32_t n = 0; + + if (v) *v = 0; + for (;;) { + if (p[n] <= 0x7f) { + if (v) (*v) |= (((uint32_t)p[n]) << (7 * n)); + n++; + break; + } + if (v) (*v) |= (((uint32_t)(p[n] & 0x7f)) << (7 * n)); + n++; + } + + return n; +} static FORCE_INLINE int32_t tGetI32v(uint8_t* p, int32_t* v) { int32_t n; @@ -631,7 +645,22 @@ static FORCE_INLINE int32_t tGetI32v(uint8_t* p, int32_t* v) { return n; } -static FORCE_INLINE int32_t tGetU64v(uint8_t* p, uint64_t* v) { tGetV(p, v); } +static FORCE_INLINE int32_t tGetU64v(uint8_t* p, uint64_t* v) { + int32_t n = 0; + + if (v) *v = 0; + for (;;) { + if (p[n] <= 0x7f) { + if (v) (*v) |= (((uint64_t)p[n]) << (7 * n)); + n++; + break; + } + if (v) (*v) |= (((uint64_t)(p[n] & 0x7f)) << (7 * n)); + n++; + } + + return n; +} static FORCE_INLINE int32_t tGetI64v(uint8_t* p, int64_t* v) { int32_t n; diff --git a/include/util/tlog.h b/include/util/tlog.h index 988d9c6890..a8c9eeabde 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -60,7 +60,7 @@ extern int32_t tsdbDebugFlag; extern int32_t tqDebugFlag; extern int32_t fsDebugFlag; extern int32_t metaDebugFlag; -extern int32_t fnDebugFlag; +extern int32_t udfDebugFlag; extern int32_t smaDebugFlag; extern int32_t idxDebugFlag; @@ -94,7 +94,7 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons #define pError(...) { taosPrintLog("APP ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); } #define pPrint(...) { taosPrintLog("APP ", DEBUG_INFO, 255, __VA_ARGS__); } // clang-format on - +#define BUF_PAGE_DEBUG #ifdef __cplusplus } #endif diff --git a/packaging/deb/DEBIAN/preinst b/packaging/deb/DEBIAN/preinst index 5217a82295..c9957fc89c 100644 --- a/packaging/deb/DEBIAN/preinst +++ b/packaging/deb/DEBIAN/preinst @@ -37,4 +37,5 @@ if [ -f "${install_main_dir}/taosadapter.service" ]; then fi # there can not libtaos.so*, otherwise ln -s error -${csudo}rm -f ${install_main_dir}/driver/libtaos* || : +${csudo}rm -f ${install_main_dir}/driver/libtaos.* || : +${csudo}rm -f ${install_main_dir}/driver/libtaosws.* || : diff --git a/packaging/deb/DEBIAN/prerm b/packaging/deb/DEBIAN/prerm index 501398f350..5ff970bb70 100644 --- a/packaging/deb/DEBIAN/prerm +++ b/packaging/deb/DEBIAN/prerm @@ -29,8 +29,12 @@ else ${csudo}rm -f ${bin_link_dir}/taosdemo || : ${csudo}rm -f ${cfg_link_dir}/* || : ${csudo}rm -f ${inc_link_dir}/taos.h || : + ${csudo}rm -f ${inc_link_dir}/taosdef.h || : + ${csudo}rm -f ${inc_link_dir}/taoserror.h || : ${csudo}rm -f ${inc_link_dir}/taosudf.h || : + ${csudo}rm -f ${inc_link_dir}/taosws.h || : ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaosws.* || : ${csudo}rm -f ${log_link_dir} || : ${csudo}rm -f ${data_link_dir} || : diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index 043c1456b8..1a4131ec6f 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -30,6 +30,7 @@ mkdir -p ${pkg_dir} cd ${pkg_dir} libfile="libtaos.so.${tdengine_ver}" +wslibfile="libtaosws.so" # create install dir install_home_path="/usr/local/taos" @@ -67,10 +68,12 @@ fi cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver +cp ${compile_dir}/build/lib/${wslibfile} ${pkg_dir}${install_home_path}/driver ||: cp ${compile_dir}/../include/client/taos.h ${pkg_dir}${install_home_path}/include cp ${compile_dir}/../include/common/taosdef.h ${pkg_dir}${install_home_path}/include cp ${compile_dir}/../include/util/taoserror.h ${pkg_dir}${install_home_path}/include cp ${compile_dir}/../include/libs/function/taosudf.h ${pkg_dir}${install_home_path}/include +cp ${compile_dir}/../src/inc/taosws.h ${pkg_dir}${install_home_path}/include ||: cp -r ${top_dir}/examples/* ${pkg_dir}${install_home_path}/examples #cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector #cp -r ${top_dir}/src/connector/go ${pkg_dir}${install_home_path}/connector diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index f440f72aa2..02e7e9b5e5 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -42,6 +42,7 @@ echo version: %{_version} echo buildroot: %{buildroot} libfile="libtaos.so.%{_version}" +wslibfile="libtaosws.so" # create install path, and cp file mkdir -p %{buildroot}%{homepath}/bin @@ -74,10 +75,12 @@ if [ -f %{_compiledir}/build/bin/taosadapter ]; then cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||: fi cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver +cp %{_compiledir}/build/lib/${wslibfile} %{buildroot}%{homepath}/driver ||: cp %{_compiledir}/../include/client/taos.h %{buildroot}%{homepath}/include cp %{_compiledir}/../include/common/taosdef.h %{buildroot}%{homepath}/include cp %{_compiledir}/../include/util/taoserror.h %{buildroot}%{homepath}/include cp %{_compiledir}/../include/libs/function/taosudf.h %{buildroot}%{homepath}/include +cp %{_compiledir}/../src/inc/taosws.h %{buildroot}%{homepath}/include ||: #cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector #cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector #cp -r %{_compiledir}/../src/connector/nodejs %{buildroot}%{homepath}/connector diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 2d17ef4812..77817e5cf6 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -30,6 +30,7 @@ configDir="/etc/taos" installDir="/usr/local/taos" adapterName="taosadapter" benchmarkName="taosBenchmark" +tmqName="tmq_sim" dumpName="taosdump" demoName="taosdemo" @@ -205,6 +206,7 @@ function install_bin() { [ -x ${install_main_dir}/bin/${adapterName} ] && ${csudo}ln -s ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || : [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || : [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || : + [ -x ${install_main_dir}/bin/${tmqName} ] && ${csudo}ln -s ${install_main_dir}/bin/${tmqName} ${bin_link_dir}/${tmqName} || : [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || : [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : @@ -227,9 +229,13 @@ function install_lib() { ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${lib_link_dir}/libtaosws.so ${lib_link_dir}/libtaosws.so || : + if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + + ${csudo}ln -s ${lib64_link_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || : fi ${csudo}ldconfig @@ -313,11 +319,16 @@ function install_jemalloc() { function install_header() { ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : + + ${csudo}rm -f ${inc_link_dir}/taosws.h || : + ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h + + ${csudo}ln -s ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h || : } function add_newHostname_to_hosts() { diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 4e4ebb72c0..8ad42811d4 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -294,21 +294,29 @@ function install_avro() { function install_lib() { # Remove links ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaosws.* || : if [ "$osType" != "Darwin" ]; then ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || : fi if [ "$osType" != "Darwin" ]; then ${csudo}cp ${binary_dir}/build/lib/libtaos.so.${verNumber} \ ${install_main_dir}/driver && - ${csudo}chmod 777 ${install_main_dir}/driver/* + ${csudo}chmod 777 ${install_main_dir}/driver/libtaos.so.${verNumber} + + ${csudo}cp ${binary_dir}/build/lib/libtaosws.so \ + ${install_main_dir}/driver && + ${csudo}chmod 777 ${install_main_dir}/driver/libtaosws.so ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo}ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so || : if [ -d "${lib64_link_dir}" ]; then ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 ${csudo}ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so + ${csudo}ln -sf ${lib64_link_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || : fi else ${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ @@ -337,8 +345,8 @@ function install_lib() { fi install_jemalloc - install_avro lib - install_avro lib64 + #install_avro lib + #install_avro lib64 if [ "$osType" != "Darwin" ]; then ${csudo}ldconfig @@ -350,11 +358,19 @@ function install_header() { if [ "$osType" != "Darwin" ]; then ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \ + ${csudo}rm -f ${inc_link_dir}/taosws.h || : + + ${csudo}cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taosdef.h ${source_dir}/src/inc/taoserror.h \ ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* + + ${csudo}cp -f ${binary_dir}/build/include/taosws.h ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/taosws.h + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h + + ${csudo}ln -s ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h || : else ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \ ${install_main_dir}/include || diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index cd656fe6f2..7edab2141b 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -60,7 +60,7 @@ if [ "$pagMode" == "lite" ]; then strip ${build_dir}/bin/${serverName} strip ${build_dir}/bin/${clientName} # lite version doesn't include taosadapter, which will lead to no restful interface - bin_files="${build_dir}/bin/${serverName} ${build_dir}/bin/${clientName} ${script_dir}/remove.sh ${script_dir}/startPre.sh ${build_dir}/bin/taosBenchmark" + bin_files="${build_dir}/bin/${serverName} ${build_dir}/bin/${clientName} ${script_dir}/remove.sh ${script_dir}/startPre.sh ${build_dir}/bin/taosBenchmark ${build_dir}/bin/tmq_sim" taostools_bin_files="" else @@ -78,6 +78,7 @@ else taostools_bin_files=" ${build_dir}/bin/taosdump \ ${build_dir}/bin/taosBenchmark \ + ${build_dir}/bin/tmq_sim \ ${build_dir}/bin/TDinsight.sh \ $tdinsight_caches" @@ -92,8 +93,11 @@ else fi lib_files="${build_dir}/lib/libtaos.so.${version}" +wslib_files="${build_dir}/lib/libtaosws.so." header_files="${code_dir}/include/client/taos.h ${code_dir}/include/common/taosdef.h ${code_dir}/include/util/taoserror.h ${code_dir}/include/libs/function/taosudf.h" +wsheader_files="${code_dir}/inc/taosws.h" + if [ "$dbName" != "taos" ]; then cfg_dir="${top_dir}/../enterprise/packaging/cfg" else @@ -109,6 +113,9 @@ init_file_rpm=${script_dir}/../rpm/taosd # make directories. mkdir -p ${install_dir} mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc + +${wsheader_files} ${install_dir}/inc || : + mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/${configFile} ${install_dir}/cfg/${configFile} if [ -f "${compile_dir}/test/cfg/taosadapter.toml" ]; then @@ -283,6 +290,7 @@ fi # Copy driver mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && echo "${versionComp}" >${install_dir}/driver/vercomp.txt +cp ${wslib_files} ${install_dir}/driver || : # Copy connector if [ "$verMode" == "cluster" ]; then diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index d34c81a4f5..ec836f2eac 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -102,7 +102,10 @@ function clean_local_bin() { function clean_lib() { # Remove link ${csudo}rm -f ${lib_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib_link_dir}/libtaosws.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || : #${csudo}rm -rf ${v15_java_app_dir} || : } @@ -111,6 +114,8 @@ function clean_header() { ${csudo}rm -f ${inc_link_dir}/taos.h || : ${csudo}rm -f ${inc_link_dir}/taosdef.h || : ${csudo}rm -f ${inc_link_dir}/taoserror.h || : + + ${csudo}rm -f ${inc_link_dir}/taosws.h || : } function clean_config() { diff --git a/source/client/src/TMQConnector.c b/source/client/src/TMQConnector.c index c3d1e60782..1d84dcf7a2 100644 --- a/source/client/src/TMQConnector.c +++ b/source/client/src/TMQConnector.c @@ -324,9 +324,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_fetchRawBlockImp( (*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfRowsFp, (jint)numOfRows); (*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfColsFp, (jint)numOfFields); - char *chars = (char *)data; - int32_t len = chars[0] + (chars[1] << 8) + (chars[2] << 16) + (chars[3] << 24); - (*env)->CallVoidMethod(env, rowobj, g_blockdataSetByteArrayFp, len, jniFromNCharToByteArray(env, (char *)data, len)); - + int32_t len = *(int32_t *)data; + (*env)->CallVoidMethod(env, rowobj, g_blockdataSetByteArrayFp, jniFromNCharToByteArray(env, (char *)data, len)); return JNI_SUCCESS; } diff --git a/source/client/src/TSDBJNIConnector.c b/source/client/src/TSDBJNIConnector.c index 246785b570..227c2fff18 100644 --- a/source/client/src/TSDBJNIConnector.c +++ b/source/client/src/TSDBJNIConnector.c @@ -592,8 +592,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI (*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfRowsFp, (jint)numOfRows); (*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfColsFp, (jint)numOfFields); - char *chars = (char *)data; - int32_t len = chars[0] + (chars[1] << 8) + (chars[2] << 16) + (chars[3] << 24); + int32_t len = *(int32_t *)data; (*env)->CallVoidMethod(env, rowobj, g_blockdataSetByteArrayFp, jniFromNCharToByteArray(env, (char *)data, len)); return JNI_SUCCESS; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index bff65d3527..6fb3d98027 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -325,11 +325,13 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) { if (pInfo->pQnodeList) { taosArrayDestroy(pInfo->pQnodeList); pInfo->pQnodeList = NULL; + tscDebug("QnodeList cleared in cluster 0x%" PRIx64, pInfo->clusterId); } if (pNodeList) { pInfo->pQnodeList = taosArrayDup(pNodeList); taosArraySort(pInfo->pQnodeList, compareQueryNodeLoad); + tscDebug("QnodeList updated in cluster 0x%" PRIx64 ", num:%d", pInfo->clusterId, taosArrayGetSize(pInfo->pQnodeList)); } taosThreadMutexUnlock(&pInfo->qnodeMutex); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 5039f8bbaf..b6972e4670 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -1570,41 +1570,40 @@ static int32_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int64_t *tsV return TSDB_CODE_TSC_INVALID_TIME_STAMP; } + *tsVal = timeDouble; size_t typeLen = strlen(type->valuestring); if (typeLen == 1 && (type->valuestring[0] == 's' || type->valuestring[0] == 'S')) { // seconds - timeDouble = timeDouble * 1e9; + *tsVal = *tsVal * NANOSECOND_PER_SEC; + timeDouble = timeDouble * NANOSECOND_PER_SEC; if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } - *tsVal = timeDouble; } else if (typeLen == 2 && (type->valuestring[1] == 's' || type->valuestring[1] == 'S')) { switch (type->valuestring[0]) { case 'm': case 'M': // milliseconds - timeDouble = timeDouble * 1e6; + *tsVal = *tsVal * NANOSECOND_PER_MSEC; + timeDouble = timeDouble * NANOSECOND_PER_MSEC; if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } - *tsVal = timeDouble; break; case 'u': case 'U': // microseconds - timeDouble = timeDouble * 1e3; + *tsVal = *tsVal * NANOSECOND_PER_USEC; + timeDouble = timeDouble * NANOSECOND_PER_USEC; if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } - *tsVal = timeDouble; break; case 'n': case 'N': - // nanoseconds - *tsVal = timeDouble; break; default: return TSDB_CODE_TSC_INVALID_JSON; @@ -1641,21 +1640,23 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) { if (timeDouble < 0) { return TSDB_CODE_TSC_INVALID_TIME_STAMP; } + uint8_t tsLen = smlGetTimestampLen((int64_t)timeDouble); + tsVal = (int64_t)timeDouble; if (tsLen == TSDB_TIME_PRECISION_SEC_DIGITS) { - timeDouble = timeDouble * 1e9; + tsVal = tsVal * NANOSECOND_PER_SEC; + timeDouble = timeDouble * NANOSECOND_PER_SEC; if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } - tsVal = timeDouble; } else if (tsLen == TSDB_TIME_PRECISION_MILLI_DIGITS) { - timeDouble = timeDouble * 1e6; + tsVal = tsVal * NANOSECOND_PER_MSEC; + timeDouble = timeDouble * NANOSECOND_PER_MSEC; if (smlDoubleToInt64OverFlow(timeDouble)) { smlBuildInvalidDataMsg(&info->msgBuf, "timestamp is too large", NULL); return TSDB_CODE_TSC_INVALID_TIME_STAMP; } - tsVal = timeDouble; } else if (timeDouble == 0) { tsVal = taosGetTimestampNs(); } else { diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 2132f7a2d6..cea6905c69 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -106,6 +106,12 @@ struct tmq_t { tsem_t rspSem; }; +struct tmq_raw_data{ + void *raw_meta; + int32_t raw_meta_len; + int16_t raw_meta_type; +}; + enum { TMQ_VG_STATUS__IDLE = 0, TMQ_VG_STATUS__WAIT, @@ -396,7 +402,7 @@ int32_t tmqCommitCb2(void* param, SDataBuf* pBuf, int32_t code) { } #endif - /*tscDebug("receive offset commit cb of %s on vg %d, offset is %ld", pParam->pOffset->subKey, pParam->->vgId, + /*tscDebug("receive offset commit cb of %s on vgId:%d, offset is %" PRId64, pParam->pOffset->subKey, pParam->->vgId, * pOffset->version);*/ // count down waiting rsp @@ -471,8 +477,8 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT .handle = NULL, }; - tscDebug("consumer %ld commit offset of %s on vg %d, offset is %ld", tmq->consumerId, pOffset->subKey, pVg->vgId, - pOffset->val.version); + tscDebug("consumer:%" PRId64 ", commit offset of %s on vgId:%d, offset is %" PRId64, tmq->consumerId, pOffset->subKey, + pVg->vgId, pOffset->val.version); // TODO: put into cb pVg->committedOffsetNew = pVg->currentOffsetNew; @@ -585,13 +591,14 @@ int32_t tmqCommitInner2(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_ for (int32_t i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) { SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - tscDebug("consumer %ld begin commit for topic %s, vgNum %d", tmq->consumerId, pTopic->topicName, + tscDebug("consumer:%" PRId64 ", begin commit for topic %s, vgNum %d", tmq->consumerId, pTopic->topicName, (int32_t)taosArrayGetSize(pTopic->vgs)); for (int32_t j = 0; j < taosArrayGetSize(pTopic->vgs); j++) { SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); - tscDebug("consumer %ld begin commit for topic %s, vgId %d", tmq->consumerId, pTopic->topicName, pVg->vgId); + tscDebug("consumer:%" PRId64 ", begin commit for topic %s, vgId:%d", tmq->consumerId, pTopic->topicName, + pVg->vgId); if (pVg->currentOffsetNew.type > 0 && !tOffsetEqual(&pVg->currentOffsetNew, &pVg->committedOffsetNew)) { if (tmqSendCommitReq(tmq, pVg, pTopic, pParamSet) < 0) { @@ -1082,13 +1089,13 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { int32_t epoch = pParam->epoch; taosMemoryFree(pParam); if (code != 0) { - tscWarn("msg discard from vg %d, epoch %d, code:%x", vgId, epoch, code); + tscWarn("msg discard from vgId:%d, epoch %d, code:%x", vgId, epoch, code); if (pMsg->pData) taosMemoryFree(pMsg->pData); if (code == TSDB_CODE_TQ_NO_COMMITTED_OFFSET) { SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM); if (pRspWrapper == NULL) { taosMemoryFree(pMsg->pData); - tscWarn("msg discard from vg %d, epoch %d since out of memory", vgId, epoch); + tscWarn("msg discard from vgId:%d, epoch %d since out of memory", vgId, epoch); goto CREATE_MSG_FAIL; } pRspWrapper->tmqRspType = TMQ_MSG_TYPE__END_RSP; @@ -1104,7 +1111,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { int32_t tmqEpoch = atomic_load_32(&tmq->epoch); if (msgEpoch < tmqEpoch) { // do not write into queue since updating epoch reset - tscWarn("msg discard from vg %d since from earlier epoch, rsp epoch %d, current epoch %d", vgId, msgEpoch, + tscWarn("msg discard from vgId:%d since from earlier epoch, rsp epoch %d, current epoch %d", vgId, msgEpoch, tmqEpoch); tsem_post(&tmq->rspSem); taosMemoryFree(pMsg->pData); @@ -1112,7 +1119,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { } if (msgEpoch != tmqEpoch) { - tscWarn("mismatch rsp from vg %d, epoch %d, current epoch %d", vgId, msgEpoch, tmqEpoch); + tscWarn("mismatch rsp from vgId:%d, epoch %d, current epoch %d", vgId, msgEpoch, tmqEpoch); } // handle meta rsp @@ -1121,7 +1128,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM); if (pRspWrapper == NULL) { taosMemoryFree(pMsg->pData); - tscWarn("msg discard from vg %d, epoch %d since out of memory", vgId, epoch); + tscWarn("msg discard from vgId:%d, epoch %d since out of memory", vgId, epoch); goto CREATE_MSG_FAIL; } @@ -1143,8 +1150,9 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { taosMemoryFree(pMsg->pData); - tscDebug("consumer %ld recv poll: vg %d, req offset %ld, rsp offset %ld, type %d", tmq->consumerId, pVg->vgId, - pRspWrapper->dataRsp.reqOffset.version, pRspWrapper->dataRsp.rspOffset.version, rspType); + tscDebug("consumer:%" PRId64 ", recv poll: vgId:%d, req offset %" PRId64 ", rsp offset %" PRId64 " type %d", + tmq->consumerId, pVg->vgId, pRspWrapper->dataRsp.reqOffset.version, pRspWrapper->dataRsp.rspOffset.version, + rspType); taosWriteQitem(tmq->mqueue, pRspWrapper); tsem_post(&tmq->rspSem); @@ -1163,7 +1171,7 @@ bool tmqUpdateEp2(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { int32_t topicNumGet = taosArrayGetSize(pRsp->topics); char vgKey[TSDB_TOPIC_FNAME_LEN + 22]; - tscDebug("consumer %ld update ep epoch %d to epoch %d, topic num: %d", tmq->consumerId, tmq->epoch, epoch, + tscDebug("consumer:%" PRId64 ", update ep epoch %d to epoch %d, topic num:%d", tmq->consumerId, tmq->epoch, epoch, topicNumGet); SArray* newTopics = taosArrayInit(topicNumGet, sizeof(SMqClientTopic)); @@ -1182,14 +1190,14 @@ bool tmqUpdateEp2(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { SMqClientTopic* pTopicCur = taosArrayGet(tmq->clientTopics, i); if (pTopicCur->vgs) { int32_t vgNumCur = taosArrayGetSize(pTopicCur->vgs); - tscDebug("consumer %ld new vg num: %d", tmq->consumerId, vgNumCur); + tscDebug("consumer:%" PRId64 ", new vg num: %d", tmq->consumerId, vgNumCur); for (int32_t j = 0; j < vgNumCur; j++) { SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, j); sprintf(vgKey, "%s:%d", pTopicCur->topicName, pVgCur->vgId); char buf[50]; tFormatOffset(buf, 50, &pVgCur->currentOffsetNew); - tscDebug("consumer %ld epoch %d vg %d vgKey is %s, offset is %s", tmq->consumerId, epoch, pVgCur->vgId, vgKey, - buf); + tscDebug("consumer:%" PRId64 ", epoch %d vgId:%d vgKey is %s, offset is %s", tmq->consumerId, epoch, pVgCur->vgId, + vgKey, buf); taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffsetNew, sizeof(STqOffsetVal)); } } @@ -1202,7 +1210,7 @@ bool tmqUpdateEp2(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { topic.topicName = strdup(pTopicEp->topic); tstrncpy(topic.db, pTopicEp->db, TSDB_DB_FNAME_LEN); - tscDebug("consumer %ld update topic: %s", tmq->consumerId, topic.topicName); + tscDebug("consumer:%" PRId64 ", update topic: %s", tmq->consumerId, topic.topicName); int32_t vgNumGet = taosArrayGetSize(pTopicEp->vgs); topic.vgs = taosArrayInit(vgNumGet, sizeof(SMqClientVg)); @@ -1215,7 +1223,8 @@ bool tmqUpdateEp2(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { offsetNew = *pOffset; } - /*tscDebug("consumer %ld(epoch %d) offset of vg %d updated to %ld, vgKey is %s", tmq->consumerId, epoch,*/ + /*tscDebug("consumer:%" PRId64 ", (epoch %d) offset of vgId:%d updated to %" PRId64 ", vgKey is %s", + * tmq->consumerId, epoch,*/ /*pVgEp->vgId, offset, vgKey);*/ SMqClientVg clientVg = { .pollCnt = 0, @@ -1249,7 +1258,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { bool set = false; int32_t topicNumGet = taosArrayGetSize(pRsp->topics); char vgKey[TSDB_TOPIC_FNAME_LEN + 22]; - tscDebug("consumer %ld update ep epoch %d to epoch %d, topic num: %d", tmq->consumerId, tmq->epoch, epoch, + tscDebug("consumer:%" PRId64 ", update ep epoch %d to epoch %d, topic num: %d", tmq->consumerId, tmq->epoch, epoch, topicNumGet); SArray* newTopics = taosArrayInit(topicNumGet, sizeof(SMqClientTopic)); if (newTopics == NULL) { @@ -1270,19 +1279,19 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { topic.topicName = strdup(pTopicEp->topic); tstrncpy(topic.db, pTopicEp->db, TSDB_DB_FNAME_LEN); - tscDebug("consumer %ld update topic: %s", tmq->consumerId, topic.topicName); + tscDebug("consumer:%" PRId64 ", update topic: %s", tmq->consumerId, topic.topicName); int32_t topicNumCur = taosArrayGetSize(tmq->clientTopics); for (int32_t j = 0; j < topicNumCur; j++) { // find old topic SMqClientTopic* pTopicCur = taosArrayGet(tmq->clientTopics, j); if (pTopicCur->vgs && strcmp(pTopicCur->topicName, pTopicEp->topic) == 0) { int32_t vgNumCur = taosArrayGetSize(pTopicCur->vgs); - tscDebug("consumer %ld new vg num: %d", tmq->consumerId, vgNumCur); + tscDebug("consumer:%" PRId64 ", new vg num: %d", tmq->consumerId, vgNumCur); if (vgNumCur == 0) break; for (int32_t k = 0; k < vgNumCur; k++) { SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, k); sprintf(vgKey, "%s:%d", topic.topicName, pVgCur->vgId); - tscDebug("consumer %ld epoch %d vg %d build %s", tmq->consumerId, epoch, pVgCur->vgId, vgKey); + tscDebug("consumer:%" PRId64 ", epoch %d vgId:%d build %s", tmq->consumerId, epoch, pVgCur->vgId, vgKey); taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffset, sizeof(int64_t)); } break; @@ -1296,13 +1305,13 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { sprintf(vgKey, "%s:%d", topic.topicName, pVgEp->vgId); int64_t* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey)); int64_t offset = pVgEp->offset; - tscDebug("consumer %ld(epoch %d) original offset of vg %d is %ld", tmq->consumerId, epoch, pVgEp->vgId, offset); + tscDebug("consumer:%" PRId64 ", (epoch %d) original offset of vgId:%d is %" PRId64, tmq->consumerId, epoch, pVgEp->vgId, offset); if (pOffset != NULL) { offset = *pOffset; - tscDebug("consumer %ld(epoch %d) receive offset of vg %d, full key is %s", tmq->consumerId, epoch, pVgEp->vgId, + tscDebug("consumer:%" PRId64 ", (epoch %d) receive offset of vgId:%d, full key is %s", tmq->consumerId, epoch, pVgEp->vgId, vgKey); } - tscDebug("consumer %ld(epoch %d) offset of vg %d updated to %ld", tmq->consumerId, epoch, pVgEp->vgId, offset); + tscDebug("consumer:%" PRId64 ", (epoch %d) offset of vgId:%d updated to %" PRId64, tmq->consumerId, epoch, pVgEp->vgId, offset); SMqClientVg clientVg = { .pollCnt = 0, .currentOffset = offset, @@ -1336,7 +1345,7 @@ int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) { int8_t async = pParam->async; pParam->code = code; if (code != 0) { - tscError("consumer %ld get topic endpoint error, not ready, wait:%d", tmq->consumerId, pParam->async); + tscError("consumer:%" PRId64 ", get topic endpoint error, not ready, wait:%d", tmq->consumerId, pParam->async); goto END; } @@ -1345,7 +1354,7 @@ int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) { // Epoch will only increase when received newer epoch ep msg SMqRspHead* head = pMsg->pData; int32_t epoch = atomic_load_32(&tmq->epoch); - tscDebug("consumer %ld recv ep, msg epoch %d, current epoch %d", tmq->consumerId, head->epoch, epoch); + tscDebug("consumer:%" PRId64 ", recv ep, msg epoch %d, current epoch %d", tmq->consumerId, head->epoch, epoch); if (head->epoch <= epoch) { goto END; } @@ -1353,8 +1362,8 @@ int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) { if (!async) { SMqAskEpRsp rsp; tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &rsp); - /*printf("rsp epoch %ld sz %ld\n", rsp.epoch, rsp.topics->size);*/ - /*printf("tmq epoch %ld sz %ld\n", tmq->epoch, tmq->clientTopics->size);*/ + /*printf("rsp epoch %" PRId64 " sz %" PRId64 "\n", rsp.epoch, rsp.topics->size);*/ + /*printf("tmq epoch %" PRId64 " sz %" PRId64 "\n", tmq->epoch, tmq->clientTopics->size);*/ tmqUpdateEp2(tmq, head->epoch, &rsp); tDeleteSMqAskEpRsp(&rsp); } else { @@ -1389,7 +1398,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) { int8_t epStatus = atomic_val_compare_exchange_8(&tmq->epStatus, 0, 1); if (epStatus == 1) { int32_t epSkipCnt = atomic_add_fetch_32(&tmq->epSkipCnt, 1); - tscTrace("consumer %ld skip ask ep cnt %d", tmq->consumerId, epSkipCnt); + tscTrace("consumer:%" PRId64 ", skip ask ep cnt %d", tmq->consumerId, epSkipCnt); if (epSkipCnt < 5000) return 0; } atomic_store_32(&tmq->epSkipCnt, 0); @@ -1439,7 +1448,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) { SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp); - tscDebug("consumer %ld ask ep", tmq->consumerId); + tscDebug("consumer:%" PRId64 ", ask ep", tmq->consumerId); int64_t transporterId = 0; asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); @@ -1555,14 +1564,14 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { int32_t vgStatus = atomic_val_compare_exchange_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE, TMQ_VG_STATUS__WAIT); if (vgStatus != TMQ_VG_STATUS__IDLE) { int32_t vgSkipCnt = atomic_add_fetch_32(&pVg->vgSkipCnt, 1); - tscTrace("consumer %ld epoch %d skip vg %d skip cnt %d", tmq->consumerId, tmq->epoch, pVg->vgId, vgSkipCnt); + tscTrace("consumer:%" PRId64 ", epoch %d skip vgId:%d skip cnt %d", tmq->consumerId, tmq->epoch, pVg->vgId, vgSkipCnt); continue; /*if (vgSkipCnt < 10000) continue;*/ #if 0 if (skipCnt < 30000) { continue; } else { - tscDebug("consumer %ld skip vg %d skip too much reset", tmq->consumerId, pVg->vgId); + tscDebug("consumer:%" PRId64 ",skip vgId:%d skip too much reset", tmq->consumerId, pVg->vgId); } #endif } @@ -1611,9 +1620,9 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { char offsetFormatBuf[80]; tFormatOffset(offsetFormatBuf, 80, &pVg->currentOffsetNew); - tscDebug("consumer %ld send poll to %s : vg %d, epoch %d, req offset %s, reqId %lu", tmq->consumerId, + tscDebug("consumer:%" PRId64 ", send poll to %s vgId:%d, epoch %d, req offset:%s, reqId:%" PRIu64, tmq->consumerId, pTopic->topicName, pVg->vgId, tmq->epoch, offsetFormatBuf, pReq->reqId); - /*printf("send vg %d %ld\n", pVg->vgId, pVg->currentOffset);*/ + /*printf("send vgId:%d %" PRId64 "\n", pVg->vgId, pVg->currentOffset);*/ asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo); pVg->pollCnt++; tmq->pollCnt++; @@ -1660,7 +1669,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { int32_t consumerEpoch = atomic_load_32(&tmq->epoch); if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) { SMqClientVg* pVg = pollRspWrapper->vgHandle; - /*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ + /*printf("vgId:%d offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ pVg->currentOffsetNew = pollRspWrapper->dataRsp.rspOffset; atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); if (pollRspWrapper->dataRsp.blockNum == 0) { @@ -1682,7 +1691,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { int32_t consumerEpoch = atomic_load_32(&tmq->epoch); if (pollRspWrapper->metaRsp.head.epoch == consumerEpoch) { SMqClientVg* pVg = pollRspWrapper->vgHandle; - /*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ + /*printf("vgId:%d offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ pVg->currentOffsetNew.version = pollRspWrapper->metaRsp.rspOffset; pVg->currentOffsetNew.type = TMQ_OFFSET__LOG; atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); @@ -1701,7 +1710,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { tmqHandleNoPollRsp(tmq, rspWrapper, &reset); taosFreeQitem(rspWrapper); if (pollIfReset && reset) { - tscDebug("consumer %ld reset and repoll", tmq->consumerId); + tscDebug("consumer:%" PRId64 ", reset and repoll", tmq->consumerId); tmqPollImpl(tmq, timeout); } } @@ -1741,7 +1750,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { int64_t endTime = taosGetTimestampMs(); int64_t leftTime = endTime - startTime; if (leftTime > timeout) { - tscDebug("consumer %ld (epoch %d) timeout, no rsp", tmq->consumerId, tmq->epoch); + tscDebug("consumer:%" PRId64 ", (epoch %d) timeout, no rsp", tmq->consumerId, tmq->epoch); return NULL; } tsem_timewait(&tmq->rspSem, leftTime * 1000); @@ -1839,14 +1848,16 @@ const char* tmq_get_table_name(TAOS_RES* res) { return NULL; } -int32_t tmq_get_raw_meta(TAOS_RES* res, void** raw_meta, int32_t* raw_meta_len) { +tmq_raw_data *tmq_get_raw_meta(TAOS_RES* res) { if (TD_RES_TMQ_META(res)) { + tmq_raw_data *raw = taosMemoryCalloc(1, sizeof(tmq_raw_data)); SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; - *raw_meta = pMetaRspObj->metaRsp.metaRsp; - *raw_meta_len = pMetaRspObj->metaRsp.metaRspLen; - return 0; + raw->raw_meta = pMetaRspObj->metaRsp.metaRsp; + raw->raw_meta_len = pMetaRspObj->metaRsp.metaRspLen; + raw->raw_meta_type = pMetaRspObj->metaRsp.resMsgType; + return raw; } - return -1; + return NULL; } static char *buildCreateTableJson(SSchemaWrapper *schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id, int8_t t){ @@ -2249,6 +2260,515 @@ char *tmq_get_json_meta(TAOS_RES *res){ return NULL; } +static int32_t taosCreateStb(TAOS *taos, void *meta, int32_t metaLen){ + SVCreateStbReq req = {0}; + SDecoder coder; + SMCreateStbReq pReq = {0}; + int32_t code = TSDB_CODE_SUCCESS; + SRequestObj* pRequest = NULL; + + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); + if (NULL == pTscObj) { + code = TSDB_CODE_TSC_DISCONNECTED; + goto end; + } + + code = buildRequest(pTscObj, "", 0, &pRequest); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + if(!pRequest->pDb){ + code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; + goto end; + } + // decode and process req + void* data = POINTER_SHIFT(meta, sizeof(SMsgHead)); + int32_t len = metaLen - sizeof(SMsgHead); + tDecoderInit(&coder, data, len); + if (tDecodeSVCreateStbReq(&coder, &req) < 0) { + code = TSDB_CODE_INVALID_PARA; + goto end; + } + // build create stable + pReq.pColumns = taosArrayInit(req.schemaRow.nCols, sizeof(SField)); + for(int32_t i = 0; i < req.schemaRow.nCols; i++){ + SSchema* pSchema = req.schemaRow.pSchema + i; + SField field = {.type = pSchema->type, .bytes = pSchema->bytes}; + strcpy(field.name, pSchema->name); + taosArrayPush(pReq.pColumns, &field); + } + pReq.pTags = taosArrayInit(req.schemaTag.nCols, sizeof(SField)); + for(int32_t i = 0; i < req.schemaTag.nCols; i++){ + SSchema* pSchema = req.schemaTag.pSchema + i; + SField field = {.type = pSchema->type, .bytes = pSchema->bytes}; + strcpy(field.name, pSchema->name); + taosArrayPush(pReq.pTags, &field); + } + pReq.colVer = req.schemaRow.version; + pReq.tagVer = req.schemaTag.version; + pReq.numOfColumns = req.schemaRow.nCols; + pReq.numOfTags = req.schemaTag.nCols; + pReq.commentLen = -1; + pReq.suid = req.suid; + pReq.source = 1; + + SName tableName; + tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); + + SCmdMsgInfo pCmdMsg = {0}; + pCmdMsg.epSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); + pCmdMsg.msgType = TDMT_MND_CREATE_STB; + pCmdMsg.msgLen = tSerializeSMCreateStbReq(NULL, 0, &pReq); + pCmdMsg.pMsg = taosMemoryMalloc(pCmdMsg.msgLen); + if (NULL == pCmdMsg.pMsg) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + tSerializeSMCreateStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq); + + SQuery pQuery = {0}; + pQuery.execMode = QUERY_EXEC_MODE_RPC; + pQuery.pCmdMsg = &pCmdMsg; + pQuery.msgType = pQuery.pCmdMsg->msgType; + pQuery.stableQuery = true; + + launchQueryImpl(pRequest, &pQuery, true, NULL); + code = pRequest->code; + taosMemoryFree(pCmdMsg.pMsg); + + end: + destroyRequest(pRequest); + tFreeSMCreateStbReq(&pReq); + tDecoderClear(&coder); + return code; +} + +static int32_t taosDropStb(TAOS *taos, void *meta, int32_t metaLen){ + SVDropStbReq req = {0}; + SDecoder coder; + SMDropStbReq pReq = {0}; + int32_t code = TSDB_CODE_SUCCESS; + SRequestObj* pRequest = NULL; + + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); + if (NULL == pTscObj) { + code = TSDB_CODE_TSC_DISCONNECTED; + goto end; + } + + code = buildRequest(pTscObj, "", 0, &pRequest); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + if(!pRequest->pDb){ + code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; + goto end; + } + // decode and process req + void* data = POINTER_SHIFT(meta, sizeof(SMsgHead)); + int32_t len = metaLen - sizeof(SMsgHead); + tDecoderInit(&coder, data, len); + if (tDecodeSVDropStbReq(&coder, &req) < 0) { + code = TSDB_CODE_INVALID_PARA; + goto end; + } + + // build drop stable + pReq.igNotExists = true; + pReq.source = 1; + pReq.suid = req.suid; + SName tableName; + tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); + + SCmdMsgInfo pCmdMsg = {0}; + pCmdMsg.epSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); + pCmdMsg.msgType = TDMT_MND_DROP_STB; + pCmdMsg.msgLen = tSerializeSMDropStbReq(NULL, 0, &pReq); + pCmdMsg.pMsg = taosMemoryMalloc(pCmdMsg.msgLen); + if (NULL == pCmdMsg.pMsg) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + tSerializeSMDropStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq); + + SQuery pQuery = {0}; + pQuery.execMode = QUERY_EXEC_MODE_RPC; + pQuery.pCmdMsg = &pCmdMsg; + pQuery.msgType = pQuery.pCmdMsg->msgType; + pQuery.stableQuery = true; + + launchQueryImpl(pRequest, &pQuery, true, NULL); + code = pRequest->code; + taosMemoryFree(pCmdMsg.pMsg); + + end: + destroyRequest(pRequest); + tDecoderClear(&coder); + return code; +} + +typedef struct SVgroupCreateTableBatch { + SVCreateTbBatchReq req; + SVgroupInfo info; + char dbName[TSDB_DB_NAME_LEN]; +} SVgroupCreateTableBatch; + +static void destroyCreateTbReqBatch(void* data) { + SVgroupCreateTableBatch* pTbBatch = (SVgroupCreateTableBatch*) data; + taosArrayDestroy(pTbBatch->req.pArray); +} + +static int32_t taosCreateTable(TAOS *taos, void *meta, int32_t metaLen){ + SVCreateTbBatchReq req = {0}; + SDecoder coder = {0}; + int32_t code = TSDB_CODE_SUCCESS; + SRequestObj *pRequest = NULL; + SQuery *pQuery = NULL; + SHashObj *pVgroupHashmap = NULL; + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); + + if (NULL == pTscObj) { + code = TSDB_CODE_TSC_DISCONNECTED; + goto end; + } + + code = buildRequest(pTscObj, "", 0, &pRequest); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + if(!pRequest->pDb){ + code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; + goto end; + } + // decode and process req + void* data = POINTER_SHIFT(meta, sizeof(SMsgHead)); + int32_t len = metaLen - sizeof(SMsgHead); + tDecoderInit(&coder, data, len); + if (tDecodeSVCreateTbBatchReq(&coder, &req) < 0) { + code = TSDB_CODE_INVALID_PARA; + goto end; + } + + SVCreateTbReq *pCreateReq = NULL; + SCatalog* pCatalog = NULL; + code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + pVgroupHashmap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (NULL == pVgroupHashmap) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + taosHashSetFreeFp(pVgroupHashmap, destroyCreateTbReqBatch); + + SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + // loop to create table + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + + SVgroupInfo pInfo = {0}; + SName pName; + toName(pTscObj->acctId, pRequest->pDb, pCreateReq->name, &pName); + code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &pInfo); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + SVgroupCreateTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pInfo.vgId, sizeof(pInfo.vgId)); + if (pTableBatch == NULL) { + SVgroupCreateTableBatch tBatch = {0}; + tBatch.info = pInfo; + strcpy(tBatch.dbName, pRequest->pDb); + + tBatch.req.pArray = taosArrayInit(4, sizeof(struct SVCreateTbReq)); + taosArrayPush(tBatch.req.pArray, pCreateReq); + + taosHashPut(pVgroupHashmap, &pInfo.vgId, sizeof(pInfo.vgId), &tBatch, sizeof(tBatch)); + } else { // add to the correct vgroup + taosArrayPush(pTableBatch->req.pArray, pCreateReq); + } + } + + SArray* pBufArray = serializeVgroupsCreateTableBatch(pVgroupHashmap); + if (NULL == pBufArray) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + + pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); + pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; + pQuery->msgType = TDMT_VND_CREATE_TABLE; + pQuery->stableQuery = false; + pQuery->pRoot = nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT); + + code = rewriteToVnodeModifyOpStmt(pQuery, pBufArray); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + launchQueryImpl(pRequest, pQuery, false, NULL); + pQuery = NULL; // no need to free in the end + code = pRequest->code; + + end: + taosHashCleanup(pVgroupHashmap); + destroyRequest(pRequest); + tDecoderClear(&coder); + qDestroyQuery(pQuery); + return code; +} + +typedef struct SVgroupDropTableBatch { + SVDropTbBatchReq req; + SVgroupInfo info; + char dbName[TSDB_DB_NAME_LEN]; +} SVgroupDropTableBatch; + +static void destroyDropTbReqBatch(void* data) { + SVgroupDropTableBatch* pTbBatch = (SVgroupDropTableBatch*)data; + taosArrayDestroy(pTbBatch->req.pArray); +} + +static int32_t taosDropTable(TAOS *taos, void *meta, int32_t metaLen){ + SVDropTbBatchReq req = {0}; + SDecoder coder = {0}; + int32_t code = TSDB_CODE_SUCCESS; + SRequestObj *pRequest = NULL; + SQuery *pQuery = NULL; + SHashObj *pVgroupHashmap = NULL; + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); + + if (NULL == pTscObj) { + code = TSDB_CODE_TSC_DISCONNECTED; + goto end; + } + + code = buildRequest(pTscObj, "", 0, &pRequest); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + if(!pRequest->pDb){ + code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; + goto end; + } + // decode and process req + void* data = POINTER_SHIFT(meta, sizeof(SMsgHead)); + int32_t len = metaLen - sizeof(SMsgHead); + tDecoderInit(&coder, data, len); + if (tDecodeSVDropTbBatchReq(&coder, &req) < 0) { + code = TSDB_CODE_INVALID_PARA; + goto end; + } + + SVDropTbReq *pDropReq = NULL; + SCatalog *pCatalog = NULL; + code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + pVgroupHashmap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (NULL == pVgroupHashmap) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch); + + SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + // loop to create table + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pDropReq = req.pReqs + iReq; + + SVgroupInfo pInfo = {0}; + SName pName; + toName(pTscObj->acctId, pRequest->pDb, pDropReq->name, &pName); + code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &pInfo); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + SVgroupDropTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pInfo.vgId, sizeof(pInfo.vgId)); + if (pTableBatch == NULL) { + SVgroupDropTableBatch tBatch = {0}; + tBatch.info = pInfo; + tBatch.req.pArray = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SVDropTbReq)); + taosArrayPush(tBatch.req.pArray, pDropReq); + + taosHashPut(pVgroupHashmap, &pInfo.vgId, sizeof(pInfo.vgId), &tBatch, sizeof(tBatch)); + } else { // add to the correct vgroup + taosArrayPush(pTableBatch->req.pArray, pDropReq); + } + } + + SArray* pBufArray = serializeVgroupsDropTableBatch(pVgroupHashmap); + if (NULL == pBufArray) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + + pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); + pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; + pQuery->msgType = TDMT_VND_DROP_TABLE; + pQuery->stableQuery = false; + pQuery->pRoot = nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT); + + code = rewriteToVnodeModifyOpStmt(pQuery, pBufArray); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + launchQueryImpl(pRequest, pQuery, false, NULL); + pQuery = NULL; // no need to free in the end + code = pRequest->code; + + end: + taosHashCleanup(pVgroupHashmap); + destroyRequest(pRequest); + tDecoderClear(&coder); + qDestroyQuery(pQuery); + return code; +} + +static int32_t taosAlterTable(TAOS *taos, void *meta, int32_t metaLen){ + SVAlterTbReq req = {0}; + SDecoder coder = {0}; + int32_t code = TSDB_CODE_SUCCESS; + SRequestObj *pRequest = NULL; + SQuery *pQuery = NULL; + SArray *pArray = NULL; + SVgDataBlocks *pVgData = NULL; + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); + + if (NULL == pTscObj) { + code = TSDB_CODE_TSC_DISCONNECTED; + goto end; + } + + code = buildRequest(pTscObj, "", 0, &pRequest); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + if(!pRequest->pDb){ + code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; + goto end; + } + // decode and process req + void* data = POINTER_SHIFT(meta, sizeof(SMsgHead)); + int32_t len = metaLen - sizeof(SMsgHead); + tDecoderInit(&coder, data, len); + if (tDecodeSVAlterTbReq(&coder, &req) < 0) { + code = TSDB_CODE_INVALID_PARA; + goto end; + } + + // do not deal TSDB_ALTER_TABLE_UPDATE_OPTIONS + if(req.action == TSDB_ALTER_TABLE_UPDATE_OPTIONS){ + goto end; + } + + SCatalog *pCatalog = NULL; + code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + + SVgroupInfo pInfo = {0}; + SName pName = {0}; + toName(pTscObj->acctId, pRequest->pDb, req.tbName, &pName); + code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &pInfo); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + pArray = taosArrayInit(1, sizeof(void*)); + if (NULL == pArray) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + + pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); + if (NULL == pVgData) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + pVgData->vg = pInfo; + pVgData->pData = taosMemoryMalloc(metaLen); + if (NULL == pVgData->pData) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + memcpy(pVgData->pData, meta, metaLen); + ((SMsgHead*)pVgData->pData)->vgId = htonl(pInfo.vgId); + pVgData->size = metaLen; + pVgData->numOfTables = 1; + taosArrayPush(pArray, &pVgData); + + pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); + pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; + pQuery->msgType = TDMT_VND_ALTER_TABLE; + pQuery->stableQuery = false; + pQuery->pRoot = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + + code = rewriteToVnodeModifyOpStmt(pQuery, pArray); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + + launchQueryImpl(pRequest, pQuery, false, NULL); + pQuery = NULL; // no need to free in the end + pVgData = NULL; + pArray = NULL; + code = pRequest->code; + +end: + taosArrayDestroy(pArray); + if(pVgData) taosMemoryFreeClear(pVgData->pData); + taosMemoryFreeClear(pVgData); + destroyRequest(pRequest); + tDecoderClear(&coder); + qDestroyQuery(pQuery); + return code; +} + +int32_t taos_write_raw_meta(TAOS *taos, tmq_raw_data *raw_meta){ + if (!taos || !raw_meta) { + return TSDB_CODE_INVALID_PARA; + } + + if(raw_meta->raw_meta_type == TDMT_VND_CREATE_STB) { + return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); + }else if(raw_meta->raw_meta_type == TDMT_VND_ALTER_STB){ + return taosCreateStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); + }else if(raw_meta->raw_meta_type == TDMT_VND_DROP_STB){ + return taosDropStb(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); + }else if(raw_meta->raw_meta_type == TDMT_VND_CREATE_TABLE){ + return taosCreateTable(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); + }else if(raw_meta->raw_meta_type == TDMT_VND_ALTER_TABLE){ + return taosAlterTable(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); + }else if(raw_meta->raw_meta_type == TDMT_VND_DROP_TABLE){ + return taosDropTable(taos, raw_meta->raw_meta, raw_meta->raw_meta_len); + } + return TSDB_CODE_INVALID_PARA; +} + void tmq_commit_async(tmq_t* tmq, const TAOS_RES* msg, tmq_commit_cb* cb, void* param) { tmqCommitInner2(tmq, msg, 0, 1, cb, param); } diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index e8e3237b67..7927c1e008 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -750,7 +750,6 @@ TEST(testCase, projection_query_stables) { taos_close(pConn); } - TEST(testCase, agg_query_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); @@ -763,7 +762,7 @@ TEST(testCase, agg_query_tables) { } taos_free_result(pRes); - pRes = taos_query(pConn, "show table distributed st1"); + pRes = taos_query(pConn, "show table distributed tup"); if (taos_errno(pRes) != 0) { printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); @@ -822,13 +821,29 @@ TEST(testCase, async_api_test) { } #endif + TEST(testCase, update_test) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); - taos_query(pConn, "use abc1"); + TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1"); + if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { + printf("failed to create database, code:%s", taos_errstr(pRes)); + taos_free_result(pRes); + return; + } - TAOS_RES* pRes = taos_query(pConn, "create table tup (ts timestamp, k int);"); + taos_free_result(pRes); + + pRes = taos_query(pConn, "use abc1"); + if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { + printf("failed to use db, code:%s", taos_errstr(pRes)); + taos_free_result(pRes); + return; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table tup (ts timestamp, k int);"); if (taos_errno(pRes) != 0) { printf("failed to create table, reason:%s", taos_errstr(pRes)); } @@ -836,11 +851,10 @@ TEST(testCase, update_test) { taos_free_result(pRes); char s[256] = {0}; - for(int32_t i = 0; i < 7000; ++i) { - sprintf(s, "insert into tup values('2020-1-1 1:1:1', %d)", i); + for(int32_t i = 0; i < 17000; ++i) { + sprintf(s, "insert into tup values(now+%da, %d)", i, i); pRes = taos_query(pConn, s); taos_free_result(pRes); } } - #pragma GCC diagnostic pop diff --git a/source/client/test/smlTest.cpp b/source/client/test/smlTest.cpp index 832564e0db..a6062efb98 100644 --- a/source/client/test/smlTest.cpp +++ b/source/client/test/smlTest.cpp @@ -1284,4 +1284,210 @@ TEST(testCase, sml_dup_time_Test) { ASSERT_EQ(taos_errno(pRes), 0); taos_free_result(pRes); } -*/ + + +TEST(testCase, sml_16960_Test) { +TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); +ASSERT_NE(taos, nullptr); + +TAOS_RES* pRes = taos_query(taos, "create database if not exists d16368 schemaless 1"); +taos_free_result(pRes); + +pRes = taos_query(taos, "use d16368"); +taos_free_result(pRes); + +const char *sql[] = { + "[\n" + "{\n" + "\"timestamp\":\n" + "\n" + "{ \"value\": 1349020800000, \"type\": \"ms\" }\n" + ",\n" + "\"value\":\n" + "\n" + "{ \"value\": 830525384, \"type\": \"int\" }\n" + ",\n" + "\"tags\": {\n" + "\"id\": \"stb00_0\",\n" + "\"t0\":\n" + "\n" + "{ \"value\": 83972721, \"type\": \"int\" }\n" + ",\n" + "\"t1\":\n" + "\n" + "{ \"value\": 539147525, \"type\": \"int\" }\n" + ",\n" + "\"t2\":\n" + "\n" + "{ \"value\": 618258572, \"type\": \"int\" }\n" + ",\n" + "\"t3\":\n" + "\n" + "{ \"value\": -10536201, \"type\": \"int\" }\n" + ",\n" + "\"t4\":\n" + "\n" + "{ \"value\": 349227409, \"type\": \"int\" }\n" + ",\n" + "\"t5\":\n" + "\n" + "{ \"value\": 249347042, \"type\": \"int\" }\n" + "},\n" + "\"metric\": \"stb0\"\n" + "},\n" + "{\n" + "\"timestamp\":\n" + "\n" + "{ \"value\": 1349020800001, \"type\": \"ms\" }\n" + ",\n" + "\"value\":\n" + "\n" + "{ \"value\": -588348364, \"type\": \"int\" }\n" + ",\n" + "\"tags\": {\n" + "\"id\": \"stb00_0\",\n" + "\"t0\":\n" + "\n" + "{ \"value\": 83972721, \"type\": \"int\" }\n" + ",\n" + "\"t1\":\n" + "\n" + "{ \"value\": 539147525, \"type\": \"int\" }\n" + ",\n" + "\"t2\":\n" + "\n" + "{ \"value\": 618258572, \"type\": \"int\" }\n" + ",\n" + "\"t3\":\n" + "\n" + "{ \"value\": -10536201, \"type\": \"int\" }\n" + ",\n" + "\"t4\":\n" + "\n" + "{ \"value\": 349227409, \"type\": \"int\" }\n" + ",\n" + "\"t5\":\n" + "\n" + "{ \"value\": 249347042, \"type\": \"int\" }\n" + "},\n" + "\"metric\": \"stb0\"\n" + "},\n" + "{\n" + "\"timestamp\":\n" + "\n" + "{ \"value\": 1349020800002, \"type\": \"ms\" }\n" + ",\n" + "\"value\":\n" + "\n" + "{ \"value\": -370310823, \"type\": \"int\" }\n" + ",\n" + "\"tags\": {\n" + "\"id\": \"stb00_0\",\n" + "\"t0\":\n" + "\n" + "{ \"value\": 83972721, \"type\": \"int\" }\n" + ",\n" + "\"t1\":\n" + "\n" + "{ \"value\": 539147525, \"type\": \"int\" }\n" + ",\n" + "\"t2\":\n" + "\n" + "{ \"value\": 618258572, \"type\": \"int\" }\n" + ",\n" + "\"t3\":\n" + "\n" + "{ \"value\": -10536201, \"type\": \"int\" }\n" + ",\n" + "\"t4\":\n" + "\n" + "{ \"value\": 349227409, \"type\": \"int\" }\n" + ",\n" + "\"t5\":\n" + "\n" + "{ \"value\": 249347042, \"type\": \"int\" }\n" + "},\n" + "\"metric\": \"stb0\"\n" + "},\n" + "{\n" + "\"timestamp\":\n" + "\n" + "{ \"value\": 1349020800003, \"type\": \"ms\" }\n" + ",\n" + "\"value\":\n" + "\n" + "{ \"value\": -811250191, \"type\": \"int\" }\n" + ",\n" + "\"tags\": {\n" + "\"id\": \"stb00_0\",\n" + "\"t0\":\n" + "\n" + "{ \"value\": 83972721, \"type\": \"int\" }\n" + ",\n" + "\"t1\":\n" + "\n" + "{ \"value\": 539147525, \"type\": \"int\" }\n" + ",\n" + "\"t2\":\n" + "\n" + "{ \"value\": 618258572, \"type\": \"int\" }\n" + ",\n" + "\"t3\":\n" + "\n" + "{ \"value\": -10536201, \"type\": \"int\" }\n" + ",\n" + "\"t4\":\n" + "\n" + "{ \"value\": 349227409, \"type\": \"int\" }\n" + ",\n" + "\"t5\":\n" + "\n" + "{ \"value\": 249347042, \"type\": \"int\" }\n" + "},\n" + "\"metric\": \"stb0\"\n" + "},\n" + "{\n" + "\"timestamp\":\n" + "\n" + "{ \"value\": 1349020800004, \"type\": \"ms\" }\n" + ",\n" + "\"value\":\n" + "\n" + "{ \"value\": -330340558, \"type\": \"int\" }\n" + ",\n" + "\"tags\": {\n" + "\"id\": \"stb00_0\",\n" + "\"t0\":\n" + "\n" + "{ \"value\": 83972721, \"type\": \"int\" }\n" + ",\n" + "\"t1\":\n" + "\n" + "{ \"value\": 539147525, \"type\": \"int\" }\n" + ",\n" + "\"t2\":\n" + "\n" + "{ \"value\": 618258572, \"type\": \"int\" }\n" + ",\n" + "\"t3\":\n" + "\n" + "{ \"value\": -10536201, \"type\": \"int\" }\n" + ",\n" + "\"t4\":\n" + "\n" + "{ \"value\": 349227409, \"type\": \"int\" }\n" + ",\n" + "\"t5\":\n" + "\n" + "{ \"value\": 249347042, \"type\": \"int\" }\n" + "},\n" + "\"metric\": \"stb0\"\n" + "}\n" + "]" +}; + +pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); +ASSERT_EQ(taos_errno(pRes), 0); +taos_free_result(pRes); +} +*/ \ No newline at end of file diff --git a/source/common/src/tdata.c b/source/common/src/tdata.c deleted file mode 100644 index 6dea4a4e57..0000000000 --- a/source/common/src/tdata.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ \ No newline at end of file diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 38a2a70894..4e17a9aea0 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -228,7 +228,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui uint32_t finalNumOfRows = numOfRow1 + numOfRow2; if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { // Handle the bitmap - if (finalNumOfRows > *capacity) { + if (finalNumOfRows > *capacity || numOfRow1 == 0) { char* p = taosMemoryRealloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * (numOfRow1 + numOfRow2)); if (p == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -262,7 +262,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui memcpy(pColumnInfoData->pData + oldLen, pSource->pData, len); pColumnInfoData->varmeta.length = len + oldLen; } else { - if (finalNumOfRows > *capacity) { + if (finalNumOfRows > *capacity || numOfRow1 == 0) { ASSERT(finalNumOfRows * pColumnInfoData->info.bytes); char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes); if (tmp == NULL) { @@ -1356,7 +1356,7 @@ SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId) return col; } -SColumnInfoData* bdGetColumnInfoData(SSDataBlock* pBlock, int32_t index) { +SColumnInfoData* bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index) { ASSERT(pBlock != NULL); if (index >= taosArrayGetSize(pBlock->pDataBlock)) { return NULL; @@ -1735,9 +1735,9 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock); int32_t rows = pDataBlock->info.rows; int32_t len = 0; - len += snprintf(dumpBuf + len, size - len, "\n%s |block type %d |child id %d|group id %lu|\n", flag, + len += snprintf(dumpBuf + len, size - len, "\n%s |block type %d |child id %d|group id:%" PRIu64 "|\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.groupId); - if (len >= size -1) return dumpBuf; + if (len >= size - 1) return dumpBuf; for (int32_t j = 0; j < rows; j++) { len += snprintf(dumpBuf + len, size - len, "%s |", flag); @@ -2119,3 +2119,4 @@ const char* blockDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRow ASSERT(pStart - pData == dataLen); return pStart; } + diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index b104e1c2be..5b3993dd40 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -314,7 +314,7 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "tsdbDebugFlag", tsdbDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "tqDebugFlag", tqDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "fsDebugFlag", fsDebugFlag, 0, 255, 0) != 0) return -1; - if (cfgAddInt32(pCfg, "fnDebugFlag", fnDebugFlag, 0, 255, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "udfDebugFlag", udfDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "smaDebugFlag", smaDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "idxDebugFlag", idxDebugFlag, 0, 255, 0) != 0) return -1; return 0; @@ -504,7 +504,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) { tsdbDebugFlag = cfgGetItem(pCfg, "tsdbDebugFlag")->i32; tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32; fsDebugFlag = cfgGetItem(pCfg, "fsDebugFlag")->i32; - fnDebugFlag = cfgGetItem(pCfg, "fnDebugFlag")->i32; + udfDebugFlag = cfgGetItem(pCfg, "udfDebugFlag")->i32; smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32; idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32; } @@ -715,8 +715,6 @@ int32_t taosSetCfg(SConfig *pCfg, char* name) { cfgSetItem(pCfg, "firstEp", tsFirst, pFirstEpItem->stype); } else if (strcasecmp("fsDebugFlag", name) == 0) { fsDebugFlag = cfgGetItem(pCfg, "fsDebugFlag")->i32; - } else if (strcasecmp("fnDebugFlag", name) == 0) { - fnDebugFlag = cfgGetItem(pCfg, "fnDebugFlag")->i32; } break; } @@ -817,6 +815,8 @@ int32_t taosSetCfg(SConfig *pCfg, char* name) { case 'u': { if (strcasecmp("multiProcess", name) == 0) { tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval; + } else if (strcasecmp("udfDebugFlag", name) == 0) { + udfDebugFlag = cfgGetItem(pCfg, "udfDebugFlag")->i32; } break; } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 192a41a70e..c80960b8ce 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -381,9 +381,11 @@ static int32_t tDeserializeSClientHbRsp(SDecoder *pDecoder, SClientHbRsp *pRsp) if (pQnodeNum > 0) { pRsp->query->pQnodeList = taosArrayInit(pQnodeNum, sizeof(SQueryNodeLoad)); if (NULL == pRsp->query->pQnodeList) return -1; - SQueryNodeLoad load = {0}; - if (tDecodeSQueryNodeLoad(pDecoder, &load) < 0) return -1; - taosArrayPush(pRsp->query->pQnodeList, &load); + for (int32_t i = 0; i < pQnodeNum; ++i) { + SQueryNodeLoad load = {0}; + if (tDecodeSQueryNodeLoad(pDecoder, &load) < 0) return -1; + taosArrayPush(pRsp->query->pQnodeList, &load); + } } } @@ -496,11 +498,18 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq if (tStartEncode(&encoder) < 0) return -1; if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1; + if (tEncodeI8(&encoder, pReq->source) < 0) return -1; + for (int32_t i = 0; i < sizeof(pReq->reserved) / sizeof(int8_t); ++i) { + if (tEncodeI8(&encoder, pReq->reserved[i]) < 0) return -1; + } + if (tEncodeI64(&encoder, pReq->suid) < 0) return -1; if (tEncodeI64(&encoder, pReq->delay1) < 0) return -1; if (tEncodeI64(&encoder, pReq->delay2) < 0) return -1; if (tEncodeI64(&encoder, pReq->watermark1) < 0) return -1; if (tEncodeI64(&encoder, pReq->watermark2) < 0) return -1; if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1; + if (tEncodeI32(&encoder, pReq->colVer) < 0) return -1; + if (tEncodeI32(&encoder, pReq->tagVer) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfFuncs) < 0) return -1; @@ -553,11 +562,18 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR if (tStartDecode(&decoder) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->source) < 0) return -1; + for (int32_t i = 0; i < sizeof(pReq->reserved) / sizeof(int8_t); ++i) { + if (tDecodeI8(&decoder, &pReq->reserved[i]) < 0) return -1; + } + if (tDecodeI64(&decoder, &pReq->suid) < 0) return -1; if (tDecodeI64(&decoder, &pReq->delay1) < 0) return -1; if (tDecodeI64(&decoder, &pReq->delay2) < 0) return -1; if (tDecodeI64(&decoder, &pReq->watermark1) < 0) return -1; if (tDecodeI64(&decoder, &pReq->watermark2) < 0) return -1; if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->colVer) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->tagVer) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfFuncs) < 0) return -1; @@ -645,6 +661,11 @@ int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) { if (tStartEncode(&encoder) < 0) return -1; if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; if (tEncodeI8(&encoder, pReq->igNotExists) < 0) return -1; + if (tEncodeI8(&encoder, pReq->source) < 0) return -1; + for (int32_t i = 0; i < sizeof(pReq->reserved) / sizeof(int8_t); ++i) { + if (tEncodeI8(&encoder, pReq->reserved[i]) < 0) return -1; + } + if (tEncodeI64(&encoder, pReq->suid) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -659,6 +680,12 @@ int32_t tDeserializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) if (tStartDecode(&decoder) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igNotExists) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->source) < 0) return -1; + for (int32_t i = 0; i < sizeof(pReq->reserved) / sizeof(int8_t); ++i) { + if (tDecodeI8(&decoder, &pReq->reserved[i]) < 0) return -1; + } + if (tDecodeI64(&decoder, &pReq->suid) < 0) return -1; + tEndDecode(&decoder); tDecoderClear(&decoder); @@ -672,8 +699,6 @@ int32_t tSerializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq) if (tStartEncode(&encoder) < 0) return -1; if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; if (tEncodeI8(&encoder, pReq->alterType) < 0) return -1; - if (tEncodeI32(&encoder, pReq->tagVer) < 0) return -1; - if (tEncodeI32(&encoder, pReq->colVer) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfFields) < 0) return -1; for (int32_t i = 0; i < pReq->numOfFields; ++i) { SField *pField = taosArrayGet(pReq->pFields, i); @@ -700,8 +725,6 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq if (tStartDecode(&decoder) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->alterType) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->tagVer) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->colVer) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfFields) < 0) return -1; pReq->pFields = taosArrayInit(pReq->numOfFields, sizeof(SField)); if (pReq->pFields == NULL) { @@ -5406,11 +5429,11 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { } else if (pVal->type == TMQ_OFFSET__RESET_LATEST) { snprintf(buf, maxLen, "offset(reset to latest)"); } else if (pVal->type == TMQ_OFFSET__LOG) { - snprintf(buf, maxLen, "offset(log) ver:%ld", pVal->version); + snprintf(buf, maxLen, "offset(log) ver:%" PRId64, pVal->version); } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA) { - snprintf(buf, maxLen, "offset(ss data) uid:%ld, ts:%ld", pVal->uid, pVal->ts); + snprintf(buf, maxLen, "offset(ss data) uid:%" PRId64 ", ts:%" PRId64, pVal->uid, pVal->ts); } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_META) { - snprintf(buf, maxLen, "offset(ss meta) uid:%ld, ts:%ld", pVal->uid, pVal->ts); + snprintf(buf, maxLen, "offset(ss meta) uid:%" PRId64 ", ts:%" PRId64, pVal->uid, pVal->ts); } else { ASSERT(0); } diff --git a/source/common/src/tmsgtype.c b/source/common/src/tmsgtype.c deleted file mode 100644 index 3ca0f00fc2..0000000000 --- a/source/common/src/tmsgtype.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#define TSDB_SQL_C -#include "tmsgtype.h" diff --git a/source/common/src/tname.c b/source/common/src/tname.c index fb3a2d7464..7183153824 100644 --- a/source/common/src/tname.c +++ b/source/common/src/tname.c @@ -115,6 +115,14 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in #endif +SName* toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName) { + pName->type = TSDB_TABLE_NAME_T; + pName->acctId = acctId; + strcpy(pName->dbname, pDbName); + strcpy(pName->tname, pTableName); + return pName; +} + int32_t tNameExtractFullName(const SName* name, char* dst) { assert(name != NULL && dst != NULL); diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 2b0f6a01a0..00c32e1990 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -216,7 +216,7 @@ int main(int argc, char const *argv[]) { return -1; } - dInfo("start to open dnode"); + dInfo("start to init service"); dmSetSignalHandle(); int32_t code = dmRun(); dInfo("shutting down the service"); diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index 59b442881a..5f982ad3a4 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -21,7 +21,7 @@ extern SConfig *tsCfg; static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) { if (pMgmt->pData->dnodeId == 0 || pMgmt->pData->clusterId == 0) { - dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId); + dInfo("set local info, dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId); taosThreadRwlockWrlock(&pMgmt->pData->lock); pMgmt->pData->dnodeId = pCfg->dnodeId; pMgmt->pData->clusterId = pCfg->clusterId; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index 7f3f76b4b6..a171d2e1e4 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -167,7 +167,7 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { if (pMsg == NULL) return -1; memcpy(pMsg, pRpc, sizeof(SRpcMsg)); - dTrace("msg:%p, is created and will put int %s queue", pMsg, pWorker->name); + dTrace("msg:%p, is created and will put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType)); return mmPutMsgToWorker(pMgmt, pWorker, pMsg); } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 993a604b51..5ffddd0127 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -384,6 +384,8 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_BATCH, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_VNODE_STANDBY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; code = 0; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index dc1bcbd258..051e5defb0 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -173,7 +173,7 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) { pThread->pCfgs[pThread->vnodeNum++] = pCfgs[v]; } - dInfo("start %d threads to open %d vnodes", threadNum, numOfVnodes); + dInfo("open %d vnodes with %d threads", numOfVnodes, threadNum); for (int32_t t = 0; t < threadNum; ++t) { SVnodeThread *pThread = &threads[t]; @@ -204,7 +204,7 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) { dError("there are total vnodes:%d, opened:%d", pMgmt->state.totalVnodes, pMgmt->state.openVnodes); return -1; } else { - dInfo("total vnodes:%d open successfully", pMgmt->state.totalVnodes); + dInfo("successfully opened %d vnodes", pMgmt->state.totalVnodes); return 0; } } diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index 436282d9fe..c2e8a55271 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -128,7 +128,7 @@ static void dmClearVars(SDnode *pDnode) { } int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) { - dInfo("start to create dnode"); + dDebug("start to create dnode"); int32_t code = -1; char path[PATH_MAX + 100] = {0}; diff --git a/source/dnode/mgmt/node_mgmt/src/dmNodes.c b/source/dnode/mgmt/node_mgmt/src/dmNodes.c index ab9d3f67e7..ecbb695e02 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmNodes.c +++ b/source/dnode/mgmt/node_mgmt/src/dmNodes.c @@ -277,7 +277,7 @@ int32_t dmRunDnode(SDnode *pDnode) { while (1) { if (pDnode->stop) { - dInfo("dnode is about to stop"); + dInfo("TDengine is about to stop"); dmSetStatus(pDnode, DND_STAT_STOPPED); dmStopNodes(pDnode); dmCloseNodes(pDnode); diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index ad7fbf4344..9052fb20ca 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -89,7 +89,8 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { case TDMT_DND_SYSTABLE_RETRIEVE_RSP: case TDMT_SCH_FETCH_RSP: case TDMT_SCH_MERGE_FETCH_RSP: - qWorkerProcessFetchRsp(NULL, NULL, pRpc, 0); + case TDMT_VND_SUBMIT_RSP: + qWorkerProcessRspMsg(NULL, NULL, pRpc, 0); return; case TDMT_MND_STATUS_RSP: if (pEpSet != NULL) { diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 14867ff693..b94c60c4ab 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -34,8 +34,6 @@ extern "C" { #endif // clang-format off - - #define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} #define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} #define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} @@ -49,7 +47,6 @@ extern "C" { #define mGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", gtid:%s", __VA_ARGS__, buf);} #define mGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", gtid:%s", __VA_ARGS__, buf);} #define mGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", gtid:%s", __VA_ARGS__, buf);} - // clang-format on #define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE) diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 5b5de10fba..5e7c19ce6a 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -92,7 +92,7 @@ static int32_t mndProcessConsumerLostMsg(SRpcMsg *pMsg) { SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, pLostMsg->consumerId); ASSERT(pConsumer); - mInfo("receive consumer lost msg, consumer id %ld, status %s", pLostMsg->consumerId, + mInfo("receive consumer lost msg, consumer id %" PRId64 ", status %s", pLostMsg->consumerId, mndConsumerStatusName(pConsumer->status)); if (pConsumer->status != MQ_CONSUMER_STATUS__READY) { @@ -124,7 +124,7 @@ static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) { SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, pRecoverMsg->consumerId); ASSERT(pConsumer); - mInfo("receive consumer recover msg, consumer id %ld, status %s", pRecoverMsg->consumerId, + mInfo("receive consumer recover msg, consumer id %" PRId64 ", status %s", pRecoverMsg->consumerId, mndConsumerStatusName(pConsumer->status)); if (pConsumer->status != MQ_CONSUMER_STATUS__READY) { @@ -296,7 +296,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { // 2. check epoch, only send ep info when epoches do not match if (epoch != serverEpoch) { taosRLockLatch(&pConsumer->lock); - mInfo("process ask ep, consumer %ld(epoch %d), server epoch %d", consumerId, epoch, serverEpoch); + mInfo("process ask ep, consumer:%" PRId64 "(epoch %d), server epoch %d", consumerId, epoch, serverEpoch); int32_t numOfTopics = taosArrayGetSize(pConsumer->currentTopics); rsp.topics = taosArrayInit(numOfTopics, sizeof(SMqSubTopicEp)); @@ -441,7 +441,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { SMqTopicObj topicObj = {0}; memcpy(&topicObj, pTopic, sizeof(SMqTopicObj)); topicObj.refConsumerCnt = pTopic->refConsumerCnt + 1; - mInfo("subscribe topic %s by consumer %ld cgroup %s, refcnt %d", pTopic->name, consumerId, cgroup, + mInfo("subscribe topic %s by consumer:%" PRId64 ",cgroup %s, refcnt %d", pTopic->name, consumerId, cgroup, topicObj.refConsumerCnt); if (mndSetTopicCommitLogs(pMnode, pTrans, &topicObj) != 0) goto SUBSCRIBE_OVER; #endif @@ -451,7 +451,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { pConsumerOld = mndAcquireConsumer(pMnode, consumerId); if (pConsumerOld == NULL) { - mInfo("receive subscribe request from new consumer: %ld", consumerId); + mInfo("receive subscribe request from new consumer:%" PRId64, consumerId); pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); tstrncpy(pConsumerNew->clientId, subscribe.clientId, 256); @@ -472,7 +472,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { int32_t status = atomic_load_32(&pConsumerOld->status); - mInfo("receive subscribe request from old consumer: %ld, current status: %s", consumerId, + mInfo("receive subscribe request from old consumer:%" PRId64 ", current status: %s", consumerId, mndConsumerStatusName(status)); if (status != MQ_CONSUMER_STATUS__READY) { diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 6ead922d95..9ce108b789 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -406,7 +406,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { } if (statusReq.dnodeId == 0) { - mInfo("dnode:%d, %s first access, set clusterId %" PRId64, pDnode->id, pDnode->ep, pMnode->clusterId); + mInfo("dnode:%d, %s first access, clusterId:%" PRId64, pDnode->id, pDnode->ep, pMnode->clusterId); } else { if (statusReq.clusterId != pMnode->clusterId) { if (pDnode != NULL) { diff --git a/source/dnode/mnode/impl/src/mndOffset.c b/source/dnode/mnode/impl/src/mndOffset.c index e2b20b2163..00753de0ec 100644 --- a/source/dnode/mnode/impl/src/mndOffset.c +++ b/source/dnode/mnode/impl/src/mndOffset.c @@ -185,7 +185,7 @@ static int32_t mndProcessCommitOffsetReq(SRpcMsg *pMsg) { for (int32_t i = 0; i < commitOffsetReq.num; i++) { SMqOffset *pOffset = &commitOffsetReq.offsets[i]; - mInfo("commit offset %ld to vg %d of consumer group %s on topic %s", pOffset->offset, pOffset->vgId, + mInfo("commit offset %" PRId64 " to vgId:%d of consumer group %s on topic %s", pOffset->offset, pOffset->vgId, pOffset->cgroup, pOffset->topicName); if (mndMakePartitionKey(key, pOffset->cgroup, pOffset->topicName, pOffset->vgId) < 0) { mError("submit offset to topic %s failed", pOffset->topicName); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index e084710e25..224c1dbb5d 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -705,10 +705,10 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat memcpy(pDst->db, pDb->name, TSDB_DB_FNAME_LEN); pDst->createdTime = taosGetTimestampMs(); pDst->updateTime = pDst->createdTime; - pDst->uid = mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); + pDst->uid = (pCreate->source == 1) ? pCreate->suid : mndGenerateUid(pCreate->name, TSDB_TABLE_FNAME_LEN); pDst->dbUid = pDb->uid; - pDst->tagVer = 1; - pDst->colVer = 1; + pDst->tagVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->tagVer : 1; + pDst->colVer = (pCreate->source != TD_REQ_FROM_APP) ? pCreate->colVer : 1; pDst->smaVer = 1; pDst->nextColId = 1; pDst->maxdelay[0] = pCreate->delay1; @@ -869,9 +869,38 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { pStb = mndAcquireStb(pMnode, createReq.name); if (pStb != NULL) { if (createReq.igExists) { - mDebug("stb:%s, already exist, ignore exist is set", createReq.name); - code = 0; - goto _OVER; + if (createReq.source == TD_REQ_FROM_APP) { + mDebug("stb:%s, already exist, ignore exist is set", createReq.name); + code = 0; + goto _OVER; + } else if (pStb->uid != createReq.suid) { + mError("stb:%s, already exist while create, input suid:%" PRId64 " not match with exist suid:%" PRId64, + createReq.name, createReq.suid, pStb->uid); + terrno = TSDB_CODE_MND_STABLE_UID_NOT_MATCH; + goto _OVER; + } else if (createReq.tagVer > 0 || createReq.colVer > 0) { + int32_t tagDelta = pStb->tagVer - createReq.tagVer; + int32_t colDelta = pStb->colVer - createReq.colVer; + int32_t verDelta = tagDelta + verDelta; + mInfo("stb:%s, already exist while create, input tagVer:%d colVer:%d, exist tagVer:%d colVer:%d", + createReq.name, createReq.tagVer, createReq.colVer, pStb->tagVer, pStb->colVer); + if (tagDelta <= 0 && colDelta <= 0) { + mInfo("stb:%s, schema version is not incremented and nothing needs to be done", createReq.name); + code = 0; + goto _OVER; + } else if ((tagDelta == 1 || colDelta == 1) && (verDelta == 1)) { + mInfo("stb:%s, schema version is only increased by 1 number, do alter operation", createReq.name); + } else { + mError("stb:%s, schema version increase more than 1 number, error is returned", createReq.name); + terrno = TSDB_CODE_MND_INVALID_SCHEMA_VER; + goto _OVER; + } + } else { + mError("stb:%s, already exist while create, input tagVer:%d colVer:%d is invalid", createReq.name, + createReq.tagVer, createReq.colVer, pStb->tagVer, pStb->colVer); + terrno = TSDB_CODE_MND_INVALID_SCHEMA_VER; + goto _OVER; + } } else { terrno = TSDB_CODE_MND_STB_ALREADY_EXIST; goto _OVER; @@ -1614,14 +1643,6 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) { goto _OVER; } - if ((alterReq.tagVer > 0 && alterReq.colVer > 0) && - (alterReq.tagVer <= pStb->tagVer || alterReq.colVer <= pStb->colVer)) { - mDebug("stb:%s, already exist, tagVer:%d colVer:%d smaller than in mnode, tagVer:%d colVer:%d, alter success", - alterReq.name, alterReq.tagVer, alterReq.colVer, pStb->tagVer, pStb->colVer); - code = 0; - goto _OVER; - } - if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pDb) != 0) { goto _OVER; } @@ -1752,6 +1773,11 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) { } } + if (dropReq.source != TD_REQ_FROM_APP && pStb->uid != dropReq.suid) { + terrno = TSDB_CODE_MND_STB_NOT_EXIST; + goto _OVER; + } + pDb = mndAcquireDbByStb(pMnode, dropReq.name); if (pDb == NULL) { terrno = TSDB_CODE_MND_DB_NOT_SELECTED; diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 8dde3e92d8..d67e4e8783 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -235,7 +235,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("mq rebalance: remove vg %d from consumer %ld", pVgEp->vgId, consumerId); + mInfo("mq rebalance: remove vgId:%d from consumer:%" PRId64, pVgEp->vgId, consumerId); } taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); // put into removed @@ -255,7 +255,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg)); - mInfo("mq rebalance: remove vg %d from unassigned", pVgEp->vgId); + mInfo("mq rebalance: remove vgId:%d from unassigned", pVgEp->vgId); } } @@ -298,7 +298,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("mq rebalance: remove vg %d from consumer %ld (first scan)", pVgEp->vgId, pConsumerEp->consumerId); + mInfo("mq rebalance: remove vgId:%d from consumer:%" PRId64 ",(first scan)", pVgEp->vgId, pConsumerEp->consumerId); } imbCnt++; } @@ -312,7 +312,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("mq rebalance: remove vg %d from consumer %ld (first scan)", pVgEp->vgId, pConsumerEp->consumerId); + mInfo("mq rebalance: remove vgId:%d from consumer:%" PRId64 ",(first scan)", pVgEp->vgId, pConsumerEp->consumerId); } } } @@ -329,7 +329,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR newConsumerEp.vgs = taosArrayInit(0, sizeof(void *)); taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp)); taosArrayPush(pOutput->newConsumers, &consumerId); - mInfo("mq rebalance: add new consumer %ld", consumerId); + mInfo("mq rebalance: add new consumer:%" PRId64, consumerId); } } @@ -354,7 +354,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); pRebVg->newConsumerId = pConsumerEp->consumerId; taosArrayPush(pOutput->rebVgs, pRebVg); - mInfo("mq rebalance: add vg %d to consumer %ld (second scan)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); + mInfo("mq rebalance: add vgId:%d to consumer:%" PRId64 ",(second scan)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); } } @@ -372,7 +372,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); pRebVg->newConsumerId = pConsumerEp->consumerId; taosArrayPush(pOutput->rebVgs, pRebVg); - mInfo("mq rebalance: add vg %d to consumer %ld (second scan)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); + mInfo("mq rebalance: add vgId:%d to consumer:%" PRId64 ",(second scan)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); } } else { // if all consumer is removed, put all vg into unassigned @@ -385,7 +385,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR ASSERT(pRebOutput->newConsumerId == -1); taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp); taosArrayPush(pOutput->rebVgs, pRebOutput); - mInfo("mq rebalance: unassign vg %d (second scan)", pRebOutput->pVgEp->vgId); + mInfo("mq rebalance: unassign vgId:%d (second scan)", pRebOutput->pVgEp->vgId); } } @@ -393,7 +393,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR mInfo("rebalance calculation completed, rebalanced vg:"); for (int32_t i = 0; i < taosArrayGetSize(pOutput->rebVgs); i++) { SMqRebOutputVg *pOutputRebVg = taosArrayGet(pOutput->rebVgs, i); - mInfo("vgId:%d, moved from consumer %" PRId64 " to consumer %" PRId64, pOutputRebVg->pVgEp->vgId, + mInfo("vgId:%d, moved from consumer:%" PRId64 ", to consumer:%" PRId64, pOutputRebVg->pVgEp->vgId, pOutputRebVg->oldConsumerId, pOutputRebVg->newConsumerId); } @@ -546,7 +546,11 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { char cgroup[TSDB_CGROUP_LEN]; mndSplitSubscribeKey(pRebInfo->key, topic, cgroup, true); SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - ASSERT(pTopic); + /*ASSERT(pTopic);*/ + if (pTopic == NULL) { + mError("rebalance %s failed since topic %s was dropped, abort", pRebInfo->key, topic); + continue; + } taosRLockLatch(&pTopic->lock); rebOutput.pSub = mndCreateSub(pMnode, pTopic, pRebInfo->key); diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 2053f3886c..d77b39003a 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -188,7 +188,7 @@ int32_t mndInitSync(SMnode *pMnode) { SNodeInfo *pNode = &pCfg->nodeInfo[0]; tstrncpy(pNode->nodeFqdn, pMgmt->replica.fqdn, sizeof(pNode->nodeFqdn)); pNode->nodePort = pMgmt->replica.port; - mInfo("fqdn:%s port:%u", pNode->nodeFqdn, pNode->nodePort); + mInfo("mnode ep:%s:%u", pNode->nodeFqdn, pNode->nodePort); } tsem_init(&pMgmt->syncSem, 0, 0); diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 8d1220d596..f2a037ab82 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -558,7 +558,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { mndReleaseConsumer(pMnode, pConsumer); mndReleaseTopic(pMnode, pTopic); terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED; - mError("topic:%s, failed to drop since subscribed by consumer %ld in consumer group %s", dropReq.name, + mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s", dropReq.name, pConsumer->consumerId, pConsumer->cgroup); return -1; } diff --git a/source/dnode/mnode/impl/test/stb/stb.cpp b/source/dnode/mnode/impl/test/stb/stb.cpp index 56b8936cf4..63bb1bf540 100644 --- a/source/dnode/mnode/impl/test/stb/stb.cpp +++ b/source/dnode/mnode/impl/test/stb/stb.cpp @@ -277,8 +277,6 @@ void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const c req.numOfFields = 1; req.pFields = taosArrayInit(1, sizeof(SField)); req.alterType = TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES; - req.tagVer = verInBlock; - req.colVer = verInBlock; SField field = {0}; field.bytes = bytes; @@ -818,7 +816,7 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) { { void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col_not_exist", 20, &contLen, 1); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); - ASSERT_EQ(pRsp->code, 0); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST); test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); diff --git a/source/dnode/qnode/src/qnode.c b/source/dnode/qnode/src/qnode.c index 723402e639..b65189153e 100644 --- a/source/dnode/qnode/src/qnode.c +++ b/source/dnode/qnode/src/qnode.c @@ -89,9 +89,6 @@ int32_t qndProcessQueryMsg(SQnode *pQnode, int64_t ts, SRpcMsg *pMsg) { case TDMT_SCH_MERGE_FETCH: code = qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg, ts); break; - case TDMT_SCH_FETCH_RSP: - code = qWorkerProcessFetchRsp(pQnode, pQnode->pQuery, pMsg, ts); - break; case TDMT_SCH_CANCEL_TASK: code = qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg, ts); break; diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index b13e654caf..0a5fe1001c 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -111,7 +111,7 @@ static int32_t sndProcessTaskDeployReq(SSnode *pNode, SRpcMsg *pMsg) { streamSetupTrigger(pTask); - qInfo("deploy stream: stream id %ld task id %d child id %d on snode", pTask->streamId, pTask->taskId, + qInfo("deploy stream: stream id %" PRId64 " task id %d child id %d on snode", pTask->streamId, pTask->taskId, pTask->selfChildId); taosHashPut(pMeta->pHash, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void *)); diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 24c4f2912c..e9e20912c5 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -3,18 +3,17 @@ add_library(vnode STATIC "") target_sources( vnode PRIVATE + # vnode "src/vnd/vnodeOpen.c" "src/vnd/vnodeBufPool.c" "src/vnd/vnodeCfg.c" "src/vnd/vnodeCommit.c" "src/vnd/vnodeQuery.c" - "src/vnd/vnodeStateMgr.c" "src/vnd/vnodeModule.c" "src/vnd/vnodeSvr.c" "src/vnd/vnodeSync.c" "src/vnd/vnodeSnapshot.c" - "src/vnd/vnodeUtil.c" # meta "src/meta/metaOpen.c" @@ -27,12 +26,10 @@ target_sources( "src/meta/metaSnapshot.c" # sma - "src/sma/sma.c" "src/sma/smaEnv.c" "src/sma/smaUtil.c" "src/sma/smaOpen.c" "src/sma/smaCommit.c" - "src/sma/smaSnapshot.c" "src/sma/smaRollup.c" "src/sma/smaTimeRange.c" @@ -43,13 +40,13 @@ target_sources( "src/tsdb/tsdbOpen.c" "src/tsdb/tsdbMemTable.c" "src/tsdb/tsdbRead.c" - "src/tsdb/tsdbReadImpl.c" "src/tsdb/tsdbCache.c" "src/tsdb/tsdbWrite.c" "src/tsdb/tsdbReaderWriter.c" "src/tsdb/tsdbUtil.c" "src/tsdb/tsdbSnapshot.c" "src/tsdb/tsdbCacheRead.c" + "src/tsdb/tsdbRetention.c" # tq "src/tq/tq.c" @@ -66,7 +63,6 @@ target_include_directories( PUBLIC "inc" PRIVATE "src/inc" PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar" - ) target_link_libraries( vnode @@ -80,18 +76,19 @@ target_link_libraries( PUBLIC executor PUBLIC scheduler PUBLIC tdb - #PUBLIC bdb - #PUBLIC scalar + + # PUBLIC bdb + # PUBLIC scalar PUBLIC transport PUBLIC stream PUBLIC index ) target_compile_definitions(vnode PUBLIC -DMETA_REFACT) -if (${BUILD_WITH_INVERTEDINDEX}) - add_definitions(-DUSE_INVERTED_INDEX) + +if(${BUILD_WITH_INVERTEDINDEX}) + add_definitions(-DUSE_INVERTED_INDEX) endif(${BUILD_WITH_INVERTEDINDEX}) + if(${BUILD_TEST}) add_subdirectory(test) endif(${BUILD_TEST}) - - diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index b381046ecf..62a39711ec 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -38,10 +38,11 @@ extern "C" { #endif // vnode -typedef struct SVnode SVnode; -typedef struct STsdbCfg STsdbCfg; // todo: remove -typedef struct SVnodeCfg SVnodeCfg; -typedef struct SVSnapshotReader SVSnapshotReader; +typedef struct SVnode SVnode; +typedef struct STsdbCfg STsdbCfg; // todo: remove +typedef struct SVnodeCfg SVnodeCfg; +typedef struct SVSnapReader SVSnapReader; +typedef struct SVSnapWriter SVSnapWriter; extern const SVnodeCfg vnodeCfgDefault; @@ -57,10 +58,6 @@ void vnodeStop(SVnode *pVnode); int64_t vnodeGetSyncHandle(SVnode *pVnode); void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot); void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId); -int32_t vnodeSnapshotReaderOpen(SVnode *pVnode, SVSnapshotReader **ppReader, int64_t sver, int64_t ever); -int32_t vnodeSnapshotReaderClose(SVSnapshotReader *pReader); -int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, const void **ppData, uint32_t *nData); - int32_t vnodeProcessCreateTSma(SVnode *pVnode, void *pCont, uint32_t contLen); int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list); int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list); @@ -131,7 +128,7 @@ int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, SArray *pTabl void tsdbReaderClose(STsdbReader *pReader); bool tsdbNextDataBlock(STsdbReader *pReader); void tsdbRetrieveDataBlockInfo(STsdbReader *pReader, SDataBlockInfo *pDataBlockInfo); -int32_t tsdbRetrieveDataBlockStatisInfo(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave); +int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave); SArray *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList); int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond, int32_t tWinIdx); int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo); @@ -143,6 +140,7 @@ int32_t tsdbLastRowReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, void **pReader); int32_t tsdbRetrieveLastRow(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds); int32_t tsdbLastrowReaderClose(void *pReader); +int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int64_t* suid); // tq @@ -173,6 +171,9 @@ int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList); int32_t tqReaderAddTbUidList(STqReader *pReader, const SArray *tbUidList); int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList); +int32_t tqSeekVer(STqReader *pReader, int64_t ver); +int32_t tqNextBlock(STqReader *pReader, SFetchRet *ret); + int32_t tqReaderSetDataMsg(STqReader *pReader, SSubmitReq *pMsg, int64_t ver); bool tqNextDataBlock(STqReader *pReader); bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids); @@ -181,7 +182,14 @@ int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader); // sma int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days); -// need to reposition +// SVSnapReader +int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader); +int32_t vnodeSnapReaderClose(SVSnapReader *pReader); +int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData); +// SVSnapWriter +int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter); +int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback); +int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData); // structs struct STsdbCfg { diff --git a/source/dnode/vnode/src/inc/meta.h b/source/dnode/vnode/src/inc/meta.h index 66d1689d57..e08925acc3 100644 --- a/source/dnode/vnode/src/inc/meta.h +++ b/source/dnode/vnode/src/inc/meta.h @@ -57,6 +57,9 @@ int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid); // metaCommit ================== static FORCE_INLINE tb_uid_t metaGenerateUid(SMeta* pMeta) { return tGenIdPI64(); } +// metaTable ================== +int metaHandleEntry(SMeta* pMeta, const SMetaEntry* pME); + struct SMeta { TdThreadRwlock lock; diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 2d6edae0e7..d5b719dfb9 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -47,7 +47,9 @@ struct SSmaEnv { }; typedef struct { - int32_t smaRef; + int8_t inited; + int32_t rsetId; + void *tmrHandle; // shared by all fetch tasks } SSmaMgmt; #define SMA_ENV_LOCK(env) ((env)->lock) @@ -64,7 +66,6 @@ struct SRSmaStat { SSma *pSma; int64_t submitVer; int64_t refId; // shared by fetch tasks - void *tmrHandle; // shared by fetch tasks int8_t triggerStat; // shared by fetch tasks int8_t runningStat; // for persistence task SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo; @@ -81,7 +82,6 @@ struct SSmaStat { #define SMA_TSMA_STAT(s) (&(s)->tsmaStat) #define SMA_RSMA_STAT(s) (&(s)->rsmaStat) #define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash) -#define RSMA_TMR_HANDLE(r) ((r)->tmrHandle) #define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat) #define RSMA_RUNNING_STAT(r) (&(r)->runningStat) #define RSMA_REF_ID(r) ((r)->refId) @@ -95,6 +95,7 @@ enum { TASK_TRIGGER_STAT_CANCELLED = 4, TASK_TRIGGER_STAT_FINISHED = 5, }; + void tdDestroySmaEnv(SSmaEnv *pSmaEnv); void *tdFreeSmaEnv(SSmaEnv *pSmaEnv); @@ -104,6 +105,10 @@ int32_t tdInsertRSmaData(SSma *pSma, char *msg); int32_t tdRefSmaStat(SSma *pSma, SSmaStat *pStat); int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat); + +void *tdAcquireSmaRef(int32_t rsetId, int64_t refId, const char *tags, int32_t ln); +int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId, const char *tags, int32_t ln); + int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType); int32_t tdLockSma(SSma *pSma); @@ -183,7 +188,7 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) { static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType); void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType); -void *tdFreeRSmaInfo(SRSmaInfo *pInfo); +void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo); int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat); int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName); diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index 9c3bd85c71..b2ea08d50d 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -129,6 +129,7 @@ typedef struct { static STqMgmt tqMgmt = {0}; // tqRead +int64_t tqScanLog(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal* offset); int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum); // tqExec diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 0f65a536e0..cce3da60cb 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -64,6 +64,7 @@ typedef struct SRowIter SRowIter; typedef struct STsdbFS STsdbFS; typedef struct SRowMerger SRowMerger; typedef struct STsdbFSState STsdbFSState; +typedef struct STsdbSnapHdr STsdbSnapHdr; #define TSDB_MAX_SUBBLOCKS 8 #define TSDB_FHDR_SIZE 512 @@ -245,6 +246,8 @@ int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h); int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey); +int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pSchema); + // structs ======================= typedef struct { int minFid; diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index ae659dc396..0c386babde 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -49,17 +49,20 @@ extern "C" { #endif -typedef struct SVnodeInfo SVnodeInfo; -typedef struct SMeta SMeta; -typedef struct SSma SSma; -typedef struct STsdb STsdb; -typedef struct STQ STQ; -typedef struct SVState SVState; -typedef struct SVBufPool SVBufPool; -typedef struct SQWorker SQHandle; -typedef struct STsdbKeepCfg STsdbKeepCfg; -typedef struct SMetaSnapshotReader SMetaSnapshotReader; -typedef struct STsdbSnapshotReader STsdbSnapshotReader; +typedef struct SVnodeInfo SVnodeInfo; +typedef struct SMeta SMeta; +typedef struct SSma SSma; +typedef struct STsdb STsdb; +typedef struct STQ STQ; +typedef struct SVState SVState; +typedef struct SVBufPool SVBufPool; +typedef struct SQWorker SQHandle; +typedef struct STsdbKeepCfg STsdbKeepCfg; +typedef struct SMetaSnapReader SMetaSnapReader; +typedef struct SMetaSnapWriter SMetaSnapWriter; +typedef struct STsdbSnapReader STsdbSnapReader; +typedef struct STsdbSnapWriter STsdbSnapWriter; +typedef struct SSnapDataHdr SSnapDataHdr; #define VNODE_META_DIR "meta" #define VNODE_TSDB_DIR "tsdb" @@ -72,10 +75,8 @@ typedef struct STsdbSnapshotReader STsdbSnapshotReader; #define VNODE_RSMA2_DIR "rsma2" // vnd.h -void* vnodeBufPoolMalloc(SVBufPool* pPool, int size); -void vnodeBufPoolFree(SVBufPool* pPool, void* p); -int32_t vnodeRealloc(void** pp, int32_t size); -void vnodeFree(void* p); +void* vnodeBufPoolMalloc(SVBufPool* pPool, int size); +void vnodeBufPoolFree(SVBufPool* pPool, void* p); // meta typedef struct SMCtbCursor SMCtbCursor; @@ -109,9 +110,6 @@ STSma* metaGetSmaInfoByIndex(SMeta* pMeta, int64_t indexUid); STSmaWrapper* metaGetSmaInfoByTable(SMeta* pMeta, tb_uid_t uid, bool deepCopy); SArray* metaGetSmaIdsByTable(SMeta* pMeta, tb_uid_t uid); SArray* metaGetSmaTbUids(SMeta* pMeta); -int32_t metaSnapshotReaderOpen(SMeta* pMeta, SMetaSnapshotReader** ppReader, int64_t sver, int64_t ever); -int32_t metaSnapshotReaderClose(SMetaSnapshotReader* pReader); -int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t* nData); void* metaGetIdx(SMeta* pMeta); void* metaGetIvtIdx(SMeta* pMeta); int metaTtlSmaller(SMeta* pMeta, uint64_t time, SArray* uidList); @@ -131,9 +129,6 @@ int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* p int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey); STsdbReader tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId, void* pMemRef); -int32_t tsdbSnapshotReaderOpen(STsdb* pTsdb, STsdbSnapshotReader** ppReader, int64_t sver, int64_t ever); -int32_t tsdbSnapshotReaderClose(STsdbSnapshotReader* pReader); -int32_t tsdbSnapshotRead(STsdbSnapshotReader* pReader, void** ppData, uint32_t* nData); // tq int tqInit(); @@ -163,6 +158,8 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool const char* stbFullName, int32_t vgId); // sma +int32_t smaInit(); +void smaCleanUp(); int32_t smaOpen(SVnode* pVnode); int32_t smaClose(SSma* pSma); int32_t smaBegin(SSma* pSma); @@ -181,6 +178,23 @@ int32_t tdUpdateTbUidList(SSma* pSma, STbUidStore* pUidStore); void tdUidStoreDestory(STbUidStore* pStore); void* tdUidStoreFree(STbUidStore* pStore); +// SMetaSnapReader ======================================== +int32_t metaSnapReaderOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapReader** ppReader); +int32_t metaSnapReaderClose(SMetaSnapReader** ppReader); +int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData); +// SMetaSnapWriter ======================================== +int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWriter** ppWriter); +int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); +int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback); +// STsdbSnapReader ======================================== +int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapReader** ppReader); +int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader); +int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData); +// STsdbSnapWriter ======================================== +int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter); +int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData); +int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback); + typedef struct { int8_t streamType; // sma or other int8_t dstType; @@ -200,7 +214,9 @@ typedef struct { struct SVState { int64_t committed; int64_t applied; + int64_t applyTerm; int64_t commitID; + int64_t commitTerm; }; struct SVnodeInfo { @@ -289,6 +305,12 @@ struct SSma { // sma void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data); +struct SSnapDataHdr { + int8_t type; + int64_t size; + uint8_t data[]; +}; + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 5757039d55..ac84842e85 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -15,53 +15,57 @@ #include "meta.h" -struct SMetaSnapshotReader { +// SMetaSnapReader ======================================== +struct SMetaSnapReader { SMeta* pMeta; - TBC* pTbc; int64_t sver; int64_t ever; + TBC* pTbc; }; -int32_t metaSnapshotReaderOpen(SMeta* pMeta, SMetaSnapshotReader** ppReader, int64_t sver, int64_t ever) { - int32_t code = 0; - int32_t c = 0; - SMetaSnapshotReader* pMetaReader = NULL; +int32_t metaSnapReaderOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapReader** ppReader) { + int32_t code = 0; + int32_t c = 0; + SMetaSnapReader* pMetaSnapReader = NULL; - pMetaReader = (SMetaSnapshotReader*)taosMemoryCalloc(1, sizeof(*pMetaReader)); - if (pMetaReader == NULL) { + // alloc + pMetaSnapReader = (SMetaSnapReader*)taosMemoryCalloc(1, sizeof(*pMetaSnapReader)); + if (pMetaSnapReader == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } - pMetaReader->pMeta = pMeta; - pMetaReader->sver = sver; - pMetaReader->ever = ever; - code = tdbTbcOpen(pMeta->pTbDb, &pMetaReader->pTbc, NULL); + pMetaSnapReader->pMeta = pMeta; + pMetaSnapReader->sver = sver; + pMetaSnapReader->ever = ever; + + // impl + code = tdbTbcOpen(pMeta->pTbDb, &pMetaSnapReader->pTbc, NULL); if (code) { goto _err; } - code = tdbTbcMoveTo(pMetaReader->pTbc, &(STbDbKey){.version = sver, .uid = INT64_MIN}, sizeof(STbDbKey), &c); + code = tdbTbcMoveTo(pMetaSnapReader->pTbc, &(STbDbKey){.version = sver, .uid = INT64_MIN}, sizeof(STbDbKey), &c); if (code) { goto _err; } - *ppReader = pMetaReader; + *ppReader = pMetaSnapReader; return code; _err: + metaError("vgId:%d meta snap reader open failed since %s", TD_VID(pMeta->pVnode), tstrerror(code)); *ppReader = NULL; return code; } -int32_t metaSnapshotReaderClose(SMetaSnapshotReader* pReader) { - if (pReader) { - tdbTbcClose(pReader->pTbc); - taosMemoryFree(pReader); - } +int32_t metaSnapReaderClose(SMetaSnapReader** ppReader) { + tdbTbcClose((*ppReader)->pTbc); + taosMemoryFree(*ppReader); + *ppReader = NULL; return 0; } -int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t* nDatap) { +int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) { const void* pKey = NULL; const void* pData = NULL; int32_t nKey = 0; @@ -71,23 +75,110 @@ int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t* for (;;) { code = tdbTbcGet(pReader->pTbc, &pKey, &nKey, &pData, &nData); if (code || ((STbDbKey*)pData)->version > pReader->ever) { - return TSDB_CODE_VND_READ_END; + code = TSDB_CODE_VND_READ_END; + goto _exit; } if (((STbDbKey*)pData)->version < pReader->sver) { + tdbTbcMoveToNext(pReader->pTbc); continue; } + tdbTbcMoveToNext(pReader->pTbc); break; } // copy the data - if (vnodeRealloc(ppData, nData) < 0) { + if (tRealloc(ppData, sizeof(SSnapDataHdr) + nData) < 0) { code = TSDB_CODE_OUT_OF_MEMORY; return code; } + ((SSnapDataHdr*)(*ppData))->type = 0; // TODO: use macro + ((SSnapDataHdr*)(*ppData))->size = nData; + memcpy(((SSnapDataHdr*)(*ppData))->data, pData, nData); - memcpy(*ppData, pData, nData); - *nDatap = nData; +_exit: + return code; +} + +// SMetaSnapWriter ======================================== +struct SMetaSnapWriter { + SMeta* pMeta; + int64_t sver; + int64_t ever; +}; + +static int32_t metaSnapRollback(SMetaSnapWriter* pWriter) { + int32_t code = 0; + // TODO + return code; +} + +static int32_t metaSnapCommit(SMetaSnapWriter* pWriter) { + int32_t code = 0; + // TODO + return code; +} + +int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWriter** ppWriter) { + int32_t code = 0; + SMetaSnapWriter* pWriter; + + // alloc + pWriter = (SMetaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); + if (pWriter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pWriter->pMeta = pMeta; + pWriter->sver = sver; + pWriter->ever = ever; + + *ppWriter = pWriter; + return code; + +_err: + metaError("vgId:%d meta snapshot writer open failed since %s", TD_VID(pMeta->pVnode), tstrerror(code)); + *ppWriter = NULL; + return code; +} + +int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback) { + int32_t code = 0; + SMetaSnapWriter* pWriter = *ppWriter; + + if (rollback) { + code = metaSnapRollback(pWriter); + if (code) goto _err; + } else { + code = metaSnapCommit(pWriter); + if (code) goto _err; + } + taosMemoryFree(pWriter); + *ppWriter = NULL; + + return code; + +_err: + metaError("vgId:%d meta snapshot writer close failed since %s", TD_VID(pWriter->pMeta->pVnode), tstrerror(code)); + return code; +} + +int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + SMeta* pMeta = pWriter->pMeta; + SMetaEntry metaEntry = {0}; + SDecoder* pDecoder = &(SDecoder){0}; + + tDecoderInit(pDecoder, pData, nData); + metaDecodeEntry(pDecoder, &metaEntry); + + code = metaHandleEntry(pMeta, &metaEntry); + if (code) goto _err; + + return code; + +_err: + metaError("vgId:%d meta snapshot write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code)); return code; } \ No newline at end of file diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 341173103c..daf7ccb26a 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -17,7 +17,6 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema); static int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema); -static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME); static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME); @@ -51,7 +50,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) { return -1; } - void * data = pCtbEntry->ctbEntry.pTags; + void *data = pCtbEntry->ctbEntry.pTags; const char *tagName = pSchema->name; tb_uid_t suid = pCtbEntry->ctbEntry.suid; @@ -70,7 +69,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i); char type = pTagVal->type; - char * key = pTagVal->pKey; + char *key = pTagVal->pKey; int32_t nKey = strlen(key); SIndexTerm *term = NULL; @@ -78,7 +77,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, NULL, 0); } else if (type == TSDB_DATA_TYPE_NCHAR) { if (pTagVal->nData > 0) { - char * val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE); + char *val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE); int32_t len = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, val + VARSTR_HEADER_SIZE); memcpy(val, (uint16_t *)&len, VARSTR_HEADER_SIZE); type = TSDB_DATA_TYPE_VARCHAR; @@ -109,7 +108,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) { return -1; } - void * data = pCtbEntry->ctbEntry.pTags; + void *data = pCtbEntry->ctbEntry.pTags; const char *tagName = pSchema->name; tb_uid_t suid = pCtbEntry->ctbEntry.suid; @@ -128,7 +127,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i); char type = pTagVal->type; - char * key = pTagVal->pKey; + char *key = pTagVal->pKey; int32_t nKey = strlen(key); SIndexTerm *term = NULL; @@ -136,7 +135,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche term = indexTermCreate(suid, DEL_VALUE, TSDB_DATA_TYPE_VARCHAR, key, nKey, NULL, 0); } else if (type == TSDB_DATA_TYPE_NCHAR) { if (pTagVal->nData > 0) { - char * val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE); + char *val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE); int32_t len = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, val + VARSTR_HEADER_SIZE); memcpy(val, (uint16_t *)&len, VARSTR_HEADER_SIZE); type = TSDB_DATA_TYPE_VARCHAR; @@ -169,9 +168,9 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { int vLen = 0; const void *pKey = NULL; const void *pVal = NULL; - void * pBuf = NULL; + void *pBuf = NULL; int32_t szBuf = 0; - void * p = NULL; + void *p = NULL; SMetaReader mr = {0}; // validate req @@ -229,7 +228,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) { } // drop all child tables - TBC * pCtbIdxc = NULL; + TBC *pCtbIdxc = NULL; SArray *pArray = taosArrayInit(8, sizeof(tb_uid_t)); tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, &pMeta->txn); @@ -285,8 +284,8 @@ _exit: int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { SMetaEntry oStbEntry = {0}; SMetaEntry nStbEntry = {0}; - TBC * pUidIdxc = NULL; - TBC * pTbDbc = NULL; + TBC *pUidIdxc = NULL; + TBC *pTbDbc = NULL; const void *pData; int nData; int64_t oversion; @@ -409,7 +408,7 @@ _err: } int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUids) { - void * pData = NULL; + void *pData = NULL; int nData = 0; int rc = 0; tb_uid_t uid; @@ -477,7 +476,7 @@ static int metaDeleteTtlIdx(SMeta *pMeta, const SMetaEntry *pME) { } static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { - void * pData = NULL; + void *pData = NULL; int nData = 0; int rc = 0; SMetaEntry e = {0}; @@ -538,14 +537,14 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { } static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq, STableMetaRsp *pMetaRsp) { - void * pVal = NULL; + void *pVal = NULL; int nVal = 0; - const void * pData = NULL; + const void *pData = NULL; int nData = 0; int ret = 0; tb_uid_t uid; int64_t oversion; - SSchema * pColumn = NULL; + SSchema *pColumn = NULL; SMetaEntry entry = {0}; SSchemaWrapper *pSchema; int c; @@ -699,7 +698,7 @@ _err: static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) { SMetaEntry ctbEntry = {0}; SMetaEntry stbEntry = {0}; - void * pVal = NULL; + void *pVal = NULL; int nVal = 0; int ret; int c; @@ -730,7 +729,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA oversion = *(int64_t *)pData; // search table.db - TBC * pTbDbc = NULL; + TBC *pTbDbc = NULL; SDecoder dc1 = {0}; SDecoder dc2 = {0}; @@ -754,7 +753,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA metaDecodeEntry(&dc2, &stbEntry); SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag; - SSchema * pColumn = NULL; + SSchema *pColumn = NULL; int32_t iCol = 0; for (;;) { pColumn = NULL; @@ -784,8 +783,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA memcpy((void *)ctbEntry.ctbEntry.pTags, pAlterTbReq->pTagVal, pAlterTbReq->nTagVal); } else { const STag *pOldTag = (const STag *)ctbEntry.ctbEntry.pTags; - STag * pNewTag = NULL; - SArray * pTagArray = taosArrayInit(pTagSchema->nCols, sizeof(STagVal)); + STag *pNewTag = NULL; + SArray *pTagArray = taosArrayInit(pTagSchema->nCols, sizeof(STagVal)); if (!pTagArray) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -844,7 +843,7 @@ _err: } static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) { - void * pVal = NULL; + void *pVal = NULL; int nVal = 0; const void *pData = NULL; int nData = 0; @@ -948,8 +947,8 @@ int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMeta static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) { STbDbKey tbDbKey; - void * pKey = NULL; - void * pVal = NULL; + void *pKey = NULL; + void *pVal = NULL; int kLen = 0; int vLen = 0; SEncoder coder = {0}; @@ -1055,14 +1054,14 @@ static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey) { } static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { - void * pData = NULL; + void *pData = NULL; int nData = 0; STbDbKey tbDbKey = {0}; SMetaEntry stbEntry = {0}; - STagIdxKey * pTagIdxKey = NULL; + STagIdxKey *pTagIdxKey = NULL; int32_t nTagIdxKey; const SSchema *pTagColumn; // = &stbEntry.stbEntry.schema.pSchema[0]; - const void * pTagData = NULL; // + const void *pTagData = NULL; // int32_t nTagData = 0; SDecoder dc = {0}; @@ -1109,7 +1108,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) { SEncoder coder = {0}; - void * pVal = NULL; + void *pVal = NULL; int vLen = 0; int rcode = 0; SSkmDbKey skmDbKey = {0}; @@ -1151,7 +1150,7 @@ _exit: return rcode; } -static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) { +int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) { metaWLock(pMeta); // save to table.db diff --git a/source/dnode/vnode/src/sma/sma.c b/source/dnode/vnode/src/sma/sma.c deleted file mode 100644 index 12f93f9400..0000000000 --- a/source/dnode/vnode/src/sma/sma.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "sma.h" - -// functions for external invocation - -// TODO: Who is responsible for resource allocate and release? -int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg) { - int32_t code = TSDB_CODE_SUCCESS; - - if ((code = tdProcessTSmaInsertImpl(pSma, indexUid, msg)) < 0) { - smaWarn("vgId:%d, insert tsma data failed since %s", SMA_VID(pSma), tstrerror(terrno)); - } - // TODO: destroy SSDataBlocks(msg) - return code; -} - -int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg) { - int32_t code = TSDB_CODE_SUCCESS; - - if ((code = tdProcessTSmaCreateImpl(pSma, version, msg)) < 0) { - smaWarn("vgId:%d, create tsma failed since %s", SMA_VID(pSma), tstrerror(terrno)); - } - // TODO: destroy SSDataBlocks(msg) - return code; -} - -int32_t smaGetTSmaDays(SVnodeCfg* pCfg, void* pCont, uint32_t contLen, int32_t* days) { - int32_t code = TSDB_CODE_SUCCESS; - if ((code = tdProcessTSmaGetDaysImpl(pCfg, pCont, contLen, days)) < 0) { - smaWarn("vgId:%d, get tsma days failed since %s", pCfg->vgId, tstrerror(terrno)); - } - smaDebug("vgId:%d, get tsma days %d", pCfg->vgId, *days); - return code; -} - - -// functions for internal invocation - -#if 0 - -/** - * @brief TODO: Assume that the final generated result it less than 3M - * - * @param pReq - * @param pDataBlocks - * @param vgId - * @param suid // TODO: check with Liao whether suid response is reasonable - * - * TODO: colId should be set - */ -int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema* pTSchema, int32_t vgId, - tb_uid_t suid, const char* stbName, bool isCreateCtb) { - int32_t sz = taosArrayGetSize(pDataBlocks); - int32_t bufSize = sizeof(SSubmitReq); - for (int32_t i = 0; i < sz; ++i) { - SDataBlockInfo* pBlkInfo = &((SSDataBlock*)taosArrayGet(pDataBlocks, i))->info; - bufSize += pBlkInfo->rows * (TD_ROW_HEAD_LEN + pBlkInfo->rowSize + BitmapLen(pBlkInfo->numOfCols)); - bufSize += sizeof(SSubmitBlk); - } - - *pReq = taosMemoryCalloc(1, bufSize); - if (!(*pReq)) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; - } - void* pDataBuf = *pReq; - - SArray* pTagArray = NULL; - int32_t msgLen = sizeof(SSubmitReq); - int32_t numOfBlks = 0; - int32_t schemaLen = 0; - SRowBuilder rb = {0}; - tdSRowInit(&rb, pTSchema->version); - - for (int32_t i = 0; i < sz; ++i) { - SSDataBlock* pDataBlock = taosArrayGet(pDataBlocks, i); - SDataBlockInfo* pDataBlkInfo = &pDataBlock->info; - int32_t colNum = pDataBlkInfo->numOfCols; - int32_t rows = pDataBlkInfo->rows; - int32_t rowSize = pDataBlkInfo->rowSize; - int64_t groupId = pDataBlkInfo->groupId; - - if (rb.nCols != colNum) { - tdSRowSetTpInfo(&rb, colNum, pTSchema->flen); - } - - if(isCreateCtb) { - SMetaReader mr = {0}; - const char* ctbName = buildCtbNameByGroupId(stbName, pDataBlock->info.groupId); - if (metaGetTableEntryByName(&mr, ctbName) != 0) { - smaDebug("vgId:%d, no tsma ctb %s exists", vgId, ctbName); - } - SVCreateTbReq ctbReq = {0}; - ctbReq.name = ctbName; - ctbReq.type = TSDB_CHILD_TABLE; - ctbReq.ctb.suid = suid; - - STagVal tagVal = {.cid = colNum + PRIMARYKEY_TIMESTAMP_COL_ID, - .type = TSDB_DATA_TYPE_BIGINT, - .i64 = groupId}; - STag* pTag = NULL; - if(!pTagArray) { - pTagArray = taosArrayInit(1, sizeof(STagVal)); - if (!pTagArray) goto _err; - } - taosArrayClear(pTagArray); - taosArrayPush(pTagArray, &tagVal); - tTagNew(pTagArray, 1, false, &pTag); - if (pTag == NULL) { - tdDestroySVCreateTbReq(&ctbReq); - goto _err; - } - ctbReq.ctb.pTag = (uint8_t*)pTag; - - int32_t code; - tEncodeSize(tEncodeSVCreateTbReq, &ctbReq, schemaLen, code); - - tdDestroySVCreateTbReq(&ctbReq); - if (code < 0) { - goto _err; - } - } - - - - SSubmitBlk* pSubmitBlk = POINTER_SHIFT(pDataBuf, msgLen); - pSubmitBlk->suid = suid; - pSubmitBlk->uid = groupId; - pSubmitBlk->numOfRows = rows; - - msgLen += sizeof(SSubmitBlk); - int32_t dataLen = 0; - for (int32_t j = 0; j < rows; ++j) { // iterate by row - tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen)); // set row buf - bool isStartKey = false; - int32_t offset = 0; - for (int32_t k = 0; k < colNum; ++k) { // iterate by column - SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k); - STColumn* pCol = &pTSchema->columns[k]; - void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); - switch (pColInfoData->info.type) { - case TSDB_DATA_TYPE_TIMESTAMP: - if (!isStartKey) { - isStartKey = true; - tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, true, - offset, k); - - } else { - tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, - true, offset, k); - } - break; - case TSDB_DATA_TYPE_NCHAR: { - tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_NCHAR, TD_VTYPE_NORM, var, true, - offset, k); - break; - } - case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY - tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_VARCHAR, TD_VTYPE_NORM, var, true, - offset, k); - break; - } - case TSDB_DATA_TYPE_VARBINARY: - case TSDB_DATA_TYPE_DECIMAL: - case TSDB_DATA_TYPE_BLOB: - case TSDB_DATA_TYPE_JSON: - case TSDB_DATA_TYPE_MEDIUMBLOB: - uError("the column type %" PRIi16 " is defined but not implemented yet", pColInfoData->info.type); - TASSERT(0); - break; - default: - if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) { - if (pCol->type == pColInfoData->info.type) { - tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, var, true, offset, - k); - } else { - char tv[8] = {0}; - if (pColInfoData->info.type == TSDB_DATA_TYPE_FLOAT) { - float v = 0; - GET_TYPED_DATA(v, float, pColInfoData->info.type, var); - SET_TYPED_DATA(&tv, pCol->type, v); - } else if (pColInfoData->info.type == TSDB_DATA_TYPE_DOUBLE) { - double v = 0; - GET_TYPED_DATA(v, double, pColInfoData->info.type, var); - SET_TYPED_DATA(&tv, pCol->type, v); - } else if (IS_SIGNED_NUMERIC_TYPE(pColInfoData->info.type)) { - int64_t v = 0; - GET_TYPED_DATA(v, int64_t, pColInfoData->info.type, var); - SET_TYPED_DATA(&tv, pCol->type, v); - } else { - uint64_t v = 0; - GET_TYPED_DATA(v, uint64_t, pColInfoData->info.type, var); - SET_TYPED_DATA(&tv, pCol->type, v); - } - tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, tv, true, offset, - k); - } - } else { - uError("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type); - TASSERT(0); - } - break; - } - offset += TYPE_BYTES[pCol->type]; // sum/avg would convert to int64_t/uint64_t/double during aggregation - } - dataLen += TD_ROW_LEN(rb.pBuf); -#ifdef TD_DEBUG_PRINT_ROW - tdSRowPrint(rb.pBuf, pTSchema, __func__); -#endif - } - - ++numOfBlks; - - pSubmitBlk->dataLen = dataLen; - msgLen += pSubmitBlk->dataLen; - } - - (*pReq)->length = msgLen; - - (*pReq)->header.vgId = htonl(vgId); - (*pReq)->header.contLen = htonl(msgLen); - (*pReq)->length = (*pReq)->header.contLen; - (*pReq)->numOfBlocks = htonl(numOfBlks); - SSubmitBlk* blk = (SSubmitBlk*)((*pReq) + 1); - while (numOfBlks--) { - int32_t dataLen = blk->dataLen; - blk->uid = htobe64(blk->uid); - blk->suid = htobe64(blk->suid); - blk->padding = htonl(blk->padding); - blk->sversion = htonl(blk->sversion); - blk->dataLen = htonl(blk->dataLen); - blk->schemaLen = htonl(blk->schemaLen); - blk->numOfRows = htons(blk->numOfRows); - blk = (SSubmitBlk*)(blk->data + dataLen); - } - return TSDB_CODE_SUCCESS; -_err: - taosMemoryFreeClear(*pReq); - taosArrayDestroy(pTagArray); - - return TSDB_CODE_FAILED; -} -#endif diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index 6e75176136..e241c14fc7 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -121,7 +121,7 @@ static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma) { // step 3: perform persist task for qTaskInfo tdRSmaPersistExecImpl(pRSmaStat); - smaDebug("vgId:%d, rsma pre commit succeess", SMA_VID(pSma)); + smaDebug("vgId:%d, rsma pre commit success", SMA_VID(pSma)); return TSDB_CODE_SUCCESS; } @@ -173,6 +173,7 @@ static int32_t tdProcessRSmaPostCommitImpl(SSma *pSma) { } if ((pDir = taosOpenDir(dir)) == NULL) { + regfree(®ex); terrno = TAOS_SYSTEM_ERROR(errno); smaWarn("vgId:%d, rsma post commit, open dir %s failed since %s", TD_VID(pVnode), dir, terrstr()); return TSDB_CODE_FAILED; diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index c7b938f884..5eb9665326 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -18,7 +18,7 @@ typedef struct SSmaStat SSmaStat; #define RSMA_TASK_INFO_HASH_SLOT 8 -#define SMA_MGMT_REF_NUM 1024 +#define SMA_MGMT_REF_NUM 10240 extern SSmaMgmt smaMgmt; @@ -30,7 +30,73 @@ static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaE static void *tdFreeTSmaStat(STSmaStat *pStat); static void tdDestroyRSmaStat(void *pRSmaStat); +/** + * @brief rsma init + * + * @return int32_t + */ // implementation +int32_t smaInit() { + int8_t old; + int32_t nLoops = 0; + while (1) { + old = atomic_val_compare_exchange_8(&smaMgmt.inited, 0, 2); + if (old != 2) break; + if (++nLoops > 1000) { + sched_yield(); + nLoops = 0; + } + } + + if (old == 0) { + // init tref rset + smaMgmt.rsetId = taosOpenRef(SMA_MGMT_REF_NUM, tdDestroyRSmaStat); + + if (smaMgmt.rsetId < 0) { + atomic_store_8(&smaMgmt.inited, 0); + smaError("failed to init sma rset since %s", terrstr()); + return TSDB_CODE_FAILED; + } + + // init fetch timer handle + smaMgmt.tmrHandle = taosTmrInit(10000, 100, 10000, "RSMA"); + if (!smaMgmt.tmrHandle) { + taosCloseRef(smaMgmt.rsetId); + atomic_store_8(&smaMgmt.inited, 0); + smaError("failed to init sma tmr hanle since %s", terrstr()); + return TSDB_CODE_FAILED; + } + + atomic_store_8(&smaMgmt.inited, 1); + smaInfo("sma mgmt env is initialized, rsetId:%d, tmrHandle:%p", smaMgmt.rsetId, smaMgmt.tmrHandle); + } + + return TSDB_CODE_SUCCESS; +} + +/** + * @brief rsma cleanup + * + */ +void smaCleanUp() { + int8_t old; + int32_t nLoops = 0; + while (1) { + old = atomic_val_compare_exchange_8(&smaMgmt.inited, 1, 2); + if (old != 2) break; + if (++nLoops > 1000) { + sched_yield(); + nLoops = 0; + } + } + + if (old == 1) { + taosCloseRef(smaMgmt.rsetId); + taosTmrCleanUp(smaMgmt.tmrHandle); + smaInfo("sma mgmt env is cleaned up, rsetId:%d, tmrHandle:%p", smaMgmt.rsetId, smaMgmt.tmrHandle); + atomic_store_8(&smaMgmt.inited, 0); + } +} static SSmaEnv *tdNewSmaEnv(const SSma *pSma, int8_t smaType, const char *path) { SSmaEnv *pEnv = NULL; @@ -135,34 +201,24 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_INIT); // init smaMgmt - smaMgmt.smaRef = taosOpenRef(SMA_MGMT_REF_NUM, tdDestroyRSmaStat); - if (smaMgmt.smaRef < 0) { - smaError("init smaRef failed, num:%d", SMA_MGMT_REF_NUM); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return TSDB_CODE_FAILED; - } + smaInit(); - int64_t refId = taosAddRef(smaMgmt.smaRef, pRSmaStat); + int64_t refId = taosAddRef(smaMgmt.rsetId, pRSmaStat); if (refId < 0) { - smaError("taosAddRef smaRef failed, since:%s", tstrerror(terrno)); + smaError("vgId:%d, taosAddRef refId:%" PRIi64 " to rsetId rsetId:%d max:%d failed since:%s", SMA_VID(pSma), + refId, smaMgmt.rsetId, SMA_MGMT_REF_NUM, tstrerror(terrno)); return TSDB_CODE_FAILED; + } else { + smaDebug("vgId:%d, taosAddRef refId:%" PRIi64 " to rsetId rsetId:%d max:%d succeed", SMA_VID(pSma), refId, + smaMgmt.rsetId, SMA_MGMT_REF_NUM); } pRSmaStat->refId = refId; - // init timer - RSMA_TMR_HANDLE(pRSmaStat) = taosTmrInit(10000, 100, 10000, "RSMA"); - if (!RSMA_TMR_HANDLE(pRSmaStat)) { - taosMemoryFreeClear(*pSmaStat); - return TSDB_CODE_FAILED; - } // init hash RSMA_INFO_HASH(pRSmaStat) = taosHashInit( RSMA_TASK_INFO_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK); if (!RSMA_INFO_HASH(pRSmaStat)) { - if (RSMA_TMR_HANDLE(pRSmaStat)) { - taosTmrCleanUp(RSMA_TMR_HANDLE(pRSmaStat)); - } taosMemoryFreeClear(*pSmaStat); return TSDB_CODE_FAILED; } @@ -223,7 +279,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { void *infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), NULL); while (infoHash) { SRSmaInfo *pSmaInfo = *(SRSmaInfo **)infoHash; - tdFreeRSmaInfo(pSmaInfo); + tdFreeRSmaInfo(pSma, pSmaInfo); infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), infoHash); } } @@ -244,11 +300,6 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { nLoops = 0; } } - - // step 6: cleanup the timer handle - if (RSMA_TMR_HANDLE(pStat)) { - taosTmrCleanUp(RSMA_TMR_HANDLE(pStat)); - } } } @@ -275,8 +326,13 @@ int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { tdDestroyTSmaStat(SMA_TSMA_STAT(pSmaStat)); } else if (smaType == TSDB_SMA_TYPE_ROLLUP) { SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pSmaStat); - if (taosRemoveRef(smaMgmt.smaRef, RSMA_REF_ID(pRSmaStat)) < 0) { - smaError("remove refId from rsmaRef:0x%" PRIx64 " failed since %s", RSMA_REF_ID(pRSmaStat), terrstr()); + if (taosRemoveRef(smaMgmt.rsetId, RSMA_REF_ID(pRSmaStat)) < 0) { + smaError("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " failed since %s", SMA_VID(pRSmaStat->pSma), + RSMA_REF_ID(pRSmaStat), smaMgmt.rsetId, terrstr()); + ASSERT(0); + } else { + smaDebug("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " succeed", SMA_VID(pRSmaStat->pSma), + RSMA_REF_ID(pRSmaStat), smaMgmt.rsetId); } } else { ASSERT(0); @@ -323,7 +379,7 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) { } break; default: - TASSERT(0); + smaError("vgId:%d undefined smaType:%", SMA_VID(pSma), smaType); return TSDB_CODE_FAILED; } diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 6f87c01be1..efa2886e48 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -19,23 +19,27 @@ #define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid SSmaMgmt smaMgmt = { - .smaRef = -1, + .inited = 0, + .rsetId = -1, }; #define TD_QTASKINFO_FNAME_PREFIX "qtaskinfo.ver" typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem; typedef struct SRSmaQTaskInfoIter SRSmaQTaskInfoIter; -static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid); -static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids); -static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaInfo *pRSmaInfo, SReadHandle *handle, - int8_t idx); -static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *rsmaItem, - tb_uid_t suid, int8_t level); -static void tdRSmaFetchTrigger(void *param, void *tmrId); -static void tdRSmaPersistTrigger(void *param, void *tmrId); -static void *tdRSmaPersistExec(void *param); -static void tdRSmaQTaskInfoGetFName(int32_t vid, int64_t version, char *outputName); +static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid); +static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids); +static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat *pStat, SRSmaInfo *pRSmaInfo, + SReadHandle *handle, int8_t idx); +static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *rsmaItem, + STSchema *pTSchema, tb_uid_t suid, int8_t level); +static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid); +static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSchema, int64_t suid, SRSmaStat *pStat, + int8_t blkType); +static void tdRSmaFetchTrigger(void *param, void *tmrId); +static void tdRSmaPersistTrigger(void *param, void *tmrId); +static void *tdRSmaPersistExec(void *param); +static void tdRSmaQTaskInfoGetFName(int32_t vid, int64_t version, char *outputName); static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile); static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish); @@ -47,25 +51,26 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed); static int32_t tdRSmaRestoreTSDataReload(SSma *pSma, int64_t committed); struct SRSmaInfoItem { - SRSmaInfo *pRsmaInfo; - int64_t refId; - void *taskInfo; // qTaskInfo_t - tmr_h tmrId; - int8_t level; - int8_t tmrInitFlag; - int8_t triggerStat; - int32_t maxDelay; + void *taskInfo; // qTaskInfo_t + int64_t refId; + tmr_h tmrId; + int32_t maxDelay; + int8_t level; + int8_t triggerStat; }; struct SRSmaInfo { STSchema *pTSchema; - SRSmaStat *pStat; int64_t suid; SRSmaInfoItem items[TSDB_RETENTION_L2]; }; -#define RSMA_INFO_SMA(r) ((r)->pStat->pSma) -#define RSMA_INFO_STAT(r) ((r)->pStat) +static SRSmaInfo *tdGetRSmaInfoByItem(SRSmaInfoItem *pItem) { + // adapt accordingly if definition of SRSmaInfo update + int32_t rsmaInfoHeadLen = sizeof(int64_t) + sizeof(STSchema *); + ASSERT(pItem->level == 1 || pItem->level == 2); + return (SRSmaInfo *)POINTER_SHIFT(pItem, -sizeof(SRSmaInfoItem) * (pItem->level - 1) - rsmaInfoHeadLen); +} struct SRSmaQTaskInfoItem { int32_t len; @@ -107,9 +112,8 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId, } } -void *tdFreeRSmaInfo(SRSmaInfo *pInfo) { +void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo) { if (pInfo) { - SSma *pSma = RSMA_INFO_SMA(pInfo); for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { SRSmaInfoItem *pItem = &pInfo->items[i]; if (pItem->taskInfo) { @@ -142,8 +146,6 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) { } static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) { - SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); - SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); SRSmaInfo *pRSmaInfo = NULL; if (!suid || !tbUids) { @@ -152,8 +154,9 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) return TSDB_CODE_FAILED; } - pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), suid, sizeof(tb_uid_t)); - if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) { + pRSmaInfo = tdGetRSmaInfoBySuid(pSma, *suid); + + if (!pRSmaInfo) { smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64, SMA_VID(pSma), *suid); terrno = TSDB_CODE_RSMA_INVALID_STAT; return TSDB_CODE_FAILED; @@ -251,15 +254,14 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui return TSDB_CODE_SUCCESS; } -static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaInfo *pRSmaInfo, SReadHandle *pReadHandle, - int8_t idx) { +static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat *pStat, SRSmaInfo *pRSmaInfo, + SReadHandle *pReadHandle, int8_t idx) { SRetention *pRetention = SMA_RETENTION(pSma); STsdbCfg *pTsdbCfg = SMA_TSDB_CFG(pSma); if (param->qmsg[idx]) { SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]); - pItem->refId = RSMA_REF_ID(pRSmaInfo->pStat); - pItem->pRsmaInfo = pRSmaInfo; + pItem->refId = RSMA_REF_ID(pStat); pItem->taskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], pReadHandle); if (!pItem->taskInfo) { terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE; @@ -277,8 +279,9 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaInfo pItem->maxDelay = TSDB_MAX_ROLLUP_MAX_DELAY; } pItem->level = (idx == 0 ? TSDB_RETENTION_L1 : TSDB_RETENTION_L2); - smaInfo("vgId:%d table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64 ", finally maxdelay:%"PRIi32, SMA_VID(pSma), - pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx], pItem->maxDelay); + smaInfo("vgId:%d table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64 + ", finally maxdelay:%" PRIi32, + SMA_VID(pSma), pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx], pItem->maxDelay); } return TSDB_CODE_SUCCESS; _err: @@ -346,14 +349,13 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con goto _err; } pRSmaInfo->pTSchema = pTSchema; - pRSmaInfo->pStat = pStat; pRSmaInfo->suid = suid; - if (tdSetRSmaInfoItemParams(pSma, param, pRSmaInfo, &handle, 0) < 0) { + if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, &handle, 0) < 0) { goto _err; } - if (tdSetRSmaInfoItemParams(pSma, param, pRSmaInfo, &handle, 1) < 0) { + if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, &handle, 1) < 0) { goto _err; } @@ -365,7 +367,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con return TSDB_CODE_SUCCESS; _err: - tdFreeRSmaInfo(pRSmaInfo); + tdFreeRSmaInfo(pSma, pRSmaInfo); taosMemoryFree(pReader); return TSDB_CODE_FAILED; } @@ -536,10 +538,10 @@ int64_t tdRSmaGetMaxSubmitVer(SSma *pSma, int8_t level) { return atomic_load_64(&pRSmaStat->submitVer); } -static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType) { - SArray *pResult = NULL; - SRSmaInfo *pRSmaInfo = pItem->pRsmaInfo; - SSma *pSma = RSMA_INFO_SMA(pRSmaInfo); +static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSchema, int64_t suid, SRSmaStat *pStat, + int8_t blkType) { + SArray *pResult = NULL; + SSma *pSma = pStat->pSma; while (1) { SSDataBlock *output = NULL; @@ -571,12 +573,16 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType) STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb1 : pSma->pRSmaTsdb2); SSubmitReq *pReq = NULL; // TODO: the schema update should be handled - if (buildSubmitReqFromDataBlock(&pReq, pResult, pRSmaInfo->pTSchema, SMA_VID(pSma), pRSmaInfo->suid) < 0) { + if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) { + smaError("vgId:%d, build submit req for rsma table %" PRIi64 "l evel %" PRIi8 " failed since %s", SMA_VID(pSma), + suid, pItem->level, terrstr()); goto _err; } - if (pReq && tdProcessSubmitReq(sinkTsdb, atomic_add_fetch_64(&pRSmaInfo->pStat->submitVer, 1), pReq) < 0) { + if (pReq && tdProcessSubmitReq(sinkTsdb, atomic_add_fetch_64(&pStat->submitVer, 1), pReq) < 0) { taosMemoryFreeClear(pReq); + smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), + suid, pItem->level, terrstr()); goto _err; } @@ -594,81 +600,16 @@ _err: return TSDB_CODE_FAILED; } -/** - * @brief trigger to get rsma result - * - * @param param - * @param tmrId - */ -static void tdRSmaFetchTrigger(void *param, void *tmrId) { - SRSmaInfoItem *pItem = param; - SSma *pSma = NULL; - SRSmaStat *pStat = (SRSmaStat *)taosAcquireRef(smaMgmt.smaRef, pItem->refId); - if (!pStat) { - smaDebug("rsma fetch task not start since already destroyed"); - return; - } - - pSma = RSMA_INFO_SMA(pItem->pRsmaInfo); - - // if rsma trigger stat in paused, cancelled or finished, not start fetch task - int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat)); - switch (rsmaTriggerStat) { - case TASK_TRIGGER_STAT_PAUSED: - case TASK_TRIGGER_STAT_CANCELLED: - case TASK_TRIGGER_STAT_FINISHED: { - taosReleaseRef(smaMgmt.smaRef, pItem->refId); - smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is cancelled", - SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); - return; - } - default: - break; - } - - int8_t fetchTriggerStat = - 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, pItem->pRsmaInfo->suid); - - tdRefSmaStat(pSma, (SSmaStat *)pStat); - - SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL}; - qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_INPUT__DATA_BLOCK, false); - tdFetchAndSubmitRSmaResult(pItem, STREAM_INPUT__DATA_BLOCK); - - tdUnRefSmaStat(pSma, (SSmaStat *)pStat); - } break; - case TASK_TRIGGER_STAT_PAUSED: { - smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is paused", - SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); - } break; - case TASK_TRIGGER_STAT_INACTIVE: { - smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is inactive", - SMA_VID(pSma), pItem->level, pItem->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, pItem->pRsmaInfo->suid); - } break; - default: { - smaWarn("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is unknown", - SMA_VID(pSma), pItem->level, pItem->pRsmaInfo->suid); - } break; - } - -_end: - taosReleaseRef(smaMgmt.smaRef, pItem->refId); -} - -static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem, tb_uid_t suid, - int8_t level) { +static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem, + STSchema *pTSchema, tb_uid_t suid, int8_t level) { if (!pItem || !pItem->taskInfo) { smaDebug("vgId:%d, no qTaskInfo to execute rsma %" PRIi8 " task for suid:%" PRIu64, SMA_VID(pSma), level, suid); return TSDB_CODE_SUCCESS; } + if (!pTSchema) { + smaWarn("vgId:%d, no schema to execute rsma %" PRIi8 " task for suid:%" PRIu64, SMA_VID(pSma), level, suid); + return TSDB_CODE_FAILED; + } smaDebug("vgId:%d, execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, SMA_VID(pSma), level, pItem->taskInfo, suid); @@ -678,14 +619,14 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType return TSDB_CODE_FAILED; } - tdFetchAndSubmitRSmaResult(pItem, STREAM_INPUT__DATA_SUBMIT); - atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE); - SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = SMA_RSMA_STAT(pEnv->pStat); - if (pStat->tmrHandle) { - taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, pStat->tmrHandle, &pItem->tmrId); + tdRSmaFetchAndSubmitResult(pItem, pTSchema, suid, pStat, 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); } @@ -693,19 +634,29 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType return TSDB_CODE_SUCCESS; } -static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb_uid_t suid) { - SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); +static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) { + SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); + SRSmaStat *pStat = NULL; if (!pEnv) { // only applicable when rsma env exists - return TSDB_CODE_SUCCESS; + return NULL; } - SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); - SRSmaInfo *pRSmaInfo = NULL; - - pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t)); + pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); + if (!pStat || !RSMA_INFO_HASH(pStat)) { + return NULL; + } + SRSmaInfo *pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t)); if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) { + return NULL; + } + return pRSmaInfo; +} + +static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb_uid_t suid) { + SRSmaInfo *pRSmaInfo = tdGetRSmaInfoBySuid(pSma, suid); + if (!pRSmaInfo) { smaDebug("vgId:%d, return as no rsma info for suid:%" PRIu64, SMA_VID(pSma), suid); return TSDB_CODE_SUCCESS; } @@ -716,8 +667,8 @@ static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb } if (inputType == STREAM_INPUT__DATA_SUBMIT) { - tdExecuteRSmaImpl(pSma, pMsg, inputType, &pRSmaInfo->items[0], suid, TSDB_RETENTION_L1); - tdExecuteRSmaImpl(pSma, pMsg, inputType, &pRSmaInfo->items[1], suid, TSDB_RETENTION_L2); + tdExecuteRSmaImpl(pSma, pMsg, inputType, &pRSmaInfo->items[0], pRSmaInfo->pTSchema, suid, TSDB_RETENTION_L1); + tdExecuteRSmaImpl(pSma, pMsg, inputType, &pRSmaInfo->items[1], pRSmaInfo->pTSchema, suid, TSDB_RETENTION_L2); } return TSDB_CODE_SUCCESS; @@ -930,13 +881,11 @@ _err: } static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *pItem) { - SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT((SSmaEnv *)pSma->pRSmaEnv); SRSmaInfo *pRSmaInfo = NULL; void *qTaskInfo = NULL; - pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &pItem->suid, sizeof(pItem->suid)); - - if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) { + pRSmaInfo = tdGetRSmaInfoBySuid(pSma, pItem->suid); + if (!pRSmaInfo) { smaDebug("vgId:%d, no restore as no rsma info for table:%" PRIu64, SMA_VID(pSma), pItem->suid); return TSDB_CODE_SUCCESS; } @@ -1253,7 +1202,8 @@ _end: } atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); - taosReleaseRef(smaMgmt.smaRef, pRSmaStat->refId); + smaDebug("vgId:%d, release rsetId rsetId:%" PRIi64 " refId:%d", SMA_VID(pSma), smaMgmt.rsetId, pRSmaStat->refId); + tdReleaseSmaRef(smaMgmt.rsetId, pRSmaStat->refId, __func__, __LINE__); taosThreadExit(NULL); return NULL; } @@ -1278,7 +1228,9 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) { atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))); } atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); - taosReleaseRef(smaMgmt.smaRef, pRSmaStat->refId); + smaDebug("vgId:%d, release rsetId rsetId:%" PRIi64 " refId:%d)", SMA_VID(pRSmaStat->pSma), smaMgmt.rsetId, + pRSmaStat->refId); + tdReleaseSmaRef(smaMgmt.rsetId, pRSmaStat->refId, __func__, __LINE__); } taosThreadAttrDestroy(&thAttr); @@ -1292,8 +1244,8 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) { */ static void tdRSmaPersistTrigger(void *param, void *tmrId) { SRSmaStat *rsmaStat = param; - SRSmaStat *pRSmaStat = (SRSmaStat *)taosAcquireRef(smaMgmt.smaRef, rsmaStat->refId); - + SRSmaStat *pRSmaStat = (SRSmaStat *)taosAcquireRef(smaMgmt.rsetId, rsmaStat->refId); + ASSERT(0); if (!pRSmaStat) { smaDebug("rsma persistence task not start since already destroyed"); return; @@ -1336,5 +1288,81 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { smaWarn("rsma persistence not start since unknown stat %" PRIi8, tmrStat); } break; } - taosReleaseRef(smaMgmt.smaRef, rsmaStat->refId); + taosReleaseRef(smaMgmt.rsetId, rsmaStat->refId); +} + +/** + * @brief trigger to get rsma result + * + * @param param + * @param tmrId + */ +static void tdRSmaFetchTrigger(void *param, void *tmrId) { + SRSmaInfoItem *pItem = param; + SSma *pSma = NULL; + SRSmaStat *pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__); + + if (!pStat) { + smaDebug("rsma fetch task not start since already destroyed, rsetId rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId, + pItem->refId); + return; + } + + pSma = pStat->pSma; + + // if rsma trigger stat in paused, cancelled or finished, not start fetch task + int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat)); + switch (rsmaTriggerStat) { + case TASK_TRIGGER_STAT_PAUSED: + case TASK_TRIGGER_STAT_CANCELLED: + case TASK_TRIGGER_STAT_FINISHED: { + tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__); + smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data since stat is %" PRIi8 ", rsetId rsetId:%" PRIi64 + " refId:%d", + SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pItem->refId); + return; + } + default: + break; + } + + SRSmaInfo *pRSmaInfo = tdGetRSmaInfoByItem(pItem); + + ASSERT(pRSmaInfo->suid > 0); + + int8_t fetchTriggerStat = + 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); + + tdRefSmaStat(pSma, (SSmaStat *)pStat); + + SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL}; + qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_INPUT__DATA_BLOCK, false); + tdRSmaFetchAndSubmitResult(pItem, pRSmaInfo->pTSchema, pRSmaInfo->suid, pStat, STREAM_INPUT__DATA_BLOCK); + + tdUnRefSmaStat(pSma, (SSmaStat *)pStat); + } break; + case TASK_TRIGGER_STAT_PAUSED: { + smaDebug("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" 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", + 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); + } break; + default: { + smaWarn("vgId:%d, not fetch rsma level %" PRIi8 " data for table:%" PRIi64 " since stat is unknown", + SMA_VID(pSma), pItem->level, pRSmaInfo->suid); + } break; + } + +_end: + tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__); } diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c deleted file mode 100644 index b2c85642b9..0000000000 --- a/source/dnode/vnode/src/sma/smaSnapshot.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "sma.h" \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index ecd8db8ea9..6d71f3a250 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -20,6 +20,36 @@ #define SMA_STORAGE_MINUTES_DAY 1440 #define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file +// TODO: Who is responsible for resource allocate and release? +int32_t tdProcessTSmaInsert(SSma *pSma, int64_t indexUid, const char *msg) { + int32_t code = TSDB_CODE_SUCCESS; + + if ((code = tdProcessTSmaInsertImpl(pSma, indexUid, msg)) < 0) { + smaWarn("vgId:%d, insert tsma data failed since %s", SMA_VID(pSma), tstrerror(terrno)); + } + // TODO: destroy SSDataBlocks(msg) + return code; +} + +int32_t tdProcessTSmaCreate(SSma *pSma, int64_t version, const char *msg) { + int32_t code = TSDB_CODE_SUCCESS; + + if ((code = tdProcessTSmaCreateImpl(pSma, version, msg)) < 0) { + smaWarn("vgId:%d, create tsma failed since %s", SMA_VID(pSma), tstrerror(terrno)); + } + // TODO: destroy SSDataBlocks(msg) + return code; +} + +int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days) { + int32_t code = TSDB_CODE_SUCCESS; + if ((code = tdProcessTSmaGetDaysImpl(pCfg, pCont, contLen, days)) < 0) { + smaWarn("vgId:%d, get tsma days failed since %s", pCfg->vgId, tstrerror(terrno)); + } + smaDebug("vgId:%d, get tsma days %d", pCfg->vgId, *days); + return code; +} + /** * @brief Judge the tsma file split days * diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c index 2ce6d23648..22d82e8df0 100644 --- a/source/dnode/vnode/src/sma/smaUtil.c +++ b/source/dnode/vnode/src/sma/smaUtil.c @@ -294,4 +294,23 @@ int32_t tdRemoveTFile(STFile *pTFile) { } // smaXXXUtil ================ +void *tdAcquireSmaRef(int32_t rsetId, int64_t refId, const char *tags, int32_t ln) { + void *pResult = taosAcquireRef(rsetId, refId); + if (!pResult) { + smaWarn("%s:%d taosAcquireRef for rsetId:%" PRIi64 " refId:%d failed since %s", tags, ln, rsetId, refId, terrstr()); + } else { + smaDebug("%s:%d taosAcquireRef for rsetId:%" PRIi64 " refId:%d success", tags, ln, rsetId, refId); + } + return pResult; +} + +int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId, const char *tags, int32_t ln) { + if (taosReleaseRef(rsetId, refId) < 0) { + smaWarn("%s:%d taosReleaseRef for rsetId:%" PRIi64 " refId:%d failed since %s", tags, ln, rsetId, refId, terrstr()); + return TSDB_CODE_FAILED; + } + smaDebug("%s:%d taosReleaseRef for rsetId:%" PRIi64 " refId:%d success", tags, ln, rsetId, refId); + + return TSDB_CODE_SUCCESS; +} // ... \ No newline at end of file diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index e21b0fe9e8..0c72d35027 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -112,7 +112,7 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, }; tmsgSendRsp(&resp); - tqDebug("vg %d from consumer %ld (epoch %d) send rsp, res msg type %d, reqOffset: %ld, rspOffset: %ld", + tqDebug("vgId:%d from consumer:%" PRId64 ", (epoch %d) send rsp, res msg type %d, reqOffset:%" PRId64 ", rspOffset:%" PRId64, TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->resMsgType, pRsp->reqOffset, pRsp->rspOffset); return 0; @@ -162,7 +162,7 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con char buf2[80]; tFormatOffset(buf1, 80, &pRsp->reqOffset); tFormatOffset(buf2, 80, &pRsp->rspOffset); - tqDebug("vg %d from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %s, rspOffset: %s", + tqDebug("vgId:%d from consumer:%" PRId64 ", (epoch %d) send rsp, block num: %d, reqOffset:%s, rspOffset:%s", TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2); return 0; @@ -179,10 +179,10 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) { tDecoderClear(&decoder); if (offset.val.type == TMQ_OFFSET__SNAPSHOT_DATA) { - tqDebug("receive offset commit msg to %s on vg %d, offset(type:snapshot) uid: %ld, ts: %ld", offset.subKey, + tqDebug("receive offset commit msg to %s on vgId:%d, offset(type:snapshot) uid:%" PRId64 ", ts:%" PRId64, offset.subKey, TD_VID(pTq->pVnode), offset.val.uid, offset.val.ts); } else if (offset.val.type == TMQ_OFFSET__LOG) { - tqDebug("receive offset commit msg to %s on vg %d, offset(type:log) version: %ld", offset.subKey, + tqDebug("receive offset commit msg to %s on vgId:%d, offset(type:log) version:%" PRId64, offset.subKey, TD_VID(pTq->pVnode), offset.val.version); } else { ASSERT(0); @@ -244,22 +244,18 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { STqOffsetVal fetchOffsetNew; // 1.find handle - char buf[80]; - tFormatOffset(buf, 80, &reqOffset); - tqDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req offset %s", consumerId, pReq->epoch, - TD_VID(pTq->pVnode), buf); - STqHandle* pHandle = taosHashGet(pTq->handles, pReq->subKey, strlen(pReq->subKey)); /*ASSERT(pHandle);*/ if (pHandle == NULL) { - tqError("tmq poll: no consumer handle for consumer %ld in vg %d, subkey %s", consumerId, TD_VID(pTq->pVnode), - pReq->subKey); + tqError("tmq poll: no consumer handle for consumer:%" PRId64 ", in vgId:%d, subkey %s", consumerId, + TD_VID(pTq->pVnode), pReq->subKey); return -1; } // check rebalance if (pHandle->consumerId != consumerId) { - tqError("tmq poll: consumer handle mismatch for consumer %ld in vg %d, subkey %s, handle consumer id %ld", + tqError("tmq poll: consumer handle mismatch for consumer:%" PRId64 + ", in vgId:%d, subkey %s, handle consumer id %" PRId64, consumerId, TD_VID(pTq->pVnode), pReq->subKey, pHandle->consumerId); return -1; } @@ -270,6 +266,14 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { consumerEpoch = atomic_val_compare_exchange_32(&pHandle->epoch, consumerEpoch, reqEpoch); } + char buf[80]; + tFormatOffset(buf, 80, &reqOffset); + tqDebug("tmq poll: consumer %ld (epoch %d), subkey %s, recv poll req in vg %d, req offset %s", consumerId, + pReq->epoch, pHandle->subKey, TD_VID(pTq->pVnode), buf); + + SMqDataRsp dataRsp = {0}; + tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); + // 2.reset offset if needed if (reqOffset.type > 0) { fetchOffsetNew = reqOffset; @@ -279,7 +283,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { fetchOffsetNew = pOffset->val; char formatBuf[80]; tFormatOffset(formatBuf, 80, &fetchOffsetNew); - tqDebug("tmq poll: consumer %ld, offset reset to %s", consumerId, formatBuf); + tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, offset reset to %s", consumerId, pHandle->subKey, formatBuf); } else { if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEAST) { if (pReq->useSnapshot && pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { @@ -293,25 +297,48 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { tqOffsetResetToLog(&fetchOffsetNew, walGetFirstVer(pTq->pVnode->pWal)); } } else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) { - tqOffsetResetToLog(&fetchOffsetNew, walGetLastVer(pTq->pVnode->pWal)); + tqOffsetResetToLog(&dataRsp.rspOffset, walGetLastVer(pTq->pVnode->pWal)); + tqDebug("tmq poll: consumer %ld, subkey %s, offset reset to %ld", consumerId, pHandle->subKey, + dataRsp.rspOffset.version); + if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + code = -1; + } + goto OVER; } else if (reqOffset.type == TMQ_OFFSET__RESET_NONE) { - tqError("tmq poll: no offset committed for consumer %ld in vg %d, subkey %s, reset none failed", consumerId, - TD_VID(pTq->pVnode), pReq->subKey); + tqError("tmq poll: subkey %s, no offset committed for consumer %" PRId64 + " in vg %d, subkey %s, reset none failed", + pHandle->subKey, consumerId, TD_VID(pTq->pVnode), pReq->subKey); terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET; - return -1; + code = -1; + goto OVER; } } } // 3.query - SMqDataRsp dataRsp = {0}; - tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); + if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN && fetchOffsetNew.type == TMQ_OFFSET__LOG) { + fetchOffsetNew.version++; + if (tqScanLog(pTq, &pHandle->execHandle, &dataRsp, &fetchOffsetNew) < 0) { + ASSERT(0); + code = -1; + goto OVER; + } + if (dataRsp.blockNum == 0) { + // TODO add to async task pool + /*dataRsp.rspOffset.version--;*/ + } + if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + code = -1; + } + goto OVER; + } - if (fetchOffsetNew.type == TMQ_OFFSET__LOG) { + if (pHandle->execHandle.subType != TOPIC_SUB_TYPE__COLUMN && fetchOffsetNew.type == TMQ_OFFSET__LOG) { int64_t fetchVer = fetchOffsetNew.version + 1; SWalCkHead* pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048); if (pCkHead == NULL) { - return -1; + code = -1; + goto OVER; } walSetReaderCapacity(pHandle->pWalReader, 2048); @@ -319,8 +346,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { while (1) { consumerEpoch = atomic_load_32(&pHandle->epoch); if (consumerEpoch > reqEpoch) { - tqWarn("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d, discard req epoch %d", - consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchVer, consumerEpoch, reqEpoch); + tqWarn("tmq poll: consumer %ld (epoch %d), subkey %s, vg %d offset %" PRId64 + ", found new consumer epoch %d, discard req epoch %d", + consumerId, pReq->epoch, pHandle->subKey, TD_VID(pTq->pVnode), fetchVer, consumerEpoch, reqEpoch); break; } @@ -337,8 +365,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { SWalCont* pHead = &pCkHead->head; - tqDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch, - TD_VID(pTq->pVnode), fetchVer, pHead->msgType); + tqDebug("tmq poll: consumer:%" PRId64 ", (epoch %d) iter log, vgId:%d offset %" PRId64 " msgType %d", consumerId, + pReq->epoch, TD_VID(pTq->pVnode), fetchVer, pHead->msgType); if (pHead->msgType == TDMT_VND_SUBMIT) { SSubmitReq* pCont = (SSubmitReq*)&pHead->body; @@ -363,7 +391,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { } else { ASSERT(pHandle->fetchMeta); ASSERT(IS_META_MSG(pHead->msgType)); - tqInfo("fetch meta msg, ver: %ld, type: %d", pHead->version, pHead->msgType); + tqInfo("fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType); SMqMetaRsp metaRsp = {0}; /*metaRsp.reqOffset = pReq->reqOffset.version;*/ /*metaRsp.rspOffset = fetchVer;*/ @@ -384,7 +412,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { taosMemoryFree(pCkHead); } else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) { - tqInfo("retrieve using snapshot actual offset: uid %ld ts %ld", fetchOffsetNew.uid, fetchOffsetNew.ts); + tqInfo("retrieve using snapshot actual offset: uid %" PRId64 " ts %" PRId64, fetchOffsetNew.uid, fetchOffsetNew.ts); if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, fetchOffsetNew, workerId) < 0) { ASSERT(0); } @@ -482,10 +510,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) { pHandle->execHandle.execTb.suid = req.suid; SArray* tbUidList = taosArrayInit(0, sizeof(int64_t)); vnodeGetCtbIdList(pTq->pVnode, req.suid, tbUidList); - tqDebug("vg %d, tq try get suid: %ld", pTq->pVnode->config.vgId, req.suid); + tqDebug("vgId:%d, tq try get suid:%" PRId64, pTq->pVnode->config.vgId, req.suid); for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) { int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i); - tqDebug("vg %d, idx %d, uid: %ld", TD_VID(pTq->pVnode), i, tbUid); + tqDebug("vgId:%d, idx %d, uid:%" PRId64, TD_VID(pTq->pVnode), i, tbUid); } for (int32_t i = 0; i < 5; i++) { tqReaderSetTbUidList(pHandle->execHandle.pExecReader[i], tbUidList); @@ -572,7 +600,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) { streamSetupTrigger(pTask); - tqInfo("deploy stream task id %d child id %d on vg %d", pTask->taskId, pTask->selfChildId, TD_VID(pTq->pVnode)); + tqInfo("deploy stream task id %d child id %d on vgId:%d", pTask->taskId, pTask->selfChildId, TD_VID(pTq->pVnode)); taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void*)); diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqExec.c index 16822e6003..4ecd88b1fd 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqExec.c @@ -46,7 +46,7 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, int32_t workerI return 0; } -static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, int32_t workerId) { +static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) { SMetaReader mr = {0}; metaReaderInit(&mr, pTq->pVnode->pMeta, 0); if (metaGetTableEntryByUid(&mr, uid) < 0) { @@ -59,15 +59,58 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, i return 0; } +int64_t tqScanLog(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal* pOffset) { + qTaskInfo_t task = pExec->execCol.task[0]; + + if (qStreamPrepareScan(task, pOffset) < 0) { + pRsp->rspOffset = *pOffset; + pRsp->rspOffset.version--; + return 0; + } + + while (1) { + SSDataBlock* pDataBlock = NULL; + uint64_t ts = 0; + if (qExecTask(task, &pDataBlock, &ts) < 0) { + ASSERT(0); + } + + if (pDataBlock != NULL) { + tqAddBlockDataToRsp(pDataBlock, pRsp); + if (pRsp->withTbName) { + int64_t uid = pExec->pExecReader[0]->msgIter.uid; + tqAddTbNameToRsp(pTq, uid, pRsp); + } + pRsp->blockNum++; + continue; + } + + void* meta = qStreamExtractMetaMsg(task); + if (meta != NULL) { + // tq add meta to rsp + } + + if (qStreamExtractOffset(task, &pRsp->rspOffset) < 0) { + ASSERT(0); + } + + if (pRsp->rspOffset.type == TMQ_OFFSET__LOG) { + ASSERT(pRsp->rspOffset.version + 1 >= pRsp->reqOffset.version); + } + + ASSERT(pRsp->rspOffset.type != 0); + + break; + } + + return 0; +} + int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId) { ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN); qTaskInfo_t task = pExec->execCol.task[workerId]; - /*if (qStreamScanSnapshot(task) < 0) {*/ - /*ASSERT(0);*/ - /*}*/ - - if (qStreamPrepareScan(task, offset.uid, offset.ts) < 0) { + if (qStreamPrepareTsdbScan(task, offset.uid, offset.ts) < 0) { ASSERT(0); } @@ -93,7 +136,7 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, S if (qGetStreamScanStatus(task, &uid, &ts) < 0) { ASSERT(0); } - tqAddTbNameToRsp(pTq, uid, pRsp, workerId); + tqAddTbNameToRsp(pTq, uid, pRsp); #endif } pRsp->blockNum++; @@ -129,7 +172,7 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR tqAddBlockDataToRsp(pDataBlock, pRsp); if (pRsp->withTbName) { int64_t uid = pExec->pExecReader[workerId]->msgIter.uid; - tqAddTbNameToRsp(pTq, uid, pRsp, workerId); + tqAddTbNameToRsp(pTq, uid, pRsp); } pRsp->blockNum++; } @@ -146,7 +189,7 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR tqAddBlockDataToRsp(&block, pRsp); if (pRsp->withTbName) { int64_t uid = pExec->pExecReader[workerId]->msgIter.uid; - tqAddTbNameToRsp(pTq, uid, pRsp, workerId); + tqAddTbNameToRsp(pTq, uid, pRsp); } tqAddBlockSchemaToRsp(pExec, workerId, pRsp); pRsp->blockNum++; @@ -164,7 +207,7 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR tqAddBlockDataToRsp(&block, pRsp); if (pRsp->withTbName) { int64_t uid = pExec->pExecReader[workerId]->msgIter.uid; - tqAddTbNameToRsp(pTq, uid, pRsp, workerId); + tqAddTbNameToRsp(pTq, uid, pRsp); } tqAddBlockSchemaToRsp(pExec, workerId, pRsp); pRsp->blockNum++; diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index 8561314431..ec9674d637 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -139,7 +139,7 @@ int32_t tqOffsetSnapshot(STqOffsetStore* pStore) { int64_t writeLen; if ((writeLen = taosWriteFile(pFile, buf, totLen)) != totLen) { ASSERT(0); - tqError("write offset incomplete, len %d, write len %ld", bodyLen, writeLen); + tqError("write offset incomplete, len %d, write len %" PRId64, bodyLen, writeLen); taosHashCancelIterate(pStore->pHash, pIter); return -1; } diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index bd7cda4de3..e9e5f6cd8b 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -223,7 +223,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_ memset(&pHandle->pushHandle.rpcInfo, 0, sizeof(SRpcHandleInfo)); taosWUnLockLatch(&pHandle->pushHandle.lock); - tqDebug("vg %d offset %ld from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %ld, rspOffset: %ld", + tqDebug("vgId:%d offset %" PRId64 " from consumer:%" PRId64 ", (epoch %d) send rsp, block num: %d, reqOffset:%" PRId64 ", rspOffset:%" PRId64, TD_VID(pTq->pVnode), fetchOffset, pHandle->pushHandle.consumerId, pHandle->pushHandle.epoch, rsp.blockNum, rsp.reqOffset, rsp.rspOffset); diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 53ef17a6ba..8753ecc47c 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -15,11 +15,6 @@ #include "tq.h" -int64_t tqScanLog(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset) { - /*if ()*/ - return 0; -} - int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** ppCkHead) { int32_t code = 0; taosThreadMutexLock(&pHandle->pWalReader->mutex); @@ -27,8 +22,8 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea while (1) { if (walFetchHead(pHandle->pWalReader, offset, *ppCkHead) < 0) { - tqDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", pHandle->consumerId, - pHandle->epoch, TD_VID(pTq->pVnode), offset); + tqDebug("tmq poll: consumer:%" PRId64 ", (epoch %d) vgId:%d offset %" PRId64 ", no more log to return", + pHandle->consumerId, pHandle->epoch, TD_VID(pTq->pVnode), offset); *fetchOffset = offset - 1; code = -1; goto END; @@ -84,8 +79,10 @@ STqReader* tqOpenReader(SVnode* pVnode) { return NULL; } - // TODO open - /*pReader->pWalReader = walOpenReader(pVnode->pWal, NULL);*/ + pReader->pWalReader = walOpenReader(pVnode->pWal, NULL); + if (pReader->pWalReader == NULL) { + return NULL; + } pReader->pVnodeMeta = pVnode->pMeta; pReader->pMsg = NULL; @@ -106,13 +103,27 @@ void tqCloseReader(STqReader* pReader) { taosMemoryFree(pReader); } +int32_t tqSeekVer(STqReader* pReader, int64_t ver) { + if (walReadSeekVer(pReader->pWalReader, ver) < 0) { + ASSERT(pReader->pWalReader->curInvalid); + ASSERT(pReader->pWalReader->curVersion == ver); + return -1; + } + ASSERT(pReader->pWalReader->curVersion == ver); + return 0; +} + int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) { bool fromProcessedMsg = pReader->pMsg != NULL; while (1) { if (!fromProcessedMsg) { if (walNextValidMsg(pReader->pWalReader) < 0) { + pReader->ver = pReader->pWalReader->curVersion - pReader->pWalReader->curInvalid; + ret->offset.type = TMQ_OFFSET__LOG; + ret->offset.version = pReader->ver; ret->fetchType = FETCH_TYPE__NONE; + ASSERT(ret->offset.version >= 0); return -1; } void* body = pReader->pWalReader->pHead->head.body; @@ -127,22 +138,21 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) { } while (tqNextDataBlock(pReader)) { + // TODO mem free memset(&ret->data, 0, sizeof(SSDataBlock)); int32_t code = tqRetrieveDataBlock(&ret->data, pReader); if (code != 0 || ret->data.info.rows == 0) { - if (fromProcessedMsg) { - ret->fetchType = FETCH_TYPE__NONE; - return 0; - } else { - break; - } + ASSERT(0); + continue; } - ret->fetchType = FETCH_TYPE__DATA; return 0; } if (fromProcessedMsg) { + ret->offset.type = TMQ_OFFSET__LOG; + ret->offset.version = pReader->ver; + ASSERT(pReader->ver >= 0); ret->fetchType = FETCH_TYPE__NONE; return 0; } @@ -179,9 +189,9 @@ bool tqNextDataBlock(STqReader* pReader) { return true; } void* ret = taosHashGet(pReader->tbIdHash, &pReader->msgIter.uid, sizeof(int64_t)); - /*tqDebug("search uid %ld", pHandle->msgIter.uid);*/ + /*tqDebug("search uid %" PRId64, pHandle->msgIter.uid);*/ if (ret != NULL) { - /*tqDebug("find uid %ld", pHandle->msgIter.uid);*/ + /*tqDebug("find uid %" PRId64, pHandle->msgIter.uid);*/ return true; } } @@ -212,7 +222,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) { if (pReader->pSchema) taosMemoryFree(pReader->pSchema); pReader->pSchema = metaGetTbTSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion); if (pReader->pSchema == NULL) { - tqWarn("cannot found tsschema for table: uid: %ld (suid: %ld), version %d, possibly dropped table", + tqWarn("cannot found tsschema for table: uid:%" PRId64 " (suid:%" PRId64 "), version %d, possibly dropped table", pReader->msgIter.uid, pReader->msgIter.suid, pReader->cachedSchemaVer); /*ASSERT(0);*/ terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND; @@ -222,7 +232,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) { if (pReader->pSchemaWrapper) tDeleteSSchemaWrapper(pReader->pSchemaWrapper); pReader->pSchemaWrapper = metaGetTableSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion, true); if (pReader->pSchemaWrapper == NULL) { - tqWarn("cannot found schema wrapper for table: suid: %ld, version %d, possibly dropped table", + tqWarn("cannot found schema wrapper for table: suid:%" PRId64 ", version %d, possibly dropped table", pReader->msgIter.uid, pReader->cachedSchemaVer); /*ASSERT(0);*/ terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND; diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 2086d94099..0c5f851d97 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -59,6 +59,8 @@ static void getTableCacheKey(tb_uid_t uid, int cacheType, char *key, int *len) { static void deleteTableCacheLastrow(const void *key, size_t keyLen, void *value) { taosMemoryFree(value); } +static void deleteTableCacheLast(const void *key, size_t keyLen, void *value) { taosArrayDestroy(value); } + static int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) { int32_t code = 0; char key[32] = {0}; @@ -153,7 +155,7 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST /* tsdbCacheInsertLastrow(pCache, uid, row, dup); */ } } - } else { + } /*else { if (dup) { cacheRow = tdRowDup(row); } else { @@ -166,7 +168,7 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST if (status != TAOS_LRU_STATUS_OK) { code = -1; } - } + }*/ return code; } @@ -761,7 +763,6 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo for (int i = 0; i < nMax; ++i) { TSDBKEY maxKey = TSDBROW_KEY(max[i]); - // bool deleted = false; bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline); if (!deleted) { // iMerge[nMerge] = i; @@ -818,12 +819,22 @@ _err: return code; } -static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { - int32_t code = 0; +typedef struct { + TSKEY ts; + SColVal colVal; +} SLastCol; + +// static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { +static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) { + int32_t code = 0; + SArray *pSkyline = NULL; + STSRow *pRow = NULL; + STSRow **ppRow = &pRow; STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1); int16_t nCol = pTSchema->numOfCols; - SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal)); + // SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal)); + SArray *pColArray = taosArrayInit(nCol, sizeof(SLastCol)); tb_uid_t suid = getTableSuidByUid(uid, pTsdb); @@ -837,9 +848,9 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { tsdbGetTbDataFromMemTable(pTsdb->imem, suid, uid, &pIMem); } - *ppRow = NULL; + *ppLastArray = NULL; - SArray *pSkyline = taosArrayInit(32, sizeof(TSDBKEY)); + pSkyline = taosArrayInit(32, sizeof(TSDBKEY)); SDelIdx delIdx; @@ -943,7 +954,6 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { for (int i = 0; i < nMax; ++i) { TSDBKEY maxKey = TSDBROW_KEY(max[i]); - // bool deleted = false; bool deleted = tsdbKeyDeleted(&maxKey, pSkyline, &iSkyline); if (!deleted) { iMerge[nMerge] = iMax[i]; @@ -970,8 +980,9 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { tRowMergerClear(&merger); } } else { - *ppRow = NULL; - return code; + /* *ppRow = NULL; */ + /* return code; */ + continue; } if (iCol == 0) { @@ -980,7 +991,8 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, (SValue){.ts = maxKey}); - if (taosArrayPush(pColArray, pColVal) == NULL) { + // if (taosArrayPush(pColArray, pColVal) == NULL) { + if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -991,7 +1003,8 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { for (int16_t i = iCol; i < nCol; ++i) { // tsdbRowGetColVal(*ppRow, pTSchema, i, pColVal); tTSRowGetVal(*ppRow, pTSchema, i, pColVal); - if (taosArrayPush(pColArray, pColVal) == NULL) { + // if (taosArrayPush(pColArray, pColVal) == NULL) { + if (taosArrayPush(pColArray, &(SLastCol){.ts = maxKey, .colVal = *pColVal}) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -1012,11 +1025,11 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { --nilColCount; } } - /* + if (*ppRow) { taosMemoryFreeClear(*ppRow); } - */ + continue; } @@ -1024,12 +1037,16 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { for (int16_t i = iCol; i < nCol; ++i) { SColVal colVal = {0}; tTSRowGetVal(*ppRow, pTSchema, i, &colVal); + TSKEY rowTs = (*ppRow)->ts; - SColVal *tColVal = (SColVal *)taosArrayGet(pColArray, i); + // SColVal *tColVal = (SColVal *)taosArrayGet(pColArray, i); + SLastCol *tTsVal = (SLastCol *)taosArrayGet(pColArray, i); + SColVal *tColVal = &tTsVal->colVal; if (!colVal.isNone && !colVal.isNull) { if (tColVal->isNull || tColVal->isNone) { - taosArraySet(pColArray, i, &colVal); + // taosArraySet(pColArray, i, &colVal); + taosArraySet(pColArray, i, &(SLastCol){.ts = rowTs, .colVal = colVal}); --nilColCount; } } else { @@ -1054,16 +1071,45 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { } while (nilColCount > 0); // if () new ts row from pColArray if non empty - if (taosArrayGetSize(pColArray) == nCol) { - code = tdSTSRowNew(pColArray, pTSchema, ppRow); - if (code) goto _err; + /* if (taosArrayGetSize(pColArray) == nCol) { */ + /* code = tdSTSRowNew(pColArray, pTSchema, ppRow); */ + /* if (code) goto _err; */ + /* } */ + /* taosArrayDestroy(pColArray); */ + if (taosArrayGetSize(pColArray) <= 0) { + *ppLastArray = NULL; + taosArrayDestroy(pColArray); + } else { + *ppLastArray = pColArray; + } + if (*ppRow) { + taosMemoryFreeClear(*ppRow); + } + + for (int i = 0; i < 3; ++i) { + if (input[i].nextRowClearFn) { + input[i].nextRowClearFn(input[i].iter); + } + } + if (pSkyline) { + taosArrayDestroy(pSkyline); } - taosArrayDestroy(pColArray); taosMemoryFreeClear(pTSchema); return code; _err: taosArrayDestroy(pColArray); + if (*ppRow) { + taosMemoryFreeClear(*ppRow); + } + for (int i = 0; i < 3; ++i) { + if (input[i].nextRowClearFn) { + input[i].nextRowClearFn(input[i].iter); + } + } + if (pSkyline) { + taosArrayDestroy(pSkyline); + } taosMemoryFreeClear(pTSchema); tsdbError("vgId:%d merge last_row failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); return code; @@ -1081,7 +1127,7 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH //*ppRow = (STSRow *)taosLRUCacheValue(pCache, h); } else { STSRow *pRow = NULL; - bool dup = false; + bool dup = false; // which is always false for now code = mergeLastRow(uid, pTsdb, &dup, &pRow); // if table's empty or error, return code of -1 if (code < 0 || pRow == NULL) { @@ -1093,7 +1139,14 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH return 0; } - tsdbCacheInsertLastrow(pCache, pTsdb, uid, pRow, dup); + _taos_lru_deleter_t deleter = deleteTableCacheLastrow; + LRUStatus status = + taosLRUCacheInsert(pCache, key, keyLen, pRow, TD_ROW_LEN(pRow), deleter, NULL, TAOS_LRU_PRIORITY_LOW); + if (status != TAOS_LRU_STATUS_OK) { + code = -1; + } + + // tsdbCacheInsertLastrow(pCache, pTsdb, uid, pRow, dup); h = taosLRUCacheLookup(pCache, key, keyLen); //*ppRow = (STSRow *)taosLRUCacheValue(pCache, h); } @@ -1103,6 +1156,30 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH return code; } +int32_t tsdbCacheLastArray2Row(SArray *pLastArray, STSRow **ppRow, STSchema *pTSchema) { + int32_t code = 0; + int16_t nCol = taosArrayGetSize(pLastArray); + SArray *pColArray = taosArrayInit(nCol, sizeof(SColVal)); + + for (int16_t iCol = 0; iCol < nCol; ++iCol) { + SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLastArray, iCol); + SColVal *tColVal = &tTsVal->colVal; + taosArrayPush(pColArray, tColVal); + } + + code = tdSTSRowNew(pColArray, pTSchema, ppRow); + if (code) goto _err; + + taosArrayDestroy(pColArray); + + return code; + +_err: + taosArrayDestroy(pColArray); + + return code; +} + int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHandle **handle) { int32_t code = 0; char key[32] = {0}; @@ -1115,21 +1192,24 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand //*ppRow = (STSRow *)taosLRUCacheValue(pCache, h); } else { - STSRow *pRow = NULL; - code = mergeLast(uid, pTsdb, &pRow); + // STSRow *pRow = NULL; + // code = mergeLast(uid, pTsdb, &pRow); + SArray *pLastArray = NULL; + code = mergeLast(uid, pTsdb, &pLastArray); // if table's empty or error, return code of -1 - if (code < 0 || pRow == NULL) { + // if (code < 0 || pRow == NULL) { + if (code < 0 || pLastArray == NULL) { *handle = NULL; return 0; } - _taos_lru_deleter_t deleter = deleteTableCacheLastrow; + _taos_lru_deleter_t deleter = deleteTableCacheLast; LRUStatus status = - taosLRUCacheInsert(pCache, key, keyLen, pRow, TD_ROW_LEN(pRow), deleter, NULL, TAOS_LRU_PRIORITY_LOW); + taosLRUCacheInsert(pCache, key, keyLen, pLastArray, pLastArray->capacity, deleter, NULL, TAOS_LRU_PRIORITY_LOW); if (status != TAOS_LRU_STATUS_OK) { code = -1; } - /* tsdbCacheInsertLast(pCache, uid, pRow); */ + h = taosLRUCacheLookup(pCache, key, keyLen); //*ppRow = (STSRow *)taosLRUCacheValue(pCache, h); } @@ -1162,9 +1242,23 @@ int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey) { getTableCacheKey(uid, 1, key, &keyLen); h = taosLRUCacheLookup(pCache, key, keyLen); if (h) { - // clear last cache anyway, no matter where eKey ends. - taosLRUCacheRelease(pCache, h, true); + SArray *pLast = (SArray *)taosLRUCacheValue(pCache, h); + bool invalidate = false; + int16_t nCol = taosArrayGetSize(pLast); + for (int16_t iCol = 0; iCol < nCol; ++iCol) { + SLastCol *tTsVal = (SLastCol *)taosArrayGet(pLast, iCol); + if (eKey >= tTsVal->ts) { + invalidate = true; + break; + } + } + + if (invalidate) { + taosLRUCacheRelease(pCache, h, true); + } else { + taosLRUCacheRelease(pCache, h, false); + } // void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen); } diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index 30bc603b30..150ed620bf 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -128,6 +128,8 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t } pRow = (STSRow*)taosLRUCacheValue(lruCache, h); + // SArray* pLast = (SArray*)taosLRUCacheValue(lruCache, h); + // tsdbCacheLastArray2Row(pLast, &pRow, pr->pSchema); if (pRow->ts > lastKey) { // Set result row into the same rowIndex repeatly, so we need to check if the internal result row has already // appended or not. @@ -140,6 +142,7 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t lastKey = pRow->ts; } + // taosMemoryFree(pRow); tsdbCacheRelease(lruCache, h); } } else if (pr->type == LASTROW_RETRIEVE_TYPE_ALL) { @@ -158,8 +161,12 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t } pRow = (STSRow*)taosLRUCacheValue(lruCache, h); + // SArray* pLast = (SArray*)taosLRUCacheValue(lruCache, h); + // tsdbCacheLastArray2Row(pLast, &pRow, pr->pSchema); + saveOneRow(pRow, pResBlock, pr, slotIds); + // taosMemoryFree(pRow); tsdbCacheRelease(lruCache, h); pr->tableIndex += 1; diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index b60a4697fa..8a189d98b3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -602,7 +602,7 @@ static int32_t tsdbGetOvlpNRow(STbDataIter *pIter, SBlock *pBlock) { iter.pRow = NULL; while (true) { - pRow = tsdbTbDataIterGet(pIter); + pRow = tsdbTbDataIterGet(&iter); if (pRow == NULL) break; key = TSDBROW_KEY(pRow); @@ -610,7 +610,7 @@ static int32_t tsdbGetOvlpNRow(STbDataIter *pIter, SBlock *pBlock) { c = tBlockCmprFn(&(SBlock){.maxKey = key, .minKey = key}, pBlock); if (c == 0) { nRow++; - tsdbTbDataIterNext(pIter); + tsdbTbDataIterNext(&iter); } else if (c > 0) { break; } else { @@ -635,7 +635,7 @@ static int32_t tsdbMergeAsSubBlock(SCommitter *pCommitter, STbDataIter *pIter, S code = tsdbCommitterUpdateRowSchema(pCommitter, pBlockIdx->suid, pBlockIdx->uid, TSDBROW_SVERSION(pRow)); if (code) goto _err; while (true) { - if (pRow) break; + if (pRow == NULL) break; code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema); if (code) goto _err; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index e53a1b43af..9e01468fc7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -48,14 +48,15 @@ typedef struct SBlockOrderSupporter { typedef struct SIOCostSummary { int64_t blockLoadTime; - int64_t statisInfoLoadTime; + int64_t smaLoadTime; int64_t checkForNextTime; int64_t headFileLoad; int64_t headFileLoadTime; } SIOCostSummary; typedef struct SBlockLoadSuppInfo { - SColumnDataAgg* pstatis; + SArray* pColAgg; + SColumnDataAgg tsColAgg; SColumnDataAgg** plist; int16_t* colIds; // column ids for loading file block data int32_t* slotIds; // colId to slotId @@ -63,10 +64,10 @@ typedef struct SBlockLoadSuppInfo { } SBlockLoadSuppInfo; typedef struct SFilesetIter { - int32_t numOfFiles; // number of total files - int32_t index; // current accessed index in the list - SArray* pFileList; // data file list - int32_t order; + int32_t numOfFiles; // number of total files + int32_t index; // current accessed index in the list + SArray* pFileList; // data file list + int32_t order; } SFilesetIter; typedef struct SFileDataBlockInfo { @@ -119,24 +120,10 @@ struct STsdbReader { int32_t type; // query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows SBlockLoadSuppInfo suppInfo; - SIOCostSummary cost; - STSchema* pSchema; - SDataFReader* pFileReader; - SVersionRange verRange; -#if 0 - SArray* prev; // previous row which is before than time window - SArray* next; // next row which is after the query time window - SFileBlockInfo* pDataBlockInfo; - SDataCols* pDataCols; // in order to hold current file data block - int32_t allocSize; // allocated data block size - SDataBlockLoadInfo dataBlockLoadInfo; /* record current block load information */ - SLoadCompBlockInfo compBlockLoadInfo; /* record current compblock information in SQueryAttr */ - // SDFileSet* pFileGroup; - // SFSIter fileIter; - // SReadH rhelper; - // SColumnDataAgg* statis; // query level statistics, only one table block statistics info exists at any time - // SColumnDataAgg** pstatis;// the ptr array list to return to caller -#endif + SIOCostSummary cost; + STSchema* pSchema; + SDataFReader* pFileReader; + SVersionRange verRange; }; static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter); @@ -150,7 +137,7 @@ static int32_t doMergeRowsInBuf(SIterInfo* pIter, int64_t ts, SArray* pDelList, static int32_t doAppendOneRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow); static void setComposedBlockFlag(STsdbReader* pReader, bool composed); static void updateSchema(TSDBROW* pRow, uint64_t uid, STsdbReader* pReader); -static bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey); +static bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order); static void doMergeMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDelList, STSRow** pTSRow, STsdbReader* pReader); @@ -252,33 +239,6 @@ static STimeWindow updateQueryTimeWindow(STsdb* pTsdb, STimeWindow* pWindow) { return win; } -// todo remove this -static void setQueryTimewindow(STsdbReader* pReader, SQueryTableDataCond* pCond, int32_t tWinIdx) { - // pReader->window = pCond->twindows[tWinIdx]; - - // bool updateTs = false; - // int64_t startTs = updateQueryTimeWindow(pReader->pTsdb); - // if (ASCENDING_TRAVERSE(pReader->order)) { - // if (startTs > pReader->window.skey) { - // pReader->window.skey = startTs; - // pCond->twindows[tWinIdx].skey = startTs; - // updateTs = true; - // } - // } else { - // if (startTs > pReader->window.ekey) { - // pReader->window.ekey = startTs; - // pCond->twindows[tWinIdx].ekey = startTs; - // updateTs = true; - // } - // } - - // if (updateTs) { - // tsdbDebug("%p update the query time window, old:%" PRId64 " - %" PRId64 ", new:%" PRId64 " - %" PRId64 ", %s", - // pReader, pCond->twindows[tWinIdx].skey, pCond->twindows[tWinIdx].ekey, pReader->window.skey, - // pReader->window.ekey, pReader->idStr); - // } -} - static void limitOutputBufferSize(const SQueryTableDataCond* pCond, int32_t* capacity) { int32_t rowLen = 0; for (int32_t i = 0; i < pCond->numOfCols; ++i) { @@ -405,21 +365,21 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd pReader->type = pCond->type; pReader->window = updateQueryTimeWindow(pVnode->pTsdb, pCond->twindows); - // todo remove this - setQueryTimewindow(pReader, pCond, 0); ASSERT(pCond->numOfCols > 0); limitOutputBufferSize(pCond, &pReader->capacity); // allocate buffer in order to load data blocks from file SBlockLoadSuppInfo* pSup = &pReader->suppInfo; - pSup->pstatis = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnDataAgg)); + pSup->pColAgg = taosArrayInit(4, sizeof(SColumnDataAgg)); pSup->plist = taosMemoryCalloc(pCond->numOfCols, POINTER_BYTES); - if (pSup->pstatis == NULL || pSup->plist == NULL) { + if (pSup->pColAgg == NULL || pSup->plist == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _end; } + pSup->tsColAgg.colId = PRIMARYKEY_TIMESTAMP_COL_ID; + pReader->pResBlock = createResBlock(pCond, pReader->capacity); if (pReader->pResBlock == NULL) { code = terrno; @@ -920,200 +880,6 @@ _error: // return midPos; // } -// static int32_t mergeTwoRowFromMem(STsdbReader* pTsdbReadHandle, int32_t capacity, int32_t* curRow, STSRow* row1, -// STSRow* row2, int32_t numOfCols, uint64_t uid, STSchema* pSchema1, STSchema* -// pSchema2, bool update, TSKEY* lastRowKey) { -// #if 1 -// STSchema* pSchema; -// STSRow* row; -// int16_t colId; -// int16_t offset; - -// bool isRow1DataRow = TD_IS_TP_ROW(row1); -// bool isRow2DataRow; -// bool isChosenRowDataRow; -// int32_t chosen_itr; -// SCellVal sVal = {0}; -// TSKEY rowKey = TSKEY_INITIAL_VAL; -// int32_t nResult = 0; -// int32_t mergeOption = 0; // 0 discard 1 overwrite 2 merge - -// // the schema version info is embeded in STSRow -// int32_t numOfColsOfRow1 = 0; - -// if (pSchema1 == NULL) { -// pSchema1 = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), uid, TD_ROW_SVER(row1)); -// } - -// #ifdef TD_DEBUG_PRINT_ROW -// char flags[70] = {0}; -// STsdb* pTsdb = pTsdbReadHandle->rhelper.pRepo; -// snprintf(flags, 70, "%s:%d vgId:%d dir:%s row1%s=NULL,row2%s=NULL", __func__, __LINE__, TD_VID(pTsdb->pVnode), -// pTsdb->dir, row1 ? "!" : "", row2 ? "!" : ""); -// tdSRowPrint(row1, pSchema1, flags); -// #endif - -// if (isRow1DataRow) { -// numOfColsOfRow1 = schemaNCols(pSchema1); -// } else { -// numOfColsOfRow1 = tdRowGetNCols(row1); -// } - -// int32_t numOfColsOfRow2 = 0; -// if (row2) { -// isRow2DataRow = TD_IS_TP_ROW(row2); -// if (pSchema2 == NULL) { -// pSchema2 = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), uid, TD_ROW_SVER(row2)); -// } -// if (isRow2DataRow) { -// numOfColsOfRow2 = schemaNCols(pSchema2); -// } else { -// numOfColsOfRow2 = tdRowGetNCols(row2); -// } -// } - -// int32_t i = 0, j = 0, k = 0; -// while (i < numOfCols && (j < numOfColsOfRow1 || k < numOfColsOfRow2)) { -// SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, i); - -// int32_t colIdOfRow1; -// if (j >= numOfColsOfRow1) { -// colIdOfRow1 = INT32_MAX; -// } else if (isRow1DataRow) { -// colIdOfRow1 = pSchema1->columns[j].colId; -// } else { -// colIdOfRow1 = tdKvRowColIdAt(row1, j); -// } - -// int32_t colIdOfRow2; -// if (k >= numOfColsOfRow2) { -// colIdOfRow2 = INT32_MAX; -// } else if (isRow2DataRow) { -// colIdOfRow2 = pSchema2->columns[k].colId; -// } else { -// colIdOfRow2 = tdKvRowColIdAt(row2, k); -// } - -// if (colIdOfRow1 < colIdOfRow2) { // the most probability -// if (colIdOfRow1 < pColInfo->info.colId) { -// ++j; -// continue; -// } -// row = row1; -// pSchema = pSchema1; -// isChosenRowDataRow = isRow1DataRow; -// chosen_itr = j; -// } else if (colIdOfRow1 == colIdOfRow2) { -// if (colIdOfRow1 < pColInfo->info.colId) { -// ++j; -// ++k; -// continue; -// } -// row = row1; -// pSchema = pSchema1; -// isChosenRowDataRow = isRow1DataRow; -// chosen_itr = j; -// } else { -// if (colIdOfRow2 < pColInfo->info.colId) { -// ++k; -// continue; -// } -// row = row2; -// pSchema = pSchema2; -// chosen_itr = k; -// isChosenRowDataRow = isRow2DataRow; -// } - -// if (isChosenRowDataRow) { -// colId = pSchema->columns[chosen_itr].colId; -// offset = pSchema->columns[chosen_itr].offset; -// // TODO: use STSRowIter -// tdSTpRowGetVal(row, colId, pSchema->columns[chosen_itr].type, pSchema->flen, offset, chosen_itr - 1, &sVal); -// if (colId == PRIMARYKEY_TIMESTAMP_COL_ID) { -// rowKey = *(TSKEY*)sVal.val; -// if (rowKey != *lastRowKey) { -// mergeOption = 1; -// if (*lastRowKey != TSKEY_INITIAL_VAL) { -// ++(*curRow); -// } -// *lastRowKey = rowKey; -// ++nResult; -// } else if (update) { -// mergeOption = 2; -// } else { -// mergeOption = 0; -// break; -// } -// } -// } else { -// // TODO: use STSRowIter -// if (chosen_itr == 0) { -// colId = PRIMARYKEY_TIMESTAMP_COL_ID; -// tdSKvRowGetVal(row, PRIMARYKEY_TIMESTAMP_COL_ID, -1, -1, &sVal); -// rowKey = *(TSKEY*)sVal.val; -// if (rowKey != *lastRowKey) { -// mergeOption = 1; -// if (*lastRowKey != TSKEY_INITIAL_VAL) { -// ++(*curRow); -// } -// *lastRowKey = rowKey; -// ++nResult; -// } else if (update) { -// mergeOption = 2; -// } else { -// mergeOption = 0; -// break; -// } -// } else { -// SKvRowIdx* pColIdx = tdKvRowColIdxAt(row, chosen_itr - 1); -// colId = pColIdx->colId; -// offset = pColIdx->offset; -// tdSKvRowGetVal(row, colId, offset, chosen_itr - 1, &sVal); -// } -// } - -// ASSERT(rowKey != TSKEY_INITIAL_VAL); - -// if (colId == pColInfo->info.colId) { -// if (tdValTypeIsNorm(sVal.valType)) { -// colDataAppend(pColInfo, *curRow, sVal.val, false); -// } else if (tdValTypeIsNull(sVal.valType)) { -// colDataAppend(pColInfo, *curRow, NULL, true); -// } else if (tdValTypeIsNone(sVal.valType)) { -// // TODO: Set null if nothing append for this row -// if (mergeOption == 1) { -// colDataAppend(pColInfo, *curRow, NULL, true); -// } -// } else { -// ASSERT(0); -// } - -// ++i; - -// if (row == row1) { -// ++j; -// } else { -// ++k; -// } -// } else { -// if (mergeOption == 1) { -// colDataAppend(pColInfo, *curRow, NULL, true); -// } -// ++i; -// } -// } - -// if (mergeOption == 1) { -// while (i < numOfCols) { // the remain columns are all null data -// SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, i); -// colDataAppend(pColInfo, *curRow, NULL, true); -// ++i; -// } -// } - -// return nResult; -// #endif -// } // static void doCheckGeneratedBlockRange(STsdbReader* pTsdbReadHandle) { // SQueryFilePos* cur = &pTsdbReadHandle->cur; @@ -1393,66 +1159,6 @@ _error: // pTsdbReadHandle->idStr); // } -// int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order) { -// int firstPos, lastPos, midPos = -1; -// int numOfRows; -// TSKEY* keyList; - -// if (num <= 0) return -1; - -// keyList = (TSKEY*)pValue; -// firstPos = 0; -// lastPos = num - 1; - -// if (order == TSDB_ORDER_DESC) { -// // find the first position which is smaller than the key -// while (1) { -// if (key >= keyList[lastPos]) return lastPos; -// if (key == keyList[firstPos]) return firstPos; -// if (key < keyList[firstPos]) return firstPos - 1; - -// numOfRows = lastPos - firstPos + 1; -// midPos = (numOfRows >> 1) + firstPos; - -// if (key < keyList[midPos]) { -// lastPos = midPos - 1; -// } else if (key > keyList[midPos]) { -// firstPos = midPos + 1; -// } else { -// break; -// } -// } - -// } else { -// // find the first position which is bigger than the key -// while (1) { -// if (key <= keyList[firstPos]) return firstPos; -// if (key == keyList[lastPos]) return lastPos; - -// if (key > keyList[lastPos]) { -// lastPos = lastPos + 1; -// if (lastPos >= num) -// return -1; -// else -// return lastPos; -// } - -// numOfRows = lastPos - firstPos + 1; -// midPos = (numOfRows >> 1) + firstPos; - -// if (key < keyList[midPos]) { -// lastPos = midPos - 1; -// } else if (key > keyList[midPos]) { -// firstPos = midPos + 1; -// } else { -// break; -// } -// } -// } - -// return midPos; -// } - static void cleanupBlockOrderSupporter(SBlockOrderSupporter* pSup) { taosMemoryFreeClear(pSup->numOfBlocksPerTable); taosMemoryFreeClear(pSup->indexPerTable); @@ -1710,29 +1416,60 @@ static bool keyOverlapFileBlock(TSDBKEY key, SBlock* pBlock, SVersionRange* pVer (pBlock->minVersion <= pVerRange->maxVer); } +static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock, int32_t order) { + if (pBlockScanInfo->delSkyline == NULL) { + return false; + } + + TSDBKEY* pFirst = taosArrayGet(pBlockScanInfo->delSkyline, 0); + TSDBKEY* pLast = taosArrayGetLast(pBlockScanInfo->delSkyline); + + // ts is not overlap + if (pBlock->minKey.ts > pLast->ts || pBlock->maxKey.ts < pFirst->ts) { + return false; + } + + int32_t step = ASCENDING_TRAVERSE(order)? 1:-1; + + // version is not overlap + size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline); + for(int32_t i = pBlockScanInfo->fileDelIndex; i < num; i += step) { + TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i); + if (p->ts >= pBlock->minKey.ts && p->ts <= pBlock->maxKey.ts) { + if (p->version >= pBlock->minVersion) { + return true; + } + } else if (p->ts > pBlock->maxKey.ts) { + return false; + } + } + + ASSERT(0); + return false; +} + // 1. the version of all rows should be less than the endVersion // 2. current block should not overlap with next neighbor block // 3. current timestamp should not be overlap with each other // 4. output buffer should be large enough to hold all rows in current block +// 5. delete info should not overlap with current block data static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pFBlock, SBlock* pBlock, STableBlockScanInfo* pScanInfo, TSDBKEY key) { int32_t neighborIndex = 0; SBlock* pNeighbor = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &neighborIndex, pReader->order); + // overlap with neighbor bool overlapWithNeighbor = false; if (pNeighbor) { overlapWithNeighbor = overlapWithNeighborBlock(pBlock, pNeighbor, pReader->order); } - bool hasDup = false; - if (pBlock->nSubBlock == 1) { - hasDup = pBlock->hasDup; - } else { - hasDup = true; - } + // has duplicated ts of different version in this block + bool hasDup = (pBlock->nSubBlock == 1)? pBlock->hasDup:true; + bool overlapWithDel= overlapWithDelSkyline(pScanInfo, pBlock, pReader->order); return (overlapWithNeighbor || hasDup || dataBlockPartiallyRequired(&pReader->window, &pReader->verRange, pBlock) || - keyOverlapFileBlock(key, pBlock, &pReader->verRange) || (pBlock->nRow > pReader->capacity)); + keyOverlapFileBlock(key, pBlock, &pReader->verRange) || (pBlock->nRow > pReader->capacity) || overlapWithDel); } static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo, int64_t endKey) { @@ -1940,6 +1677,7 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* } ASSERT(0); + return -1; } static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDumpInfo, @@ -1956,7 +1694,7 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum } TSDBKEY k = {.ts = ts, .version = ver}; - if (hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->fileDelIndex, &k)) { + if (hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->fileDelIndex, &k, pReader->order)) { return false; } @@ -2444,12 +2182,21 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret return VND_TSDB(pVnode); } -static SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_t level) { +SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_t level) { + int64_t startVer = (pCond->startVersion == -1)? 0:pCond->startVersion; + if (VND_IS_RSMA(pVnode)) { - return (SVersionRange){.minVer = pCond->startVersion, .maxVer = tdRSmaGetMaxSubmitVer(pVnode->pSma, level)}; + return (SVersionRange){.minVer = startVer, .maxVer = tdRSmaGetMaxSubmitVer(pVnode->pSma, level)}; } - return (SVersionRange){.minVer = pCond->startVersion, .maxVer = pVnode->state.applied}; + int64_t endVer = 0; + if (pCond->endVersion == -1) { // user not specified end version, set current maximum version of vnode as the endVersion + endVer = pVnode->state.applied; + } else { + endVer = (pCond->endVersion > pVnode->state.applied)? pVnode->state.applied:pCond->endVersion; + } + + return (SVersionRange){.minVer = startVer, .maxVer = endVer}; } // // todo not unref yet, since it is not support multi-group interpolation query @@ -2485,41 +2232,104 @@ static SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond // taosArrayPush(pTsdbReadHandle->pTableCheckInfo, &info); // } -bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey) { +bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order) { ASSERT(pKey != NULL); if (pDelList == NULL) { return false; } + size_t num = taosArrayGetSize(pDelList); + bool asc = ASCENDING_TRAVERSE(order); + int32_t step = asc? 1:-1; - if (*index >= taosArrayGetSize(pDelList) - 1) { - TSDBKEY* last = taosArrayGetLast(pDelList); - if (pKey->ts > last->ts) { - return false; - } else if (pKey->ts == last->ts) { - size_t size = taosArrayGetSize(pDelList); - TSDBKEY* prev = taosArrayGet(pDelList, size - 2); - if (prev->version >= pKey->version) { - return true; - } else { + if (asc) { + if (*index >= num - 1) { + TSDBKEY* last = taosArrayGetLast(pDelList); + ASSERT(pKey->ts >= last->ts); + + if (pKey->ts > last->ts) { return false; + } else if (pKey->ts == last->ts) { + TSDBKEY* prev = taosArrayGet(pDelList, num - 2); + return (prev->version >= pKey->version); } } else { - ASSERT(0); + TSDBKEY* pCurrent = taosArrayGet(pDelList, *index); + TSDBKEY* pNext = taosArrayGet(pDelList, (*index) + 1); + + if (pKey->ts < pCurrent->ts) { + return false; + } + + if (pCurrent->ts <= pKey->ts && pNext->ts >= pKey->ts && pCurrent->version >= pKey->version) { + return true; + } + + while (pNext->ts <= pKey->ts && (*index) < num - 1) { + (*index) += 1; + + if ((*index) < num - 1) { + pCurrent = taosArrayGet(pDelList, *index); + pNext = taosArrayGet(pDelList, (*index) + 1); + + // it is not a consecutive deletion range, ignore it + if (pCurrent->version == 0 && pNext->version > 0) { + continue; + } + + if (pCurrent->ts <= pKey->ts && pNext->ts >= pKey->ts && pCurrent->version >= pKey->version) { + return true; + } + } + } + + return false; } } else { - TSDBKEY* pCurrent = taosArrayGet(pDelList, *index); - TSDBKEY* pNext = taosArrayGet(pDelList, (*index) + 1); + if (*index <= 0) { + TSDBKEY* pFirst = taosArrayGet(pDelList, 0); - if (pCurrent->ts <= pKey->ts && pNext->ts >= pKey->ts && pCurrent->version >= pKey->version) { - return true; + if (pKey->ts < pFirst->ts) { + return false; + } else if (pKey->ts == pFirst->ts) { + return pFirst->version >= pKey->version; + } else { + ASSERT(0); + } } else { - while (pNext->ts < pKey->ts && (*index) < taosArrayGetSize(pDelList) - 1) { - (*index) += 1; + TSDBKEY* pCurrent = taosArrayGet(pDelList, *index); + TSDBKEY* pPrev = taosArrayGet(pDelList, (*index) - 1); + + if (pKey->ts > pCurrent->ts) { + return false; + } + + if (pPrev->ts <= pKey->ts && pCurrent->ts >= pKey->ts && pPrev->version >= pKey->version) { + return true; + } + + while (pPrev->ts >= pKey->ts && (*index) > 1) { + (*index) += step; + + if ((*index) >= 1) { + pCurrent = taosArrayGet(pDelList, *index); + pPrev = taosArrayGet(pDelList, (*index) - 1); + + // it is not a consecutive deletion range, ignore it + if (pCurrent->version > 0 && pPrev->version == 0) { + continue; + } + + if (pPrev->ts <= pKey->ts && pCurrent->ts >= pKey->ts && pPrev->version >= pKey->version) { + return true; + } + } } return false; } } + + return false; } TSDBROW* getValidRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader) { @@ -2536,7 +2346,7 @@ TSDBROW* getValidRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pRea // it is a valid data version if ((key.version <= pReader->verRange.maxVer && key.version >= pReader->verRange.minVer) && - (!hasBeenDropped(pDelList, &pIter->index, &key))) { + (!hasBeenDropped(pDelList, &pIter->index, &key, pReader->order))) { return pRow; } @@ -2555,7 +2365,7 @@ TSDBROW* getValidRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pRea } if (key.version <= pReader->verRange.maxVer && key.version >= pReader->verRange.minVer && - (!hasBeenDropped(pDelList, &pIter->index, &key))) { + (!hasBeenDropped(pDelList, &pIter->index, &key, pReader->order))) { return pRow; } } @@ -2907,162 +2717,6 @@ int32_t tsdbGetStbIdList(SMeta* pMeta, int64_t suid, SArray* list) { return TSDB_CODE_SUCCESS; } -// static void destroyHelper(void* param) { -// if (param == NULL) { -// return; -// } - -// // tQueryInfo* pInfo = (tQueryInfo*)param; -// // if (pInfo->optr != TSDB_RELATION_IN) { -// // taosMemoryFreeClear(pInfo->q); -// // } else { -// // taosHashCleanup((SHashObj *)(pInfo->q)); -// // } - -// taosMemoryFree(param); -// } - -// #define TSDB_PREV_ROW 0x1 -// #define TSDB_NEXT_ROW 0x2 - -// static bool loadBlockOfActiveTable(STsdbReader* pTsdbReadHandle) { -// if (pTsdbReadHandle->checkFiles) { -// // check if the query range overlaps with the file data block -// bool exists = true; - -// int32_t code = buildBlockFromFiles(pTsdbReadHandle, &exists); -// if (code != TSDB_CODE_SUCCESS) { -// pTsdbReadHandle->checkFiles = false; -// return false; -// } - -// if (exists) { -// tsdbRetrieveDataBlock((STsdbReader**)pTsdbReadHandle, NULL); -// if (pTsdbReadHandle->currentLoadExternalRows && pTsdbReadHandle->window.skey == pTsdbReadHandle->window.ekey) { -// SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, 0); -// assert(*(int64_t*)pColInfo->pData == pTsdbReadHandle->window.skey); -// } - -// pTsdbReadHandle->currentLoadExternalRows = false; // clear the flag, since the exact matched row is found. -// return exists; -// } - -// pTsdbReadHandle->checkFiles = false; -// } - -// if (hasMoreDataInCache(pTsdbReadHandle)) { -// pTsdbReadHandle->currentLoadExternalRows = false; -// return true; -// } - -// // current result is empty -// if (pTsdbReadHandle->currentLoadExternalRows && pTsdbReadHandle->window.skey == pTsdbReadHandle->window.ekey && -// pTsdbReadHandle->cur.rows == 0) { -// // SMemTable* pMemRef = pTsdbReadHandle->pMemTable; - -// // doGetExternalRow(pTsdbReadHandle, TSDB_PREV_ROW, pMemRef); -// // doGetExternalRow(pTsdbReadHandle, TSDB_NEXT_ROW, pMemRef); - -// bool result = tsdbGetExternalRow(pTsdbReadHandle); - -// // pTsdbReadHandle->prev = doFreeColumnInfoData(pTsdbReadHandle->prev); -// // pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next); -// pTsdbReadHandle->currentLoadExternalRows = false; - -// return result; -// } - -// return false; -// } - -// static bool loadDataBlockFromTableSeq(STsdbReader* pTsdbReadHandle) { -// size_t numOfTables = taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo); -// assert(numOfTables > 0); - -// int64_t stime = taosGetTimestampUs(); - -// while (pTsdbReadHandle->activeIndex < numOfTables) { -// if (loadBlockOfActiveTable(pTsdbReadHandle)) { -// return true; -// } - -// STableBlockScanInfo* pCheckInfo = taosArrayGet(pTsdbReadHandle->pTableCheckInfo, pTsdbReadHandle->activeIndex); -// pCheckInfo->numOfBlocks = 0; - -// pTsdbReadHandle->activeIndex += 1; -// pTsdbReadHandle->locateStart = false; -// pTsdbReadHandle->checkFiles = true; -// pTsdbReadHandle->cur.rows = 0; -// pTsdbReadHandle->currentLoadExternalRows = pTsdbReadHandle->loadExternalRow; - -// terrno = TSDB_CODE_SUCCESS; - -// int64_t elapsedTime = taosGetTimestampUs() - stime; -// pTsdbReadHandle->cost.checkForNextTime += elapsedTime; -// } - -// return false; -// } - -// bool tsdbGetExternalRow(STsdbReader* pHandle) { -// STsdbReader* pTsdbReadHandle = (STsdbReader*)pHandle; -// SQueryFilePos* cur = &pTsdbReadHandle->cur; - -// cur->fid = INT32_MIN; -// cur->mixBlock = true; -// if (pTsdbReadHandle->prev == NULL || pTsdbReadHandle->next == NULL) { -// cur->rows = 0; -// return false; -// } - -// int32_t numOfCols = (int32_t)QH_GET_NUM_OF_COLS(pTsdbReadHandle); -// for (int32_t i = 0; i < numOfCols; ++i) { -// SColumnInfoData* pColInfoData = taosArrayGet(pTsdbReadHandle->pColumns, i); -// SColumnInfoData* first = taosArrayGet(pTsdbReadHandle->prev, i); - -// memcpy(pColInfoData->pData, first->pData, pColInfoData->info.bytes); - -// SColumnInfoData* sec = taosArrayGet(pTsdbReadHandle->next, i); -// memcpy(((char*)pColInfoData->pData) + pColInfoData->info.bytes, sec->pData, pColInfoData->info.bytes); - -// if (i == 0 && pColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) { -// cur->win.skey = *(TSKEY*)pColInfoData->pData; -// cur->win.ekey = *(TSKEY*)(((char*)pColInfoData->pData) + TSDB_KEYSIZE); -// } -// } - -// cur->rows = 2; -// return true; -// } - -// static void* doFreeColumnInfoData(SArray* pColumnInfoData) { -// if (pColumnInfoData == NULL) { -// return NULL; -// } - -// size_t cols = taosArrayGetSize(pColumnInfoData); -// for (int32_t i = 0; i < cols; ++i) { -// SColumnInfoData* pColInfo = taosArrayGet(pColumnInfoData, i); -// colDataDestroy(pColInfo); -// } - -// taosArrayDestroy(pColumnInfoData); -// return NULL; -// } - -// static void* destroyTableCheckInfo(SArray* pTableCheckInfo) { -// size_t size = taosArrayGetSize(pTableCheckInfo); -// for (int32_t i = 0; i < size; ++i) { -// STableBlockScanInfo* p = taosArrayGet(pTableCheckInfo, i); -// destroyTableMemIterator(p); - -// taosMemoryFreeClear(p->pCompInfo); -// } - -// taosArrayDestroy(pTableCheckInfo); -// return NULL; -// } - // ====================================== EXPOSED APIs ====================================== int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTableList, STsdbReader** ppReader, const char* idstr) { @@ -3125,16 +2779,11 @@ void tsdbReaderClose(STsdbReader* pReader) { } blockDataDestroy(pReader->pResBlock); - - taosMemoryFreeClear(pReader->suppInfo.pstatis); taosMemoryFreeClear(pReader->suppInfo.plist); + + taosArrayDestroy(pReader->suppInfo.pColAgg); taosMemoryFree(pReader->suppInfo.slotIds); - if (!isEmptyQueryTimeWindow(&pReader->window)) { - // tsdbMayUnTakeMemSnapshot(pTsdbReadHandle); - } else { - ASSERT(pReader->status.pTableMap == NULL); - } #if 0 // if (pReader->status.pTableScanInfo != NULL) { // pReader->status.pTableScanInfo = destroyTableCheckInfo(pReader->status.pTableScanInfo); @@ -3153,7 +2802,7 @@ void tsdbReaderClose(STsdbReader* pReader) { tsdbDebug("%p :io-cost summary: head-file read cnt:%" PRIu64 ", head-file time:%" PRIu64 " us, statis-info:%" PRId64 " us, datablock:%" PRId64 " us, check data:%" PRId64 " us, %s", - pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->statisInfoLoadTime, pCost->blockLoadTime, + pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaLoadTime, pCost->blockLoadTime, pCost->checkForNextTime, pReader->idStr); taosMemoryFree(pReader->idStr); @@ -3206,77 +2855,76 @@ void tsdbRetrieveDataBlockInfo(STsdbReader* pReader, SDataBlockInfo* pDataBlockI pDataBlockInfo->window = pReader->pResBlock->info.window; } -int32_t tsdbRetrieveDataBlockStatisInfo(STsdbReader* pReader, SColumnDataAgg*** pBlockStatis, bool* allHave) { +int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockStatis, bool* allHave) { int32_t code = 0; *allHave = false; + // there is no statistics data for composed block if (pReader->status.composedDataBlock) { *pBlockStatis = NULL; return TSDB_CODE_SUCCESS; } - // SFileBlockInfo* pBlockInfo = &pReader->pDataBlockInfo[c->slot]; - // assert((c->slot >= 0 && c->slot < pReader->numOfBlocks) || ((c->slot == pReader->numOfBlocks) && (c->slot == 0))); + SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter); + STableBlockScanInfo* pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); + SBlock* pBlock = taosArrayGet(pBlockScanInfo->pBlockList, pFBlock->tbBlockIdx); - // // file block with sub-blocks has no statistics data - // if (pBlockInfo->compBlock->numOfSubBlocks > 1) { - // *pBlockStatis = NULL; - // return TSDB_CODE_SUCCESS; - // } + int64_t stime = taosGetTimestampUs(); - // int64_t stime = taosGetTimestampUs(); - // int statisStatus = tsdbLoadBlockStatis(&pReader->rhelper, pBlockInfo->compBlock); - // if (statisStatus < TSDB_STATIS_OK) { - // return terrno; - // } else if (statisStatus > TSDB_STATIS_OK) { - // *pBlockStatis = NULL; - // return TSDB_CODE_SUCCESS; - // } + SBlockLoadSuppInfo* pSup = &pReader->suppInfo; - // tsdbDebug("vgId:%d, succeed to load block statis part for uid %" PRIu64, REPO_ID(pReader->pTsdb), - // TSDB_READ_TABLE_UID(&pReader->rhelper)); + if (tBlockHasSma(pBlock)) { + code = tsdbReadBlockSma(pReader->pFileReader, pBlock, pSup->pColAgg, NULL); + if (code != TSDB_CODE_SUCCESS) { + tsdbDebug("vgId:%d, failed to load block SMA for uid %" PRIu64 ", code:%s, %s", 0, pFBlock->uid, tstrerror(code), + pReader->idStr); + return code; + } + } else { + *pBlockStatis = NULL; + return TSDB_CODE_SUCCESS; + } - // int16_t* colIds = pReader->suppInfo.defaultLoadColumn->pData; + *allHave = true; - // size_t numOfCols = QH_GET_NUM_OF_COLS(pReader); - // memset(pReader->suppInfo.plist, 0, numOfCols * POINTER_BYTES); - // memset(pReader->suppInfo.pstatis, 0, numOfCols * sizeof(SColumnDataAgg)); + // always load the first primary timestamp column data + SColumnDataAgg* pTsAgg = &pSup->tsColAgg; - // for (int32_t i = 0; i < numOfCols; ++i) { - // pReader->suppInfo.pstatis[i].colId = colIds[i]; - // } + pTsAgg->numOfNull = 0; + pTsAgg->colId = PRIMARYKEY_TIMESTAMP_COL_ID; + pTsAgg->min = pReader->pResBlock->info.window.skey; + pTsAgg->max = pReader->pResBlock->info.window.ekey; + pSup->plist[0] = pTsAgg; - // *allHave = true; - // tsdbGetBlockStatis(&pReader->rhelper, pReader->suppInfo.pstatis, (int)numOfCols, pBlockInfo->compBlock); + // update the number of NULL data rows + size_t numOfCols = blockDataGetNumOfCols(pReader->pResBlock); - // // always load the first primary timestamp column data - // SColumnDataAgg* pPrimaryColStatis = &pReader->suppInfo.pstatis[0]; - // assert(pPrimaryColStatis->colId == PRIMARYKEY_TIMESTAMP_COL_ID); + int32_t i = 0, j = 0; + while (j < numOfCols && i < taosArrayGetSize(pSup->pColAgg)) { + SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i); + if (pAgg->colId == pSup->colIds[j]) { + if (IS_BSMA_ON(&(pReader->pSchema->columns[i]))) { + pSup->plist[j] = pAgg; + } else { + *allHave = false; + } + i += 1; + j += 1; + } else if (pAgg->colId < pSup->colIds[j]) { + i += 1; + } else if (pSup->colIds[j] < pAgg->colId) { + j += 1; + } + } - // pPrimaryColStatis->numOfNull = 0; - // pPrimaryColStatis->min = pBlockInfo->compBlock->minKey.ts; - // pPrimaryColStatis->max = pBlockInfo->compBlock->maxKey.ts; - // pReader->suppInfo.plist[0] = &pReader->suppInfo.pstatis[0]; + int64_t elapsed = taosGetTimestampUs() - stime; + pReader->cost.smaLoadTime += elapsed; - // // update the number of NULL data rows - // int32_t* slotIds = pReader->suppInfo.slotIds; - // for (int32_t i = 1; i < numOfCols; ++i) { - // ASSERT(colIds[i] == pReader->pSchema->columns[slotIds[i]].colId); - // if (IS_BSMA_ON(&(pReader->pSchema->columns[slotIds[i]]))) { - // if (pReader->suppInfo.pstatis[i].numOfNull == -1) { // set the column data are all NULL - // pReader->suppInfo.pstatis[i].numOfNull = pBlockInfo->compBlock->numOfRows; - // } + *pBlockStatis = pSup->plist; - // pReader->suppInfo.plist[i] = &pReader->suppInfo.pstatis[i]; - // } else { - // *allHave = false; - // } - // } + tsdbDebug("vgId:%d, succeed to load block SMA for uid %" PRIu64 ", elapsed time:%" PRId64 "us, %s", 0, pFBlock->uid, + elapsed, pReader->idStr); - // int64_t elapsed = taosGetTimestampUs() - stime; - // pReader->cost.statisInfoLoadTime += elapsed; - - // *pBlockStatis = pReader->suppInfo.plist; return code; } @@ -3311,19 +2959,19 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond, int32_ return TSDB_CODE_SUCCESS; } - setQueryTimewindow(pReader, pCond, tWinIdx); - - pReader->order = pCond->order; - pReader->type = BLOCK_LOAD_OFFSET_ORDER; + pReader->order = pCond->order; + pReader->type = BLOCK_LOAD_OFFSET_ORDER; pReader->status.loadFromFile = true; pReader->status.pTableIter = NULL; pReader->window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows[tWinIdx]); // allocate buffer in order to load data blocks from file - memset(pReader->suppInfo.pstatis, 0, sizeof(SColumnDataAgg)); + memset(&pReader->suppInfo.tsColAgg, 0, sizeof(SColumnDataAgg)); memset(pReader->suppInfo.plist, 0, POINTER_BYTES); + pReader->suppInfo.tsColAgg.colId = PRIMARYKEY_TIMESTAMP_COL_ID; + // todo set the correct numOfTables int32_t numOfTables = 1; SDataBlockIter* pBlockIter = &pReader->status.blockIter; @@ -3349,114 +2997,80 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond, int32_ return code; } +static int32_t getBucketIndex(int32_t startRow, int32_t bucketRange, int32_t numOfRows) { + return (numOfRows - startRow) / bucketRange; +} + int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTableBlockInfo) { - int32_t code = 0; - // pTableBlockInfo->totalSize = 0; - // pTableBlockInfo->totalRows = 0; + int32_t code = TSDB_CODE_SUCCESS; + pTableBlockInfo->totalSize = 0; + pTableBlockInfo->totalRows = 0; - // STsdbFS* pFileHandle = REPO_FS(pReader->pTsdb); + // find the start data block in file + SReaderStatus* pStatus = &pReader->status; - // // find the start data block in file - // pReader->locateStart = true; - // STsdbKeepCfg* pCfg = REPO_KEEP_CFG(pReader->pTsdb); - // int32_t fid = getFileIdFromKey(pReader->window.skey, pCfg->days, pCfg->precision); + STsdbCfg* pc = &pReader->pTsdb->pVnode->config.tsdbCfg; + pTableBlockInfo->defMinRows = pc->minRows; + pTableBlockInfo->defMaxRows = pc->maxRows; - // tsdbRLockFS(pFileHandle); - // tsdbFSIterInit(&pReader->fileIter, pFileHandle, pReader->order); - // tsdbFSIterSeek(&pReader->fileIter, fid); - // tsdbUnLockFS(pFileHandle); + int32_t bucketRange = ceil((pc->maxRows - pc->minRows) / 20.0); - // STsdbCfg* pc = REPO_CFG(pReader->pTsdb); - // pTableBlockInfo->defMinRows = pc->minRows; - // pTableBlockInfo->defMaxRows = pc->maxRows; + pTableBlockInfo->numOfFiles += 1; - // int32_t bucketRange = ceil((pc->maxRows - pc->minRows) / 20.0); + int32_t numOfTables = (int32_t)taosHashGetSize(pStatus->pTableMap); + int defaultRows = 4096; - // pTableBlockInfo->numOfFiles += 1; + SDataBlockIter* pBlockIter = &pStatus->blockIter; + pTableBlockInfo->numOfFiles += pStatus->fileIter.numOfFiles; + pTableBlockInfo->numOfBlocks += pBlockIter->numOfBlocks; - // int32_t code = TSDB_CODE_SUCCESS; - // int32_t numOfBlocks = 0; - // int32_t numOfTables = (int32_t)taosArrayGetSize(pReader->pTableCheckInfo); - // int defaultRows = 4096; - // STimeWindow win = TSWINDOW_INITIALIZER; + pTableBlockInfo->numOfTables = numOfTables; + bool hasNext = true; - // while (true) { - // numOfBlocks = 0; - // tsdbRLockFS(REPO_FS(pReader->pTsdb)); + while (true) { + if (hasNext) { + SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); + STableBlockScanInfo* pScanInfo = taosHashGet(pStatus->pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); + SBlock* pBlock = taosArrayGet(pScanInfo->pBlockList, pFBlock->tbBlockIdx); - // if ((pReader->pFileGroup = tsdbFSIterNext(&pReader->fileIter)) == NULL) { - // tsdbUnLockFS(REPO_FS(pReader->pTsdb)); - // break; - // } + int32_t numOfRows = pBlock->nRow; + pTableBlockInfo->totalRows += numOfRows; - // tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pReader->pFileGroup->fid, &win.skey, &win.ekey); + if (numOfRows > pTableBlockInfo->maxRows) { + pTableBlockInfo->maxRows = numOfRows; + } - // // current file are not overlapped with query time window, ignore remain files - // if ((win.skey > pReader->window.ekey) /* || (!ascTraverse && win.ekey < pTsdbReadHandle->window.ekey)*/) { - // tsdbUnLockFS(REPO_FS(pReader->pTsdb)); - // tsdbDebug("%p remain files are not qualified for qrange:%" PRId64 "-%" PRId64 ", ignore, %s", pReader, - // pReader->window.skey, pReader->window.ekey, pReader->idStr); - // pReader->pFileGroup = NULL; - // break; - // } + if (numOfRows < pTableBlockInfo->minRows) { + pTableBlockInfo->minRows = numOfRows; + } - // pTableBlockInfo->numOfFiles += 1; - // if (tsdbSetAndOpenReadFSet(&pReader->rhelper, pReader->pFileGroup) < 0) { - // tsdbUnLockFS(REPO_FS(pReader->pTsdb)); - // code = terrno; - // break; - // } + if (numOfRows < defaultRows) { + pTableBlockInfo->numOfSmallBlocks += 1; + } - // tsdbUnLockFS(REPO_FS(pReader->pTsdb)); + int32_t bucketIndex = getBucketIndex(pTableBlockInfo->defMinRows, bucketRange, numOfRows); + pTableBlockInfo->blockRowsHisto[bucketIndex]++; - // if (tsdbLoadBlockIdx(&pReader->rhelper) < 0) { - // code = terrno; - // break; - // } + hasNext = blockIteratorNext(&pStatus->blockIter); - // if ((code = getFileCompInfo(pReader, &numOfBlocks)) != TSDB_CODE_SUCCESS) { - // break; - // } + } else { + code = initForFirstBlockInFile(pReader, pBlockIter); + if ((code != TSDB_CODE_SUCCESS) || (pReader->status.loadFromFile == false)) { + break; + } - // tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, %s", pReader, numOfBlocks, numOfTables, - // pReader->pFileGroup->fid, pReader->idStr); + pTableBlockInfo->numOfBlocks += pBlockIter->numOfBlocks; + } - // if (numOfBlocks == 0) { - // continue; - // } +/* + hasNext = blockIteratorNext(&pStatus->blockIter); +*/ - // pTableBlockInfo->numOfBlocks += numOfBlocks; - // for (int32_t i = 0; i < numOfTables; ++i) { - // STableBlockScanInfo* pCheckInfo = taosArrayGet(pReader->pTableCheckInfo, i); +// tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, %s", pReader, numOfBlocks, numOfTables, +// pReader->pFileGroup->fid, pReader->idStr); + } - // SBlock* pBlock = pCheckInfo->pCompInfo->blocks; - - // for (int32_t j = 0; j < pCheckInfo->numOfBlocks; ++j) { - // pTableBlockInfo->totalSize += pBlock[j].len; - - // int32_t numOfRows = pBlock[j].numOfRows; - // pTableBlockInfo->totalRows += numOfRows; - - // if (numOfRows > pTableBlockInfo->maxRows) { - // pTableBlockInfo->maxRows = numOfRows; - // } - - // if (numOfRows < pTableBlockInfo->minRows) { - // pTableBlockInfo->minRows = numOfRows; - // } - - // if (numOfRows < defaultRows) { - // pTableBlockInfo->numOfSmallBlocks += 1; - // } - - // int32_t bucketIndex = getBucketIndex(pTableBlockInfo->defMinRows, bucketRange, numOfRows); - // pTableBlockInfo->blockRowsHisto[bucketIndex]++; - // } - // } - // } - - // pTableBlockInfo->numOfTables = numOfTables; return code; } @@ -3491,3 +3105,39 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) { return rows; } + +int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int64_t *suid) { + int32_t sversion = 1; + + SMetaReader mr = {0}; + metaReaderInit(&mr, pVnode->pMeta, 0); + int32_t code = metaGetTableEntryByUid(&mr, uid); + if (code != TSDB_CODE_SUCCESS) { + terrno = TSDB_CODE_TDB_INVALID_TABLE_ID; + metaReaderClear(&mr); + return terrno; + } + + *suid = 0; + + if (mr.me.type == TSDB_CHILD_TABLE) { + *suid = mr.me.ctbEntry.suid; + code = metaGetTableEntryByUid(&mr, *suid); + if (code != TSDB_CODE_SUCCESS) { + terrno = TSDB_CODE_TDB_INVALID_TABLE_ID; + metaReaderClear(&mr); + return terrno; + } + sversion = mr.me.stbEntry.schemaRow.version; + } else { + ASSERT(mr.me.type == TSDB_NORMAL_TABLE); + sversion = mr.me.ntbEntry.schemaRow.version; + } + + metaReaderClear(&mr); + *pSchema = metaGetTbTSchema(pVnode->pMeta, uid, sversion); + + return TSDB_CODE_SUCCESS; +} + + diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index 2bd62348c9..e96ee03b03 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -424,10 +424,12 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx, uint8_t **ppBuf) { ASSERT(n == size - sizeof(TSCKSUM)); + tFree(pBuf); return code; _err: tsdbError("vgId:%d read del idx failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); + tFree(pBuf); return code; } @@ -969,6 +971,8 @@ int32_t tsdbReadColData(SDataFReader *pReader, SBlockIdx *pBlockIdx, SBlock *pBl SBlockData *pBlockData1 = &(SBlockData){0}; SBlockData *pBlockData2 = &(SBlockData){0}; + tBlockDataInit(pBlockData1); + tBlockDataInit(pBlockData2); for (int32_t iSubBlock = 1; iSubBlock < pBlock->nSubBlock; iSubBlock++) { code = tsdbReadSubColData(pReader, pBlockIdx, pBlock, iSubBlock, aColId, nCol, pBlockData1, ppBuf1, ppBuf2); if (code) goto _err; @@ -1106,6 +1110,8 @@ int32_t tsdbReadBlockData(SDataFReader *pReader, SBlockIdx *pBlockIdx, SBlock *p SBlockData *pBlockData1 = &(SBlockData){0}; SBlockData *pBlockData2 = &(SBlockData){0}; + tBlockDataInit(pBlockData1); + tBlockDataInit(pBlockData2); for (iSubBlock = 1; iSubBlock < pBlock->nSubBlock; iSubBlock++) { code = tsdbReadSubBlockData(pReader, pBlockIdx, pBlock, iSubBlock, pBlockData1, ppBuf1, ppBuf2); if (code) { @@ -1152,7 +1158,7 @@ _err: int32_t tsdbReadBlockSma(SDataFReader *pReader, SBlock *pBlock, SArray *aColumnDataAgg, uint8_t **ppBuf) { int32_t code = 0; TdFilePtr pFD = pReader->pSmaFD; - int64_t offset = pBlock->aSubBlock[0].offset; + int64_t offset = pBlock->aSubBlock[0].sOffset; int64_t size = pBlock->aSubBlock[0].nSma * sizeof(SColumnDataAgg) + sizeof(TSCKSUM); uint8_t *pBuf = NULL; int64_t n; @@ -1175,10 +1181,13 @@ int32_t tsdbReadBlockSma(SDataFReader *pReader, SBlock *pBlock, SArray *aColumnD if (n < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; + } else if (n < size) { + code = TSDB_CODE_FILE_CORRUPTED; + goto _err; } // check - if (!taosCheckChecksumWhole(NULL, size)) { + if (!taosCheckChecksumWhole(*ppBuf, size)) { code = TSDB_CODE_FILE_CORRUPTED; goto _err; } diff --git a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c similarity index 53% rename from source/dnode/vnode/src/tsdb/tsdbReadImpl.c rename to source/dnode/vnode/src/tsdb/tsdbRetention.c index fe0d3a1b6f..e73f3f947c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -14,3 +14,29 @@ */ #include "tsdb.h" + +int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) { + int32_t code = 0; + + // begin + code = tsdbFSBegin(pTsdb->fs); + if (code) goto _err; + + // do retention + for (int32_t iSet = 0; iSet < taosArrayGetSize(pTsdb->fs->nState->aDFileSet); iSet++) { + SDFileSet *pDFileSet = (SDFileSet *)taosArrayGet(pTsdb->fs->nState->aDFileSet, iSet); + + // TODO + } + + // commit + code = tsdbFSCommit(pTsdb->fs); + if (code) goto _err; + +_exit: + return code; + +_err: + tsdbError("vgId:%d tsdb do retention failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + return code; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 79989a5560..54087a7871 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -15,22 +15,686 @@ #include "tsdb.h" -struct STsdbSnapshotReader { - STsdb* pTsdb; - // TODO +// STsdbSnapReader ======================================== +struct STsdbSnapReader { + STsdb* pTsdb; + int64_t sver; + int64_t ever; + // for data file + int8_t dataDone; + int32_t fid; + SDataFReader* pDataFReader; + SArray* aBlockIdx; // SArray + int32_t iBlockIdx; + SBlockIdx* pBlockIdx; + SMapData mBlock; // SMapData + int32_t iBlock; + SBlockData blkData; + // for del file + int8_t delDone; + SDelFReader* pDelFReader; + int32_t iDelIdx; + SArray* aDelIdx; // SArray + SArray* aDelData; // SArray }; -int32_t tsdbSnapshotReaderOpen(STsdb* pTsdb, STsdbSnapshotReader** ppReader, int64_t sver, int64_t ever) { - // TODO - return 0; +static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + + while (true) { + if (pReader->pDataFReader == NULL) { + SDFileSet* pSet = NULL; + + // search the next data file set to read (todo) + if (0 /* TODO */) { + code = TSDB_CODE_VND_READ_END; + goto _exit; + } + + // open + code = tsdbDataFReaderOpen(&pReader->pDataFReader, pReader->pTsdb, pSet); + if (code) goto _err; + + // SBlockIdx + code = tsdbReadBlockIdx(pReader->pDataFReader, pReader->aBlockIdx, NULL); + if (code) goto _err; + + pReader->iBlockIdx = 0; + pReader->pBlockIdx = NULL; + } + + while (true) { + if (pReader->pBlockIdx == NULL) { + if (pReader->iBlockIdx >= taosArrayGetSize(pReader->aBlockIdx)) { + tsdbDataFReaderClose(&pReader->pDataFReader); + break; + } + + pReader->pBlockIdx = (SBlockIdx*)taosArrayGet(pReader->aBlockIdx, pReader->iBlockIdx); + pReader->iBlockIdx++; + + // SBlock + code = tsdbReadBlock(pReader->pDataFReader, pReader->pBlockIdx, &pReader->mBlock, NULL); + if (code) goto _err; + + pReader->iBlock = 0; + } + + while (true) { + SBlock block; + SBlock* pBlock = █ + + if (pReader->iBlock >= pReader->mBlock.nItem) { + pReader->pBlockIdx = NULL; + break; + } + + tMapDataGetItemByIdx(&pReader->mBlock, pReader->iBlock, pBlock, tGetBlock); + pReader->iBlock++; + + if ((pBlock->minVersion >= pReader->sver && pBlock->minVersion <= pReader->ever) || + (pBlock->maxVersion >= pReader->sver && pBlock->maxVersion <= pReader->ever)) { + // overlap (todo) + + code = tsdbReadBlockData(pReader->pDataFReader, pReader->pBlockIdx, pBlock, &pReader->blkData, NULL, NULL); + if (code) goto _err; + + goto _exit; + } + } + } + } + +_exit: + return code; + +_err: + tsdbError("vgId:%d snap read data failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); + return code; } -int32_t tsdbSnapshotReaderClose(STsdbSnapshotReader* pReader) { - // TODO - return 0; +static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + STsdb* pTsdb = pReader->pTsdb; + SDelFile* pDelFile = pTsdb->fs->cState->pDelFile; + + if (pReader->pDelFReader == NULL) { + if (pDelFile == NULL) { + code = TSDB_CODE_VND_READ_END; + goto _exit; + } + + // open + code = tsdbDelFReaderOpen(&pReader->pDelFReader, pDelFile, pTsdb, NULL); + if (code) goto _err; + + // read index + code = tsdbReadDelIdx(pReader->pDelFReader, pReader->aDelIdx, NULL); + if (code) goto _err; + + pReader->iDelIdx = 0; + } + + while (pReader->iDelIdx < taosArrayGetSize(pReader->aDelIdx)) { + SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pReader->aDelIdx, pReader->iDelIdx); + int32_t size = 0; + + pReader->iDelIdx++; + + code = tsdbReadDelData(pReader->pDelFReader, pDelIdx, pReader->aDelData, NULL); + if (code) goto _err; + + for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); iDelData++) { + SDelData* pDelData = (SDelData*)taosArrayGet(pReader->aDelData, iDelData); + + if (pDelData->version >= pReader->sver && pDelData->version <= pReader->ever) { + size += tPutDelData(NULL, pDelData); + } + } + + if (size > 0) { + int64_t n = 0; + + size = size + sizeof(SSnapDataHdr) + sizeof(TABLEID); + code = tRealloc(ppData, size); + if (code) goto _err; + + // SSnapDataHdr + SSnapDataHdr* pSnapDataHdr = (SSnapDataHdr*)(*ppData + n); + pSnapDataHdr->type = 1; + pSnapDataHdr->size = size; // TODO: size here may incorrect + n += sizeof(SSnapDataHdr); + + // TABLEID + TABLEID* pId = (TABLEID*)(*ppData + n); + pId->suid = pDelIdx->suid; + pId->uid = pDelIdx->uid; + n += sizeof(*pId); + + // DATA + for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); iDelData++) { + SDelData* pDelData = (SDelData*)taosArrayGet(pReader->aDelData, iDelData); + + if (pDelData->version >= pReader->sver && pDelData->version <= pReader->ever) { + n += tPutDelData(*ppData + n, pDelData); + } + } + + goto _exit; + } + } + + code = TSDB_CODE_VND_READ_END; + tsdbDelFReaderClose(&pReader->pDelFReader); + +_exit: + return code; + +_err: + tsdbError("vgId:%d snap read del failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + return code; } -int32_t tsdbSnapshotRead(STsdbSnapshotReader* pReader, void** ppData, uint32_t* nData) { - // TODO - return 0; +int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapReader** ppReader) { + int32_t code = 0; + STsdbSnapReader* pReader = NULL; + + // alloc + pReader = (STsdbSnapReader*)taosMemoryCalloc(1, sizeof(*pReader)); + if (pReader == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pReader->pTsdb = pTsdb; + pReader->sver = sver; + pReader->ever = ever; + + pReader->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); + if (pReader->aBlockIdx == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + + pReader->mBlock = tMapDataInit(); + + code = tBlockDataInit(&pReader->blkData); + if (code) goto _err; + + pReader->aDelIdx = taosArrayInit(0, sizeof(SDelIdx)); + if (pReader->aDelIdx == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + + pReader->aDelData = taosArrayInit(0, sizeof(SDelData)); + if (pReader->aDelData == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + + *ppReader = pReader; + return code; + +_err: + tsdbError("vgId:%d snapshot reader open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + *ppReader = NULL; + return code; +} + +int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) { + int32_t code = 0; + STsdbSnapReader* pReader = *ppReader; + + taosArrayDestroy(pReader->aDelData); + taosArrayDestroy(pReader->aDelIdx); + if (pReader->pDelFReader) { + tsdbDelFReaderClose(&pReader->pDelFReader); + } + tBlockDataClear(&pReader->blkData); + tMapDataClear(&pReader->mBlock); + taosArrayDestroy(pReader->aBlockIdx); + if (pReader->pDataFReader) { + tsdbDataFReaderClose(&pReader->pDataFReader); + } + taosMemoryFree(pReader); + *ppReader = NULL; + + return code; +} + +int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + + // read data file + if (!pReader->dataDone) { + code = tsdbSnapReadData(pReader, ppData); + if (code) { + if (code == TSDB_CODE_VND_READ_END) { + pReader->dataDone = 1; + } else { + goto _err; + } + } else { + goto _exit; + } + } + + // read del file + if (!pReader->delDone) { + code = tsdbSnapReadDel(pReader, ppData); + if (code) { + if (code == TSDB_CODE_VND_READ_END) { + pReader->delDone = 1; + } else { + goto _err; + } + } else { + goto _exit; + } + } + + code = TSDB_CODE_VND_READ_END; + +_exit: + return code; + +_err: + tsdbError("vgId:%d snapshot read failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code)); + return code; +} + +// STsdbSnapWriter ======================================== +struct STsdbSnapWriter { + STsdb* pTsdb; + int64_t sver; + int64_t ever; + + // config + int32_t minutes; + int8_t precision; + + // for data file + int32_t fid; + SDataFReader* pDataFReader; + SArray* aBlockIdx; + int32_t iBlockIdx; + SBlockIdx* pBlockIdx; + SMapData mBlock; + int32_t iBlock; + SBlockData blockData; + int32_t iRow; + + SDataFWriter* pDataFWriter; + SArray* aBlockIdxN; + SBlockIdx blockIdx; + SMapData mBlockN; + SBlock block; + SBlockData nBlockData; + + // for del file + SDelFReader* pDelFReader; + SDelFWriter* pDelFWriter; + int32_t iDelIdx; + SArray* aDelIdx; + SArray* aDelData; + SArray* aDelIdxN; +}; + +static int32_t tsdbSnapRollback(STsdbSnapWriter* pWriter) { + int32_t code = 0; + // TODO + return code; +} + +static int32_t tsdbSnapCommit(STsdbSnapWriter* pWriter) { + int32_t code = 0; + // TODO + return code; +} + +static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) { + int32_t code = 0; + STsdb* pTsdb = pWriter->pTsdb; + + if (pWriter->pDataFWriter == NULL) goto _exit; + + // TODO + + code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 0); + if (code) goto _err; + + if (pWriter->pDataFReader) { + code = tsdbDataFReaderClose(&pWriter->pDataFReader); + if (code) goto _err; + } + +_exit: + return code; + +_err: + tsdbError("vgId:%d tsdb snapshot writer data end failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + return code; +} + +static int32_t tsdbSnapWriteAppendData(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + int32_t iRow = 0; // todo + int32_t nRow = 0; // todo + SBlockData* pBlockData = NULL; // todo + + while (iRow < nRow) { + code = tBlockDataAppendRow(&pWriter->nBlockData, &tsdbRowFromBlockData(pBlockData, iRow), NULL); + if (code) goto _err; + } + + return code; + +_err: + tsdbError("vgId:%d tsdb snapshot write append data failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code)); + return code; +} + +static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + STsdb* pTsdb = pWriter->pTsdb; + int64_t suid = 0; // todo + int64_t uid = 0; // todo + int64_t skey; // todo + int64_t ekey; // todo + + int32_t fid = tsdbKeyFid(skey, pWriter->minutes, pWriter->precision); + ASSERT(fid == tsdbKeyFid(ekey, pWriter->minutes, pWriter->precision)); + + // begin + if (pWriter->pDataFWriter == NULL || pWriter->fid != fid) { + code = tsdbSnapWriteDataEnd(pWriter); + if (code) goto _err; + + pWriter->fid = fid; + SDFileSet* pSet = tsdbFSStateGetDFileSet(pTsdb->fs->nState, fid); + // reader + if (pSet) { + // open + code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet); + if (code) goto _err; + + // SBlockIdx + code = tsdbReadBlockIdx(pWriter->pDataFReader, pWriter->aBlockIdx, NULL); + if (code) goto _err; + } else { + taosArrayClear(pWriter->aBlockIdx); + } + pWriter->iBlockIdx = 0; + + // writer + SDFileSet wSet = {0}; + if (pSet == NULL) { + wSet = (SDFileSet){0}; // todo + } else { + wSet = (SDFileSet){0}; // todo + } + + code = tsdbDataFWriterOpen(&pWriter->pDataFWriter, pTsdb, &wSet); + if (code) goto _err; + + taosArrayClear(pWriter->aBlockIdxN); + } + + // process + TABLEID id = {0}; // TODO + TSKEY minKey = 0; // TODO + TSKEY maxKey = 0; // TODO + + while (true) { + if (pWriter->pBlockIdx) { + int32_t c = tTABLEIDCmprFn(&id, pWriter->pBlockIdx); + + if (c == 0) { + } else if (c < 0) { + // keep merge + } else { + // code = tsdbSnapWriteTableDataEnd(pWriter); + if (code) goto _err; + + pWriter->iBlockIdx++; + if (pWriter->iBlockIdx < taosArrayGetSize(pWriter->aBlockIdx)) { + pWriter->pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx); + } else { + pWriter->pBlockIdx = NULL; + } + + if (pWriter->pBlockIdx) { + code = tsdbReadBlock(pWriter->pDataFReader, pWriter->pBlockIdx, &pWriter->mBlock, NULL); + if (code) goto _err; + } + } + } else { + int32_t c = tTABLEIDCmprFn(&id, &pWriter->blockIdx); + + if (c == 0) { + // merge commit the block data + } else if (c > 0) { + // code = tsdbSnapWriteTableDataEnd(pWriter); + if (code) goto _err; + } else { + ASSERT(0); + } + } + } + + return code; + +_err: + tsdbError("vgId:%d tsdb snapshot write data failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + return code; +} + +static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + STsdb* pTsdb = pWriter->pTsdb; + + if (pWriter->pDelFWriter == NULL) { + SDelFile* pDelFile = tsdbFSStateGetDelFile(pTsdb->fs->nState); + + // reader + if (pDelFile) { + code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb, NULL); + if (code) goto _err; + + code = tsdbReadDelIdx(pWriter->pDelFReader, pWriter->aDelIdx, NULL); + if (code) goto _err; + } + + // writer + SDelFile delFile = {.commitID = pTsdb->pVnode->state.commitID, .offset = 0, .size = 0}; + code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &delFile, pTsdb); + if (code) goto _err; + } + + // process the del data + TABLEID id = {0}; // todo + + while (true) { + SDelIdx* pDelIdx = NULL; + int64_t n = 0; + SDelData delData; + SDelIdx delIdx; + int8_t toBreak = 0; + + if (pWriter->iDelIdx < taosArrayGetSize(pWriter->aDelIdx)) { + pDelIdx = taosArrayGet(pWriter->aDelIdx, pWriter->iDelIdx); + } + + if (pDelIdx) { + int32_t c = tTABLEIDCmprFn(&id, pDelIdx); + if (c < 0) { + goto _new_del; + } else { + code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData, NULL); + if (code) goto _err; + + pWriter->iDelIdx++; + if (c == 0) { + toBreak = 1; + delIdx = (SDelIdx){.suid = id.suid, .uid = id.uid}; + goto _merge_del; + } else { + delIdx = (SDelIdx){.suid = pDelIdx->suid, .uid = pDelIdx->uid}; + goto _write_del; + } + } + } + + _new_del: + toBreak = 1; + delIdx = (SDelIdx){.suid = id.suid, .uid = id.uid}; + taosArrayClear(pWriter->aDelData); + + _merge_del: + while (n < nData) { + n += tGetDelData(pData + n, &delData); + if (taosArrayPush(pWriter->aDelData, &delData) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + } + + _write_del: + code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, NULL, &delIdx); + if (code) goto _err; + + if (taosArrayPush(pWriter->aDelIdxN, &delIdx) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + + if (toBreak) break; + } + +_exit: + return code; + +_err: + tsdbError("vgId:%d tsdb snapshot write del failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + return code; +} + +static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) { + int32_t code = 0; + STsdb* pTsdb = pWriter->pTsdb; + + if (pWriter->pDelFWriter == NULL) goto _exit; + for (; pWriter->iDelIdx < taosArrayGetSize(pWriter->aDelIdx); pWriter->iDelIdx++) { + SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdx, pWriter->iDelIdx); + + code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData, NULL); + if (code) goto _err; + + SDelIdx delIdx = (SDelIdx){.suid = pDelIdx->suid, .uid = pDelIdx->uid}; + code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, NULL, &delIdx); + if (code) goto _err; + + if (taosArrayPush(pWriter->aDelIdx, &delIdx) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + } + + code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter); + if (code) goto _err; + + code = tsdbFSStateUpsertDelFile(pTsdb->fs->nState, &pWriter->pDelFWriter->fDel); + if (code) goto _err; + + code = tsdbDelFWriterClose(&pWriter->pDelFWriter, 1); + if (code) goto _err; + + if (pWriter->pDelFReader) { + code = tsdbDelFReaderClose(&pWriter->pDelFReader); + if (code) goto _err; + } + +_exit: + return code; + +_err: + tsdbError("vgId:%d tsdb snapshow write del end failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + return code; +} + +int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter) { + int32_t code = 0; + STsdbSnapWriter* pWriter = NULL; + + // alloc + pWriter = (STsdbSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); + if (pWriter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pWriter->pTsdb = pTsdb; + pWriter->sver = sver; + pWriter->ever = ever; + + *ppWriter = pWriter; + return code; + +_err: + tsdbError("vgId:%d tsdb snapshot writer open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + *ppWriter = NULL; + return code; +} + +int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) { + int32_t code = 0; + STsdbSnapWriter* pWriter = *ppWriter; + + if (rollback) { + code = tsdbSnapRollback(pWriter); + if (code) goto _err; + } else { + code = tsdbSnapWriteDataEnd(pWriter); + if (code) goto _err; + + code = tsdbSnapWriteDelEnd(pWriter); + if (code) goto _err; + + code = tsdbSnapCommit(pWriter); + if (code) goto _err; + } + + taosMemoryFree(pWriter); + *ppWriter = NULL; + + return code; + +_err: + tsdbError("vgId:%d tsdb snapshot writer close failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code)); + return code; +} + +int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { + int32_t code = 0; + int8_t type = pData[0]; + + // ts data + if (type == 0) { + code = tsdbSnapWriteData(pWriter, pData + 1, nData - 1); + if (code) goto _err; + } else { + code = tsdbSnapWriteDataEnd(pWriter); + if (code) goto _err; + } + + // del data + if (type == 1) { + code = tsdbSnapWriteDel(pWriter, pData + 1, nData - 1); + if (code) goto _err; + } + + return code; + +_err: + tsdbError("vgId:%d tsdb snapshow write failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code)); + return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index f906ef1b54..415a674737 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -87,8 +87,10 @@ int32_t tPutMapData(uint8_t *p, SMapData *pMapData) { n += tPutI32v(p ? p + n : p, pMapData->nItem); if (pMapData->nItem) { + int32_t lOffset = 0; for (int32_t iItem = 0; iItem < pMapData->nItem; iItem++) { - n += tPutI32v(p ? p + n : p, pMapData->aOffset[iItem]); + n += tPutI32v(p ? p + n : p, pMapData->aOffset[iItem] - lOffset); + lOffset = pMapData->aOffset[iItem]; } n += tPutI32v(p ? p + n : p, pMapData->nData); @@ -111,8 +113,11 @@ int32_t tGetMapData(uint8_t *p, SMapData *pMapData) { if (pMapData->nItem) { if (tRealloc((uint8_t **)&pMapData->aOffset, sizeof(int32_t) * pMapData->nItem)) return -1; + int32_t lOffset = 0; for (int32_t iItem = 0; iItem < pMapData->nItem; iItem++) { n += tGetI32v(p + n, &pMapData->aOffset[iItem]); + pMapData->aOffset[iItem] += lOffset; + lOffset = pMapData->aOffset[iItem]; } n += tGetI32v(p + n, &pMapData->nData); @@ -821,16 +826,20 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest) { int32_t code = 0; int32_t size; + ASSERT(pColDataSrc->nVal > 0); + pColDataDest->cid = pColDataSrc->cid; pColDataDest->type = pColDataSrc->type; pColDataDest->smaOn = pColDataSrc->smaOn; pColDataDest->nVal = pColDataSrc->nVal; pColDataDest->flag = pColDataSrc->flag; - size = BIT2_SIZE(pColDataSrc->nVal); - code = tRealloc(&pColDataDest->pBitMap, size); - if (code) goto _exit; - memcpy(pColDataDest->pBitMap, pColDataSrc->pBitMap, size); + if (pColDataSrc->flag != HAS_NONE && pColDataSrc->flag != HAS_NULL && pColDataSrc->flag != HAS_VALUE) { + size = BIT2_SIZE(pColDataSrc->nVal); + code = tRealloc(&pColDataDest->pBitMap, size); + if (code) goto _exit; + memcpy(pColDataDest->pBitMap, pColDataSrc->pBitMap, size); + } if (IS_VAR_DATA_TYPE(pColDataDest->type)) { size = sizeof(int32_t) * pColDataSrc->nVal; @@ -1012,7 +1021,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS SColData *pColData; SColVal *pColVal; - ASSERT(nColData > 0); + if (nColData == 0) goto _exit; tRowIterInit(pIter, pRow, pTSchema); pColData = tBlockDataGetColDataByIdx(pBlockData, iColData); @@ -1042,6 +1051,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS } } +_exit: pBlockData->nRow++; return code; @@ -1230,10 +1240,26 @@ void tsdbCalcColDataSMA(SColData *pColData, SColumnDataAgg *pColAgg) { break; case TSDB_DATA_TYPE_SMALLINT: break; - case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_INT: { + pColAgg->sum += colVal.value.i32; + if (pColAgg->min > colVal.value.i32) { + pColAgg->min = colVal.value.i32; + } + if (pColAgg->max < colVal.value.i32) { + pColAgg->max = colVal.value.i32; + } break; - case TSDB_DATA_TYPE_BIGINT: + } + case TSDB_DATA_TYPE_BIGINT: { + pColAgg->sum += colVal.value.i64; + if (pColAgg->min > colVal.value.i64) { + pColAgg->min = colVal.value.i64; + } + if (pColAgg->max < colVal.value.i64) { + pColAgg->max = colVal.value.i64; + } break; + } case TSDB_DATA_TYPE_FLOAT: break; case TSDB_DATA_TYPE_DOUBLE: diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 21db14f0df..ed829666cd 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -223,6 +223,7 @@ int vnodeCommit(SVnode *pVnode) { // save info info.config = pVnode->config; info.state.committed = pVnode->state.applied; + info.state.commitTerm = pVnode->state.applyTerm; info.state.commitID = pVnode->state.commitID; snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path); if (vnodeSaveInfo(dir, &info) < 0) { @@ -270,7 +271,7 @@ int vnodeCommit(SVnode *pVnode) { ASSERT(0); return -1; } - + pVnode->state.committed = info.state.committed; // postCommit @@ -316,6 +317,7 @@ static int vnodeEncodeState(const void *pObj, SJson *pJson) { if (tjsonAddIntegerToObject(pJson, "commit version", pState->committed) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "commit ID", pState->commitID) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "commit term", pState->commitTerm) < 0) return -1; return 0; } @@ -328,6 +330,8 @@ static int vnodeDecodeState(const SJson *pJson, void *pObj) { if (code < 0) return -1; tjsonGetNumberValue(pJson, "commit ID", pState->commitID, code); if (code < 0) return -1; + tjsonGetNumberValue(pJson, "commit term", pState->commitTerm, code); + if (code < 0) return -1; return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeModule.c b/source/dnode/vnode/src/vnd/vnodeModule.c index d0aede145e..69f87a2c1a 100644 --- a/source/dnode/vnode/src/vnd/vnodeModule.c +++ b/source/dnode/vnode/src/vnd/vnodeModule.c @@ -100,6 +100,7 @@ void vnodeCleanup() { walCleanUp(); tqCleanUp(); + smaCleanUp(); } int vnodeScheduleTask(int (*execute)(void*), void* arg) { diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 4267dd9b1f..e59f8ae558 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -79,8 +79,10 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { strcpy(pVnode->path, path); pVnode->config = info.config; pVnode->state.committed = info.state.committed; + pVnode->state.commitTerm = info.state.commitTerm; pVnode->state.applied = info.state.committed; pVnode->state.commitID = info.state.commitID; + pVnode->state.commitTerm = info.state.commitTerm; pVnode->pTfs = pTfs; pVnode->msgCb = msgCb; pVnode->blockCount = 0; @@ -194,4 +196,9 @@ void vnodeStop(SVnode *pVnode) {} int64_t vnodeGetSyncHandle(SVnode *pVnode) { return pVnode->sync; } -void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot) { pSnapshot->lastApplyIndex = pVnode->state.committed; } +void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot) { + pSnapshot->data = NULL; + pSnapshot->lastApplyIndex = pVnode->state.committed; + pSnapshot->lastApplyTerm = pVnode->state.commitTerm; + pSnapshot->lastConfigIndex = -1; +} diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index baa8422307..27f30ec787 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -13,24 +13,27 @@ * along with this program. If not, see . */ -#include "vnodeInt.h" +#include "vnd.h" -struct SVSnapshotReader { - SVnode *pVnode; - int64_t sver; - int64_t ever; - int8_t isMetaEnd; - int8_t isTsdbEnd; - SMetaSnapshotReader *pMetaReader; - STsdbSnapshotReader *pTsdbReader; - void *pData; - int32_t nData; +// SVSnapReader ======================================================== +struct SVSnapReader { + SVnode *pVnode; + int64_t sver; + int64_t ever; + // meta + int8_t metaDone; + SMetaSnapReader *pMetaReader; + // tsdb + int8_t tsdbDone; + STsdbSnapReader *pTsdbReader; + uint8_t *pData; }; -int32_t vnodeSnapshotReaderOpen(SVnode *pVnode, SVSnapshotReader **ppReader, int64_t sver, int64_t ever) { - SVSnapshotReader *pReader = NULL; +int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader) { + int32_t code = 0; + SVSnapReader *pReader = NULL; - pReader = (SVSnapshotReader *)taosMemoryCalloc(1, sizeof(*pReader)); + pReader = (SVSnapReader *)taosMemoryCalloc(1, sizeof(*pReader)); if (pReader == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -38,72 +41,169 @@ int32_t vnodeSnapshotReaderOpen(SVnode *pVnode, SVSnapshotReader **ppReader, int pReader->pVnode = pVnode; pReader->sver = sver; pReader->ever = ever; - pReader->isMetaEnd = 0; - pReader->isTsdbEnd = 0; - if (metaSnapshotReaderOpen(pVnode->pMeta, &pReader->pMetaReader, sver, ever) < 0) { - taosMemoryFree(pReader); - goto _err; - } + code = metaSnapReaderOpen(pVnode->pMeta, sver, ever, &pReader->pMetaReader); + if (code) goto _err; - if (tsdbSnapshotReaderOpen(pVnode->pTsdb, &pReader->pTsdbReader, sver, ever) < 0) { - metaSnapshotReaderClose(pReader->pMetaReader); - taosMemoryFree(pReader); - goto _err; - } + code = tsdbSnapReaderOpen(pVnode->pTsdb, sver, ever, &pReader->pTsdbReader); + if (code) goto _err; -_exit: *ppReader = pReader; - return 0; + return code; _err: + vError("vgId:%d vnode snapshot reader open failed since %s", TD_VID(pVnode), tstrerror(code)); *ppReader = NULL; - return -1; + return code; } -int32_t vnodeSnapshotReaderClose(SVSnapshotReader *pReader) { - if (pReader) { - vnodeFree(pReader->pData); - tsdbSnapshotReaderClose(pReader->pTsdbReader); - metaSnapshotReaderClose(pReader->pMetaReader); - taosMemoryFree(pReader); - } - return 0; -} - -int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, const void **ppData, uint32_t *nData) { +int32_t vnodeSnapReaderClose(SVSnapReader *pReader) { int32_t code = 0; - if (!pReader->isMetaEnd) { - code = metaSnapshotRead(pReader->pMetaReader, &pReader->pData, &pReader->nData); + tFree(pReader->pData); + if (pReader->pTsdbReader) tsdbSnapReaderClose(&pReader->pTsdbReader); + if (pReader->pMetaReader) metaSnapReaderClose(&pReader->pMetaReader); + taosMemoryFree(pReader); + + return code; +} + +int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) { + int32_t code = 0; + + if (!pReader->metaDone) { + code = metaSnapRead(pReader->pMetaReader, &pReader->pData); if (code) { if (code == TSDB_CODE_VND_READ_END) { - pReader->isMetaEnd = 1; + pReader->metaDone = 1; } else { - return code; + goto _err; } } else { *ppData = pReader->pData; - *nData = pReader->nData; - return code; + *nData = sizeof(SSnapDataHdr) + ((SSnapDataHdr *)pReader->pData)->size; + goto _exit; } } - if (!pReader->isTsdbEnd) { - code = tsdbSnapshotRead(pReader->pTsdbReader, &pReader->pData, &pReader->nData); + if (!pReader->tsdbDone) { + code = tsdbSnapRead(pReader->pTsdbReader, &pReader->pData); if (code) { if (code == TSDB_CODE_VND_READ_END) { - pReader->isTsdbEnd = 1; + pReader->tsdbDone = 1; } else { - return code; + goto _err; } } else { *ppData = pReader->pData; - *nData = pReader->nData; - return code; + *nData = sizeof(SSnapDataHdr) + ((SSnapDataHdr *)pReader->pData)->size; + goto _exit; } } code = TSDB_CODE_VND_READ_END; + +_exit: + return code; + +_err: + vError("vgId:% snapshot read failed since %s", TD_VID(pReader->pVnode), tstrerror(code)); + return code; +} + +// SVSnapWriter ======================================================== +struct SVSnapWriter { + SVnode *pVnode; + int64_t sver; + int64_t ever; + // meta + SMetaSnapWriter *pMetaSnapWriter; + // tsdb + STsdbSnapWriter *pTsdbSnapWriter; +}; + +static int32_t vnodeSnapRollback(SVSnapWriter *pWriter) { + int32_t code = 0; + // TODO + return code; +} + +static int32_t vnodeSnapCommit(SVSnapWriter *pWriter) { + int32_t code = 0; + // TODO + return code; +} + +int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter) { + int32_t code = 0; + SVSnapWriter *pWriter = NULL; + + // alloc + pWriter = (SVSnapWriter *)taosMemoryCalloc(1, sizeof(*pWriter)); + if (pWriter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pWriter->pVnode = pVnode; + pWriter->sver = sver; + pWriter->ever = ever; + + return code; + +_err: + vError("vgId:%d vnode snapshot writer open failed since %s", TD_VID(pVnode), tstrerror(code)); + return code; +} + +int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback) { + int32_t code = 0; + + if (rollback) { + code = vnodeSnapRollback(pWriter); + if (code) goto _err; + } else { + code = vnodeSnapCommit(pWriter); + if (code) goto _err; + } + + taosMemoryFree(pWriter); + return code; + +_err: + vError("vgId:%d vnode snapshow writer close failed since %s", TD_VID(pWriter->pVnode), tstrerror(code)); + return code; +} + +int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) { + int32_t code = 0; + SSnapDataHdr *pSnapDataHdr = (SSnapDataHdr *)pData; + SVnode *pVnode = pWriter->pVnode; + + ASSERT(pSnapDataHdr->size + sizeof(SSnapDataHdr) == nData); + + if (pSnapDataHdr->type == 0) { + // meta + if (pWriter->pMetaSnapWriter == NULL) { + code = metaSnapWriterOpen(pVnode->pMeta, pWriter->sver, pWriter->ever, &pWriter->pMetaSnapWriter); + if (code) goto _err; + } + + code = metaSnapWrite(pWriter->pMetaSnapWriter, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr)); + if (code) goto _err; + } else { + // tsdb + if (pWriter->pTsdbSnapWriter == NULL) { + code = tsdbSnapWriterOpen(pVnode->pTsdb, pWriter->sver, pWriter->ever, &pWriter->pTsdbSnapWriter); + if (code) goto _err; + } + + code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr)); + if (code) goto _err; + } + + return code; + +_err: + vError("vgId:%d vnode snapshot write failed since %s", TD_VID(pVnode), tstrerror(code)); return code; } \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeStateMgr.c b/source/dnode/vnode/src/vnd/vnodeStateMgr.c deleted file mode 100644 index 6dea4a4e57..0000000000 --- a/source/dnode/vnode/src/vnd/vnodeStateMgr.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index bceac024bc..dceeb4c282 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -143,6 +143,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp version); pVnode->state.applied = version; + pVnode->state.applyTerm = pMsg->info.conn.applyTerm; // skip header pReq = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); @@ -296,7 +297,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { case TDMT_SCH_MERGE_FETCH: return qWorkerProcessFetchMsg(pVnode, pVnode->pQuery, pMsg, 0); case TDMT_SCH_FETCH_RSP: - return qWorkerProcessFetchRsp(pVnode, pVnode->pQuery, pMsg, 0); + return qWorkerProcessRspMsg(pVnode, pVnode->pQuery, pMsg, 0); case TDMT_SCH_CANCEL_TASK: return qWorkerProcessCancelMsg(pVnode, pVnode->pQuery, pMsg, 0); case TDMT_SCH_DROP_TASK: diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index f75ccba4bb..8d0ae4785b 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -338,12 +338,12 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { } else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) { SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg); ASSERT(pSyncMsg != NULL); - code = syncNodeOnRequestVoteCb(pSyncNode, pSyncMsg); + code = syncNodeOnRequestVoteSnapshotCb(pSyncNode, pSyncMsg); syncRequestVoteDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE_REPLY) { SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pMsg); ASSERT(pSyncMsg != NULL); - code = syncNodeOnRequestVoteReplyCb(pSyncNode, pSyncMsg); + code = syncNodeOnRequestVoteReplySnapshotCb(pSyncNode, pSyncMsg); syncRequestVoteReplyDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_APPEND_ENTRIES_BATCH) { SyncAppendEntriesBatch *pSyncMsg = syncAppendEntriesBatchFromRpcMsg2(pMsg); @@ -355,6 +355,14 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { ASSERT(pSyncMsg != NULL); code = syncNodeOnAppendEntriesReplySnapshot2Cb(pSyncNode, pSyncMsg); syncAppendEntriesReplyDestroy(pSyncMsg); + } else if (pMsg->msgType == TDMT_SYNC_SNAPSHOT_SEND) { + SyncSnapshotSend *pSyncMsg = syncSnapshotSendFromRpcMsg2(pMsg); + code = syncNodeOnSnapshotSendCb(pSyncNode, pSyncMsg); + syncSnapshotSendDestroy(pSyncMsg); + } else if (pMsg->msgType == TDMT_SYNC_SNAPSHOT_RSP) { + SyncSnapshotRsp *pSyncMsg = syncSnapshotRspFromRpcMsg2(pMsg); + code = syncNodeOnSnapshotRspCb(pSyncNode, pSyncMsg); + syncSnapshotRspDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_SET_VNODE_STANDBY) { code = vnodeSetStandBy(pVnode); if (code != 0 && terrno != 0) code = terrno; @@ -415,7 +423,7 @@ static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReCon static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { SVnode *pVnode = pFsm->data; - vTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", + vTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType)); @@ -430,14 +438,14 @@ static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta c static void vnodeSyncPreCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { SVnode *pVnode = pFsm->data; - vTrace("vgId:%d, pre-commit-cb is excuted, fsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", + vTrace("vgId:%d, pre-commit-cb is excuted, fsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType)); } static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { SVnode *pVnode = pFsm->data; - vTrace("vgId:%d, rollback-cb is excuted, fsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", + vTrace("vgId:%d, rollback-cb is excuted, fsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, msgtype:%d %s", syncGetVgId(pVnode->sync), pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), pMsg->msgType, TMSG_INFO(pMsg->msgType)); } @@ -445,28 +453,40 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta static int32_t vnodeSnapshotStartRead(struct SSyncFSM *pFsm, void *pParam, void **ppReader) { SVnode *pVnode = pFsm->data; SSnapshotParam *pSnapshotParam = pParam; - int32_t code = - vnodeSnapshotReaderOpen(pVnode, (SVSnapshotReader **)ppReader, pSnapshotParam->start, pSnapshotParam->end); + int32_t code = vnodeSnapReaderOpen(pVnode, pSnapshotParam->start, pSnapshotParam->end, (SVSnapReader **)ppReader); return code; } static int32_t vnodeSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { SVnode *pVnode = pFsm->data; - int32_t code = vnodeSnapshotReaderClose(pReader); + int32_t code = vnodeSnapReaderClose(pReader); return code; } static int32_t vnodeSnapshotDoRead(struct SSyncFSM *pFsm, void *pReader, void **ppBuf, int32_t *len) { SVnode *pVnode = pFsm->data; - int32_t code = vnodeSnapshotRead(pReader, (const void **)ppBuf, len); + int32_t code = vnodeSnapRead(pReader, (uint8_t **)ppBuf, len); return code; } -static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWriter) { return 0; } +static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void **ppWriter) { + SVnode *pVnode = pFsm->data; + SSnapshotParam *pSnapshotParam = pParam; + int32_t code = vnodeSnapWriterOpen(pVnode, pSnapshotParam->start, pSnapshotParam->end, (SVSnapWriter **)ppWriter); + return code; +} -static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) { return 0; } +static int32_t vnodeSnapshotStopWrite(struct SSyncFSM *pFsm, void *pWriter, bool isApply) { + SVnode *pVnode = pFsm->data; + int32_t code = vnodeSnapWriterClose(pWriter, isApply); + return code; +} -static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { return 0; } +static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *pBuf, int32_t len) { + SVnode *pVnode = pFsm->data; + int32_t code = vnodeSnapWrite(pWriter, pBuf, len); + return code; +} static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM)); diff --git a/source/dnode/vnode/src/vnd/vnodeUtil.c b/source/dnode/vnode/src/vnd/vnodeUtil.c deleted file mode 100644 index cd942099bc..0000000000 --- a/source/dnode/vnode/src/vnd/vnodeUtil.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "vnd.h" - -int32_t vnodeRealloc(void** pp, int32_t size) { - uint8_t* p = NULL; - int32_t csize = 0; - - if (*pp) { - p = (uint8_t*)(*pp) - sizeof(int32_t); - csize = *(int32_t*)p; - } - - if (csize >= size) { - return 0; - } - - p = (uint8_t*)taosMemoryRealloc(p, size); - if (p == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - *(int32_t*)p = size; - *pp = p + sizeof(int32_t); - - return 0; -} - -void vnodeFree(void* p) { - if (p) { - taosMemoryFree(((uint8_t*)p) - sizeof(int32_t)); - } -} \ No newline at end of file diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c index 9195747bee..bd3402dc39 100644 --- a/source/libs/catalog/src/ctgDbg.c +++ b/source/libs/catalog/src/ctgDbg.c @@ -64,7 +64,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { qDebug("db %d vgInfo:", i); for (int32_t j = 0; j < vgNum; ++j) { SVgroupInfo* pInfo = taosArrayGet(pDb, j); - qDebug("vg %d info: vgId:%d", j, pInfo->vgId); + qDebug("vg :%d info: vgId:%d", j, pInfo->vgId); } } } else { diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index 21e78d4925..ad73fe40d2 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -731,7 +731,7 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName *pVgroup = *vgInfo; - ctgDebug("Got tb %s hash vgroup, vgId %d, epNum %d, current %s port %d", tbFullName, vgInfo->vgId, vgInfo->epSet.numOfEps, + ctgDebug("Got tb %s hash vgroup, vgId:%d, epNum %d, current %s port %d", tbFullName, vgInfo->vgId, vgInfo->epSet.numOfEps, vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port); CTG_RET(code); diff --git a/source/libs/executor/inc/dataSinkInt.h b/source/libs/executor/inc/dataSinkInt.h index dead1aff73..9426c99a0f 100644 --- a/source/libs/executor/inc/dataSinkInt.h +++ b/source/libs/executor/inc/dataSinkInt.h @@ -34,7 +34,7 @@ typedef struct SDataSinkManager { typedef int32_t (*FPutDataBlock)(struct SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue); typedef void (*FEndPut)(struct SDataSinkHandle* pHandle, uint64_t useconds); -typedef void (*FGetDataLength)(struct SDataSinkHandle* pHandle, int32_t* pLen, bool* pQueryEnd); +typedef void (*FGetDataLength)(struct SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryEnd); typedef int32_t (*FGetDataBlock)(struct SDataSinkHandle* pHandle, SOutputData* pOutput); typedef int32_t (*FDestroyDataSinker)(struct SDataSinkHandle* pHandle); typedef int32_t (*FGetCacheSize)(struct SDataSinkHandle* pHandle, uint64_t* size); @@ -50,6 +50,7 @@ typedef struct SDataSinkHandle { int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle); int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void *pParam); +int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void *pParam); #ifdef __cplusplus } diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 3488069925..82387119b6 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -51,13 +51,12 @@ typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int #define NEEDTO_COMPRESS_QUERY(size) ((size) > tsCompressColData ? 1 : 0) -#define START_TS_COLUMN_INDEX 0 -#define END_TS_COLUMN_INDEX 1 -#define UID_COLUMN_INDEX 2 -#define GROUPID_COLUMN_INDEX UID_COLUMN_INDEX +#define START_TS_COLUMN_INDEX 0 +#define END_TS_COLUMN_INDEX 1 +#define UID_COLUMN_INDEX 2 +#define GROUPID_COLUMN_INDEX UID_COLUMN_INDEX #define DELETE_GROUPID_COLUMN_INDEX 2 - enum { // when this task starts to execute, this status will set TASK_NOT_COMPLETED = 0x1u, @@ -81,8 +80,8 @@ typedef struct SResultInfo { // TODO refactor } SResultInfo; typedef struct STableQueryInfo { - TSKEY lastKey; // last check ts, todo remove it later - SResultRowPosition pos; // current active time window + TSKEY lastKey; // last check ts, todo remove it later + SResultRowPosition pos; // current active time window } STableQueryInfo; typedef struct SLimit { @@ -105,7 +104,7 @@ typedef struct STaskCostInfo { uint64_t loadDataTime; SFileBlockLoadRecorder* pRecoder; - uint64_t elapsedTime; + uint64_t elapsedTime; uint64_t firstStageMergeTime; uint64_t winInfoSize; @@ -118,8 +117,8 @@ typedef struct STaskCostInfo { } STaskCostInfo; typedef struct SOperatorCostInfo { - double openCost; - double totalCost; + double openCost; + double totalCost; } SOperatorCostInfo; struct SOperatorInfo; @@ -139,24 +138,35 @@ typedef struct STaskIdInfo { char* str; } STaskIdInfo; +typedef struct { + STqOffsetVal prepareStatus; // for tmq + STqOffsetVal lastStatus; // for tmq + void* metaBlk; // for tmq fetching meta + SSDataBlock* pullOverBlk; // for streaming + SWalFilterCond cond; +} SStreamTaskInfo; + typedef struct SExecTaskInfo { - STaskIdInfo id; - uint32_t status; - STimeWindow window; - STaskCostInfo cost; - int64_t owner; // if it is in execution - int32_t code; + STaskIdInfo id; + uint32_t status; + STimeWindow window; + STaskCostInfo cost; + int64_t owner; // if it is in execution + int32_t code; + + SStreamTaskInfo streamInfo; + struct { - char *tablename; - char *dbname; - int32_t tversion; - SSchemaWrapper*sw; + char* tablename; + char* dbname; + int32_t tversion; + SSchemaWrapper* sw; } schemaVer; - STableListInfo tableqinfoList; // this is a table list - const char* sql; // query sql string - jmp_buf env; // jump to this position when error happens. - EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] + STableListInfo tableqinfoList; // this is a table list + const char* sql; // query sql string + jmp_buf env; // jump to this position when error happens. + EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] struct SOperatorInfo* pRoot; } SExecTaskInfo; @@ -168,36 +178,36 @@ enum { }; typedef struct SOperatorFpSet { - __optr_open_fn_t _openFn; // DO NOT invoke this function directly - __optr_fn_t getNextFn; - __optr_fn_t getStreamResFn; // execute the aggregate in the stream model, todo remove it - __optr_fn_t cleanupFn; // call this function to release the allocated resources ASAP - __optr_close_fn_t closeFn; - __optr_encode_fn_t encodeResultRow; - __optr_decode_fn_t decodeResultRow; - __optr_explain_fn_t getExplainFn; + __optr_open_fn_t _openFn; // DO NOT invoke this function directly + __optr_fn_t getNextFn; + __optr_fn_t getStreamResFn; // execute the aggregate in the stream model, todo remove it + __optr_fn_t cleanupFn; // call this function to release the allocated resources ASAP + __optr_close_fn_t closeFn; + __optr_encode_fn_t encodeResultRow; + __optr_decode_fn_t decodeResultRow; + __optr_explain_fn_t getExplainFn; } SOperatorFpSet; typedef struct SExprSupp { SExprInfo* pExprInfo; - int32_t numOfExprs; // the number of scalar expression in group operator + int32_t numOfExprs; // the number of scalar expression in group operator SqlFunctionCtx* pCtx; int32_t* rowEntryInfoOffset; // offset value for each row result cell info } SExprSupp; typedef struct SOperatorInfo { - uint8_t operatorType; - bool blocking; // block operator or not - uint8_t status; // denote if current operator is completed - char* name; // name, for debug purpose - void* info; // extension attribution - SExprSupp exprSupp; - SExecTaskInfo* pTaskInfo; - SOperatorCostInfo cost; - SResultInfo resultInfo; - struct SOperatorInfo** pDownstream; // downstram pointer list - int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator - SOperatorFpSet fpSet; + uint8_t operatorType; + bool blocking; // block operator or not + uint8_t status; // denote if current operator is completed + char* name; // name, for debug purpose + void* info; // extension attribution + SExprSupp exprSupp; + SExecTaskInfo* pTaskInfo; + SOperatorCostInfo cost; + SResultInfo resultInfo; + struct SOperatorInfo** pDownstream; // downstram pointer list + int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator + SOperatorFpSet fpSet; } SOperatorInfo; typedef enum { @@ -210,12 +220,12 @@ typedef enum { #define COL_MATCH_FROM_SLOT_ID 0x2 typedef struct SSourceDataInfo { - int32_t index; - SRetrieveTableRsp* pRsp; - uint64_t totalRows; - int32_t code; - EX_SOURCE_STATUS status; - const char* taskId; + int32_t index; + SRetrieveTableRsp* pRsp; + uint64_t totalRows; + int32_t code; + EX_SOURCE_STATUS status; + const char* taskId; } SSourceDataInfo; typedef struct SLoadRemoteDataInfo { @@ -325,10 +335,10 @@ typedef enum EStreamScanMode { } EStreamScanMode; typedef struct SCatchSupporter { - SHashObj* pWindowHashTable; // quick locate the window object for each window - SDiskbasedBuf* pDataBuf; // buffer based on blocked-wised disk file - int32_t keySize; - int64_t* pKeyBuf; + SHashObj* pWindowHashTable; // quick locate the window object for each window + SDiskbasedBuf* pDataBuf; // buffer based on blocked-wised disk file + int32_t keySize; + int64_t* pKeyBuf; } SCatchSupporter; typedef struct SStreamAggSupporter { @@ -344,48 +354,48 @@ typedef struct SStreamAggSupporter { typedef struct SessionWindowSupporter { SStreamAggSupporter* pStreamAggSup; - int64_t gap; - uint8_t parentType; + int64_t gap; + uint8_t parentType; } SessionWindowSupporter; typedef struct SStreamScanInfo { - uint64_t tableUid; // queried super table uid - SExprInfo* pPseudoExpr; - int32_t numOfPseudoExpr; - int32_t primaryTsIndex; // primary time stamp slot id - SReadHandle readHandle; - SInterval interval; // if the upstream is an interval operator, the interval info is also kept here. - SArray* pColMatchInfo; // - SNode* pCondition; + uint64_t tableUid; // queried super table uid + SExprInfo* pPseudoExpr; + int32_t numOfPseudoExpr; + int32_t primaryTsIndex; // primary time stamp slot id + SReadHandle readHandle; + SInterval interval; // if the upstream is an interval operator, the interval info is also kept here. + SArray* pColMatchInfo; // + SNode* pCondition; - SArray* pBlockLists; // multiple SSDatablock. - SSDataBlock* pRes; // result SSDataBlock - SSDataBlock* pUpdateRes; // update SSDataBlock - int32_t updateResIndex; - int32_t blockType; // current block type - int32_t validBlockIndex; // Is current data has returned? - uint64_t numOfExec; // execution times - STqReader* tqReader; + SArray* pBlockLists; // multiple SSDatablock. + SSDataBlock* pRes; // result SSDataBlock + SSDataBlock* pUpdateRes; // update SSDataBlock + int32_t updateResIndex; + int32_t blockType; // current block type + int32_t validBlockIndex; // Is current data has returned? + uint64_t numOfExec; // execution times + STqReader* tqReader; - int32_t tsArrayIndex; - SArray* tsArray; - uint64_t groupId; - SUpdateInfo* pUpdateInfo; + int32_t tsArrayIndex; + SArray* tsArray; + uint64_t groupId; + SUpdateInfo* pUpdateInfo; - EStreamScanMode scanMode; - SOperatorInfo* pStreamScanOp; - SOperatorInfo* pTableScanOp; - SArray* childIds; + EStreamScanMode scanMode; + SOperatorInfo* pStreamScanOp; + SOperatorInfo* pTableScanOp; + SArray* childIds; SessionWindowSupporter sessionSup; - bool assignBlockUid; // assign block uid to groupId, temporarily used for generating rollup SMA. - int32_t scanWinIndex; // for state operator - int32_t pullDataResIndex; - SSDataBlock* pPullDataRes; // pull data SSDataBlock - SSDataBlock* pDeleteDataRes; // delete data SSDataBlock - int32_t deleteDataIndex; + bool assignBlockUid; // assign block uid to groupId, temporarily used for generating rollup SMA. + int32_t scanWinIndex; // for state operator + int32_t pullDataResIndex; + SSDataBlock* pPullDataRes; // pull data SSDataBlock + SSDataBlock* pDeleteDataRes; // delete data SSDataBlock + int32_t deleteDataIndex; // status for tmq - //SSchemaWrapper schema; + // SSchemaWrapper schema; STqOffset offset; } SStreamScanInfo; @@ -445,7 +455,6 @@ typedef struct SIntervalAggOperatorInfo { int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator. STimeWindow win; // query time range bool timeWindowInterpo; // interpolation needed or not - char** pRow; // previous row/tuple of already processed datablock SArray* pInterpCols; // interpolation columns int32_t order; // current SSDataBlock scan order EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] @@ -595,7 +604,7 @@ typedef struct SSessionAggOperatorInfo { int64_t gap; // session window gap int32_t tsSlotId; // primary timestamp slot id STimeWindowAggSupp twAggSup; - SNode *pCondition; + const SNode* pCondition; } SSessionAggOperatorInfo; typedef struct SResultWindowInfo { @@ -657,7 +666,7 @@ typedef struct SStateWindowOperatorInfo { int32_t tsSlotId; // primary timestamp column slot id STimeWindowAggSupp twAggSup; // bool reptScan; - const SNode *pCondition; + const SNode* pCondition; } SStateWindowOperatorInfo; typedef struct SStreamStateAggOperatorInfo { @@ -806,7 +815,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId, - SExecTaskInfo* pTaskInfo); + SNode* pCondition, SExecTaskInfo* pTaskInfo); SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, int32_t numOfChild); @@ -885,7 +894,7 @@ int32_t decodeOperator(SOperatorInfo* ops, const char* data, int32_t length); void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, const char* sql, EOPTR_EXEC_MODEL model); -int32_t createDataSinkParam(SDataSinkNode *pNode, void **pParam, qTaskInfo_t* pTaskInfo); +int32_t createDataSinkParam(SDataSinkNode *pNode, void **pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle); int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo** pRes, int32_t* capacity, int32_t* resNum); @@ -893,7 +902,7 @@ int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result); int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* length); STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, - int32_t precision, STimeWindow* win); + int32_t precision, int32_t order); int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey, __block_search_fn_t searchFn, STableQueryInfo* item, int32_t order); int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order); diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index 8c220134f0..3c56abbd15 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -154,7 +154,7 @@ static void endPut(struct SDataSinkHandle* pHandle, uint64_t useconds) { taosThreadMutexUnlock(&pDeleter->mutex); } -static void getDataLength(SDataSinkHandle* pHandle, int32_t* pLen, bool* pQueryEnd) { +static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryEnd) { SDataDeleterHandle* pDeleter = (SDataDeleterHandle*)pHandle; if (taosQueueEmpty(pDeleter->pDataBlocks)) { *pQueryEnd = pDeleter->queryEnd; @@ -168,7 +168,7 @@ static void getDataLength(SDataSinkHandle* pHandle, int32_t* pLen, bool* pQueryE taosFreeQitem(pBuf); *pLen = ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->dataLen; *pQueryEnd = pDeleter->queryEnd; - qDebug("got data len %d, row num %d in sink", *pLen, ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->numOfRows); + qDebug("got data len %" PRId64 ", row num %d in sink", *pLen, ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->numOfRows); } static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) { diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index 5ee222efb7..b8495faffd 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -156,7 +156,7 @@ static void endPut(struct SDataSinkHandle* pHandle, uint64_t useconds) { taosThreadMutexUnlock(&pDispatcher->mutex); } -static void getDataLength(SDataSinkHandle* pHandle, int32_t* pLen, bool* pQueryEnd) { +static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryEnd) { SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle; if (taosQueueEmpty(pDispatcher->pDataBlocks)) { *pQueryEnd = pDispatcher->queryEnd; @@ -170,7 +170,7 @@ static void getDataLength(SDataSinkHandle* pHandle, int32_t* pLen, bool* pQueryE taosFreeQitem(pBuf); *pLen = ((SDataCacheEntry*)(pDispatcher->nextOutput.pData))->dataLen; *pQueryEnd = pDispatcher->queryEnd; - qDebug("got data len %d, row num %d in sink", *pLen, ((SDataCacheEntry*)(pDispatcher->nextOutput.pData))->numOfRows); + qDebug("got data len %" PRId64 ", row num %d in sink", *pLen, ((SDataCacheEntry*)(pDispatcher->nextOutput.pData))->numOfRows); } static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) { diff --git a/source/libs/executor/src/dataInserter.c b/source/libs/executor/src/dataInserter.c index c424cb33fa..e53c9fae6f 100644 --- a/source/libs/executor/src/dataInserter.c +++ b/source/libs/executor/src/dataInserter.c @@ -24,195 +24,266 @@ extern SDataSinkStat gDataSinkStat; -typedef struct SDataInserterBuf { - int32_t useSize; - int32_t allocSize; - char* pData; -} SDataInserterBuf; - -typedef struct SDataCacheEntry { - int32_t dataLen; - int32_t numOfRows; - int32_t numOfCols; - int8_t compressed; - char data[]; -} SDataCacheEntry; +typedef struct SSubmitRes { + int64_t affectedRows; + int32_t code; + SSubmitRsp *pRsp; +} SSubmitRes; typedef struct SDataInserterHandle { SDataSinkHandle sink; SDataSinkManager* pManager; - SDataBlockDescNode* pSchema; - SDataDeleterNode* pDeleter; - SDeleterParam* pParam; - STaosQueue* pDataBlocks; - SDataInserterBuf nextOutput; + STSchema* pSchema; + SQueryInserterNode* pNode; + SSubmitRes submitRes; + SInserterParam* pParam; + SArray* pDataBlocks; + SHashObj* pCols; int32_t status; bool queryEnd; uint64_t useconds; uint64_t cachedSize; TdThreadMutex mutex; + tsem_t ready; } SDataInserterHandle; -static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) { - if (tsCompressColData < 0 || 0 == pData->info.rows) { - return false; - } +typedef struct SSubmitRspParam { + SDataInserterHandle* pInserter; +} SSubmitRspParam; - for (int32_t col = 0; col < numOfCols; ++col) { - SColumnInfoData* pColRes = taosArrayGet(pData->pDataBlock, col); - int32_t colSize = pColRes->info.bytes * pData->info.rows; - if (NEEDTO_COMPRESS_QUERY(colSize)) { - return true; - } - } +int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) { + SSubmitRspParam* pParam = (SSubmitRspParam*)param; + SDataInserterHandle* pInserter = pParam->pInserter; - return false; -} - -static void toDataCacheEntry(SDataInserterHandle* pHandle, const SInputData* pInput, SDataInserterBuf* pBuf) { - int32_t numOfCols = LIST_LENGTH(pHandle->pSchema->pSlots); - - SDataCacheEntry* pEntry = (SDataCacheEntry*)pBuf->pData; - pEntry->compressed = 0; - pEntry->numOfRows = pInput->pData->info.rows; - pEntry->numOfCols = taosArrayGetSize(pInput->pData->pDataBlock); - pEntry->dataLen = sizeof(SDeleterRes); - - ASSERT(1 == pEntry->numOfRows); - ASSERT(1 == pEntry->numOfCols); - - pBuf->useSize = sizeof(SDataCacheEntry); - - SColumnInfoData* pColRes = (SColumnInfoData*)taosArrayGet(pInput->pData->pDataBlock, 0); - - SDeleterRes* pRes = (SDeleterRes*)pEntry->data; - pRes->suid = pHandle->pParam->suid; - pRes->uidList = pHandle->pParam->pUidList; - pRes->skey = pHandle->pDeleter->deleteTimeRange.skey; - pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey; - pRes->affectedRows = *(int64_t*)pColRes->pData; - - pBuf->useSize += pEntry->dataLen; + pInserter->submitRes.code = code; - atomic_add_fetch_64(&pHandle->cachedSize, pEntry->dataLen); - atomic_add_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen); -} + if (code == TSDB_CODE_SUCCESS) { + pInserter->submitRes.pRsp = taosMemoryCalloc(1, sizeof(SSubmitRsp)); + SDecoder coder = {0}; + tDecoderInit(&coder, pMsg->pData, pMsg->len); + code = tDecodeSSubmitRsp(&coder, pInserter->submitRes.pRsp); + if (code) { + tFreeSSubmitRsp(pInserter->submitRes.pRsp); + pInserter->submitRes.code = code; + goto _return; + } + + if (pInserter->submitRes.pRsp->nBlocks > 0) { + for (int32_t i = 0; i < pInserter->submitRes.pRsp->nBlocks; ++i) { + SSubmitBlkRsp *blk = pInserter->submitRes.pRsp->pBlocks + i; + if (TSDB_CODE_SUCCESS != blk->code) { + code = blk->code; + tFreeSSubmitRsp(pInserter->submitRes.pRsp); + pInserter->submitRes.code = code; + goto _return; + } + } + } + + pInserter->submitRes.affectedRows += pInserter->submitRes.pRsp->affectedRows; + qDebug("submit rsp received, affectedRows:%d, total:%d", pInserter->submitRes.pRsp->affectedRows, pInserter->submitRes.affectedRows); -static bool allocBuf(SDataInserterHandle* pDeleter, const SInputData* pInput, SDataInserterBuf* pBuf) { - uint32_t capacity = pDeleter->pManager->cfg.maxDataBlockNumPerQuery; - if (taosQueueItemSize(pDeleter->pDataBlocks) > capacity) { - qError("SinkNode queue is full, no capacity, max:%d, current:%d, no capacity", capacity, - taosQueueItemSize(pDeleter->pDataBlocks)); - return false; + tFreeSSubmitRsp(pInserter->submitRes.pRsp); } - pBuf->allocSize = sizeof(SDataCacheEntry) + sizeof(SDeleterRes); +_return: - pBuf->pData = taosMemoryMalloc(pBuf->allocSize); - if (pBuf->pData == NULL) { - qError("SinkNode failed to malloc memory, size:%d, code:%d", pBuf->allocSize, TAOS_SYSTEM_ERROR(errno)); + tsem_post(&pInserter->ready); + + taosMemoryFree(param); + + return TSDB_CODE_SUCCESS; +} + + +static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMsg, void* pTransporter, SEpSet* pEpset) { + // send the fetch remote task result reques + SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); + if (NULL == pMsgSendInfo) { + taosMemoryFreeClear(pMsg); + terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + return terrno; } - return NULL != pBuf->pData; + SSubmitRspParam* pParam = taosMemoryCalloc(1, sizeof(SSubmitRspParam)); + pParam->pInserter = pInserter; + + pMsgSendInfo->param = pParam; + pMsgSendInfo->msgInfo.pData = pMsg; + pMsgSendInfo->msgInfo.len = ntohl(pMsg->length); + pMsgSendInfo->msgType = TDMT_VND_SUBMIT; + pMsgSendInfo->fp = inserterCallback; + + int64_t transporterId = 0; + return asyncSendMsgToServer(pTransporter, pEpset, &transporterId, pMsgSendInfo); } -static int32_t updateStatus(SDataInserterHandle* pDeleter) { - taosThreadMutexLock(&pDeleter->mutex); - int32_t blockNums = taosQueueItemSize(pDeleter->pDataBlocks); - int32_t status = - (0 == blockNums ? DS_BUF_EMPTY - : (blockNums < pDeleter->pManager->cfg.maxDataBlockNumPerQuery ? DS_BUF_LOW : DS_BUF_FULL)); - pDeleter->status = status; - taosThreadMutexUnlock(&pDeleter->mutex); - return status; + +int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { + const SArray* pBlocks = pInserter->pDataBlocks; + const STSchema* pTSchema = pInserter->pSchema; + int64_t uid = pInserter->pNode->tableId; + int64_t suid = pInserter->pNode->stableId; + int32_t vgId = pInserter->pNode->vgId; + bool fullCol = (pInserter->pNode->pCols->length == pTSchema->numOfCols); + + SSubmitReq* ret = NULL; + int32_t sz = taosArrayGetSize(pBlocks); + + // cal size + int32_t cap = sizeof(SSubmitReq); + for (int32_t i = 0; i < sz; i++) { + SSDataBlock* pDataBlock = taosArrayGetP(pBlocks, i); + int32_t rows = pDataBlock->info.rows; + // TODO min + int32_t rowSize = pDataBlock->info.rowSize; + int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema); + + cap += sizeof(SSubmitBlk) + rows * maxLen; + } + + // assign data + // TODO + ret = taosMemoryCalloc(1, cap); + ret->header.vgId = htonl(vgId); + ret->version = htonl(pTSchema->version); + ret->length = sizeof(SSubmitReq); + ret->numOfBlocks = htonl(sz); + + SSubmitBlk* blkHead = POINTER_SHIFT(ret, sizeof(SSubmitReq)); + for (int32_t i = 0; i < sz; i++) { + SSDataBlock* pDataBlock = taosArrayGetP(pBlocks, i); + + blkHead->sversion = htonl(pTSchema->version); + // TODO + blkHead->suid = htobe64(suid); + blkHead->uid = htobe64(uid); + blkHead->schemaLen = htonl(0); + + int32_t rows = 0; + int32_t dataLen = 0; + STSRow* rowData = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk)); + int64_t lastTs = TSKEY_MIN; + bool ignoreRow = false; + for (int32_t j = 0; j < pDataBlock->info.rows; j++) { + SRowBuilder rb = {0}; + tdSRowInit(&rb, pTSchema->version); + tdSRowSetTpInfo(&rb, pTSchema->numOfCols, pTSchema->flen); + tdSRowResetBuf(&rb, rowData); + + ignoreRow = false; + for (int32_t k = 0; k < pTSchema->numOfCols; k++) { + const STColumn* pColumn = &pTSchema->columns[k]; + SColumnInfoData* pColData = NULL; + int16_t colIdx = k; + if (!fullCol) { + int16_t *slotId = taosHashGet(pInserter->pCols, &pColumn->colId, sizeof(pColumn->colId)); + if (NULL == slotId) { + continue; + } + + colIdx = *slotId; + } + + pColData = taosArrayGet(pDataBlock->pDataBlock, colIdx); + if (pColData->info.type != pColumn->type) { + qError("col type mis-match, schema type:%d, type in block:%d", pColumn->type, pColData->info.type); + terrno = TSDB_CODE_APP_ERROR; + return TSDB_CODE_APP_ERROR; + } + + if (colDataIsNull_s(pColData, j)) { + if (0 == k && TSDB_DATA_TYPE_TIMESTAMP == pColumn->type) { + ignoreRow = true; + break; + } + + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, pColumn->offset, k); + } else { + void* data = colDataGetData(pColData, j); + if (0 == k && TSDB_DATA_TYPE_TIMESTAMP == pColumn->type) { + if (*(int64_t*)data == lastTs) { + ignoreRow = true; + break; + } else { + lastTs = *(int64_t*)data; + } + } + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k); + } + } + + if (ignoreRow) { + continue; + } + + rows++; + int32_t rowLen = TD_ROW_LEN(rowData); + rowData = POINTER_SHIFT(rowData, rowLen); + dataLen += rowLen; + } + + blkHead->dataLen = htonl(dataLen); + blkHead->numOfRows = htons(rows); + + ret->length += sizeof(SSubmitBlk) + dataLen; + blkHead = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk) + dataLen); + } + + ret->length = htonl(ret->length); + + *pReq = ret; + + return TSDB_CODE_SUCCESS; } -static int32_t getStatus(SDataInserterHandle* pDeleter) { - taosThreadMutexLock(&pDeleter->mutex); - int32_t status = pDeleter->status; - taosThreadMutexUnlock(&pDeleter->mutex); - return status; -} static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) { - SDataInserterHandle* pDeleter = (SDataInserterHandle*)pHandle; - SDataInserterBuf* pBuf = taosAllocateQitem(sizeof(SDataInserterBuf), DEF_QITEM); - if (NULL == pBuf || !allocBuf(pDeleter, pInput, pBuf)) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + SDataInserterHandle* pInserter = (SDataInserterHandle*)pHandle; + taosArrayPush(pInserter->pDataBlocks, &pInput->pData); + SSubmitReq* pMsg = NULL; + int32_t code = dataBlockToSubmit(pInserter, &pMsg); + if (code) { + return code; } - toDataCacheEntry(pDeleter, pInput, pBuf); - taosWriteQitem(pDeleter->pDataBlocks, pBuf); - *pContinue = (DS_BUF_LOW == updateStatus(pDeleter) ? true : false); + + code = sendSubmitRequest(pInserter, pMsg, pInserter->pParam->readHandle->pMsgCb->clientRpc, &pInserter->pNode->epSet); + if (code) { + return code; + } + + tsem_wait(&pInserter->ready); + + if (pInserter->submitRes.code) { + return pInserter->submitRes.code; + } + + *pContinue = true; + return TSDB_CODE_SUCCESS; } static void endPut(struct SDataSinkHandle* pHandle, uint64_t useconds) { - SDataInserterHandle* pDeleter = (SDataInserterHandle*)pHandle; - taosThreadMutexLock(&pDeleter->mutex); - pDeleter->queryEnd = true; - pDeleter->useconds = useconds; - taosThreadMutexUnlock(&pDeleter->mutex); + SDataInserterHandle* pInserter = (SDataInserterHandle*)pHandle; + taosThreadMutexLock(&pInserter->mutex); + pInserter->queryEnd = true; + pInserter->useconds = useconds; + taosThreadMutexUnlock(&pInserter->mutex); } -static void getDataLength(SDataSinkHandle* pHandle, int32_t* pLen, bool* pQueryEnd) { - SDataInserterHandle* pDeleter = (SDataInserterHandle*)pHandle; - if (taosQueueEmpty(pDeleter->pDataBlocks)) { - *pQueryEnd = pDeleter->queryEnd; - *pLen = 0; - return; - } - - SDataInserterBuf* pBuf = NULL; - taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf); - memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataInserterBuf)); - taosFreeQitem(pBuf); - *pLen = ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->dataLen; - *pQueryEnd = pDeleter->queryEnd; - qDebug("got data len %d, row num %d in sink", *pLen, ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->numOfRows); +static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryEnd) { + SDataInserterHandle* pDispatcher = (SDataInserterHandle*)pHandle; + *pLen = pDispatcher->submitRes.affectedRows; + qDebug("got total affectedRows %" PRId64 , *pLen); } -static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) { - SDataInserterHandle* pDeleter = (SDataInserterHandle*)pHandle; - if (NULL == pDeleter->nextOutput.pData) { - assert(pDeleter->queryEnd); - pOutput->useconds = pDeleter->useconds; - pOutput->precision = pDeleter->pSchema->precision; - pOutput->bufStatus = DS_BUF_EMPTY; - pOutput->queryEnd = pDeleter->queryEnd; - return TSDB_CODE_SUCCESS; - } - SDataCacheEntry* pEntry = (SDataCacheEntry*)(pDeleter->nextOutput.pData); - memcpy(pOutput->pData, pEntry->data, pEntry->dataLen); - pOutput->numOfRows = pEntry->numOfRows; - pOutput->numOfCols = pEntry->numOfCols; - pOutput->compressed = pEntry->compressed; - - atomic_sub_fetch_64(&pDeleter->cachedSize, pEntry->dataLen); - atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen); - - taosMemoryFreeClear(pDeleter->nextOutput.pData); // todo persistent - pOutput->bufStatus = updateStatus(pDeleter); - taosThreadMutexLock(&pDeleter->mutex); - pOutput->queryEnd = pDeleter->queryEnd; - pOutput->useconds = pDeleter->useconds; - pOutput->precision = pDeleter->pSchema->precision; - taosThreadMutexUnlock(&pDeleter->mutex); - - return TSDB_CODE_SUCCESS; -} static int32_t destroyDataSinker(SDataSinkHandle* pHandle) { - SDataInserterHandle* pDeleter = (SDataInserterHandle*)pHandle; - atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pDeleter->cachedSize); - taosMemoryFreeClear(pDeleter->nextOutput.pData); - while (!taosQueueEmpty(pDeleter->pDataBlocks)) { - SDataInserterBuf* pBuf = NULL; - taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf); - taosMemoryFreeClear(pBuf->pData); - taosFreeQitem(pBuf); - } - taosCloseQueue(pDeleter->pDataBlocks); - taosThreadMutexDestroy(&pDeleter->mutex); + SDataInserterHandle* pInserter = (SDataInserterHandle*)pHandle; + atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pInserter->cachedSize); + taosArrayDestroy(pInserter->pDataBlocks); + taosMemoryFree(pInserter->pSchema); + taosThreadMutexDestroy(&pInserter->mutex); return TSDB_CODE_SUCCESS; } @@ -230,25 +301,46 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat return TSDB_CODE_QRY_OUT_OF_MEMORY; } - SDataDeleterNode* pDeleterNode = (SDataDeleterNode *)pDataSink; + SQueryInserterNode* pInserterNode = (SQueryInserterNode *)pDataSink; inserter->sink.fPut = putDataBlock; inserter->sink.fEndPut = endPut; inserter->sink.fGetLen = getDataLength; - inserter->sink.fGetData = getDataBlock; + inserter->sink.fGetData = NULL; inserter->sink.fDestroy = destroyDataSinker; inserter->sink.fGetCacheSize = getCacheSize; inserter->pManager = pManager; - inserter->pDeleter = pDeleterNode; - inserter->pSchema = pDataSink->pInputDataBlockDesc; + inserter->pNode = pInserterNode; inserter->pParam = pParam; inserter->status = DS_BUF_EMPTY; inserter->queryEnd = false; - inserter->pDataBlocks = taosOpenQueue(); + + int64_t suid = 0; + int32_t code = tsdbGetTableSchema(inserter->pParam->readHandle->vnode, pInserterNode->tableId, &inserter->pSchema, &suid); + if (code) { + return code; + } + + if (pInserterNode->stableId != suid) { + terrno = TSDB_CODE_TDB_INVALID_TABLE_ID; + return terrno; + } + + inserter->pDataBlocks = taosArrayInit(1, POINTER_BYTES); taosThreadMutexInit(&inserter->mutex, NULL); if (NULL == inserter->pDataBlocks) { terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY; } + + inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK); + SNode* pNode = NULL; + FOREACH(pNode, pInserterNode->pCols) { + SColumnNode* pCol = (SColumnNode*)pNode; + taosHashPut(inserter->pCols, &pCol->colId, sizeof(pCol->colId), &pCol->slotId, sizeof(pCol->slotId)); + } + + tsem_init(&inserter->ready, 0, 0); + *pHandle = inserter; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/executor/src/dataSinkMgt.c b/source/libs/executor/src/dataSinkMgt.c index 498171e88c..0aa5e6266c 100644 --- a/source/libs/executor/src/dataSinkMgt.c +++ b/source/libs/executor/src/dataSinkMgt.c @@ -40,6 +40,8 @@ int32_t dsCreateDataSinker(const SDataSinkNode *pDataSink, DataSinkHandle* pHand return createDataDispatcher(&gDataSinkManager, pDataSink, pHandle); case QUERY_NODE_PHYSICAL_PLAN_DELETE: return createDataDeleter(&gDataSinkManager, pDataSink, pHandle, pParam); + case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: + return createDataInserter(&gDataSinkManager, pDataSink, pHandle, pParam); } return TSDB_CODE_FAILED; } @@ -54,7 +56,7 @@ void dsEndPut(DataSinkHandle handle, uint64_t useconds) { return pHandleImpl->fEndPut(pHandleImpl, useconds); } -void dsGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd) { +void dsGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd) { SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle; pHandleImpl->fGetLen(pHandleImpl, pLen, pQueryEnd); } diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 4e5458e620..1f11f4be98 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -323,12 +323,12 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, if (code == TSDB_CODE_INDEX_REBUILDING) { code = vnodeGetAllTableList(pVnode, tableUid, pListInfo->pTableList); } else if (code != TSDB_CODE_SUCCESS) { - qError("failed to get tableIds, reason: %s, suid: %" PRIu64 "", tstrerror(code), tableUid); + qError("failed to get tableIds, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid); taosArrayDestroy(res); terrno = code; return code; } else { - qDebug("sucess to get tableIds, size: %d, suid: %" PRIu64 "", (int)taosArrayGetSize(res), tableUid); + qDebug("success to get tableIds, size:%d, suid:%" PRIu64, (int)taosArrayGetSize(res), tableUid); } for (int i = 0; i < taosArrayGetSize(res); i++) { @@ -341,7 +341,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, } if (code != TSDB_CODE_SUCCESS) { - qError("failed to get tableIds, reason: %s, suid: %" PRIu64 "", tstrerror(code), tableUid); + qError("failed to get tableIds, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid); terrno = code; return code; } @@ -748,11 +748,12 @@ SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode) { SColumn extractColumnFromColumnNode(SColumnNode* pColNode) { SColumn c = {0}; - c.slotId = pColNode->slotId; - c.colId = pColNode->colId; - c.type = pColNode->node.resType.type; - c.bytes = pColNode->node.resType.bytes; - c.scale = pColNode->node.resType.scale; + + c.slotId = pColNode->slotId; + c.colId = pColNode->colId; + c.type = pColNode->node.resType.type; + c.bytes = pColNode->node.resType.bytes; + c.scale = pColNode->node.resType.scale; c.precision = pColNode->node.resType.precision; return c; } @@ -774,6 +775,8 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi pCond->suid = pTableScanNode->scan.suid; pCond->type = BLOCK_LOAD_OFFSET_ORDER; + pCond->startVersion = -1; + pCond->endVersion = -1; // pCond->type = pTableScanNode->scanFlag; int32_t j = 0; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index a83565cbe0..fc35fba935 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -60,9 +60,9 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock); taosArrayPush(pInfo->pBlockLists, &p); } - } else if (type == STREAM_INPUT__DATA_SCAN) { + } else if (type == STREAM_INPUT__TABLE_SCAN) { // do nothing - ASSERT(pInfo->blockType == STREAM_INPUT__DATA_SCAN); + ASSERT(pInfo->blockType == STREAM_INPUT__TABLE_SCAN); } else { ASSERT(0); } @@ -76,7 +76,7 @@ int32_t qStreamScanSnapshot(qTaskInfo_t tinfo) { return TSDB_CODE_QRY_APP_ERROR; } SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - return doSetStreamBlock(pTaskInfo->pRoot, NULL, 0, STREAM_INPUT__DATA_SCAN, 0, NULL); + return doSetStreamBlock(pTaskInfo->pRoot, NULL, 0, STREAM_INPUT__TABLE_SCAN, 0, NULL); } int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool assignUid) { diff --git a/source/libs/executor/src/executorMain.c b/source/libs/executor/src/executorMain.c index d5e546f466..ca1d8b2b10 100644 --- a/source/libs/executor/src/executorMain.c +++ b/source/libs/executor/src/executorMain.c @@ -52,7 +52,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, if (handle) { void* pSinkParam = NULL; - code = createDataSinkParam(pSubplan->pDataSink, &pSinkParam, pTaskInfo); + code = createDataSinkParam(pSubplan->pDataSink, &pSinkParam, pTaskInfo, readHandle); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -267,7 +267,93 @@ const STqOffset* qExtractStatusFromStreamScanner(void* scanner) { return &pInfo->offset; } -int32_t qStreamPrepareScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts) { +void* qStreamExtractMetaMsg(qTaskInfo_t tinfo) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; + ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM); + return pTaskInfo->streamInfo.metaBlk; +} + +int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; + ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM); + memcpy(pOffset, &pTaskInfo->streamInfo.lastStatus, sizeof(STqOffsetVal)); + return 0; +} + +int32_t qStreamPrepareScan(qTaskInfo_t tinfo, const STqOffsetVal* pOffset) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; + SOperatorInfo* pOperator = pTaskInfo->pRoot; + ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM); + pTaskInfo->streamInfo.prepareStatus = *pOffset; + // TODO: optimize + /*if (pTaskInfo->streamInfo.lastStatus.type != pOffset->type ||*/ + /*pTaskInfo->streamInfo.prepareStatus.version != pTaskInfo->streamInfo.lastStatus.version) {*/ + while (1) { + uint8_t type = pOperator->operatorType; + pOperator->status = OP_OPENED; + if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + SStreamScanInfo* pInfo = pOperator->info; + if (pOffset->type == TMQ_OFFSET__LOG) { + if (tqSeekVer(pInfo->tqReader, pOffset->version) < 0) { + return -1; + } + ASSERT(pInfo->tqReader->pWalReader->curVersion == pOffset->version); + } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { + pInfo->blockType = STREAM_INPUT__TABLE_SCAN; + int64_t uid = pOffset->uid; + int64_t ts = pOffset->ts; + + if (uid == 0) { + if (taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList) != 0) { + STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, 0); + uid = pTableInfo->uid; + ts = INT64_MIN; + } + } + if (pTaskInfo->streamInfo.lastStatus.type != TMQ_OFFSET__SNAPSHOT_DATA || + pTaskInfo->streamInfo.lastStatus.uid != uid || pTaskInfo->streamInfo.lastStatus.ts != ts) { + STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; + int32_t tableSz = taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList); + bool found = false; + for (int32_t i = 0; i < tableSz; i++) { + STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, i); + if (pTableInfo->uid == uid) { + found = true; + pTableScanInfo->currentTable = i; + } + } + + // TODO after dropping table, table may be not found + ASSERT(found); + + tsdbSetTableId(pTableScanInfo->dataReader, uid); + int64_t oldSkey = pTableScanInfo->cond.twindows[0].skey; + pTableScanInfo->cond.twindows[0].skey = ts + 1; + tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0); + pTableScanInfo->cond.twindows[0].skey = oldSkey; + pTableScanInfo->scanTimes = 0; + pTableScanInfo->curTWinIdx = 0; + + qDebug("tsdb reader offset seek to uid %ld ts %ld, table cur set to %d , all table num %d", uid, ts, + pTableScanInfo->currentTable, tableSz); + } else { + // switch to log + } + + } else { + ASSERT(0); + } + return 0; + } else { + ASSERT(pOperator->numOfDownstream == 1); + pOperator = pOperator->pDownstream[0]; + } + } + /*}*/ + return 0; +} + +int32_t qStreamPrepareTsdbScan(qTaskInfo_t tinfo, uint64_t uid, int64_t ts) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; if (uid == 0) { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index ab08cfd2b3..4b0f29e106 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -741,10 +741,10 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF if (type == TSDB_DATA_TYPE_BIGINT) { int64_t v = pFuncParam->param.i; - *da = (SColumnDataAgg){.numOfNull = 0, .min = v, .max = v, .maxIndex = 0, .minIndex = 0, .sum = v * numOfRows}; + *da = (SColumnDataAgg){.numOfNull = 0, .min = v, .max = v, .sum = v * numOfRows}; } else if (type == TSDB_DATA_TYPE_DOUBLE) { double v = pFuncParam->param.d; - *da = (SColumnDataAgg){.numOfNull = 0, .maxIndex = 0, .minIndex = 0}; + *da = (SColumnDataAgg){.numOfNull = 0}; *(double*)&da->min = v; *(double*)&da->max = v; @@ -752,7 +752,7 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF } else if (type == TSDB_DATA_TYPE_BOOL) { // todo validate this data type bool v = pFuncParam->param.i; - *da = (SColumnDataAgg){.numOfNull = 0, .maxIndex = 0, .minIndex = 0}; + *da = (SColumnDataAgg){.numOfNull = 0}; *(bool*)&da->min = 0; *(bool*)&da->max = v; *(bool*)&da->sum = v * numOfRows; @@ -1130,7 +1130,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc } else if ((*status) == BLK_DATA_SMA_LOAD) { // this function never returns error? pCost->loadBlockStatis += 1; -// tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); +// tsdbRetrieveDatablockSMA(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); if (pBlock->pBlockAgg == NULL) { // data block statistics does not exist, load data block // pBlock->pDataBlock = tsdbRetrieveDataBlock(pTableScanInfo->pTsdbReadHandle, NULL); @@ -1141,7 +1141,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc // load the data block statistics to perform further filter pCost->loadBlockStatis += 1; -// tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); +// tsdbRetrieveDatablockSMA(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); if (pQueryAttr->topBotQuery && pBlock->pBlockAgg != NULL) { { // set previous window @@ -1994,7 +1994,7 @@ static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) { taosMemoryFreeClear(pMsgBody); } -void qProcessFetchRsp(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { +void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle; assert(pMsg->info.ahandle != NULL); @@ -2463,6 +2463,8 @@ static void destroySortedMergeOperatorInfo(void* param, int32_t numOfOutput) { blockDataDestroy(pInfo->binfo.pRes); cleanupAggSup(&pInfo->aggSup); + + taosMemoryFreeClear(param); } static bool needToMerge(SSDataBlock* pBlock, SArray* groupInfo, char** buf, int32_t rowIndex) { @@ -2850,7 +2852,7 @@ int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts) { if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { SStreamScanInfo* pScanInfo = pOperator->info; - pScanInfo->blockType = STREAM_INPUT__DATA_SCAN; + pScanInfo->blockType = STREAM_INPUT__TABLE_SCAN; pScanInfo->pTableScanOp->status = OP_OPENED; @@ -2892,7 +2894,7 @@ int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts) { pInfo->scanTimes = 0; pInfo->curTWinIdx = 0; - qDebug("tsdb reader offset seek to uid %ld ts %ld, table cur set to %d , all table num %d", uid, ts, + qDebug("tsdb reader offset seek to uid %" PRId64 " ts %" PRId64 ", table cur set to %d , all table num %d", uid, ts, pInfo->currentTable, tableSz); } @@ -3285,7 +3287,10 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { // The downstream exec may change the value of the newgroup, so use a local variable instead. SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { + // TODO optimize + /*if (pTaskInfo->execModel != OPTR_EXEC_MODEL_STREAM) {*/ doSetOperatorCompleted(pOperator); + /*}*/ break; } if (pBlock->info.type == STREAM_RETRIEVE) { @@ -3504,7 +3509,6 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) { } taosMemoryFreeClear(pOperator->exprSupp.pExprInfo); - taosMemoryFreeClear(pOperator->info); taosMemoryFreeClear(pOperator); } @@ -3674,11 +3678,15 @@ void cleanupBasicInfo(SOptrBasicInfo* pInfo) { void destroyBasicOperatorInfo(void* param, int32_t numOfOutput) { SOptrBasicInfo* pInfo = (SOptrBasicInfo*)param; cleanupBasicInfo(pInfo); + + taosMemoryFreeClear(param); } void destroyAggOperatorInfo(void* param, int32_t numOfOutput) { SAggOperatorInfo* pInfo = (SAggOperatorInfo*)param; - cleanupBasicInfo(&pInfo->binfo); + cleanupBasicInfo(&pInfo->binfo); + + taosMemoryFreeClear(param); } void destroySFillOperatorInfo(void* param, int32_t numOfOutput) { @@ -3686,6 +3694,8 @@ void destroySFillOperatorInfo(void* param, int32_t numOfOutput) { pInfo->pFillInfo = taosDestroyFillInfo(pInfo->pFillInfo); pInfo->pRes = blockDataDestroy(pInfo->pRes); taosMemoryFreeClear(pInfo->p); + + taosMemoryFreeClear(param); } static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) { @@ -3696,6 +3706,8 @@ static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) { cleanupBasicInfo(&pInfo->binfo); cleanupAggSup(&pInfo->aggSup); taosArrayDestroy(pInfo->pPseudoColInfo); + + taosMemoryFreeClear(param); } void cleanupExprSupp(SExprSupp* pSupp) { @@ -3712,6 +3724,8 @@ static void destroyIndefinitOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pPseudoColInfo); cleanupAggSup(&pInfo->aggSup); cleanupExprSupp(&pInfo->scalarSup); + + taosMemoryFreeClear(param); } void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) { @@ -3729,6 +3743,8 @@ void doDestroyExchangeOperatorInfo(void* param) { } tsem_destroy(&pExInfo->ready); + + taosMemoryFreeClear(param); } static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols) { @@ -4449,7 +4465,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo .precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision}; int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; - pOptr = createMergeAlignedIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, pTaskInfo); + pOptr = createMergeAlignedIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, pPhyNode->pConditions, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL == type) { SMergeIntervalPhysiNode* pIntervalPhyNode = (SMergeIntervalPhysiNode*)pPhyNode; @@ -4772,10 +4788,20 @@ int32_t decodeOperator(SOperatorInfo* ops, const char* result, int32_t length) { return TDB_CODE_SUCCESS; } -int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo) { +int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle) { SExecTaskInfo* pTask = *(SExecTaskInfo**)pTaskInfo; switch (pNode->type) { + case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: { + SInserterParam* pInserterParam = taosMemoryCalloc(1, sizeof(SInserterParam)); + if (NULL == pInserterParam) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pInserterParam->readHandle = readHandle; + + *pParam = pInserterParam; + break; + } case QUERY_NODE_PHYSICAL_PLAN_DELETE: { SDeleterParam* pDeleterParam = taosMemoryCalloc(1, sizeof(SDeleterParam)); if (NULL == pDeleterParam) { diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index e262a529bb..311d7f0d5a 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -38,6 +38,8 @@ static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pGroupCols); taosArrayDestroy(pInfo->pGroupColVals); cleanupExprSupp(&pInfo->scalarSup); + + taosMemoryFreeClear(param); } static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** keyBuf, const SArray* pGroupColList) { @@ -724,6 +726,8 @@ static void destroyPartitionOperatorInfo(void* param, int32_t numOfOutput) { taosMemoryFree(pInfo->columnOffset); cleanupExprSupp(&pInfo->scalarSup); + + taosMemoryFreeClear(param); } SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo) { @@ -806,4 +810,4 @@ int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, setResultRowInitCtx(pResultRow, pCtx, numOfCols, pOperator->exprSupp.rowEntryInfoOffset); return TSDB_CODE_SUCCESS; -} \ No newline at end of file +} diff --git a/source/libs/executor/src/joinoperator.c b/source/libs/executor/src/joinoperator.c index e9995ed77a..b864fae47f 100644 --- a/source/libs/executor/src/joinoperator.c +++ b/source/libs/executor/src/joinoperator.c @@ -104,6 +104,8 @@ void setJoinColumnInfo(SColumnInfo* pColumn, const SColumnNode* pColumnNode) { void destroyMergeJoinOperator(void* param, int32_t numOfOutput) { SJoinOperatorInfo* pJoinOperator = (SJoinOperatorInfo*)param; nodesDestroyNode(pJoinOperator->pCondAfterMerge); + + taosMemoryFreeClear(param); } static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes) { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 68cda52b10..d2f63849d0 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -39,9 +39,9 @@ static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capac static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size, const char* dbName); -static void addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, - SSDataBlock* pBlock); -static bool processBlockWithProbability(const SSampleExecInfo* pInfo); +static int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, + SSDataBlock* pBlock, const char* idStr); +static bool processBlockWithProbability(const SSampleExecInfo* pInfo); bool processBlockWithProbability(const SSampleExecInfo* pInfo) { #if 0 @@ -210,7 +210,11 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca bool allColumnsHaveAgg = true; SColumnDataAgg** pColAgg = NULL; - tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->dataReader, &pColAgg, &allColumnsHaveAgg); + + int32_t code = tsdbRetrieveDatablockSMA(pTableScanInfo->dataReader, &pColAgg, &allColumnsHaveAgg); + if (code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, code); + } if (allColumnsHaveAgg == true) { int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); @@ -260,7 +264,12 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca // currently only the tbname pseudo column if (pTableScanInfo->pseudoSup.numOfExprs > 0) { SExprSupp* pSup = &pTableScanInfo->pseudoSup; - addTagPseudoColumnData(&pTableScanInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pBlock); + + int32_t code = addTagPseudoColumnData(&pTableScanInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pBlock, + GET_TASKID(pTaskInfo)); + if (code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, code); + } } int64_t st = taosGetTimestampMs(); @@ -294,16 +303,21 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction taosqsort(pCond->twindows, pCond->numOfTWindows, sizeof(STimeWindow), pCond, compareTimeWindow); } -void addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, - SSDataBlock* pBlock) { +int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, + SSDataBlock* pBlock, const char* idStr) { // currently only the tbname pseudo column if (numOfPseudoExpr == 0) { - return; + return TSDB_CODE_SUCCESS; } SMetaReader mr = {0}; metaReaderInit(&mr, pHandle->meta, 0); - metaGetTableEntryByUid(&mr, pBlock->info.uid); + int32_t code = metaGetTableEntryByUid(&mr, pBlock->info.uid); + if (code != TSDB_CODE_SUCCESS) { + qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.uid, tstrerror(terrno), idStr); + metaReaderClear(&mr); + return terrno; + } for (int32_t j = 0; j < numOfPseudoExpr; ++j) { SExprInfo* pExpr = &pPseudoExpr[j]; @@ -345,6 +359,7 @@ void addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_ } metaReaderClear(&mr); + return TSDB_CODE_SUCCESS; } void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId) { @@ -592,6 +607,8 @@ static void destroyTableScanOperatorInfo(void* param, int32_t numOfOutput) { if (pTableScanInfo->pColMatchInfo != NULL) { taosArrayDestroy(pTableScanInfo->pColMatchInfo); } + + taosMemoryFreeClear(param); } SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, @@ -674,34 +691,46 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* return pOperator; } -static int32_t doGetTableRowSize(void* pMeta, uint64_t uid) { - int32_t rowLen = 0; +static int32_t doGetTableRowSize(void* pMeta, uint64_t uid, int32_t* rowLen, const char* idstr) { + *rowLen = 0; SMetaReader mr = {0}; metaReaderInit(&mr, pMeta, 0); - metaGetTableEntryByUid(&mr, uid); + int32_t code = metaGetTableEntryByUid(&mr, uid); + if (code != TSDB_CODE_SUCCESS) { + qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", uid, tstrerror(terrno), idstr); + metaReaderClear(&mr); + return terrno; + } + if (mr.me.type == TSDB_SUPER_TABLE) { int32_t numOfCols = mr.me.stbEntry.schemaRow.nCols; for (int32_t i = 0; i < numOfCols; ++i) { - rowLen += mr.me.stbEntry.schemaRow.pSchema[i].bytes; + (*rowLen) += mr.me.stbEntry.schemaRow.pSchema[i].bytes; } } else if (mr.me.type == TSDB_CHILD_TABLE) { uint64_t suid = mr.me.ctbEntry.suid; - metaGetTableEntryByUid(&mr, suid); + code = metaGetTableEntryByUid(&mr, suid); + if (code != TSDB_CODE_SUCCESS) { + qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", suid, tstrerror(terrno), idstr); + metaReaderClear(&mr); + return terrno; + } + int32_t numOfCols = mr.me.stbEntry.schemaRow.nCols; for (int32_t i = 0; i < numOfCols; ++i) { - rowLen += mr.me.stbEntry.schemaRow.pSchema[i].bytes; + (*rowLen) += mr.me.stbEntry.schemaRow.pSchema[i].bytes; } } else if (mr.me.type == TSDB_NORMAL_TABLE) { int32_t numOfCols = mr.me.ntbEntry.schemaRow.nCols; for (int32_t i = 0; i < numOfCols; ++i) { - rowLen += mr.me.ntbEntry.schemaRow.pSchema[i].bytes; + (*rowLen) += mr.me.ntbEntry.schemaRow.pSchema[i].bytes; } } metaReaderClear(&mr); - return rowLen; + return TSDB_CODE_SUCCESS; } static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator) { @@ -710,9 +739,14 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator) { } SBlockDistInfo* pBlockScanInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; STableBlockDistInfo blockDistInfo = {.minRows = INT_MAX, .maxRows = INT_MIN}; - blockDistInfo.rowSize = doGetTableRowSize(pBlockScanInfo->readHandle.meta, pBlockScanInfo->uid); + int32_t code = doGetTableRowSize(pBlockScanInfo->readHandle.meta, pBlockScanInfo->uid, &blockDistInfo.rowSize, + GET_TASKID(pTaskInfo)); + if (code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, code); + } tsdbGetFileBlocksDistInfo(pBlockScanInfo->pHandle, &blockDistInfo); blockDistInfo.numOfInmemRows = (int32_t)tsdbGetNumOfRowsInMemTable(pBlockScanInfo->pHandle); @@ -740,6 +774,8 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator) { static void destroyBlockDistScanOperatorInfo(void* param, int32_t numOfOutput) { SBlockDistInfo* pDistInfo = (SBlockDistInfo*)param; blockDataDestroy(pDistInfo->pResBlock); + + taosMemoryFreeClear(param); } SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* readHandle, uint64_t uid, @@ -904,7 +940,8 @@ static bool prepareDataScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32_t t setGroupId(pInfo, pSDB, GROUPID_COLUMN_INDEX, *pRowIndex); (*pRowIndex) += updateSessionWindowInfo(pCurWin, tsCols, NULL, pSDB->info.rows, *pRowIndex, gap, NULL); } else { - win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[*pRowIndex], &pInfo->interval, pInfo->interval.precision, NULL); + win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[*pRowIndex], &pInfo->interval, pInfo->interval.precision, + TSDB_ORDER_ASC); setGroupId(pInfo, pSDB, GROUPID_COLUMN_INDEX, *pRowIndex); (*pRowIndex) += getNumOfRowsInTimeWindow(&pSDB->info, tsCols, *pRowIndex, win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); @@ -1123,15 +1160,129 @@ static void setBlockGroupId(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32 uidCol[i] = getGroupId(pOperator, uidCol[i]); } } +static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock) { + SDataBlockInfo* pBlockInfo = &pInfo->pRes->info; + SOperatorInfo* pOperator = pInfo->pStreamScanOp; + SExecTaskInfo* pTaskInfo = pInfo->pStreamScanOp->pTaskInfo; + + pInfo->pRes->info.rows = pBlock->info.rows; + pInfo->pRes->info.uid = pBlock->info.uid; + pInfo->pRes->info.type = STREAM_NORMAL; + pInfo->pRes->info.capacity = pBlock->info.rows; + + // for generating rollup SMA result, each time is an independent time serie. + // TODO temporarily used, when the statement of "partition by tbname" is ready, remove this + if (pInfo->assignBlockUid) { + pInfo->pRes->info.groupId = pBlock->info.uid; + } + + uint64_t* groupIdPre = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t)); + if (groupIdPre) { + pInfo->pRes->info.groupId = *groupIdPre; + } else { + pInfo->pRes->info.groupId = 0; + } + + // todo extract method + for (int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) { + SColMatchInfo* pColMatchInfo = taosArrayGet(pInfo->pColMatchInfo, i); + if (!pColMatchInfo->output) { + continue; + } + + bool colExists = false; + for (int32_t j = 0; j < blockDataGetNumOfCols(pBlock); ++j) { + SColumnInfoData* pResCol = bdGetColumnInfoData(pBlock, j); + if (pResCol->info.colId == pColMatchInfo->colId) { + taosArraySet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId, pResCol); + colExists = true; + break; + } + } + + // the required column does not exists in submit block, let's set it to be all null value + if (!colExists) { + SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId); + colDataAppendNNULL(pDst, 0, pBlockInfo->rows); + } + } + + taosArrayDestroy(pBlock->pDataBlock); + + ASSERT(pInfo->pRes->pDataBlock != NULL); +#if 0 + if (pInfo->pRes->pDataBlock == NULL) { + // TODO add log + updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo); + pOperator->status = OP_EXEC_DONE; + pTaskInfo->code = terrno; + return -1; + } +#endif + + // currently only the tbname pseudo column + if (pInfo->numOfPseudoExpr > 0) { + int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes, + GET_TASKID(pTaskInfo)); + if (code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, code); + } + } + + doFilter(pInfo->pCondition, pInfo->pRes); + blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex); + if (pBlockInfo->rows > 0) { + return 0; + } + return 0; +} static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { // NOTE: this operator does never check if current status is done or not SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamScanInfo* pInfo = pOperator->info; - pTaskInfo->code = pOperator->fpSet._openFn(pOperator); - if (pTaskInfo->code != TSDB_CODE_SUCCESS || pOperator->status == OP_EXEC_DONE) { - return NULL; + /*pTaskInfo->code = pOperator->fpSet._openFn(pOperator);*/ + /*if (pTaskInfo->code != TSDB_CODE_SUCCESS || pOperator->status == OP_EXEC_DONE) {*/ + /*return NULL;*/ + /*}*/ + + if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__LOG) { + while (1) { + SFetchRet ret = {0}; + tqNextBlock(pInfo->tqReader, &ret); + if (ret.fetchType == FETCH_TYPE__DATA) { + blockDataCleanup(pInfo->pRes); + if (setBlockIntoRes(pInfo, &ret.data) < 0) { + ASSERT(0); + } + /*pTaskInfo->streamInfo.lastStatus = ret.offset;*/ + if (pInfo->pRes->info.rows > 0) { + return pInfo->pRes; + /*} else {*/ + /*tDeleteSSDataBlock(&ret.data);*/ + } + } else if (ret.fetchType == FETCH_TYPE__META) { + ASSERT(0); + pTaskInfo->streamInfo.lastStatus = ret.offset; + pTaskInfo->streamInfo.metaBlk = ret.meta; + return NULL; + } else if (ret.fetchType == FETCH_TYPE__NONE) { + /*if (ret.offset.version == -1) {*/ + /*pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG;*/ + /*pTaskInfo->streamInfo.lastStatus.version = pTaskInfo->streamInfo.prepareStatus.version - 1;*/ + /*} else {*/ + pTaskInfo->streamInfo.lastStatus = ret.offset; + ASSERT(pTaskInfo->streamInfo.lastStatus.version + 1 >= pTaskInfo->streamInfo.prepareStatus.version); + /*}*/ + return NULL; + } else { + ASSERT(0); + } + } + } else if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { + SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp); + return pResult && pResult->info.rows > 0 ? pResult : NULL; } size_t total = taosArrayGetSize(pInfo->pBlockLists); @@ -1139,7 +1290,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) { if (pInfo->validBlockIndex >= total) { /*doClearBufferedBlocks(pInfo);*/ - pOperator->status = OP_EXEC_DONE; + /*pOperator->status = OP_EXEC_DONE;*/ return NULL; } @@ -1248,12 +1399,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { pInfo->pRes->info.type = STREAM_NORMAL; pInfo->pRes->info.capacity = block.info.rows; - // for generating rollup SMA result, each time is an independent time serie. - // TODO temporarily used, when the statement of "partition by tbname" is ready, remove this - if (pInfo->assignBlockUid) { - pInfo->pRes->info.groupId = block.info.uid; - } - uint64_t* groupIdPre = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &block.info.uid, sizeof(int64_t)); if (groupIdPre) { pInfo->pRes->info.groupId = *groupIdPre; @@ -1261,6 +1406,12 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { pInfo->pRes->info.groupId = 0; } + // for generating rollup SMA result, each time is an independent time serie. + // TODO temporarily used, when the statement of "partition by tbname" is ready, remove this + if (pInfo->assignBlockUid) { + pInfo->pRes->info.groupId = block.info.uid; + } + // todo extract method for (int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) { SColMatchInfo* pColMatchInfo = taosArrayGet(pInfo->pColMatchInfo, i); @@ -1286,6 +1437,9 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { } taosArrayDestroy(block.pDataBlock); + + ASSERT(pInfo->pRes->pDataBlock != NULL); +#if 0 if (pInfo->pRes->pDataBlock == NULL) { // TODO add log updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo); @@ -1293,10 +1447,15 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { pTaskInfo->code = terrno; return NULL; } +#endif // currently only the tbname pseudo column if (pInfo->numOfPseudoExpr > 0) { - addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes); + code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes, + GET_TASKID(pTaskInfo)); + if (code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, code); + } } doFilter(pInfo->pCondition, pInfo->pRes); @@ -1312,7 +1471,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { if (pBlockInfo->rows == 0) { updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo); - pOperator->status = OP_EXEC_DONE; + /*pOperator->status = OP_EXEC_DONE;*/ } else if (pInfo->pUpdateInfo) { pInfo->tsArrayIndex = 0; checkUpdateData(pInfo, true, pInfo->pRes, true); @@ -1330,7 +1489,8 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes; - } else if (pInfo->blockType == STREAM_INPUT__DATA_SCAN) { + } else if (pInfo->blockType == STREAM_INPUT__TABLE_SCAN) { + /*ASSERT(0);*/ // check reader last status // if not match, reset status SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp); @@ -1488,6 +1648,8 @@ static void destroySysScanOperator(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->scanCols); taosMemoryFreeClear(pInfo->pUser); + + taosMemoryFreeClear(param); } static int32_t getSysTableDbNameColId(const char* pTable) { @@ -1719,7 +1881,17 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) { SMetaReader mr = {0}; metaReaderInit(&mr, pInfo->readHandle.meta, 0); - metaGetTableEntryByUid(&mr, pInfo->pCur->mr.me.ctbEntry.suid); + + uint64_t suid = pInfo->pCur->mr.me.ctbEntry.suid; + int32_t code = metaGetTableEntryByUid(&mr, suid); + if (code != TSDB_CODE_SUCCESS) { + qError("failed to get super table meta, uid:0x%" PRIx64 ", code:%s, %s", suid, tstrerror(terrno), + GET_TASKID(pTaskInfo)); + metaReaderClear(&mr); + metaCloseTbCursor(pInfo->pCur); + pInfo->pCur = NULL; + longjmp(pTaskInfo->env, terrno); + } // number of columns pColInfoData = taosArrayGet(p->pDataBlock, 3); @@ -2114,7 +2286,13 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { while (pInfo->curPos < size && count < pOperator->resultInfo.capacity) { STableKeyInfo* item = taosArrayGet(pInfo->pTableList->pTableList, pInfo->curPos); - metaGetTableEntryByUid(&mr, item->uid); + int32_t code = metaGetTableEntryByUid(&mr, item->uid); + if (code != TSDB_CODE_SUCCESS) { + qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", item->uid, tstrerror(terrno), + GET_TASKID(pTaskInfo)); + metaReaderClear(&mr); + longjmp(pTaskInfo->env, terrno); + } for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) { SColumnInfoData* pDst = taosArrayGet(pRes->pDataBlock, pExprInfo[j].base.resSchema.slotId); @@ -2166,6 +2344,8 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { static void destroyTagScanOperatorInfo(void* param, int32_t numOfOutput) { STagScanInfo* pInfo = (STagScanInfo*)param; pInfo->pRes = blockDataDestroy(pInfo->pRes); + + taosMemoryFreeClear(param); } SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, @@ -2347,7 +2527,7 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc bool allColumnsHaveAgg = true; SColumnDataAgg** pColAgg = NULL; STsdbReader* reader = taosArrayGetP(pTableScanInfo->dataReaders, readerIdx); - tsdbRetrieveDataBlockStatisInfo(reader, &pColAgg, &allColumnsHaveAgg); + tsdbRetrieveDatablockSMA(reader, &pColAgg, &allColumnsHaveAgg); if (allColumnsHaveAgg == true) { int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); @@ -2397,8 +2577,11 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc // currently only the tbname pseudo column if (pTableScanInfo->numOfPseudoExpr > 0) { - addTagPseudoColumnData(&pTableScanInfo->readHandle, pTableScanInfo->pPseudoExpr, pTableScanInfo->numOfPseudoExpr, - pBlock); + int32_t code = addTagPseudoColumnData(&pTableScanInfo->readHandle, pTableScanInfo->pPseudoExpr, + pTableScanInfo->numOfPseudoExpr, pBlock, GET_TASKID(pTaskInfo)); + if (code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, code); + } } int64_t st = taosGetTimestampMs(); @@ -2656,6 +2839,8 @@ void destroyTableMergeScanOperatorInfo(void* param, int32_t numOfOutput) { pTableScanInfo->pSortInputBlock = blockDataDestroy(pTableScanInfo->pSortInputBlock); taosArrayDestroy(pTableScanInfo->pSortInfo); + + taosMemoryFreeClear(param); } typedef struct STableMergeScanExecInfo { @@ -2787,6 +2972,8 @@ static void destroyLastrowScanOperator(void* param, int32_t numOfOutput) { SLastrowScanInfo* pInfo = (SLastrowScanInfo*)param; blockDataDestroy(pInfo->pRes); tsdbLastrowReaderClose(pInfo->pLastrowReader); + + taosMemoryFreeClear(param); } SOperatorInfo* createLastrowScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle, SArray* pTableList, diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 2dc8ced737..d106d3e749 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -235,6 +235,8 @@ void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pSortInfo); taosArrayDestroy(pInfo->pColMatchInfo); + + taosMemoryFreeClear(param); } int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { @@ -451,6 +453,8 @@ void destroyGroupSortOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pSortInfo); taosArrayDestroy(pInfo->pColMatchInfo); + + taosMemoryFreeClear(param); } SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSortPhysiNode* pSortPhyNode, @@ -670,6 +674,8 @@ void destroyMultiwayMergeOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pSortInfo); taosArrayDestroy(pInfo->pColMatchInfo); + + taosMemoryFreeClear(param); } int32_t getMultiwayMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 9763f86838..f9810913e3 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -79,36 +79,111 @@ static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, T } } +static STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order) { + int32_t factor = (order == TSDB_ORDER_ASC)? -1:1; + + STimeWindow win = *pWindow; + STimeWindow save = win; + while(win.skey <= ts && win.ekey >= ts) { + save = win; + win.skey = taosTimeAdd(win.skey, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision); + win.ekey = taosTimeAdd(win.ekey, factor * pInterval->sliding, pInterval->slidingUnit, pInterval->precision); + } + + return save; +} + +// todo do refactor // get the correct time window according to the handled timestamp STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, - int32_t precision, STimeWindow* win) { + int32_t precision, int32_t order) { STimeWindow w = {0}; if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value getInitialStartTimeWindow(pInterval, precision, ts, &w, true); w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; - } else { - w = getResultRowByPos(pBuf, &pResultRowInfo->cur)->win; + return w; } - if (w.skey > ts || w.ekey < ts) { - if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') { - w.skey = taosTimeTruncate(ts, pInterval, precision); - w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; + w = getResultRowByPos(pBuf, &pResultRowInfo->cur)->win; + + if (pInterval->interval == pInterval->sliding) { + if (w.skey > ts || w.ekey < ts) { + if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') { + w.skey = taosTimeTruncate(ts, pInterval, precision); + w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; + } else { + int64_t st = w.skey; + + if (st > ts) { + st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; + } + + int64_t et = st + pInterval->interval - 1; + if (et < ts) { + st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; + } + + w.skey = st; + w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; + } + } + } else { // it is an sliding window query, in which sliding value is not equalled to + // interval value, and we need to find the first qualified time window for asc/desc traverse respectively. + if (order == TSDB_ORDER_ASC) { + if (w.skey <= ts && w.ekey >= ts) { + // ts is resident in current time window, but we need to find the first + //qualified time window that cover this timestamp + w = getFirstQualifiedTimeWindow(ts, &w, pInterval, order); + } else { + // todo refactor: + if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') { + w.skey = taosTimeTruncate(ts, pInterval, precision); + w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; + } else { + int64_t st = w.skey; + + if (st > ts) { + st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; + } + + int64_t et = st + pInterval->interval - 1; + if (et < ts) { + st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; + } + + w.skey = st; + w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; + + w = getFirstQualifiedTimeWindow(ts, &w, pInterval, order); + } + } } else { - int64_t st = w.skey; + if (w.skey <= ts && w.ekey >= ts) { + w = getFirstQualifiedTimeWindow(ts, &w, pInterval, order); + } else { + // todo refactor: + if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') { + w.skey = taosTimeTruncate(ts, pInterval, precision); + w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; + } else { + int64_t st = w.skey; - if (st > ts) { - st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; + if (st > ts) { + st -= ((st - ts + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; + } + + int64_t et = st + pInterval->interval - 1; + if (et < ts) { + st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; + } + + w.skey = st; + w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; + + w = getFirstQualifiedTimeWindow(ts, &w, pInterval, order); + } } - - int64_t et = st + pInterval->interval - 1; - if (et < ts) { - st += ((ts - et + pInterval->sliding - 1) / pInterval->sliding) * pInterval->sliding; - } - - w.skey = st; - w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; } } return w; @@ -856,7 +931,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul SResultRow* pResult = NULL; STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, - pInfo->interval.precision, &pInfo->win); + pInfo->interval.precision, pInfo->order); int32_t ret = TSDB_CODE_SUCCESS; if (!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) { ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, @@ -1010,21 +1085,6 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, scanFlag, true); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag, NULL); - -#if 0 // test for encode/decode result info - if(pOperator->fpSet.encodeResultRow){ - char *result = NULL; - int32_t length = 0; - SAggSupporter *pSup = &pInfo->aggSup; - pOperator->fpSet.encodeResultRow(pOperator, &result, &length); - taosHashClear(pSup->pResultRowHashTable); - pInfo->binfo.resultRowInfo.size = 0; - pOperator->fpSet.decodeResultRow(pOperator, result); - if(result){ - taosMemoryFree(result); - } - } -#endif } closeAllResultRows(&pInfo->binfo.resultRowInfo); @@ -1316,7 +1376,7 @@ bool doDeleteIntervalWindow(SAggSupporter* pAggSup, TSKEY ts, uint64_t groupId) // window has been closed return false; } - SFilePage* bufPage = getBufPage(pAggSup->pResultBuf, p1->pageId); + // SFilePage* bufPage = getBufPage(pAggSup->pResultBuf, p1->pageId); // dBufSetBufPageRecycled(pAggSup->pResultBuf, bufPage); taosHashRemove(pAggSup->pResultRowHashTable, pAggSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); return true; @@ -1330,7 +1390,7 @@ void doDeleteSpecifyIntervalWindow(SAggSupporter* pAggSup, SSDataBlock* pBlock, for (int32_t i = 0; i < pBlock->info.rows; i++) { SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; - STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsStarts[i], pInterval, pInterval->precision, NULL); + STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsStarts[i], pInterval, pInterval->precision, TSDB_ORDER_ASC); doDeleteIntervalWindow(pAggSup, win.skey, groupIds[i]); if (pUpWins) { SWinRes winRes = {.ts = win.skey, .groupId = groupIds[i]}; @@ -1352,7 +1412,7 @@ static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval* for (int32_t i = 0; i < pBlock->info.rows; i += step) { SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; - STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[i], pInterval, pInterval->precision, NULL); + STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCols[i], pInterval, pInterval->precision, TSDB_ORDER_ASC); step = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, i, win.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); uint64_t winGpId = pGpDatas ? pGpDatas[i] : pBlock->info.groupId; bool res = doClearWindow(pAggSup, pSup1, (char*)&win.skey, sizeof(TKEY), winGpId, numOfOutput); @@ -1392,7 +1452,7 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; - STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, ts, pInterval, pInterval->precision, NULL); + STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, ts, pInterval, pInterval->precision, TSDB_ORDER_ASC); SWinRes winRe = { .ts = win.skey, .groupId = groupId, @@ -1402,13 +1462,13 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, if (chIds && pPullDataMap) { SArray* chAy = *(SArray**)chIds; int32_t size = taosArrayGetSize(chAy); - qInfo("======window %ld wait child size:%d", win.skey, size); + qInfo("window %" PRId64 " wait child size:%d", win.skey, size); for (int32_t i = 0; i < size; i++) { - qInfo("======window %ld wait chid id:%d", win.skey, *(int32_t*)taosArrayGet(chAy, i)); + qInfo("window %" PRId64 " wait chid id:%d", win.skey, *(int32_t*)taosArrayGet(chAy, i)); } continue; } else if (pPullDataMap) { - qInfo("======close window %ld", win.skey); + qInfo("close window %" PRId64, win.skey); } SResultRowPosition* pPos = (SResultRowPosition*)pIte; if (pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { @@ -1419,7 +1479,7 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, ASSERT(pRecyPages != NULL); taosArrayPush(pRecyPages, &pPos->pageId); } else { - SFilePage* bufPage = getBufPage(pDiscBuf, pPos->pageId); + // SFilePage* bufPage = getBufPage(pDiscBuf, pPos->pageId); // dBufSetBufPageRecycled(pDiscBuf, bufPage); } char keyBuf[GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY))]; @@ -1446,7 +1506,7 @@ static void freeAllPages(SArray* pageIds, SDiskbasedBuf* pDiskBuf) { int32_t size = taosArrayGetSize(pageIds); for (int32_t i = 0; i < size; i++) { int32_t pageId = *(int32_t*)taosArrayGet(pageIds, i); - SFilePage* bufPage = getBufPage(pDiskBuf, pageId); + // SFilePage* bufPage = getBufPage(pDiskBuf, pageId); // dBufSetBufPageRecycled(pDiskBuf, bufPage); } taosArrayClear(pageIds); @@ -1557,6 +1617,8 @@ static void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput) { SStateWindowOperatorInfo* pInfo = (SStateWindowOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); taosMemoryFreeClear(pInfo->stateKey.pData); + + taosMemoryFreeClear(param); } void destroyIntervalOperatorInfo(void* param, int32_t numOfOutput) { @@ -1564,6 +1626,8 @@ void destroyIntervalOperatorInfo(void* param, int32_t numOfOutput) { cleanupBasicInfo(&pInfo->binfo); cleanupAggSup(&pInfo->aggSup); taosArrayDestroy(pInfo->pRecycledPages); + + taosMemoryFreeClear(param); } void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) { @@ -1586,6 +1650,8 @@ void destroyStreamFinalIntervalOperatorInfo(void* param, int32_t numOfOutput) { } } nodesDestroyNode((SNode*)pInfo->pPhyNode); + + taosMemoryFreeClear(param); } static bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) { @@ -2319,6 +2385,8 @@ _error: void destroySWindowOperatorInfo(void* param, int32_t numOfOutput) { SSessionAggOperatorInfo* pInfo = (SSessionAggOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); + + taosMemoryFreeClear(param); } SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, @@ -2480,7 +2548,7 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc int32_t startPos = ascScan ? 0 : (pSDataBlock->info.rows - 1); TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols); STimeWindow nextWin = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, - pInfo->interval.precision, NULL); + pInfo->interval.precision, pInfo->order); while (1) { bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup); if (pInfo->ignoreExpiredData && isClosed) { @@ -2995,6 +3063,8 @@ void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) { taosMemoryFreeClear(pChInfo); } } + + taosMemoryFreeClear(param); } int32_t initBasicInfoEx(SOptrBasicInfo* pBasicInfo, SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfCols, @@ -3954,6 +4024,8 @@ void destroyStreamStateOperatorInfo(void* param, int32_t numOfOutput) { taosMemoryFreeClear(pChInfo); } } + + taosMemoryFreeClear(param); } int64_t getStateWinTsKey(void* data, int32_t index) { @@ -4357,23 +4429,27 @@ _error: } typedef struct SMergeAlignedIntervalAggOperatorInfo { - SIntervalAggOperatorInfo intervalAggOperatorInfo; + SIntervalAggOperatorInfo *intervalAggOperatorInfo; bool hasGroupId; uint64_t groupId; SSDataBlock* prefetchedBlock; bool inputBlocksFinished; + + SNode* pCondition; } SMergeAlignedIntervalAggOperatorInfo; void destroyMergeAlignedIntervalOperatorInfo(void* param, int32_t numOfOutput) { SMergeAlignedIntervalAggOperatorInfo* miaInfo = (SMergeAlignedIntervalAggOperatorInfo*)param; - destroyIntervalOperatorInfo(&miaInfo->intervalAggOperatorInfo, numOfOutput); + destroyIntervalOperatorInfo(miaInfo->intervalAggOperatorInfo, numOfOutput); + + taosMemoryFreeClear(param); } static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, SSDataBlock* pResultBlock, TSKEY wstartTs) { SMergeAlignedIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; - SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + SIntervalAggOperatorInfo* iaInfo = miaInfo->intervalAggOperatorInfo; SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; SExprSupp* pSup = &pOperatorInfo->exprSupp; @@ -4394,7 +4470,7 @@ static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, ui static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pBlock, int32_t scanFlag, SSDataBlock* pResultBlock) { SMergeAlignedIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; - SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + SIntervalAggOperatorInfo* iaInfo = miaInfo->intervalAggOperatorInfo; SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; SExprSupp* pSup = &pOperatorInfo->exprSupp; @@ -4438,8 +4514,7 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR currTs = tsCols[currPos]; currWin.skey = currTs; currWin.ekey = taosTimeAdd(currWin.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit, - iaInfo->interval.precision) - - 1; + iaInfo->interval.precision) - 1; startPos = currPos; ret = setTimeWindowOutputBuf(pResultRowInfo, &currWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); @@ -4459,7 +4534,7 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SMergeAlignedIntervalAggOperatorInfo* miaInfo = pOperator->info; - SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + SIntervalAggOperatorInfo* iaInfo = miaInfo->intervalAggOperatorInfo; if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -4498,8 +4573,8 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { getTableScanInfo(pOperator, &iaInfo->order, &scanFlag); setInputDataBlock(pOperator, pSup->pCtx, pBlock, iaInfo->order, scanFlag, true); doMergeAlignedIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes); - - if (pRes->info.rows >= pOperator->resultInfo.threshold) { + doFilter(miaInfo->pCondition, pRes); + if (pRes->info.rows > 0) { break; } } @@ -4507,7 +4582,7 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { pRes->info.groupId = miaInfo->groupId; } - if (pRes->info.rows == 0) { + if (miaInfo->inputBlocksFinished) { doSetOperatorCompleted(pOperator); } @@ -4518,16 +4593,22 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, - int32_t primaryTsSlotId, SExecTaskInfo* pTaskInfo) { + int32_t primaryTsSlotId, SNode* pCondition, SExecTaskInfo* pTaskInfo) { SMergeAlignedIntervalAggOperatorInfo* miaInfo = taosMemoryCalloc(1, sizeof(SMergeAlignedIntervalAggOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (miaInfo == NULL || pOperator == NULL) { goto _error; } - SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + miaInfo->intervalAggOperatorInfo = taosMemoryCalloc(1, sizeof(SIntervalAggOperatorInfo)); + if (miaInfo->intervalAggOperatorInfo == NULL) { + goto _error; + } + + SIntervalAggOperatorInfo* iaInfo = miaInfo->intervalAggOperatorInfo; SExprSupp* pSup = &pOperator->exprSupp; + miaInfo->pCondition = pCondition; iaInfo->win = pTaskInfo->window; iaInfo->order = TSDB_ORDER_ASC; iaInfo->interval = *pInterval; @@ -4602,6 +4683,8 @@ void destroyMergeIntervalOperatorInfo(void* param, int32_t numOfOutput) { SMergeIntervalAggOperatorInfo* miaInfo = (SMergeIntervalAggOperatorInfo*)param; tdListFree(miaInfo->groupIntervals); destroyIntervalOperatorInfo(&miaInfo->intervalAggOperatorInfo, numOfOutput); + + taosMemoryFreeClear(param); } static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, STimeWindow* win, @@ -4668,7 +4751,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* SResultRow* pResult = NULL; STimeWindow win = getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval, - iaInfo->interval.precision, &iaInfo->win); + iaInfo->interval.precision, iaInfo->order); int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx, diff --git a/source/libs/executor/test/executorTests.cpp b/source/libs/executor/test/executorTests.cpp index 3c12889aca..bba4b254c5 100644 --- a/source/libs/executor/test/executorTests.cpp +++ b/source/libs/executor/test/executorTests.cpp @@ -1029,7 +1029,7 @@ TEST(testCase, external_sort_Test) { int64_t e = taosGetTimestampUs(); if (t++ == 1) { - printf("---------------elapsed:%ld\n", e - s); + printf("---------------elapsed:%" PRId64 "\n", e - s); } if (pRes == NULL) { @@ -1046,7 +1046,7 @@ TEST(testCase, external_sort_Test) { } int64_t s2 = taosGetTimestampUs(); - printf("total:%ld\n", s2 - s1); + printf("total:%" PRId64 "\n", s2 - s1); pOperator->closeFn(pOperator->info, 2); taosMemoryFreeClear(exp); @@ -1101,7 +1101,7 @@ TEST(testCase, sorted_merge_Test) { int64_t e = taosGetTimestampUs(); if (t++ == 1) { - printf("---------------elapsed:%ld\n", e - s); + printf("---------------elapsed:%" PRId64 "\n", e - s); } if (pRes == NULL) { @@ -1112,13 +1112,13 @@ TEST(testCase, sorted_merge_Test) { // SColumnInfoData* pCol2 = static_cast(taosArrayGet(pRes->pDataBlock, 1)); for (int32_t i = 0; i < pRes->info.rows; ++i) { // char* p = colDataGetData(pCol2, i); - printf("%d: %ld\n", total++, ((int64_t*)pCol1->pData)[i]); + printf("%d: %" PRId64 "\n", total++, ((int64_t*)pCol1->pData)[i]); // printf("%d: %d, %s\n", total++, ((int32_t*)pCol1->pData)[i], (char*)varDataVal(p)); } } int64_t s2 = taosGetTimestampUs(); - printf("total:%ld\n", s2 - s1); + printf("total:%" PRId64 "\n", s2 - s1); pOperator->closeFn(pOperator->info, 2); taosMemoryFreeClear(exp); @@ -1179,7 +1179,7 @@ TEST(testCase, time_interval_Operator_Test) { int64_t e = taosGetTimestampUs(); if (t++ == 1) { - printf("---------------elapsed:%ld\n", e - s); + printf("---------------elapsed:%" PRId64 "\n", e - s); } if (pRes == NULL) { @@ -1190,13 +1190,13 @@ TEST(testCase, time_interval_Operator_Test) { // SColumnInfoData* pCol2 = static_cast(taosArrayGet(pRes->pDataBlock, 1)); for (int32_t i = 0; i < pRes->info.rows; ++i) { // char* p = colDataGetData(pCol2, i); - printf("%d: %ld\n", total++, ((int64_t*)pCol1->pData)[i]); + printf("%d: %" PRId64 "\n", total++, ((int64_t*)pCol1->pData)[i]); // printf("%d: %d, %s\n", total++, ((int32_t*)pCol1->pData)[i], (char*)varDataVal(p)); } } int64_t s2 = taosGetTimestampUs(); - printf("total:%ld\n", s2 - s1); + printf("total:%" PRId64 "\n", s2 - s1); pOperator->closeFn(pOperator->info, 2); taosMemoryFreeClear(exp); diff --git a/source/libs/executor/test/sortTests.cpp b/source/libs/executor/test/sortTests.cpp index 70def78263..6e244152f2 100644 --- a/source/libs/executor/test/sortTests.cpp +++ b/source/libs/executor/test/sortTests.cpp @@ -118,7 +118,7 @@ SSDataBlock* getSingleColDummyBlock(void* param) { } colDataAppend(pColInfo, i, result, false); - printf("int: %ld\n", v); + printf("int: %" PRId64 "\n", v); taosMemoryFree(result); } } @@ -333,7 +333,7 @@ TEST(testCase, external_mem_sort_Test) { }else{ memcpy((char*)(&result) + sizeof(int64_t) - tDataTypes[pInfo[i].type].bytes, v, tDataTypes[pInfo[i].type].bytes); } - printf("%d: %ld\n", row++, result); + printf("%d: %" PRId64 "\n", row++, result); } } taosArrayDestroy(orderInfo); diff --git a/source/libs/function/inc/fnLog.h b/source/libs/function/inc/fnLog.h index d85dd02433..9658b6b782 100644 --- a/source/libs/function/inc/fnLog.h +++ b/source/libs/function/inc/fnLog.h @@ -10,12 +10,14 @@ extern "C" { #endif -#define fnFatal(...) { if (fnDebugFlag & DEBUG_FATAL) { taosPrintLog("FN FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} -#define fnError(...) { if (fnDebugFlag & DEBUG_ERROR) { taosPrintLog("FN ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} -#define fnWarn(...) { if (fnDebugFlag & DEBUG_WARN) { taosPrintLog("FN WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} -#define fnInfo(...) { if (fnDebugFlag & DEBUG_INFO) { taosPrintLog("FN ", DEBUG_INFO, 255, __VA_ARGS__); }} -#define fnDebug(...) { if (fnDebugFlag & DEBUG_DEBUG) { taosPrintLog("FN ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }} -#define fnTrace(...) { if (fnDebugFlag & DEBUG_TRACE) { taosPrintLog("FN ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }} +// clang-format off +#define fnFatal(...) { if (udfDebugFlag & DEBUG_FATAL) { taosPrintLog("UDF FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} +#define fnError(...) { if (udfDebugFlag & DEBUG_ERROR) { taosPrintLog("UDF ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} +#define fnWarn(...) { if (udfDebugFlag & DEBUG_WARN) { taosPrintLog("UDF WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} +#define fnInfo(...) { if (udfDebugFlag & DEBUG_INFO) { taosPrintLog("UDF ", DEBUG_INFO, 255, __VA_ARGS__); }} +#define fnDebug(...) { if (udfDebugFlag & DEBUG_DEBUG) { taosPrintLog("UDF ", DEBUG_DEBUG, udfDebugFlag, __VA_ARGS__); }} +#define fnTrace(...) { if (udfDebugFlag & DEBUG_TRACE) { taosPrintLog("UDF ", DEBUG_TRACE, udfDebugFlag, __VA_ARGS__); }} +// clang-format on #ifdef __cplusplus } diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index f94522f0d8..1706c129ce 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -1080,6 +1080,19 @@ bool getMinmaxFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { static void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos); static void copyTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos); +static int32_t findRowIndex(int32_t start, int32_t num, SColumnInfoData* pCol, const char* tval) { + // the data is loaded, not only the block SMA value + for(int32_t i = start; i < num + start; ++i) { + char* p = colDataGetData(pCol, i); + if (memcpy((void*)tval, p, pCol->info.bytes) == 0) { + return i; + } + } + + ASSERT(0); +} + + int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { int32_t numOfElems = 0; @@ -1111,15 +1124,14 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { if (isMinFunc) { tval = &pInput->pColumnDataAgg[0]->min; - index = pInput->pColumnDataAgg[0]->minIndex; } else { tval = &pInput->pColumnDataAgg[0]->max; - index = pInput->pColumnDataAgg[0]->maxIndex; } if (!pBuf->assign) { pBuf->v = *(int64_t*)tval; if (pCtx->subsidiaries.num > 0) { + index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); } } else { @@ -1131,6 +1143,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { if ((prev < val) ^ isMinFunc) { pBuf->v = val; if (pCtx->subsidiaries.num > 0) { + index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); } } @@ -1143,6 +1156,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { if ((prev < val) ^ isMinFunc) { pBuf->v = val; if (pCtx->subsidiaries.num > 0) { + index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); } } @@ -1154,6 +1168,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { if ((prev < val) ^ isMinFunc) { pBuf->v = val; if (pCtx->subsidiaries.num > 0) { + index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); } } @@ -1167,6 +1182,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { } if (pCtx->subsidiaries.num > 0) { + index = findRowIndex(pInput->startRowIndex, pInput->numOfRows, pCol, tval); saveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); } } @@ -3451,6 +3467,10 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS setBufPageDirty(pPage, true); releaseBufPage(pCtx->pBuf, pPage); +#ifdef BUF_PAGE_DEBUG + qDebug("page_saveTuple pos:%p,pageId:%d, offset:%d\n", pPos, pPos->pageId, + pPos->offset); +#endif } void copyTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos) { @@ -3485,6 +3505,9 @@ void copyTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS setBufPageDirty(pPage, true); releaseBufPage(pCtx->pBuf, pPage); +#ifdef BUF_PAGE_DEBUG + qDebug("page_copyTuple pos:%p, pageId:%d, offset:%d", pPos, pPos->pageId, pPos->offset); +#endif } int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { @@ -5547,30 +5570,18 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { } } - int32_t delta = maxVal - minVal; - int32_t step = delta / 50; - if (step == 0) { - step = 1; - } + // maximum number of step is 80 + double factor = pData->numOfBlocks / 80.0; int32_t numOfBuckets = sizeof(pData->blockRowsHisto) / sizeof(pData->blockRowsHisto[0]); - int32_t bucketRange = (pData->maxRows - pData->minRows) / numOfBuckets; - - bool singleModel = false; - if (bucketRange == 0) { - singleModel = true; - step = 20; - bucketRange = (pData->defMaxRows - pData->defMinRows) / numOfBuckets; - } + int32_t bucketRange = (pData->defMaxRows - pData->defMinRows) / numOfBuckets; for (int32_t i = 0; i < tListLen(pData->blockRowsHisto); ++i) { - len = sprintf(st + VARSTR_HEADER_SIZE, "%04d |", pData->defMinRows + bucketRange * (i + 1)); + len = sprintf(st + VARSTR_HEADER_SIZE, "%04d |", pData->defMinRows + bucketRange * i); int32_t num = 0; - if (singleModel && pData->blockRowsHisto[i] > 0) { - num = 20; - } else { - num = (pData->blockRowsHisto[i] + step - 1) / step; + if (pData->blockRowsHisto[i] > 0) { + num = (pData->blockRowsHisto[i]) / factor; } for (int32_t j = 0; j < num; ++j) { @@ -5578,9 +5589,10 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { len += x; } - double v = pData->blockRowsHisto[i] * 100.0 / pData->numOfBlocks; - len += sprintf(st + VARSTR_HEADER_SIZE + len, " %d (%.2f%c)", pData->blockRowsHisto[i], v, '%'); - printf("%s\n", st); + if (num > 0) { + double v = pData->blockRowsHisto[i] * 100.0 / pData->numOfBlocks; + len += sprintf(st + VARSTR_HEADER_SIZE + len, " %d (%.2f%c)", pData->blockRowsHisto[i], v, '%'); + } varDataSetLen(st, len); colDataAppend(pColInfo, row++, st, false); diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index dcf6676f9f..c16c3e3937 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -203,7 +203,7 @@ int32_t udfStartUdfd(int32_t startDnodeId) { uv_async_send(&pData->stopAsync); uv_thread_join(&pData->thread); pData->needCleanUp = false; - fnInfo("dnode udfd cleaned up after spawn err"); + fnInfo("udfd is cleaned up after spawn err"); } else { pData->needCleanUp = true; } @@ -212,7 +212,7 @@ int32_t udfStartUdfd(int32_t startDnodeId) { int32_t udfStopUdfd() { SUdfdData *pData = &udfdGlobal; - fnInfo("dnode to stop udfd. need cleanup: %d, spawn err: %d", + fnInfo("udfd start to stop, need cleanup:%d, spawn err:%d", pData->needCleanUp, pData->spawnErr); if (!pData->needCleanUp || atomic_load_32(&pData->stopCalled)) { return 0; @@ -225,7 +225,7 @@ int32_t udfStopUdfd() { #ifdef WINDOWS if (pData->jobHandle != NULL) CloseHandle(pData->jobHandle); #endif - fnInfo("dnode udfd cleaned up"); + fnInfo("udfd is cleaned up"); return 0; } @@ -467,7 +467,7 @@ int32_t getUdfdPipeName(char* pipeName, int32_t size) { size_t dnodeIdSize = sizeof(dnodeId); int32_t err = uv_os_getenv(UDF_DNODE_ID_ENV_NAME, dnodeId, &dnodeIdSize); if (err != 0) { - fnError("get dnode id from env. error: %s.", uv_err_name(err)); + fnError("failed to get dnodeId from env since %s", uv_err_name(err)); dnodeId[0] = '1'; } #ifdef _WIN32 @@ -475,7 +475,7 @@ int32_t getUdfdPipeName(char* pipeName, int32_t size) { #else snprintf(pipeName, size, "%s/%s%s", tsDataDir, UDF_LISTEN_PIPE_NAME_PREFIX, dnodeId); #endif - fnInfo("get dnode id from env. dnode id: %s. pipe path: %s", dnodeId, pipeName); + fnInfo("get dnodeId:%s from env, pipe path:%s", dnodeId, pipeName); return 0; } @@ -1609,7 +1609,7 @@ int32_t udfcClose() { taosArrayDestroy(udfc->udfStubs); uv_mutex_destroy(&udfc->udfStubsMutex); udfc->udfcState = UDFC_STATE_INITAL; - fnInfo("udfc cleaned up"); + fnInfo("udfc is cleaned up"); return 0; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 2a94ee43e3..5d5e95cd2b 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -3605,7 +3605,7 @@ static int32_t databaseOptionsToJson(const void* pObj, SJson* pJson) { int32_t code = tjsonAddIntegerToObject(pJson, jkDatabaseOptionsBuffer, pNode->buffer); if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkDatabaseOptionsCachelast, pNode->cachelast); + code = tjsonAddIntegerToObject(pJson, jkDatabaseOptionsCachelast, pNode->cacheLast); } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkDatabaseOptionsCompressionLevel, pNode->compressionLevel); @@ -3667,7 +3667,7 @@ static int32_t jsonToDatabaseOptions(const SJson* pJson, void* pObj) { int32_t code = tjsonGetIntValue(pJson, jkDatabaseOptionsBuffer, &pNode->buffer); if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetTinyIntValue(pJson, jkDatabaseOptionsCachelast, &pNode->cachelast); + code = tjsonGetTinyIntValue(pJson, jkDatabaseOptionsCachelast, &pNode->cacheLast); } if (TSDB_CODE_SUCCESS == code) { code = tjsonGetTinyIntValue(pJson, jkDatabaseOptionsCompressionLevel, &pNode->compressionLevel); diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 835f8098a3..ee60a14da9 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -39,6 +39,7 @@ typedef struct SAstCreateContext { typedef enum EDatabaseOptionType { DB_OPTION_BUFFER = 1, DB_OPTION_CACHELAST, + DB_OPTION_CACHELASTSIZE, DB_OPTION_COMP, DB_OPTION_DAYS, DB_OPTION_FSYNC, diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 3c173aead9..fd79eaa9b7 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -172,6 +172,7 @@ exists_opt(A) ::= . db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); } db_options(A) ::= db_options(B) BUFFER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BUFFER, &C); } db_options(A) ::= db_options(B) CACHELAST NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHELAST, &C); } +db_options(A) ::= db_options(B) CACHELASTSIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHELASTSIZE, &C); } db_options(A) ::= db_options(B) COMP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_COMP, &C); } db_options(A) ::= db_options(B) DURATION NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); } db_options(A) ::= db_options(B) DURATION NK_VARIABLE(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_DAYS, &C); } @@ -198,6 +199,7 @@ alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). %destructor alter_db_option { } alter_db_option(A) ::= BUFFER NK_INTEGER(B). { A.type = DB_OPTION_BUFFER; A.val = B; } alter_db_option(A) ::= CACHELAST NK_INTEGER(B). { A.type = DB_OPTION_CACHELAST; A.val = B; } +alter_db_option(A) ::= CACHELASTSIZE NK_INTEGER(B). { A.type = DB_OPTION_CACHELASTSIZE; A.val = B; } alter_db_option(A) ::= FSYNC NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; A.val = B; } alter_db_option(A) ::= KEEP integer_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; } alter_db_option(A) ::= KEEP variable_list(B). { A.type = DB_OPTION_KEEP; A.pList = B; } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 29396f4101..ab73204fb7 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -746,7 +746,8 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { SDatabaseOptions* pOptions = (SDatabaseOptions*)nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->buffer = TSDB_DEFAULT_BUFFER_PER_VNODE; - pOptions->cachelast = TSDB_DEFAULT_CACHE_LAST_ROW; + pOptions->cacheLast = TSDB_DEFAULT_CACHE_LAST_ROW; + pOptions->cacheLastSize = TSDB_DEFAULT_LAST_ROW_MEM; pOptions->compressionLevel = TSDB_DEFAULT_COMP_LEVEL; pOptions->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE; pOptions->fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD; @@ -772,7 +773,8 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { SDatabaseOptions* pOptions = (SDatabaseOptions*)nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->buffer = -1; - pOptions->cachelast = -1; + pOptions->cacheLast = -1; + pOptions->cacheLastSize = -1; pOptions->compressionLevel = -1; pOptions->daysPerFile = -1; pOptions->fsyncPeriod = -1; @@ -800,7 +802,10 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti ((SDatabaseOptions*)pOptions)->buffer = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_CACHELAST: - ((SDatabaseOptions*)pOptions)->cachelast = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + ((SDatabaseOptions*)pOptions)->cacheLast = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + break; + case DB_OPTION_CACHELASTSIZE: + ((SDatabaseOptions*)pOptions)->cacheLastSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_COMP: ((SDatabaseOptions*)pOptions)->compressionLevel = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 38fe8ffc24..920921a3b3 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -53,6 +53,7 @@ static SKeyword keywordTable[] = { {"BY", TK_BY}, {"CACHE", TK_CACHE}, {"CACHELAST", TK_CACHELAST}, + {"CACHELASTSIZE", TK_CACHELASTSIZE}, {"CAST", TK_CAST}, {"CLIENT_VERSION", TK_CLIENT_VERSION}, {"CLUSTER", TK_CLUSTER}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 0975fe7309..67133d0bf1 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -77,14 +77,6 @@ static int32_t addNamespace(STranslateContext* pCxt, void* pTable) { return TSDB_CODE_SUCCESS; } -static SName* toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName) { - pName->type = TSDB_TABLE_NAME_T; - pName->acctId = acctId; - strcpy(pName->dbname, pDbName); - strcpy(pName->tname, pTableName); - return pName; -} - static int32_t collectUseDatabaseImpl(const char* pFullDbName, SHashObj* pDbs) { SFullDatabaseName name = {0}; strcpy(name.fullDbName, pFullDbName); @@ -2988,7 +2980,8 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS pReq->compression = pStmt->pOptions->compressionLevel; pReq->replications = pStmt->pOptions->replica; pReq->strict = pStmt->pOptions->strict; - pReq->cacheLastRow = pStmt->pOptions->cachelast; + pReq->cacheLastRow = pStmt->pOptions->cacheLast; + pReq->lastRowMem = pStmt->pOptions->cacheLastSize; pReq->schemaless = pStmt->pOptions->schemaless; pReq->ignoreExist = pStmt->ignoreExists; return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq); @@ -3149,9 +3142,13 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName int32_t code = checkRangeOption(pCxt, "buffer", pOptions->buffer, TSDB_MIN_BUFFER_PER_VNODE, TSDB_MAX_BUFFER_PER_VNODE); if (TSDB_CODE_SUCCESS == code) { - code = checkRangeOption(pCxt, "cacheLast", pOptions->cachelast, TSDB_MIN_DB_CACHE_LAST_ROW, + code = checkRangeOption(pCxt, "cacheLast", pOptions->cacheLast, TSDB_MIN_DB_CACHE_LAST_ROW, TSDB_MAX_DB_CACHE_LAST_ROW); } + if (TSDB_CODE_SUCCESS == code) { + code = checkRangeOption(pCxt, "cacheLastSize", pOptions->cacheLastSize, TSDB_MIN_DB_LAST_ROW_MEM, + TSDB_MAX_DB_LAST_ROW_MEM); + } if (TSDB_CODE_SUCCESS == code) { code = checkRangeOption(pCxt, "compression", pOptions->compressionLevel, TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL); } @@ -3271,7 +3268,8 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; pReq->walLevel = pStmt->pOptions->walLevel; pReq->strict = pStmt->pOptions->strict; - pReq->cacheLastRow = pStmt->pOptions->cachelast; + pReq->cacheLastRow = pStmt->pOptions->cacheLast; + pReq->lastRowMem = pStmt->pOptions->cacheLastSize; pReq->replications = pStmt->pOptions->replica; return; } @@ -5364,7 +5362,8 @@ static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch return TSDB_CODE_SUCCESS; } -static void destroyCreateTbReqBatch(SVgroupCreateTableBatch* pTbBatch) { +static void destroyCreateTbReqBatch(void* data) { + SVgroupCreateTableBatch* pTbBatch = (SVgroupCreateTableBatch*) data; size_t size = taosArrayGetSize(pTbBatch->req.pArray); for (int32_t i = 0; i < size; ++i) { SVCreateTbReq* pTableReq = taosArrayGet(pTbBatch->req.pArray, i); @@ -5381,7 +5380,7 @@ static void destroyCreateTbReqBatch(SVgroupCreateTableBatch* pTbBatch) { taosArrayDestroy(pTbBatch->req.pArray); } -static int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray) { +int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray) { SVnodeModifOpStmt* pNewStmt = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT); if (pNewStmt == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -5447,10 +5446,10 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, SCreateSubTableClause* pStmt, const STag* pTag, uint64_t suid, SVgroupInfo* pVgInfo) { - char dbFName[TSDB_DB_FNAME_LEN] = {0}; - SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId}; - strcpy(name.dbname, pStmt->dbName); - tNameGetFullDbName(&name, dbFName); +// char dbFName[TSDB_DB_FNAME_LEN] = {0}; +// SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId}; +// strcpy(name.dbname, pStmt->dbName); +// tNameGetFullDbName(&name, dbFName); struct SVCreateTbReq req = {0}; req.type = TD_CHILD_TABLE; @@ -5711,7 +5710,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla return code; } -static SArray* serializeVgroupsCreateTableBatch(int32_t acctId, SHashObj* pVgroupHashmap) { +SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap) { SArray* pBufArray = taosArrayInit(taosHashGetSize(pVgroupHashmap), sizeof(void*)); if (NULL == pBufArray) { return NULL; @@ -5726,7 +5725,6 @@ static SArray* serializeVgroupsCreateTableBatch(int32_t acctId, SHashObj* pVgrou } serializeVgroupCreateTableBatch(pTbBatch, pBufArray); - destroyCreateTbReqBatch(pTbBatch); } while (true); return pBufArray; @@ -5740,6 +5738,7 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery) return TSDB_CODE_OUT_OF_MEMORY; } + taosHashSetFreeFp(pVgroupHashmap, destroyCreateTbReqBatch); int32_t code = TSDB_CODE_SUCCESS; SNode* pNode; FOREACH(pNode, pStmt->pSubTables) { @@ -5751,7 +5750,7 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery) } } - SArray* pBufArray = serializeVgroupsCreateTableBatch(pCxt->pParseCxt->acctId, pVgroupHashmap); + SArray* pBufArray = serializeVgroupsCreateTableBatch(pVgroupHashmap); taosHashCleanup(pVgroupHashmap); if (NULL == pBufArray) { return TSDB_CODE_OUT_OF_MEMORY; @@ -5811,7 +5810,10 @@ over: return code; } -static void destroyDropTbReqBatch(SVgroupDropTableBatch* pTbBatch) { taosArrayDestroy(pTbBatch->req.pArray); } +static void destroyDropTbReqBatch(void* data) { + SVgroupDropTableBatch* pTbBatch = (SVgroupDropTableBatch*)data; + taosArrayDestroy(pTbBatch->req.pArray); +} static int32_t serializeVgroupDropTableBatch(SVgroupDropTableBatch* pTbBatch, SArray* pBufArray) { int tlen; @@ -5845,7 +5847,7 @@ static int32_t serializeVgroupDropTableBatch(SVgroupDropTableBatch* pTbBatch, SA return TSDB_CODE_SUCCESS; } -static SArray* serializeVgroupsDropTableBatch(int32_t acctId, SHashObj* pVgroupHashmap) { +SArray* serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap) { SArray* pBufArray = taosArrayInit(taosHashGetSize(pVgroupHashmap), sizeof(void*)); if (NULL == pBufArray) { return NULL; @@ -5860,7 +5862,6 @@ static SArray* serializeVgroupsDropTableBatch(int32_t acctId, SHashObj* pVgroupH } serializeVgroupDropTableBatch(pTbBatch, pBufArray); - destroyDropTbReqBatch(pTbBatch); } while (true); return pBufArray; @@ -5874,6 +5875,7 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } + taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch); bool isSuperTable = false; SNode* pNode; FOREACH(pNode, pStmt->pTables) { @@ -5892,7 +5894,7 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) { return TSDB_CODE_SUCCESS; } - SArray* pBufArray = serializeVgroupsDropTableBatch(pCxt->pParseCxt->acctId, pVgroupHashmap); + SArray* pBufArray = serializeVgroupsDropTableBatch(pVgroupHashmap); taosHashCleanup(pVgroupHashmap); if (NULL == pBufArray) { return TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index 4f8ea00271..b36adbe5d4 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -39,6 +39,9 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) { if (TK_USING == t.type || TK_VALUES == t.type) { return true; } + if (0 == t.type) { + break; + } } while (pStr - pSql < length); return false; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 1bc204b9d9..124d1b2270 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,26 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 376 +#define YYNOCODE 377 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EJoinType yy52; - bool yy89; - SDataType yy224; - int32_t yy228; - SNode* yy248; - SAlterOption yy301; - ENullOrder yy345; - SToken yy401; - EOrder yy482; - int64_t yy525; - SNodeList* yy552; - EFillMode yy582; - int8_t yy695; - EOperatorType yy716; + SToken yy5; + EJoinType yy74; + SNodeList* yy210; + EFillMode yy270; + int64_t yy311; + SAlterOption yy351; + bool yy403; + EOperatorType yy428; + int32_t yy462; + ENullOrder yy477; + int8_t yy535; + SDataType yy552; + EOrder yy553; + SNode* yy652; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 661 -#define YYNRULE 485 -#define YYNTOKEN 253 -#define YY_MAX_SHIFT 660 -#define YY_MIN_SHIFTREDUCE 962 -#define YY_MAX_SHIFTREDUCE 1446 -#define YY_ERROR_ACTION 1447 -#define YY_ACCEPT_ACTION 1448 -#define YY_NO_ACTION 1449 -#define YY_MIN_REDUCE 1450 -#define YY_MAX_REDUCE 1934 +#define YYNSTATE 663 +#define YYNRULE 487 +#define YYNTOKEN 254 +#define YY_MAX_SHIFT 662 +#define YY_MIN_SHIFTREDUCE 966 +#define YY_MAX_SHIFTREDUCE 1452 +#define YY_ERROR_ACTION 1453 +#define YY_ACCEPT_ACTION 1454 +#define YY_NO_ACTION 1455 +#define YY_MIN_REDUCE 1456 +#define YY_MAX_REDUCE 1942 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,658 +216,656 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2363) +#define YY_ACTTAB_COUNT (2360) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 430, 549, 431, 1485, 438, 1685, 431, 1485, 1576, 549, - /* 10 */ 34, 33, 40, 38, 41, 39, 37, 36, 35, 1753, - /* 20 */ 337, 71, 1248, 1451, 379, 1756, 435, 342, 552, 122, - /* 30 */ 1630, 1632, 1270, 1323, 117, 1246, 1753, 122, 41, 39, - /* 40 */ 37, 36, 35, 1580, 103, 1749, 1755, 102, 101, 100, - /* 50 */ 99, 98, 97, 96, 95, 94, 1318, 570, 554, 1912, - /* 60 */ 14, 1448, 1749, 1755, 326, 1912, 1254, 1769, 62, 120, - /* 70 */ 385, 1012, 1911, 1011, 570, 447, 1909, 120, 159, 40, - /* 80 */ 38, 1386, 1909, 1, 156, 1854, 1855, 337, 1859, 1248, - /* 90 */ 1273, 44, 249, 1854, 548, 1787, 547, 995, 513, 1912, - /* 100 */ 1323, 1013, 1246, 577, 1473, 657, 323, 301, 1739, 1682, - /* 110 */ 576, 142, 161, 1462, 61, 1912, 1909, 482, 481, 1325, - /* 120 */ 1326, 349, 480, 1318, 554, 118, 477, 14, 160, 476, - /* 130 */ 475, 474, 1909, 1254, 1681, 1800, 298, 999, 1000, 89, - /* 140 */ 1770, 579, 1772, 1773, 575, 1739, 570, 61, 610, 1846, - /* 150 */ 2, 34, 33, 304, 1842, 41, 39, 37, 36, 35, - /* 160 */ 220, 221, 1912, 1912, 1249, 1912, 1247, 131, 130, 607, - /* 170 */ 606, 605, 657, 1512, 552, 159, 1910, 1637, 161, 1909, - /* 180 */ 1909, 143, 1909, 418, 325, 1542, 1325, 1326, 1450, 1145, - /* 190 */ 1146, 1252, 1253, 1635, 1301, 1302, 1304, 1305, 1306, 1307, - /* 200 */ 1308, 572, 568, 1316, 1317, 1319, 1320, 1321, 1322, 1324, - /* 210 */ 1327, 61, 112, 111, 110, 109, 108, 107, 106, 105, - /* 220 */ 104, 303, 558, 162, 515, 31, 259, 1417, 214, 174, - /* 230 */ 173, 1249, 219, 1247, 71, 634, 633, 632, 345, 1407, - /* 240 */ 631, 630, 629, 123, 624, 623, 622, 621, 620, 619, - /* 250 */ 618, 617, 133, 613, 162, 61, 1581, 75, 1252, 1253, - /* 260 */ 1273, 1301, 1302, 1304, 1305, 1306, 1307, 1308, 572, 568, - /* 270 */ 1316, 1317, 1319, 1320, 1321, 1322, 1324, 1327, 40, 38, - /* 280 */ 535, 1405, 1406, 1408, 1409, 549, 337, 162, 1248, 627, - /* 290 */ 512, 378, 347, 377, 1228, 1229, 1631, 1632, 370, 1323, - /* 300 */ 1563, 1246, 1103, 601, 600, 599, 1107, 598, 1109, 1110, - /* 310 */ 597, 1112, 594, 122, 1118, 591, 1120, 1121, 588, 585, - /* 320 */ 372, 368, 1318, 498, 479, 478, 14, 525, 1561, 525, - /* 330 */ 373, 1912, 1254, 1912, 554, 40, 38, 1769, 164, 1248, - /* 340 */ 113, 86, 1272, 337, 159, 1248, 159, 468, 1909, 2, - /* 350 */ 1909, 162, 1246, 120, 119, 1585, 1323, 1585, 1246, 447, - /* 360 */ 543, 1012, 1577, 1011, 1912, 1787, 207, 1472, 249, 1854, - /* 370 */ 548, 657, 547, 577, 1787, 1912, 466, 159, 1739, 1318, - /* 380 */ 576, 1909, 542, 1254, 552, 1325, 1326, 612, 159, 1254, - /* 390 */ 1471, 1013, 1909, 103, 554, 162, 102, 101, 100, 99, - /* 400 */ 98, 97, 96, 95, 94, 1800, 8, 1757, 1739, 89, - /* 410 */ 1770, 579, 1772, 1773, 575, 1065, 570, 538, 1753, 1846, - /* 420 */ 541, 559, 657, 304, 1842, 73, 303, 612, 657, 515, - /* 430 */ 1249, 1739, 1247, 34, 33, 1912, 496, 41, 39, 37, - /* 440 */ 36, 35, 1325, 1326, 1749, 1755, 1067, 43, 159, 494, - /* 450 */ 1470, 492, 1909, 1390, 1274, 1037, 570, 1252, 1253, 1272, - /* 460 */ 1301, 1302, 1304, 1305, 1306, 1307, 1308, 572, 568, 1316, - /* 470 */ 1317, 1319, 1320, 1321, 1322, 1324, 1327, 11, 10, 549, - /* 480 */ 1562, 1249, 525, 1247, 525, 549, 1038, 1249, 153, 1247, - /* 490 */ 79, 1739, 1861, 165, 1726, 383, 544, 539, 34, 33, - /* 500 */ 314, 1624, 41, 39, 37, 36, 35, 122, 1252, 1253, - /* 510 */ 1585, 1578, 1585, 122, 1252, 1253, 1858, 1301, 1302, 1304, - /* 520 */ 1305, 1306, 1307, 1308, 572, 568, 1316, 1317, 1319, 1320, - /* 530 */ 1321, 1322, 1324, 1327, 40, 38, 1328, 525, 37, 36, - /* 540 */ 35, 358, 337, 1769, 1248, 525, 162, 120, 384, 315, - /* 550 */ 305, 313, 312, 120, 470, 1323, 388, 1246, 472, 324, - /* 560 */ 1359, 551, 155, 1854, 1855, 1585, 1859, 140, 157, 1854, - /* 570 */ 1855, 1787, 1859, 1585, 1286, 610, 1587, 1271, 1318, 553, - /* 580 */ 471, 1443, 1345, 1333, 1739, 251, 576, 162, 1254, 1272, - /* 590 */ 85, 40, 38, 1515, 131, 130, 607, 606, 605, 337, - /* 600 */ 82, 1248, 34, 33, 1861, 9, 41, 39, 37, 36, - /* 610 */ 35, 1800, 1323, 566, 1246, 90, 1770, 579, 1772, 1773, - /* 620 */ 575, 525, 570, 429, 170, 1846, 433, 657, 1857, 330, - /* 630 */ 1842, 154, 113, 525, 1303, 1318, 1346, 23, 1680, 473, - /* 640 */ 298, 1325, 1326, 158, 403, 1254, 525, 1675, 1469, 1585, - /* 650 */ 69, 1872, 1254, 68, 525, 482, 481, 404, 172, 1351, - /* 660 */ 480, 1585, 9, 118, 477, 446, 1275, 476, 475, 474, - /* 670 */ 1442, 34, 33, 340, 1585, 41, 39, 37, 36, 35, - /* 680 */ 1637, 140, 1585, 525, 657, 604, 1249, 341, 1247, 1739, - /* 690 */ 1587, 615, 1468, 616, 1582, 1557, 1635, 1383, 1325, 1326, - /* 700 */ 1560, 30, 335, 1340, 1341, 1342, 1343, 1344, 1348, 1349, - /* 710 */ 1350, 1585, 437, 1252, 1253, 433, 1301, 1302, 1304, 1305, - /* 720 */ 1306, 1307, 1308, 572, 568, 1316, 1317, 1319, 1320, 1321, - /* 730 */ 1322, 1324, 1327, 1739, 34, 33, 628, 626, 41, 39, - /* 740 */ 37, 36, 35, 1249, 1337, 1247, 27, 1397, 608, 999, - /* 750 */ 1000, 1628, 34, 33, 140, 29, 41, 39, 37, 36, - /* 760 */ 35, 34, 33, 1588, 1303, 41, 39, 37, 36, 35, - /* 770 */ 1252, 1253, 59, 1301, 1302, 1304, 1305, 1306, 1307, 1308, - /* 780 */ 572, 568, 1316, 1317, 1319, 1320, 1321, 1322, 1324, 1327, - /* 790 */ 40, 38, 300, 1272, 1270, 610, 660, 231, 337, 1769, - /* 800 */ 1248, 411, 1574, 1347, 423, 1467, 1466, 1465, 525, 525, - /* 810 */ 266, 1323, 1464, 1246, 131, 130, 607, 606, 605, 1714, - /* 820 */ 506, 396, 1461, 424, 151, 398, 1352, 1787, 7, 650, - /* 830 */ 646, 642, 638, 264, 1318, 577, 1585, 1585, 525, 1460, - /* 840 */ 1739, 525, 576, 343, 1254, 1570, 1739, 1739, 1739, 510, - /* 850 */ 42, 140, 523, 1739, 513, 609, 389, 561, 1628, 87, - /* 860 */ 1587, 2, 229, 1739, 1861, 1683, 1585, 1800, 28, 1585, - /* 870 */ 472, 91, 1770, 579, 1772, 1773, 575, 139, 570, 1459, - /* 880 */ 1739, 1846, 1458, 657, 1457, 1845, 1842, 271, 1856, 1456, - /* 890 */ 1615, 1196, 471, 1866, 1379, 522, 422, 1325, 1326, 417, - /* 900 */ 416, 415, 414, 413, 410, 409, 408, 407, 406, 402, - /* 910 */ 401, 400, 399, 393, 392, 391, 390, 1382, 387, 386, - /* 920 */ 1739, 1455, 1454, 1739, 1637, 1739, 141, 216, 34, 33, - /* 930 */ 1739, 277, 41, 39, 37, 36, 35, 45, 4, 1502, - /* 940 */ 1636, 1572, 1249, 525, 1247, 275, 58, 1568, 1220, 57, - /* 950 */ 209, 34, 33, 1453, 524, 41, 39, 37, 36, 35, - /* 960 */ 210, 483, 1739, 1739, 1769, 176, 426, 1497, 1303, 1252, - /* 970 */ 1253, 1585, 1301, 1302, 1304, 1305, 1306, 1307, 1308, 572, - /* 980 */ 568, 1316, 1317, 1319, 1320, 1321, 1322, 1324, 1327, 485, - /* 990 */ 198, 61, 1787, 196, 1739, 525, 200, 525, 202, 199, - /* 1000 */ 553, 201, 1495, 305, 1286, 1739, 260, 576, 344, 556, - /* 1010 */ 204, 1379, 218, 203, 125, 213, 52, 509, 128, 129, - /* 1020 */ 1759, 50, 1257, 1585, 488, 1585, 235, 11, 10, 88, - /* 1030 */ 571, 603, 1800, 1256, 505, 1345, 90, 1770, 579, 1772, - /* 1040 */ 1773, 575, 1769, 570, 74, 1463, 1846, 1445, 1446, 42, - /* 1050 */ 330, 1842, 154, 222, 1543, 518, 254, 1761, 562, 228, - /* 1060 */ 1096, 42, 1404, 42, 66, 65, 382, 238, 583, 169, - /* 1070 */ 1787, 536, 1873, 465, 499, 376, 243, 1788, 577, 128, - /* 1080 */ 346, 129, 114, 1739, 1491, 576, 128, 1486, 299, 1346, - /* 1090 */ 1353, 366, 1625, 364, 360, 356, 166, 351, 348, 1876, - /* 1100 */ 550, 248, 1309, 253, 270, 256, 258, 3, 53, 1124, - /* 1110 */ 1800, 80, 1351, 5, 90, 1770, 579, 1772, 1773, 575, - /* 1120 */ 1128, 570, 1135, 1133, 1846, 328, 327, 132, 330, 1842, - /* 1130 */ 1925, 162, 652, 350, 1270, 1262, 353, 357, 310, 1880, - /* 1140 */ 1769, 1065, 1212, 311, 267, 405, 1323, 1677, 1255, 171, - /* 1150 */ 412, 193, 419, 1260, 30, 335, 1340, 1341, 1342, 1343, - /* 1160 */ 1344, 1348, 1349, 1350, 1259, 146, 1769, 420, 1787, 1318, - /* 1170 */ 464, 460, 456, 452, 192, 1276, 577, 487, 421, 1254, - /* 1180 */ 425, 1739, 427, 576, 428, 436, 1279, 439, 440, 179, - /* 1190 */ 181, 1278, 497, 442, 1787, 1280, 1277, 441, 184, 444, - /* 1200 */ 72, 186, 577, 190, 445, 188, 206, 1739, 1800, 576, - /* 1210 */ 70, 448, 90, 1770, 579, 1772, 1773, 575, 534, 570, - /* 1220 */ 490, 191, 1846, 467, 484, 469, 330, 1842, 1925, 205, - /* 1230 */ 1575, 1719, 195, 1769, 1800, 1571, 197, 1903, 90, 1770, - /* 1240 */ 579, 1772, 1773, 575, 134, 570, 135, 1573, 1846, 93, - /* 1250 */ 1569, 302, 330, 1842, 1925, 56, 136, 137, 55, 268, - /* 1260 */ 208, 1787, 501, 1865, 500, 189, 182, 504, 187, 577, - /* 1270 */ 211, 507, 443, 511, 1739, 533, 576, 1263, 215, 1258, - /* 1280 */ 519, 514, 320, 1718, 224, 1687, 1769, 126, 516, 127, - /* 1290 */ 554, 180, 322, 226, 269, 520, 1769, 78, 1275, 537, - /* 1300 */ 1586, 1800, 521, 6, 1266, 284, 1770, 579, 1772, 1773, - /* 1310 */ 575, 233, 570, 529, 1787, 568, 1316, 1317, 1319, 1320, - /* 1320 */ 1321, 1322, 577, 1877, 1787, 237, 531, 1739, 530, 576, - /* 1330 */ 532, 1912, 577, 546, 329, 528, 527, 1739, 540, 576, - /* 1340 */ 121, 1379, 1887, 554, 161, 247, 1274, 563, 1909, 560, - /* 1350 */ 1886, 1769, 19, 581, 1800, 331, 1629, 245, 284, 1770, - /* 1360 */ 579, 1772, 1773, 575, 1800, 570, 272, 1769, 91, 1770, - /* 1370 */ 579, 1772, 1773, 575, 1868, 570, 246, 242, 1846, 1787, - /* 1380 */ 1862, 244, 565, 1842, 1912, 1928, 1558, 574, 1827, 263, - /* 1390 */ 653, 656, 1739, 252, 576, 1787, 654, 159, 51, 147, - /* 1400 */ 285, 1909, 148, 577, 1908, 557, 295, 294, 1739, 274, - /* 1410 */ 576, 276, 1733, 255, 63, 1732, 564, 1769, 257, 1800, - /* 1420 */ 1731, 1730, 64, 292, 1770, 579, 1772, 1773, 575, 573, - /* 1430 */ 570, 567, 1818, 1769, 352, 1800, 1727, 355, 354, 144, - /* 1440 */ 1770, 579, 1772, 1773, 575, 1787, 570, 359, 1240, 1241, - /* 1450 */ 1725, 167, 361, 577, 362, 363, 1724, 365, 1739, 1723, - /* 1460 */ 576, 1787, 367, 1722, 369, 1721, 321, 371, 1704, 577, - /* 1470 */ 168, 374, 375, 1215, 1739, 1769, 576, 1214, 1698, 1697, - /* 1480 */ 380, 381, 1696, 555, 1926, 1800, 1695, 1184, 1670, 91, - /* 1490 */ 1770, 579, 1772, 1773, 575, 1769, 570, 1669, 1668, 1846, - /* 1500 */ 67, 1800, 1667, 1787, 1843, 293, 1770, 579, 1772, 1773, - /* 1510 */ 575, 577, 570, 1666, 1665, 1664, 1739, 1663, 576, 394, - /* 1520 */ 395, 1662, 397, 1787, 1661, 1660, 1659, 1658, 526, 1657, - /* 1530 */ 1656, 577, 124, 1647, 1646, 1645, 1739, 1655, 576, 1654, - /* 1540 */ 1653, 1652, 1651, 1800, 1650, 1649, 1648, 288, 1770, 579, - /* 1550 */ 1772, 1773, 575, 1769, 570, 1644, 1643, 1642, 1186, 1641, - /* 1560 */ 1640, 1639, 1638, 1800, 1516, 1769, 175, 293, 1770, 579, - /* 1570 */ 1772, 1773, 575, 1514, 570, 1769, 1482, 1002, 1481, 1001, - /* 1580 */ 177, 1787, 115, 1712, 1706, 545, 1694, 1693, 178, 577, - /* 1590 */ 152, 116, 185, 1787, 1739, 432, 576, 434, 334, 1679, - /* 1600 */ 1564, 577, 1513, 1787, 1511, 183, 1739, 449, 576, 451, - /* 1610 */ 1509, 574, 453, 455, 450, 1031, 1739, 1507, 576, 459, - /* 1620 */ 457, 1800, 454, 1505, 1494, 144, 1770, 579, 1772, 1773, - /* 1630 */ 575, 461, 570, 1800, 1493, 1769, 458, 293, 1770, 579, - /* 1640 */ 1772, 1773, 575, 1800, 570, 462, 463, 292, 1770, 579, - /* 1650 */ 1772, 1773, 575, 1478, 570, 1566, 1819, 1139, 1769, 194, - /* 1660 */ 49, 1138, 1565, 1787, 1064, 1063, 1062, 1061, 336, 625, - /* 1670 */ 1927, 577, 1058, 1057, 1503, 1056, 1739, 1498, 576, 627, - /* 1680 */ 316, 317, 486, 1496, 489, 318, 1787, 1477, 1476, 491, - /* 1690 */ 1475, 338, 493, 495, 577, 92, 1711, 1705, 138, 1739, - /* 1700 */ 1769, 576, 1222, 1800, 502, 1692, 212, 293, 1770, 579, - /* 1710 */ 1772, 1773, 575, 1690, 570, 1691, 1689, 1769, 15, 1686, - /* 1720 */ 1678, 82, 54, 1688, 225, 217, 1800, 223, 1787, 1232, - /* 1730 */ 293, 1770, 579, 1772, 1773, 575, 577, 570, 230, 503, - /* 1740 */ 1419, 1739, 319, 576, 76, 1787, 508, 42, 77, 16, - /* 1750 */ 517, 24, 227, 577, 234, 232, 241, 1401, 1739, 236, - /* 1760 */ 576, 1264, 1403, 145, 48, 1396, 1431, 1769, 1800, 239, - /* 1770 */ 240, 1759, 278, 1770, 579, 1772, 1773, 575, 25, 570, - /* 1780 */ 26, 81, 250, 1376, 1375, 1800, 47, 1758, 1769, 279, - /* 1790 */ 1770, 579, 1772, 1773, 575, 1787, 570, 149, 1436, 18, - /* 1800 */ 1430, 1425, 46, 577, 332, 1435, 17, 1434, 1739, 1769, - /* 1810 */ 576, 333, 10, 1803, 20, 569, 1787, 13, 1338, 1313, - /* 1820 */ 150, 163, 1311, 32, 577, 1294, 1310, 580, 12, 1739, - /* 1830 */ 21, 576, 22, 582, 1125, 1800, 578, 1787, 584, 280, - /* 1840 */ 1770, 579, 1772, 1773, 575, 577, 570, 339, 1122, 586, - /* 1850 */ 1739, 1769, 576, 589, 592, 595, 1800, 1119, 1102, 1117, - /* 1860 */ 287, 1770, 579, 1772, 1773, 575, 587, 570, 1769, 590, - /* 1870 */ 1116, 1113, 593, 1115, 1111, 596, 602, 1800, 83, 1787, - /* 1880 */ 84, 289, 1770, 579, 1772, 1773, 575, 577, 570, 1114, - /* 1890 */ 1134, 60, 1739, 261, 576, 1130, 1787, 1071, 1029, 611, - /* 1900 */ 1053, 262, 614, 1051, 577, 1050, 1049, 1048, 1046, 1739, - /* 1910 */ 1047, 576, 1045, 1044, 1068, 1066, 1041, 1040, 1039, 1800, - /* 1920 */ 1769, 636, 1036, 281, 1770, 579, 1772, 1773, 575, 1035, - /* 1930 */ 570, 1034, 1510, 635, 637, 1508, 1800, 639, 640, 641, - /* 1940 */ 290, 1770, 579, 1772, 1773, 575, 1506, 570, 1787, 643, - /* 1950 */ 644, 645, 1504, 647, 648, 649, 577, 1492, 651, 992, - /* 1960 */ 1474, 1739, 265, 576, 655, 1449, 1250, 273, 658, 659, - /* 1970 */ 1449, 1449, 1449, 1449, 1769, 1449, 1449, 1449, 1449, 1449, - /* 1980 */ 1449, 1449, 1449, 1449, 1449, 1449, 1449, 1449, 1800, 1449, - /* 1990 */ 1769, 1449, 282, 1770, 579, 1772, 1773, 575, 1449, 570, - /* 2000 */ 1769, 1449, 1787, 1449, 1449, 1449, 1449, 1449, 1449, 1449, - /* 2010 */ 577, 1449, 1449, 1449, 1449, 1739, 1449, 576, 1787, 1449, - /* 2020 */ 1449, 1449, 1449, 1449, 1449, 1449, 577, 1449, 1787, 1449, - /* 2030 */ 1449, 1739, 1449, 576, 1449, 1449, 577, 1449, 1449, 1449, - /* 2040 */ 1449, 1739, 1800, 576, 1449, 1449, 291, 1770, 579, 1772, - /* 2050 */ 1773, 575, 1769, 570, 1449, 1449, 1449, 1449, 1800, 1449, - /* 2060 */ 1449, 1449, 283, 1770, 579, 1772, 1773, 575, 1800, 570, - /* 2070 */ 1449, 1449, 296, 1770, 579, 1772, 1773, 575, 1449, 570, - /* 2080 */ 1787, 1449, 1449, 1449, 1449, 1449, 1449, 1449, 577, 1449, - /* 2090 */ 1449, 1449, 1449, 1739, 1769, 576, 1449, 1449, 1449, 1449, - /* 2100 */ 1449, 1449, 1449, 1449, 1449, 1449, 1449, 1449, 1769, 1449, - /* 2110 */ 1449, 1449, 1449, 1449, 1449, 1449, 1449, 1449, 1769, 1449, - /* 2120 */ 1800, 1449, 1787, 1449, 297, 1770, 579, 1772, 1773, 575, - /* 2130 */ 577, 570, 1449, 1449, 1449, 1739, 1787, 576, 1449, 1449, - /* 2140 */ 1449, 1449, 1449, 1449, 577, 1449, 1787, 1449, 1449, 1739, - /* 2150 */ 1449, 576, 1449, 1449, 577, 1449, 1449, 1449, 1449, 1739, - /* 2160 */ 1449, 576, 1800, 1449, 1449, 1449, 1781, 1770, 579, 1772, - /* 2170 */ 1773, 575, 1449, 570, 1449, 1449, 1800, 1769, 1449, 1449, - /* 2180 */ 1780, 1770, 579, 1772, 1773, 575, 1800, 570, 1449, 1449, - /* 2190 */ 1779, 1770, 579, 1772, 1773, 575, 1449, 570, 1769, 1449, - /* 2200 */ 1449, 1449, 1449, 1449, 1449, 1787, 1449, 1449, 1449, 1449, - /* 2210 */ 1449, 1449, 1449, 577, 1449, 1449, 1449, 1449, 1739, 1449, - /* 2220 */ 576, 1449, 1449, 1449, 1449, 1449, 1787, 1449, 1449, 1449, - /* 2230 */ 1449, 1449, 1449, 1449, 577, 1449, 1449, 1449, 1449, 1739, - /* 2240 */ 1449, 576, 1449, 1449, 1449, 1800, 1449, 1449, 1449, 308, - /* 2250 */ 1770, 579, 1772, 1773, 575, 1449, 570, 1769, 1449, 1449, - /* 2260 */ 1449, 1449, 1449, 1449, 1449, 1449, 1800, 1769, 1449, 1449, - /* 2270 */ 307, 1770, 579, 1772, 1773, 575, 1449, 570, 1449, 1449, - /* 2280 */ 1449, 1449, 1449, 1769, 1449, 1787, 1449, 1449, 1449, 1449, - /* 2290 */ 1449, 1449, 1449, 577, 1449, 1787, 1449, 1449, 1739, 1449, - /* 2300 */ 576, 1449, 1449, 577, 1449, 1449, 1449, 1449, 1739, 1449, - /* 2310 */ 576, 1787, 1449, 1449, 1449, 1449, 1449, 1449, 1449, 577, - /* 2320 */ 1449, 1449, 1449, 1449, 1739, 1800, 576, 1449, 1449, 309, - /* 2330 */ 1770, 579, 1772, 1773, 575, 1800, 570, 1449, 1449, 306, - /* 2340 */ 1770, 579, 1772, 1773, 575, 1449, 570, 1449, 1449, 1449, - /* 2350 */ 1449, 1800, 1449, 1449, 1449, 286, 1770, 579, 1772, 1773, - /* 2360 */ 575, 1449, 570, + /* 0 */ 430, 1920, 431, 1491, 438, 71, 431, 1491, 514, 62, + /* 10 */ 1645, 1693, 40, 38, 1919, 550, 323, 325, 1917, 1690, + /* 20 */ 337, 86, 1254, 1457, 34, 33, 1643, 1589, 41, 39, + /* 30 */ 37, 36, 35, 1329, 119, 1252, 1777, 41, 39, 37, + /* 40 */ 36, 35, 1585, 122, 103, 1734, 550, 102, 101, 100, + /* 50 */ 99, 98, 97, 96, 95, 94, 1324, 526, 550, 23, + /* 60 */ 14, 1016, 342, 1015, 1795, 1638, 1640, 1260, 113, 142, + /* 70 */ 1795, 1468, 578, 79, 122, 468, 466, 1747, 543, 577, + /* 80 */ 40, 38, 1392, 120, 1, 1593, 122, 61, 337, 61, + /* 90 */ 1254, 1017, 358, 555, 1586, 555, 379, 552, 155, 1862, + /* 100 */ 1863, 1329, 1867, 1252, 1808, 1479, 659, 1521, 89, 1778, + /* 110 */ 580, 1780, 1781, 576, 120, 571, 542, 553, 1854, 553, + /* 120 */ 1331, 1332, 304, 1850, 1324, 1478, 120, 526, 14, 249, + /* 130 */ 1862, 549, 1456, 548, 1920, 1260, 1920, 1920, 164, 31, + /* 140 */ 259, 156, 1862, 1863, 1777, 1867, 1747, 161, 447, 161, + /* 150 */ 159, 1917, 2, 1917, 1917, 1593, 112, 111, 110, 109, + /* 160 */ 108, 107, 106, 105, 104, 1255, 1747, 1253, 1279, 483, + /* 170 */ 482, 481, 1795, 1920, 659, 480, 220, 221, 118, 477, + /* 180 */ 578, 44, 476, 475, 474, 1747, 160, 577, 1331, 1332, + /* 190 */ 1917, 429, 1258, 1259, 433, 1307, 1308, 1310, 1311, 1312, + /* 200 */ 1313, 1314, 573, 569, 1322, 1323, 1325, 1326, 1327, 1328, + /* 210 */ 1330, 1333, 1808, 1413, 1278, 539, 90, 1778, 580, 1780, + /* 220 */ 1781, 576, 1279, 571, 162, 1454, 1854, 162, 553, 162, + /* 230 */ 330, 1850, 1933, 1255, 314, 1253, 61, 303, 140, 143, + /* 240 */ 516, 1888, 999, 1549, 34, 33, 1645, 1596, 41, 39, + /* 250 */ 37, 36, 35, 341, 536, 1411, 1412, 1414, 1415, 1477, + /* 260 */ 1258, 1259, 1643, 1307, 1308, 1310, 1311, 1312, 1313, 1314, + /* 270 */ 573, 569, 1322, 1323, 1325, 1326, 1327, 1328, 1330, 1333, + /* 280 */ 40, 38, 1003, 1004, 315, 349, 313, 312, 337, 470, + /* 290 */ 1254, 1777, 43, 472, 545, 540, 305, 1353, 11, 10, + /* 300 */ 1747, 1329, 103, 1252, 153, 102, 101, 100, 99, 98, + /* 310 */ 97, 96, 95, 94, 385, 471, 378, 1632, 377, 1795, + /* 320 */ 1358, 1292, 1151, 1152, 1324, 1278, 1920, 554, 14, 1351, + /* 330 */ 1639, 1640, 1747, 437, 577, 1260, 433, 40, 38, 159, + /* 340 */ 483, 482, 481, 1917, 1920, 337, 480, 1254, 1518, 118, + /* 350 */ 477, 301, 2, 476, 475, 474, 605, 1918, 1329, 1808, + /* 360 */ 1252, 1917, 28, 90, 1778, 580, 1780, 1781, 576, 435, + /* 370 */ 571, 71, 370, 1854, 659, 1276, 162, 330, 1850, 154, + /* 380 */ 1396, 1324, 1365, 1352, 117, 1016, 1278, 1015, 1331, 1332, + /* 390 */ 1309, 158, 1260, 1588, 372, 368, 544, 34, 33, 1880, + /* 400 */ 1571, 41, 39, 37, 36, 35, 1357, 479, 478, 8, + /* 410 */ 636, 635, 634, 633, 345, 1017, 632, 631, 630, 123, + /* 420 */ 625, 624, 623, 622, 621, 620, 619, 618, 133, 614, + /* 430 */ 324, 659, 162, 1255, 562, 1253, 34, 33, 140, 613, + /* 440 */ 41, 39, 37, 36, 35, 1331, 1332, 1595, 30, 335, + /* 450 */ 1346, 1347, 1348, 1349, 1350, 1354, 1355, 1356, 1280, 447, + /* 460 */ 1258, 1259, 1476, 1307, 1308, 1310, 1311, 1312, 1313, 1314, + /* 470 */ 573, 569, 1322, 1323, 1325, 1326, 1327, 1328, 1330, 1333, + /* 480 */ 34, 33, 214, 526, 41, 39, 37, 36, 35, 170, + /* 490 */ 1255, 207, 1253, 219, 165, 1281, 340, 37, 36, 35, + /* 500 */ 59, 34, 33, 1747, 140, 41, 39, 37, 36, 35, + /* 510 */ 61, 1593, 75, 1595, 629, 627, 69, 1258, 1259, 68, + /* 520 */ 1307, 1308, 1310, 1311, 1312, 1313, 1314, 573, 569, 1322, + /* 530 */ 1323, 1325, 1326, 1327, 1328, 1330, 1333, 40, 38, 1334, + /* 540 */ 1689, 139, 298, 1475, 343, 337, 1777, 1254, 1277, 162, + /* 550 */ 73, 303, 140, 305, 516, 1234, 1235, 1423, 1329, 418, + /* 560 */ 1252, 1595, 1309, 1109, 602, 601, 600, 1113, 599, 1115, + /* 570 */ 1116, 598, 1118, 595, 1795, 1124, 592, 1126, 1127, 589, + /* 580 */ 586, 1324, 578, 488, 1747, 1449, 1351, 1747, 526, 577, + /* 590 */ 251, 472, 1260, 1474, 40, 38, 1683, 1254, 498, 383, + /* 600 */ 45, 4, 337, 555, 1254, 174, 173, 172, 1260, 9, + /* 610 */ 1252, 1071, 206, 471, 1808, 1329, 1593, 1252, 89, 1778, + /* 620 */ 580, 1780, 1781, 576, 497, 571, 491, 231, 1854, 1473, + /* 630 */ 485, 659, 304, 1850, 1747, 205, 563, 495, 1324, 493, + /* 640 */ 1352, 27, 1260, 1073, 1920, 1331, 1332, 34, 33, 1260, + /* 650 */ 162, 41, 39, 37, 36, 35, 1569, 159, 1869, 1472, + /* 660 */ 1471, 1917, 56, 1357, 611, 55, 9, 1869, 559, 526, + /* 670 */ 1747, 34, 33, 1645, 1448, 41, 39, 37, 36, 35, + /* 680 */ 384, 659, 1866, 131, 130, 608, 607, 606, 659, 1644, + /* 690 */ 1255, 1865, 1253, 1003, 1004, 1869, 513, 1593, 1470, 7, + /* 700 */ 1747, 1747, 1331, 1332, 1570, 30, 335, 1346, 1347, 1348, + /* 710 */ 1349, 1350, 1354, 1355, 1356, 613, 1582, 1258, 1259, 1864, + /* 720 */ 1307, 1308, 1310, 1311, 1312, 1313, 1314, 573, 569, 1322, + /* 730 */ 1323, 1325, 1326, 1327, 1328, 1330, 1333, 1920, 557, 1747, + /* 740 */ 1255, 1688, 1253, 298, 617, 29, 1565, 1255, 1403, 1253, + /* 750 */ 159, 34, 33, 514, 1917, 41, 39, 37, 36, 35, + /* 760 */ 347, 1874, 1385, 1263, 1691, 34, 33, 1258, 1259, 41, + /* 770 */ 39, 37, 36, 35, 1258, 1259, 213, 1307, 1308, 1310, + /* 780 */ 1311, 1312, 1313, 1314, 573, 569, 1322, 1323, 1325, 1326, + /* 790 */ 1327, 1328, 1330, 1333, 40, 38, 300, 1578, 1276, 1467, + /* 800 */ 611, 1920, 337, 1777, 1254, 411, 74, 609, 423, 1466, + /* 810 */ 1636, 1508, 1389, 526, 159, 1329, 499, 1252, 1917, 131, + /* 820 */ 130, 608, 607, 606, 388, 396, 1465, 424, 1464, 398, + /* 830 */ 1339, 1795, 610, 484, 271, 1636, 1278, 1623, 1324, 578, + /* 840 */ 1747, 1593, 1292, 1568, 1747, 526, 577, 34, 33, 1260, + /* 850 */ 1747, 41, 39, 37, 36, 35, 113, 1920, 550, 52, + /* 860 */ 510, 389, 198, 473, 1262, 196, 2, 1747, 560, 1747, + /* 870 */ 159, 1808, 616, 1593, 1917, 90, 1778, 580, 1780, 1781, + /* 880 */ 576, 1463, 571, 1385, 1462, 1854, 122, 1461, 659, 330, + /* 890 */ 1850, 1933, 1460, 1459, 200, 1266, 1497, 199, 567, 1580, + /* 900 */ 1911, 422, 1331, 1332, 417, 416, 415, 414, 413, 410, + /* 910 */ 409, 408, 407, 406, 402, 401, 400, 399, 393, 392, + /* 920 */ 391, 390, 1747, 387, 386, 1747, 120, 526, 1747, 526, + /* 930 */ 628, 141, 1576, 1747, 1747, 526, 277, 526, 403, 611, + /* 940 */ 404, 157, 1862, 1863, 654, 1867, 446, 1255, 1590, 1253, + /* 950 */ 275, 58, 11, 10, 57, 1593, 506, 1593, 131, 130, + /* 960 */ 608, 607, 606, 1593, 210, 1593, 1777, 1451, 1452, 572, + /* 970 */ 176, 426, 373, 42, 1258, 1259, 550, 1307, 1308, 1310, + /* 980 */ 1311, 1312, 1313, 1314, 573, 569, 1322, 1323, 1325, 1326, + /* 990 */ 1327, 1328, 1330, 1333, 1795, 526, 1265, 61, 202, 526, + /* 1000 */ 526, 201, 554, 526, 122, 204, 1722, 1747, 203, 577, + /* 1010 */ 507, 511, 1309, 1584, 524, 1202, 218, 1469, 1764, 604, + /* 1020 */ 1550, 526, 254, 1593, 1761, 555, 465, 1593, 1593, 1761, + /* 1030 */ 1343, 1593, 525, 1388, 1808, 88, 526, 1777, 90, 1778, + /* 1040 */ 580, 1780, 1781, 576, 120, 571, 1503, 260, 1854, 1593, + /* 1050 */ 1757, 1763, 330, 1850, 154, 1757, 1763, 326, 222, 249, + /* 1060 */ 1862, 549, 571, 548, 1593, 1795, 1920, 571, 486, 1501, + /* 1070 */ 66, 65, 382, 578, 1881, 169, 537, 243, 1747, 159, + /* 1080 */ 577, 376, 1767, 1917, 125, 328, 327, 526, 128, 1042, + /* 1090 */ 129, 489, 1796, 50, 299, 1268, 235, 366, 344, 364, + /* 1100 */ 360, 356, 166, 351, 348, 1808, 1329, 1765, 1261, 90, + /* 1110 */ 1778, 580, 1780, 1781, 576, 1593, 571, 42, 1761, 1854, + /* 1120 */ 1769, 1043, 42, 330, 1850, 1933, 519, 346, 42, 1324, + /* 1130 */ 228, 584, 1102, 1777, 1873, 1410, 85, 162, 238, 128, + /* 1140 */ 1260, 129, 114, 128, 1757, 1763, 82, 500, 1492, 1633, + /* 1150 */ 551, 1884, 253, 256, 258, 248, 571, 3, 53, 1359, + /* 1160 */ 80, 1795, 5, 350, 1315, 1276, 353, 357, 310, 578, + /* 1170 */ 270, 1071, 1218, 1130, 1747, 311, 577, 405, 267, 535, + /* 1180 */ 1685, 1134, 171, 1141, 1139, 132, 412, 420, 419, 421, + /* 1190 */ 555, 425, 427, 1282, 1777, 1285, 1284, 428, 436, 439, + /* 1200 */ 179, 1808, 440, 181, 441, 284, 1778, 580, 1780, 1781, + /* 1210 */ 576, 1286, 571, 442, 184, 186, 444, 1283, 188, 70, + /* 1220 */ 445, 448, 1795, 191, 467, 469, 1583, 195, 1579, 197, + /* 1230 */ 578, 1920, 134, 135, 93, 1747, 302, 577, 1269, 268, + /* 1240 */ 1264, 208, 1581, 1577, 161, 136, 137, 1777, 1917, 211, + /* 1250 */ 1727, 555, 502, 501, 508, 505, 512, 534, 1281, 215, + /* 1260 */ 515, 1726, 1808, 520, 1695, 1272, 284, 1778, 580, 1780, + /* 1270 */ 1781, 576, 320, 571, 517, 1795, 569, 1322, 1323, 1325, + /* 1280 */ 1326, 1327, 1328, 578, 126, 322, 521, 127, 1747, 224, + /* 1290 */ 577, 522, 1920, 269, 226, 78, 1594, 530, 1885, 1777, + /* 1300 */ 538, 6, 233, 532, 533, 159, 237, 547, 329, 1917, + /* 1310 */ 531, 541, 1385, 528, 1895, 1808, 529, 247, 121, 91, + /* 1320 */ 1778, 580, 1780, 1781, 576, 1894, 571, 1795, 244, 1854, + /* 1330 */ 246, 1876, 148, 1853, 1850, 578, 1280, 564, 1870, 561, + /* 1340 */ 1747, 331, 577, 242, 19, 245, 1835, 582, 272, 1637, + /* 1350 */ 1566, 252, 1777, 655, 1916, 51, 147, 263, 1741, 558, + /* 1360 */ 1936, 656, 658, 285, 63, 255, 1777, 1808, 276, 565, + /* 1370 */ 257, 91, 1778, 580, 1780, 1781, 576, 1740, 571, 274, + /* 1380 */ 1795, 1854, 1739, 295, 294, 566, 1850, 64, 575, 1738, + /* 1390 */ 352, 1735, 354, 1747, 1795, 577, 355, 1246, 1247, 167, + /* 1400 */ 359, 1733, 578, 361, 362, 363, 1732, 1747, 365, 577, + /* 1410 */ 1731, 1730, 369, 367, 1729, 371, 1712, 168, 374, 1777, + /* 1420 */ 1808, 375, 1221, 1220, 292, 1778, 580, 1780, 1781, 576, + /* 1430 */ 574, 571, 568, 1826, 1808, 1706, 1705, 1777, 144, 1778, + /* 1440 */ 580, 1780, 1781, 576, 380, 571, 381, 1795, 1704, 1703, + /* 1450 */ 1190, 1678, 1677, 1676, 67, 578, 1675, 1674, 1673, 1672, + /* 1460 */ 1747, 1671, 577, 394, 395, 1795, 1670, 397, 1669, 1668, + /* 1470 */ 321, 1667, 1666, 578, 1665, 1664, 1663, 1662, 1747, 1661, + /* 1480 */ 577, 1660, 556, 1934, 1659, 1658, 1657, 1808, 1656, 1777, + /* 1490 */ 1655, 91, 1778, 580, 1780, 1781, 576, 124, 571, 1654, + /* 1500 */ 1653, 1854, 1652, 1651, 1650, 1808, 1851, 1649, 1648, 293, + /* 1510 */ 1778, 580, 1780, 1781, 576, 1192, 571, 1795, 1647, 1646, + /* 1520 */ 1522, 175, 527, 1520, 1488, 578, 152, 1006, 115, 177, + /* 1530 */ 1747, 1777, 577, 1487, 178, 1005, 116, 432, 434, 1720, + /* 1540 */ 1714, 1777, 1702, 185, 183, 1701, 1687, 1572, 1519, 1517, + /* 1550 */ 449, 451, 1515, 455, 1513, 459, 1035, 1808, 450, 1795, + /* 1560 */ 453, 293, 1778, 580, 1780, 1781, 576, 578, 571, 1795, + /* 1570 */ 457, 1511, 1747, 454, 577, 458, 461, 578, 462, 1500, + /* 1580 */ 1499, 1484, 1747, 463, 577, 1574, 1145, 1144, 1573, 194, + /* 1590 */ 1070, 1777, 1069, 1068, 49, 1067, 626, 1509, 1064, 1808, + /* 1600 */ 316, 1063, 628, 288, 1778, 580, 1780, 1781, 576, 1808, + /* 1610 */ 571, 662, 1062, 144, 1778, 580, 1780, 1781, 576, 1795, + /* 1620 */ 571, 1061, 1504, 317, 334, 266, 490, 578, 1502, 318, + /* 1630 */ 1483, 487, 1747, 1777, 577, 492, 1482, 494, 1481, 151, + /* 1640 */ 496, 546, 1719, 92, 652, 648, 644, 640, 264, 1713, + /* 1650 */ 1228, 1777, 1700, 138, 503, 1698, 1699, 1697, 1935, 1808, + /* 1660 */ 1696, 1795, 54, 293, 1778, 580, 1780, 1781, 576, 575, + /* 1670 */ 571, 212, 217, 15, 1747, 87, 577, 1694, 229, 1795, + /* 1680 */ 223, 504, 319, 76, 336, 225, 509, 578, 518, 1238, + /* 1690 */ 1686, 227, 1747, 77, 577, 16, 230, 82, 1425, 1437, + /* 1700 */ 24, 1808, 42, 1777, 232, 292, 1778, 580, 1780, 1781, + /* 1710 */ 576, 523, 571, 236, 1827, 1270, 234, 48, 1407, 1808, + /* 1720 */ 1409, 145, 240, 293, 1778, 580, 1780, 1781, 576, 239, + /* 1730 */ 571, 1795, 25, 241, 1767, 193, 338, 26, 1402, 578, + /* 1740 */ 47, 250, 81, 216, 1747, 17, 577, 1382, 1381, 146, + /* 1750 */ 1766, 149, 1442, 1777, 464, 460, 456, 452, 192, 46, + /* 1760 */ 18, 1431, 13, 1777, 1226, 1436, 209, 332, 1441, 1440, + /* 1770 */ 333, 1808, 10, 1811, 20, 293, 1778, 580, 1780, 1781, + /* 1780 */ 576, 1795, 571, 1319, 570, 72, 1344, 32, 190, 578, + /* 1790 */ 150, 1795, 1317, 1316, 1747, 12, 577, 21, 163, 578, + /* 1800 */ 1300, 581, 579, 22, 1747, 1131, 577, 583, 339, 585, + /* 1810 */ 587, 1128, 588, 1108, 1125, 590, 593, 596, 1123, 1777, + /* 1820 */ 591, 1808, 1122, 1119, 594, 278, 1778, 580, 1780, 1781, + /* 1830 */ 576, 1808, 571, 1117, 597, 279, 1778, 580, 1780, 1781, + /* 1840 */ 576, 603, 571, 83, 84, 1140, 60, 1795, 261, 1121, + /* 1850 */ 189, 182, 1136, 187, 1120, 578, 1033, 443, 612, 1058, + /* 1860 */ 1747, 1777, 577, 1077, 262, 615, 1051, 1056, 1055, 1054, + /* 1870 */ 1053, 1777, 1052, 1050, 1049, 1074, 180, 1072, 1046, 1516, + /* 1880 */ 1045, 1044, 1041, 1777, 1040, 1039, 1038, 1808, 637, 1795, + /* 1890 */ 1514, 280, 1778, 580, 1780, 1781, 576, 578, 571, 1795, + /* 1900 */ 639, 638, 1747, 641, 577, 642, 643, 578, 1512, 645, + /* 1910 */ 646, 1795, 1747, 1510, 577, 647, 649, 650, 1498, 578, + /* 1920 */ 653, 651, 996, 1480, 1747, 1777, 577, 265, 657, 1808, + /* 1930 */ 1455, 1256, 273, 287, 1778, 580, 1780, 1781, 576, 1808, + /* 1940 */ 571, 660, 1777, 289, 1778, 580, 1780, 1781, 576, 661, + /* 1950 */ 571, 1808, 1455, 1795, 1455, 281, 1778, 580, 1780, 1781, + /* 1960 */ 576, 578, 571, 1455, 1455, 1455, 1747, 1455, 577, 1455, + /* 1970 */ 1795, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455, + /* 1980 */ 1455, 1455, 1455, 1747, 1777, 577, 1455, 1455, 1455, 1455, + /* 1990 */ 1455, 1455, 1455, 1808, 1777, 1455, 1455, 290, 1778, 580, + /* 2000 */ 1780, 1781, 576, 1455, 571, 1455, 1455, 1455, 1455, 1455, + /* 2010 */ 1808, 1455, 1795, 1455, 282, 1778, 580, 1780, 1781, 576, + /* 2020 */ 578, 571, 1795, 1455, 1455, 1747, 1455, 577, 1455, 1455, + /* 2030 */ 578, 1455, 1455, 1455, 1455, 1747, 1777, 577, 1455, 1455, + /* 2040 */ 1455, 1455, 1455, 1455, 1455, 1455, 1777, 1455, 1455, 1455, + /* 2050 */ 1455, 1455, 1808, 1455, 1455, 1455, 291, 1778, 580, 1780, + /* 2060 */ 1781, 576, 1808, 571, 1795, 1455, 283, 1778, 580, 1780, + /* 2070 */ 1781, 576, 578, 571, 1795, 1455, 1455, 1747, 1455, 577, + /* 2080 */ 1455, 1455, 578, 1455, 1455, 1455, 1455, 1747, 1777, 577, + /* 2090 */ 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1777, 1455, + /* 2100 */ 1455, 1455, 1455, 1455, 1808, 1455, 1455, 1455, 296, 1778, + /* 2110 */ 580, 1780, 1781, 576, 1808, 571, 1795, 1455, 297, 1778, + /* 2120 */ 580, 1780, 1781, 576, 578, 571, 1795, 1455, 1455, 1747, + /* 2130 */ 1455, 577, 1455, 1455, 578, 1455, 1455, 1455, 1455, 1747, + /* 2140 */ 1455, 577, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1455, + /* 2150 */ 1777, 1455, 1455, 1455, 1455, 1455, 1808, 1455, 1455, 1455, + /* 2160 */ 1789, 1778, 580, 1780, 1781, 576, 1808, 571, 1455, 1777, + /* 2170 */ 1788, 1778, 580, 1780, 1781, 576, 1455, 571, 1795, 1455, + /* 2180 */ 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455, 1455, 1455, + /* 2190 */ 1455, 1747, 1777, 577, 1455, 1455, 1455, 1795, 1455, 1455, + /* 2200 */ 1455, 1455, 1455, 1455, 1455, 578, 1455, 1455, 1455, 1455, + /* 2210 */ 1747, 1777, 577, 1455, 1455, 1455, 1455, 1455, 1808, 1455, + /* 2220 */ 1795, 1455, 1787, 1778, 580, 1780, 1781, 576, 578, 571, + /* 2230 */ 1455, 1455, 1455, 1747, 1455, 577, 1455, 1808, 1455, 1795, + /* 2240 */ 1455, 308, 1778, 580, 1780, 1781, 576, 578, 571, 1455, + /* 2250 */ 1455, 1455, 1747, 1455, 577, 1455, 1455, 1455, 1455, 1455, + /* 2260 */ 1808, 1455, 1455, 1455, 307, 1778, 580, 1780, 1781, 576, + /* 2270 */ 1777, 571, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1808, + /* 2280 */ 1777, 1455, 1455, 309, 1778, 580, 1780, 1781, 576, 1455, + /* 2290 */ 571, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1795, 1455, + /* 2300 */ 1455, 1455, 1455, 1455, 1455, 1455, 578, 1455, 1795, 1455, + /* 2310 */ 1455, 1747, 1455, 577, 1455, 1455, 578, 1455, 1455, 1455, + /* 2320 */ 1455, 1747, 1455, 577, 1455, 1455, 1455, 1455, 1455, 1455, + /* 2330 */ 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1455, 1808, 1455, + /* 2340 */ 1455, 1455, 306, 1778, 580, 1780, 1781, 576, 1808, 571, + /* 2350 */ 1455, 1455, 286, 1778, 580, 1780, 1781, 576, 1455, 571, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 260, 264, 262, 263, 260, 0, 262, 263, 286, 264, - /* 10 */ 8, 9, 12, 13, 12, 13, 14, 15, 16, 297, - /* 20 */ 20, 268, 22, 0, 313, 286, 14, 295, 20, 292, - /* 30 */ 298, 299, 20, 33, 281, 35, 297, 292, 12, 13, - /* 40 */ 14, 15, 16, 290, 21, 323, 324, 24, 25, 26, - /* 50 */ 27, 28, 29, 30, 31, 32, 56, 335, 313, 354, - /* 60 */ 60, 253, 323, 324, 325, 354, 66, 256, 4, 332, - /* 70 */ 264, 20, 367, 22, 335, 59, 371, 332, 367, 12, - /* 80 */ 13, 14, 371, 83, 347, 348, 349, 20, 351, 22, - /* 90 */ 20, 83, 347, 348, 349, 284, 351, 4, 299, 354, - /* 100 */ 33, 50, 35, 292, 256, 105, 307, 301, 297, 310, - /* 110 */ 299, 255, 367, 257, 83, 354, 371, 62, 63, 119, - /* 120 */ 120, 313, 67, 56, 313, 70, 71, 60, 367, 74, - /* 130 */ 75, 76, 371, 66, 309, 324, 311, 44, 45, 328, - /* 140 */ 329, 330, 331, 332, 333, 297, 335, 83, 95, 338, - /* 150 */ 83, 8, 9, 342, 343, 12, 13, 14, 15, 16, - /* 160 */ 114, 115, 354, 354, 164, 354, 166, 114, 115, 116, - /* 170 */ 117, 118, 105, 0, 20, 367, 367, 284, 367, 371, - /* 180 */ 371, 269, 371, 77, 291, 273, 119, 120, 0, 119, - /* 190 */ 120, 191, 192, 300, 194, 195, 196, 197, 198, 199, + /* 0 */ 261, 355, 263, 264, 261, 269, 263, 264, 300, 4, + /* 10 */ 285, 0, 12, 13, 368, 265, 308, 292, 372, 311, + /* 20 */ 20, 267, 22, 0, 8, 9, 301, 291, 12, 13, + /* 30 */ 14, 15, 16, 33, 280, 35, 257, 12, 13, 14, + /* 40 */ 15, 16, 288, 293, 21, 0, 265, 24, 25, 26, + /* 50 */ 27, 28, 29, 30, 31, 32, 56, 265, 265, 43, + /* 60 */ 60, 20, 296, 22, 285, 299, 300, 67, 276, 256, + /* 70 */ 285, 258, 293, 267, 293, 283, 35, 298, 293, 300, + /* 80 */ 12, 13, 14, 333, 84, 293, 293, 84, 20, 84, + /* 90 */ 22, 50, 47, 314, 288, 314, 314, 347, 348, 349, + /* 100 */ 350, 33, 352, 35, 325, 257, 106, 0, 329, 330, + /* 110 */ 331, 332, 333, 334, 333, 336, 331, 20, 339, 20, + /* 120 */ 120, 121, 343, 344, 56, 257, 333, 265, 60, 348, + /* 130 */ 349, 350, 0, 352, 355, 67, 355, 355, 276, 340, + /* 140 */ 341, 348, 349, 350, 257, 352, 298, 368, 59, 368, + /* 150 */ 368, 372, 84, 372, 372, 293, 24, 25, 26, 27, + /* 160 */ 28, 29, 30, 31, 32, 165, 298, 167, 20, 62, + /* 170 */ 63, 64, 285, 355, 106, 68, 115, 116, 71, 72, + /* 180 */ 293, 84, 75, 76, 77, 298, 368, 300, 120, 121, + /* 190 */ 372, 262, 192, 193, 265, 195, 196, 197, 198, 199, /* 200 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, - /* 210 */ 210, 83, 24, 25, 26, 27, 28, 29, 30, 31, - /* 220 */ 32, 175, 43, 223, 178, 339, 340, 84, 56, 123, - /* 230 */ 124, 164, 114, 166, 268, 62, 63, 64, 65, 191, - /* 240 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - /* 250 */ 77, 78, 79, 80, 223, 83, 290, 85, 191, 192, - /* 260 */ 20, 194, 195, 196, 197, 198, 199, 200, 201, 202, - /* 270 */ 203, 204, 205, 206, 207, 208, 209, 210, 12, 13, - /* 280 */ 232, 233, 234, 235, 236, 264, 20, 223, 22, 43, - /* 290 */ 313, 163, 313, 165, 176, 177, 298, 299, 159, 33, - /* 300 */ 0, 35, 96, 97, 98, 99, 100, 101, 102, 103, - /* 310 */ 104, 105, 106, 292, 108, 109, 110, 111, 112, 113, - /* 320 */ 181, 182, 56, 313, 270, 271, 60, 264, 0, 264, - /* 330 */ 84, 354, 66, 354, 313, 12, 13, 256, 275, 22, - /* 340 */ 275, 266, 20, 20, 367, 22, 367, 282, 371, 83, - /* 350 */ 371, 223, 35, 332, 279, 292, 33, 292, 35, 59, - /* 360 */ 20, 20, 287, 22, 354, 284, 115, 256, 347, 348, - /* 370 */ 349, 105, 351, 292, 284, 354, 35, 367, 297, 56, - /* 380 */ 299, 371, 292, 66, 20, 119, 120, 59, 367, 66, - /* 390 */ 256, 50, 371, 21, 313, 223, 24, 25, 26, 27, - /* 400 */ 28, 29, 30, 31, 32, 324, 83, 286, 297, 328, - /* 410 */ 329, 330, 331, 332, 333, 35, 335, 149, 297, 338, - /* 420 */ 330, 242, 105, 342, 343, 174, 175, 59, 105, 178, - /* 430 */ 164, 297, 166, 8, 9, 354, 21, 12, 13, 14, - /* 440 */ 15, 16, 119, 120, 323, 324, 66, 83, 367, 34, - /* 450 */ 256, 36, 371, 14, 20, 35, 335, 191, 192, 20, - /* 460 */ 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, - /* 470 */ 204, 205, 206, 207, 208, 209, 210, 1, 2, 264, - /* 480 */ 0, 164, 264, 166, 264, 264, 66, 164, 283, 166, - /* 490 */ 266, 297, 326, 275, 0, 275, 228, 229, 8, 9, - /* 500 */ 37, 296, 12, 13, 14, 15, 16, 292, 191, 192, - /* 510 */ 292, 287, 292, 292, 191, 192, 350, 194, 195, 196, - /* 520 */ 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, - /* 530 */ 207, 208, 209, 210, 12, 13, 14, 264, 14, 15, - /* 540 */ 16, 47, 20, 256, 22, 264, 223, 332, 275, 86, - /* 550 */ 60, 88, 89, 332, 91, 33, 275, 35, 95, 276, - /* 560 */ 84, 346, 347, 348, 349, 292, 351, 284, 347, 348, - /* 570 */ 349, 284, 351, 292, 84, 95, 293, 20, 56, 292, - /* 580 */ 117, 156, 92, 14, 297, 151, 299, 223, 66, 20, - /* 590 */ 83, 12, 13, 0, 114, 115, 116, 117, 118, 20, - /* 600 */ 93, 22, 8, 9, 326, 83, 12, 13, 14, 15, - /* 610 */ 16, 324, 33, 60, 35, 328, 329, 330, 331, 332, - /* 620 */ 333, 264, 335, 261, 56, 338, 264, 105, 350, 342, - /* 630 */ 343, 344, 275, 264, 195, 56, 146, 43, 309, 282, - /* 640 */ 311, 119, 120, 356, 275, 66, 264, 292, 256, 292, - /* 650 */ 82, 364, 66, 85, 264, 62, 63, 275, 303, 169, - /* 660 */ 67, 292, 83, 70, 71, 275, 20, 74, 75, 76, - /* 670 */ 245, 8, 9, 276, 292, 12, 13, 14, 15, 16, - /* 680 */ 284, 284, 292, 264, 105, 94, 164, 291, 166, 297, - /* 690 */ 293, 66, 256, 272, 275, 274, 300, 4, 119, 120, - /* 700 */ 0, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 710 */ 220, 292, 261, 191, 192, 264, 194, 195, 196, 197, - /* 720 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - /* 730 */ 208, 209, 210, 297, 8, 9, 270, 271, 12, 13, - /* 740 */ 14, 15, 16, 164, 191, 166, 2, 84, 294, 44, - /* 750 */ 45, 297, 8, 9, 284, 2, 12, 13, 14, 15, - /* 760 */ 16, 8, 9, 293, 195, 12, 13, 14, 15, 16, - /* 770 */ 191, 192, 3, 194, 195, 196, 197, 198, 199, 200, - /* 780 */ 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, - /* 790 */ 12, 13, 18, 20, 20, 95, 19, 151, 20, 256, - /* 800 */ 22, 27, 285, 146, 30, 256, 256, 256, 264, 264, - /* 810 */ 33, 33, 256, 35, 114, 115, 116, 117, 118, 275, - /* 820 */ 275, 47, 256, 49, 47, 51, 169, 284, 39, 52, - /* 830 */ 53, 54, 55, 56, 56, 292, 292, 292, 264, 256, - /* 840 */ 297, 264, 299, 276, 66, 285, 297, 297, 297, 275, - /* 850 */ 43, 284, 275, 297, 299, 294, 82, 43, 297, 82, - /* 860 */ 293, 83, 85, 297, 326, 310, 292, 324, 211, 292, - /* 870 */ 95, 328, 329, 330, 331, 332, 333, 151, 335, 256, - /* 880 */ 297, 338, 256, 105, 256, 342, 343, 277, 350, 256, - /* 890 */ 280, 84, 117, 221, 222, 118, 122, 119, 120, 125, - /* 900 */ 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, - /* 910 */ 136, 137, 138, 139, 140, 141, 142, 224, 144, 145, - /* 920 */ 297, 256, 256, 297, 284, 297, 18, 150, 8, 9, - /* 930 */ 297, 23, 12, 13, 14, 15, 16, 42, 43, 0, - /* 940 */ 300, 285, 164, 264, 166, 37, 38, 285, 171, 41, - /* 950 */ 173, 8, 9, 256, 275, 12, 13, 14, 15, 16, - /* 960 */ 285, 22, 297, 297, 256, 57, 58, 0, 195, 191, - /* 970 */ 192, 292, 194, 195, 196, 197, 198, 199, 200, 201, - /* 980 */ 202, 203, 204, 205, 206, 207, 208, 209, 210, 22, - /* 990 */ 87, 83, 284, 90, 297, 264, 87, 264, 87, 90, - /* 1000 */ 292, 90, 0, 60, 84, 297, 275, 299, 275, 240, - /* 1010 */ 87, 222, 43, 90, 43, 56, 151, 152, 43, 43, - /* 1020 */ 46, 43, 35, 292, 22, 292, 43, 1, 2, 121, - /* 1030 */ 285, 285, 324, 35, 317, 92, 328, 329, 330, 331, - /* 1040 */ 332, 333, 256, 335, 85, 257, 338, 119, 120, 43, - /* 1050 */ 342, 343, 344, 84, 273, 84, 374, 83, 244, 84, - /* 1060 */ 84, 43, 84, 43, 156, 157, 158, 84, 43, 161, - /* 1070 */ 284, 365, 364, 265, 320, 167, 361, 284, 292, 43, - /* 1080 */ 265, 43, 43, 297, 0, 299, 43, 263, 180, 146, - /* 1090 */ 84, 183, 296, 185, 186, 187, 188, 189, 190, 327, - /* 1100 */ 352, 345, 84, 368, 84, 368, 368, 355, 288, 84, - /* 1110 */ 324, 83, 169, 225, 328, 329, 330, 331, 332, 333, - /* 1120 */ 84, 335, 84, 84, 338, 12, 13, 84, 342, 343, - /* 1130 */ 344, 223, 48, 322, 20, 22, 264, 47, 321, 353, - /* 1140 */ 256, 35, 162, 270, 315, 264, 33, 264, 35, 42, - /* 1150 */ 304, 33, 302, 166, 211, 212, 213, 214, 215, 216, - /* 1160 */ 217, 218, 219, 220, 166, 47, 256, 146, 284, 56, - /* 1170 */ 52, 53, 54, 55, 56, 20, 292, 4, 302, 66, - /* 1180 */ 264, 297, 264, 299, 258, 258, 20, 319, 299, 268, - /* 1190 */ 268, 20, 19, 314, 284, 20, 20, 312, 268, 312, - /* 1200 */ 82, 268, 292, 85, 305, 268, 33, 297, 324, 299, - /* 1210 */ 268, 264, 328, 329, 330, 331, 332, 333, 105, 335, - /* 1220 */ 47, 268, 338, 258, 51, 284, 342, 343, 344, 56, - /* 1230 */ 284, 297, 284, 256, 324, 284, 284, 353, 328, 329, - /* 1240 */ 330, 331, 332, 333, 284, 335, 284, 284, 338, 264, - /* 1250 */ 284, 258, 342, 343, 344, 82, 284, 284, 85, 319, - /* 1260 */ 266, 284, 318, 353, 172, 147, 148, 299, 150, 292, - /* 1270 */ 266, 264, 154, 264, 297, 230, 299, 164, 266, 166, - /* 1280 */ 148, 297, 312, 297, 292, 297, 256, 308, 297, 308, - /* 1290 */ 313, 173, 297, 266, 280, 306, 256, 266, 20, 231, - /* 1300 */ 292, 324, 305, 237, 191, 328, 329, 330, 331, 332, - /* 1310 */ 333, 308, 335, 297, 284, 202, 203, 204, 205, 206, - /* 1320 */ 207, 208, 292, 327, 284, 308, 297, 297, 239, 299, - /* 1330 */ 297, 354, 292, 155, 297, 238, 226, 297, 297, 299, - /* 1340 */ 292, 222, 360, 313, 367, 322, 20, 243, 371, 241, - /* 1350 */ 360, 256, 83, 288, 324, 246, 297, 358, 328, 329, - /* 1360 */ 330, 331, 332, 333, 324, 335, 264, 256, 328, 329, - /* 1370 */ 330, 331, 332, 333, 363, 335, 357, 362, 338, 284, - /* 1380 */ 326, 359, 342, 343, 354, 375, 274, 292, 341, 266, - /* 1390 */ 36, 258, 297, 369, 299, 284, 259, 367, 316, 311, - /* 1400 */ 278, 371, 360, 292, 370, 370, 278, 278, 297, 267, - /* 1410 */ 299, 254, 0, 369, 174, 0, 370, 256, 369, 324, - /* 1420 */ 0, 0, 42, 328, 329, 330, 331, 332, 333, 334, - /* 1430 */ 335, 336, 337, 256, 74, 324, 0, 184, 35, 328, - /* 1440 */ 329, 330, 331, 332, 333, 284, 335, 184, 35, 35, - /* 1450 */ 0, 35, 35, 292, 35, 184, 0, 184, 297, 0, - /* 1460 */ 299, 284, 35, 0, 22, 0, 289, 35, 0, 292, - /* 1470 */ 83, 169, 168, 166, 297, 256, 299, 164, 0, 0, - /* 1480 */ 160, 159, 0, 372, 373, 324, 0, 46, 0, 328, - /* 1490 */ 329, 330, 331, 332, 333, 256, 335, 0, 0, 338, - /* 1500 */ 143, 324, 0, 284, 343, 328, 329, 330, 331, 332, - /* 1510 */ 333, 292, 335, 0, 0, 0, 297, 0, 299, 138, - /* 1520 */ 35, 0, 138, 284, 0, 0, 0, 0, 289, 0, - /* 1530 */ 0, 292, 42, 0, 0, 0, 297, 0, 299, 0, - /* 1540 */ 0, 0, 0, 324, 0, 0, 0, 328, 329, 330, - /* 1550 */ 331, 332, 333, 256, 335, 0, 0, 0, 22, 0, - /* 1560 */ 0, 0, 0, 324, 0, 256, 56, 328, 329, 330, - /* 1570 */ 331, 332, 333, 0, 335, 256, 0, 14, 0, 14, - /* 1580 */ 42, 284, 39, 0, 0, 366, 0, 0, 40, 292, - /* 1590 */ 43, 39, 155, 284, 297, 46, 299, 46, 289, 0, - /* 1600 */ 0, 292, 0, 284, 0, 39, 297, 35, 299, 39, - /* 1610 */ 0, 292, 35, 39, 47, 61, 297, 0, 299, 39, - /* 1620 */ 35, 324, 47, 0, 0, 328, 329, 330, 331, 332, - /* 1630 */ 333, 35, 335, 324, 0, 256, 47, 328, 329, 330, - /* 1640 */ 331, 332, 333, 324, 335, 47, 39, 328, 329, 330, - /* 1650 */ 331, 332, 333, 0, 335, 0, 337, 35, 256, 90, - /* 1660 */ 92, 22, 0, 284, 35, 35, 35, 35, 289, 43, - /* 1670 */ 373, 292, 35, 35, 0, 35, 297, 0, 299, 43, - /* 1680 */ 22, 22, 49, 0, 35, 22, 284, 0, 0, 35, - /* 1690 */ 0, 289, 35, 22, 292, 20, 0, 0, 170, 297, - /* 1700 */ 256, 299, 35, 324, 22, 0, 148, 328, 329, 330, - /* 1710 */ 331, 332, 333, 0, 335, 0, 0, 256, 83, 0, - /* 1720 */ 0, 93, 151, 0, 39, 84, 324, 83, 284, 179, - /* 1730 */ 328, 329, 330, 331, 332, 333, 292, 335, 46, 151, - /* 1740 */ 84, 297, 151, 299, 83, 284, 153, 43, 83, 227, - /* 1750 */ 149, 83, 147, 292, 84, 83, 46, 84, 297, 83, - /* 1760 */ 299, 22, 84, 83, 43, 84, 35, 256, 324, 83, - /* 1770 */ 43, 46, 328, 329, 330, 331, 332, 333, 83, 335, - /* 1780 */ 43, 83, 46, 84, 84, 324, 43, 46, 256, 328, - /* 1790 */ 329, 330, 331, 332, 333, 284, 335, 46, 84, 43, - /* 1800 */ 35, 84, 221, 292, 35, 35, 227, 35, 297, 256, - /* 1810 */ 299, 35, 2, 83, 43, 83, 284, 227, 191, 84, - /* 1820 */ 46, 46, 84, 83, 292, 22, 84, 94, 83, 297, - /* 1830 */ 83, 299, 83, 35, 84, 324, 193, 284, 83, 328, - /* 1840 */ 329, 330, 331, 332, 333, 292, 335, 35, 84, 35, - /* 1850 */ 297, 256, 299, 35, 35, 35, 324, 84, 22, 107, - /* 1860 */ 328, 329, 330, 331, 332, 333, 83, 335, 256, 83, - /* 1870 */ 107, 84, 83, 107, 84, 83, 95, 324, 83, 284, - /* 1880 */ 83, 328, 329, 330, 331, 332, 333, 292, 335, 107, - /* 1890 */ 35, 83, 297, 43, 299, 22, 284, 66, 61, 60, - /* 1900 */ 35, 43, 81, 35, 292, 35, 35, 35, 22, 297, - /* 1910 */ 35, 299, 35, 35, 66, 35, 35, 35, 35, 324, - /* 1920 */ 256, 47, 35, 328, 329, 330, 331, 332, 333, 35, - /* 1930 */ 335, 35, 0, 35, 39, 0, 324, 35, 47, 39, - /* 1940 */ 328, 329, 330, 331, 332, 333, 0, 335, 284, 35, - /* 1950 */ 47, 39, 0, 35, 47, 39, 292, 0, 35, 35, - /* 1960 */ 0, 297, 22, 299, 21, 376, 22, 22, 21, 20, - /* 1970 */ 376, 376, 376, 376, 256, 376, 376, 376, 376, 376, - /* 1980 */ 376, 376, 376, 376, 376, 376, 376, 376, 324, 376, - /* 1990 */ 256, 376, 328, 329, 330, 331, 332, 333, 376, 335, - /* 2000 */ 256, 376, 284, 376, 376, 376, 376, 376, 376, 376, - /* 2010 */ 292, 376, 376, 376, 376, 297, 376, 299, 284, 376, - /* 2020 */ 376, 376, 376, 376, 376, 376, 292, 376, 284, 376, - /* 2030 */ 376, 297, 376, 299, 376, 376, 292, 376, 376, 376, - /* 2040 */ 376, 297, 324, 299, 376, 376, 328, 329, 330, 331, - /* 2050 */ 332, 333, 256, 335, 376, 376, 376, 376, 324, 376, - /* 2060 */ 376, 376, 328, 329, 330, 331, 332, 333, 324, 335, - /* 2070 */ 376, 376, 328, 329, 330, 331, 332, 333, 376, 335, - /* 2080 */ 284, 376, 376, 376, 376, 376, 376, 376, 292, 376, - /* 2090 */ 376, 376, 376, 297, 256, 299, 376, 376, 376, 376, - /* 2100 */ 376, 376, 376, 376, 376, 376, 376, 376, 256, 376, - /* 2110 */ 376, 376, 376, 376, 376, 376, 376, 376, 256, 376, - /* 2120 */ 324, 376, 284, 376, 328, 329, 330, 331, 332, 333, - /* 2130 */ 292, 335, 376, 376, 376, 297, 284, 299, 376, 376, - /* 2140 */ 376, 376, 376, 376, 292, 376, 284, 376, 376, 297, - /* 2150 */ 376, 299, 376, 376, 292, 376, 376, 376, 376, 297, - /* 2160 */ 376, 299, 324, 376, 376, 376, 328, 329, 330, 331, - /* 2170 */ 332, 333, 376, 335, 376, 376, 324, 256, 376, 376, - /* 2180 */ 328, 329, 330, 331, 332, 333, 324, 335, 376, 376, - /* 2190 */ 328, 329, 330, 331, 332, 333, 376, 335, 256, 376, - /* 2200 */ 376, 376, 376, 376, 376, 284, 376, 376, 376, 376, - /* 2210 */ 376, 376, 376, 292, 376, 376, 376, 376, 297, 376, - /* 2220 */ 299, 376, 376, 376, 376, 376, 284, 376, 376, 376, - /* 2230 */ 376, 376, 376, 376, 292, 376, 376, 376, 376, 297, - /* 2240 */ 376, 299, 376, 376, 376, 324, 376, 376, 376, 328, - /* 2250 */ 329, 330, 331, 332, 333, 376, 335, 256, 376, 376, - /* 2260 */ 376, 376, 376, 376, 376, 376, 324, 256, 376, 376, - /* 2270 */ 328, 329, 330, 331, 332, 333, 376, 335, 376, 376, - /* 2280 */ 376, 376, 376, 256, 376, 284, 376, 376, 376, 376, - /* 2290 */ 376, 376, 376, 292, 376, 284, 376, 376, 297, 376, - /* 2300 */ 299, 376, 376, 292, 376, 376, 376, 376, 297, 376, - /* 2310 */ 299, 284, 376, 376, 376, 376, 376, 376, 376, 292, - /* 2320 */ 376, 376, 376, 376, 297, 324, 299, 376, 376, 328, - /* 2330 */ 329, 330, 331, 332, 333, 324, 335, 376, 376, 328, - /* 2340 */ 329, 330, 331, 332, 333, 376, 335, 376, 376, 376, - /* 2350 */ 376, 324, 376, 376, 376, 328, 329, 330, 331, 332, - /* 2360 */ 333, 376, 335, + /* 210 */ 210, 211, 325, 192, 20, 150, 329, 330, 331, 332, + /* 220 */ 333, 334, 20, 336, 224, 254, 339, 224, 20, 224, + /* 230 */ 343, 344, 345, 165, 37, 167, 84, 176, 285, 270, + /* 240 */ 179, 354, 4, 274, 8, 9, 285, 294, 12, 13, + /* 250 */ 14, 15, 16, 292, 233, 234, 235, 236, 237, 257, + /* 260 */ 192, 193, 301, 195, 196, 197, 198, 199, 200, 201, + /* 270 */ 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + /* 280 */ 12, 13, 44, 45, 87, 314, 89, 90, 20, 92, + /* 290 */ 22, 257, 84, 96, 229, 230, 60, 147, 1, 2, + /* 300 */ 298, 33, 21, 35, 284, 24, 25, 26, 27, 28, + /* 310 */ 29, 30, 31, 32, 265, 118, 164, 297, 166, 285, + /* 320 */ 170, 85, 120, 121, 56, 20, 355, 293, 60, 93, + /* 330 */ 299, 300, 298, 262, 300, 67, 265, 12, 13, 368, + /* 340 */ 62, 63, 64, 372, 355, 20, 68, 22, 0, 71, + /* 350 */ 72, 302, 84, 75, 76, 77, 95, 368, 33, 325, + /* 360 */ 35, 372, 212, 329, 330, 331, 332, 333, 334, 14, + /* 370 */ 336, 269, 160, 339, 106, 20, 224, 343, 344, 345, + /* 380 */ 14, 56, 85, 147, 282, 20, 20, 22, 120, 121, + /* 390 */ 196, 357, 67, 291, 182, 183, 20, 8, 9, 365, + /* 400 */ 0, 12, 13, 14, 15, 16, 170, 271, 272, 84, + /* 410 */ 62, 63, 64, 65, 66, 50, 68, 69, 70, 71, + /* 420 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + /* 430 */ 277, 106, 224, 165, 43, 167, 8, 9, 285, 59, + /* 440 */ 12, 13, 14, 15, 16, 120, 121, 294, 212, 213, + /* 450 */ 214, 215, 216, 217, 218, 219, 220, 221, 20, 59, + /* 460 */ 192, 193, 257, 195, 196, 197, 198, 199, 200, 201, + /* 470 */ 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + /* 480 */ 8, 9, 56, 265, 12, 13, 14, 15, 16, 56, + /* 490 */ 165, 116, 167, 115, 276, 20, 277, 14, 15, 16, + /* 500 */ 3, 8, 9, 298, 285, 12, 13, 14, 15, 16, + /* 510 */ 84, 293, 86, 294, 271, 272, 83, 192, 193, 86, + /* 520 */ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + /* 530 */ 205, 206, 207, 208, 209, 210, 211, 12, 13, 14, + /* 540 */ 310, 152, 312, 257, 277, 20, 257, 22, 20, 224, + /* 550 */ 175, 176, 285, 60, 179, 177, 178, 85, 33, 78, + /* 560 */ 35, 294, 196, 97, 98, 99, 100, 101, 102, 103, + /* 570 */ 104, 105, 106, 107, 285, 109, 110, 111, 112, 113, + /* 580 */ 114, 56, 293, 4, 298, 157, 93, 298, 265, 300, + /* 590 */ 152, 96, 67, 257, 12, 13, 293, 22, 19, 276, + /* 600 */ 42, 43, 20, 314, 22, 124, 125, 304, 67, 84, + /* 610 */ 35, 35, 33, 118, 325, 33, 293, 35, 329, 330, + /* 620 */ 331, 332, 333, 334, 21, 336, 47, 152, 339, 257, + /* 630 */ 51, 106, 343, 344, 298, 56, 245, 34, 56, 36, + /* 640 */ 147, 2, 67, 67, 355, 120, 121, 8, 9, 67, + /* 650 */ 224, 12, 13, 14, 15, 16, 0, 368, 327, 257, + /* 660 */ 257, 372, 83, 170, 96, 86, 84, 327, 43, 265, + /* 670 */ 298, 8, 9, 285, 246, 12, 13, 14, 15, 16, + /* 680 */ 276, 106, 351, 115, 116, 117, 118, 119, 106, 301, + /* 690 */ 165, 351, 167, 44, 45, 327, 314, 293, 257, 39, + /* 700 */ 298, 298, 120, 121, 0, 212, 213, 214, 215, 216, + /* 710 */ 217, 218, 219, 220, 221, 59, 286, 192, 193, 351, + /* 720 */ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, + /* 730 */ 205, 206, 207, 208, 209, 210, 211, 355, 241, 298, + /* 740 */ 165, 310, 167, 312, 273, 2, 275, 165, 85, 167, + /* 750 */ 368, 8, 9, 300, 372, 12, 13, 14, 15, 16, + /* 760 */ 314, 222, 223, 35, 311, 8, 9, 192, 193, 12, + /* 770 */ 13, 14, 15, 16, 192, 193, 56, 195, 196, 197, + /* 780 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, + /* 790 */ 208, 209, 210, 211, 12, 13, 18, 286, 20, 257, + /* 800 */ 96, 355, 20, 257, 22, 27, 86, 295, 30, 257, + /* 810 */ 298, 0, 4, 265, 368, 33, 314, 35, 372, 115, + /* 820 */ 116, 117, 118, 119, 276, 47, 257, 49, 257, 51, + /* 830 */ 14, 285, 295, 22, 278, 298, 20, 281, 56, 293, + /* 840 */ 298, 293, 85, 0, 298, 265, 300, 8, 9, 67, + /* 850 */ 298, 12, 13, 14, 15, 16, 276, 355, 265, 152, + /* 860 */ 153, 83, 88, 283, 35, 91, 84, 298, 243, 298, + /* 870 */ 368, 325, 67, 293, 372, 329, 330, 331, 332, 333, + /* 880 */ 334, 257, 336, 223, 257, 339, 293, 257, 106, 343, + /* 890 */ 344, 345, 257, 257, 88, 167, 0, 91, 60, 286, + /* 900 */ 354, 123, 120, 121, 126, 127, 128, 129, 130, 131, + /* 910 */ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, + /* 920 */ 142, 143, 298, 145, 146, 298, 333, 265, 298, 265, + /* 930 */ 43, 18, 286, 298, 298, 265, 23, 265, 276, 96, + /* 940 */ 276, 348, 349, 350, 48, 352, 276, 165, 276, 167, + /* 950 */ 37, 38, 1, 2, 41, 293, 318, 293, 115, 116, + /* 960 */ 117, 118, 119, 293, 286, 293, 257, 120, 121, 286, + /* 970 */ 57, 58, 85, 43, 192, 193, 265, 195, 196, 197, + /* 980 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, + /* 990 */ 208, 209, 210, 211, 285, 265, 167, 84, 88, 265, + /* 1000 */ 265, 91, 293, 265, 293, 88, 276, 298, 91, 300, + /* 1010 */ 276, 276, 196, 287, 276, 85, 43, 258, 287, 286, + /* 1020 */ 274, 265, 375, 293, 298, 314, 266, 293, 293, 298, + /* 1030 */ 192, 293, 276, 225, 325, 122, 265, 257, 329, 330, + /* 1040 */ 331, 332, 333, 334, 333, 336, 0, 276, 339, 293, + /* 1050 */ 324, 325, 343, 344, 345, 324, 325, 326, 85, 348, + /* 1060 */ 349, 350, 336, 352, 293, 285, 355, 336, 22, 0, + /* 1070 */ 157, 158, 159, 293, 365, 162, 366, 362, 298, 368, + /* 1080 */ 300, 168, 46, 372, 43, 12, 13, 265, 43, 35, + /* 1090 */ 43, 22, 285, 43, 181, 22, 43, 184, 276, 186, + /* 1100 */ 187, 188, 189, 190, 191, 325, 33, 287, 35, 329, + /* 1110 */ 330, 331, 332, 333, 334, 293, 336, 43, 298, 339, + /* 1120 */ 84, 67, 43, 343, 344, 345, 85, 266, 43, 56, + /* 1130 */ 85, 43, 85, 257, 354, 85, 84, 224, 85, 43, + /* 1140 */ 67, 43, 43, 43, 324, 325, 94, 321, 264, 297, + /* 1150 */ 353, 328, 369, 369, 369, 346, 336, 356, 289, 85, + /* 1160 */ 84, 285, 226, 323, 85, 20, 265, 47, 322, 293, + /* 1170 */ 85, 35, 163, 85, 298, 271, 300, 265, 316, 106, + /* 1180 */ 265, 85, 42, 85, 85, 85, 305, 147, 303, 303, + /* 1190 */ 314, 265, 265, 20, 257, 20, 20, 259, 259, 320, + /* 1200 */ 269, 325, 300, 269, 313, 329, 330, 331, 332, 333, + /* 1210 */ 334, 20, 336, 315, 269, 269, 313, 20, 269, 269, + /* 1220 */ 306, 265, 285, 269, 259, 285, 285, 285, 285, 285, + /* 1230 */ 293, 355, 285, 285, 265, 298, 259, 300, 165, 320, + /* 1240 */ 167, 267, 285, 285, 368, 285, 285, 257, 372, 267, + /* 1250 */ 298, 314, 319, 173, 265, 300, 265, 231, 20, 267, + /* 1260 */ 298, 298, 325, 149, 298, 192, 329, 330, 331, 332, + /* 1270 */ 333, 334, 313, 336, 298, 285, 203, 204, 205, 206, + /* 1280 */ 207, 208, 209, 293, 309, 298, 307, 309, 298, 293, + /* 1290 */ 300, 306, 355, 281, 267, 267, 293, 298, 328, 257, + /* 1300 */ 232, 238, 309, 298, 298, 368, 309, 156, 298, 372, + /* 1310 */ 240, 298, 223, 227, 361, 325, 239, 323, 293, 329, + /* 1320 */ 330, 331, 332, 333, 334, 361, 336, 285, 360, 339, + /* 1330 */ 358, 364, 361, 343, 344, 293, 20, 244, 327, 242, + /* 1340 */ 298, 247, 300, 363, 84, 359, 342, 289, 265, 298, + /* 1350 */ 275, 370, 257, 36, 371, 317, 312, 267, 0, 371, + /* 1360 */ 376, 260, 259, 279, 175, 370, 257, 325, 255, 371, + /* 1370 */ 370, 329, 330, 331, 332, 333, 334, 0, 336, 268, + /* 1380 */ 285, 339, 0, 279, 279, 343, 344, 42, 293, 0, + /* 1390 */ 75, 0, 35, 298, 285, 300, 185, 35, 35, 35, + /* 1400 */ 185, 0, 293, 35, 35, 185, 0, 298, 185, 300, + /* 1410 */ 0, 0, 22, 35, 0, 35, 0, 84, 170, 257, + /* 1420 */ 325, 169, 167, 165, 329, 330, 331, 332, 333, 334, + /* 1430 */ 335, 336, 337, 338, 325, 0, 0, 257, 329, 330, + /* 1440 */ 331, 332, 333, 334, 161, 336, 160, 285, 0, 0, + /* 1450 */ 46, 0, 0, 0, 144, 293, 0, 0, 0, 0, + /* 1460 */ 298, 0, 300, 139, 35, 285, 0, 139, 0, 0, + /* 1470 */ 290, 0, 0, 293, 0, 0, 0, 0, 298, 0, + /* 1480 */ 300, 0, 373, 374, 0, 0, 0, 325, 0, 257, + /* 1490 */ 0, 329, 330, 331, 332, 333, 334, 42, 336, 0, + /* 1500 */ 0, 339, 0, 0, 0, 325, 344, 0, 0, 329, + /* 1510 */ 330, 331, 332, 333, 334, 22, 336, 285, 0, 0, + /* 1520 */ 0, 56, 290, 0, 0, 293, 43, 14, 39, 42, + /* 1530 */ 298, 257, 300, 0, 40, 14, 39, 46, 46, 0, + /* 1540 */ 0, 257, 0, 156, 39, 0, 0, 0, 0, 0, + /* 1550 */ 35, 39, 0, 39, 0, 39, 61, 325, 47, 285, + /* 1560 */ 35, 329, 330, 331, 332, 333, 334, 293, 336, 285, + /* 1570 */ 35, 0, 298, 47, 300, 47, 35, 293, 47, 0, + /* 1580 */ 0, 0, 298, 39, 300, 0, 35, 22, 0, 91, + /* 1590 */ 35, 257, 35, 35, 93, 35, 43, 0, 35, 325, + /* 1600 */ 22, 35, 43, 329, 330, 331, 332, 333, 334, 325, + /* 1610 */ 336, 19, 35, 329, 330, 331, 332, 333, 334, 285, + /* 1620 */ 336, 35, 0, 22, 290, 33, 35, 293, 0, 22, + /* 1630 */ 0, 49, 298, 257, 300, 35, 0, 35, 0, 47, + /* 1640 */ 22, 367, 0, 20, 52, 53, 54, 55, 56, 0, + /* 1650 */ 35, 257, 0, 171, 22, 0, 0, 0, 374, 325, + /* 1660 */ 0, 285, 152, 329, 330, 331, 332, 333, 334, 293, + /* 1670 */ 336, 149, 85, 84, 298, 83, 300, 0, 86, 285, + /* 1680 */ 84, 152, 152, 84, 290, 39, 154, 293, 150, 180, + /* 1690 */ 0, 148, 298, 84, 300, 228, 46, 94, 85, 35, + /* 1700 */ 84, 325, 43, 257, 84, 329, 330, 331, 332, 333, + /* 1710 */ 334, 119, 336, 84, 338, 22, 85, 43, 85, 325, + /* 1720 */ 85, 84, 43, 329, 330, 331, 332, 333, 334, 84, + /* 1730 */ 336, 285, 84, 46, 46, 33, 290, 43, 85, 293, + /* 1740 */ 43, 46, 84, 151, 298, 228, 300, 85, 85, 47, + /* 1750 */ 46, 46, 85, 257, 52, 53, 54, 55, 56, 222, + /* 1760 */ 43, 85, 228, 257, 172, 35, 174, 35, 35, 35, + /* 1770 */ 35, 325, 2, 84, 43, 329, 330, 331, 332, 333, + /* 1780 */ 334, 285, 336, 85, 84, 83, 192, 84, 86, 293, + /* 1790 */ 46, 285, 85, 85, 298, 84, 300, 84, 46, 293, + /* 1800 */ 22, 95, 194, 84, 298, 85, 300, 35, 35, 84, + /* 1810 */ 35, 85, 84, 22, 85, 35, 35, 35, 108, 257, + /* 1820 */ 84, 325, 108, 85, 84, 329, 330, 331, 332, 333, + /* 1830 */ 334, 325, 336, 85, 84, 329, 330, 331, 332, 333, + /* 1840 */ 334, 96, 336, 84, 84, 35, 84, 285, 43, 108, + /* 1850 */ 148, 149, 22, 151, 108, 293, 61, 155, 60, 35, + /* 1860 */ 298, 257, 300, 67, 43, 82, 22, 35, 35, 35, + /* 1870 */ 35, 257, 35, 35, 35, 67, 174, 35, 35, 0, + /* 1880 */ 35, 35, 35, 257, 35, 35, 35, 325, 35, 285, + /* 1890 */ 0, 329, 330, 331, 332, 333, 334, 293, 336, 285, + /* 1900 */ 39, 47, 298, 35, 300, 47, 39, 293, 0, 35, + /* 1910 */ 47, 285, 298, 0, 300, 39, 35, 47, 0, 293, + /* 1920 */ 35, 39, 35, 0, 298, 257, 300, 22, 21, 325, + /* 1930 */ 377, 22, 22, 329, 330, 331, 332, 333, 334, 325, + /* 1940 */ 336, 21, 257, 329, 330, 331, 332, 333, 334, 20, + /* 1950 */ 336, 325, 377, 285, 377, 329, 330, 331, 332, 333, + /* 1960 */ 334, 293, 336, 377, 377, 377, 298, 377, 300, 377, + /* 1970 */ 285, 377, 377, 377, 377, 377, 377, 377, 293, 377, + /* 1980 */ 377, 377, 377, 298, 257, 300, 377, 377, 377, 377, + /* 1990 */ 377, 377, 377, 325, 257, 377, 377, 329, 330, 331, + /* 2000 */ 332, 333, 334, 377, 336, 377, 377, 377, 377, 377, + /* 2010 */ 325, 377, 285, 377, 329, 330, 331, 332, 333, 334, + /* 2020 */ 293, 336, 285, 377, 377, 298, 377, 300, 377, 377, + /* 2030 */ 293, 377, 377, 377, 377, 298, 257, 300, 377, 377, + /* 2040 */ 377, 377, 377, 377, 377, 377, 257, 377, 377, 377, + /* 2050 */ 377, 377, 325, 377, 377, 377, 329, 330, 331, 332, + /* 2060 */ 333, 334, 325, 336, 285, 377, 329, 330, 331, 332, + /* 2070 */ 333, 334, 293, 336, 285, 377, 377, 298, 377, 300, + /* 2080 */ 377, 377, 293, 377, 377, 377, 377, 298, 257, 300, + /* 2090 */ 377, 377, 377, 377, 377, 377, 377, 377, 257, 377, + /* 2100 */ 377, 377, 377, 377, 325, 377, 377, 377, 329, 330, + /* 2110 */ 331, 332, 333, 334, 325, 336, 285, 377, 329, 330, + /* 2120 */ 331, 332, 333, 334, 293, 336, 285, 377, 377, 298, + /* 2130 */ 377, 300, 377, 377, 293, 377, 377, 377, 377, 298, + /* 2140 */ 377, 300, 377, 377, 377, 377, 377, 377, 377, 377, + /* 2150 */ 257, 377, 377, 377, 377, 377, 325, 377, 377, 377, + /* 2160 */ 329, 330, 331, 332, 333, 334, 325, 336, 377, 257, + /* 2170 */ 329, 330, 331, 332, 333, 334, 377, 336, 285, 377, + /* 2180 */ 377, 377, 377, 377, 377, 377, 293, 377, 377, 377, + /* 2190 */ 377, 298, 257, 300, 377, 377, 377, 285, 377, 377, + /* 2200 */ 377, 377, 377, 377, 377, 293, 377, 377, 377, 377, + /* 2210 */ 298, 257, 300, 377, 377, 377, 377, 377, 325, 377, + /* 2220 */ 285, 377, 329, 330, 331, 332, 333, 334, 293, 336, + /* 2230 */ 377, 377, 377, 298, 377, 300, 377, 325, 377, 285, + /* 2240 */ 377, 329, 330, 331, 332, 333, 334, 293, 336, 377, + /* 2250 */ 377, 377, 298, 377, 300, 377, 377, 377, 377, 377, + /* 2260 */ 325, 377, 377, 377, 329, 330, 331, 332, 333, 334, + /* 2270 */ 257, 336, 377, 377, 377, 377, 377, 377, 377, 325, + /* 2280 */ 257, 377, 377, 329, 330, 331, 332, 333, 334, 377, + /* 2290 */ 336, 377, 377, 377, 377, 377, 377, 377, 285, 377, + /* 2300 */ 377, 377, 377, 377, 377, 377, 293, 377, 285, 377, + /* 2310 */ 377, 298, 377, 300, 377, 377, 293, 377, 377, 377, + /* 2320 */ 377, 298, 377, 300, 377, 377, 377, 377, 377, 377, + /* 2330 */ 377, 377, 377, 377, 377, 377, 377, 377, 325, 377, + /* 2340 */ 377, 377, 329, 330, 331, 332, 333, 334, 325, 336, + /* 2350 */ 377, 377, 329, 330, 331, 332, 333, 334, 377, 336, }; -#define YY_SHIFT_COUNT (660) +#define YY_SHIFT_COUNT (662) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1960) +#define YY_SHIFT_MAX (1929) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 908, 0, 0, 67, 67, 266, 266, 266, 323, 323, - /* 10 */ 266, 266, 522, 579, 778, 579, 579, 579, 579, 579, - /* 20 */ 579, 579, 579, 579, 579, 579, 579, 579, 579, 579, - /* 30 */ 579, 579, 579, 579, 579, 579, 579, 579, 579, 579, - /* 40 */ 579, 579, 579, 364, 364, 8, 8, 8, 1113, 1113, - /* 50 */ 1113, 128, 172, 31, 31, 154, 154, 93, 93, 64, - /* 60 */ 70, 31, 31, 154, 154, 154, 154, 154, 154, 154, - /* 70 */ 154, 154, 16, 154, 154, 154, 240, 322, 154, 154, - /* 80 */ 322, 340, 154, 322, 322, 322, 154, 368, 774, 490, - /* 90 */ 943, 943, 372, 55, 317, 317, 317, 317, 317, 317, - /* 100 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, - /* 110 */ 317, 317, 317, 463, 70, 12, 12, 300, 380, 328, - /* 120 */ 434, 434, 434, 380, 557, 240, 5, 5, 322, 322, - /* 130 */ 586, 586, 591, 625, 206, 206, 206, 206, 206, 206, - /* 140 */ 206, 777, 23, 593, 425, 48, 341, 251, 268, 439, - /* 150 */ 569, 51, 705, 775, 646, 672, 789, 672, 895, 769, - /* 160 */ 769, 769, 693, 773, 1028, 888, 1114, 1090, 1106, 980, - /* 170 */ 1114, 1114, 1107, 1021, 1021, 1114, 1114, 1155, 1155, 1166, - /* 180 */ 16, 240, 16, 1171, 1175, 16, 1171, 16, 1176, 16, - /* 190 */ 16, 1114, 16, 1155, 322, 322, 322, 322, 322, 322, - /* 200 */ 322, 322, 322, 322, 322, 1114, 1155, 586, 1166, 368, - /* 210 */ 1092, 240, 368, 1114, 1114, 1171, 368, 1045, 586, 586, - /* 220 */ 586, 586, 1045, 586, 1132, 557, 1176, 368, 591, 368, - /* 230 */ 557, 1278, 586, 1068, 1045, 586, 586, 1068, 1045, 586, - /* 240 */ 586, 322, 1066, 1178, 1068, 1089, 1097, 1110, 888, 1119, - /* 250 */ 557, 1326, 1104, 1108, 1109, 1104, 1108, 1104, 1108, 1269, - /* 260 */ 1028, 586, 625, 1114, 368, 1354, 1155, 2363, 2363, 2363, - /* 270 */ 2363, 2363, 2363, 2363, 173, 1118, 188, 1173, 143, 594, - /* 280 */ 663, 744, 753, 726, 920, 480, 2, 2, 2, 2, - /* 290 */ 2, 2, 2, 2, 700, 53, 26, 26, 46, 139, - /* 300 */ 568, 106, 415, 118, 476, 657, 524, 524, 524, 524, - /* 310 */ 494, 246, 903, 909, 911, 923, 939, 967, 1002, 959, - /* 320 */ 865, 807, 969, 971, 975, 976, 978, 987, 998, 983, - /* 330 */ 1026, 928, 179, 814, 1006, 553, 1018, 974, 1020, 1025, - /* 340 */ 1036, 1038, 1039, 1043, 507, 420, 1084, 1412, 1240, 1415, - /* 350 */ 1420, 1380, 1421, 1360, 1436, 1403, 1253, 1413, 1414, 1416, - /* 360 */ 1263, 1450, 1417, 1419, 1271, 1456, 1273, 1459, 1427, 1463, - /* 370 */ 1442, 1465, 1432, 1468, 1387, 1302, 1304, 1307, 1313, 1478, - /* 380 */ 1479, 1320, 1322, 1482, 1486, 1441, 1488, 1497, 1498, 1357, - /* 390 */ 1502, 1513, 1514, 1515, 1517, 1381, 1485, 1521, 1384, 1524, - /* 400 */ 1525, 1526, 1527, 1529, 1530, 1537, 1539, 1540, 1541, 1542, - /* 410 */ 1544, 1545, 1546, 1490, 1533, 1534, 1535, 1555, 1556, 1557, - /* 420 */ 1536, 1559, 1560, 1561, 1562, 1564, 1510, 1573, 1576, 1538, - /* 430 */ 1543, 1547, 1563, 1549, 1565, 1551, 1578, 1548, 1552, 1583, - /* 440 */ 1584, 1586, 1566, 1437, 1587, 1599, 1600, 1554, 1602, 1604, - /* 450 */ 1572, 1567, 1570, 1610, 1577, 1575, 1574, 1617, 1585, 1589, - /* 460 */ 1580, 1623, 1596, 1598, 1607, 1624, 1634, 1653, 1655, 1568, - /* 470 */ 1569, 1622, 1639, 1662, 1629, 1630, 1631, 1632, 1626, 1636, - /* 480 */ 1637, 1638, 1640, 1674, 1658, 1677, 1659, 1633, 1683, 1663, - /* 490 */ 1649, 1687, 1654, 1688, 1657, 1690, 1671, 1675, 1696, 1571, - /* 500 */ 1667, 1697, 1528, 1682, 1588, 1558, 1705, 1713, 1591, 1593, - /* 510 */ 1715, 1716, 1723, 1635, 1641, 1550, 1719, 1644, 1601, 1661, - /* 520 */ 1720, 1685, 1605, 1665, 1628, 1692, 1704, 1522, 1668, 1656, - /* 530 */ 1672, 1670, 1673, 1676, 1739, 1721, 1678, 1680, 1686, 1695, - /* 540 */ 1681, 1727, 1710, 1725, 1698, 1737, 1579, 1699, 1700, 1736, - /* 550 */ 1581, 1743, 1741, 1751, 1714, 1756, 1590, 1717, 1731, 1765, - /* 560 */ 1769, 1770, 1772, 1776, 1717, 1810, 1627, 1771, 1730, 1735, - /* 570 */ 1732, 1738, 1740, 1742, 1774, 1745, 1747, 1775, 1803, 1643, - /* 580 */ 1749, 1733, 1750, 1798, 1812, 1755, 1764, 1814, 1783, 1773, - /* 590 */ 1818, 1786, 1787, 1819, 1789, 1790, 1820, 1792, 1752, 1763, - /* 600 */ 1766, 1782, 1836, 1781, 1795, 1797, 1855, 1808, 1850, 1850, - /* 610 */ 1873, 1837, 1839, 1865, 1831, 1821, 1858, 1868, 1870, 1871, - /* 620 */ 1872, 1875, 1886, 1877, 1878, 1848, 1626, 1880, 1636, 1881, - /* 630 */ 1882, 1883, 1887, 1894, 1896, 1932, 1898, 1874, 1895, 1935, - /* 640 */ 1902, 1891, 1900, 1946, 1914, 1903, 1912, 1952, 1918, 1907, - /* 650 */ 1916, 1957, 1923, 1924, 1960, 1940, 1943, 1944, 1945, 1947, - /* 660 */ 1949, + /* 0 */ 913, 0, 0, 68, 68, 268, 268, 268, 325, 325, + /* 10 */ 268, 268, 525, 582, 782, 582, 582, 582, 582, 582, + /* 20 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, + /* 30 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, + /* 40 */ 582, 582, 582, 208, 208, 97, 97, 97, 1073, 1073, + /* 50 */ 1073, 152, 426, 3, 3, 99, 99, 238, 238, 5, + /* 60 */ 202, 3, 3, 99, 99, 99, 99, 99, 99, 99, + /* 70 */ 99, 99, 89, 99, 99, 99, 148, 305, 99, 99, + /* 80 */ 305, 376, 99, 305, 305, 305, 99, 380, 778, 236, + /* 90 */ 493, 493, 281, 278, 575, 575, 575, 575, 575, 575, + /* 100 */ 575, 575, 575, 575, 575, 575, 575, 575, 575, 575, + /* 110 */ 575, 575, 575, 197, 202, 355, 355, 400, 576, 656, + /* 120 */ 438, 438, 438, 576, 528, 148, 11, 11, 305, 305, + /* 130 */ 541, 541, 261, 805, 466, 466, 466, 466, 466, 466, + /* 140 */ 466, 1592, 23, 107, 428, 21, 41, 375, 65, 366, + /* 150 */ 816, 365, 649, 495, 475, 539, 660, 539, 558, 497, + /* 160 */ 497, 497, 808, 194, 1076, 936, 1145, 1120, 1136, 1009, + /* 170 */ 1145, 1145, 1140, 1040, 1040, 1145, 1145, 1173, 1173, 1175, + /* 180 */ 89, 148, 89, 1176, 1191, 89, 1176, 89, 1197, 89, + /* 190 */ 89, 1145, 89, 1173, 305, 305, 305, 305, 305, 305, + /* 200 */ 305, 305, 305, 305, 305, 1145, 1173, 541, 1175, 380, + /* 210 */ 1080, 148, 380, 1145, 1145, 1176, 380, 1026, 541, 541, + /* 220 */ 541, 541, 1026, 541, 1114, 528, 1197, 380, 261, 380, + /* 230 */ 528, 1238, 541, 1068, 1026, 541, 541, 1068, 1026, 541, + /* 240 */ 541, 305, 1063, 1151, 1068, 1070, 1077, 1086, 936, 1089, + /* 250 */ 528, 1316, 1093, 1097, 1094, 1093, 1097, 1093, 1097, 1260, + /* 260 */ 1076, 541, 805, 1145, 380, 1317, 1173, 2360, 2360, 2360, + /* 270 */ 2360, 2360, 2360, 2360, 348, 1702, 132, 579, 472, 16, + /* 280 */ 663, 639, 743, 389, 757, 704, 839, 839, 839, 839, + /* 290 */ 839, 839, 839, 839, 843, 568, 25, 25, 61, 212, + /* 300 */ 433, 481, 603, 378, 297, 150, 483, 483, 483, 483, + /* 310 */ 45, 887, 774, 806, 910, 917, 811, 1046, 1069, 720, + /* 320 */ 707, 930, 973, 1041, 1045, 1047, 1050, 728, 829, 1053, + /* 330 */ 951, 847, 625, 391, 1074, 838, 1079, 1036, 1085, 1088, + /* 340 */ 1096, 1098, 1099, 1100, 1052, 1054, 896, 1358, 1189, 1377, + /* 350 */ 1382, 1345, 1389, 1315, 1391, 1357, 1211, 1362, 1363, 1364, + /* 360 */ 1215, 1401, 1368, 1369, 1220, 1406, 1223, 1410, 1378, 1411, + /* 370 */ 1390, 1414, 1380, 1416, 1333, 1248, 1252, 1255, 1258, 1435, + /* 380 */ 1436, 1283, 1286, 1448, 1449, 1404, 1451, 1452, 1453, 1310, + /* 390 */ 1456, 1457, 1458, 1459, 1461, 1324, 1429, 1466, 1328, 1468, + /* 400 */ 1469, 1471, 1472, 1474, 1475, 1476, 1477, 1479, 1481, 1484, + /* 410 */ 1485, 1486, 1488, 1455, 1490, 1499, 1500, 1502, 1503, 1504, + /* 420 */ 1493, 1507, 1508, 1518, 1519, 1520, 1465, 1523, 1524, 1487, + /* 430 */ 1489, 1483, 1513, 1491, 1521, 1492, 1533, 1494, 1497, 1539, + /* 440 */ 1540, 1542, 1505, 1387, 1545, 1546, 1547, 1495, 1548, 1549, + /* 450 */ 1515, 1511, 1512, 1552, 1525, 1526, 1514, 1554, 1535, 1528, + /* 460 */ 1516, 1571, 1541, 1531, 1544, 1579, 1580, 1581, 1585, 1501, + /* 470 */ 1498, 1551, 1565, 1588, 1555, 1557, 1558, 1560, 1553, 1559, + /* 480 */ 1563, 1566, 1577, 1586, 1597, 1578, 1622, 1601, 1582, 1628, + /* 490 */ 1607, 1591, 1630, 1600, 1636, 1602, 1638, 1618, 1623, 1642, + /* 500 */ 1510, 1615, 1649, 1482, 1632, 1529, 1522, 1652, 1655, 1530, + /* 510 */ 1532, 1656, 1657, 1660, 1589, 1587, 1509, 1677, 1596, 1538, + /* 520 */ 1599, 1690, 1646, 1543, 1609, 1603, 1650, 1659, 1467, 1616, + /* 530 */ 1613, 1620, 1631, 1633, 1629, 1693, 1674, 1635, 1637, 1645, + /* 540 */ 1648, 1653, 1679, 1687, 1688, 1658, 1694, 1517, 1662, 1663, + /* 550 */ 1695, 1537, 1697, 1704, 1705, 1667, 1717, 1534, 1676, 1664, + /* 560 */ 1730, 1732, 1733, 1734, 1735, 1676, 1770, 1594, 1731, 1689, + /* 570 */ 1698, 1700, 1707, 1703, 1708, 1744, 1711, 1713, 1752, 1778, + /* 580 */ 1608, 1719, 1706, 1720, 1772, 1773, 1725, 1726, 1775, 1728, + /* 590 */ 1729, 1780, 1736, 1738, 1781, 1740, 1748, 1782, 1750, 1710, + /* 600 */ 1714, 1741, 1746, 1791, 1745, 1759, 1760, 1810, 1762, 1805, + /* 610 */ 1805, 1830, 1795, 1798, 1824, 1796, 1783, 1821, 1832, 1833, + /* 620 */ 1834, 1835, 1837, 1844, 1838, 1839, 1808, 1553, 1842, 1559, + /* 630 */ 1843, 1845, 1846, 1847, 1849, 1850, 1851, 1879, 1853, 1854, + /* 640 */ 1861, 1890, 1868, 1858, 1867, 1908, 1874, 1863, 1876, 1913, + /* 650 */ 1881, 1870, 1882, 1918, 1885, 1887, 1923, 1905, 1907, 1909, + /* 660 */ 1910, 1920, 1929, }; #define YY_REDUCE_COUNT (273) -#define YY_REDUCE_MIN (-295) -#define YY_REDUCE_MAX (2027) +#define YY_REDUCE_MIN (-354) +#define YY_REDUCE_MAX (2023) static const short yy_reduce_ofst[] = { - /* 0 */ -192, -189, 81, 287, 708, 786, 884, 910, 977, 1030, - /* 10 */ 543, 1040, 1095, 1111, 1161, 1177, 1239, 1219, 1297, 1309, - /* 20 */ 1319, 1379, 1402, 1444, 1461, 1511, 1532, 1553, 1595, 1612, - /* 30 */ 1664, 1718, 1734, 1744, 1796, 1838, 1852, 1862, 1921, 1942, - /* 40 */ 2001, 2011, 2027, -255, 21, 215, -263, 221, -261, -278, - /* 50 */ 121, -289, -23, -21, 10, 65, 357, -260, -256, -295, - /* 60 */ -268, -239, -191, 63, 218, 220, 273, 281, 369, 382, - /* 70 */ 390, 419, -247, 544, 545, 574, -201, 283, 577, 679, - /* 80 */ -107, 90, 731, 397, 396, 567, 733, 75, -194, -114, - /* 90 */ -114, -114, -144, -88, -152, 111, 134, 194, 392, 436, - /* 100 */ 549, 550, 551, 556, 566, 583, 623, 626, 628, 633, - /* 110 */ 665, 666, 697, 205, -2, 362, 451, -34, 54, 224, - /* 120 */ 166, 278, 538, 466, 355, 555, -175, 329, 470, 640, - /* 130 */ 454, 561, 610, 421, 517, 560, 656, 662, 675, 745, - /* 140 */ 746, 717, 788, 781, 682, 706, 808, 754, 715, 793, - /* 150 */ 793, 815, 824, 796, 772, 748, 748, 748, 756, 735, - /* 160 */ 737, 738, 752, 793, 820, 811, 872, 817, 873, 829, - /* 170 */ 881, 883, 846, 850, 876, 916, 918, 926, 927, 868, - /* 180 */ 921, 889, 922, 885, 879, 930, 887, 933, 899, 937, - /* 190 */ 942, 947, 953, 965, 941, 946, 948, 951, 952, 960, - /* 200 */ 962, 963, 966, 972, 973, 985, 993, 934, 940, 994, - /* 210 */ 944, 968, 1004, 1007, 1009, 970, 1012, 979, 984, 986, - /* 220 */ 988, 991, 981, 995, 989, 992, 997, 1027, 1014, 1031, - /* 230 */ 1008, 996, 1016, 982, 1003, 1029, 1033, 990, 1017, 1037, - /* 240 */ 1041, 793, 1011, 1015, 1042, 1022, 999, 1019, 1023, 748, - /* 250 */ 1048, 1054, 1034, 1024, 1010, 1035, 1044, 1046, 1049, 1047, - /* 260 */ 1065, 1059, 1112, 1102, 1123, 1137, 1133, 1082, 1088, 1122, - /* 270 */ 1128, 1129, 1142, 1157, + /* 0 */ -29, -221, 289, 34, 709, -113, 546, 780, 876, 937, + /* 10 */ 990, 1042, 1095, 1109, 1162, 1180, 1232, 1274, 1284, 1334, + /* 20 */ 1376, 1394, 1446, 1496, 1506, 1562, 1604, 1614, 1626, 1668, + /* 30 */ 1685, 1727, 1737, 1779, 1789, 1831, 1841, 1893, 1912, 1935, + /* 40 */ 1954, 2013, 2023, -219, 711, -250, -207, 593, 731, 726, + /* 50 */ 820, -218, 382, 446, 502, -208, 580, -261, -257, -354, + /* 60 */ -234, -182, -11, -138, 218, 323, 404, 548, 662, 664, + /* 70 */ 670, 672, 102, 730, 734, 735, -292, 153, 738, 756, + /* 80 */ -275, -215, 771, 219, -39, 267, 822, -246, 49, -201, + /* 90 */ -201, -201, -187, -31, -152, -132, 2, 205, 286, 336, + /* 100 */ 372, 402, 403, 441, 542, 552, 569, 571, 624, 627, + /* 110 */ 630, 635, 636, 20, 31, -71, 71, -264, 136, -194, + /* 120 */ 331, 340, 368, 243, 303, 453, 230, 431, -47, 388, + /* 130 */ 512, 537, 556, 471, 430, 511, 613, 646, 678, 683, + /* 140 */ 733, 638, 759, 746, 647, 710, 760, 826, 715, 807, + /* 150 */ 807, 861, 884, 852, 823, 797, 797, 797, 809, 783, + /* 160 */ 784, 785, 801, 807, 869, 840, 901, 846, 904, 862, + /* 170 */ 912, 915, 881, 885, 886, 926, 927, 938, 939, 879, + /* 180 */ 931, 902, 934, 891, 898, 945, 903, 946, 914, 949, + /* 190 */ 950, 956, 954, 965, 940, 941, 942, 943, 944, 947, + /* 200 */ 948, 957, 958, 960, 961, 969, 977, 952, 919, 974, + /* 210 */ 933, 955, 982, 989, 991, 959, 992, 975, 962, 963, + /* 220 */ 966, 976, 978, 987, 979, 996, 985, 1027, 1012, 1028, + /* 230 */ 1003, 970, 999, 953, 993, 1005, 1006, 964, 997, 1010, + /* 240 */ 1013, 807, 967, 980, 971, 968, 986, 972, 994, 797, + /* 250 */ 1025, 1011, 983, 981, 984, 988, 995, 998, 1000, 1004, + /* 260 */ 1058, 1051, 1075, 1083, 1090, 1101, 1103, 1038, 1044, 1084, + /* 270 */ 1104, 1105, 1111, 1113, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 10 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 20 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 30 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 40 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 50 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 60 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 70 */ 1447, 1447, 1520, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 80 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1518, 1671, 1447, - /* 90 */ 1848, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 100 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 110 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1520, 1447, 1518, - /* 120 */ 1860, 1860, 1860, 1447, 1447, 1447, 1715, 1715, 1447, 1447, - /* 130 */ 1447, 1447, 1614, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 140 */ 1447, 1707, 1447, 1447, 1929, 1447, 1447, 1713, 1883, 1447, - /* 150 */ 1447, 1447, 1447, 1567, 1875, 1852, 1866, 1853, 1850, 1914, - /* 160 */ 1914, 1914, 1869, 1447, 1583, 1879, 1447, 1447, 1447, 1699, - /* 170 */ 1447, 1447, 1676, 1673, 1673, 1447, 1447, 1447, 1447, 1447, - /* 180 */ 1520, 1447, 1520, 1447, 1447, 1520, 1447, 1520, 1447, 1520, - /* 190 */ 1520, 1447, 1520, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 200 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1518, - /* 210 */ 1709, 1447, 1518, 1447, 1447, 1447, 1518, 1888, 1447, 1447, - /* 220 */ 1447, 1447, 1888, 1447, 1447, 1447, 1447, 1518, 1447, 1518, - /* 230 */ 1447, 1447, 1447, 1890, 1888, 1447, 1447, 1890, 1888, 1447, - /* 240 */ 1447, 1447, 1902, 1898, 1890, 1906, 1904, 1881, 1879, 1866, - /* 250 */ 1447, 1447, 1920, 1916, 1932, 1920, 1916, 1920, 1916, 1447, - /* 260 */ 1583, 1447, 1447, 1447, 1518, 1479, 1447, 1701, 1715, 1617, - /* 270 */ 1617, 1617, 1521, 1452, 1447, 1447, 1447, 1447, 1447, 1447, - /* 280 */ 1447, 1447, 1447, 1447, 1447, 1447, 1786, 1901, 1900, 1824, - /* 290 */ 1823, 1822, 1820, 1785, 1447, 1579, 1784, 1783, 1447, 1447, - /* 300 */ 1447, 1447, 1447, 1447, 1447, 1447, 1777, 1778, 1776, 1775, - /* 310 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 320 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 330 */ 1849, 1447, 1917, 1921, 1447, 1447, 1447, 1760, 1447, 1447, - /* 340 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 350 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 360 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 370 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 380 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 390 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 400 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 410 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 420 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 430 */ 1447, 1484, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 440 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 450 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 460 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 470 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1548, 1547, - /* 480 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 490 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 500 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 510 */ 1447, 1447, 1447, 1447, 1447, 1447, 1719, 1447, 1447, 1447, - /* 520 */ 1447, 1447, 1447, 1447, 1447, 1447, 1882, 1447, 1447, 1447, - /* 530 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 540 */ 1447, 1447, 1447, 1760, 1447, 1899, 1447, 1859, 1855, 1447, - /* 550 */ 1447, 1851, 1759, 1447, 1447, 1915, 1447, 1447, 1447, 1447, - /* 560 */ 1447, 1447, 1447, 1447, 1447, 1844, 1447, 1817, 1802, 1447, - /* 570 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1771, - /* 580 */ 1447, 1447, 1447, 1447, 1447, 1611, 1447, 1447, 1447, 1447, - /* 590 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1596, 1594, - /* 600 */ 1593, 1592, 1447, 1589, 1447, 1447, 1447, 1447, 1620, 1619, - /* 610 */ 1447, 1447, 1447, 1447, 1447, 1447, 1540, 1447, 1447, 1447, - /* 620 */ 1447, 1447, 1447, 1447, 1447, 1447, 1531, 1447, 1530, 1447, - /* 630 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 640 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 650 */ 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, 1447, - /* 660 */ 1447, + /* 0 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 10 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 20 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 30 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 40 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 50 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 60 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 70 */ 1453, 1453, 1526, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 80 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1524, 1679, 1453, + /* 90 */ 1856, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 100 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 110 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1526, 1453, 1524, + /* 120 */ 1868, 1868, 1868, 1453, 1453, 1453, 1723, 1723, 1453, 1453, + /* 130 */ 1453, 1453, 1622, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 140 */ 1453, 1715, 1453, 1453, 1937, 1453, 1453, 1721, 1891, 1453, + /* 150 */ 1453, 1453, 1453, 1575, 1883, 1860, 1874, 1861, 1858, 1922, + /* 160 */ 1922, 1922, 1877, 1453, 1591, 1887, 1453, 1453, 1453, 1707, + /* 170 */ 1453, 1453, 1684, 1681, 1681, 1453, 1453, 1453, 1453, 1453, + /* 180 */ 1526, 1453, 1526, 1453, 1453, 1526, 1453, 1526, 1453, 1526, + /* 190 */ 1526, 1453, 1526, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 200 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1524, + /* 210 */ 1717, 1453, 1524, 1453, 1453, 1453, 1524, 1896, 1453, 1453, + /* 220 */ 1453, 1453, 1896, 1453, 1453, 1453, 1453, 1524, 1453, 1524, + /* 230 */ 1453, 1453, 1453, 1898, 1896, 1453, 1453, 1898, 1896, 1453, + /* 240 */ 1453, 1453, 1910, 1906, 1898, 1914, 1912, 1889, 1887, 1874, + /* 250 */ 1453, 1453, 1928, 1924, 1940, 1928, 1924, 1928, 1924, 1453, + /* 260 */ 1591, 1453, 1453, 1453, 1524, 1485, 1453, 1709, 1723, 1625, + /* 270 */ 1625, 1625, 1527, 1458, 1453, 1453, 1453, 1453, 1453, 1453, + /* 280 */ 1453, 1453, 1453, 1453, 1453, 1453, 1794, 1909, 1908, 1832, + /* 290 */ 1831, 1830, 1828, 1793, 1453, 1587, 1792, 1791, 1453, 1453, + /* 300 */ 1453, 1453, 1453, 1453, 1453, 1453, 1785, 1786, 1784, 1783, + /* 310 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 320 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 330 */ 1857, 1453, 1925, 1929, 1453, 1453, 1453, 1768, 1453, 1453, + /* 340 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 350 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 360 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 370 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 380 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 390 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 400 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 410 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 420 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 430 */ 1453, 1490, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 440 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 450 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 460 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 470 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1556, 1555, + /* 480 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 490 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 500 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 510 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1727, 1453, 1453, + /* 520 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1890, 1453, 1453, + /* 530 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 540 */ 1453, 1453, 1453, 1453, 1768, 1453, 1907, 1453, 1867, 1863, + /* 550 */ 1453, 1453, 1859, 1767, 1453, 1453, 1923, 1453, 1453, 1453, + /* 560 */ 1453, 1453, 1453, 1453, 1453, 1453, 1852, 1453, 1825, 1810, + /* 570 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 580 */ 1779, 1453, 1453, 1453, 1453, 1453, 1619, 1453, 1453, 1453, + /* 590 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1604, + /* 600 */ 1602, 1601, 1600, 1453, 1597, 1453, 1453, 1453, 1453, 1628, + /* 610 */ 1627, 1453, 1453, 1453, 1453, 1453, 1453, 1547, 1453, 1453, + /* 620 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1538, 1453, 1537, + /* 630 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 640 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 650 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 660 */ 1453, 1453, 1453, }; /********** End of lemon-generated parsing tables *****************************/ @@ -951,6 +949,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* EXISTS => nothing */ 0, /* BUFFER => nothing */ 0, /* CACHELAST => nothing */ + 0, /* CACHELASTSIZE => nothing */ 0, /* COMP => nothing */ 0, /* DURATION => nothing */ 0, /* NK_VARIABLE => nothing */ @@ -1135,11 +1134,11 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 247, /* NK_BITNOT => ID */ - 247, /* VALUES => ID */ - 247, /* IMPORT => ID */ - 247, /* NK_SEMI => ID */ - 247, /* FILE => ID */ + 248, /* NK_BITNOT => ID */ + 248, /* VALUES => ID */ + 248, /* IMPORT => ID */ + 248, /* NK_SEMI => ID */ + 248, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1291,318 +1290,319 @@ static const char *const yyTokenName[] = { /* 61 */ "EXISTS", /* 62 */ "BUFFER", /* 63 */ "CACHELAST", - /* 64 */ "COMP", - /* 65 */ "DURATION", - /* 66 */ "NK_VARIABLE", - /* 67 */ "FSYNC", - /* 68 */ "MAXROWS", - /* 69 */ "MINROWS", - /* 70 */ "KEEP", - /* 71 */ "PAGES", - /* 72 */ "PAGESIZE", - /* 73 */ "PRECISION", - /* 74 */ "REPLICA", - /* 75 */ "STRICT", - /* 76 */ "WAL", - /* 77 */ "VGROUPS", - /* 78 */ "SINGLE_STABLE", - /* 79 */ "RETENTIONS", - /* 80 */ "SCHEMALESS", - /* 81 */ "NK_COLON", - /* 82 */ "TABLE", - /* 83 */ "NK_LP", - /* 84 */ "NK_RP", - /* 85 */ "STABLE", - /* 86 */ "ADD", - /* 87 */ "COLUMN", - /* 88 */ "MODIFY", - /* 89 */ "RENAME", - /* 90 */ "TAG", - /* 91 */ "SET", - /* 92 */ "NK_EQ", - /* 93 */ "USING", - /* 94 */ "TAGS", - /* 95 */ "COMMENT", - /* 96 */ "BOOL", - /* 97 */ "TINYINT", - /* 98 */ "SMALLINT", - /* 99 */ "INT", - /* 100 */ "INTEGER", - /* 101 */ "BIGINT", - /* 102 */ "FLOAT", - /* 103 */ "DOUBLE", - /* 104 */ "BINARY", - /* 105 */ "TIMESTAMP", - /* 106 */ "NCHAR", - /* 107 */ "UNSIGNED", - /* 108 */ "JSON", - /* 109 */ "VARCHAR", - /* 110 */ "MEDIUMBLOB", - /* 111 */ "BLOB", - /* 112 */ "VARBINARY", - /* 113 */ "DECIMAL", - /* 114 */ "MAX_DELAY", - /* 115 */ "WATERMARK", - /* 116 */ "ROLLUP", - /* 117 */ "TTL", - /* 118 */ "SMA", - /* 119 */ "FIRST", - /* 120 */ "LAST", - /* 121 */ "SHOW", - /* 122 */ "DATABASES", - /* 123 */ "TABLES", - /* 124 */ "STABLES", - /* 125 */ "MNODES", - /* 126 */ "MODULES", - /* 127 */ "QNODES", - /* 128 */ "FUNCTIONS", - /* 129 */ "INDEXES", - /* 130 */ "ACCOUNTS", - /* 131 */ "APPS", - /* 132 */ "CONNECTIONS", - /* 133 */ "LICENCE", - /* 134 */ "GRANTS", - /* 135 */ "QUERIES", - /* 136 */ "SCORES", - /* 137 */ "TOPICS", - /* 138 */ "VARIABLES", - /* 139 */ "BNODES", - /* 140 */ "SNODES", - /* 141 */ "CLUSTER", - /* 142 */ "TRANSACTIONS", - /* 143 */ "DISTRIBUTED", - /* 144 */ "CONSUMERS", - /* 145 */ "SUBSCRIPTIONS", - /* 146 */ "LIKE", - /* 147 */ "INDEX", - /* 148 */ "FUNCTION", - /* 149 */ "INTERVAL", - /* 150 */ "TOPIC", - /* 151 */ "AS", - /* 152 */ "WITH", - /* 153 */ "META", - /* 154 */ "CONSUMER", - /* 155 */ "GROUP", - /* 156 */ "DESC", - /* 157 */ "DESCRIBE", - /* 158 */ "RESET", - /* 159 */ "QUERY", - /* 160 */ "CACHE", - /* 161 */ "EXPLAIN", - /* 162 */ "ANALYZE", - /* 163 */ "VERBOSE", - /* 164 */ "NK_BOOL", - /* 165 */ "RATIO", - /* 166 */ "NK_FLOAT", - /* 167 */ "COMPACT", - /* 168 */ "VNODES", - /* 169 */ "IN", - /* 170 */ "OUTPUTTYPE", - /* 171 */ "AGGREGATE", - /* 172 */ "BUFSIZE", - /* 173 */ "STREAM", - /* 174 */ "INTO", - /* 175 */ "TRIGGER", - /* 176 */ "AT_ONCE", - /* 177 */ "WINDOW_CLOSE", - /* 178 */ "IGNORE", - /* 179 */ "EXPIRED", - /* 180 */ "KILL", - /* 181 */ "CONNECTION", - /* 182 */ "TRANSACTION", - /* 183 */ "BALANCE", - /* 184 */ "VGROUP", - /* 185 */ "MERGE", - /* 186 */ "REDISTRIBUTE", - /* 187 */ "SPLIT", - /* 188 */ "SYNCDB", - /* 189 */ "DELETE", - /* 190 */ "INSERT", - /* 191 */ "NULL", - /* 192 */ "NK_QUESTION", - /* 193 */ "NK_ARROW", - /* 194 */ "ROWTS", - /* 195 */ "TBNAME", - /* 196 */ "QSTARTTS", - /* 197 */ "QENDTS", - /* 198 */ "WSTARTTS", - /* 199 */ "WENDTS", - /* 200 */ "WDURATION", - /* 201 */ "CAST", - /* 202 */ "NOW", - /* 203 */ "TODAY", - /* 204 */ "TIMEZONE", - /* 205 */ "CLIENT_VERSION", - /* 206 */ "SERVER_VERSION", - /* 207 */ "SERVER_STATUS", - /* 208 */ "CURRENT_USER", - /* 209 */ "COUNT", - /* 210 */ "LAST_ROW", - /* 211 */ "BETWEEN", - /* 212 */ "IS", - /* 213 */ "NK_LT", - /* 214 */ "NK_GT", - /* 215 */ "NK_LE", - /* 216 */ "NK_GE", - /* 217 */ "NK_NE", - /* 218 */ "MATCH", - /* 219 */ "NMATCH", - /* 220 */ "CONTAINS", - /* 221 */ "JOIN", - /* 222 */ "INNER", - /* 223 */ "SELECT", - /* 224 */ "DISTINCT", - /* 225 */ "WHERE", - /* 226 */ "PARTITION", - /* 227 */ "BY", - /* 228 */ "SESSION", - /* 229 */ "STATE_WINDOW", - /* 230 */ "SLIDING", - /* 231 */ "FILL", - /* 232 */ "VALUE", - /* 233 */ "NONE", - /* 234 */ "PREV", - /* 235 */ "LINEAR", - /* 236 */ "NEXT", - /* 237 */ "HAVING", - /* 238 */ "RANGE", - /* 239 */ "EVERY", - /* 240 */ "ORDER", - /* 241 */ "SLIMIT", - /* 242 */ "SOFFSET", - /* 243 */ "LIMIT", - /* 244 */ "OFFSET", - /* 245 */ "ASC", - /* 246 */ "NULLS", - /* 247 */ "ID", - /* 248 */ "NK_BITNOT", - /* 249 */ "VALUES", - /* 250 */ "IMPORT", - /* 251 */ "NK_SEMI", - /* 252 */ "FILE", - /* 253 */ "cmd", - /* 254 */ "account_options", - /* 255 */ "alter_account_options", - /* 256 */ "literal", - /* 257 */ "alter_account_option", - /* 258 */ "user_name", - /* 259 */ "sysinfo_opt", - /* 260 */ "privileges", - /* 261 */ "priv_level", - /* 262 */ "priv_type_list", - /* 263 */ "priv_type", - /* 264 */ "db_name", - /* 265 */ "dnode_endpoint", - /* 266 */ "not_exists_opt", - /* 267 */ "db_options", - /* 268 */ "exists_opt", - /* 269 */ "alter_db_options", - /* 270 */ "integer_list", - /* 271 */ "variable_list", - /* 272 */ "retention_list", - /* 273 */ "alter_db_option", - /* 274 */ "retention", - /* 275 */ "full_table_name", - /* 276 */ "column_def_list", - /* 277 */ "tags_def_opt", - /* 278 */ "table_options", - /* 279 */ "multi_create_clause", - /* 280 */ "tags_def", - /* 281 */ "multi_drop_clause", - /* 282 */ "alter_table_clause", - /* 283 */ "alter_table_options", - /* 284 */ "column_name", - /* 285 */ "type_name", - /* 286 */ "signed_literal", - /* 287 */ "create_subtable_clause", - /* 288 */ "specific_cols_opt", - /* 289 */ "expression_list", - /* 290 */ "drop_table_clause", - /* 291 */ "col_name_list", - /* 292 */ "table_name", - /* 293 */ "column_def", - /* 294 */ "duration_list", - /* 295 */ "rollup_func_list", - /* 296 */ "alter_table_option", - /* 297 */ "duration_literal", - /* 298 */ "rollup_func_name", - /* 299 */ "function_name", - /* 300 */ "col_name", - /* 301 */ "db_name_cond_opt", - /* 302 */ "like_pattern_opt", - /* 303 */ "table_name_cond", - /* 304 */ "from_db_opt", - /* 305 */ "index_name", - /* 306 */ "index_options", - /* 307 */ "func_list", - /* 308 */ "sliding_opt", - /* 309 */ "sma_stream_opt", - /* 310 */ "func", - /* 311 */ "stream_options", - /* 312 */ "topic_name", - /* 313 */ "query_expression", - /* 314 */ "cgroup_name", - /* 315 */ "analyze_opt", - /* 316 */ "explain_options", - /* 317 */ "agg_func_opt", - /* 318 */ "bufsize_opt", - /* 319 */ "stream_name", - /* 320 */ "into_opt", - /* 321 */ "dnode_list", - /* 322 */ "where_clause_opt", - /* 323 */ "signed", - /* 324 */ "literal_func", - /* 325 */ "literal_list", - /* 326 */ "table_alias", - /* 327 */ "column_alias", - /* 328 */ "expression", - /* 329 */ "pseudo_column", - /* 330 */ "column_reference", - /* 331 */ "function_expression", - /* 332 */ "subquery", - /* 333 */ "star_func", - /* 334 */ "star_func_para_list", - /* 335 */ "noarg_func", - /* 336 */ "other_para_list", - /* 337 */ "star_func_para", - /* 338 */ "predicate", - /* 339 */ "compare_op", - /* 340 */ "in_op", - /* 341 */ "in_predicate_value", - /* 342 */ "boolean_value_expression", - /* 343 */ "boolean_primary", - /* 344 */ "common_expression", - /* 345 */ "from_clause_opt", - /* 346 */ "table_reference_list", - /* 347 */ "table_reference", - /* 348 */ "table_primary", - /* 349 */ "joined_table", - /* 350 */ "alias_opt", - /* 351 */ "parenthesized_joined_table", - /* 352 */ "join_type", - /* 353 */ "search_condition", - /* 354 */ "query_specification", - /* 355 */ "set_quantifier_opt", - /* 356 */ "select_list", - /* 357 */ "partition_by_clause_opt", - /* 358 */ "range_opt", - /* 359 */ "every_opt", - /* 360 */ "fill_opt", - /* 361 */ "twindow_clause_opt", - /* 362 */ "group_by_clause_opt", - /* 363 */ "having_clause_opt", - /* 364 */ "select_item", - /* 365 */ "fill_mode", - /* 366 */ "group_by_list", - /* 367 */ "query_expression_body", - /* 368 */ "order_by_clause_opt", - /* 369 */ "slimit_clause_opt", - /* 370 */ "limit_clause_opt", - /* 371 */ "query_primary", - /* 372 */ "sort_specification_list", - /* 373 */ "sort_specification", - /* 374 */ "ordering_specification_opt", - /* 375 */ "null_ordering_opt", + /* 64 */ "CACHELASTSIZE", + /* 65 */ "COMP", + /* 66 */ "DURATION", + /* 67 */ "NK_VARIABLE", + /* 68 */ "FSYNC", + /* 69 */ "MAXROWS", + /* 70 */ "MINROWS", + /* 71 */ "KEEP", + /* 72 */ "PAGES", + /* 73 */ "PAGESIZE", + /* 74 */ "PRECISION", + /* 75 */ "REPLICA", + /* 76 */ "STRICT", + /* 77 */ "WAL", + /* 78 */ "VGROUPS", + /* 79 */ "SINGLE_STABLE", + /* 80 */ "RETENTIONS", + /* 81 */ "SCHEMALESS", + /* 82 */ "NK_COLON", + /* 83 */ "TABLE", + /* 84 */ "NK_LP", + /* 85 */ "NK_RP", + /* 86 */ "STABLE", + /* 87 */ "ADD", + /* 88 */ "COLUMN", + /* 89 */ "MODIFY", + /* 90 */ "RENAME", + /* 91 */ "TAG", + /* 92 */ "SET", + /* 93 */ "NK_EQ", + /* 94 */ "USING", + /* 95 */ "TAGS", + /* 96 */ "COMMENT", + /* 97 */ "BOOL", + /* 98 */ "TINYINT", + /* 99 */ "SMALLINT", + /* 100 */ "INT", + /* 101 */ "INTEGER", + /* 102 */ "BIGINT", + /* 103 */ "FLOAT", + /* 104 */ "DOUBLE", + /* 105 */ "BINARY", + /* 106 */ "TIMESTAMP", + /* 107 */ "NCHAR", + /* 108 */ "UNSIGNED", + /* 109 */ "JSON", + /* 110 */ "VARCHAR", + /* 111 */ "MEDIUMBLOB", + /* 112 */ "BLOB", + /* 113 */ "VARBINARY", + /* 114 */ "DECIMAL", + /* 115 */ "MAX_DELAY", + /* 116 */ "WATERMARK", + /* 117 */ "ROLLUP", + /* 118 */ "TTL", + /* 119 */ "SMA", + /* 120 */ "FIRST", + /* 121 */ "LAST", + /* 122 */ "SHOW", + /* 123 */ "DATABASES", + /* 124 */ "TABLES", + /* 125 */ "STABLES", + /* 126 */ "MNODES", + /* 127 */ "MODULES", + /* 128 */ "QNODES", + /* 129 */ "FUNCTIONS", + /* 130 */ "INDEXES", + /* 131 */ "ACCOUNTS", + /* 132 */ "APPS", + /* 133 */ "CONNECTIONS", + /* 134 */ "LICENCE", + /* 135 */ "GRANTS", + /* 136 */ "QUERIES", + /* 137 */ "SCORES", + /* 138 */ "TOPICS", + /* 139 */ "VARIABLES", + /* 140 */ "BNODES", + /* 141 */ "SNODES", + /* 142 */ "CLUSTER", + /* 143 */ "TRANSACTIONS", + /* 144 */ "DISTRIBUTED", + /* 145 */ "CONSUMERS", + /* 146 */ "SUBSCRIPTIONS", + /* 147 */ "LIKE", + /* 148 */ "INDEX", + /* 149 */ "FUNCTION", + /* 150 */ "INTERVAL", + /* 151 */ "TOPIC", + /* 152 */ "AS", + /* 153 */ "WITH", + /* 154 */ "META", + /* 155 */ "CONSUMER", + /* 156 */ "GROUP", + /* 157 */ "DESC", + /* 158 */ "DESCRIBE", + /* 159 */ "RESET", + /* 160 */ "QUERY", + /* 161 */ "CACHE", + /* 162 */ "EXPLAIN", + /* 163 */ "ANALYZE", + /* 164 */ "VERBOSE", + /* 165 */ "NK_BOOL", + /* 166 */ "RATIO", + /* 167 */ "NK_FLOAT", + /* 168 */ "COMPACT", + /* 169 */ "VNODES", + /* 170 */ "IN", + /* 171 */ "OUTPUTTYPE", + /* 172 */ "AGGREGATE", + /* 173 */ "BUFSIZE", + /* 174 */ "STREAM", + /* 175 */ "INTO", + /* 176 */ "TRIGGER", + /* 177 */ "AT_ONCE", + /* 178 */ "WINDOW_CLOSE", + /* 179 */ "IGNORE", + /* 180 */ "EXPIRED", + /* 181 */ "KILL", + /* 182 */ "CONNECTION", + /* 183 */ "TRANSACTION", + /* 184 */ "BALANCE", + /* 185 */ "VGROUP", + /* 186 */ "MERGE", + /* 187 */ "REDISTRIBUTE", + /* 188 */ "SPLIT", + /* 189 */ "SYNCDB", + /* 190 */ "DELETE", + /* 191 */ "INSERT", + /* 192 */ "NULL", + /* 193 */ "NK_QUESTION", + /* 194 */ "NK_ARROW", + /* 195 */ "ROWTS", + /* 196 */ "TBNAME", + /* 197 */ "QSTARTTS", + /* 198 */ "QENDTS", + /* 199 */ "WSTARTTS", + /* 200 */ "WENDTS", + /* 201 */ "WDURATION", + /* 202 */ "CAST", + /* 203 */ "NOW", + /* 204 */ "TODAY", + /* 205 */ "TIMEZONE", + /* 206 */ "CLIENT_VERSION", + /* 207 */ "SERVER_VERSION", + /* 208 */ "SERVER_STATUS", + /* 209 */ "CURRENT_USER", + /* 210 */ "COUNT", + /* 211 */ "LAST_ROW", + /* 212 */ "BETWEEN", + /* 213 */ "IS", + /* 214 */ "NK_LT", + /* 215 */ "NK_GT", + /* 216 */ "NK_LE", + /* 217 */ "NK_GE", + /* 218 */ "NK_NE", + /* 219 */ "MATCH", + /* 220 */ "NMATCH", + /* 221 */ "CONTAINS", + /* 222 */ "JOIN", + /* 223 */ "INNER", + /* 224 */ "SELECT", + /* 225 */ "DISTINCT", + /* 226 */ "WHERE", + /* 227 */ "PARTITION", + /* 228 */ "BY", + /* 229 */ "SESSION", + /* 230 */ "STATE_WINDOW", + /* 231 */ "SLIDING", + /* 232 */ "FILL", + /* 233 */ "VALUE", + /* 234 */ "NONE", + /* 235 */ "PREV", + /* 236 */ "LINEAR", + /* 237 */ "NEXT", + /* 238 */ "HAVING", + /* 239 */ "RANGE", + /* 240 */ "EVERY", + /* 241 */ "ORDER", + /* 242 */ "SLIMIT", + /* 243 */ "SOFFSET", + /* 244 */ "LIMIT", + /* 245 */ "OFFSET", + /* 246 */ "ASC", + /* 247 */ "NULLS", + /* 248 */ "ID", + /* 249 */ "NK_BITNOT", + /* 250 */ "VALUES", + /* 251 */ "IMPORT", + /* 252 */ "NK_SEMI", + /* 253 */ "FILE", + /* 254 */ "cmd", + /* 255 */ "account_options", + /* 256 */ "alter_account_options", + /* 257 */ "literal", + /* 258 */ "alter_account_option", + /* 259 */ "user_name", + /* 260 */ "sysinfo_opt", + /* 261 */ "privileges", + /* 262 */ "priv_level", + /* 263 */ "priv_type_list", + /* 264 */ "priv_type", + /* 265 */ "db_name", + /* 266 */ "dnode_endpoint", + /* 267 */ "not_exists_opt", + /* 268 */ "db_options", + /* 269 */ "exists_opt", + /* 270 */ "alter_db_options", + /* 271 */ "integer_list", + /* 272 */ "variable_list", + /* 273 */ "retention_list", + /* 274 */ "alter_db_option", + /* 275 */ "retention", + /* 276 */ "full_table_name", + /* 277 */ "column_def_list", + /* 278 */ "tags_def_opt", + /* 279 */ "table_options", + /* 280 */ "multi_create_clause", + /* 281 */ "tags_def", + /* 282 */ "multi_drop_clause", + /* 283 */ "alter_table_clause", + /* 284 */ "alter_table_options", + /* 285 */ "column_name", + /* 286 */ "type_name", + /* 287 */ "signed_literal", + /* 288 */ "create_subtable_clause", + /* 289 */ "specific_cols_opt", + /* 290 */ "expression_list", + /* 291 */ "drop_table_clause", + /* 292 */ "col_name_list", + /* 293 */ "table_name", + /* 294 */ "column_def", + /* 295 */ "duration_list", + /* 296 */ "rollup_func_list", + /* 297 */ "alter_table_option", + /* 298 */ "duration_literal", + /* 299 */ "rollup_func_name", + /* 300 */ "function_name", + /* 301 */ "col_name", + /* 302 */ "db_name_cond_opt", + /* 303 */ "like_pattern_opt", + /* 304 */ "table_name_cond", + /* 305 */ "from_db_opt", + /* 306 */ "index_name", + /* 307 */ "index_options", + /* 308 */ "func_list", + /* 309 */ "sliding_opt", + /* 310 */ "sma_stream_opt", + /* 311 */ "func", + /* 312 */ "stream_options", + /* 313 */ "topic_name", + /* 314 */ "query_expression", + /* 315 */ "cgroup_name", + /* 316 */ "analyze_opt", + /* 317 */ "explain_options", + /* 318 */ "agg_func_opt", + /* 319 */ "bufsize_opt", + /* 320 */ "stream_name", + /* 321 */ "into_opt", + /* 322 */ "dnode_list", + /* 323 */ "where_clause_opt", + /* 324 */ "signed", + /* 325 */ "literal_func", + /* 326 */ "literal_list", + /* 327 */ "table_alias", + /* 328 */ "column_alias", + /* 329 */ "expression", + /* 330 */ "pseudo_column", + /* 331 */ "column_reference", + /* 332 */ "function_expression", + /* 333 */ "subquery", + /* 334 */ "star_func", + /* 335 */ "star_func_para_list", + /* 336 */ "noarg_func", + /* 337 */ "other_para_list", + /* 338 */ "star_func_para", + /* 339 */ "predicate", + /* 340 */ "compare_op", + /* 341 */ "in_op", + /* 342 */ "in_predicate_value", + /* 343 */ "boolean_value_expression", + /* 344 */ "boolean_primary", + /* 345 */ "common_expression", + /* 346 */ "from_clause_opt", + /* 347 */ "table_reference_list", + /* 348 */ "table_reference", + /* 349 */ "table_primary", + /* 350 */ "joined_table", + /* 351 */ "alias_opt", + /* 352 */ "parenthesized_joined_table", + /* 353 */ "join_type", + /* 354 */ "search_condition", + /* 355 */ "query_specification", + /* 356 */ "set_quantifier_opt", + /* 357 */ "select_list", + /* 358 */ "partition_by_clause_opt", + /* 359 */ "range_opt", + /* 360 */ "every_opt", + /* 361 */ "fill_opt", + /* 362 */ "twindow_clause_opt", + /* 363 */ "group_by_clause_opt", + /* 364 */ "having_clause_opt", + /* 365 */ "select_item", + /* 366 */ "fill_mode", + /* 367 */ "group_by_list", + /* 368 */ "query_expression_body", + /* 369 */ "order_by_clause_opt", + /* 370 */ "slimit_clause_opt", + /* 371 */ "limit_clause_opt", + /* 372 */ "query_primary", + /* 373 */ "sort_specification_list", + /* 374 */ "sort_specification", + /* 375 */ "ordering_specification_opt", + /* 376 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1684,417 +1684,419 @@ static const char *const yyRuleName[] = { /* 71 */ "db_options ::=", /* 72 */ "db_options ::= db_options BUFFER NK_INTEGER", /* 73 */ "db_options ::= db_options CACHELAST NK_INTEGER", - /* 74 */ "db_options ::= db_options COMP NK_INTEGER", - /* 75 */ "db_options ::= db_options DURATION NK_INTEGER", - /* 76 */ "db_options ::= db_options DURATION NK_VARIABLE", - /* 77 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 78 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 79 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 80 */ "db_options ::= db_options KEEP integer_list", - /* 81 */ "db_options ::= db_options KEEP variable_list", - /* 82 */ "db_options ::= db_options PAGES NK_INTEGER", - /* 83 */ "db_options ::= db_options PAGESIZE NK_INTEGER", - /* 84 */ "db_options ::= db_options PRECISION NK_STRING", - /* 85 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 86 */ "db_options ::= db_options STRICT NK_INTEGER", - /* 87 */ "db_options ::= db_options WAL NK_INTEGER", - /* 88 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 89 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 90 */ "db_options ::= db_options RETENTIONS retention_list", - /* 91 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", - /* 92 */ "alter_db_options ::= alter_db_option", - /* 93 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 94 */ "alter_db_option ::= BUFFER NK_INTEGER", - /* 95 */ "alter_db_option ::= CACHELAST NK_INTEGER", - /* 96 */ "alter_db_option ::= FSYNC NK_INTEGER", - /* 97 */ "alter_db_option ::= KEEP integer_list", - /* 98 */ "alter_db_option ::= KEEP variable_list", - /* 99 */ "alter_db_option ::= PAGES NK_INTEGER", - /* 100 */ "alter_db_option ::= REPLICA NK_INTEGER", - /* 101 */ "alter_db_option ::= STRICT NK_INTEGER", - /* 102 */ "alter_db_option ::= WAL NK_INTEGER", - /* 103 */ "integer_list ::= NK_INTEGER", - /* 104 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", - /* 105 */ "variable_list ::= NK_VARIABLE", - /* 106 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", - /* 107 */ "retention_list ::= retention", - /* 108 */ "retention_list ::= retention_list NK_COMMA retention", - /* 109 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 110 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 111 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 112 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 113 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 114 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 115 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 116 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 117 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 118 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 119 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 120 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 121 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 122 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 123 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 124 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 125 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 126 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 127 */ "multi_create_clause ::= create_subtable_clause", - /* 128 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 129 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", - /* 130 */ "multi_drop_clause ::= drop_table_clause", - /* 131 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 132 */ "drop_table_clause ::= exists_opt full_table_name", - /* 133 */ "specific_cols_opt ::=", - /* 134 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 135 */ "full_table_name ::= table_name", - /* 136 */ "full_table_name ::= db_name NK_DOT table_name", - /* 137 */ "column_def_list ::= column_def", - /* 138 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 139 */ "column_def ::= column_name type_name", - /* 140 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 141 */ "type_name ::= BOOL", - /* 142 */ "type_name ::= TINYINT", - /* 143 */ "type_name ::= SMALLINT", - /* 144 */ "type_name ::= INT", - /* 145 */ "type_name ::= INTEGER", - /* 146 */ "type_name ::= BIGINT", - /* 147 */ "type_name ::= FLOAT", - /* 148 */ "type_name ::= DOUBLE", - /* 149 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 150 */ "type_name ::= TIMESTAMP", - /* 151 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 152 */ "type_name ::= TINYINT UNSIGNED", - /* 153 */ "type_name ::= SMALLINT UNSIGNED", - /* 154 */ "type_name ::= INT UNSIGNED", - /* 155 */ "type_name ::= BIGINT UNSIGNED", - /* 156 */ "type_name ::= JSON", - /* 157 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 158 */ "type_name ::= MEDIUMBLOB", - /* 159 */ "type_name ::= BLOB", - /* 160 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 161 */ "type_name ::= DECIMAL", - /* 162 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 163 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 164 */ "tags_def_opt ::=", - /* 165 */ "tags_def_opt ::= tags_def", - /* 166 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 167 */ "table_options ::=", - /* 168 */ "table_options ::= table_options COMMENT NK_STRING", - /* 169 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 170 */ "table_options ::= table_options WATERMARK duration_list", - /* 171 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 172 */ "table_options ::= table_options TTL NK_INTEGER", - /* 173 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 174 */ "alter_table_options ::= alter_table_option", - /* 175 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 176 */ "alter_table_option ::= COMMENT NK_STRING", - /* 177 */ "alter_table_option ::= TTL NK_INTEGER", - /* 178 */ "duration_list ::= duration_literal", - /* 179 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 180 */ "rollup_func_list ::= rollup_func_name", - /* 181 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 182 */ "rollup_func_name ::= function_name", - /* 183 */ "rollup_func_name ::= FIRST", - /* 184 */ "rollup_func_name ::= LAST", - /* 185 */ "col_name_list ::= col_name", - /* 186 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 187 */ "col_name ::= column_name", - /* 188 */ "cmd ::= SHOW DNODES", - /* 189 */ "cmd ::= SHOW USERS", - /* 190 */ "cmd ::= SHOW DATABASES", - /* 191 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 192 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 193 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 194 */ "cmd ::= SHOW MNODES", - /* 195 */ "cmd ::= SHOW MODULES", - /* 196 */ "cmd ::= SHOW QNODES", - /* 197 */ "cmd ::= SHOW FUNCTIONS", - /* 198 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 199 */ "cmd ::= SHOW STREAMS", - /* 200 */ "cmd ::= SHOW ACCOUNTS", - /* 201 */ "cmd ::= SHOW APPS", - /* 202 */ "cmd ::= SHOW CONNECTIONS", - /* 203 */ "cmd ::= SHOW LICENCE", - /* 204 */ "cmd ::= SHOW GRANTS", - /* 205 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 206 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 207 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 208 */ "cmd ::= SHOW QUERIES", - /* 209 */ "cmd ::= SHOW SCORES", - /* 210 */ "cmd ::= SHOW TOPICS", - /* 211 */ "cmd ::= SHOW VARIABLES", - /* 212 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 213 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", - /* 214 */ "cmd ::= SHOW BNODES", - /* 215 */ "cmd ::= SHOW SNODES", - /* 216 */ "cmd ::= SHOW CLUSTER", - /* 217 */ "cmd ::= SHOW TRANSACTIONS", - /* 218 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 219 */ "cmd ::= SHOW CONSUMERS", - /* 220 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 221 */ "db_name_cond_opt ::=", - /* 222 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 223 */ "like_pattern_opt ::=", - /* 224 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 225 */ "table_name_cond ::= table_name", - /* 226 */ "from_db_opt ::=", - /* 227 */ "from_db_opt ::= FROM db_name", - /* 228 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 229 */ "cmd ::= DROP INDEX exists_opt index_name", - /* 230 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 231 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", - /* 232 */ "func_list ::= func", - /* 233 */ "func_list ::= func_list NK_COMMA func", - /* 234 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 235 */ "sma_stream_opt ::=", - /* 236 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", - /* 237 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", - /* 238 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 239 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 240 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 241 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 242 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 243 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 244 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 245 */ "cmd ::= DESC full_table_name", - /* 246 */ "cmd ::= DESCRIBE full_table_name", - /* 247 */ "cmd ::= RESET QUERY CACHE", - /* 248 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 249 */ "analyze_opt ::=", - /* 250 */ "analyze_opt ::= ANALYZE", - /* 251 */ "explain_options ::=", - /* 252 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 253 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 254 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", - /* 255 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 256 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 257 */ "agg_func_opt ::=", - /* 258 */ "agg_func_opt ::= AGGREGATE", - /* 259 */ "bufsize_opt ::=", - /* 260 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 261 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", - /* 262 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 263 */ "into_opt ::=", - /* 264 */ "into_opt ::= INTO full_table_name", - /* 265 */ "stream_options ::=", - /* 266 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 267 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 268 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 269 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 270 */ "stream_options ::= stream_options IGNORE EXPIRED", - /* 271 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 272 */ "cmd ::= KILL QUERY NK_STRING", - /* 273 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 274 */ "cmd ::= BALANCE VGROUP", - /* 275 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 276 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 277 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 278 */ "dnode_list ::= DNODE NK_INTEGER", - /* 279 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 280 */ "cmd ::= SYNCDB db_name REPLICA", - /* 281 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 282 */ "cmd ::= query_expression", - /* 283 */ "cmd ::= INSERT INTO full_table_name specific_cols_opt query_expression", - /* 284 */ "literal ::= NK_INTEGER", - /* 285 */ "literal ::= NK_FLOAT", - /* 286 */ "literal ::= NK_STRING", - /* 287 */ "literal ::= NK_BOOL", - /* 288 */ "literal ::= TIMESTAMP NK_STRING", - /* 289 */ "literal ::= duration_literal", - /* 290 */ "literal ::= NULL", - /* 291 */ "literal ::= NK_QUESTION", - /* 292 */ "duration_literal ::= NK_VARIABLE", - /* 293 */ "signed ::= NK_INTEGER", - /* 294 */ "signed ::= NK_PLUS NK_INTEGER", - /* 295 */ "signed ::= NK_MINUS NK_INTEGER", - /* 296 */ "signed ::= NK_FLOAT", - /* 297 */ "signed ::= NK_PLUS NK_FLOAT", - /* 298 */ "signed ::= NK_MINUS NK_FLOAT", - /* 299 */ "signed_literal ::= signed", - /* 300 */ "signed_literal ::= NK_STRING", - /* 301 */ "signed_literal ::= NK_BOOL", - /* 302 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 303 */ "signed_literal ::= duration_literal", - /* 304 */ "signed_literal ::= NULL", - /* 305 */ "signed_literal ::= literal_func", - /* 306 */ "literal_list ::= signed_literal", - /* 307 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 308 */ "db_name ::= NK_ID", - /* 309 */ "table_name ::= NK_ID", - /* 310 */ "column_name ::= NK_ID", - /* 311 */ "function_name ::= NK_ID", - /* 312 */ "table_alias ::= NK_ID", - /* 313 */ "column_alias ::= NK_ID", - /* 314 */ "user_name ::= NK_ID", - /* 315 */ "index_name ::= NK_ID", - /* 316 */ "topic_name ::= NK_ID", - /* 317 */ "stream_name ::= NK_ID", - /* 318 */ "cgroup_name ::= NK_ID", - /* 319 */ "expression ::= literal", - /* 320 */ "expression ::= pseudo_column", - /* 321 */ "expression ::= column_reference", - /* 322 */ "expression ::= function_expression", - /* 323 */ "expression ::= subquery", - /* 324 */ "expression ::= NK_LP expression NK_RP", - /* 325 */ "expression ::= NK_PLUS expression", - /* 326 */ "expression ::= NK_MINUS expression", - /* 327 */ "expression ::= expression NK_PLUS expression", - /* 328 */ "expression ::= expression NK_MINUS expression", - /* 329 */ "expression ::= expression NK_STAR expression", - /* 330 */ "expression ::= expression NK_SLASH expression", - /* 331 */ "expression ::= expression NK_REM expression", - /* 332 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 333 */ "expression ::= expression NK_BITAND expression", - /* 334 */ "expression ::= expression NK_BITOR expression", - /* 335 */ "expression_list ::= expression", - /* 336 */ "expression_list ::= expression_list NK_COMMA expression", - /* 337 */ "column_reference ::= column_name", - /* 338 */ "column_reference ::= table_name NK_DOT column_name", - /* 339 */ "pseudo_column ::= ROWTS", - /* 340 */ "pseudo_column ::= TBNAME", - /* 341 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 342 */ "pseudo_column ::= QSTARTTS", - /* 343 */ "pseudo_column ::= QENDTS", - /* 344 */ "pseudo_column ::= WSTARTTS", - /* 345 */ "pseudo_column ::= WENDTS", - /* 346 */ "pseudo_column ::= WDURATION", - /* 347 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 348 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 349 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 350 */ "function_expression ::= literal_func", - /* 351 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 352 */ "literal_func ::= NOW", - /* 353 */ "noarg_func ::= NOW", - /* 354 */ "noarg_func ::= TODAY", - /* 355 */ "noarg_func ::= TIMEZONE", - /* 356 */ "noarg_func ::= DATABASE", - /* 357 */ "noarg_func ::= CLIENT_VERSION", - /* 358 */ "noarg_func ::= SERVER_VERSION", - /* 359 */ "noarg_func ::= SERVER_STATUS", - /* 360 */ "noarg_func ::= CURRENT_USER", - /* 361 */ "noarg_func ::= USER", - /* 362 */ "star_func ::= COUNT", - /* 363 */ "star_func ::= FIRST", - /* 364 */ "star_func ::= LAST", - /* 365 */ "star_func ::= LAST_ROW", - /* 366 */ "star_func_para_list ::= NK_STAR", - /* 367 */ "star_func_para_list ::= other_para_list", - /* 368 */ "other_para_list ::= star_func_para", - /* 369 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 370 */ "star_func_para ::= expression", - /* 371 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 372 */ "predicate ::= expression compare_op expression", - /* 373 */ "predicate ::= expression BETWEEN expression AND expression", - /* 374 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 375 */ "predicate ::= expression IS NULL", - /* 376 */ "predicate ::= expression IS NOT NULL", - /* 377 */ "predicate ::= expression in_op in_predicate_value", - /* 378 */ "compare_op ::= NK_LT", - /* 379 */ "compare_op ::= NK_GT", - /* 380 */ "compare_op ::= NK_LE", - /* 381 */ "compare_op ::= NK_GE", - /* 382 */ "compare_op ::= NK_NE", - /* 383 */ "compare_op ::= NK_EQ", - /* 384 */ "compare_op ::= LIKE", - /* 385 */ "compare_op ::= NOT LIKE", - /* 386 */ "compare_op ::= MATCH", - /* 387 */ "compare_op ::= NMATCH", - /* 388 */ "compare_op ::= CONTAINS", - /* 389 */ "in_op ::= IN", - /* 390 */ "in_op ::= NOT IN", - /* 391 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 392 */ "boolean_value_expression ::= boolean_primary", - /* 393 */ "boolean_value_expression ::= NOT boolean_primary", - /* 394 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 395 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 396 */ "boolean_primary ::= predicate", - /* 397 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 398 */ "common_expression ::= expression", - /* 399 */ "common_expression ::= boolean_value_expression", - /* 400 */ "from_clause_opt ::=", - /* 401 */ "from_clause_opt ::= FROM table_reference_list", - /* 402 */ "table_reference_list ::= table_reference", - /* 403 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 404 */ "table_reference ::= table_primary", - /* 405 */ "table_reference ::= joined_table", - /* 406 */ "table_primary ::= table_name alias_opt", - /* 407 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 408 */ "table_primary ::= subquery alias_opt", - /* 409 */ "table_primary ::= parenthesized_joined_table", - /* 410 */ "alias_opt ::=", - /* 411 */ "alias_opt ::= table_alias", - /* 412 */ "alias_opt ::= AS table_alias", - /* 413 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 414 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 415 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 416 */ "join_type ::=", - /* 417 */ "join_type ::= INNER", - /* 418 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 419 */ "set_quantifier_opt ::=", - /* 420 */ "set_quantifier_opt ::= DISTINCT", - /* 421 */ "set_quantifier_opt ::= ALL", - /* 422 */ "select_list ::= select_item", - /* 423 */ "select_list ::= select_list NK_COMMA select_item", - /* 424 */ "select_item ::= NK_STAR", - /* 425 */ "select_item ::= common_expression", - /* 426 */ "select_item ::= common_expression column_alias", - /* 427 */ "select_item ::= common_expression AS column_alias", - /* 428 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 429 */ "where_clause_opt ::=", - /* 430 */ "where_clause_opt ::= WHERE search_condition", - /* 431 */ "partition_by_clause_opt ::=", - /* 432 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 433 */ "twindow_clause_opt ::=", - /* 434 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 435 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 436 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 437 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 438 */ "sliding_opt ::=", - /* 439 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 440 */ "fill_opt ::=", - /* 441 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 442 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 443 */ "fill_mode ::= NONE", - /* 444 */ "fill_mode ::= PREV", - /* 445 */ "fill_mode ::= NULL", - /* 446 */ "fill_mode ::= LINEAR", - /* 447 */ "fill_mode ::= NEXT", - /* 448 */ "group_by_clause_opt ::=", - /* 449 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 450 */ "group_by_list ::= expression", - /* 451 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 452 */ "having_clause_opt ::=", - /* 453 */ "having_clause_opt ::= HAVING search_condition", - /* 454 */ "range_opt ::=", - /* 455 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", - /* 456 */ "every_opt ::=", - /* 457 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 458 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 459 */ "query_expression_body ::= query_primary", - /* 460 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 461 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 462 */ "query_primary ::= query_specification", - /* 463 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 464 */ "order_by_clause_opt ::=", - /* 465 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 466 */ "slimit_clause_opt ::=", - /* 467 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 468 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 469 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 470 */ "limit_clause_opt ::=", - /* 471 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 472 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 473 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 474 */ "subquery ::= NK_LP query_expression NK_RP", - /* 475 */ "search_condition ::= common_expression", - /* 476 */ "sort_specification_list ::= sort_specification", - /* 477 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 478 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 479 */ "ordering_specification_opt ::=", - /* 480 */ "ordering_specification_opt ::= ASC", - /* 481 */ "ordering_specification_opt ::= DESC", - /* 482 */ "null_ordering_opt ::=", - /* 483 */ "null_ordering_opt ::= NULLS FIRST", - /* 484 */ "null_ordering_opt ::= NULLS LAST", + /* 74 */ "db_options ::= db_options CACHELASTSIZE NK_INTEGER", + /* 75 */ "db_options ::= db_options COMP NK_INTEGER", + /* 76 */ "db_options ::= db_options DURATION NK_INTEGER", + /* 77 */ "db_options ::= db_options DURATION NK_VARIABLE", + /* 78 */ "db_options ::= db_options FSYNC NK_INTEGER", + /* 79 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 80 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 81 */ "db_options ::= db_options KEEP integer_list", + /* 82 */ "db_options ::= db_options KEEP variable_list", + /* 83 */ "db_options ::= db_options PAGES NK_INTEGER", + /* 84 */ "db_options ::= db_options PAGESIZE NK_INTEGER", + /* 85 */ "db_options ::= db_options PRECISION NK_STRING", + /* 86 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 87 */ "db_options ::= db_options STRICT NK_INTEGER", + /* 88 */ "db_options ::= db_options WAL NK_INTEGER", + /* 89 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 90 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 91 */ "db_options ::= db_options RETENTIONS retention_list", + /* 92 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", + /* 93 */ "alter_db_options ::= alter_db_option", + /* 94 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 95 */ "alter_db_option ::= BUFFER NK_INTEGER", + /* 96 */ "alter_db_option ::= CACHELAST NK_INTEGER", + /* 97 */ "alter_db_option ::= CACHELASTSIZE NK_INTEGER", + /* 98 */ "alter_db_option ::= FSYNC NK_INTEGER", + /* 99 */ "alter_db_option ::= KEEP integer_list", + /* 100 */ "alter_db_option ::= KEEP variable_list", + /* 101 */ "alter_db_option ::= PAGES NK_INTEGER", + /* 102 */ "alter_db_option ::= REPLICA NK_INTEGER", + /* 103 */ "alter_db_option ::= STRICT NK_INTEGER", + /* 104 */ "alter_db_option ::= WAL NK_INTEGER", + /* 105 */ "integer_list ::= NK_INTEGER", + /* 106 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 107 */ "variable_list ::= NK_VARIABLE", + /* 108 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 109 */ "retention_list ::= retention", + /* 110 */ "retention_list ::= retention_list NK_COMMA retention", + /* 111 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 112 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 113 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 114 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 115 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 116 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 117 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 118 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 119 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 120 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 121 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 122 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 123 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 124 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 125 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 126 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 127 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 128 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 129 */ "multi_create_clause ::= create_subtable_clause", + /* 130 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 131 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", + /* 132 */ "multi_drop_clause ::= drop_table_clause", + /* 133 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 134 */ "drop_table_clause ::= exists_opt full_table_name", + /* 135 */ "specific_cols_opt ::=", + /* 136 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 137 */ "full_table_name ::= table_name", + /* 138 */ "full_table_name ::= db_name NK_DOT table_name", + /* 139 */ "column_def_list ::= column_def", + /* 140 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 141 */ "column_def ::= column_name type_name", + /* 142 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 143 */ "type_name ::= BOOL", + /* 144 */ "type_name ::= TINYINT", + /* 145 */ "type_name ::= SMALLINT", + /* 146 */ "type_name ::= INT", + /* 147 */ "type_name ::= INTEGER", + /* 148 */ "type_name ::= BIGINT", + /* 149 */ "type_name ::= FLOAT", + /* 150 */ "type_name ::= DOUBLE", + /* 151 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 152 */ "type_name ::= TIMESTAMP", + /* 153 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 154 */ "type_name ::= TINYINT UNSIGNED", + /* 155 */ "type_name ::= SMALLINT UNSIGNED", + /* 156 */ "type_name ::= INT UNSIGNED", + /* 157 */ "type_name ::= BIGINT UNSIGNED", + /* 158 */ "type_name ::= JSON", + /* 159 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 160 */ "type_name ::= MEDIUMBLOB", + /* 161 */ "type_name ::= BLOB", + /* 162 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 163 */ "type_name ::= DECIMAL", + /* 164 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 165 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 166 */ "tags_def_opt ::=", + /* 167 */ "tags_def_opt ::= tags_def", + /* 168 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 169 */ "table_options ::=", + /* 170 */ "table_options ::= table_options COMMENT NK_STRING", + /* 171 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 172 */ "table_options ::= table_options WATERMARK duration_list", + /* 173 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 174 */ "table_options ::= table_options TTL NK_INTEGER", + /* 175 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 176 */ "alter_table_options ::= alter_table_option", + /* 177 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 178 */ "alter_table_option ::= COMMENT NK_STRING", + /* 179 */ "alter_table_option ::= TTL NK_INTEGER", + /* 180 */ "duration_list ::= duration_literal", + /* 181 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 182 */ "rollup_func_list ::= rollup_func_name", + /* 183 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 184 */ "rollup_func_name ::= function_name", + /* 185 */ "rollup_func_name ::= FIRST", + /* 186 */ "rollup_func_name ::= LAST", + /* 187 */ "col_name_list ::= col_name", + /* 188 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 189 */ "col_name ::= column_name", + /* 190 */ "cmd ::= SHOW DNODES", + /* 191 */ "cmd ::= SHOW USERS", + /* 192 */ "cmd ::= SHOW DATABASES", + /* 193 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 194 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 195 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 196 */ "cmd ::= SHOW MNODES", + /* 197 */ "cmd ::= SHOW MODULES", + /* 198 */ "cmd ::= SHOW QNODES", + /* 199 */ "cmd ::= SHOW FUNCTIONS", + /* 200 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 201 */ "cmd ::= SHOW STREAMS", + /* 202 */ "cmd ::= SHOW ACCOUNTS", + /* 203 */ "cmd ::= SHOW APPS", + /* 204 */ "cmd ::= SHOW CONNECTIONS", + /* 205 */ "cmd ::= SHOW LICENCE", + /* 206 */ "cmd ::= SHOW GRANTS", + /* 207 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 208 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 209 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 210 */ "cmd ::= SHOW QUERIES", + /* 211 */ "cmd ::= SHOW SCORES", + /* 212 */ "cmd ::= SHOW TOPICS", + /* 213 */ "cmd ::= SHOW VARIABLES", + /* 214 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 215 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", + /* 216 */ "cmd ::= SHOW BNODES", + /* 217 */ "cmd ::= SHOW SNODES", + /* 218 */ "cmd ::= SHOW CLUSTER", + /* 219 */ "cmd ::= SHOW TRANSACTIONS", + /* 220 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 221 */ "cmd ::= SHOW CONSUMERS", + /* 222 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 223 */ "db_name_cond_opt ::=", + /* 224 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 225 */ "like_pattern_opt ::=", + /* 226 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 227 */ "table_name_cond ::= table_name", + /* 228 */ "from_db_opt ::=", + /* 229 */ "from_db_opt ::= FROM db_name", + /* 230 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 231 */ "cmd ::= DROP INDEX exists_opt index_name", + /* 232 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 233 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", + /* 234 */ "func_list ::= func", + /* 235 */ "func_list ::= func_list NK_COMMA func", + /* 236 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 237 */ "sma_stream_opt ::=", + /* 238 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", + /* 239 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", + /* 240 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 241 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 242 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 243 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 244 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 245 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 246 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 247 */ "cmd ::= DESC full_table_name", + /* 248 */ "cmd ::= DESCRIBE full_table_name", + /* 249 */ "cmd ::= RESET QUERY CACHE", + /* 250 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 251 */ "analyze_opt ::=", + /* 252 */ "analyze_opt ::= ANALYZE", + /* 253 */ "explain_options ::=", + /* 254 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 255 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 256 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", + /* 257 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 258 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 259 */ "agg_func_opt ::=", + /* 260 */ "agg_func_opt ::= AGGREGATE", + /* 261 */ "bufsize_opt ::=", + /* 262 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 263 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", + /* 264 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 265 */ "into_opt ::=", + /* 266 */ "into_opt ::= INTO full_table_name", + /* 267 */ "stream_options ::=", + /* 268 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 269 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 270 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 271 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 272 */ "stream_options ::= stream_options IGNORE EXPIRED", + /* 273 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 274 */ "cmd ::= KILL QUERY NK_STRING", + /* 275 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 276 */ "cmd ::= BALANCE VGROUP", + /* 277 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 278 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 279 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 280 */ "dnode_list ::= DNODE NK_INTEGER", + /* 281 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 282 */ "cmd ::= SYNCDB db_name REPLICA", + /* 283 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 284 */ "cmd ::= query_expression", + /* 285 */ "cmd ::= INSERT INTO full_table_name specific_cols_opt query_expression", + /* 286 */ "literal ::= NK_INTEGER", + /* 287 */ "literal ::= NK_FLOAT", + /* 288 */ "literal ::= NK_STRING", + /* 289 */ "literal ::= NK_BOOL", + /* 290 */ "literal ::= TIMESTAMP NK_STRING", + /* 291 */ "literal ::= duration_literal", + /* 292 */ "literal ::= NULL", + /* 293 */ "literal ::= NK_QUESTION", + /* 294 */ "duration_literal ::= NK_VARIABLE", + /* 295 */ "signed ::= NK_INTEGER", + /* 296 */ "signed ::= NK_PLUS NK_INTEGER", + /* 297 */ "signed ::= NK_MINUS NK_INTEGER", + /* 298 */ "signed ::= NK_FLOAT", + /* 299 */ "signed ::= NK_PLUS NK_FLOAT", + /* 300 */ "signed ::= NK_MINUS NK_FLOAT", + /* 301 */ "signed_literal ::= signed", + /* 302 */ "signed_literal ::= NK_STRING", + /* 303 */ "signed_literal ::= NK_BOOL", + /* 304 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 305 */ "signed_literal ::= duration_literal", + /* 306 */ "signed_literal ::= NULL", + /* 307 */ "signed_literal ::= literal_func", + /* 308 */ "literal_list ::= signed_literal", + /* 309 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 310 */ "db_name ::= NK_ID", + /* 311 */ "table_name ::= NK_ID", + /* 312 */ "column_name ::= NK_ID", + /* 313 */ "function_name ::= NK_ID", + /* 314 */ "table_alias ::= NK_ID", + /* 315 */ "column_alias ::= NK_ID", + /* 316 */ "user_name ::= NK_ID", + /* 317 */ "index_name ::= NK_ID", + /* 318 */ "topic_name ::= NK_ID", + /* 319 */ "stream_name ::= NK_ID", + /* 320 */ "cgroup_name ::= NK_ID", + /* 321 */ "expression ::= literal", + /* 322 */ "expression ::= pseudo_column", + /* 323 */ "expression ::= column_reference", + /* 324 */ "expression ::= function_expression", + /* 325 */ "expression ::= subquery", + /* 326 */ "expression ::= NK_LP expression NK_RP", + /* 327 */ "expression ::= NK_PLUS expression", + /* 328 */ "expression ::= NK_MINUS expression", + /* 329 */ "expression ::= expression NK_PLUS expression", + /* 330 */ "expression ::= expression NK_MINUS expression", + /* 331 */ "expression ::= expression NK_STAR expression", + /* 332 */ "expression ::= expression NK_SLASH expression", + /* 333 */ "expression ::= expression NK_REM expression", + /* 334 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 335 */ "expression ::= expression NK_BITAND expression", + /* 336 */ "expression ::= expression NK_BITOR expression", + /* 337 */ "expression_list ::= expression", + /* 338 */ "expression_list ::= expression_list NK_COMMA expression", + /* 339 */ "column_reference ::= column_name", + /* 340 */ "column_reference ::= table_name NK_DOT column_name", + /* 341 */ "pseudo_column ::= ROWTS", + /* 342 */ "pseudo_column ::= TBNAME", + /* 343 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 344 */ "pseudo_column ::= QSTARTTS", + /* 345 */ "pseudo_column ::= QENDTS", + /* 346 */ "pseudo_column ::= WSTARTTS", + /* 347 */ "pseudo_column ::= WENDTS", + /* 348 */ "pseudo_column ::= WDURATION", + /* 349 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 350 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 351 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 352 */ "function_expression ::= literal_func", + /* 353 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 354 */ "literal_func ::= NOW", + /* 355 */ "noarg_func ::= NOW", + /* 356 */ "noarg_func ::= TODAY", + /* 357 */ "noarg_func ::= TIMEZONE", + /* 358 */ "noarg_func ::= DATABASE", + /* 359 */ "noarg_func ::= CLIENT_VERSION", + /* 360 */ "noarg_func ::= SERVER_VERSION", + /* 361 */ "noarg_func ::= SERVER_STATUS", + /* 362 */ "noarg_func ::= CURRENT_USER", + /* 363 */ "noarg_func ::= USER", + /* 364 */ "star_func ::= COUNT", + /* 365 */ "star_func ::= FIRST", + /* 366 */ "star_func ::= LAST", + /* 367 */ "star_func ::= LAST_ROW", + /* 368 */ "star_func_para_list ::= NK_STAR", + /* 369 */ "star_func_para_list ::= other_para_list", + /* 370 */ "other_para_list ::= star_func_para", + /* 371 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 372 */ "star_func_para ::= expression", + /* 373 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 374 */ "predicate ::= expression compare_op expression", + /* 375 */ "predicate ::= expression BETWEEN expression AND expression", + /* 376 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 377 */ "predicate ::= expression IS NULL", + /* 378 */ "predicate ::= expression IS NOT NULL", + /* 379 */ "predicate ::= expression in_op in_predicate_value", + /* 380 */ "compare_op ::= NK_LT", + /* 381 */ "compare_op ::= NK_GT", + /* 382 */ "compare_op ::= NK_LE", + /* 383 */ "compare_op ::= NK_GE", + /* 384 */ "compare_op ::= NK_NE", + /* 385 */ "compare_op ::= NK_EQ", + /* 386 */ "compare_op ::= LIKE", + /* 387 */ "compare_op ::= NOT LIKE", + /* 388 */ "compare_op ::= MATCH", + /* 389 */ "compare_op ::= NMATCH", + /* 390 */ "compare_op ::= CONTAINS", + /* 391 */ "in_op ::= IN", + /* 392 */ "in_op ::= NOT IN", + /* 393 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 394 */ "boolean_value_expression ::= boolean_primary", + /* 395 */ "boolean_value_expression ::= NOT boolean_primary", + /* 396 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 397 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 398 */ "boolean_primary ::= predicate", + /* 399 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 400 */ "common_expression ::= expression", + /* 401 */ "common_expression ::= boolean_value_expression", + /* 402 */ "from_clause_opt ::=", + /* 403 */ "from_clause_opt ::= FROM table_reference_list", + /* 404 */ "table_reference_list ::= table_reference", + /* 405 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 406 */ "table_reference ::= table_primary", + /* 407 */ "table_reference ::= joined_table", + /* 408 */ "table_primary ::= table_name alias_opt", + /* 409 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 410 */ "table_primary ::= subquery alias_opt", + /* 411 */ "table_primary ::= parenthesized_joined_table", + /* 412 */ "alias_opt ::=", + /* 413 */ "alias_opt ::= table_alias", + /* 414 */ "alias_opt ::= AS table_alias", + /* 415 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 416 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 417 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 418 */ "join_type ::=", + /* 419 */ "join_type ::= INNER", + /* 420 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 421 */ "set_quantifier_opt ::=", + /* 422 */ "set_quantifier_opt ::= DISTINCT", + /* 423 */ "set_quantifier_opt ::= ALL", + /* 424 */ "select_list ::= select_item", + /* 425 */ "select_list ::= select_list NK_COMMA select_item", + /* 426 */ "select_item ::= NK_STAR", + /* 427 */ "select_item ::= common_expression", + /* 428 */ "select_item ::= common_expression column_alias", + /* 429 */ "select_item ::= common_expression AS column_alias", + /* 430 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 431 */ "where_clause_opt ::=", + /* 432 */ "where_clause_opt ::= WHERE search_condition", + /* 433 */ "partition_by_clause_opt ::=", + /* 434 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 435 */ "twindow_clause_opt ::=", + /* 436 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 437 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 438 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 439 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 440 */ "sliding_opt ::=", + /* 441 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 442 */ "fill_opt ::=", + /* 443 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 444 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 445 */ "fill_mode ::= NONE", + /* 446 */ "fill_mode ::= PREV", + /* 447 */ "fill_mode ::= NULL", + /* 448 */ "fill_mode ::= LINEAR", + /* 449 */ "fill_mode ::= NEXT", + /* 450 */ "group_by_clause_opt ::=", + /* 451 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 452 */ "group_by_list ::= expression", + /* 453 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 454 */ "having_clause_opt ::=", + /* 455 */ "having_clause_opt ::= HAVING search_condition", + /* 456 */ "range_opt ::=", + /* 457 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", + /* 458 */ "every_opt ::=", + /* 459 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 460 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 461 */ "query_expression_body ::= query_primary", + /* 462 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 463 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 464 */ "query_primary ::= query_specification", + /* 465 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 466 */ "order_by_clause_opt ::=", + /* 467 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 468 */ "slimit_clause_opt ::=", + /* 469 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 470 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 471 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 472 */ "limit_clause_opt ::=", + /* 473 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 474 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 475 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 476 */ "subquery ::= NK_LP query_expression NK_RP", + /* 477 */ "search_condition ::= common_expression", + /* 478 */ "sort_specification_list ::= sort_specification", + /* 479 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 480 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 481 */ "ordering_specification_opt ::=", + /* 482 */ "ordering_specification_opt ::= ASC", + /* 483 */ "ordering_specification_opt ::= DESC", + /* 484 */ "null_ordering_opt ::=", + /* 485 */ "null_ordering_opt ::= NULLS FIRST", + /* 486 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2221,181 +2223,181 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 253: /* cmd */ - case 256: /* literal */ - case 267: /* db_options */ - case 269: /* alter_db_options */ - case 274: /* retention */ - case 275: /* full_table_name */ - case 278: /* table_options */ - case 282: /* alter_table_clause */ - case 283: /* alter_table_options */ - case 286: /* signed_literal */ - case 287: /* create_subtable_clause */ - case 290: /* drop_table_clause */ - case 293: /* column_def */ - case 297: /* duration_literal */ - case 298: /* rollup_func_name */ - case 300: /* col_name */ - case 301: /* db_name_cond_opt */ - case 302: /* like_pattern_opt */ - case 303: /* table_name_cond */ - case 304: /* from_db_opt */ - case 306: /* index_options */ - case 308: /* sliding_opt */ - case 309: /* sma_stream_opt */ - case 310: /* func */ - case 311: /* stream_options */ - case 313: /* query_expression */ - case 316: /* explain_options */ - case 320: /* into_opt */ - case 322: /* where_clause_opt */ - case 323: /* signed */ - case 324: /* literal_func */ - case 328: /* expression */ - case 329: /* pseudo_column */ - case 330: /* column_reference */ - case 331: /* function_expression */ - case 332: /* subquery */ - case 337: /* star_func_para */ - case 338: /* predicate */ - case 341: /* in_predicate_value */ - case 342: /* boolean_value_expression */ - case 343: /* boolean_primary */ - case 344: /* common_expression */ - case 345: /* from_clause_opt */ - case 346: /* table_reference_list */ - case 347: /* table_reference */ - case 348: /* table_primary */ - case 349: /* joined_table */ - case 351: /* parenthesized_joined_table */ - case 353: /* search_condition */ - case 354: /* query_specification */ - case 358: /* range_opt */ - case 359: /* every_opt */ - case 360: /* fill_opt */ - case 361: /* twindow_clause_opt */ - case 363: /* having_clause_opt */ - case 364: /* select_item */ - case 367: /* query_expression_body */ - case 369: /* slimit_clause_opt */ - case 370: /* limit_clause_opt */ - case 371: /* query_primary */ - case 373: /* sort_specification */ + case 254: /* cmd */ + case 257: /* literal */ + case 268: /* db_options */ + case 270: /* alter_db_options */ + case 275: /* retention */ + case 276: /* full_table_name */ + case 279: /* table_options */ + case 283: /* alter_table_clause */ + case 284: /* alter_table_options */ + case 287: /* signed_literal */ + case 288: /* create_subtable_clause */ + case 291: /* drop_table_clause */ + case 294: /* column_def */ + case 298: /* duration_literal */ + case 299: /* rollup_func_name */ + case 301: /* col_name */ + case 302: /* db_name_cond_opt */ + case 303: /* like_pattern_opt */ + case 304: /* table_name_cond */ + case 305: /* from_db_opt */ + case 307: /* index_options */ + case 309: /* sliding_opt */ + case 310: /* sma_stream_opt */ + case 311: /* func */ + case 312: /* stream_options */ + case 314: /* query_expression */ + case 317: /* explain_options */ + case 321: /* into_opt */ + case 323: /* where_clause_opt */ + case 324: /* signed */ + case 325: /* literal_func */ + case 329: /* expression */ + case 330: /* pseudo_column */ + case 331: /* column_reference */ + case 332: /* function_expression */ + case 333: /* subquery */ + case 338: /* star_func_para */ + case 339: /* predicate */ + case 342: /* in_predicate_value */ + case 343: /* boolean_value_expression */ + case 344: /* boolean_primary */ + case 345: /* common_expression */ + case 346: /* from_clause_opt */ + case 347: /* table_reference_list */ + case 348: /* table_reference */ + case 349: /* table_primary */ + case 350: /* joined_table */ + case 352: /* parenthesized_joined_table */ + case 354: /* search_condition */ + case 355: /* query_specification */ + case 359: /* range_opt */ + case 360: /* every_opt */ + case 361: /* fill_opt */ + case 362: /* twindow_clause_opt */ + case 364: /* having_clause_opt */ + case 365: /* select_item */ + case 368: /* query_expression_body */ + case 370: /* slimit_clause_opt */ + case 371: /* limit_clause_opt */ + case 372: /* query_primary */ + case 374: /* sort_specification */ { - nodesDestroyNode((yypminor->yy248)); + nodesDestroyNode((yypminor->yy652)); } break; - case 254: /* account_options */ - case 255: /* alter_account_options */ - case 257: /* alter_account_option */ - case 318: /* bufsize_opt */ + case 255: /* account_options */ + case 256: /* alter_account_options */ + case 258: /* alter_account_option */ + case 319: /* bufsize_opt */ { } break; - case 258: /* user_name */ - case 261: /* priv_level */ - case 264: /* db_name */ - case 265: /* dnode_endpoint */ - case 284: /* column_name */ - case 292: /* table_name */ - case 299: /* function_name */ - case 305: /* index_name */ - case 312: /* topic_name */ - case 314: /* cgroup_name */ - case 319: /* stream_name */ - case 326: /* table_alias */ - case 327: /* column_alias */ - case 333: /* star_func */ - case 335: /* noarg_func */ - case 350: /* alias_opt */ + case 259: /* user_name */ + case 262: /* priv_level */ + case 265: /* db_name */ + case 266: /* dnode_endpoint */ + case 285: /* column_name */ + case 293: /* table_name */ + case 300: /* function_name */ + case 306: /* index_name */ + case 313: /* topic_name */ + case 315: /* cgroup_name */ + case 320: /* stream_name */ + case 327: /* table_alias */ + case 328: /* column_alias */ + case 334: /* star_func */ + case 336: /* noarg_func */ + case 351: /* alias_opt */ { } break; - case 259: /* sysinfo_opt */ + case 260: /* sysinfo_opt */ { } break; - case 260: /* privileges */ - case 262: /* priv_type_list */ - case 263: /* priv_type */ + case 261: /* privileges */ + case 263: /* priv_type_list */ + case 264: /* priv_type */ { } break; - case 266: /* not_exists_opt */ - case 268: /* exists_opt */ - case 315: /* analyze_opt */ - case 317: /* agg_func_opt */ - case 355: /* set_quantifier_opt */ + case 267: /* not_exists_opt */ + case 269: /* exists_opt */ + case 316: /* analyze_opt */ + case 318: /* agg_func_opt */ + case 356: /* set_quantifier_opt */ { } break; - case 270: /* integer_list */ - case 271: /* variable_list */ - case 272: /* retention_list */ - case 276: /* column_def_list */ - case 277: /* tags_def_opt */ - case 279: /* multi_create_clause */ - case 280: /* tags_def */ - case 281: /* multi_drop_clause */ - case 288: /* specific_cols_opt */ - case 289: /* expression_list */ - case 291: /* col_name_list */ - case 294: /* duration_list */ - case 295: /* rollup_func_list */ - case 307: /* func_list */ - case 321: /* dnode_list */ - case 325: /* literal_list */ - case 334: /* star_func_para_list */ - case 336: /* other_para_list */ - case 356: /* select_list */ - case 357: /* partition_by_clause_opt */ - case 362: /* group_by_clause_opt */ - case 366: /* group_by_list */ - case 368: /* order_by_clause_opt */ - case 372: /* sort_specification_list */ + case 271: /* integer_list */ + case 272: /* variable_list */ + case 273: /* retention_list */ + case 277: /* column_def_list */ + case 278: /* tags_def_opt */ + case 280: /* multi_create_clause */ + case 281: /* tags_def */ + case 282: /* multi_drop_clause */ + case 289: /* specific_cols_opt */ + case 290: /* expression_list */ + case 292: /* col_name_list */ + case 295: /* duration_list */ + case 296: /* rollup_func_list */ + case 308: /* func_list */ + case 322: /* dnode_list */ + case 326: /* literal_list */ + case 335: /* star_func_para_list */ + case 337: /* other_para_list */ + case 357: /* select_list */ + case 358: /* partition_by_clause_opt */ + case 363: /* group_by_clause_opt */ + case 367: /* group_by_list */ + case 369: /* order_by_clause_opt */ + case 373: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy552)); + nodesDestroyList((yypminor->yy210)); } break; - case 273: /* alter_db_option */ - case 296: /* alter_table_option */ + case 274: /* alter_db_option */ + case 297: /* alter_table_option */ { } break; - case 285: /* type_name */ + case 286: /* type_name */ { } break; - case 339: /* compare_op */ - case 340: /* in_op */ + case 340: /* compare_op */ + case 341: /* in_op */ { } break; - case 352: /* join_type */ + case 353: /* join_type */ { } break; - case 365: /* fill_mode */ + case 366: /* fill_mode */ { } break; - case 374: /* ordering_specification_opt */ + case 375: /* ordering_specification_opt */ { } break; - case 375: /* null_ordering_opt */ + case 376: /* null_ordering_opt */ { } @@ -2694,491 +2696,493 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 253, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 253, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 254, 0 }, /* (2) account_options ::= */ - { 254, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 254, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 254, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 254, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 254, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 254, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 254, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 254, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 254, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 255, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 255, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 257, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 257, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 257, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 257, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 257, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 257, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 257, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 257, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 257, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 257, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 253, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 253, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 253, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 253, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 253, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 259, 0 }, /* (29) sysinfo_opt ::= */ - { 259, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 253, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 253, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 260, -1 }, /* (33) privileges ::= ALL */ - { 260, -1 }, /* (34) privileges ::= priv_type_list */ - { 262, -1 }, /* (35) priv_type_list ::= priv_type */ - { 262, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 263, -1 }, /* (37) priv_type ::= READ */ - { 263, -1 }, /* (38) priv_type ::= WRITE */ - { 261, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 261, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 253, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 253, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 253, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ - { 253, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ - { 253, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 253, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 253, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 253, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 265, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 265, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 265, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 253, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ - { 253, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 253, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 253, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 253, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 253, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 253, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 253, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 253, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 253, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 253, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 253, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ - { 253, -2 }, /* (64) cmd ::= USE db_name */ - { 253, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 253, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ - { 266, -3 }, /* (67) not_exists_opt ::= IF NOT EXISTS */ - { 266, 0 }, /* (68) not_exists_opt ::= */ - { 268, -2 }, /* (69) exists_opt ::= IF EXISTS */ - { 268, 0 }, /* (70) exists_opt ::= */ - { 267, 0 }, /* (71) db_options ::= */ - { 267, -3 }, /* (72) db_options ::= db_options BUFFER NK_INTEGER */ - { 267, -3 }, /* (73) db_options ::= db_options CACHELAST NK_INTEGER */ - { 267, -3 }, /* (74) db_options ::= db_options COMP NK_INTEGER */ - { 267, -3 }, /* (75) db_options ::= db_options DURATION NK_INTEGER */ - { 267, -3 }, /* (76) db_options ::= db_options DURATION NK_VARIABLE */ - { 267, -3 }, /* (77) db_options ::= db_options FSYNC NK_INTEGER */ - { 267, -3 }, /* (78) db_options ::= db_options MAXROWS NK_INTEGER */ - { 267, -3 }, /* (79) db_options ::= db_options MINROWS NK_INTEGER */ - { 267, -3 }, /* (80) db_options ::= db_options KEEP integer_list */ - { 267, -3 }, /* (81) db_options ::= db_options KEEP variable_list */ - { 267, -3 }, /* (82) db_options ::= db_options PAGES NK_INTEGER */ - { 267, -3 }, /* (83) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 267, -3 }, /* (84) db_options ::= db_options PRECISION NK_STRING */ - { 267, -3 }, /* (85) db_options ::= db_options REPLICA NK_INTEGER */ - { 267, -3 }, /* (86) db_options ::= db_options STRICT NK_INTEGER */ - { 267, -3 }, /* (87) db_options ::= db_options WAL NK_INTEGER */ - { 267, -3 }, /* (88) db_options ::= db_options VGROUPS NK_INTEGER */ - { 267, -3 }, /* (89) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 267, -3 }, /* (90) db_options ::= db_options RETENTIONS retention_list */ - { 267, -3 }, /* (91) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 269, -1 }, /* (92) alter_db_options ::= alter_db_option */ - { 269, -2 }, /* (93) alter_db_options ::= alter_db_options alter_db_option */ - { 273, -2 }, /* (94) alter_db_option ::= BUFFER NK_INTEGER */ - { 273, -2 }, /* (95) alter_db_option ::= CACHELAST NK_INTEGER */ - { 273, -2 }, /* (96) alter_db_option ::= FSYNC NK_INTEGER */ - { 273, -2 }, /* (97) alter_db_option ::= KEEP integer_list */ - { 273, -2 }, /* (98) alter_db_option ::= KEEP variable_list */ - { 273, -2 }, /* (99) alter_db_option ::= PAGES NK_INTEGER */ - { 273, -2 }, /* (100) alter_db_option ::= REPLICA NK_INTEGER */ - { 273, -2 }, /* (101) alter_db_option ::= STRICT NK_INTEGER */ - { 273, -2 }, /* (102) alter_db_option ::= WAL NK_INTEGER */ - { 270, -1 }, /* (103) integer_list ::= NK_INTEGER */ - { 270, -3 }, /* (104) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 271, -1 }, /* (105) variable_list ::= NK_VARIABLE */ - { 271, -3 }, /* (106) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 272, -1 }, /* (107) retention_list ::= retention */ - { 272, -3 }, /* (108) retention_list ::= retention_list NK_COMMA retention */ - { 274, -3 }, /* (109) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 253, -9 }, /* (110) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 253, -3 }, /* (111) cmd ::= CREATE TABLE multi_create_clause */ - { 253, -9 }, /* (112) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 253, -3 }, /* (113) cmd ::= DROP TABLE multi_drop_clause */ - { 253, -4 }, /* (114) cmd ::= DROP STABLE exists_opt full_table_name */ - { 253, -3 }, /* (115) cmd ::= ALTER TABLE alter_table_clause */ - { 253, -3 }, /* (116) cmd ::= ALTER STABLE alter_table_clause */ - { 282, -2 }, /* (117) alter_table_clause ::= full_table_name alter_table_options */ - { 282, -5 }, /* (118) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 282, -4 }, /* (119) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 282, -5 }, /* (120) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 282, -5 }, /* (121) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 282, -5 }, /* (122) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 282, -4 }, /* (123) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 282, -5 }, /* (124) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 282, -5 }, /* (125) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 282, -6 }, /* (126) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 279, -1 }, /* (127) multi_create_clause ::= create_subtable_clause */ - { 279, -2 }, /* (128) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 287, -10 }, /* (129) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ - { 281, -1 }, /* (130) multi_drop_clause ::= drop_table_clause */ - { 281, -2 }, /* (131) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 290, -2 }, /* (132) drop_table_clause ::= exists_opt full_table_name */ - { 288, 0 }, /* (133) specific_cols_opt ::= */ - { 288, -3 }, /* (134) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - { 275, -1 }, /* (135) full_table_name ::= table_name */ - { 275, -3 }, /* (136) full_table_name ::= db_name NK_DOT table_name */ - { 276, -1 }, /* (137) column_def_list ::= column_def */ - { 276, -3 }, /* (138) column_def_list ::= column_def_list NK_COMMA column_def */ - { 293, -2 }, /* (139) column_def ::= column_name type_name */ - { 293, -4 }, /* (140) column_def ::= column_name type_name COMMENT NK_STRING */ - { 285, -1 }, /* (141) type_name ::= BOOL */ - { 285, -1 }, /* (142) type_name ::= TINYINT */ - { 285, -1 }, /* (143) type_name ::= SMALLINT */ - { 285, -1 }, /* (144) type_name ::= INT */ - { 285, -1 }, /* (145) type_name ::= INTEGER */ - { 285, -1 }, /* (146) type_name ::= BIGINT */ - { 285, -1 }, /* (147) type_name ::= FLOAT */ - { 285, -1 }, /* (148) type_name ::= DOUBLE */ - { 285, -4 }, /* (149) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 285, -1 }, /* (150) type_name ::= TIMESTAMP */ - { 285, -4 }, /* (151) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 285, -2 }, /* (152) type_name ::= TINYINT UNSIGNED */ - { 285, -2 }, /* (153) type_name ::= SMALLINT UNSIGNED */ - { 285, -2 }, /* (154) type_name ::= INT UNSIGNED */ - { 285, -2 }, /* (155) type_name ::= BIGINT UNSIGNED */ - { 285, -1 }, /* (156) type_name ::= JSON */ - { 285, -4 }, /* (157) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 285, -1 }, /* (158) type_name ::= MEDIUMBLOB */ - { 285, -1 }, /* (159) type_name ::= BLOB */ - { 285, -4 }, /* (160) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 285, -1 }, /* (161) type_name ::= DECIMAL */ - { 285, -4 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 285, -6 }, /* (163) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 277, 0 }, /* (164) tags_def_opt ::= */ - { 277, -1 }, /* (165) tags_def_opt ::= tags_def */ - { 280, -4 }, /* (166) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 278, 0 }, /* (167) table_options ::= */ - { 278, -3 }, /* (168) table_options ::= table_options COMMENT NK_STRING */ - { 278, -3 }, /* (169) table_options ::= table_options MAX_DELAY duration_list */ - { 278, -3 }, /* (170) table_options ::= table_options WATERMARK duration_list */ - { 278, -5 }, /* (171) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 278, -3 }, /* (172) table_options ::= table_options TTL NK_INTEGER */ - { 278, -5 }, /* (173) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 283, -1 }, /* (174) alter_table_options ::= alter_table_option */ - { 283, -2 }, /* (175) alter_table_options ::= alter_table_options alter_table_option */ - { 296, -2 }, /* (176) alter_table_option ::= COMMENT NK_STRING */ - { 296, -2 }, /* (177) alter_table_option ::= TTL NK_INTEGER */ - { 294, -1 }, /* (178) duration_list ::= duration_literal */ - { 294, -3 }, /* (179) duration_list ::= duration_list NK_COMMA duration_literal */ - { 295, -1 }, /* (180) rollup_func_list ::= rollup_func_name */ - { 295, -3 }, /* (181) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 298, -1 }, /* (182) rollup_func_name ::= function_name */ - { 298, -1 }, /* (183) rollup_func_name ::= FIRST */ - { 298, -1 }, /* (184) rollup_func_name ::= LAST */ - { 291, -1 }, /* (185) col_name_list ::= col_name */ - { 291, -3 }, /* (186) col_name_list ::= col_name_list NK_COMMA col_name */ - { 300, -1 }, /* (187) col_name ::= column_name */ - { 253, -2 }, /* (188) cmd ::= SHOW DNODES */ - { 253, -2 }, /* (189) cmd ::= SHOW USERS */ - { 253, -2 }, /* (190) cmd ::= SHOW DATABASES */ - { 253, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 253, -4 }, /* (192) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 253, -3 }, /* (193) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 253, -2 }, /* (194) cmd ::= SHOW MNODES */ - { 253, -2 }, /* (195) cmd ::= SHOW MODULES */ - { 253, -2 }, /* (196) cmd ::= SHOW QNODES */ - { 253, -2 }, /* (197) cmd ::= SHOW FUNCTIONS */ - { 253, -5 }, /* (198) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 253, -2 }, /* (199) cmd ::= SHOW STREAMS */ - { 253, -2 }, /* (200) cmd ::= SHOW ACCOUNTS */ - { 253, -2 }, /* (201) cmd ::= SHOW APPS */ - { 253, -2 }, /* (202) cmd ::= SHOW CONNECTIONS */ - { 253, -2 }, /* (203) cmd ::= SHOW LICENCE */ - { 253, -2 }, /* (204) cmd ::= SHOW GRANTS */ - { 253, -4 }, /* (205) cmd ::= SHOW CREATE DATABASE db_name */ - { 253, -4 }, /* (206) cmd ::= SHOW CREATE TABLE full_table_name */ - { 253, -4 }, /* (207) cmd ::= SHOW CREATE STABLE full_table_name */ - { 253, -2 }, /* (208) cmd ::= SHOW QUERIES */ - { 253, -2 }, /* (209) cmd ::= SHOW SCORES */ - { 253, -2 }, /* (210) cmd ::= SHOW TOPICS */ - { 253, -2 }, /* (211) cmd ::= SHOW VARIABLES */ - { 253, -3 }, /* (212) cmd ::= SHOW LOCAL VARIABLES */ - { 253, -4 }, /* (213) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 253, -2 }, /* (214) cmd ::= SHOW BNODES */ - { 253, -2 }, /* (215) cmd ::= SHOW SNODES */ - { 253, -2 }, /* (216) cmd ::= SHOW CLUSTER */ - { 253, -2 }, /* (217) cmd ::= SHOW TRANSACTIONS */ - { 253, -4 }, /* (218) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 253, -2 }, /* (219) cmd ::= SHOW CONSUMERS */ - { 253, -2 }, /* (220) cmd ::= SHOW SUBSCRIPTIONS */ - { 301, 0 }, /* (221) db_name_cond_opt ::= */ - { 301, -2 }, /* (222) db_name_cond_opt ::= db_name NK_DOT */ - { 302, 0 }, /* (223) like_pattern_opt ::= */ - { 302, -2 }, /* (224) like_pattern_opt ::= LIKE NK_STRING */ - { 303, -1 }, /* (225) table_name_cond ::= table_name */ - { 304, 0 }, /* (226) from_db_opt ::= */ - { 304, -2 }, /* (227) from_db_opt ::= FROM db_name */ - { 253, -8 }, /* (228) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 253, -4 }, /* (229) cmd ::= DROP INDEX exists_opt index_name */ - { 306, -10 }, /* (230) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 306, -12 }, /* (231) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - { 307, -1 }, /* (232) func_list ::= func */ - { 307, -3 }, /* (233) func_list ::= func_list NK_COMMA func */ - { 310, -4 }, /* (234) func ::= function_name NK_LP expression_list NK_RP */ - { 309, 0 }, /* (235) sma_stream_opt ::= */ - { 309, -3 }, /* (236) sma_stream_opt ::= stream_options WATERMARK duration_literal */ - { 309, -3 }, /* (237) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ - { 253, -6 }, /* (238) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 253, -7 }, /* (239) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 253, -9 }, /* (240) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 253, -7 }, /* (241) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 253, -9 }, /* (242) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 253, -4 }, /* (243) cmd ::= DROP TOPIC exists_opt topic_name */ - { 253, -7 }, /* (244) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 253, -2 }, /* (245) cmd ::= DESC full_table_name */ - { 253, -2 }, /* (246) cmd ::= DESCRIBE full_table_name */ - { 253, -3 }, /* (247) cmd ::= RESET QUERY CACHE */ - { 253, -4 }, /* (248) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 315, 0 }, /* (249) analyze_opt ::= */ - { 315, -1 }, /* (250) analyze_opt ::= ANALYZE */ - { 316, 0 }, /* (251) explain_options ::= */ - { 316, -3 }, /* (252) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 316, -3 }, /* (253) explain_options ::= explain_options RATIO NK_FLOAT */ - { 253, -6 }, /* (254) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 253, -10 }, /* (255) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 253, -4 }, /* (256) cmd ::= DROP FUNCTION exists_opt function_name */ - { 317, 0 }, /* (257) agg_func_opt ::= */ - { 317, -1 }, /* (258) agg_func_opt ::= AGGREGATE */ - { 318, 0 }, /* (259) bufsize_opt ::= */ - { 318, -2 }, /* (260) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 253, -8 }, /* (261) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 253, -4 }, /* (262) cmd ::= DROP STREAM exists_opt stream_name */ - { 320, 0 }, /* (263) into_opt ::= */ - { 320, -2 }, /* (264) into_opt ::= INTO full_table_name */ - { 311, 0 }, /* (265) stream_options ::= */ - { 311, -3 }, /* (266) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 311, -3 }, /* (267) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 311, -4 }, /* (268) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 311, -3 }, /* (269) stream_options ::= stream_options WATERMARK duration_literal */ - { 311, -3 }, /* (270) stream_options ::= stream_options IGNORE EXPIRED */ - { 253, -3 }, /* (271) cmd ::= KILL CONNECTION NK_INTEGER */ - { 253, -3 }, /* (272) cmd ::= KILL QUERY NK_STRING */ - { 253, -3 }, /* (273) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 253, -2 }, /* (274) cmd ::= BALANCE VGROUP */ - { 253, -4 }, /* (275) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 253, -4 }, /* (276) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 253, -3 }, /* (277) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 321, -2 }, /* (278) dnode_list ::= DNODE NK_INTEGER */ - { 321, -3 }, /* (279) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 253, -3 }, /* (280) cmd ::= SYNCDB db_name REPLICA */ - { 253, -4 }, /* (281) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 253, -1 }, /* (282) cmd ::= query_expression */ - { 253, -5 }, /* (283) cmd ::= INSERT INTO full_table_name specific_cols_opt query_expression */ - { 256, -1 }, /* (284) literal ::= NK_INTEGER */ - { 256, -1 }, /* (285) literal ::= NK_FLOAT */ - { 256, -1 }, /* (286) literal ::= NK_STRING */ - { 256, -1 }, /* (287) literal ::= NK_BOOL */ - { 256, -2 }, /* (288) literal ::= TIMESTAMP NK_STRING */ - { 256, -1 }, /* (289) literal ::= duration_literal */ - { 256, -1 }, /* (290) literal ::= NULL */ - { 256, -1 }, /* (291) literal ::= NK_QUESTION */ - { 297, -1 }, /* (292) duration_literal ::= NK_VARIABLE */ - { 323, -1 }, /* (293) signed ::= NK_INTEGER */ - { 323, -2 }, /* (294) signed ::= NK_PLUS NK_INTEGER */ - { 323, -2 }, /* (295) signed ::= NK_MINUS NK_INTEGER */ - { 323, -1 }, /* (296) signed ::= NK_FLOAT */ - { 323, -2 }, /* (297) signed ::= NK_PLUS NK_FLOAT */ - { 323, -2 }, /* (298) signed ::= NK_MINUS NK_FLOAT */ - { 286, -1 }, /* (299) signed_literal ::= signed */ - { 286, -1 }, /* (300) signed_literal ::= NK_STRING */ - { 286, -1 }, /* (301) signed_literal ::= NK_BOOL */ - { 286, -2 }, /* (302) signed_literal ::= TIMESTAMP NK_STRING */ - { 286, -1 }, /* (303) signed_literal ::= duration_literal */ - { 286, -1 }, /* (304) signed_literal ::= NULL */ - { 286, -1 }, /* (305) signed_literal ::= literal_func */ - { 325, -1 }, /* (306) literal_list ::= signed_literal */ - { 325, -3 }, /* (307) literal_list ::= literal_list NK_COMMA signed_literal */ - { 264, -1 }, /* (308) db_name ::= NK_ID */ - { 292, -1 }, /* (309) table_name ::= NK_ID */ - { 284, -1 }, /* (310) column_name ::= NK_ID */ - { 299, -1 }, /* (311) function_name ::= NK_ID */ - { 326, -1 }, /* (312) table_alias ::= NK_ID */ - { 327, -1 }, /* (313) column_alias ::= NK_ID */ - { 258, -1 }, /* (314) user_name ::= NK_ID */ - { 305, -1 }, /* (315) index_name ::= NK_ID */ - { 312, -1 }, /* (316) topic_name ::= NK_ID */ - { 319, -1 }, /* (317) stream_name ::= NK_ID */ - { 314, -1 }, /* (318) cgroup_name ::= NK_ID */ - { 328, -1 }, /* (319) expression ::= literal */ - { 328, -1 }, /* (320) expression ::= pseudo_column */ - { 328, -1 }, /* (321) expression ::= column_reference */ - { 328, -1 }, /* (322) expression ::= function_expression */ - { 328, -1 }, /* (323) expression ::= subquery */ - { 328, -3 }, /* (324) expression ::= NK_LP expression NK_RP */ - { 328, -2 }, /* (325) expression ::= NK_PLUS expression */ - { 328, -2 }, /* (326) expression ::= NK_MINUS expression */ - { 328, -3 }, /* (327) expression ::= expression NK_PLUS expression */ - { 328, -3 }, /* (328) expression ::= expression NK_MINUS expression */ - { 328, -3 }, /* (329) expression ::= expression NK_STAR expression */ - { 328, -3 }, /* (330) expression ::= expression NK_SLASH expression */ - { 328, -3 }, /* (331) expression ::= expression NK_REM expression */ - { 328, -3 }, /* (332) expression ::= column_reference NK_ARROW NK_STRING */ - { 328, -3 }, /* (333) expression ::= expression NK_BITAND expression */ - { 328, -3 }, /* (334) expression ::= expression NK_BITOR expression */ - { 289, -1 }, /* (335) expression_list ::= expression */ - { 289, -3 }, /* (336) expression_list ::= expression_list NK_COMMA expression */ - { 330, -1 }, /* (337) column_reference ::= column_name */ - { 330, -3 }, /* (338) column_reference ::= table_name NK_DOT column_name */ - { 329, -1 }, /* (339) pseudo_column ::= ROWTS */ - { 329, -1 }, /* (340) pseudo_column ::= TBNAME */ - { 329, -3 }, /* (341) pseudo_column ::= table_name NK_DOT TBNAME */ - { 329, -1 }, /* (342) pseudo_column ::= QSTARTTS */ - { 329, -1 }, /* (343) pseudo_column ::= QENDTS */ - { 329, -1 }, /* (344) pseudo_column ::= WSTARTTS */ - { 329, -1 }, /* (345) pseudo_column ::= WENDTS */ - { 329, -1 }, /* (346) pseudo_column ::= WDURATION */ - { 331, -4 }, /* (347) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 331, -4 }, /* (348) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 331, -6 }, /* (349) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 331, -1 }, /* (350) function_expression ::= literal_func */ - { 324, -3 }, /* (351) literal_func ::= noarg_func NK_LP NK_RP */ - { 324, -1 }, /* (352) literal_func ::= NOW */ - { 335, -1 }, /* (353) noarg_func ::= NOW */ - { 335, -1 }, /* (354) noarg_func ::= TODAY */ - { 335, -1 }, /* (355) noarg_func ::= TIMEZONE */ - { 335, -1 }, /* (356) noarg_func ::= DATABASE */ - { 335, -1 }, /* (357) noarg_func ::= CLIENT_VERSION */ - { 335, -1 }, /* (358) noarg_func ::= SERVER_VERSION */ - { 335, -1 }, /* (359) noarg_func ::= SERVER_STATUS */ - { 335, -1 }, /* (360) noarg_func ::= CURRENT_USER */ - { 335, -1 }, /* (361) noarg_func ::= USER */ - { 333, -1 }, /* (362) star_func ::= COUNT */ - { 333, -1 }, /* (363) star_func ::= FIRST */ - { 333, -1 }, /* (364) star_func ::= LAST */ - { 333, -1 }, /* (365) star_func ::= LAST_ROW */ - { 334, -1 }, /* (366) star_func_para_list ::= NK_STAR */ - { 334, -1 }, /* (367) star_func_para_list ::= other_para_list */ - { 336, -1 }, /* (368) other_para_list ::= star_func_para */ - { 336, -3 }, /* (369) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 337, -1 }, /* (370) star_func_para ::= expression */ - { 337, -3 }, /* (371) star_func_para ::= table_name NK_DOT NK_STAR */ - { 338, -3 }, /* (372) predicate ::= expression compare_op expression */ - { 338, -5 }, /* (373) predicate ::= expression BETWEEN expression AND expression */ - { 338, -6 }, /* (374) predicate ::= expression NOT BETWEEN expression AND expression */ - { 338, -3 }, /* (375) predicate ::= expression IS NULL */ - { 338, -4 }, /* (376) predicate ::= expression IS NOT NULL */ - { 338, -3 }, /* (377) predicate ::= expression in_op in_predicate_value */ - { 339, -1 }, /* (378) compare_op ::= NK_LT */ - { 339, -1 }, /* (379) compare_op ::= NK_GT */ - { 339, -1 }, /* (380) compare_op ::= NK_LE */ - { 339, -1 }, /* (381) compare_op ::= NK_GE */ - { 339, -1 }, /* (382) compare_op ::= NK_NE */ - { 339, -1 }, /* (383) compare_op ::= NK_EQ */ - { 339, -1 }, /* (384) compare_op ::= LIKE */ - { 339, -2 }, /* (385) compare_op ::= NOT LIKE */ - { 339, -1 }, /* (386) compare_op ::= MATCH */ - { 339, -1 }, /* (387) compare_op ::= NMATCH */ - { 339, -1 }, /* (388) compare_op ::= CONTAINS */ - { 340, -1 }, /* (389) in_op ::= IN */ - { 340, -2 }, /* (390) in_op ::= NOT IN */ - { 341, -3 }, /* (391) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 342, -1 }, /* (392) boolean_value_expression ::= boolean_primary */ - { 342, -2 }, /* (393) boolean_value_expression ::= NOT boolean_primary */ - { 342, -3 }, /* (394) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 342, -3 }, /* (395) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 343, -1 }, /* (396) boolean_primary ::= predicate */ - { 343, -3 }, /* (397) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 344, -1 }, /* (398) common_expression ::= expression */ - { 344, -1 }, /* (399) common_expression ::= boolean_value_expression */ - { 345, 0 }, /* (400) from_clause_opt ::= */ - { 345, -2 }, /* (401) from_clause_opt ::= FROM table_reference_list */ - { 346, -1 }, /* (402) table_reference_list ::= table_reference */ - { 346, -3 }, /* (403) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 347, -1 }, /* (404) table_reference ::= table_primary */ - { 347, -1 }, /* (405) table_reference ::= joined_table */ - { 348, -2 }, /* (406) table_primary ::= table_name alias_opt */ - { 348, -4 }, /* (407) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 348, -2 }, /* (408) table_primary ::= subquery alias_opt */ - { 348, -1 }, /* (409) table_primary ::= parenthesized_joined_table */ - { 350, 0 }, /* (410) alias_opt ::= */ - { 350, -1 }, /* (411) alias_opt ::= table_alias */ - { 350, -2 }, /* (412) alias_opt ::= AS table_alias */ - { 351, -3 }, /* (413) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 351, -3 }, /* (414) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 349, -6 }, /* (415) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 352, 0 }, /* (416) join_type ::= */ - { 352, -1 }, /* (417) join_type ::= INNER */ - { 354, -12 }, /* (418) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 355, 0 }, /* (419) set_quantifier_opt ::= */ - { 355, -1 }, /* (420) set_quantifier_opt ::= DISTINCT */ - { 355, -1 }, /* (421) set_quantifier_opt ::= ALL */ - { 356, -1 }, /* (422) select_list ::= select_item */ - { 356, -3 }, /* (423) select_list ::= select_list NK_COMMA select_item */ - { 364, -1 }, /* (424) select_item ::= NK_STAR */ - { 364, -1 }, /* (425) select_item ::= common_expression */ - { 364, -2 }, /* (426) select_item ::= common_expression column_alias */ - { 364, -3 }, /* (427) select_item ::= common_expression AS column_alias */ - { 364, -3 }, /* (428) select_item ::= table_name NK_DOT NK_STAR */ - { 322, 0 }, /* (429) where_clause_opt ::= */ - { 322, -2 }, /* (430) where_clause_opt ::= WHERE search_condition */ - { 357, 0 }, /* (431) partition_by_clause_opt ::= */ - { 357, -3 }, /* (432) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 361, 0 }, /* (433) twindow_clause_opt ::= */ - { 361, -6 }, /* (434) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 361, -4 }, /* (435) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 361, -6 }, /* (436) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 361, -8 }, /* (437) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 308, 0 }, /* (438) sliding_opt ::= */ - { 308, -4 }, /* (439) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 360, 0 }, /* (440) fill_opt ::= */ - { 360, -4 }, /* (441) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 360, -6 }, /* (442) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 365, -1 }, /* (443) fill_mode ::= NONE */ - { 365, -1 }, /* (444) fill_mode ::= PREV */ - { 365, -1 }, /* (445) fill_mode ::= NULL */ - { 365, -1 }, /* (446) fill_mode ::= LINEAR */ - { 365, -1 }, /* (447) fill_mode ::= NEXT */ - { 362, 0 }, /* (448) group_by_clause_opt ::= */ - { 362, -3 }, /* (449) group_by_clause_opt ::= GROUP BY group_by_list */ - { 366, -1 }, /* (450) group_by_list ::= expression */ - { 366, -3 }, /* (451) group_by_list ::= group_by_list NK_COMMA expression */ - { 363, 0 }, /* (452) having_clause_opt ::= */ - { 363, -2 }, /* (453) having_clause_opt ::= HAVING search_condition */ - { 358, 0 }, /* (454) range_opt ::= */ - { 358, -6 }, /* (455) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 359, 0 }, /* (456) every_opt ::= */ - { 359, -4 }, /* (457) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 313, -4 }, /* (458) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 367, -1 }, /* (459) query_expression_body ::= query_primary */ - { 367, -4 }, /* (460) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 367, -3 }, /* (461) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 371, -1 }, /* (462) query_primary ::= query_specification */ - { 371, -6 }, /* (463) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 368, 0 }, /* (464) order_by_clause_opt ::= */ - { 368, -3 }, /* (465) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 369, 0 }, /* (466) slimit_clause_opt ::= */ - { 369, -2 }, /* (467) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 369, -4 }, /* (468) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 369, -4 }, /* (469) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 370, 0 }, /* (470) limit_clause_opt ::= */ - { 370, -2 }, /* (471) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 370, -4 }, /* (472) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 370, -4 }, /* (473) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 332, -3 }, /* (474) subquery ::= NK_LP query_expression NK_RP */ - { 353, -1 }, /* (475) search_condition ::= common_expression */ - { 372, -1 }, /* (476) sort_specification_list ::= sort_specification */ - { 372, -3 }, /* (477) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 373, -3 }, /* (478) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 374, 0 }, /* (479) ordering_specification_opt ::= */ - { 374, -1 }, /* (480) ordering_specification_opt ::= ASC */ - { 374, -1 }, /* (481) ordering_specification_opt ::= DESC */ - { 375, 0 }, /* (482) null_ordering_opt ::= */ - { 375, -2 }, /* (483) null_ordering_opt ::= NULLS FIRST */ - { 375, -2 }, /* (484) null_ordering_opt ::= NULLS LAST */ + { 254, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 254, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 255, 0 }, /* (2) account_options ::= */ + { 255, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 255, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 255, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 255, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 255, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 255, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 255, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 255, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 255, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 256, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 256, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 258, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 258, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 258, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 258, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 258, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 258, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 258, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 258, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 258, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 258, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 254, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 254, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 254, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 254, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 254, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 260, 0 }, /* (29) sysinfo_opt ::= */ + { 260, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 254, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 254, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 261, -1 }, /* (33) privileges ::= ALL */ + { 261, -1 }, /* (34) privileges ::= priv_type_list */ + { 263, -1 }, /* (35) priv_type_list ::= priv_type */ + { 263, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 264, -1 }, /* (37) priv_type ::= READ */ + { 264, -1 }, /* (38) priv_type ::= WRITE */ + { 262, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 262, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 254, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 254, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 254, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 254, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 254, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 254, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 254, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 254, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 266, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 266, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 266, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 254, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 254, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 254, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 254, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 254, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 254, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 254, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 254, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 254, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 254, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 254, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 254, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 254, -2 }, /* (64) cmd ::= USE db_name */ + { 254, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 254, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ + { 267, -3 }, /* (67) not_exists_opt ::= IF NOT EXISTS */ + { 267, 0 }, /* (68) not_exists_opt ::= */ + { 269, -2 }, /* (69) exists_opt ::= IF EXISTS */ + { 269, 0 }, /* (70) exists_opt ::= */ + { 268, 0 }, /* (71) db_options ::= */ + { 268, -3 }, /* (72) db_options ::= db_options BUFFER NK_INTEGER */ + { 268, -3 }, /* (73) db_options ::= db_options CACHELAST NK_INTEGER */ + { 268, -3 }, /* (74) db_options ::= db_options CACHELASTSIZE NK_INTEGER */ + { 268, -3 }, /* (75) db_options ::= db_options COMP NK_INTEGER */ + { 268, -3 }, /* (76) db_options ::= db_options DURATION NK_INTEGER */ + { 268, -3 }, /* (77) db_options ::= db_options DURATION NK_VARIABLE */ + { 268, -3 }, /* (78) db_options ::= db_options FSYNC NK_INTEGER */ + { 268, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */ + { 268, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */ + { 268, -3 }, /* (81) db_options ::= db_options KEEP integer_list */ + { 268, -3 }, /* (82) db_options ::= db_options KEEP variable_list */ + { 268, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */ + { 268, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 268, -3 }, /* (85) db_options ::= db_options PRECISION NK_STRING */ + { 268, -3 }, /* (86) db_options ::= db_options REPLICA NK_INTEGER */ + { 268, -3 }, /* (87) db_options ::= db_options STRICT NK_INTEGER */ + { 268, -3 }, /* (88) db_options ::= db_options WAL NK_INTEGER */ + { 268, -3 }, /* (89) db_options ::= db_options VGROUPS NK_INTEGER */ + { 268, -3 }, /* (90) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 268, -3 }, /* (91) db_options ::= db_options RETENTIONS retention_list */ + { 268, -3 }, /* (92) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 270, -1 }, /* (93) alter_db_options ::= alter_db_option */ + { 270, -2 }, /* (94) alter_db_options ::= alter_db_options alter_db_option */ + { 274, -2 }, /* (95) alter_db_option ::= BUFFER NK_INTEGER */ + { 274, -2 }, /* (96) alter_db_option ::= CACHELAST NK_INTEGER */ + { 274, -2 }, /* (97) alter_db_option ::= CACHELASTSIZE NK_INTEGER */ + { 274, -2 }, /* (98) alter_db_option ::= FSYNC NK_INTEGER */ + { 274, -2 }, /* (99) alter_db_option ::= KEEP integer_list */ + { 274, -2 }, /* (100) alter_db_option ::= KEEP variable_list */ + { 274, -2 }, /* (101) alter_db_option ::= PAGES NK_INTEGER */ + { 274, -2 }, /* (102) alter_db_option ::= REPLICA NK_INTEGER */ + { 274, -2 }, /* (103) alter_db_option ::= STRICT NK_INTEGER */ + { 274, -2 }, /* (104) alter_db_option ::= WAL NK_INTEGER */ + { 271, -1 }, /* (105) integer_list ::= NK_INTEGER */ + { 271, -3 }, /* (106) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 272, -1 }, /* (107) variable_list ::= NK_VARIABLE */ + { 272, -3 }, /* (108) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 273, -1 }, /* (109) retention_list ::= retention */ + { 273, -3 }, /* (110) retention_list ::= retention_list NK_COMMA retention */ + { 275, -3 }, /* (111) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 254, -9 }, /* (112) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 254, -3 }, /* (113) cmd ::= CREATE TABLE multi_create_clause */ + { 254, -9 }, /* (114) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 254, -3 }, /* (115) cmd ::= DROP TABLE multi_drop_clause */ + { 254, -4 }, /* (116) cmd ::= DROP STABLE exists_opt full_table_name */ + { 254, -3 }, /* (117) cmd ::= ALTER TABLE alter_table_clause */ + { 254, -3 }, /* (118) cmd ::= ALTER STABLE alter_table_clause */ + { 283, -2 }, /* (119) alter_table_clause ::= full_table_name alter_table_options */ + { 283, -5 }, /* (120) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 283, -4 }, /* (121) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 283, -5 }, /* (122) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 283, -5 }, /* (123) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 283, -5 }, /* (124) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 283, -4 }, /* (125) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 283, -5 }, /* (126) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 283, -5 }, /* (127) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 283, -6 }, /* (128) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 280, -1 }, /* (129) multi_create_clause ::= create_subtable_clause */ + { 280, -2 }, /* (130) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 288, -10 }, /* (131) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ + { 282, -1 }, /* (132) multi_drop_clause ::= drop_table_clause */ + { 282, -2 }, /* (133) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 291, -2 }, /* (134) drop_table_clause ::= exists_opt full_table_name */ + { 289, 0 }, /* (135) specific_cols_opt ::= */ + { 289, -3 }, /* (136) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 276, -1 }, /* (137) full_table_name ::= table_name */ + { 276, -3 }, /* (138) full_table_name ::= db_name NK_DOT table_name */ + { 277, -1 }, /* (139) column_def_list ::= column_def */ + { 277, -3 }, /* (140) column_def_list ::= column_def_list NK_COMMA column_def */ + { 294, -2 }, /* (141) column_def ::= column_name type_name */ + { 294, -4 }, /* (142) column_def ::= column_name type_name COMMENT NK_STRING */ + { 286, -1 }, /* (143) type_name ::= BOOL */ + { 286, -1 }, /* (144) type_name ::= TINYINT */ + { 286, -1 }, /* (145) type_name ::= SMALLINT */ + { 286, -1 }, /* (146) type_name ::= INT */ + { 286, -1 }, /* (147) type_name ::= INTEGER */ + { 286, -1 }, /* (148) type_name ::= BIGINT */ + { 286, -1 }, /* (149) type_name ::= FLOAT */ + { 286, -1 }, /* (150) type_name ::= DOUBLE */ + { 286, -4 }, /* (151) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 286, -1 }, /* (152) type_name ::= TIMESTAMP */ + { 286, -4 }, /* (153) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 286, -2 }, /* (154) type_name ::= TINYINT UNSIGNED */ + { 286, -2 }, /* (155) type_name ::= SMALLINT UNSIGNED */ + { 286, -2 }, /* (156) type_name ::= INT UNSIGNED */ + { 286, -2 }, /* (157) type_name ::= BIGINT UNSIGNED */ + { 286, -1 }, /* (158) type_name ::= JSON */ + { 286, -4 }, /* (159) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 286, -1 }, /* (160) type_name ::= MEDIUMBLOB */ + { 286, -1 }, /* (161) type_name ::= BLOB */ + { 286, -4 }, /* (162) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 286, -1 }, /* (163) type_name ::= DECIMAL */ + { 286, -4 }, /* (164) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 286, -6 }, /* (165) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 278, 0 }, /* (166) tags_def_opt ::= */ + { 278, -1 }, /* (167) tags_def_opt ::= tags_def */ + { 281, -4 }, /* (168) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 279, 0 }, /* (169) table_options ::= */ + { 279, -3 }, /* (170) table_options ::= table_options COMMENT NK_STRING */ + { 279, -3 }, /* (171) table_options ::= table_options MAX_DELAY duration_list */ + { 279, -3 }, /* (172) table_options ::= table_options WATERMARK duration_list */ + { 279, -5 }, /* (173) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 279, -3 }, /* (174) table_options ::= table_options TTL NK_INTEGER */ + { 279, -5 }, /* (175) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 284, -1 }, /* (176) alter_table_options ::= alter_table_option */ + { 284, -2 }, /* (177) alter_table_options ::= alter_table_options alter_table_option */ + { 297, -2 }, /* (178) alter_table_option ::= COMMENT NK_STRING */ + { 297, -2 }, /* (179) alter_table_option ::= TTL NK_INTEGER */ + { 295, -1 }, /* (180) duration_list ::= duration_literal */ + { 295, -3 }, /* (181) duration_list ::= duration_list NK_COMMA duration_literal */ + { 296, -1 }, /* (182) rollup_func_list ::= rollup_func_name */ + { 296, -3 }, /* (183) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 299, -1 }, /* (184) rollup_func_name ::= function_name */ + { 299, -1 }, /* (185) rollup_func_name ::= FIRST */ + { 299, -1 }, /* (186) rollup_func_name ::= LAST */ + { 292, -1 }, /* (187) col_name_list ::= col_name */ + { 292, -3 }, /* (188) col_name_list ::= col_name_list NK_COMMA col_name */ + { 301, -1 }, /* (189) col_name ::= column_name */ + { 254, -2 }, /* (190) cmd ::= SHOW DNODES */ + { 254, -2 }, /* (191) cmd ::= SHOW USERS */ + { 254, -2 }, /* (192) cmd ::= SHOW DATABASES */ + { 254, -4 }, /* (193) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 254, -4 }, /* (194) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 254, -3 }, /* (195) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 254, -2 }, /* (196) cmd ::= SHOW MNODES */ + { 254, -2 }, /* (197) cmd ::= SHOW MODULES */ + { 254, -2 }, /* (198) cmd ::= SHOW QNODES */ + { 254, -2 }, /* (199) cmd ::= SHOW FUNCTIONS */ + { 254, -5 }, /* (200) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 254, -2 }, /* (201) cmd ::= SHOW STREAMS */ + { 254, -2 }, /* (202) cmd ::= SHOW ACCOUNTS */ + { 254, -2 }, /* (203) cmd ::= SHOW APPS */ + { 254, -2 }, /* (204) cmd ::= SHOW CONNECTIONS */ + { 254, -2 }, /* (205) cmd ::= SHOW LICENCE */ + { 254, -2 }, /* (206) cmd ::= SHOW GRANTS */ + { 254, -4 }, /* (207) cmd ::= SHOW CREATE DATABASE db_name */ + { 254, -4 }, /* (208) cmd ::= SHOW CREATE TABLE full_table_name */ + { 254, -4 }, /* (209) cmd ::= SHOW CREATE STABLE full_table_name */ + { 254, -2 }, /* (210) cmd ::= SHOW QUERIES */ + { 254, -2 }, /* (211) cmd ::= SHOW SCORES */ + { 254, -2 }, /* (212) cmd ::= SHOW TOPICS */ + { 254, -2 }, /* (213) cmd ::= SHOW VARIABLES */ + { 254, -3 }, /* (214) cmd ::= SHOW LOCAL VARIABLES */ + { 254, -4 }, /* (215) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 254, -2 }, /* (216) cmd ::= SHOW BNODES */ + { 254, -2 }, /* (217) cmd ::= SHOW SNODES */ + { 254, -2 }, /* (218) cmd ::= SHOW CLUSTER */ + { 254, -2 }, /* (219) cmd ::= SHOW TRANSACTIONS */ + { 254, -4 }, /* (220) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 254, -2 }, /* (221) cmd ::= SHOW CONSUMERS */ + { 254, -2 }, /* (222) cmd ::= SHOW SUBSCRIPTIONS */ + { 302, 0 }, /* (223) db_name_cond_opt ::= */ + { 302, -2 }, /* (224) db_name_cond_opt ::= db_name NK_DOT */ + { 303, 0 }, /* (225) like_pattern_opt ::= */ + { 303, -2 }, /* (226) like_pattern_opt ::= LIKE NK_STRING */ + { 304, -1 }, /* (227) table_name_cond ::= table_name */ + { 305, 0 }, /* (228) from_db_opt ::= */ + { 305, -2 }, /* (229) from_db_opt ::= FROM db_name */ + { 254, -8 }, /* (230) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 254, -4 }, /* (231) cmd ::= DROP INDEX exists_opt index_name */ + { 307, -10 }, /* (232) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 307, -12 }, /* (233) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + { 308, -1 }, /* (234) func_list ::= func */ + { 308, -3 }, /* (235) func_list ::= func_list NK_COMMA func */ + { 311, -4 }, /* (236) func ::= function_name NK_LP expression_list NK_RP */ + { 310, 0 }, /* (237) sma_stream_opt ::= */ + { 310, -3 }, /* (238) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 310, -3 }, /* (239) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 254, -6 }, /* (240) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 254, -7 }, /* (241) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 254, -9 }, /* (242) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 254, -7 }, /* (243) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 254, -9 }, /* (244) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 254, -4 }, /* (245) cmd ::= DROP TOPIC exists_opt topic_name */ + { 254, -7 }, /* (246) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 254, -2 }, /* (247) cmd ::= DESC full_table_name */ + { 254, -2 }, /* (248) cmd ::= DESCRIBE full_table_name */ + { 254, -3 }, /* (249) cmd ::= RESET QUERY CACHE */ + { 254, -4 }, /* (250) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 316, 0 }, /* (251) analyze_opt ::= */ + { 316, -1 }, /* (252) analyze_opt ::= ANALYZE */ + { 317, 0 }, /* (253) explain_options ::= */ + { 317, -3 }, /* (254) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 317, -3 }, /* (255) explain_options ::= explain_options RATIO NK_FLOAT */ + { 254, -6 }, /* (256) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 254, -10 }, /* (257) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 254, -4 }, /* (258) cmd ::= DROP FUNCTION exists_opt function_name */ + { 318, 0 }, /* (259) agg_func_opt ::= */ + { 318, -1 }, /* (260) agg_func_opt ::= AGGREGATE */ + { 319, 0 }, /* (261) bufsize_opt ::= */ + { 319, -2 }, /* (262) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 254, -8 }, /* (263) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 254, -4 }, /* (264) cmd ::= DROP STREAM exists_opt stream_name */ + { 321, 0 }, /* (265) into_opt ::= */ + { 321, -2 }, /* (266) into_opt ::= INTO full_table_name */ + { 312, 0 }, /* (267) stream_options ::= */ + { 312, -3 }, /* (268) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 312, -3 }, /* (269) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 312, -4 }, /* (270) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 312, -3 }, /* (271) stream_options ::= stream_options WATERMARK duration_literal */ + { 312, -3 }, /* (272) stream_options ::= stream_options IGNORE EXPIRED */ + { 254, -3 }, /* (273) cmd ::= KILL CONNECTION NK_INTEGER */ + { 254, -3 }, /* (274) cmd ::= KILL QUERY NK_STRING */ + { 254, -3 }, /* (275) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 254, -2 }, /* (276) cmd ::= BALANCE VGROUP */ + { 254, -4 }, /* (277) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 254, -4 }, /* (278) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 254, -3 }, /* (279) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 322, -2 }, /* (280) dnode_list ::= DNODE NK_INTEGER */ + { 322, -3 }, /* (281) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 254, -3 }, /* (282) cmd ::= SYNCDB db_name REPLICA */ + { 254, -4 }, /* (283) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 254, -1 }, /* (284) cmd ::= query_expression */ + { 254, -5 }, /* (285) cmd ::= INSERT INTO full_table_name specific_cols_opt query_expression */ + { 257, -1 }, /* (286) literal ::= NK_INTEGER */ + { 257, -1 }, /* (287) literal ::= NK_FLOAT */ + { 257, -1 }, /* (288) literal ::= NK_STRING */ + { 257, -1 }, /* (289) literal ::= NK_BOOL */ + { 257, -2 }, /* (290) literal ::= TIMESTAMP NK_STRING */ + { 257, -1 }, /* (291) literal ::= duration_literal */ + { 257, -1 }, /* (292) literal ::= NULL */ + { 257, -1 }, /* (293) literal ::= NK_QUESTION */ + { 298, -1 }, /* (294) duration_literal ::= NK_VARIABLE */ + { 324, -1 }, /* (295) signed ::= NK_INTEGER */ + { 324, -2 }, /* (296) signed ::= NK_PLUS NK_INTEGER */ + { 324, -2 }, /* (297) signed ::= NK_MINUS NK_INTEGER */ + { 324, -1 }, /* (298) signed ::= NK_FLOAT */ + { 324, -2 }, /* (299) signed ::= NK_PLUS NK_FLOAT */ + { 324, -2 }, /* (300) signed ::= NK_MINUS NK_FLOAT */ + { 287, -1 }, /* (301) signed_literal ::= signed */ + { 287, -1 }, /* (302) signed_literal ::= NK_STRING */ + { 287, -1 }, /* (303) signed_literal ::= NK_BOOL */ + { 287, -2 }, /* (304) signed_literal ::= TIMESTAMP NK_STRING */ + { 287, -1 }, /* (305) signed_literal ::= duration_literal */ + { 287, -1 }, /* (306) signed_literal ::= NULL */ + { 287, -1 }, /* (307) signed_literal ::= literal_func */ + { 326, -1 }, /* (308) literal_list ::= signed_literal */ + { 326, -3 }, /* (309) literal_list ::= literal_list NK_COMMA signed_literal */ + { 265, -1 }, /* (310) db_name ::= NK_ID */ + { 293, -1 }, /* (311) table_name ::= NK_ID */ + { 285, -1 }, /* (312) column_name ::= NK_ID */ + { 300, -1 }, /* (313) function_name ::= NK_ID */ + { 327, -1 }, /* (314) table_alias ::= NK_ID */ + { 328, -1 }, /* (315) column_alias ::= NK_ID */ + { 259, -1 }, /* (316) user_name ::= NK_ID */ + { 306, -1 }, /* (317) index_name ::= NK_ID */ + { 313, -1 }, /* (318) topic_name ::= NK_ID */ + { 320, -1 }, /* (319) stream_name ::= NK_ID */ + { 315, -1 }, /* (320) cgroup_name ::= NK_ID */ + { 329, -1 }, /* (321) expression ::= literal */ + { 329, -1 }, /* (322) expression ::= pseudo_column */ + { 329, -1 }, /* (323) expression ::= column_reference */ + { 329, -1 }, /* (324) expression ::= function_expression */ + { 329, -1 }, /* (325) expression ::= subquery */ + { 329, -3 }, /* (326) expression ::= NK_LP expression NK_RP */ + { 329, -2 }, /* (327) expression ::= NK_PLUS expression */ + { 329, -2 }, /* (328) expression ::= NK_MINUS expression */ + { 329, -3 }, /* (329) expression ::= expression NK_PLUS expression */ + { 329, -3 }, /* (330) expression ::= expression NK_MINUS expression */ + { 329, -3 }, /* (331) expression ::= expression NK_STAR expression */ + { 329, -3 }, /* (332) expression ::= expression NK_SLASH expression */ + { 329, -3 }, /* (333) expression ::= expression NK_REM expression */ + { 329, -3 }, /* (334) expression ::= column_reference NK_ARROW NK_STRING */ + { 329, -3 }, /* (335) expression ::= expression NK_BITAND expression */ + { 329, -3 }, /* (336) expression ::= expression NK_BITOR expression */ + { 290, -1 }, /* (337) expression_list ::= expression */ + { 290, -3 }, /* (338) expression_list ::= expression_list NK_COMMA expression */ + { 331, -1 }, /* (339) column_reference ::= column_name */ + { 331, -3 }, /* (340) column_reference ::= table_name NK_DOT column_name */ + { 330, -1 }, /* (341) pseudo_column ::= ROWTS */ + { 330, -1 }, /* (342) pseudo_column ::= TBNAME */ + { 330, -3 }, /* (343) pseudo_column ::= table_name NK_DOT TBNAME */ + { 330, -1 }, /* (344) pseudo_column ::= QSTARTTS */ + { 330, -1 }, /* (345) pseudo_column ::= QENDTS */ + { 330, -1 }, /* (346) pseudo_column ::= WSTARTTS */ + { 330, -1 }, /* (347) pseudo_column ::= WENDTS */ + { 330, -1 }, /* (348) pseudo_column ::= WDURATION */ + { 332, -4 }, /* (349) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 332, -4 }, /* (350) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 332, -6 }, /* (351) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 332, -1 }, /* (352) function_expression ::= literal_func */ + { 325, -3 }, /* (353) literal_func ::= noarg_func NK_LP NK_RP */ + { 325, -1 }, /* (354) literal_func ::= NOW */ + { 336, -1 }, /* (355) noarg_func ::= NOW */ + { 336, -1 }, /* (356) noarg_func ::= TODAY */ + { 336, -1 }, /* (357) noarg_func ::= TIMEZONE */ + { 336, -1 }, /* (358) noarg_func ::= DATABASE */ + { 336, -1 }, /* (359) noarg_func ::= CLIENT_VERSION */ + { 336, -1 }, /* (360) noarg_func ::= SERVER_VERSION */ + { 336, -1 }, /* (361) noarg_func ::= SERVER_STATUS */ + { 336, -1 }, /* (362) noarg_func ::= CURRENT_USER */ + { 336, -1 }, /* (363) noarg_func ::= USER */ + { 334, -1 }, /* (364) star_func ::= COUNT */ + { 334, -1 }, /* (365) star_func ::= FIRST */ + { 334, -1 }, /* (366) star_func ::= LAST */ + { 334, -1 }, /* (367) star_func ::= LAST_ROW */ + { 335, -1 }, /* (368) star_func_para_list ::= NK_STAR */ + { 335, -1 }, /* (369) star_func_para_list ::= other_para_list */ + { 337, -1 }, /* (370) other_para_list ::= star_func_para */ + { 337, -3 }, /* (371) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 338, -1 }, /* (372) star_func_para ::= expression */ + { 338, -3 }, /* (373) star_func_para ::= table_name NK_DOT NK_STAR */ + { 339, -3 }, /* (374) predicate ::= expression compare_op expression */ + { 339, -5 }, /* (375) predicate ::= expression BETWEEN expression AND expression */ + { 339, -6 }, /* (376) predicate ::= expression NOT BETWEEN expression AND expression */ + { 339, -3 }, /* (377) predicate ::= expression IS NULL */ + { 339, -4 }, /* (378) predicate ::= expression IS NOT NULL */ + { 339, -3 }, /* (379) predicate ::= expression in_op in_predicate_value */ + { 340, -1 }, /* (380) compare_op ::= NK_LT */ + { 340, -1 }, /* (381) compare_op ::= NK_GT */ + { 340, -1 }, /* (382) compare_op ::= NK_LE */ + { 340, -1 }, /* (383) compare_op ::= NK_GE */ + { 340, -1 }, /* (384) compare_op ::= NK_NE */ + { 340, -1 }, /* (385) compare_op ::= NK_EQ */ + { 340, -1 }, /* (386) compare_op ::= LIKE */ + { 340, -2 }, /* (387) compare_op ::= NOT LIKE */ + { 340, -1 }, /* (388) compare_op ::= MATCH */ + { 340, -1 }, /* (389) compare_op ::= NMATCH */ + { 340, -1 }, /* (390) compare_op ::= CONTAINS */ + { 341, -1 }, /* (391) in_op ::= IN */ + { 341, -2 }, /* (392) in_op ::= NOT IN */ + { 342, -3 }, /* (393) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 343, -1 }, /* (394) boolean_value_expression ::= boolean_primary */ + { 343, -2 }, /* (395) boolean_value_expression ::= NOT boolean_primary */ + { 343, -3 }, /* (396) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 343, -3 }, /* (397) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 344, -1 }, /* (398) boolean_primary ::= predicate */ + { 344, -3 }, /* (399) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 345, -1 }, /* (400) common_expression ::= expression */ + { 345, -1 }, /* (401) common_expression ::= boolean_value_expression */ + { 346, 0 }, /* (402) from_clause_opt ::= */ + { 346, -2 }, /* (403) from_clause_opt ::= FROM table_reference_list */ + { 347, -1 }, /* (404) table_reference_list ::= table_reference */ + { 347, -3 }, /* (405) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 348, -1 }, /* (406) table_reference ::= table_primary */ + { 348, -1 }, /* (407) table_reference ::= joined_table */ + { 349, -2 }, /* (408) table_primary ::= table_name alias_opt */ + { 349, -4 }, /* (409) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 349, -2 }, /* (410) table_primary ::= subquery alias_opt */ + { 349, -1 }, /* (411) table_primary ::= parenthesized_joined_table */ + { 351, 0 }, /* (412) alias_opt ::= */ + { 351, -1 }, /* (413) alias_opt ::= table_alias */ + { 351, -2 }, /* (414) alias_opt ::= AS table_alias */ + { 352, -3 }, /* (415) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 352, -3 }, /* (416) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 350, -6 }, /* (417) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 353, 0 }, /* (418) join_type ::= */ + { 353, -1 }, /* (419) join_type ::= INNER */ + { 355, -12 }, /* (420) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 356, 0 }, /* (421) set_quantifier_opt ::= */ + { 356, -1 }, /* (422) set_quantifier_opt ::= DISTINCT */ + { 356, -1 }, /* (423) set_quantifier_opt ::= ALL */ + { 357, -1 }, /* (424) select_list ::= select_item */ + { 357, -3 }, /* (425) select_list ::= select_list NK_COMMA select_item */ + { 365, -1 }, /* (426) select_item ::= NK_STAR */ + { 365, -1 }, /* (427) select_item ::= common_expression */ + { 365, -2 }, /* (428) select_item ::= common_expression column_alias */ + { 365, -3 }, /* (429) select_item ::= common_expression AS column_alias */ + { 365, -3 }, /* (430) select_item ::= table_name NK_DOT NK_STAR */ + { 323, 0 }, /* (431) where_clause_opt ::= */ + { 323, -2 }, /* (432) where_clause_opt ::= WHERE search_condition */ + { 358, 0 }, /* (433) partition_by_clause_opt ::= */ + { 358, -3 }, /* (434) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 362, 0 }, /* (435) twindow_clause_opt ::= */ + { 362, -6 }, /* (436) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 362, -4 }, /* (437) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 362, -6 }, /* (438) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 362, -8 }, /* (439) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 309, 0 }, /* (440) sliding_opt ::= */ + { 309, -4 }, /* (441) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 361, 0 }, /* (442) fill_opt ::= */ + { 361, -4 }, /* (443) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 361, -6 }, /* (444) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 366, -1 }, /* (445) fill_mode ::= NONE */ + { 366, -1 }, /* (446) fill_mode ::= PREV */ + { 366, -1 }, /* (447) fill_mode ::= NULL */ + { 366, -1 }, /* (448) fill_mode ::= LINEAR */ + { 366, -1 }, /* (449) fill_mode ::= NEXT */ + { 363, 0 }, /* (450) group_by_clause_opt ::= */ + { 363, -3 }, /* (451) group_by_clause_opt ::= GROUP BY group_by_list */ + { 367, -1 }, /* (452) group_by_list ::= expression */ + { 367, -3 }, /* (453) group_by_list ::= group_by_list NK_COMMA expression */ + { 364, 0 }, /* (454) having_clause_opt ::= */ + { 364, -2 }, /* (455) having_clause_opt ::= HAVING search_condition */ + { 359, 0 }, /* (456) range_opt ::= */ + { 359, -6 }, /* (457) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + { 360, 0 }, /* (458) every_opt ::= */ + { 360, -4 }, /* (459) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 314, -4 }, /* (460) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 368, -1 }, /* (461) query_expression_body ::= query_primary */ + { 368, -4 }, /* (462) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 368, -3 }, /* (463) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 372, -1 }, /* (464) query_primary ::= query_specification */ + { 372, -6 }, /* (465) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 369, 0 }, /* (466) order_by_clause_opt ::= */ + { 369, -3 }, /* (467) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 370, 0 }, /* (468) slimit_clause_opt ::= */ + { 370, -2 }, /* (469) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 370, -4 }, /* (470) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 370, -4 }, /* (471) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 371, 0 }, /* (472) limit_clause_opt ::= */ + { 371, -2 }, /* (473) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 371, -4 }, /* (474) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 371, -4 }, /* (475) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 333, -3 }, /* (476) subquery ::= NK_LP query_expression NK_RP */ + { 354, -1 }, /* (477) search_condition ::= common_expression */ + { 373, -1 }, /* (478) sort_specification_list ::= sort_specification */ + { 373, -3 }, /* (479) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 374, -3 }, /* (480) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 375, 0 }, /* (481) ordering_specification_opt ::= */ + { 375, -1 }, /* (482) ordering_specification_opt ::= ASC */ + { 375, -1 }, /* (483) ordering_specification_opt ::= DESC */ + { 376, 0 }, /* (484) null_ordering_opt ::= */ + { 376, -2 }, /* (485) null_ordering_opt ::= NULLS FIRST */ + { 376, -2 }, /* (486) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3267,11 +3271,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,254,&yymsp[0].minor); + yy_destructor(yypParser,255,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,255,&yymsp[0].minor); + yy_destructor(yypParser,256,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3285,20 +3289,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,254,&yymsp[-2].minor); +{ yy_destructor(yypParser,255,&yymsp[-2].minor); { } - yy_destructor(yypParser,256,&yymsp[0].minor); + yy_destructor(yypParser,257,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,257,&yymsp[0].minor); +{ yy_destructor(yypParser,258,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,255,&yymsp[-1].minor); +{ yy_destructor(yypParser,256,&yymsp[-1].minor); { } - yy_destructor(yypParser,257,&yymsp[0].minor); + yy_destructor(yypParser,258,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3312,72 +3316,72 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,256,&yymsp[0].minor); + yy_destructor(yypParser,257,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy401, &yymsp[-1].minor.yy0, yymsp[0].minor.yy695); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy0, yymsp[0].minor.yy535); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy401, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy401, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy401, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy401); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy5); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy695 = 1; } +{ yymsp[1].minor.yy535 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy695 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy535 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy525, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy401); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy311, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy525, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy401); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy311, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy525 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy311 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy525 = yymsp[0].minor.yy525; } - yymsp[0].minor.yy525 = yylhsminor.yy525; +{ yylhsminor.yy311 = yymsp[0].minor.yy311; } + yymsp[0].minor.yy311 = yylhsminor.yy311; break; case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy525 = yymsp[-2].minor.yy525 | yymsp[0].minor.yy525; } - yymsp[-2].minor.yy525 = yylhsminor.yy525; +{ yylhsminor.yy311 = yymsp[-2].minor.yy311 | yymsp[0].minor.yy311; } + yymsp[-2].minor.yy311 = yylhsminor.yy311; break; case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy525 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy311 = PRIVILEGE_TYPE_READ; } break; case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy525 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy311 = PRIVILEGE_TYPE_WRITE; } break; case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy401 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy401 = yylhsminor.yy401; +{ yylhsminor.yy5 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy5 = yylhsminor.yy5; break; case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy401 = yymsp[-2].minor.yy401; } - yymsp[-2].minor.yy401 = yylhsminor.yy401; +{ yylhsminor.yy5 = yymsp[-2].minor.yy5; } + yymsp[-2].minor.yy5 = yylhsminor.yy5; break; case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy401, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy5, NULL); } break; case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 44: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy401); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy5); } break; case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3394,32 +3398,32 @@ static YYACTIONTYPE yy_reduce( case 49: /* dnode_endpoint ::= NK_STRING */ case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50); case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51); - case 308: /* db_name ::= NK_ID */ yytestcase(yyruleno==308); - case 309: /* table_name ::= NK_ID */ yytestcase(yyruleno==309); - case 310: /* column_name ::= NK_ID */ yytestcase(yyruleno==310); - case 311: /* function_name ::= NK_ID */ yytestcase(yyruleno==311); - case 312: /* table_alias ::= NK_ID */ yytestcase(yyruleno==312); - case 313: /* column_alias ::= NK_ID */ yytestcase(yyruleno==313); - case 314: /* user_name ::= NK_ID */ yytestcase(yyruleno==314); - case 315: /* index_name ::= NK_ID */ yytestcase(yyruleno==315); - case 316: /* topic_name ::= NK_ID */ yytestcase(yyruleno==316); - case 317: /* stream_name ::= NK_ID */ yytestcase(yyruleno==317); - case 318: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==318); - case 353: /* noarg_func ::= NOW */ yytestcase(yyruleno==353); - case 354: /* noarg_func ::= TODAY */ yytestcase(yyruleno==354); - case 355: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==355); - case 356: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==356); - case 357: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==357); - case 358: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==358); - case 359: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==359); - case 360: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==360); - case 361: /* noarg_func ::= USER */ yytestcase(yyruleno==361); - case 362: /* star_func ::= COUNT */ yytestcase(yyruleno==362); - case 363: /* star_func ::= FIRST */ yytestcase(yyruleno==363); - case 364: /* star_func ::= LAST */ yytestcase(yyruleno==364); - case 365: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==365); -{ yylhsminor.yy401 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy401 = yylhsminor.yy401; + case 310: /* db_name ::= NK_ID */ yytestcase(yyruleno==310); + case 311: /* table_name ::= NK_ID */ yytestcase(yyruleno==311); + case 312: /* column_name ::= NK_ID */ yytestcase(yyruleno==312); + case 313: /* function_name ::= NK_ID */ yytestcase(yyruleno==313); + case 314: /* table_alias ::= NK_ID */ yytestcase(yyruleno==314); + case 315: /* column_alias ::= NK_ID */ yytestcase(yyruleno==315); + case 316: /* user_name ::= NK_ID */ yytestcase(yyruleno==316); + case 317: /* index_name ::= NK_ID */ yytestcase(yyruleno==317); + case 318: /* topic_name ::= NK_ID */ yytestcase(yyruleno==318); + case 319: /* stream_name ::= NK_ID */ yytestcase(yyruleno==319); + case 320: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==320); + case 355: /* noarg_func ::= NOW */ yytestcase(yyruleno==355); + case 356: /* noarg_func ::= TODAY */ yytestcase(yyruleno==356); + case 357: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==357); + case 358: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==358); + case 359: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==359); + case 360: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==360); + case 361: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==361); + case 362: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==362); + case 363: /* noarg_func ::= USER */ yytestcase(yyruleno==363); + case 364: /* star_func ::= COUNT */ yytestcase(yyruleno==364); + case 365: /* star_func ::= FIRST */ yytestcase(yyruleno==365); + case 366: /* star_func ::= LAST */ yytestcase(yyruleno==366); + case 367: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==367); +{ yylhsminor.yy5 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy5 = yylhsminor.yy5; break; case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3452,1227 +3456,1234 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy89, &yymsp[-1].minor.yy401, yymsp[0].minor.yy248); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy403, &yymsp[-1].minor.yy5, yymsp[0].minor.yy652); } break; case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy89, &yymsp[0].minor.yy401); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy403, &yymsp[0].minor.yy5); } break; case 64: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy401); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy5); } break; case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy401, yymsp[0].minor.yy248); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy5, yymsp[0].minor.yy652); } break; case 66: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy401); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy5); } break; case 67: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy89 = true; } +{ yymsp[-2].minor.yy403 = true; } break; case 68: /* not_exists_opt ::= */ case 70: /* exists_opt ::= */ yytestcase(yyruleno==70); - case 249: /* analyze_opt ::= */ yytestcase(yyruleno==249); - case 257: /* agg_func_opt ::= */ yytestcase(yyruleno==257); - case 419: /* set_quantifier_opt ::= */ yytestcase(yyruleno==419); -{ yymsp[1].minor.yy89 = false; } + case 251: /* analyze_opt ::= */ yytestcase(yyruleno==251); + case 259: /* agg_func_opt ::= */ yytestcase(yyruleno==259); + case 421: /* set_quantifier_opt ::= */ yytestcase(yyruleno==421); +{ yymsp[1].minor.yy403 = false; } break; case 69: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy89 = true; } +{ yymsp[-1].minor.yy403 = true; } break; case 71: /* db_options ::= */ -{ yymsp[1].minor.yy248 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy652 = createDefaultDatabaseOptions(pCxt); } break; case 72: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; case 73: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 74: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 74: /* db_options ::= db_options CACHELASTSIZE NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_CACHELASTSIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 75: /* db_options ::= db_options DURATION NK_INTEGER */ - case 76: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==76); -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 75: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 77: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 76: /* db_options ::= db_options DURATION NK_INTEGER */ + case 77: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==77); +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 78: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 78: /* db_options ::= db_options FSYNC NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 79: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 79: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 80: /* db_options ::= db_options KEEP integer_list */ - case 81: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==81); -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_KEEP, yymsp[0].minor.yy552); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 82: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 83: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 84: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 85: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 86: /* db_options ::= db_options STRICT NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 87: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 88: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 89: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 90: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_RETENTIONS, yymsp[0].minor.yy552); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 91: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy248 = setDatabaseOption(pCxt, yymsp[-2].minor.yy248, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 92: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy248 = createAlterDatabaseOptions(pCxt); yylhsminor.yy248 = setAlterDatabaseOption(pCxt, yylhsminor.yy248, &yymsp[0].minor.yy301); } - yymsp[0].minor.yy248 = yylhsminor.yy248; - break; - case 93: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy248 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy248, &yymsp[0].minor.yy301); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; - break; - case 94: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } - break; - case 95: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } - break; - case 96: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } - break; - case 97: /* alter_db_option ::= KEEP integer_list */ - case 98: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==98); -{ yymsp[-1].minor.yy301.type = DB_OPTION_KEEP; yymsp[-1].minor.yy301.pList = yymsp[0].minor.yy552; } - break; - case 99: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_PAGES; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } - break; - case 100: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } - break; - case 101: /* alter_db_option ::= STRICT NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_STRICT; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } - break; - case 102: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_WAL; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } - break; - case 103: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy552 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy552 = yylhsminor.yy552; - break; - case 104: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 279: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==279); -{ yylhsminor.yy552 = addNodeToList(pCxt, yymsp[-2].minor.yy552, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy552 = yylhsminor.yy552; - break; - case 105: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy552 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy552 = yylhsminor.yy552; - break; - case 106: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy552 = addNodeToList(pCxt, yymsp[-2].minor.yy552, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy552 = yylhsminor.yy552; - break; - case 107: /* retention_list ::= retention */ - case 127: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==127); - case 130: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==130); - case 137: /* column_def_list ::= column_def */ yytestcase(yyruleno==137); - case 180: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==180); - case 185: /* col_name_list ::= col_name */ yytestcase(yyruleno==185); - case 232: /* func_list ::= func */ yytestcase(yyruleno==232); - case 306: /* literal_list ::= signed_literal */ yytestcase(yyruleno==306); - case 368: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==368); - case 422: /* select_list ::= select_item */ yytestcase(yyruleno==422); - case 476: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==476); -{ yylhsminor.yy552 = createNodeList(pCxt, yymsp[0].minor.yy248); } - yymsp[0].minor.yy552 = yylhsminor.yy552; - break; - case 108: /* retention_list ::= retention_list NK_COMMA retention */ - case 138: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==138); - case 181: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==181); - case 186: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==186); - case 233: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==233); - case 307: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==307); - case 369: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==369); - case 423: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==423); - case 477: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==477); -{ yylhsminor.yy552 = addNodeToList(pCxt, yymsp[-2].minor.yy552, yymsp[0].minor.yy248); } - yymsp[-2].minor.yy552 = yylhsminor.yy552; - break; - case 109: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy248 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; - break; - case 110: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 112: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==112); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy89, yymsp[-5].minor.yy248, yymsp[-3].minor.yy552, yymsp[-1].minor.yy552, yymsp[0].minor.yy248); } - break; - case 111: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy552); } - break; - case 113: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy552); } - break; - case 114: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy89, yymsp[0].minor.yy248); } - break; - case 115: /* cmd ::= ALTER TABLE alter_table_clause */ - case 282: /* cmd ::= query_expression */ yytestcase(yyruleno==282); -{ pCxt->pRootNode = yymsp[0].minor.yy248; } - break; - case 116: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy248); } - break; - case 117: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy248 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy248, yymsp[0].minor.yy248); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + case 80: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 118: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy248 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy248, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy401, yymsp[0].minor.yy224); } - yymsp[-4].minor.yy248 = yylhsminor.yy248; + case 81: /* db_options ::= db_options KEEP integer_list */ + case 82: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==82); +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_KEEP, yymsp[0].minor.yy210); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 119: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy248 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy248, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy401); } - yymsp[-3].minor.yy248 = yylhsminor.yy248; - break; - case 120: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy248 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy248, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy401, yymsp[0].minor.yy224); } - yymsp[-4].minor.yy248 = yylhsminor.yy248; + case 83: /* db_options ::= db_options PAGES NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 84: /* db_options ::= db_options PAGESIZE NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 85: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 86: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 87: /* db_options ::= db_options STRICT NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 88: /* db_options ::= db_options WAL NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 89: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 90: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 91: /* db_options ::= db_options RETENTIONS retention_list */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_RETENTIONS, yymsp[0].minor.yy210); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 92: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ +{ yylhsminor.yy652 = setDatabaseOption(pCxt, yymsp[-2].minor.yy652, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 93: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy652 = createAlterDatabaseOptions(pCxt); yylhsminor.yy652 = setAlterDatabaseOption(pCxt, yylhsminor.yy652, &yymsp[0].minor.yy351); } + yymsp[0].minor.yy652 = yylhsminor.yy652; + break; + case 94: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy652 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy652, &yymsp[0].minor.yy351); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; + break; + case 95: /* alter_db_option ::= BUFFER NK_INTEGER */ +{ yymsp[-1].minor.yy351.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } + break; + case 96: /* alter_db_option ::= CACHELAST NK_INTEGER */ +{ yymsp[-1].minor.yy351.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } + break; + case 97: /* alter_db_option ::= CACHELASTSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy351.type = DB_OPTION_CACHELASTSIZE; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } + break; + case 98: /* alter_db_option ::= FSYNC NK_INTEGER */ +{ yymsp[-1].minor.yy351.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } + break; + case 99: /* alter_db_option ::= KEEP integer_list */ + case 100: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==100); +{ yymsp[-1].minor.yy351.type = DB_OPTION_KEEP; yymsp[-1].minor.yy351.pList = yymsp[0].minor.yy210; } + break; + case 101: /* alter_db_option ::= PAGES NK_INTEGER */ +{ yymsp[-1].minor.yy351.type = DB_OPTION_PAGES; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } + break; + case 102: /* alter_db_option ::= REPLICA NK_INTEGER */ +{ yymsp[-1].minor.yy351.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } + break; + case 103: /* alter_db_option ::= STRICT NK_INTEGER */ +{ yymsp[-1].minor.yy351.type = DB_OPTION_STRICT; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } + break; + case 104: /* alter_db_option ::= WAL NK_INTEGER */ +{ yymsp[-1].minor.yy351.type = DB_OPTION_WAL; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } + break; + case 105: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy210 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy210 = yylhsminor.yy210; + break; + case 106: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 281: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==281); +{ yylhsminor.yy210 = addNodeToList(pCxt, yymsp[-2].minor.yy210, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy210 = yylhsminor.yy210; + break; + case 107: /* variable_list ::= NK_VARIABLE */ +{ yylhsminor.yy210 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy210 = yylhsminor.yy210; + break; + case 108: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +{ yylhsminor.yy210 = addNodeToList(pCxt, yymsp[-2].minor.yy210, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy210 = yylhsminor.yy210; + break; + case 109: /* retention_list ::= retention */ + case 129: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==129); + case 132: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==132); + case 139: /* column_def_list ::= column_def */ yytestcase(yyruleno==139); + case 182: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==182); + case 187: /* col_name_list ::= col_name */ yytestcase(yyruleno==187); + case 234: /* func_list ::= func */ yytestcase(yyruleno==234); + case 308: /* literal_list ::= signed_literal */ yytestcase(yyruleno==308); + case 370: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==370); + case 424: /* select_list ::= select_item */ yytestcase(yyruleno==424); + case 478: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==478); +{ yylhsminor.yy210 = createNodeList(pCxt, yymsp[0].minor.yy652); } + yymsp[0].minor.yy210 = yylhsminor.yy210; + break; + case 110: /* retention_list ::= retention_list NK_COMMA retention */ + case 140: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==140); + case 183: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==183); + case 188: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==188); + case 235: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==235); + case 309: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==309); + case 371: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==371); + case 425: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==425); + case 479: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==479); +{ yylhsminor.yy210 = addNodeToList(pCxt, yymsp[-2].minor.yy210, yymsp[0].minor.yy652); } + yymsp[-2].minor.yy210 = yylhsminor.yy210; + break; + case 111: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ +{ yylhsminor.yy652 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; + break; + case 112: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 114: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==114); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy403, yymsp[-5].minor.yy652, yymsp[-3].minor.yy210, yymsp[-1].minor.yy210, yymsp[0].minor.yy652); } + break; + case 113: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy210); } + break; + case 115: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy210); } + break; + case 116: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy403, yymsp[0].minor.yy652); } + break; + case 117: /* cmd ::= ALTER TABLE alter_table_clause */ + case 284: /* cmd ::= query_expression */ yytestcase(yyruleno==284); +{ pCxt->pRootNode = yymsp[0].minor.yy652; } + break; + case 118: /* cmd ::= ALTER STABLE alter_table_clause */ +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy652); } + break; + case 119: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy652 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 121: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy248 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy248, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy401, &yymsp[0].minor.yy401); } - yymsp[-4].minor.yy248 = yylhsminor.yy248; + case 120: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy5, yymsp[0].minor.yy552); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 122: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy248 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy248, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy401, yymsp[0].minor.yy224); } - yymsp[-4].minor.yy248 = yylhsminor.yy248; + case 121: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy652 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy652, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy5); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; + break; + case 122: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy5, yymsp[0].minor.yy552); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 123: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy248 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy248, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy401); } - yymsp[-3].minor.yy248 = yylhsminor.yy248; + case 123: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy652 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 124: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy248 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy248, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy401, yymsp[0].minor.yy224); } - yymsp[-4].minor.yy248 = yylhsminor.yy248; + case 124: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy5, yymsp[0].minor.yy552); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 125: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy248 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy248, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy401, &yymsp[0].minor.yy401); } - yymsp[-4].minor.yy248 = yylhsminor.yy248; + case 125: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy652 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy652, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy5); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 126: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy248 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy248, &yymsp[-2].minor.yy401, yymsp[0].minor.yy248); } - yymsp[-5].minor.yy248 = yylhsminor.yy248; + case 126: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy652 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy5, yymsp[0].minor.yy552); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 128: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 131: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==131); -{ yylhsminor.yy552 = addNodeToList(pCxt, yymsp[-1].minor.yy552, yymsp[0].minor.yy248); } - yymsp[-1].minor.yy552 = yylhsminor.yy552; + case 127: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy652 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy652, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 129: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ -{ yylhsminor.yy248 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy89, yymsp[-8].minor.yy248, yymsp[-6].minor.yy248, yymsp[-5].minor.yy552, yymsp[-2].minor.yy552, yymsp[0].minor.yy248); } - yymsp[-9].minor.yy248 = yylhsminor.yy248; + case 128: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +{ yylhsminor.yy652 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy652, &yymsp[-2].minor.yy5, yymsp[0].minor.yy652); } + yymsp[-5].minor.yy652 = yylhsminor.yy652; break; - case 132: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy248 = createDropTableClause(pCxt, yymsp[-1].minor.yy89, yymsp[0].minor.yy248); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + case 130: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 133: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==133); +{ yylhsminor.yy210 = addNodeToList(pCxt, yymsp[-1].minor.yy210, yymsp[0].minor.yy652); } + yymsp[-1].minor.yy210 = yylhsminor.yy210; break; - case 133: /* specific_cols_opt ::= */ - case 164: /* tags_def_opt ::= */ yytestcase(yyruleno==164); - case 431: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==431); - case 448: /* group_by_clause_opt ::= */ yytestcase(yyruleno==448); - case 464: /* order_by_clause_opt ::= */ yytestcase(yyruleno==464); -{ yymsp[1].minor.yy552 = NULL; } + case 131: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ +{ yylhsminor.yy652 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy403, yymsp[-8].minor.yy652, yymsp[-6].minor.yy652, yymsp[-5].minor.yy210, yymsp[-2].minor.yy210, yymsp[0].minor.yy652); } + yymsp[-9].minor.yy652 = yylhsminor.yy652; break; - case 134: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy552 = yymsp[-1].minor.yy552; } + case 134: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy652 = createDropTableClause(pCxt, yymsp[-1].minor.yy403, yymsp[0].minor.yy652); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 135: /* full_table_name ::= table_name */ -{ yylhsminor.yy248 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy401, NULL); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 135: /* specific_cols_opt ::= */ + case 166: /* tags_def_opt ::= */ yytestcase(yyruleno==166); + case 433: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==433); + case 450: /* group_by_clause_opt ::= */ yytestcase(yyruleno==450); + case 466: /* order_by_clause_opt ::= */ yytestcase(yyruleno==466); +{ yymsp[1].minor.yy210 = NULL; } break; - case 136: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy248 = createRealTableNode(pCxt, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy401, NULL); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 136: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy210 = yymsp[-1].minor.yy210; } break; - case 139: /* column_def ::= column_name type_name */ -{ yylhsminor.yy248 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy401, yymsp[0].minor.yy224, NULL); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + case 137: /* full_table_name ::= table_name */ +{ yylhsminor.yy652 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy5, NULL); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 140: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy248 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy401, yymsp[-2].minor.yy224, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy248 = yylhsminor.yy248; + case 138: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy652 = createRealTableNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, NULL); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 141: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 141: /* column_def ::= column_name type_name */ +{ yylhsminor.yy652 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy5, yymsp[0].minor.yy552, NULL); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 142: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 142: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy652 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-2].minor.yy552, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 143: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 143: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 144: /* type_name ::= INT */ - case 145: /* type_name ::= INTEGER */ yytestcase(yyruleno==145); -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_INT); } + case 144: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 146: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 145: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 147: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 146: /* type_name ::= INT */ + case 147: /* type_name ::= INTEGER */ yytestcase(yyruleno==147); +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 148: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 148: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 149: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 149: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 150: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 150: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 151: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 151: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy552 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 152: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 152: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 153: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 153: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy552 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 154: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UINT); } + case 154: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy552 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 155: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 155: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy552 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 156: /* type_name ::= JSON */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_JSON); } + case 156: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy552 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 157: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 157: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy552 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 158: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 158: /* type_name ::= JSON */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 159: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 159: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy552 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 160: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 160: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 161: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 161: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 162: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 162: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy552 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 163: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 163: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy552 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 165: /* tags_def_opt ::= tags_def */ - case 367: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==367); -{ yylhsminor.yy552 = yymsp[0].minor.yy552; } - yymsp[0].minor.yy552 = yylhsminor.yy552; + case 164: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy552 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 166: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy552 = yymsp[-1].minor.yy552; } + case 165: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy552 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 167: /* table_options ::= */ -{ yymsp[1].minor.yy248 = createDefaultTableOptions(pCxt); } + case 167: /* tags_def_opt ::= tags_def */ + case 369: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==369); +{ yylhsminor.yy210 = yymsp[0].minor.yy210; } + yymsp[0].minor.yy210 = yylhsminor.yy210; break; - case 168: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy248 = setTableOption(pCxt, yymsp[-2].minor.yy248, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 168: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy210 = yymsp[-1].minor.yy210; } break; - case 169: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy248 = setTableOption(pCxt, yymsp[-2].minor.yy248, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy552); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 169: /* table_options ::= */ +{ yymsp[1].minor.yy652 = createDefaultTableOptions(pCxt); } break; - case 170: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy248 = setTableOption(pCxt, yymsp[-2].minor.yy248, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy552); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 170: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 171: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy248 = setTableOption(pCxt, yymsp[-4].minor.yy248, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy552); } - yymsp[-4].minor.yy248 = yylhsminor.yy248; + case 171: /* table_options ::= table_options MAX_DELAY duration_list */ +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy210); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 172: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy248 = setTableOption(pCxt, yymsp[-2].minor.yy248, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 172: /* table_options ::= table_options WATERMARK duration_list */ +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy210); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 173: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy248 = setTableOption(pCxt, yymsp[-4].minor.yy248, TABLE_OPTION_SMA, yymsp[-1].minor.yy552); } - yymsp[-4].minor.yy248 = yylhsminor.yy248; + case 173: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-4].minor.yy652, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy210); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 174: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy248 = createAlterTableOptions(pCxt); yylhsminor.yy248 = setTableOption(pCxt, yylhsminor.yy248, yymsp[0].minor.yy301.type, &yymsp[0].minor.yy301.val); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 174: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-2].minor.yy652, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 175: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy248 = setTableOption(pCxt, yymsp[-1].minor.yy248, yymsp[0].minor.yy301.type, &yymsp[0].minor.yy301.val); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + case 175: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-4].minor.yy652, TABLE_OPTION_SMA, yymsp[-1].minor.yy210); } + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 176: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy301.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } + case 176: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy652 = createAlterTableOptions(pCxt); yylhsminor.yy652 = setTableOption(pCxt, yylhsminor.yy652, yymsp[0].minor.yy351.type, &yymsp[0].minor.yy351.val); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 177: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } + case 177: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy652 = setTableOption(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy351.type, &yymsp[0].minor.yy351.val); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 178: /* duration_list ::= duration_literal */ - case 335: /* expression_list ::= expression */ yytestcase(yyruleno==335); -{ yylhsminor.yy552 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy248)); } - yymsp[0].minor.yy552 = yylhsminor.yy552; + case 178: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy351.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } break; - case 179: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 336: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==336); -{ yylhsminor.yy552 = addNodeToList(pCxt, yymsp[-2].minor.yy552, releaseRawExprNode(pCxt, yymsp[0].minor.yy248)); } - yymsp[-2].minor.yy552 = yylhsminor.yy552; + case 179: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy351.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy351.val = yymsp[0].minor.yy0; } break; - case 182: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy248 = createFunctionNode(pCxt, &yymsp[0].minor.yy401, NULL); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 180: /* duration_list ::= duration_literal */ + case 337: /* expression_list ::= expression */ yytestcase(yyruleno==337); +{ yylhsminor.yy210 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy652)); } + yymsp[0].minor.yy210 = yylhsminor.yy210; break; - case 183: /* rollup_func_name ::= FIRST */ - case 184: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==184); -{ yylhsminor.yy248 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 181: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 338: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==338); +{ yylhsminor.yy210 = addNodeToList(pCxt, yymsp[-2].minor.yy210, releaseRawExprNode(pCxt, yymsp[0].minor.yy652)); } + yymsp[-2].minor.yy210 = yylhsminor.yy210; break; - case 187: /* col_name ::= column_name */ -{ yylhsminor.yy248 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy401); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 184: /* rollup_func_name ::= function_name */ +{ yylhsminor.yy652 = createFunctionNode(pCxt, &yymsp[0].minor.yy5, NULL); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 188: /* cmd ::= SHOW DNODES */ + case 185: /* rollup_func_name ::= FIRST */ + case 186: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==186); +{ yylhsminor.yy652 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy652 = yylhsminor.yy652; + break; + case 189: /* col_name ::= column_name */ +{ yylhsminor.yy652 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5); } + yymsp[0].minor.yy652 = yylhsminor.yy652; + break; + case 190: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } break; - case 189: /* cmd ::= SHOW USERS */ + case 191: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } break; - case 190: /* cmd ::= SHOW DATABASES */ + case 192: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; - case 191: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy248, yymsp[0].minor.yy248, OP_TYPE_LIKE); } + case 193: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy652, yymsp[0].minor.yy652, OP_TYPE_LIKE); } break; - case 192: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy248, yymsp[0].minor.yy248, OP_TYPE_LIKE); } + case 194: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy652, yymsp[0].minor.yy652, OP_TYPE_LIKE); } break; - case 193: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy248, NULL, OP_TYPE_LIKE); } + case 195: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy652, NULL, OP_TYPE_LIKE); } break; - case 194: /* cmd ::= SHOW MNODES */ + case 196: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 195: /* cmd ::= SHOW MODULES */ + case 197: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); } break; - case 196: /* cmd ::= SHOW QNODES */ + case 198: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 197: /* cmd ::= SHOW FUNCTIONS */ + case 199: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 198: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy248, yymsp[-1].minor.yy248, OP_TYPE_EQUAL); } + case 200: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy652, yymsp[-1].minor.yy652, OP_TYPE_EQUAL); } break; - case 199: /* cmd ::= SHOW STREAMS */ + case 201: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 200: /* cmd ::= SHOW ACCOUNTS */ + case 202: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 201: /* cmd ::= SHOW APPS */ + case 203: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 202: /* cmd ::= SHOW CONNECTIONS */ + case 204: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 203: /* cmd ::= SHOW LICENCE */ - case 204: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==204); + case 205: /* cmd ::= SHOW LICENCE */ + case 206: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==206); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); } break; - case 205: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy401); } + case 207: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy5); } break; - case 206: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy248); } + case 208: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy652); } break; - case 207: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy248); } + case 209: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy652); } break; - case 208: /* cmd ::= SHOW QUERIES */ + case 210: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 209: /* cmd ::= SHOW SCORES */ + case 211: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 210: /* cmd ::= SHOW TOPICS */ + case 212: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 211: /* cmd ::= SHOW VARIABLES */ + case 213: /* cmd ::= SHOW VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 212: /* cmd ::= SHOW LOCAL VARIABLES */ + case 214: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 213: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + case 215: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-1].minor.yy0)); } break; - case 214: /* cmd ::= SHOW BNODES */ + case 216: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 215: /* cmd ::= SHOW SNODES */ + case 217: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 216: /* cmd ::= SHOW CLUSTER */ + case 218: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 217: /* cmd ::= SHOW TRANSACTIONS */ + case 219: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 218: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy248); } + case 220: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy652); } break; - case 219: /* cmd ::= SHOW CONSUMERS */ + case 221: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 220: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 222: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 221: /* db_name_cond_opt ::= */ - case 226: /* from_db_opt ::= */ yytestcase(yyruleno==226); -{ yymsp[1].minor.yy248 = createDefaultDatabaseCondValue(pCxt); } + case 223: /* db_name_cond_opt ::= */ + case 228: /* from_db_opt ::= */ yytestcase(yyruleno==228); +{ yymsp[1].minor.yy652 = createDefaultDatabaseCondValue(pCxt); } break; - case 222: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy401); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + case 224: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy5); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 223: /* like_pattern_opt ::= */ - case 263: /* into_opt ::= */ yytestcase(yyruleno==263); - case 400: /* from_clause_opt ::= */ yytestcase(yyruleno==400); - case 429: /* where_clause_opt ::= */ yytestcase(yyruleno==429); - case 433: /* twindow_clause_opt ::= */ yytestcase(yyruleno==433); - case 438: /* sliding_opt ::= */ yytestcase(yyruleno==438); - case 440: /* fill_opt ::= */ yytestcase(yyruleno==440); - case 452: /* having_clause_opt ::= */ yytestcase(yyruleno==452); - case 454: /* range_opt ::= */ yytestcase(yyruleno==454); - case 456: /* every_opt ::= */ yytestcase(yyruleno==456); - case 466: /* slimit_clause_opt ::= */ yytestcase(yyruleno==466); - case 470: /* limit_clause_opt ::= */ yytestcase(yyruleno==470); -{ yymsp[1].minor.yy248 = NULL; } + case 225: /* like_pattern_opt ::= */ + case 265: /* into_opt ::= */ yytestcase(yyruleno==265); + case 402: /* from_clause_opt ::= */ yytestcase(yyruleno==402); + case 431: /* where_clause_opt ::= */ yytestcase(yyruleno==431); + case 435: /* twindow_clause_opt ::= */ yytestcase(yyruleno==435); + case 440: /* sliding_opt ::= */ yytestcase(yyruleno==440); + case 442: /* fill_opt ::= */ yytestcase(yyruleno==442); + case 454: /* having_clause_opt ::= */ yytestcase(yyruleno==454); + case 456: /* range_opt ::= */ yytestcase(yyruleno==456); + case 458: /* every_opt ::= */ yytestcase(yyruleno==458); + case 468: /* slimit_clause_opt ::= */ yytestcase(yyruleno==468); + case 472: /* limit_clause_opt ::= */ yytestcase(yyruleno==472); +{ yymsp[1].minor.yy652 = NULL; } break; - case 224: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 226: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 225: /* table_name_cond ::= table_name */ -{ yylhsminor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy401); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 227: /* table_name_cond ::= table_name */ +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy5); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 227: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy401); } + case 229: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy5); } break; - case 228: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy89, &yymsp[-3].minor.yy401, &yymsp[-1].minor.yy401, NULL, yymsp[0].minor.yy248); } + case 230: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy403, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, NULL, yymsp[0].minor.yy652); } break; - case 229: /* cmd ::= DROP INDEX exists_opt index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy89, &yymsp[0].minor.yy401); } + case 231: /* cmd ::= DROP INDEX exists_opt index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy403, &yymsp[0].minor.yy5); } break; - case 230: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy248 = createIndexOption(pCxt, yymsp[-7].minor.yy552, releaseRawExprNode(pCxt, yymsp[-3].minor.yy248), NULL, yymsp[-1].minor.yy248, yymsp[0].minor.yy248); } + case 232: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy652 = createIndexOption(pCxt, yymsp[-7].minor.yy210, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), NULL, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; - case 231: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-11].minor.yy248 = createIndexOption(pCxt, yymsp[-9].minor.yy552, releaseRawExprNode(pCxt, yymsp[-5].minor.yy248), releaseRawExprNode(pCxt, yymsp[-3].minor.yy248), yymsp[-1].minor.yy248, yymsp[0].minor.yy248); } + case 233: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-11].minor.yy652 = createIndexOption(pCxt, yymsp[-9].minor.yy210, releaseRawExprNode(pCxt, yymsp[-5].minor.yy652), releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; - case 234: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy248 = createFunctionNode(pCxt, &yymsp[-3].minor.yy401, yymsp[-1].minor.yy552); } - yymsp[-3].minor.yy248 = yylhsminor.yy248; + case 236: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy652 = createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy210); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 235: /* sma_stream_opt ::= */ - case 265: /* stream_options ::= */ yytestcase(yyruleno==265); -{ yymsp[1].minor.yy248 = createStreamOptions(pCxt); } + case 237: /* sma_stream_opt ::= */ + case 267: /* stream_options ::= */ yytestcase(yyruleno==267); +{ yymsp[1].minor.yy652 = createStreamOptions(pCxt); } break; - case 236: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ - case 269: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==269); -{ ((SStreamOptions*)yymsp[-2].minor.yy248)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy248); yylhsminor.yy248 = yymsp[-2].minor.yy248; } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 238: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ + case 271: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==271); +{ ((SStreamOptions*)yymsp[-2].minor.yy652)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); yylhsminor.yy652 = yymsp[-2].minor.yy652; } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 237: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy248)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy248); yylhsminor.yy248 = yymsp[-2].minor.yy248; } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 239: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy652)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); yylhsminor.yy652 = yymsp[-2].minor.yy652; } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 238: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy89, &yymsp[-2].minor.yy401, yymsp[0].minor.yy248); } + case 240: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy403, &yymsp[-2].minor.yy5, yymsp[0].minor.yy652); } break; - case 239: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy89, &yymsp[-3].minor.yy401, &yymsp[0].minor.yy401, false); } + case 241: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy403, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy5, false); } break; - case 240: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy89, &yymsp[-5].minor.yy401, &yymsp[0].minor.yy401, true); } + case 242: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy403, &yymsp[-5].minor.yy5, &yymsp[0].minor.yy5, true); } break; - case 241: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy89, &yymsp[-3].minor.yy401, yymsp[0].minor.yy248, false); } + case 243: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy403, &yymsp[-3].minor.yy5, yymsp[0].minor.yy652, false); } break; - case 242: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy89, &yymsp[-5].minor.yy401, yymsp[0].minor.yy248, true); } + case 244: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy403, &yymsp[-5].minor.yy5, yymsp[0].minor.yy652, true); } break; - case 243: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy89, &yymsp[0].minor.yy401); } + case 245: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy403, &yymsp[0].minor.yy5); } break; - case 244: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy89, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy401); } + case 246: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy403, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5); } break; - case 245: /* cmd ::= DESC full_table_name */ - case 246: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==246); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy248); } + case 247: /* cmd ::= DESC full_table_name */ + case 248: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==248); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy652); } break; - case 247: /* cmd ::= RESET QUERY CACHE */ + case 249: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 248: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy89, yymsp[-1].minor.yy248, yymsp[0].minor.yy248); } + case 250: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy403, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; - case 250: /* analyze_opt ::= ANALYZE */ - case 258: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==258); - case 420: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==420); -{ yymsp[0].minor.yy89 = true; } + case 252: /* analyze_opt ::= ANALYZE */ + case 260: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==260); + case 422: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==422); +{ yymsp[0].minor.yy403 = true; } break; - case 251: /* explain_options ::= */ -{ yymsp[1].minor.yy248 = createDefaultExplainOptions(pCxt); } + case 253: /* explain_options ::= */ +{ yymsp[1].minor.yy652 = createDefaultExplainOptions(pCxt); } break; - case 252: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy248 = setExplainVerbose(pCxt, yymsp[-2].minor.yy248, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 254: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy652 = setExplainVerbose(pCxt, yymsp[-2].minor.yy652, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 253: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy248 = setExplainRatio(pCxt, yymsp[-2].minor.yy248, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 255: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy652 = setExplainRatio(pCxt, yymsp[-2].minor.yy652, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 254: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy552); } + case 256: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy210); } break; - case 255: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy89, yymsp[-8].minor.yy89, &yymsp[-5].minor.yy401, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy224, yymsp[0].minor.yy228); } + case 257: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy403, yymsp[-8].minor.yy403, &yymsp[-5].minor.yy5, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy552, yymsp[0].minor.yy462); } break; - case 256: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy89, &yymsp[0].minor.yy401); } + case 258: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy403, &yymsp[0].minor.yy5); } break; - case 259: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy228 = 0; } + case 261: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy462 = 0; } break; - case 260: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy228 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 262: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy462 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 261: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy89, &yymsp[-4].minor.yy401, yymsp[-2].minor.yy248, yymsp[-3].minor.yy248, yymsp[0].minor.yy248); } + case 263: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy403, &yymsp[-4].minor.yy5, yymsp[-2].minor.yy652, yymsp[-3].minor.yy652, yymsp[0].minor.yy652); } break; - case 262: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy89, &yymsp[0].minor.yy401); } + case 264: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy403, &yymsp[0].minor.yy5); } break; - case 264: /* into_opt ::= INTO full_table_name */ - case 401: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==401); - case 430: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==430); - case 453: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==453); -{ yymsp[-1].minor.yy248 = yymsp[0].minor.yy248; } + case 266: /* into_opt ::= INTO full_table_name */ + case 403: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==403); + case 432: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==432); + case 455: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==455); +{ yymsp[-1].minor.yy652 = yymsp[0].minor.yy652; } break; - case 266: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy248)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy248 = yymsp[-2].minor.yy248; } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 268: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy652)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy652 = yymsp[-2].minor.yy652; } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 267: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy248)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy248 = yymsp[-2].minor.yy248; } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 269: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy652)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy652 = yymsp[-2].minor.yy652; } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 268: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy248)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy248)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy248); yylhsminor.yy248 = yymsp[-3].minor.yy248; } - yymsp[-3].minor.yy248 = yylhsminor.yy248; + case 270: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy652)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy652)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); yylhsminor.yy652 = yymsp[-3].minor.yy652; } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 270: /* stream_options ::= stream_options IGNORE EXPIRED */ -{ ((SStreamOptions*)yymsp[-2].minor.yy248)->ignoreExpired = true; yylhsminor.yy248 = yymsp[-2].minor.yy248; } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 272: /* stream_options ::= stream_options IGNORE EXPIRED */ +{ ((SStreamOptions*)yymsp[-2].minor.yy652)->ignoreExpired = true; yylhsminor.yy652 = yymsp[-2].minor.yy652; } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 271: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 273: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 272: /* cmd ::= KILL QUERY NK_STRING */ + case 274: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 273: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 275: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 274: /* cmd ::= BALANCE VGROUP */ + case 276: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 275: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 277: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 276: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy552); } + case 278: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy210); } break; - case 277: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 279: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 278: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy552 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 280: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy210 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 280: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy401); } + case 282: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy5); } break; - case 281: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy248, yymsp[0].minor.yy248); } + case 283: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; - case 283: /* cmd ::= INSERT INTO full_table_name specific_cols_opt query_expression */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-2].minor.yy248, yymsp[-1].minor.yy552, yymsp[0].minor.yy248); } + case 285: /* cmd ::= INSERT INTO full_table_name specific_cols_opt query_expression */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-2].minor.yy652, yymsp[-1].minor.yy210, yymsp[0].minor.yy652); } break; - case 284: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy248 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 286: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 285: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy248 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 287: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 286: /* literal ::= NK_STRING */ -{ yylhsminor.yy248 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 288: /* literal ::= NK_STRING */ +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 287: /* literal ::= NK_BOOL */ -{ yylhsminor.yy248 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 289: /* literal ::= NK_BOOL */ +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 288: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + case 290: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 289: /* literal ::= duration_literal */ - case 299: /* signed_literal ::= signed */ yytestcase(yyruleno==299); - case 319: /* expression ::= literal */ yytestcase(yyruleno==319); - case 320: /* expression ::= pseudo_column */ yytestcase(yyruleno==320); - case 321: /* expression ::= column_reference */ yytestcase(yyruleno==321); - case 322: /* expression ::= function_expression */ yytestcase(yyruleno==322); - case 323: /* expression ::= subquery */ yytestcase(yyruleno==323); - case 350: /* function_expression ::= literal_func */ yytestcase(yyruleno==350); - case 392: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==392); - case 396: /* boolean_primary ::= predicate */ yytestcase(yyruleno==396); - case 398: /* common_expression ::= expression */ yytestcase(yyruleno==398); - case 399: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==399); - case 402: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==402); - case 404: /* table_reference ::= table_primary */ yytestcase(yyruleno==404); - case 405: /* table_reference ::= joined_table */ yytestcase(yyruleno==405); - case 409: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==409); - case 459: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==459); - case 462: /* query_primary ::= query_specification */ yytestcase(yyruleno==462); -{ yylhsminor.yy248 = yymsp[0].minor.yy248; } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 291: /* literal ::= duration_literal */ + case 301: /* signed_literal ::= signed */ yytestcase(yyruleno==301); + case 321: /* expression ::= literal */ yytestcase(yyruleno==321); + case 322: /* expression ::= pseudo_column */ yytestcase(yyruleno==322); + case 323: /* expression ::= column_reference */ yytestcase(yyruleno==323); + case 324: /* expression ::= function_expression */ yytestcase(yyruleno==324); + case 325: /* expression ::= subquery */ yytestcase(yyruleno==325); + case 352: /* function_expression ::= literal_func */ yytestcase(yyruleno==352); + case 394: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==394); + case 398: /* boolean_primary ::= predicate */ yytestcase(yyruleno==398); + case 400: /* common_expression ::= expression */ yytestcase(yyruleno==400); + case 401: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==401); + case 404: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==404); + case 406: /* table_reference ::= table_primary */ yytestcase(yyruleno==406); + case 407: /* table_reference ::= joined_table */ yytestcase(yyruleno==407); + case 411: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==411); + case 461: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==461); + case 464: /* query_primary ::= query_specification */ yytestcase(yyruleno==464); +{ yylhsminor.yy652 = yymsp[0].minor.yy652; } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 290: /* literal ::= NULL */ -{ yylhsminor.yy248 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 292: /* literal ::= NULL */ +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 291: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy248 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 293: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 292: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy248 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 294: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 293: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 295: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 294: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 296: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 295: /* signed ::= NK_MINUS NK_INTEGER */ + case 297: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 296: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 298: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 297: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 299: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 298: /* signed ::= NK_MINUS NK_FLOAT */ + case 300: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 300: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 302: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 301: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 303: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 302: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 304: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 303: /* signed_literal ::= duration_literal */ - case 305: /* signed_literal ::= literal_func */ yytestcase(yyruleno==305); - case 370: /* star_func_para ::= expression */ yytestcase(yyruleno==370); - case 425: /* select_item ::= common_expression */ yytestcase(yyruleno==425); - case 475: /* search_condition ::= common_expression */ yytestcase(yyruleno==475); -{ yylhsminor.yy248 = releaseRawExprNode(pCxt, yymsp[0].minor.yy248); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 305: /* signed_literal ::= duration_literal */ + case 307: /* signed_literal ::= literal_func */ yytestcase(yyruleno==307); + case 372: /* star_func_para ::= expression */ yytestcase(yyruleno==372); + case 427: /* select_item ::= common_expression */ yytestcase(yyruleno==427); + case 477: /* search_condition ::= common_expression */ yytestcase(yyruleno==477); +{ yylhsminor.yy652 = releaseRawExprNode(pCxt, yymsp[0].minor.yy652); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 304: /* signed_literal ::= NULL */ -{ yylhsminor.yy248 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 306: /* signed_literal ::= NULL */ +{ yylhsminor.yy652 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 324: /* expression ::= NK_LP expression NK_RP */ - case 397: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==397); -{ yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy248)); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 326: /* expression ::= NK_LP expression NK_RP */ + case 399: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==399); +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 325: /* expression ::= NK_PLUS expression */ + case 327: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy248)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy652)); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 326: /* expression ::= NK_MINUS expression */ + case 328: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy248), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy652), NULL)); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 327: /* expression ::= expression NK_PLUS expression */ + case 329: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 328: /* expression ::= expression NK_MINUS expression */ + case 330: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 329: /* expression ::= expression NK_STAR expression */ + case 331: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 330: /* expression ::= expression NK_SLASH expression */ + case 332: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 331: /* expression ::= expression NK_REM expression */ + case 333: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 332: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 334: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 333: /* expression ::= expression NK_BITAND expression */ + case 335: /* expression ::= expression NK_BITAND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 334: /* expression ::= expression NK_BITOR expression */ + case 336: /* expression ::= expression NK_BITOR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 337: /* column_reference ::= column_name */ -{ yylhsminor.yy248 = createRawExprNode(pCxt, &yymsp[0].minor.yy401, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy401)); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 339: /* column_reference ::= column_name */ +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy5, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 338: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy401, createColumnNode(pCxt, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy401)); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 340: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 339: /* pseudo_column ::= ROWTS */ - case 340: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==340); - case 342: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==342); - case 343: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==343); - case 344: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==344); - case 345: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==345); - case 346: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==346); - case 352: /* literal_func ::= NOW */ yytestcase(yyruleno==352); -{ yylhsminor.yy248 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 341: /* pseudo_column ::= ROWTS */ + case 342: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==342); + case 344: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==344); + case 345: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==345); + case 346: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==346); + case 347: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==347); + case 348: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==348); + case 354: /* literal_func ::= NOW */ yytestcase(yyruleno==354); +{ yylhsminor.yy652 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 341: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy401)))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 343: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy5)))); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 347: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 348: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==348); -{ yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy401, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy401, yymsp[-1].minor.yy552)); } - yymsp[-3].minor.yy248 = yylhsminor.yy248; + case 349: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 350: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==350); +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy210)); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 349: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy248), yymsp[-1].minor.yy224)); } - yymsp[-5].minor.yy248 = yylhsminor.yy248; + case 351: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), yymsp[-1].minor.yy552)); } + yymsp[-5].minor.yy652 = yylhsminor.yy652; break; - case 351: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy401, NULL)); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 353: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy5, NULL)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 366: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy552 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy552 = yylhsminor.yy552; + case 368: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy210 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy210 = yylhsminor.yy210; break; - case 371: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 428: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==428); -{ yylhsminor.yy248 = createColumnNode(pCxt, &yymsp[-2].minor.yy401, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 373: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 430: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==430); +{ yylhsminor.yy652 = createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 372: /* predicate ::= expression compare_op expression */ - case 377: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==377); + case 374: /* predicate ::= expression compare_op expression */ + case 379: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==379); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy716, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy428, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 373: /* predicate ::= expression BETWEEN expression AND expression */ + case 375: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy248), releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy652), releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-4].minor.yy248 = yylhsminor.yy248; + yymsp[-4].minor.yy652 = yylhsminor.yy652; break; - case 374: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 376: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy248), releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy652), releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-5].minor.yy248 = yylhsminor.yy248; + yymsp[-5].minor.yy652 = yylhsminor.yy652; break; - case 375: /* predicate ::= expression IS NULL */ + case 377: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), NULL)); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 376: /* predicate ::= expression IS NOT NULL */ + case 378: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy248), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), NULL)); } - yymsp[-3].minor.yy248 = yylhsminor.yy248; + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 378: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy716 = OP_TYPE_LOWER_THAN; } + case 380: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy428 = OP_TYPE_LOWER_THAN; } break; - case 379: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy716 = OP_TYPE_GREATER_THAN; } + case 381: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy428 = OP_TYPE_GREATER_THAN; } break; - case 380: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy716 = OP_TYPE_LOWER_EQUAL; } + case 382: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy428 = OP_TYPE_LOWER_EQUAL; } break; - case 381: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy716 = OP_TYPE_GREATER_EQUAL; } + case 383: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy428 = OP_TYPE_GREATER_EQUAL; } break; - case 382: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy716 = OP_TYPE_NOT_EQUAL; } + case 384: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy428 = OP_TYPE_NOT_EQUAL; } break; - case 383: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy716 = OP_TYPE_EQUAL; } + case 385: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy428 = OP_TYPE_EQUAL; } break; - case 384: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy716 = OP_TYPE_LIKE; } + case 386: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy428 = OP_TYPE_LIKE; } break; - case 385: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy716 = OP_TYPE_NOT_LIKE; } + case 387: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy428 = OP_TYPE_NOT_LIKE; } break; - case 386: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy716 = OP_TYPE_MATCH; } + case 388: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy428 = OP_TYPE_MATCH; } break; - case 387: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy716 = OP_TYPE_NMATCH; } + case 389: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy428 = OP_TYPE_NMATCH; } break; - case 388: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy716 = OP_TYPE_JSON_CONTAINS; } + case 390: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy428 = OP_TYPE_JSON_CONTAINS; } break; - case 389: /* in_op ::= IN */ -{ yymsp[0].minor.yy716 = OP_TYPE_IN; } + case 391: /* in_op ::= IN */ +{ yymsp[0].minor.yy428 = OP_TYPE_IN; } break; - case 390: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy716 = OP_TYPE_NOT_IN; } + case 392: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy428 = OP_TYPE_NOT_IN; } break; - case 391: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy552)); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 393: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy210)); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 393: /* boolean_value_expression ::= NOT boolean_primary */ + case 395: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy248), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy652), NULL)); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 394: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 396: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 395: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 397: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy248); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy248); - yylhsminor.yy248 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy652); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy652); + yylhsminor.yy652 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 403: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy248 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy248, yymsp[0].minor.yy248, NULL); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 405: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy652 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy652, yymsp[0].minor.yy652, NULL); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 406: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy248 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy401, &yymsp[0].minor.yy401); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + case 408: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy652 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 407: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy248 = createRealTableNode(pCxt, &yymsp[-3].minor.yy401, &yymsp[-1].minor.yy401, &yymsp[0].minor.yy401); } - yymsp[-3].minor.yy248 = yylhsminor.yy248; + case 409: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy652 = createRealTableNode(pCxt, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 408: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy248 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy248), &yymsp[0].minor.yy401); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + case 410: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy652 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652), &yymsp[0].minor.yy5); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 410: /* alias_opt ::= */ -{ yymsp[1].minor.yy401 = nil_token; } + case 412: /* alias_opt ::= */ +{ yymsp[1].minor.yy5 = nil_token; } break; - case 411: /* alias_opt ::= table_alias */ -{ yylhsminor.yy401 = yymsp[0].minor.yy401; } - yymsp[0].minor.yy401 = yylhsminor.yy401; + case 413: /* alias_opt ::= table_alias */ +{ yylhsminor.yy5 = yymsp[0].minor.yy5; } + yymsp[0].minor.yy5 = yylhsminor.yy5; break; - case 412: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy401 = yymsp[0].minor.yy401; } + case 414: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy5 = yymsp[0].minor.yy5; } break; - case 413: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 414: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==414); -{ yymsp[-2].minor.yy248 = yymsp[-1].minor.yy248; } + case 415: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 416: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==416); +{ yymsp[-2].minor.yy652 = yymsp[-1].minor.yy652; } break; - case 415: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy248 = createJoinTableNode(pCxt, yymsp[-4].minor.yy52, yymsp[-5].minor.yy248, yymsp[-2].minor.yy248, yymsp[0].minor.yy248); } - yymsp[-5].minor.yy248 = yylhsminor.yy248; + case 417: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy652 = createJoinTableNode(pCxt, yymsp[-4].minor.yy74, yymsp[-5].minor.yy652, yymsp[-2].minor.yy652, yymsp[0].minor.yy652); } + yymsp[-5].minor.yy652 = yylhsminor.yy652; break; - case 416: /* join_type ::= */ -{ yymsp[1].minor.yy52 = JOIN_TYPE_INNER; } + case 418: /* join_type ::= */ +{ yymsp[1].minor.yy74 = JOIN_TYPE_INNER; } break; - case 417: /* join_type ::= INNER */ -{ yymsp[0].minor.yy52 = JOIN_TYPE_INNER; } + case 419: /* join_type ::= INNER */ +{ yymsp[0].minor.yy74 = JOIN_TYPE_INNER; } break; - case 418: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 420: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-11].minor.yy248 = createSelectStmt(pCxt, yymsp[-10].minor.yy89, yymsp[-9].minor.yy552, yymsp[-8].minor.yy248); - yymsp[-11].minor.yy248 = addWhereClause(pCxt, yymsp[-11].minor.yy248, yymsp[-7].minor.yy248); - yymsp[-11].minor.yy248 = addPartitionByClause(pCxt, yymsp[-11].minor.yy248, yymsp[-6].minor.yy552); - yymsp[-11].minor.yy248 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy248, yymsp[-2].minor.yy248); - yymsp[-11].minor.yy248 = addGroupByClause(pCxt, yymsp[-11].minor.yy248, yymsp[-1].minor.yy552); - yymsp[-11].minor.yy248 = addHavingClause(pCxt, yymsp[-11].minor.yy248, yymsp[0].minor.yy248); - yymsp[-11].minor.yy248 = addRangeClause(pCxt, yymsp[-11].minor.yy248, yymsp[-5].minor.yy248); - yymsp[-11].minor.yy248 = addEveryClause(pCxt, yymsp[-11].minor.yy248, yymsp[-4].minor.yy248); - yymsp[-11].minor.yy248 = addFillClause(pCxt, yymsp[-11].minor.yy248, yymsp[-3].minor.yy248); + yymsp[-11].minor.yy652 = createSelectStmt(pCxt, yymsp[-10].minor.yy403, yymsp[-9].minor.yy210, yymsp[-8].minor.yy652); + yymsp[-11].minor.yy652 = addWhereClause(pCxt, yymsp[-11].minor.yy652, yymsp[-7].minor.yy652); + yymsp[-11].minor.yy652 = addPartitionByClause(pCxt, yymsp[-11].minor.yy652, yymsp[-6].minor.yy210); + yymsp[-11].minor.yy652 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy652, yymsp[-2].minor.yy652); + yymsp[-11].minor.yy652 = addGroupByClause(pCxt, yymsp[-11].minor.yy652, yymsp[-1].minor.yy210); + yymsp[-11].minor.yy652 = addHavingClause(pCxt, yymsp[-11].minor.yy652, yymsp[0].minor.yy652); + yymsp[-11].minor.yy652 = addRangeClause(pCxt, yymsp[-11].minor.yy652, yymsp[-5].minor.yy652); + yymsp[-11].minor.yy652 = addEveryClause(pCxt, yymsp[-11].minor.yy652, yymsp[-4].minor.yy652); + yymsp[-11].minor.yy652 = addFillClause(pCxt, yymsp[-11].minor.yy652, yymsp[-3].minor.yy652); } break; - case 421: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy89 = false; } + case 423: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy403 = false; } break; - case 424: /* select_item ::= NK_STAR */ -{ yylhsminor.yy248 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy248 = yylhsminor.yy248; + case 426: /* select_item ::= NK_STAR */ +{ yylhsminor.yy652 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy652 = yylhsminor.yy652; break; - case 426: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy248 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy248), &yymsp[0].minor.yy401); } - yymsp[-1].minor.yy248 = yylhsminor.yy248; + case 428: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy652 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652), &yymsp[0].minor.yy5); } + yymsp[-1].minor.yy652 = yylhsminor.yy652; break; - case 427: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy248 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), &yymsp[0].minor.yy401); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 429: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy652 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), &yymsp[0].minor.yy5); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 432: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 449: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==449); - case 465: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==465); -{ yymsp[-2].minor.yy552 = yymsp[0].minor.yy552; } + case 434: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 451: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==451); + case 467: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==467); +{ yymsp[-2].minor.yy210 = yymsp[0].minor.yy210; } break; - case 434: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy248 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy248), releaseRawExprNode(pCxt, yymsp[-1].minor.yy248)); } + case 436: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy652 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } break; - case 435: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy248 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy248)); } + case 437: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy652 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } break; - case 436: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy248 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy248), NULL, yymsp[-1].minor.yy248, yymsp[0].minor.yy248); } + case 438: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy652 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), NULL, yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; - case 437: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy248 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy248), releaseRawExprNode(pCxt, yymsp[-3].minor.yy248), yymsp[-1].minor.yy248, yymsp[0].minor.yy248); } + case 439: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy652 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy652), releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), yymsp[-1].minor.yy652, yymsp[0].minor.yy652); } break; - case 439: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 457: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==457); -{ yymsp[-3].minor.yy248 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy248); } + case 441: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 459: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==459); +{ yymsp[-3].minor.yy652 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy652); } break; - case 441: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy248 = createFillNode(pCxt, yymsp[-1].minor.yy582, NULL); } + case 443: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy652 = createFillNode(pCxt, yymsp[-1].minor.yy270, NULL); } break; - case 442: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy248 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy552)); } + case 444: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy652 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy210)); } break; - case 443: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy582 = FILL_MODE_NONE; } + case 445: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy270 = FILL_MODE_NONE; } break; - case 444: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy582 = FILL_MODE_PREV; } + case 446: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy270 = FILL_MODE_PREV; } break; - case 445: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy582 = FILL_MODE_NULL; } + case 447: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy270 = FILL_MODE_NULL; } break; - case 446: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy582 = FILL_MODE_LINEAR; } + case 448: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy270 = FILL_MODE_LINEAR; } break; - case 447: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy582 = FILL_MODE_NEXT; } + case 449: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy270 = FILL_MODE_NEXT; } break; - case 450: /* group_by_list ::= expression */ -{ yylhsminor.yy552 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); } - yymsp[0].minor.yy552 = yylhsminor.yy552; + case 452: /* group_by_list ::= expression */ +{ yylhsminor.yy210 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } + yymsp[0].minor.yy210 = yylhsminor.yy210; break; - case 451: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy552 = addNodeToList(pCxt, yymsp[-2].minor.yy552, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy248))); } - yymsp[-2].minor.yy552 = yylhsminor.yy552; + case 453: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy210 = addNodeToList(pCxt, yymsp[-2].minor.yy210, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy652))); } + yymsp[-2].minor.yy210 = yylhsminor.yy210; break; - case 455: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ -{ yymsp[-5].minor.yy248 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy248), releaseRawExprNode(pCxt, yymsp[-1].minor.yy248)); } + case 457: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ +{ yymsp[-5].minor.yy652 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy652), releaseRawExprNode(pCxt, yymsp[-1].minor.yy652)); } break; - case 458: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 460: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy248 = addOrderByClause(pCxt, yymsp[-3].minor.yy248, yymsp[-2].minor.yy552); - yylhsminor.yy248 = addSlimitClause(pCxt, yylhsminor.yy248, yymsp[-1].minor.yy248); - yylhsminor.yy248 = addLimitClause(pCxt, yylhsminor.yy248, yymsp[0].minor.yy248); + yylhsminor.yy652 = addOrderByClause(pCxt, yymsp[-3].minor.yy652, yymsp[-2].minor.yy210); + yylhsminor.yy652 = addSlimitClause(pCxt, yylhsminor.yy652, yymsp[-1].minor.yy652); + yylhsminor.yy652 = addLimitClause(pCxt, yylhsminor.yy652, yymsp[0].minor.yy652); } - yymsp[-3].minor.yy248 = yylhsminor.yy248; + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 460: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy248 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy248, yymsp[0].minor.yy248); } - yymsp[-3].minor.yy248 = yylhsminor.yy248; + case 462: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy652 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy652, yymsp[0].minor.yy652); } + yymsp[-3].minor.yy652 = yylhsminor.yy652; break; - case 461: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy248 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy248, yymsp[0].minor.yy248); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 463: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy652 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy652, yymsp[0].minor.yy652); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 463: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ yymsp[-5].minor.yy248 = yymsp[-4].minor.yy248; } - yy_destructor(yypParser,368,&yymsp[-3].minor); - yy_destructor(yypParser,369,&yymsp[-2].minor); - yy_destructor(yypParser,370,&yymsp[-1].minor); + case 465: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ +{ yymsp[-5].minor.yy652 = yymsp[-4].minor.yy652; } + yy_destructor(yypParser,369,&yymsp[-3].minor); + yy_destructor(yypParser,370,&yymsp[-2].minor); + yy_destructor(yypParser,371,&yymsp[-1].minor); break; - case 467: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 471: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==471); -{ yymsp[-1].minor.yy248 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 469: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 473: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==473); +{ yymsp[-1].minor.yy652 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 468: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 472: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==472); -{ yymsp[-3].minor.yy248 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 470: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 474: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==474); +{ yymsp[-3].minor.yy652 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 469: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 473: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==473); -{ yymsp[-3].minor.yy248 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 471: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 475: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==475); +{ yymsp[-3].minor.yy652 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 474: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy248 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy248); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 476: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy652 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy652); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 478: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy248 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy248), yymsp[-1].minor.yy482, yymsp[0].minor.yy345); } - yymsp[-2].minor.yy248 = yylhsminor.yy248; + case 480: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy652 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy652), yymsp[-1].minor.yy553, yymsp[0].minor.yy477); } + yymsp[-2].minor.yy652 = yylhsminor.yy652; break; - case 479: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy482 = ORDER_ASC; } + case 481: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy553 = ORDER_ASC; } break; - case 480: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy482 = ORDER_ASC; } + case 482: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy553 = ORDER_ASC; } break; - case 481: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy482 = ORDER_DESC; } + case 483: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy553 = ORDER_DESC; } break; - case 482: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy345 = NULL_ORDER_DEFAULT; } + case 484: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy477 = NULL_ORDER_DEFAULT; } break; - case 483: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy345 = NULL_ORDER_FIRST; } + case 485: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy477 = NULL_ORDER_FIRST; } break; - case 484: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy345 = NULL_ORDER_LAST; } + case 486: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy477 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index 10921a2082..b39a066ba1 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -77,6 +77,7 @@ TEST_F(ParserInitialCTest, createDatabase) { expect.ignoreExist = igExists; expect.buffer = TSDB_DEFAULT_BUFFER_PER_VNODE; expect.cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW; + expect.lastRowMem = TSDB_DEFAULT_LAST_ROW_MEM; expect.compression = TSDB_DEFAULT_COMP_LEVEL; expect.daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE; expect.fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD; @@ -97,7 +98,8 @@ TEST_F(ParserInitialCTest, createDatabase) { }; auto setDbBufferFunc = [&](int32_t buffer) { expect.buffer = buffer; }; - auto setDbCachelastFunc = [&](int8_t CACHELAST) { expect.cacheLastRow = CACHELAST; }; + auto setDbCachelastFunc = [&](int8_t cachelast) { expect.cacheLastRow = cachelast; }; + auto setDbCachelastSize = [&](int8_t cachelastSize) { expect.lastRowMem = cachelastSize; }; auto setDbCompressionFunc = [&](int8_t compressionLevel) { expect.compression = compressionLevel; }; auto setDbDaysFunc = [&](int32_t daysPerFile) { expect.daysPerFile = daysPerFile; }; auto setDbFsyncFunc = [&](int32_t fsyncPeriod) { expect.fsyncPeriod = fsyncPeriod; }; @@ -154,6 +156,7 @@ TEST_F(ParserInitialCTest, createDatabase) { ASSERT_EQ(req.replications, expect.replications); ASSERT_EQ(req.strict, expect.strict); ASSERT_EQ(req.cacheLastRow, expect.cacheLastRow); + ASSERT_EQ(req.lastRowMem, expect.lastRowMem); // ASSERT_EQ(req.schemaless, expect.schemaless); ASSERT_EQ(req.ignoreExist, expect.ignoreExist); ASSERT_EQ(req.numOfRetensions, expect.numOfRetensions); @@ -179,6 +182,7 @@ TEST_F(ParserInitialCTest, createDatabase) { setCreateDbReqFunc("wxy_db", 1); setDbBufferFunc(64); setDbCachelastFunc(2); + setDbCachelastSize(20); setDbCompressionFunc(1); setDbDaysFunc(100 * 1440); setDbFsyncFunc(100); @@ -200,6 +204,7 @@ TEST_F(ParserInitialCTest, createDatabase) { run("CREATE DATABASE IF NOT EXISTS wxy_db " "BUFFER 64 " "CACHELAST 2 " + "CACHELASTSIZE 20 " "COMP 1 " "DURATION 100 " "FSYNC 100 " diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index e7589fb0df..703395b0d5 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -1340,6 +1340,17 @@ static void doSetLogicNodeParent(SLogicNode* pNode, SLogicNode* pParent) { static void setLogicNodeParent(SLogicNode* pNode) { doSetLogicNodeParent(pNode, NULL); } +static void setLogicSubplanType(SLogicSubplan* pSubplan) { + if (QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY != nodeType(pSubplan->pNode)) { + pSubplan->subplanType = SUBPLAN_TYPE_SCAN; + } else { + SVnodeModifyLogicNode* pModify = (SVnodeModifyLogicNode*)pSubplan->pNode; + pSubplan->subplanType = (MODIFY_TABLE_TYPE_INSERT == pModify->modifyType && NULL != pModify->node.pChildren) + ? SUBPLAN_TYPE_SCAN + : SUBPLAN_TYPE_MODIFY; + } +} + int32_t createLogicPlan(SPlanContext* pCxt, SLogicSubplan** pLogicSubplan) { SLogicPlanContext cxt = {.pPlanCxt = pCxt}; @@ -1354,11 +1365,7 @@ int32_t createLogicPlan(SPlanContext* pCxt, SLogicSubplan** pLogicSubplan) { int32_t code = createQueryLogicNode(&cxt, pCxt->pAstRoot, &pSubplan->pNode); if (TSDB_CODE_SUCCESS == code) { setLogicNodeParent(pSubplan->pNode); - if (QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY == nodeType(pSubplan->pNode)) { - pSubplan->subplanType = SUBPLAN_TYPE_MODIFY; - } else { - pSubplan->subplanType = SUBPLAN_TYPE_SCAN; - } + setLogicSubplanType(pSubplan); } if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 6d5d5e220b..18d69d21d8 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1566,7 +1566,7 @@ static int32_t buildInsertSelectSubplan(SPhysiPlanContext* pCxt, SVnodeModifyLog if (TSDB_CODE_SUCCESS == code) { code = createQueryInserter(pCxt, pModify, pSubplan, &pSubplan->pDataSink); } - pSubplan->msgType = TDMT_VND_SUBMIT; + pSubplan->msgType = TDMT_SCH_MERGE_QUERY; return code; } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 0863b5f21f..2137108386 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -39,7 +39,6 @@ typedef struct SSplitRule { FSplit splitFunc; } SSplitRule; -// typedef bool (*FSplFindSplitNode)(SSplitContext* pCxt, SLogicSubplan* pSubplan, void* pInfo); typedef bool (*FSplFindSplitNode)(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, void* pInfo); static void splSetSubplanVgroups(SLogicSubplan* pSubplan, SLogicNode* pNode) { @@ -67,6 +66,19 @@ static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SLogicNode* pNod return pSubplan; } +static SLogicSubplan* splCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode, ESubplanType subplanType) { + SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); + if (NULL == pSubplan) { + return NULL; + } + pSubplan->id.queryId = pCxt->queryId; + pSubplan->id.groupId = pCxt->groupId; + pSubplan->subplanType = subplanType; + pSubplan->pNode = pNode; + pNode->pParent = NULL; + return pSubplan; +} + static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pChild, SExchangeLogicNode** pOutput) { SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); if (NULL == pExchange) { @@ -98,6 +110,43 @@ static int32_t splCreateExchangeNodeForSubplan(SSplitContext* pCxt, SLogicSubpla return code; } +static bool splIsChildSubplan(SLogicNode* pLogicNode, int32_t groupId) { + if (QUERY_NODE_LOGIC_PLAN_EXCHANGE == nodeType(pLogicNode)) { + return ((SExchangeLogicNode*)pLogicNode)->srcGroupId == groupId; + } + + if (QUERY_NODE_LOGIC_PLAN_MERGE == nodeType(pLogicNode)) { + return ((SMergeLogicNode*)pLogicNode)->srcGroupId == groupId; + } + + SNode* pChild; + FOREACH(pChild, pLogicNode->pChildren) { + bool isChild = splIsChildSubplan((SLogicNode*)pChild, groupId); + if (isChild) { + return isChild; + } + } + return false; +} + +static int32_t splMountSubplan(SLogicSubplan* pParent, SNodeList* pChildren) { + SNode* pChild = NULL; + WHERE_EACH(pChild, pChildren) { + if (splIsChildSubplan(pParent->pNode, ((SLogicSubplan*)pChild)->id.groupId)) { + int32_t code = nodesListMakeAppend(&pParent->pChildren, pChild); + if (TSDB_CODE_SUCCESS == code) { + REPLACE_NODE(NULL); + ERASE_NODE(pChildren); + continue; + } else { + return code; + } + } + WHERE_NEXT; + } + return TSDB_CODE_SUCCESS; +} + static bool splMatchByNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, FSplFindSplitNode func, void* pInfo) { if (func(pCxt, pSubplan, pNode, pInfo)) { @@ -982,56 +1031,6 @@ static int32_t singleTableJoinSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan return code; } -static bool unionIsChildSubplan(SLogicNode* pLogicNode, int32_t groupId) { - if (QUERY_NODE_LOGIC_PLAN_EXCHANGE == nodeType(pLogicNode)) { - return ((SExchangeLogicNode*)pLogicNode)->srcGroupId == groupId; - } - - if (QUERY_NODE_LOGIC_PLAN_MERGE == nodeType(pLogicNode)) { - return ((SMergeLogicNode*)pLogicNode)->srcGroupId == groupId; - } - - SNode* pChild; - FOREACH(pChild, pLogicNode->pChildren) { - bool isChild = unionIsChildSubplan((SLogicNode*)pChild, groupId); - if (isChild) { - return isChild; - } - } - return false; -} - -static int32_t unionMountSubplan(SLogicSubplan* pParent, SNodeList* pChildren) { - SNode* pChild = NULL; - WHERE_EACH(pChild, pChildren) { - if (unionIsChildSubplan(pParent->pNode, ((SLogicSubplan*)pChild)->id.groupId)) { - int32_t code = nodesListMakeAppend(&pParent->pChildren, pChild); - if (TSDB_CODE_SUCCESS == code) { - REPLACE_NODE(NULL); - ERASE_NODE(pChildren); - continue; - } else { - return code; - } - } - WHERE_NEXT; - } - return TSDB_CODE_SUCCESS; -} - -static SLogicSubplan* unionCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode, ESubplanType subplanType) { - SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); - if (NULL == pSubplan) { - return NULL; - } - pSubplan->id.queryId = pCxt->queryId; - pSubplan->id.groupId = pCxt->groupId; - pSubplan->subplanType = subplanType; - pSubplan->pNode = pNode; - pNode->pParent = NULL; - return pSubplan; -} - static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubplan, SLogicNode* pSplitNode) { SNodeList* pSubplanChildren = pUnionSubplan->pChildren; pUnionSubplan->pChildren = NULL; @@ -1040,11 +1039,11 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl SNode* pChild = NULL; FOREACH(pChild, pSplitNode->pChildren) { - SLogicSubplan* pNewSubplan = unionCreateSubplan(pCxt, (SLogicNode*)pChild, pUnionSubplan->subplanType); + SLogicSubplan* pNewSubplan = splCreateSubplan(pCxt, (SLogicNode*)pChild, pUnionSubplan->subplanType); code = nodesListMakeStrictAppend(&pUnionSubplan->pChildren, (SNode*)pNewSubplan); if (TSDB_CODE_SUCCESS == code) { REPLACE_NODE(NULL); - code = unionMountSubplan(pNewSubplan, pSubplanChildren); + code = splMountSubplan(pNewSubplan, pSubplanChildren); } if (TSDB_CODE_SUCCESS != code) { break; @@ -1219,14 +1218,24 @@ static int32_t insertSelectSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { return TSDB_CODE_SUCCESS; } - int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pQueryRoot, info.pSubplan->subplanType); + SLogicSubplan* pNewSubplan = NULL; + SNodeList* pSubplanChildren = info.pSubplan->pChildren; + ESubplanType subplanType = info.pSubplan->subplanType; + int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pQueryRoot, SUBPLAN_TYPE_MODIFY); if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, info.pQueryRoot, 0)); + pNewSubplan = splCreateSubplan(pCxt, info.pQueryRoot, subplanType); + if (NULL == pNewSubplan) { + code = TSDB_CODE_OUT_OF_MEMORY; + } } if (TSDB_CODE_SUCCESS == code) { - info.pSubplan->subplanType = SUBPLAN_TYPE_MODIFY; - SPLIT_FLAG_SET_MASK(info.pSubplan->splitFlag, SPLIT_FLAG_INSERT_SPLIT); + code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)pNewSubplan); } + if (TSDB_CODE_SUCCESS == code) { + code = splMountSubplan(pNewSubplan, pSubplanChildren); + } + + SPLIT_FLAG_SET_MASK(info.pSubplan->splitFlag, SPLIT_FLAG_INSERT_SPLIT); ++(pCxt->groupId); pCxt->split = true; return code; diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index 908149c3ea..ed8786170d 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -381,11 +381,11 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta * pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes; } - qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId %d db %s stb %s suid %" PRIx64 " sver %d tver %d" PRIx64 - " tagNum %d colNum %d precision %d rowSize %d", - msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName, pTableMeta->suid, - pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags, pTableMeta->tableInfo.numOfColumns, - pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize); + qDebug("table %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s stb %s suid %" PRIx64 " sver %d tver %d" PRIx64 + " tagNum %d colNum %d precision %d rowSize %d", + msg->tbName, pTableMeta->uid, pTableMeta->tableType, pTableMeta->vgId, msg->dbFName, msg->stbName, + pTableMeta->suid, pTableMeta->sversion, pTableMeta->tversion, pTableMeta->tableInfo.numOfTags, + pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.precision, pTableMeta->tableInfo.rowSize); *pMeta = pTableMeta; return TSDB_CODE_SUCCESS; diff --git a/source/libs/qworker/inc/qwInt.h b/source/libs/qworker/inc/qwInt.h index 2b1e535e8c..539643c390 100644 --- a/source/libs/qworker/inc/qwInt.h +++ b/source/libs/qworker/inc/qwInt.h @@ -80,12 +80,19 @@ typedef struct SQWDebug { extern SQWDebug gQWDebug; +typedef struct SQWMsgInfo { + int8_t taskType; + int8_t explain; + int8_t needFetch; +} SQWMsgInfo; + typedef struct SQWMsg { void *node; int32_t code; int32_t msgType; char *msg; int32_t msgLen; + SQWMsgInfo msgInfo; SRpcHandleInfo connInfo; } SQWMsg; @@ -122,15 +129,18 @@ typedef struct SQWTaskCtx { int8_t phase; int8_t taskType; int8_t explain; + int8_t needFetch; int32_t queryType; int32_t fetchType; int32_t execId; + bool queryRsped; bool queryFetched; bool queryEnd; bool queryContinue; bool queryInQueue; int32_t rspCode; + int64_t affectedRows; // for insert ...select stmt SRpcHandleInfo ctrlConnInfo; SRpcHandleInfo dataConnInfo; @@ -162,7 +172,7 @@ typedef struct SQWMsgStat { uint64_t queryProcessed; uint64_t cqueryProcessed; uint64_t fetchProcessed; - uint64_t fetchRspProcessed; + uint64_t rspProcessed; uint64_t cancelProcessed; uint64_t dropProcessed; uint64_t hbProcessed; @@ -212,8 +222,8 @@ typedef struct SQWorkerMgmt { #define QW_STAT_GET(_item) atomic_load_64(&(_item)) #define QW_GET_EVENT(ctx, event) atomic_load_8(&(ctx)->events[event]) -#define QW_IS_EVENT_RECEIVED(ctx, event) (QW_GET_EVENT(ctx, event) == QW_EVENT_RECEIVED) -#define QW_IS_EVENT_PROCESSED(ctx, event) (QW_GET_EVENT(ctx, event) == QW_EVENT_PROCESSED) +#define QW_EVENT_RECEIVED(ctx, event) (QW_GET_EVENT(ctx, event) == QW_EVENT_RECEIVED) +#define QW_EVENT_PROCESSED(ctx, event) (QW_GET_EVENT(ctx, event) == QW_EVENT_PROCESSED) #define QW_SET_EVENT_RECEIVED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_RECEIVED) #define QW_SET_EVENT_PROCESSED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_PROCESSED) @@ -222,13 +232,8 @@ typedef struct SQWorkerMgmt { #define QW_SET_RSP_CODE(ctx, code) atomic_store_32(&(ctx)->rspCode, code) #define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code) -#define QW_IS_QUERY_RUNNING(ctx) (QW_GET_PHASE(ctx) == QW_PHASE_PRE_QUERY || QW_GET_PHASE(ctx) == QW_PHASE_PRE_CQUERY) +#define QW_QUERY_RUNNING(ctx) (QW_GET_PHASE(ctx) == QW_PHASE_PRE_QUERY || QW_GET_PHASE(ctx) == QW_PHASE_PRE_CQUERY) -#define QW_TASK_NOT_EXIST(code) (TSDB_CODE_QRY_SCH_NOT_EXIST == (code) || TSDB_CODE_QRY_TASK_NOT_EXIST == (code)) -#define QW_TASK_ALREADY_EXIST(code) (TSDB_CODE_QRY_TASK_ALREADY_EXIST == (code)) -#define QW_TASK_READY(status) \ - (status == JOB_TASK_STATUS_SUCC || status == JOB_TASK_STATUS_FAIL || status == JOB_TASK_STATUS_CANCELLED || \ - status == JOB_TASK_STATUS_PART_SUCC) #define QW_SET_QTID(id, qId, tId, eId) \ do { \ *(uint64_t *)(id) = (qId); \ diff --git a/source/libs/qworker/inc/qwMsg.h b/source/libs/qworker/inc/qwMsg.h index 7becaf06eb..704cd31428 100644 --- a/source/libs/qworker/inc/qwMsg.h +++ b/source/libs/qworker/inc/qwMsg.h @@ -25,7 +25,7 @@ extern "C" { int32_t qwAbortPrerocessQuery(QW_FPARAMS_DEF); int32_t qwPrerocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg); -int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t explain, const char* sql); +int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, const char* sql); int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg); int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg); int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg); @@ -38,7 +38,7 @@ int32_t qwBuildAndSendCancelRsp(SRpcHandleInfo *pConn, int32_t code); int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, int32_t dataLength, int32_t code); void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete); int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn); -int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo); +int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx); int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num); void qwFreeFetchRsp(void *msg); int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp); diff --git a/source/libs/qworker/src/qwDbg.c b/source/libs/qworker/src/qwDbg.c index dfe5a04d19..869eedf8f6 100644 --- a/source/libs/qworker/src/qwDbg.c +++ b/source/libs/qworker/src/qwDbg.c @@ -9,7 +9,7 @@ #include "tmsg.h" #include "tname.h" -SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false, .tmp = false}; +SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false, .tmp = true}; int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) { if (!gQWDebug.statusEnable) { diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index ea5aa3c563..73110472f7 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -43,13 +43,16 @@ void qwFreeFetchRsp(void *msg) { } } -int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, STbVerInfo* tbInfo) { +int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx) { + STbVerInfo* tbInfo = ctx ? &ctx->tbInfo : NULL; + int64_t affectedRows = ctx ? ctx->affectedRows : 0; SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp)); - pRsp->code = code; + pRsp->code = htonl(code); + pRsp->affectedRows = htobe64(affectedRows); if (tbInfo) { strcpy(pRsp->tbFName, tbInfo->tbFName); - pRsp->sversion = tbInfo->sversion; - pRsp->tversion = tbInfo->tversion; + pRsp->sversion = htonl(tbInfo->sversion); + pRsp->tversion = htonl(tbInfo->tversion); } SRpcMsg rpcRsp = { @@ -366,10 +369,14 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int int32_t eId = msg->execId; SQWMsg qwMsg = {.node = node, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info, .msgType = pMsg->msgType}; + qwMsg.msgInfo.explain = msg->explain; + qwMsg.msgInfo.taskType = msg->taskType; + qwMsg.msgInfo.needFetch = msg->needFetch; + char * sql = strndup(msg->msg, msg->sqlLen); QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, sql:%s", node, TMSG_INFO(pMsg->msgType), pMsg->info.handle, sql); - QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, msg->taskType, msg->explain, sql)); + QW_ERR_RET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql)); QW_SCH_TASK_DLOG("processQuery end, node:%p", node); return TSDB_CODE_SUCCESS; @@ -447,14 +454,14 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int return TSDB_CODE_SUCCESS; } -int32_t qWorkerProcessFetchRsp(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts) { +int32_t qWorkerProcessRspMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts) { SQWorker * mgmt = (SQWorker *)qWorkerMgmt; if (mgmt) { qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE); - QW_STAT_INC(mgmt->stat.msgStat.fetchRspProcessed, 1); + QW_STAT_INC(mgmt->stat.msgStat.rspProcessed, 1); } - qProcessFetchRsp(NULL, pMsg, NULL); + qProcessRspMsg(NULL, pMsg, NULL); pMsg->pCont = NULL; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 3f8d62b1aa..cf8116fee7 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -57,6 +57,10 @@ int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) { connInfo.ahandle = NULL; QW_ERR_RET(qwBuildAndSendExplainRsp(&connInfo, execInfo, resNum)); } + + if (!ctx->needFetch) { + dsGetDataLength(ctx->sinkHandle, &ctx->affectedRows, NULL); + } } return TSDB_CODE_SUCCESS; @@ -123,11 +127,11 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryEnd) { break; } - if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_READY) && execNum >= QW_DEFAULT_SHORT_RUN_TIMES) { + if (ctx->needFetch && (!ctx->queryRsped) && execNum >= QW_DEFAULT_SHORT_RUN_TIMES) { break; } - if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) { + if (QW_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) { break; } @@ -184,7 +188,7 @@ int32_t qwGenerateSchHbRsp(SQWorker *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo) } int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen, void **rspMsg, SOutputData *pOutput) { - int32_t len = 0; + int64_t len = 0; SRetrieveTableRsp *rsp = NULL; bool queryEnd = false; int32_t code = 0; @@ -243,7 +247,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen, } int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes) { - int32_t len = 0; + int64_t len = 0; bool queryEnd = false; int32_t code = 0; SOutputData output = {0}; @@ -251,7 +255,7 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes dsGetDataLength(ctx->sinkHandle, &len, &queryEnd); if (len <= 0 || len != sizeof(SDeleterRes)) { - QW_TASK_ELOG("invalid length from dsGetDataLength, length:%d", len); + QW_TASK_ELOG("invalid length from dsGetDataLength, length:%" PRId64, len); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } @@ -282,7 +286,6 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *input, SQWPhaseOutput *output) { int32_t code = 0; SQWTaskCtx *ctx = NULL; - SRpcHandleInfo *cancelConnection = NULL; QW_TASK_DLOG("start to handle event at phase %s", qwPhaseStr(phase)); @@ -303,13 +306,13 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu switch (phase) { case QW_PHASE_PRE_QUERY: { - if (QW_IS_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { + if (QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { QW_TASK_ELOG("task already dropped at wrong phase %s", qwPhaseStr(phase)); QW_ERR_JRET(TSDB_CODE_QRY_TASK_STATUS_ERROR); break; } - if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { + if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { QW_ERR_JRET(qwDropTask(QW_FPARAMS())); //qwBuildAndSendDropRsp(&ctx->ctrlConnInfo, code); @@ -323,29 +326,29 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu break; } case QW_PHASE_PRE_FETCH: { - if (QW_IS_EVENT_PROCESSED(ctx, QW_EVENT_DROP) || QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { + if (QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP) || QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { QW_TASK_WLOG("task dropping or already dropped, phase:%s", qwPhaseStr(phase)); QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED); } - if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) { + if (QW_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) { QW_TASK_WLOG("last fetch still not processed, phase:%s", qwPhaseStr(phase)); QW_ERR_JRET(TSDB_CODE_QRY_DUPLICATTED_OPERATION); } - if (!QW_IS_EVENT_PROCESSED(ctx, QW_EVENT_READY)) { + if (!ctx->queryRsped) { QW_TASK_ELOG("ready msg has not been processed, phase:%s", qwPhaseStr(phase)); QW_ERR_JRET(TSDB_CODE_QRY_TASK_MSG_ERROR); } break; } case QW_PHASE_PRE_CQUERY: { - if (QW_IS_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { + if (QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { QW_TASK_WLOG("task already dropped, phase:%s", qwPhaseStr(phase)); QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED); } - if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { + if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { QW_ERR_JRET(qwDropTask(QW_FPARAMS())); //qwBuildAndSendDropRsp(&ctx->ctrlConnInfo, code); @@ -374,11 +377,6 @@ _return: qwReleaseTaskCtx(mgmt, ctx); } - if (cancelConnection) { - qwBuildAndSendCancelRsp(cancelConnection, code); - QW_TASK_DLOG("cancel rsp send, handle:%p, code:%x - %s", cancelConnection->handle, code, tstrerror(code)); - } - if (code != TSDB_CODE_SUCCESS) { QW_TASK_ELOG("end to handle event at phase %s, code:%s", qwPhaseStr(phase), tstrerror(code)); } else { @@ -400,7 +398,7 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp QW_LOCK(QW_WRITE, &ctx->lock); - if (QW_IS_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { + if (QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { QW_TASK_WLOG("task already dropped, phase:%s", qwPhaseStr(phase)); QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED); } @@ -409,10 +407,10 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp connInfo = ctx->ctrlConnInfo; rspConnection = &connInfo; - QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_READY); + ctx->queryRsped = true; } - if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { + if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { if (QW_PHASE_POST_FETCH == phase) { QW_TASK_WLOG("drop received at wrong phase %s", qwPhaseStr(phase)); QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); @@ -440,7 +438,7 @@ _return: } if (rspConnection) { - qwBuildAndSendQueryRsp(input->msgType + 1, rspConnection, code, ctx ? &ctx->tbInfo : NULL); + qwBuildAndSendQueryRsp(input->msgType + 1, rspConnection, code, ctx); QW_TASK_DLOG("query msg rsped, handle:%p, code:%x - %s", rspConnection->handle, code, tstrerror(code)); } @@ -501,7 +499,7 @@ _return: } -int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t explain, const char* sql) { +int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, const char* sql) { int32_t code = 0; bool queryRsped = false; SSubplan *plan = NULL; @@ -514,8 +512,9 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType, int8_t ex QW_ERR_JRET(qwGetTaskCtx(QW_FPARAMS(), &ctx)); - ctx->taskType = taskType; - ctx->explain = explain; + ctx->taskType = qwMsg->msgInfo.taskType; + ctx->explain = qwMsg->msgInfo.explain; + ctx->needFetch = qwMsg->msgInfo.needFetch; ctx->queryType = qwMsg->msgType; QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg); @@ -585,7 +584,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { QW_ERR_JRET(qwExecTask(QW_FPARAMS(), ctx, &queryEnd)); - if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) { + if (QW_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) { SOutputData sOutput = {0}; QW_ERR_JRET(qwGetQueryResFromSink(QW_FPARAMS(), ctx, &dataLen, &rsp, &sOutput)); @@ -622,7 +621,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { break; } - if (code && QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) { + if (code && QW_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) { QW_SET_EVENT_PROCESSED(ctx, QW_EVENT_FETCH); qwFreeFetchRsp(rsp); rsp = NULL; @@ -686,7 +685,7 @@ int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg) { locked = true; // RC WARNING - if (QW_IS_QUERY_RUNNING(ctx)) { + if (QW_QUERY_RUNNING(ctx)) { atomic_store_8((int8_t *)&ctx->queryContinue, 1); } else if (0 == atomic_load_8((int8_t *)&ctx->queryInQueue)) { qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_EXEC); @@ -714,7 +713,7 @@ _return: if (code || rsp) { qwBuildAndSendFetchRsp(qwMsg->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code); - QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code), + QW_TASK_DLOG("%s send, handle:%p, code:%x - %s, dataLen:%d", TMSG_INFO(qwMsg->msgType + 1), qwMsg->connInfo.handle, code, tstrerror(code), dataLen); } @@ -733,12 +732,12 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) { locked = true; - if (QW_IS_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { + if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { QW_TASK_WLOG_E("task already dropping"); QW_ERR_JRET(TSDB_CODE_QRY_DUPLICATTED_OPERATION); } - if (QW_IS_QUERY_RUNNING(ctx)) { + if (QW_QUERY_RUNNING(ctx)) { QW_ERR_JRET(qwKillTaskHandle(QW_FPARAMS(), ctx)); qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_DROP); } else if (ctx->phase > 0) { diff --git a/source/libs/qworker/test/qworkerTests.cpp b/source/libs/qworker/test/qworkerTests.cpp index be54db51de..1f76ea1e7e 100644 --- a/source/libs/qworker/test/qworkerTests.cpp +++ b/source/libs/qworker/test/qworkerTests.cpp @@ -332,7 +332,7 @@ void qwtEndPut(DataSinkHandle handle, uint64_t useconds) { qwtTestSinkQueryEnd = true; } -void qwtGetDataLength(DataSinkHandle handle, int32_t* pLen, bool* pQueryEnd) { +void qwtGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd) { static int32_t in = 0; if (in > 0) { diff --git a/source/libs/scalar/inc/sclInt.h b/source/libs/scalar/inc/sclInt.h index c2d984c7dd..1794d8f5ed 100644 --- a/source/libs/scalar/inc/sclInt.h +++ b/source/libs/scalar/inc/sclInt.h @@ -57,7 +57,7 @@ typedef struct SScalarCtx { #define SCL_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out); -SColumnInfoData* sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows); +int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam); int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode); #define GET_PARAM_TYPE(_c) ((_c)->columnData ? (_c)->columnData->info.type : (_c)->hashValueType) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index a7f66ebb7d..57819db0b8 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -3827,13 +3827,20 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnData SScalarParam output = {0}; SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)}; - output.columnData = sclCreateColumnInfoData(&type, pSrc->info.rows); + int32_t code = sclCreateColumnInfoData(&type, pSrc->info.rows, &output); + if (code != TSDB_CODE_SUCCESS) { + return code; + } SArray *pList = taosArrayInit(1, POINTER_BYTES); taosArrayPush(pList, &pSrc); FLT_ERR_RET(scalarCalculate(info->sclCtx.node, pList, &output)); - *p = (int8_t *)output.columnData->pData; + *p = taosMemoryMalloc(output.numOfRows * sizeof(bool)); + + memcpy(*p, output.columnData->pData, output.numOfRows); + colDataDestroy(output.columnData); + taosMemoryFree(output.columnData); taosArrayDestroy(pList); return false; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index cbb1089d61..2cbe1e5c96 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -35,12 +35,11 @@ int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode) { return TSDB_CODE_SUCCESS; } - -SColumnInfoData* sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows) { +int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam) { SColumnInfoData* pColumnData = taosMemoryCalloc(1, sizeof(SColumnInfoData)); if (pColumnData == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return terrno; } pColumnData->info.type = pType->type; @@ -52,19 +51,25 @@ SColumnInfoData* sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows) { if (code != TSDB_CODE_SUCCESS) { terrno = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pColumnData); - return NULL; - } else { - return pColumnData; + return terrno; } + + pParam->columnData = pColumnData; + pParam->type = SHOULD_FREE_COLDATA; + return TSDB_CODE_SUCCESS; } int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out) { SScalarParam in = {.numOfRows = 1}; - in.columnData = sclCreateColumnInfoData(&pValueNode->node.resType, 1); + int32_t code = sclCreateColumnInfoData(&pValueNode->node.resType, 1, &in); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false); colInfoDataEnsureCapacity(out->columnData, 1); - int32_t code = vectorConvertImpl(&in, out); + code = vectorConvertImpl(&in, out); sclFreeParam(&in); return code; @@ -157,7 +162,7 @@ void sclFreeRes(SHashObj *res) { void sclFreeParam(SScalarParam *param) { if (param->columnData != NULL) { colDataDestroy(param->columnData); - taosMemoryFree(param->columnData); + taosMemoryFreeClear(param->columnData); } if (param->pHashFilter != NULL) { @@ -190,8 +195,9 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t case QUERY_NODE_VALUE: { SValueNode *valueNode = (SValueNode *)node; + ASSERT(param->columnData == NULL); param->numOfRows = 1; - param->columnData = sclCreateColumnInfoData(&valueNode->node.resType, 1); + /*int32_t code = */sclCreateColumnInfoData(&valueNode->node.resType, 1, param); if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type || valueNode->isNull) { colDataAppendNULL(param->columnData, 0); } else { @@ -429,10 +435,9 @@ int32_t sclExecFunction(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outp SCL_ERR_JRET(code); } - output->columnData = sclCreateColumnInfoData(&node->node.resType, rowNum); - if (output->columnData == NULL) { - sclError("calloc %d failed", (int32_t)(rowNum * output->columnData->info.bytes)); - SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + code = sclCreateColumnInfoData(&node->node.resType, rowNum, output); + if (code != TSDB_CODE_SUCCESS) { + SCL_ERR_JRET(code); } code = (*ffpSet.process)(params, paramNum, output); @@ -482,10 +487,9 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o output->numOfRows = rowNum; SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; - output->columnData = sclCreateColumnInfoData(&t, rowNum); - if (output->columnData == NULL) { - sclError("calloc %d failed", (int32_t)(rowNum * sizeof(bool))); - SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + code = sclCreateColumnInfoData(&t, rowNum, output); + if (code != TSDB_CODE_SUCCESS) { + SCL_ERR_JRET(code); } bool value = false; @@ -537,18 +541,19 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp int32_t code = 0; // json not support in in operator - if(nodeType(node->pLeft) == QUERY_NODE_VALUE){ + if (nodeType(node->pLeft) == QUERY_NODE_VALUE) { SValueNode *valueNode = (SValueNode *)node->pLeft; - if(valueNode->node.resType.type == TSDB_DATA_TYPE_JSON && (node->opType == OP_TYPE_IN || node->opType == OP_TYPE_NOT_IN)){ + if (valueNode->node.resType.type == TSDB_DATA_TYPE_JSON && (node->opType == OP_TYPE_IN || node->opType == OP_TYPE_NOT_IN)) { SCL_RET(TSDB_CODE_QRY_JSON_IN_ERROR); } } SCL_ERR_RET(sclInitOperatorParams(¶ms, node, ctx, &rowNum)); - output->columnData = sclCreateColumnInfoData(&node->node.resType, rowNum); if (output->columnData == NULL) { - sclError("calloc failed, size:%d", (int32_t)rowNum * node->node.resType.bytes); - SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + code = sclCreateColumnInfoData(&node->node.resType, rowNum, output); + if (code != TSDB_CODE_SUCCESS) { + SCL_ERR_JRET(code); + } } _bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(node->opType); @@ -563,7 +568,10 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp _return: for (int32_t i = 0; i < paramNum; ++i) { -// sclFreeParam(¶ms[i]); + if (params[i].type == SHOULD_FREE_COLDATA) { + colDataDestroy(params[i].columnData); + taosMemoryFreeClear(params[i].columnData); + } } taosMemoryFreeClear(params); @@ -766,7 +774,7 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { return sclRewriteNonConstOperator(pNode, ctx); } - SScalarParam output = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; + SScalarParam output = {0}; ctx->code = sclExecOperator(node, ctx, &output); if (ctx->code) { return DEAL_RES_ERROR; @@ -834,6 +842,7 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_ERROR; } + output.type = DELEGATED_MGMT_COLDATA; if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; return DEAL_RES_ERROR; @@ -868,6 +877,7 @@ EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_ERROR; } + output.type = DELEGATED_MGMT_COLDATA; if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; return DEAL_RES_ERROR; @@ -1026,7 +1036,8 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) { colDataAssign(pDst->columnData, res->columnData, res->numOfRows, NULL); pDst->numOfRows = res->numOfRows; } - + + sclFreeParam(res); taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); } diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 18bbacd5b7..98cb923b49 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -865,12 +865,11 @@ int32_t vectorGetConvertType(int32_t type1, int32_t type2) { } int32_t vectorConvertScalarParam(SScalarParam *input, SScalarParam *output, int32_t type) { - int32_t code = 0; SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; output->numOfRows = input->numOfRows; - output->columnData = sclCreateColumnInfoData(&t, input->numOfRows); - if (output->columnData == NULL) { + int32_t code = sclCreateColumnInfoData(&t, input->numOfRows, output); + if (code != TSDB_CODE_SUCCESS) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -940,13 +939,12 @@ static int32_t doConvertHelper(SScalarParam* pDest, int32_t* convert, const SSca pDest->numOfRows = pParam->numOfRows; SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; - pDest->columnData = sclCreateColumnInfoData(&t, pParam->numOfRows); - if (pDest->columnData == NULL) { - sclError("malloc %d failed", (int32_t)(pParam->numOfRows * sizeof(double))); - return TSDB_CODE_OUT_OF_MEMORY; + int32_t code = sclCreateColumnInfoData(&t, pParam->numOfRows, pDest); + if (code != TSDB_CODE_SUCCESS) { + return code; } - int32_t code = vectorConvertImpl(pParam, pDest); + code = vectorConvertImpl(pParam, pDest); if (code != TSDB_CODE_SUCCESS) { return code; } diff --git a/source/libs/scalar/test/filter/filterTests.cpp b/source/libs/scalar/test/filter/filterTests.cpp index 8f9332cef8..d8c64eef55 100644 --- a/source/libs/scalar/test/filter/filterTests.cpp +++ b/source/libs/scalar/test/filter/filterTests.cpp @@ -205,13 +205,19 @@ void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) { *pNode = (SNode *)lnode; } +void initScalarParam(SScalarParam* pParam) { + memset(pParam, 0, sizeof(SScalarParam)); + pParam->type = SHOULD_FREE_COLDATA; +} } TEST(timerangeTest, greater) { SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL; bool eRes[5] = {false, false, true, true, true}; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); + int64_t tsmall = 222, tbig = 333; flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall); @@ -234,7 +240,8 @@ TEST(timerangeTest, greater) { TEST(timerangeTest, greater_and_lower) { SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL; bool eRes[5] = {false, false, true, true, true}; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int64_t tsmall = 222, tbig = 333; flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall); @@ -265,7 +272,8 @@ TEST(timerangeTest, greater_and_lower) { TEST(timerangeTest, greater_equal_and_lower_equal) { SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL; bool eRes[5] = {false, false, true, true, true}; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int64_t tsmall = 222, tbig = 333; flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall); @@ -297,7 +305,8 @@ TEST(timerangeTest, greater_equal_and_lower_equal) { TEST(timerangeTest, greater_and_lower_not_strict) { SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode1 = NULL, *logicNode2 = NULL; bool eRes[5] = {false, false, true, true, true}; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int64_t tsmall1 = 222, tbig1 = 333; int64_t tsmall2 = 444, tbig2 = 555; SNode *list[2] = {0}; @@ -350,7 +359,8 @@ TEST(columnTest, smallint_column_greater_double_value) { double rightv= 2.5; int8_t eRes[5] = {0, 0, 1, 1, 1}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv); @@ -405,7 +415,8 @@ TEST(columnTest, int_column_greater_smallint_value) { int16_t rightv= 4; int8_t eRes[5] = {0, 0, 1, 1, 1}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, leftv); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); @@ -460,7 +471,8 @@ TEST(columnTest, int_column_in_double_list) { double rightv1 = 1.1,rightv2 = 2.2,rightv3 = 3.3; bool eRes[5] = {true, true, true, false, false}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, leftv); SNodeList* list = nodesMakeList(); @@ -503,7 +515,8 @@ TEST(columnTest, binary_column_in_binary_list) { SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL; bool eRes[5] = {true, true, false, false, false}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); char leftv[5][5]= {0}; char rightv[3][5]= {0}; for (int32_t i = 0; i < 5; ++i) { @@ -567,7 +580,8 @@ TEST(columnTest, binary_column_like_binary) { char rightv[64] = {0}; char leftv[5][5]= {0}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); bool eRes[5] = {true, false, true, false, true}; for (int32_t i = 0; i < 5; ++i) { @@ -614,7 +628,8 @@ TEST(columnTest, binary_column_is_null) { SNode *pLeft = NULL, *opNode = NULL; char leftv[5][5]= {0}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); bool eRes[5] = {false, false, true, false, true}; for (int32_t i = 0; i < 5; ++i) { @@ -661,7 +676,8 @@ TEST(columnTest, binary_column_is_not_null) { SNode *pLeft = NULL, *opNode = NULL; char leftv[5][5]= {0}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); bool eRes[5] = {true, true, true, true, false}; for (int32_t i = 0; i < 5; ++i) { @@ -710,7 +726,8 @@ TEST(opTest, smallint_column_greater_int_column) { int32_t rightv[5]= {0, -5, -4, 23, 100}; bool eRes[5] = {true, false, true, false, true}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, rightv); @@ -747,7 +764,8 @@ TEST(opTest, smallint_value_add_int_column) { int16_t rightv[5]= {0, -1, -4, -1, 100}; bool eRes[5] = {true, false, true, false, true}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); flttMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, rightv); @@ -790,7 +808,8 @@ TEST(opTest, bigint_column_multi_binary_column) { } bool eRes[5] = {false, true, true, true, true}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), rowNum, leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv); @@ -833,7 +852,8 @@ TEST(opTest, smallint_column_and_binary_column) { } bool eRes[5] = {false, false, true, false, true}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv); @@ -871,7 +891,8 @@ TEST(opTest, smallint_column_or_float_column) { float rightv[5]= {2.0, 3.0, 0, 5.2, 6.0}; bool eRes[5] = {true, true, false, true, true}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_FLOAT, sizeof(float), rowNum, rightv); @@ -909,7 +930,8 @@ TEST(opTest, smallint_column_or_double_value) { double rightv= 10.2; bool eRes[5] = {true, true, true, true, true}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv); @@ -945,7 +967,8 @@ TEST(opTest, binary_column_is_true) { SNode *pLeft = NULL, *opNode = NULL; char leftv[5][5]= {0}; SSDataBlock *src = NULL; - SScalarParam res = {0}; + SScalarParam res; + initScalarParam(&res); bool eRes[5] = {false, true, false, true, false}; for (int32_t i = 0; i < 5; ++i) { diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp index 07440e7435..9b40f0a465 100644 --- a/source/libs/scalar/test/scalar/scalarTests.cpp +++ b/source/libs/scalar/test/scalar/scalarTests.cpp @@ -1092,7 +1092,7 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do printf("op:%s,1result:%f,except:%f\n", gOptrStr[opType].str, *((double *)colDataGetData(column, 0)), exceptValue); ASSERT_TRUE(fabs(*((double *)colDataGetData(column, 0)) - exceptValue) < 0.0001); }else if(opType == OP_TYPE_BIT_AND || opType == OP_TYPE_BIT_OR){ - printf("op:%s,2result:%ld,except:%f\n", gOptrStr[opType].str, *((int64_t *)colDataGetData(column, 0)), exceptValue); + printf("op:%s,2result:%" PRId64 ",except:%f\n", gOptrStr[opType].str, *((int64_t *)colDataGetData(column, 0)), exceptValue); ASSERT_EQ(*((int64_t *)colDataGetData(column, 0)), exceptValue); }else if(opType == OP_TYPE_GREATER_THAN || opType == OP_TYPE_GREATER_EQUAL || opType == OP_TYPE_LOWER_THAN || opType == OP_TYPE_LOWER_EQUAL || opType == OP_TYPE_EQUAL || opType == OP_TYPE_NOT_EQUAL || diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index 7289e4b6be..052fdefa61 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -35,7 +35,6 @@ extern "C" { #define SCH_DEFAULT_TASK_TIMEOUT_USEC 10000000 #define SCH_MAX_TASK_TIMEOUT_USEC 60000000 -#define SCH_TASK_MAX_EXEC_TIMES 8 #define SCH_MAX_CANDIDATE_EP_NUM TSDB_MAX_REPLICA enum { @@ -179,10 +178,10 @@ typedef struct SSchLevel { } SSchLevel; typedef struct SSchTaskProfile { - int64_t startTs; - int64_t execUseTime[SCH_TASK_MAX_EXEC_TIMES]; - int64_t waitTime; - int64_t endTs; + int64_t startTs; + int64_t* execTime; + int64_t waitTime; + int64_t endTs; } SSchTaskProfile; typedef struct SSchTask { @@ -260,33 +259,7 @@ typedef struct SSchJob { extern SSchedulerMgmt schMgmt; -#define SCH_LOG_TASK_START_TS(_task) \ - do { \ - int64_t us = taosGetTimestampUs(); \ - int32_t idx = (_task)->execId % SCH_TASK_MAX_EXEC_TIMES; \ - (_task)->profile.execUseTime[idx] = us; \ - if (0 == (_task)->execId) { \ - (_task)->profile.startTs = us; \ - } \ - } while (0) - -#define SCH_LOG_TASK_WAIT_TS(_task) \ - do { \ - int64_t us = taosGetTimestampUs(); \ - int32_t idx = (_task)->execId % SCH_TASK_MAX_EXEC_TIMES; \ - (_task)->profile.waitTime += us - (_task)->profile.execUseTime[idx]; \ - } while (0) - - -#define SCH_LOG_TASK_END_TS(_task) \ - do { \ - int64_t us = taosGetTimestampUs(); \ - int32_t idx = (_task)->execId % SCH_TASK_MAX_EXEC_TIMES; \ - (_task)->profile.execUseTime[idx] = us - (_task)->profile.execUseTime[idx]; \ - (_task)->profile.endTs = us; \ - } while (0) - -#define SCH_TASK_TIMEOUT(_task) ((taosGetTimestampUs() - (_task)->profile.execUseTime[(_task)->execId % SCH_TASK_MAX_EXEC_TIMES]) > (_task)->timeoutUsec) +#define SCH_TASK_TIMEOUT(_task) ((taosGetTimestampUs() - (_task)->profile.execTime[(_task)->execId % (_task)->maxExecTimes]) > (_task)->timeoutUsec) #define SCH_TASK_READY_FOR_LAUNCH(readyNum, task) ((readyNum) >= taosArrayGetSize((task)->children)) @@ -296,8 +269,8 @@ extern SSchedulerMgmt schMgmt; #define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1) #define SCH_TASK_EID(_task) ((_task) ? (_task)->execId : -1) -#define SCH_IS_DATA_SRC_QRY_TASK(task) ((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) -#define SCH_IS_DATA_SRC_TASK(task) (((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) || ((task)->plan->subplanType == SUBPLAN_TYPE_MODIFY)) +#define SCH_IS_DATA_BIND_QRY_TASK(task) ((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) +#define SCH_IS_DATA_BIND_TASK(task) (((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) || ((task)->plan->subplanType == SUBPLAN_TYPE_MODIFY)) #define SCH_IS_LEAF_TASK(_job, _task) (((_task)->level->level + 1) == (_job)->levelNum) #define SCH_SET_TASK_STATUS(task, st) atomic_store_8(&(task)->status, st) @@ -317,8 +290,10 @@ extern SSchedulerMgmt schMgmt; #define SCH_SET_JOB_NEED_FLOW_CTRL(_job) (_job)->attr.needFlowCtrl = true #define SCH_JOB_NEED_FLOW_CTRL(_job) ((_job)->attr.needFlowCtrl) -#define SCH_TASK_NEED_FLOW_CTRL(_job, _task) (SCH_IS_DATA_SRC_QRY_TASK(_task) && SCH_JOB_NEED_FLOW_CTRL(_job) && SCH_IS_LEVEL_UNFINISHED((_task)->level)) -#define SCH_FETCH_TYPE(_pSrcTask) (SCH_IS_DATA_SRC_QRY_TASK(_pSrcTask) ? TDMT_SCH_FETCH : TDMT_SCH_MERGE_FETCH) +#define SCH_TASK_NEED_FLOW_CTRL(_job, _task) (SCH_IS_DATA_BIND_QRY_TASK(_task) && SCH_JOB_NEED_FLOW_CTRL(_job) && SCH_IS_LEVEL_UNFINISHED((_task)->level)) +#define SCH_FETCH_TYPE(_pSrcTask) (SCH_IS_DATA_BIND_QRY_TASK(_pSrcTask) ? TDMT_SCH_FETCH : TDMT_SCH_MERGE_FETCH) +#define SCH_TASK_NEED_FETCH(_task) ((_task)->plan->subplanType != SUBPLAN_TYPE_MODIFY) +#define SCH_TASK_MAX_EXEC_TIMES(_levelIdx, _levelNum) (SCH_MAX_CANDIDATE_EP_NUM * ((_levelNum) - (_levelIdx))) #define SCH_SET_JOB_TYPE(_job, type) do { if ((type) != SUBPLAN_TYPE_MODIFY) { (_job)->attr.queryJob = true; } } while (0) #define SCH_IS_QUERY_JOB(_job) ((_job)->attr.queryJob) @@ -327,16 +302,43 @@ extern SSchedulerMgmt schMgmt; #define SCH_JOB_NEED_DROP(_job) (SCH_IS_QUERY_JOB(_job)) #define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode) #define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL) -#define SCH_SUB_TASK_NETWORK_ERR(_code, _len) (SCH_NETWORK_ERR(_code) && ((_len) > 0)) -#define SCH_NEED_REDIRECT_MSGTYPE(_msgType) ((_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || (_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH) -#define SCH_NEED_REDIRECT(_msgType, _code, _rspLen) (SCH_NEED_REDIRECT_MSGTYPE(_msgType) && (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_SUB_TASK_NETWORK_ERR(_code, _rspLen))) -#define SCH_NEED_RETRY(_msgType, _code) ((SCH_NETWORK_ERR(_code) && SCH_NEED_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR) +#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) (SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task)))) +#define SCH_REDIRECT_MSGTYPE(_msgType) ((_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || (_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH) +#define SCH_TASK_NEED_REDIRECT(_task, _msgType, _code, _rspLen) (SCH_REDIRECT_MSGTYPE(_msgType) && (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_MERGE_TASK_NETWORK_ERR((_task), (_code), (_rspLen)))) +#define SCH_NEED_RETRY(_msgType, _code) ((SCH_NETWORK_ERR(_code) && SCH_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR) #define SCH_IS_LEVEL_UNFINISHED(_level) ((_level)->taskLaunchedNum < (_level)->taskNum) #define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse]) #define SCH_SWITCH_EPSET(_addr) ((_addr)->epSet.inUse = ((_addr)->epSet.inUse + 1) % (_addr)->epSet.numOfEps) #define SCH_TASK_NUM_OF_EPS(_addr) ((_addr)->epSet.numOfEps) +#define SCH_LOG_TASK_START_TS(_task) \ + do { \ + int64_t us = taosGetTimestampUs(); \ + int32_t idx = (_task)->execId % (_task)->maxExecTimes; \ + (_task)->profile.execTime[idx] = us; \ + if (0 == (_task)->execId) { \ + (_task)->profile.startTs = us; \ + } \ + } while (0) + +#define SCH_LOG_TASK_WAIT_TS(_task) \ + do { \ + int64_t us = taosGetTimestampUs(); \ + int32_t idx = (_task)->execId % (_task)->maxExecTimes; \ + (_task)->profile.waitTime += us - (_task)->profile.execTime[idx]; \ + } while (0) + + +#define SCH_LOG_TASK_END_TS(_task) \ + do { \ + int64_t us = taosGetTimestampUs(); \ + int32_t idx = (_task)->execId % (_task)->maxExecTimes; \ + (_task)->profile.execTime[idx] = us - (_task)->profile.execTime[idx]; \ + (_task)->profile.endTs = us; \ + } while (0) + + #define SCH_JOB_ELOG(param, ...) qError("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__) #define SCH_JOB_DLOG(param, ...) qDebug("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__) @@ -430,7 +432,8 @@ void schFreeTask(SSchJob *pJob, SSchTask *pTask); void schDropTaskInHashList(SSchJob *pJob, SHashObj *list); int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level); int32_t schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask); -int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel); +int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel, int32_t levelNum); +int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask); #ifdef __cplusplus diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 858f68e7ae..d2f9624eee 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -247,7 +247,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { int32_t schAppendJobDataSrc(SSchJob *pJob, SSchTask *pTask) { - if (!SCH_IS_DATA_SRC_QRY_TASK(pTask)) { + if (!SCH_IS_DATA_BIND_QRY_TASK(pTask)) { return TSDB_CODE_SUCCESS; } @@ -337,7 +337,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SCH_SET_JOB_TYPE(pJob, plan->subplanType); SSchTask task = {0}; - SCH_ERR_JRET(schInitTask(pJob, &task, plan, pLevel)); + SCH_ERR_JRET(schInitTask(pJob, &task, plan, pLevel, levelNum)); SSchTask *pTask = taosArrayPush(pLevel->subTasks, &task); if (NULL == pTask) { @@ -879,7 +879,7 @@ int32_t schProcessOnCbBegin(SSchJob** job, SSchTask** task, uint64_t qId, int64_ } if (schJobNeedToStop(pJob, &status)) { - SCH_TASK_ELOG("will not do further processing cause of job status %s", jobTaskStatusStr(status)); + SCH_TASK_DLOG("will not do further processing cause of job status %s", jobTaskStatusStr(status)); SCH_ERR_JRET(TSDB_CODE_SCH_IGNORE_ERROR); } diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index e1035c4fca..2257ba8328 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -21,44 +21,30 @@ #include "tref.h" #include "trpc.h" -int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType) { +int32_t schValidateRspMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType) { int32_t lastMsgType = pTask->lastMsgType; int32_t taskStatus = SCH_GET_TASK_STATUS(pTask); - int32_t reqMsgType = msgType - 1; + int32_t reqMsgType = (msgType & 1U) ? msgType : (msgType - 1); switch (msgType) { case TDMT_SCH_LINK_BROKEN: case TDMT_SCH_EXPLAIN_RSP: return TSDB_CODE_SUCCESS; - case TDMT_SCH_MERGE_QUERY_RSP: - case TDMT_SCH_QUERY_RSP: // query_rsp may be processed later than ready_rsp - if (lastMsgType != reqMsgType && -1 != lastMsgType) { - SCH_TASK_DLOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), - TMSG_INFO(msgType)); - } - - if (taskStatus != JOB_TASK_STATUS_EXEC && taskStatus != JOB_TASK_STATUS_PART_SUCC) { - SCH_TASK_DLOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), - TMSG_INFO(msgType)); - } - - // SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); - return TSDB_CODE_SUCCESS; case TDMT_SCH_FETCH_RSP: case TDMT_SCH_MERGE_FETCH_RSP: - if (lastMsgType != reqMsgType && -1 != lastMsgType) { + if (lastMsgType != reqMsgType) { SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); - } - - if (taskStatus != JOB_TASK_STATUS_EXEC && taskStatus != JOB_TASK_STATUS_PART_SUCC) { + } + if (taskStatus != JOB_TASK_STATUS_PART_SUCC) { SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - // SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); return TSDB_CODE_SUCCESS; + case TDMT_SCH_MERGE_QUERY_RSP: + case TDMT_SCH_QUERY_RSP: case TDMT_VND_CREATE_TABLE_RSP: case TDMT_VND_DROP_TABLE_RSP: case TDMT_VND_ALTER_TABLE_RSP: @@ -77,14 +63,12 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - if (taskStatus != JOB_TASK_STATUS_EXEC && taskStatus != JOB_TASK_STATUS_PART_SUCC) { + if (taskStatus != JOB_TASK_STATUS_EXEC) { SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - // SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); - return TSDB_CODE_SUCCESS; } @@ -98,10 +82,10 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || SCH_NETWORK_ERR(rspCode)); SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, execId)); - SCH_ERR_JRET(schValidateReceivedMsgType(pJob, pTask, msgType)); + SCH_ERR_JRET(schValidateRspMsgType(pJob, pTask, msgType)); int32_t reqType = IsReq(pMsg) ? pMsg->msgType : (pMsg->msgType - 1); - if (SCH_NEED_REDIRECT(reqType, rspCode, pMsg->len)) { + if (SCH_TASK_NEED_REDIRECT(pTask, reqType, rspCode, pMsg->len)) { SCH_RET(schHandleRedirect(pJob, pTask, (SDataBuf *)pMsg, rspCode)); } @@ -259,18 +243,25 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa } case TDMT_SCH_QUERY_RSP: case TDMT_SCH_MERGE_QUERY_RSP: { - SQueryTableRsp *rsp = (SQueryTableRsp *)msg; - SCH_ERR_JRET(rspCode); if (NULL == msg) { SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } + + SQueryTableRsp *rsp = (SQueryTableRsp *)msg; + rsp->code = ntohl(rsp->code); + rsp->sversion = ntohl(rsp->sversion); + rsp->tversion = ntohl(rsp->tversion); + rsp->affectedRows = be64toh(rsp->affectedRows); + SCH_ERR_JRET(rsp->code); SCH_ERR_JRET(schSaveJobQueryRes(pJob, rsp)); - taosMemoryFreeClear(msg); + atomic_add_fetch_32(&pJob->resNumOfRows, rsp->affectedRows); + taosMemoryFreeClear(msg); + SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); break; @@ -1010,6 +1001,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, pMsg->execId = htonl(pTask->execId); pMsg->taskType = TASK_TYPE_TEMP; pMsg->explain = SCH_IS_EXPLAIN_JOB(pJob); + pMsg->needFetch = SCH_TASK_NEED_FETCH(pTask); pMsg->phyLen = htonl(pTask->msgLen); pMsg->sqlLen = htonl(len); diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index 45cb0ab935..e1e4ed8769 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -46,21 +46,31 @@ void schFreeTask(SSchJob *pJob, SSchTask *pTask) { } -int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel) { +int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel, int32_t levelNum) { + int32_t code = 0; + pTask->plan = pPlan; pTask->level = pLevel; pTask->execId = -1; - pTask->maxExecTimes = SCH_TASK_MAX_EXEC_TIMES; + pTask->maxExecTimes = SCH_TASK_MAX_EXEC_TIMES(pLevel->level, levelNum); pTask->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC; - SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_INIT); pTask->taskId = schGenTaskId(); pTask->execNodes = taosHashInit(SCH_MAX_CANDIDATE_EP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); - if (NULL == pTask->execNodes) { - SCH_TASK_ELOG("taosHashInit %d execNodes failed", SCH_MAX_CANDIDATE_EP_NUM); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + pTask->profile.execTime = taosMemoryCalloc(pTask->maxExecTimes, sizeof(int64_t)); + if (NULL == pTask->execNodes || NULL == pTask->profile.execTime) { + SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } + SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_INIT); + return TSDB_CODE_SUCCESS; + +_return: + + taosMemoryFreeClear(pTask->profile.execTime); + taosHashCleanup(pTask->execNodes); + + SCH_RET(code); } int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask) { @@ -276,7 +286,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) { } int32_t schRescheduleTask(SSchJob *pJob, SSchTask *pTask) { - if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) { + if (SCH_IS_DATA_BIND_TASK(pTask)) { return TSDB_CODE_SUCCESS; } @@ -313,7 +323,7 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32 pTask->lastMsgType = 0; memset(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr)); - if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) { + if (SCH_IS_DATA_BIND_TASK(pTask)) { if (pData) { SCH_ERR_JRET(schUpdateTaskCandidateAddr(pJob, pTask, pData->pEpSet)); } @@ -338,6 +348,11 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32 qClearSubplanExecutionNode(pTask->plan); + // Note: current error task and upper level merge task + if ((pData && 0 == pData->len) || NULL == pData) { + SCH_ERR_JRET(schSwitchTaskCandidateAddr(pJob, pTask)); + } + SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_INIT); int32_t childrenNum = taosArrayGetSize(pTask->children); @@ -358,7 +373,7 @@ _return: int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32_t rspCode) { int32_t code = 0; - if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) { + if (SCH_IS_DATA_BIND_TASK(pTask)) { if (NULL == pData->pEpSet) { SCH_TASK_ELOG("no epset updated while got error %s", tstrerror(rspCode)); SCH_ERR_JRET(rspCode); @@ -492,7 +507,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo return TSDB_CODE_SUCCESS; } - if (SCH_IS_DATA_SRC_TASK(pTask)) { + if (SCH_IS_DATA_BIND_TASK(pTask)) { if ((pTask->execId + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) { *needRetry = false; SCH_TASK_DLOG("task no more retry since all ep tried, execId:%d, epNum:%d", pTask->execId, @@ -528,13 +543,10 @@ int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) { schDeregisterTaskHb(pJob, pTask); - if (SCH_IS_DATA_SRC_TASK(pTask)) { + if (SCH_IS_DATA_BIND_TASK(pTask)) { SCH_SWITCH_EPSET(&pTask->plan->execNode); } else { - int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs); - if (++pTask->candidateIdx >= candidateNum) { - pTask->candidateIdx = 0; - } + SCH_ERR_RET(schSwitchTaskCandidateAddr(pJob, pTask)); } SCH_ERR_RET(schLaunchTask(pJob, pTask)); @@ -596,7 +608,7 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) { return TSDB_CODE_SUCCESS; } - if (SCH_IS_DATA_SRC_QRY_TASK(pTask)) { + if (SCH_IS_DATA_BIND_TASK(pTask)) { SCH_TASK_ELOG("no execNode specifed for data src task, numOfEps:%d", pTask->plan->execNode.epSet.numOfEps); SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } @@ -633,6 +645,16 @@ int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet* pEpSe return TSDB_CODE_SUCCESS; } +int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask) { + int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs); + if (++pTask->candidateIdx >= candidateNum) { + pTask->candidateIdx = 0; + } + SCH_TASK_DLOG("switch task candiateIdx to %d", pTask->candidateIdx); + return TSDB_CODE_SUCCESS; +} + + int32_t schRemoveTaskFromExecList(SSchJob *pJob, SSchTask *pTask) { int32_t code = taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId)); diff --git a/source/libs/sync/inc/syncOnMessage.h b/source/libs/sync/inc/syncOnMessage.h deleted file mode 100644 index 2f8856e652..0000000000 --- a/source/libs/sync/inc/syncOnMessage.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_LIBS_SYNC_ON_MESSAGE_H -#define _TD_LIBS_SYNC_ON_MESSAGE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include "taosdef.h" - -// TLA+ Spec -// Receive(m) == -// LET i == m.mdest -// j == m.msource -// IN \* Any RPC with a newer term causes the recipient to advance -// \* its term first. Responses with stale terms are ignored. -// \/ UpdateTerm(i, j, m) -// \/ /\ m.mtype = RequestVoteRequest -// /\ HandleRequestVoteRequest(i, j, m) -// \/ /\ m.mtype = RequestVoteResponse -// /\ \/ DropStaleResponse(i, j, m) -// \/ HandleRequestVoteResponse(i, j, m) -// \/ /\ m.mtype = AppendEntriesRequest -// /\ HandleAppendEntriesRequest(i, j, m) -// \/ /\ m.mtype = AppendEntriesResponse -// /\ \/ DropStaleResponse(i, j, m) -// \/ HandleAppendEntriesResponse(i, j, m) - -// DuplicateMessage(m) == -// /\ Send(m) -// /\ UNCHANGED <> - -// DropMessage(m) == -// /\ Discard(m) -// /\ UNCHANGED <> - -// Next == /\ \/ \E i \in Server : Restart(i) -// \/ \E i \in Server : Timeout(i) -// \/ \E i,j \in Server : RequestVote(i, j) -// \/ \E i \in Server : BecomeLeader(i) -// \/ \E i \in Server, v \in Value : ClientRequest(i, v) -// \/ \E i \in Server : AdvanceCommitIndex(i) -// \/ \E i,j \in Server : AppendEntries(i, j) -// \/ \E m \in DOMAIN messages : Receive(m) -// \/ \E m \in DOMAIN messages : DuplicateMessage(m) -// \/ \E m \in DOMAIN messages : DropMessage(m) -// \* History variable that tracks every log ever: -// /\ allLogs' = allLogs \cup {log[i] : i \in Server} -// - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_LIBS_SYNC_ON_MESSAGE_H*/ diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 2d511b6003..8409e1c711 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -131,7 +131,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { SSyncRaftEntry* pEntry = ths->pLogStore->getEntry(ths->pLogStore, pMsg->prevLogIndex); if (pEntry == NULL) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "getEntry error, index:%ld, since %s", pMsg->prevLogIndex, terrstr()); + snprintf(logBuf, sizeof(logBuf), "getEntry error, index:%" PRId64 ", since %s", pMsg->prevLogIndex, terrstr()); syncNodeErrorLog(ths, logBuf); return -1; } @@ -150,7 +150,8 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { ((pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) && !logOK)) { do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, reject, pre-index:%ld, pre-term:%lu, datalen:%d", + snprintf(logBuf, sizeof(logBuf), + "recv sync-append-entries, reject, pre-index:%" PRId64 ", pre-term:%" PRIu64 ", datalen:%d", pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen); syncNodeEventLog(ths, logBuf); } while (0); @@ -162,6 +163,16 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { pReply->success = false; pReply->matchIndex = SYNC_INDEX_INVALID; + // msg event log + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(pReply->destId.addr, host, sizeof(host), &port); + sDebug("vgId:%d, send sync-append-entries-reply to %s:%d, {term:%" PRIu64 ", pterm:%" PRIu64 + ", success:%d, match-index:%" PRId64 "}", + ths->vgId, host, port, pReply->term, pReply->privateTerm, pReply->success, pReply->matchIndex); + } while (0); + SRpcMsg rpcMsg; syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); @@ -183,7 +194,8 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, accept, pre-index:%ld, pre-term:%lu, datalen:%d", + snprintf(logBuf, sizeof(logBuf), + "recv sync-append-entries, accept, pre-index:%" PRId64 ", pre-term:%" PRIu64 ", datalen:%d", pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen); syncNodeEventLog(ths, logBuf); } while (0); @@ -196,7 +208,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { SSyncRaftEntry* pExtraEntry = ths->pLogStore->getEntry(ths->pLogStore, extraIndex); if (pExtraEntry == NULL) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "getEntry error2, index:%ld, since %s", extraIndex, terrstr()); + snprintf(logBuf, sizeof(logBuf), "getEntry error2, index:%" PRId64 ", since %s", extraIndex, terrstr()); syncNodeErrorLog(ths, logBuf); return -1; } @@ -218,7 +230,8 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { SyncIndex delBegin = ths->pLogStore->getLastIndex(ths->pLogStore); SyncIndex delEnd = extraIndex; - sTrace("syncNodeOnAppendEntriesCb --> conflict:%d, delBegin:%ld, delEnd:%ld", conflict, delBegin, delEnd); + sTrace("syncNodeOnAppendEntriesCb --> conflict:%d, delBegin:%" PRId64 ", delEnd:%" PRId64, conflict, delBegin, + delEnd); // notice! reverse roll back! for (SyncIndex index = delEnd; index >= delBegin; --index) { @@ -226,7 +239,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { SSyncRaftEntry* pRollBackEntry = ths->pLogStore->getEntry(ths->pLogStore, index); if (pRollBackEntry == NULL) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "getEntry error3, index:%ld, since %s", index, terrstr()); + snprintf(logBuf, sizeof(logBuf), "getEntry error3, index:%" PRId64 ", since %s", index, terrstr()); syncNodeErrorLog(ths, logBuf); return -1; } @@ -334,270 +347,15 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { pReply->matchIndex = pMsg->prevLogIndex; } - SRpcMsg rpcMsg; - syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); - syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); - syncAppendEntriesReplyDestroy(pReply); - - // maybe update commit index from leader - if (pMsg->commitIndex > ths->commitIndex) { - // has commit entry in local - if (pMsg->commitIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) { - SyncIndex beginIndex = ths->commitIndex + 1; - SyncIndex endIndex = pMsg->commitIndex; - - // update commit index - ths->commitIndex = pMsg->commitIndex; - - // call back Wal - ths->pLogStore->updateCommitIndex(ths->pLogStore, ths->commitIndex); - - int32_t code = syncNodeCommit(ths, beginIndex, endIndex, ths->state); - ASSERT(code == 0); - } - } - } - - return ret; -} - -#if 0 - -int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { - int32_t ret = 0; - - char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "==syncNodeOnAppendEntriesCb== term:%lu", ths->pRaftStore->currentTerm); - syncAppendEntriesLog2(logBuf, pMsg); - - if (pMsg->term > ths->pRaftStore->currentTerm) { - syncNodeUpdateTerm(ths, pMsg->term); - } - ASSERT(pMsg->term <= ths->pRaftStore->currentTerm); - - // reset elect timer - if (pMsg->term == ths->pRaftStore->currentTerm) { - ths->leaderCache = pMsg->srcId; - syncNodeResetElectTimer(ths); - } - ASSERT(pMsg->dataLen >= 0); - - SyncTerm localPreLogTerm = 0; - if (pMsg->prevLogIndex >= SYNC_INDEX_BEGIN && pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) { - SSyncRaftEntry* pEntry = ths->pLogStore->getEntry(ths->pLogStore, pMsg->prevLogIndex); - if (pEntry == NULL) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "getEntry error, index:%ld, since %s", pMsg->prevLogIndex, terrstr()); - syncNodeErrorLog(ths, logBuf); - return -1; - } - - localPreLogTerm = pEntry->term; - syncEntryDestory(pEntry); - } - - bool logOK = - (pMsg->prevLogIndex == SYNC_INDEX_INVALID) || - ((pMsg->prevLogIndex >= SYNC_INDEX_BEGIN) && - (pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) && (pMsg->prevLogTerm == localPreLogTerm)); - - // reject request - if ((pMsg->term < ths->pRaftStore->currentTerm) || - ((pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) && !logOK)) { - sTrace( - "syncNodeOnAppendEntriesCb --> reject, pMsg->term:%lu, ths->pRaftStore->currentTerm:%lu, ths->state:%d, " - "logOK:%d", - pMsg->term, ths->pRaftStore->currentTerm, ths->state, logOK); - - SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId); - pReply->srcId = ths->myRaftId; - pReply->destId = pMsg->srcId; - pReply->term = ths->pRaftStore->currentTerm; - pReply->success = false; - pReply->matchIndex = SYNC_INDEX_INVALID; - - SRpcMsg rpcMsg; - syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); - syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); - syncAppendEntriesReplyDestroy(pReply); - - return ret; - } - - // return to follower state - if (pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_CANDIDATE) { - sTrace( - "syncNodeOnAppendEntriesCb --> return to follower, pMsg->term:%lu, ths->pRaftStore->currentTerm:%lu, " - "ths->state:%d, logOK:%d", - pMsg->term, ths->pRaftStore->currentTerm, ths->state, logOK); - - syncNodeBecomeFollower(ths, "from candidate by append entries"); - - // ret or reply? - return ret; - } - - // accept request - if (pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_FOLLOWER && logOK) { - // preIndex = -1, or has preIndex entry in local log - ASSERT(pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)); - - // has extra entries (> preIndex) in local log - bool hasExtraEntries = pMsg->prevLogIndex < ths->pLogStore->getLastIndex(ths->pLogStore); - - // has entries in SyncAppendEntries msg - bool hasAppendEntries = pMsg->dataLen > 0; - - sTrace( - "syncNodeOnAppendEntriesCb --> accept, pMsg->term:%lu, ths->pRaftStore->currentTerm:%lu, ths->state:%d, " - "logOK:%d, hasExtraEntries:%d, hasAppendEntries:%d", - pMsg->term, ths->pRaftStore->currentTerm, ths->state, logOK, hasExtraEntries, hasAppendEntries); - - if (hasExtraEntries && hasAppendEntries) { - // not conflict by default - bool conflict = false; - - SyncIndex extraIndex = pMsg->prevLogIndex + 1; - SSyncRaftEntry* pExtraEntry = ths->pLogStore->getEntry(ths->pLogStore, extraIndex); - if (pExtraEntry == NULL) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "getEntry error2, index:%ld, since %s", extraIndex, terrstr()); - syncNodeErrorLog(ths, logBuf); - return -1; - } - - SSyncRaftEntry* pAppendEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen); - if (pAppendEntry == NULL) { - syncNodeErrorLog(ths, "syncEntryDeserialize pAppendEntry error"); - return -1; - } - - // log not match, conflict - ASSERT(extraIndex == pAppendEntry->index); - if (pExtraEntry->term != pAppendEntry->term) { - conflict = true; - } - - if (conflict) { - // roll back - SyncIndex delBegin = ths->pLogStore->getLastIndex(ths->pLogStore); - SyncIndex delEnd = extraIndex; - - sTrace("syncNodeOnAppendEntriesCb --> conflict:%d, delBegin:%ld, delEnd:%ld", conflict, delBegin, delEnd); - - // notice! reverse roll back! - for (SyncIndex index = delEnd; index >= delBegin; --index) { - if (ths->pFsm->FpRollBackCb != NULL) { - SSyncRaftEntry* pRollBackEntry = ths->pLogStore->getEntry(ths->pLogStore, index); - if (pRollBackEntry == NULL) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "getEntry error3, index:%ld, since %s", index, terrstr()); - syncNodeErrorLog(ths, logBuf); - return -1; - } - - // if (pRollBackEntry->msgType != TDMT_SYNC_NOOP) { - if (syncUtilUserRollback(pRollBackEntry->msgType)) { - SRpcMsg rpcMsg; - syncEntry2OriginalRpc(pRollBackEntry, &rpcMsg); - - SFsmCbMeta cbMeta = {0}; - cbMeta.index = pRollBackEntry->index; - cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); - cbMeta.isWeak = pRollBackEntry->isWeak; - cbMeta.code = 0; - cbMeta.state = ths->state; - cbMeta.seqNum = pRollBackEntry->seqNum; - ths->pFsm->FpRollBackCb(ths->pFsm, &rpcMsg, cbMeta); - rpcFreeCont(rpcMsg.pCont); - } - - syncEntryDestory(pRollBackEntry); - } - } - - // delete confict entries - ths->pLogStore->truncate(ths->pLogStore, extraIndex); - - // append new entries - ths->pLogStore->appendEntry(ths->pLogStore, pAppendEntry); - - // pre commit - SRpcMsg rpcMsg; - syncEntry2OriginalRpc(pAppendEntry, &rpcMsg); - if (ths->pFsm != NULL) { - // if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) { - if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pAppendEntry->originalRpcType)) { - SFsmCbMeta cbMeta = {0}; - cbMeta.index = pAppendEntry->index; - cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); - cbMeta.isWeak = pAppendEntry->isWeak; - cbMeta.code = 2; - cbMeta.state = ths->state; - cbMeta.seqNum = pAppendEntry->seqNum; - ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, cbMeta); - } - } - rpcFreeCont(rpcMsg.pCont); - } - - // free memory - syncEntryDestory(pExtraEntry); - syncEntryDestory(pAppendEntry); - - } else if (hasExtraEntries && !hasAppendEntries) { - // do nothing - - } else if (!hasExtraEntries && hasAppendEntries) { - SSyncRaftEntry* pAppendEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen); - if (pAppendEntry == NULL) { - syncNodeErrorLog(ths, "syncEntryDeserialize pAppendEntry2 error"); - return -1; - } - - // append new entries - ths->pLogStore->appendEntry(ths->pLogStore, pAppendEntry); - - // pre commit - SRpcMsg rpcMsg; - syncEntry2OriginalRpc(pAppendEntry, &rpcMsg); - if (ths->pFsm != NULL) { - // if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) { - if (ths->pFsm->FpPreCommitCb != NULL && syncUtilUserPreCommit(pAppendEntry->originalRpcType)) { - SFsmCbMeta cbMeta = {0}; - cbMeta.index = pAppendEntry->index; - cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); - cbMeta.isWeak = pAppendEntry->isWeak; - cbMeta.code = 3; - cbMeta.state = ths->state; - cbMeta.seqNum = pAppendEntry->seqNum; - ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, cbMeta); - } - } - rpcFreeCont(rpcMsg.pCont); - - // free memory - syncEntryDestory(pAppendEntry); - - } else if (!hasExtraEntries && !hasAppendEntries) { - // do nothing - - } else { - syncNodeLog3("", ths); - ASSERT(0); - } - - SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId); - pReply->srcId = ths->myRaftId; - pReply->destId = pMsg->srcId; - pReply->term = ths->pRaftStore->currentTerm; - pReply->success = true; - - if (hasAppendEntries) { - pReply->matchIndex = pMsg->prevLogIndex + 1; - } else { - pReply->matchIndex = pMsg->prevLogIndex; - } + // msg event log + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(pReply->destId.addr, host, sizeof(host), &port); + sDebug("vgId:%d, send sync-append-entries-reply to %s:%d, {term:%" PRIu64 ", pterm:%" PRIu64 + ", success:%d, match-index:%" PRId64 "}", + ths->vgId, host, port, pReply->term, pReply->privateTerm, pReply->success, pReply->matchIndex); + } while (0); SRpcMsg rpcMsg; syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); @@ -626,8 +384,6 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { return ret; } -#endif - static int32_t syncNodeMakeLogSame(SSyncNode* ths, SyncAppendEntries* pMsg) { int32_t code; @@ -666,7 +422,7 @@ static int32_t syncNodeMakeLogSame(SSyncNode* ths, SyncAppendEntries* pMsg) { ASSERT(code == 0); char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "log truncate, from %ld to %ld", delBegin, delEnd); + snprintf(eventLog, sizeof(eventLog), "log truncate, from %" PRId64 " to %" PRId64, delBegin, delEnd); syncNodeEventLog(ths, eventLog); logStoreSimpleLog2("after syncNodeMakeLogSame", ths->pLogStore); @@ -711,7 +467,7 @@ static int32_t syncNodeDoMakeLogSame(SSyncNode* ths, SyncIndex FromIndex) { ASSERT(code == 0); char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "log truncate, from %ld to %ld", delBegin, delEnd); + snprintf(eventLog, sizeof(eventLog), "log truncate, from %" PRId64 " to %" PRId64, delBegin, delEnd); syncNodeEventLog(ths, eventLog); logStoreSimpleLog2("after syncNodeMakeLogSame", ths->pLogStore); @@ -744,13 +500,13 @@ static bool syncNodeOnAppendEntriesBatchLogOK(SSyncNode* pSyncNode, SyncAppendEn SyncIndex myLastIndex = syncNodeGetLastIndex(pSyncNode); if (pMsg->prevLogIndex > myLastIndex) { - sDebug("vgId:%d sync log not ok, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex); + sDebug("vgId:%d sync log not ok, preindex:%" PRId64, pSyncNode->vgId, pMsg->prevLogIndex); return false; } SyncTerm myPreLogTerm = syncNodeGetPreTerm(pSyncNode, pMsg->prevLogIndex + 1); if (myPreLogTerm == SYNC_TERM_INVALID) { - sDebug("vgId:%d sync log not ok2, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex); + sDebug("vgId:%d sync log not ok2, preindex:%" PRId64, pSyncNode->vgId, pMsg->prevLogIndex); return false; } @@ -758,7 +514,7 @@ static bool syncNodeOnAppendEntriesBatchLogOK(SSyncNode* pSyncNode, SyncAppendEn return true; } - sDebug("vgId:%d sync log not ok3, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex); + sDebug("vgId:%d sync log not ok3, preindex:%" PRId64, pSyncNode->vgId, pMsg->prevLogIndex); return false; } @@ -771,13 +527,13 @@ static bool syncNodeOnAppendEntriesLogOK(SSyncNode* pSyncNode, SyncAppendEntries SyncIndex myLastIndex = syncNodeGetLastIndex(pSyncNode); if (pMsg->prevLogIndex > myLastIndex) { - sDebug("vgId:%d sync log not ok, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex); + sDebug("vgId:%d sync log not ok, preindex:%" PRId64, pSyncNode->vgId, pMsg->prevLogIndex); return false; } SyncTerm myPreLogTerm = syncNodeGetPreTerm(pSyncNode, pMsg->prevLogIndex + 1); if (myPreLogTerm == SYNC_TERM_INVALID) { - sDebug("vgId:%d sync log not ok2, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex); + sDebug("vgId:%d sync log not ok2, preindex:%" PRId64, pSyncNode->vgId, pMsg->prevLogIndex); return false; } @@ -785,7 +541,7 @@ static bool syncNodeOnAppendEntriesLogOK(SSyncNode* pSyncNode, SyncAppendEntries return true; } - sDebug("vgId:%d sync log not ok3, preindex:%ld", pSyncNode->vgId, pMsg->prevLogIndex); + sDebug("vgId:%d sync log not ok3, preindex:%" PRId64, pSyncNode->vgId, pMsg->prevLogIndex); return false; } @@ -842,7 +598,8 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc do { char logBuf[128]; snprintf(logBuf, sizeof(logBuf), - "recv sync-append-entries-batch, fake match2, {pre-index:%ld, pre-term:%lu, datalen:%d, datacount:%d}", + "recv sync-append-entries-batch, fake match2, {pre-index:%" PRId64 ", pre-term:%" PRIu64 + ", datalen:%d, datacount:%d}", pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen, pMsg->dataCount); syncNodeEventLog(ths, logBuf); } while (0); @@ -897,6 +654,16 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc pReply->success = true; pReply->matchIndex = matchIndex; + // msg event log + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(pReply->destId.addr, host, sizeof(host), &port); + sDebug("vgId:%d, send sync-append-entries-reply to %s:%d, {term:%" PRIu64 ", pterm:%" PRIu64 + ", success:%d, match-index:%" PRId64 "}", + ths->vgId, host, port, pReply->term, pReply->privateTerm, pReply->success, pReply->matchIndex); + } while (0); + // send response SRpcMsg rpcMsg; syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); @@ -931,7 +698,8 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc do { char logBuf[128]; snprintf(logBuf, sizeof(logBuf), - "recv sync-append-entries-batch, not match, {pre-index:%ld, pre-term:%lu, datalen:%d, datacount:%d}", + "recv sync-append-entries-batch, not match, {pre-index:%" PRId64 ", pre-term:%" PRIu64 + ", datalen:%d, datacount:%d}", pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen, pMsg->dataCount); syncNodeEventLog(ths, logBuf); } while (0); @@ -945,6 +713,16 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc pReply->success = false; pReply->matchIndex = SYNC_INDEX_INVALID; + // msg event log + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(pReply->destId.addr, host, sizeof(host), &port); + sDebug("vgId:%d, send sync-append-entries-reply to %s:%d, {term:%" PRIu64 ", pterm:%" PRIu64 + ", success:%d, match-index:%" PRId64 "}", + ths->vgId, host, port, pReply->term, pReply->privateTerm, pReply->success, pReply->matchIndex); + } while (0); + // send response SRpcMsg rpcMsg; syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); @@ -977,7 +755,8 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc do { char logBuf[128]; snprintf(logBuf, sizeof(logBuf), - "recv sync-append-entries, match, {pre-index:%ld, pre-term:%lu, datalen:%d, datacount:%d}", + "recv sync-append-entries-batch, match, {pre-index:%" PRId64 ", pre-term:%" PRIu64 + ", datalen:%d, datacount:%d}", pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen, pMsg->dataCount); syncNodeEventLog(ths, logBuf); } while (0); @@ -1018,6 +797,16 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc pReply->success = true; pReply->matchIndex = hasAppendEntries ? pMsg->prevLogIndex + pMsg->dataCount : pMsg->prevLogIndex; + // msg event log + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(pReply->destId.addr, host, sizeof(host), &port); + sDebug("vgId:%d, send sync-append-entries-reply to %s:%d, {term:%" PRIu64 ", pterm:%" PRIu64 + ", success:%d, match-index:%" PRId64 "}", + ths->vgId, host, port, pReply->term, pReply->privateTerm, pReply->success, pReply->matchIndex); + } while (0); + // send response SRpcMsg rpcMsg; syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); @@ -1037,8 +826,8 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc ths->commitIndex = snapshot.lastApplyIndex; char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "commit by snapshot from index:%ld to index:%ld", commitBegin, - commitEnd); + snprintf(eventLog, sizeof(eventLog), "commit by snapshot from index:%" PRId64 " to index:%" PRId64, + commitBegin, commitEnd); syncNodeEventLog(ths, eventLog); } @@ -1139,7 +928,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs if (condition) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, fake match, pre-index:%ld, pre-term:%lu", + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, fake match, pre-index:%" PRId64 ", pre-term:%" PRIu64, pMsg->prevLogIndex, pMsg->prevLogTerm); syncNodeEventLog(ths, logBuf); @@ -1179,8 +968,8 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs do { char logBuf[128]; snprintf(logBuf, sizeof(logBuf), - "recv sync-append-entries, fake match2, pre-index:%ld, pre-term:%lu, datalen:%d", pMsg->prevLogIndex, - pMsg->prevLogTerm, pMsg->dataLen); + "recv sync-append-entries, fake match2, pre-index:%" PRId64 ", pre-term:%" PRIu64 ", datalen:%d", + pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen); syncNodeEventLog(ths, logBuf); } while (0); @@ -1227,6 +1016,16 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs pReply->success = true; pReply->matchIndex = matchIndex; + // msg event log + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(pReply->destId.addr, host, sizeof(host), &port); + sDebug("vgId:%d, send sync-append-entries-reply to %s:%d, {term:%" PRIu64 ", pterm:%" PRIu64 + ", success:%d, match-index:%" PRId64 "}", + ths->vgId, host, port, pReply->term, pReply->privateTerm, pReply->success, pReply->matchIndex); + } while (0); + // send response SRpcMsg rpcMsg; syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); @@ -1259,7 +1058,8 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs if (condition) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, not match, pre-index:%ld, pre-term:%lu, datalen:%d", + snprintf(logBuf, sizeof(logBuf), + "recv sync-append-entries, not match, pre-index:%" PRId64 ", pre-term:%" PRIu64 ", datalen:%d", pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen); syncNodeEventLog(ths, logBuf); @@ -1272,6 +1072,16 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs pReply->success = false; pReply->matchIndex = SYNC_INDEX_INVALID; + // msg event log + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(pReply->destId.addr, host, sizeof(host), &port); + sDebug("vgId:%d, send sync-append-entries-reply to %s:%d, {term:%" PRIu64 ", pterm:%" PRIu64 + ", success:%d, match-index:%" PRId64 "}", + ths->vgId, host, port, pReply->term, pReply->privateTerm, pReply->success, pReply->matchIndex); + } while (0); + // send response SRpcMsg rpcMsg; syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); @@ -1301,7 +1111,8 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs bool hasAppendEntries = pMsg->dataLen > 0; char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, match, pre-index:%ld, pre-term:%lu, datalen:%d", + snprintf(logBuf, sizeof(logBuf), + "recv sync-append-entries, match, pre-index:%" PRId64 ", pre-term:%" PRIu64 ", datalen:%d", pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen); syncNodeEventLog(ths, logBuf); @@ -1337,6 +1148,16 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs pReply->success = true; pReply->matchIndex = hasAppendEntries ? pMsg->prevLogIndex + 1 : pMsg->prevLogIndex; + // msg event log + do { + char host[128]; + uint16_t port; + syncUtilU642Addr(pReply->destId.addr, host, sizeof(host), &port); + sDebug("vgId:%d, send sync-append-entries-reply to %s:%d, {term:%" PRIu64 ", pterm:%" PRIu64 + ", success:%d, match-index:%" PRId64 "}", + ths->vgId, host, port, pReply->term, pReply->privateTerm, pReply->success, pReply->matchIndex); + } while (0); + // send response SRpcMsg rpcMsg; syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); @@ -1356,8 +1177,8 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs ths->commitIndex = snapshot.lastApplyIndex; char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "commit by snapshot from index:%ld to index:%ld", commitBegin, - commitEnd); + snprintf(eventLog, sizeof(eventLog), "commit by snapshot from index:%" PRId64 " to index:%" PRId64, + commitBegin, commitEnd); syncNodeEventLog(ths, eventLog); } diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 3f19b6759e..153f18da86 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -52,7 +52,8 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p // drop stale response if (pMsg->term < ths->pRaftStore->currentTerm) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, recv-term:%lu, drop stale response", pMsg->term); + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, recv-term:%" PRIu64 ", drop stale response", + pMsg->term); syncNodeEventLog(ths, logBuf); return 0; } @@ -70,7 +71,7 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p if (pMsg->term > ths->pRaftStore->currentTerm) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, error term, recv-term:%lu", pMsg->term); + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, error term, recv-term:%" PRIu64, pMsg->term); syncNodeErrorLog(ths, logBuf); return -1; } @@ -155,7 +156,8 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie // drop stale response if (pMsg->term < ths->pRaftStore->currentTerm) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, recv-term:%lu, drop stale response", pMsg->term); + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, recv-term:%" PRIu64 ", drop stale response", + pMsg->term); syncNodeEventLog(ths, logBuf); return -1; } @@ -163,7 +165,7 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie // error term if (pMsg->term > ths->pRaftStore->currentTerm) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, error term, recv-term:%lu", pMsg->term); + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, error term, recv-term:%" PRIu64, pMsg->term); syncNodeErrorLog(ths, logBuf); return -1; } @@ -193,9 +195,10 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie // start snapshot SSnapshot oldSnapshot; ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &oldSnapshot); - ASSERT(oldSnapshot.lastApplyIndex >= newMatchIndex + 1); - syncNodeStartSnapshotOnce(ths, newMatchIndex + 1, oldSnapshot.lastApplyIndex, oldSnapshot.lastApplyTerm, - pMsg); // term maybe not ok? + if (oldSnapshot.lastApplyIndex > newMatchIndex) { + syncNodeStartSnapshotOnce(ths, newMatchIndex + 1, oldSnapshot.lastApplyIndex, oldSnapshot.lastApplyTerm, + pMsg); // term maybe not ok? + } syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), oldSnapshot.lastApplyIndex + 1); syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), newMatchIndex); @@ -208,8 +211,8 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); char logBuf[256]; - snprintf(logBuf, sizeof(logBuf), "reset next-index:%ld, match-index:%ld for %s:%d", newNextIndex, newMatchIndex, - host, port); + snprintf(logBuf, sizeof(logBuf), "reset next-index:%" PRId64 ", match-index:%" PRId64 " for %s:%d", newNextIndex, + newMatchIndex, host, port); syncNodeEventLog(ths, logBuf); } while (0); @@ -262,8 +265,8 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie SyncIndex newNextIndex = nextIndex; SyncIndex newMatchIndex = syncIndexMgrGetIndex(ths->pMatchIndex, &(pMsg->srcId)); char logBuf[256]; - snprintf(logBuf, sizeof(logBuf), "reset2 next-index:%ld, match-index:%ld for %s:%d", newNextIndex, newMatchIndex, - host, port); + snprintf(logBuf, sizeof(logBuf), "reset2 next-index:%" PRId64 ", match-index:%" PRId64 " for %s:%d", newNextIndex, + newMatchIndex, host, port); syncNodeEventLog(ths, logBuf); } while (0); @@ -287,7 +290,8 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries // drop stale response if (pMsg->term < ths->pRaftStore->currentTerm) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, recv-term:%lu, drop stale response", pMsg->term); + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, recv-term:%" PRIu64 ", drop stale response", + pMsg->term); syncNodeEventLog(ths, logBuf); return 0; } @@ -305,7 +309,7 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries if (pMsg->term > ths->pRaftStore->currentTerm) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, error term, recv-term:%lu", pMsg->term); + snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries-reply, error term, recv-term:%" PRIu64, pMsg->term); syncNodeErrorLog(ths, logBuf); return -1; } @@ -317,7 +321,7 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), pMsg->matchIndex + 1); if (gRaftDetailLog) { - sTrace("update next match, index:%ld, success:%d", pMsg->matchIndex + 1, pMsg->success); + sTrace("update next match, index:%" PRId64 ", success:%d", pMsg->matchIndex + 1, pMsg->success); } // matchIndex' = [matchIndex EXCEPT ![i][j] = m.mmatchIndex] @@ -331,7 +335,7 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries } else { SyncIndex nextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); if (gRaftDetailLog) { - sTrace("update next index not match, begin, index:%ld, success:%d", nextIndex, pMsg->success); + sTrace("update next index not match, begin, index:%" PRId64 ", success:%d", nextIndex, pMsg->success); } // notice! int64, uint64 @@ -375,7 +379,7 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), nextIndex); if (gRaftDetailLog) { - sTrace("update next index not match, end, index:%ld, success:%d", nextIndex, pMsg->success); + sTrace("update next index not match, end, index:%" PRId64 ", success:%d", nextIndex, pMsg->success); } } diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 982d37826a..f7bee01030 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -57,8 +57,8 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { pSyncNode->commitIndex = snapshot.lastApplyIndex; char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "commit by snapshot from index:%ld to index:%ld", pSyncNode->commitIndex, - snapshot.lastApplyIndex); + snprintf(eventLog, sizeof(eventLog), "commit by snapshot from index:%" PRId64 " to index:%" PRId64, commitBegin, + commitEnd); syncNodeEventLog(pSyncNode, eventLog); } @@ -68,8 +68,8 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { bool agree = syncAgree(pSyncNode, index); if (gRaftDetailLog) { - sTrace("syncMaybeAdvanceCommitIndex syncAgree:%d, index:%ld, pSyncNode->commitIndex:%ld", agree, index, - pSyncNode->commitIndex); + sTrace("syncMaybeAdvanceCommitIndex syncAgree:%d, index:%" PRId64 ", pSyncNode->commitIndex:%" PRId64, agree, + index, pSyncNode->commitIndex); } if (agree) { @@ -83,7 +83,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { newCommitIndex = index; if (gRaftDetailLog) { - sTrace("syncMaybeAdvanceCommitIndex maybe to update, newCommitIndex:%ld commit, pSyncNode->commitIndex:%ld", + sTrace("syncMaybeAdvanceCommitIndex maybe to update, newCommitIndex:%" PRId64 " commit, pSyncNode->commitIndex:%" PRId64, newCommitIndex, pSyncNode->commitIndex); } @@ -91,10 +91,9 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { break; } else { if (gRaftDetailLog) { - sTrace( - "syncMaybeAdvanceCommitIndex can not commit due to term not equal, pEntry->term:%lu, " - "pSyncNode->pRaftStore->currentTerm:%lu", - pEntry->term, pSyncNode->pRaftStore->currentTerm); + sTrace("syncMaybeAdvanceCommitIndex can not commit due to term not equal, pEntry->term:%" PRIu64 + ", pSyncNode->pRaftStore->currentTerm:%" PRIu64, + pEntry->term, pSyncNode->pRaftStore->currentTerm); } } @@ -108,7 +107,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { SyncIndex endIndex = newCommitIndex; if (gRaftDetailLog) { - sTrace("syncMaybeAdvanceCommitIndex sync commit %ld", newCommitIndex); + sTrace("syncMaybeAdvanceCommitIndex sync commit %" PRId64, newCommitIndex); } // update commit index diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index 2712b4edc6..6dcbb598ae 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -123,8 +123,9 @@ int32_t syncNodeRequestVote(SSyncNode* pSyncNode, const SRaftId* destRaftId, con char host[128]; uint16_t port; syncUtilU642Addr(destRaftId->addr, host, sizeof(host), &port); - sDebug("vgId:%d, send sync-request-vote to %s:%d, {term:%lu, last-index:%ld, last-term:%lu}", pSyncNode->vgId, host, - port, pMsg->term, pMsg->lastLogTerm, pMsg->lastLogIndex); + sDebug("vgId:%d, send sync-request-vote to %s:%d, {term:%" PRIu64 ", last-index:%" PRId64 ", last-term:%" PRIu64 + "}", + pSyncNode->vgId, host, port, pMsg->term, pMsg->lastLogTerm, pMsg->lastLogIndex); } while (0); SRpcMsg rpcMsg; diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 10f0e0e335..a9c1147fc1 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -134,28 +134,28 @@ char *syncIndexMgr2Str(SSyncIndexMgr *pSyncIndexMgr) { // for debug ------------------- void syncIndexMgrPrint(SSyncIndexMgr *pObj) { char *serialized = syncIndexMgr2Str(pObj); - printf("syncIndexMgrPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncIndexMgrPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncIndexMgrPrint2(char *s, SSyncIndexMgr *pObj) { char *serialized = syncIndexMgr2Str(pObj); - printf("syncIndexMgrPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncIndexMgrPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncIndexMgrLog(SSyncIndexMgr *pObj) { char *serialized = syncIndexMgr2Str(pObj); - sTrace("syncIndexMgrLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncIndexMgrLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncIndexMgrLog2(char *s, SSyncIndexMgr *pObj) { if (gRaftDetailLog) { char *serialized = syncIndexMgr2Str(pObj); - sTrace("syncIndexMgrLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncIndexMgrLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -173,7 +173,7 @@ void syncIndexMgrSetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, S char host[128]; uint16_t port; syncUtilU642Addr(pRaftId->addr, host, sizeof(host), &port); - sError("vgId:%d index mgr set for %s:%d, term:%lu error", pSyncIndexMgr->pSyncNode->vgId, host, port, term); + sError("vgId:%d index mgr set for %s:%d, term:%" PRIu64 " error", pSyncIndexMgr->pSyncNode->vgId, host, port, term); } SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId) { diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 5951078822..1db60495c2 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -477,8 +477,8 @@ SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapsho lastIndex = (pSyncNode->pRaftCfg->configIndexArr)[i]; } } - sTrace("vgId:%d, sync get snapshot last config index, index:%ld lcindex:%ld", pSyncNode->vgId, snapshotLastApplyIndex, - lastIndex); + sTrace("vgId:%d, sync get snapshot last config index, index:%" PRId64 " lcindex:%" PRId64, pSyncNode->vgId, + snapshotLastApplyIndex, lastIndex); return lastIndex; } @@ -590,7 +590,7 @@ int32_t syncGetAndDelRespRpc(int64_t rid, uint64_t index, SRpcHandleInfo* pInfo) void syncSetMsgCb(int64_t rid, const SMsgCb* msgcb) { SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { - sTrace("syncSetQ get pSyncNode is NULL, rid:%ld", rid); + sTrace("syncSetQ get pSyncNode is NULL, rid:%" PRId64, rid); return; } ASSERT(rid == pSyncNode->rid); @@ -602,7 +602,7 @@ void syncSetMsgCb(int64_t rid, const SMsgCb* msgcb) { char* sync2SimpleStr(int64_t rid) { SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { - sTrace("syncSetRpc get pSyncNode is NULL, rid:%ld", rid); + sTrace("syncSetRpc get pSyncNode is NULL, rid:%" PRId64, rid); return NULL; } ASSERT(rid == pSyncNode->rid); @@ -819,12 +819,12 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { rpcFreeCont(rpcMsg.pCont); syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum); ret = 1; - sDebug("vgId:%d optimized index:%ld success, msgtype:%s,%d", pSyncNode->vgId, retIndex, + sDebug("vgId:%d optimized index:%" PRId64 " success, msgtype:%s,%d", pSyncNode->vgId, retIndex, TMSG_INFO(pMsg->msgType), pMsg->msgType); } else { ret = -1; terrno = TSDB_CODE_SYN_INTERNAL_ERROR; - sError("vgId:%d optimized index:%ld error, msgtype:%s,%d", pSyncNode->vgId, retIndex, TMSG_INFO(pMsg->msgType), + sError("vgId:%d optimized index:%" PRId64 " error, msgtype:%s,%d", pSyncNode->vgId, retIndex, TMSG_INFO(pMsg->msgType), pMsg->msgType); } @@ -1025,14 +1025,14 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { pSyncNode->FpOnSnapshotRsp = syncNodeOnSnapshotRspCb; if (pSyncNode->pRaftCfg->snapshotStrategy) { - sInfo("sync node use snapshot"); + sInfo("vgId:%d, sync node use snapshot", pSyncNode->vgId); pSyncNode->FpOnRequestVote = syncNodeOnRequestVoteSnapshotCb; pSyncNode->FpOnRequestVoteReply = syncNodeOnRequestVoteReplySnapshotCb; pSyncNode->FpOnAppendEntries = syncNodeOnAppendEntriesSnapshotCb; pSyncNode->FpOnAppendEntriesReply = syncNodeOnAppendEntriesReplySnapshotCb; } else { - sInfo("sync node do not use snapshot"); + sInfo("vgId:%d, sync node do not use snapshot", pSyncNode->vgId); pSyncNode->FpOnRequestVote = syncNodeOnRequestVoteCb; pSyncNode->FpOnRequestVoteReply = syncNodeOnRequestVoteReplyCb; pSyncNode->FpOnAppendEntries = syncNodeOnAppendEntriesCb; @@ -1311,8 +1311,10 @@ int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRp pMsg->info.noResp = 1; pSyncNode->FpSendMsg(&epSet, pMsg); } else { - sTrace("syncNodeSendMsgById pSyncNode->FpSendMsg is NULL"); + sError("vgId:%d, sync send msg by id error, fp-send-msg is null", pSyncNode->vgId); + return -1; } + return 0; } @@ -1326,7 +1328,7 @@ int32_t syncNodeSendMsgByInfo(const SNodeInfo* nodeInfo, SSyncNode* pSyncNode, S pMsg->info.noResp = 1; pSyncNode->FpSendMsg(&epSet, pMsg); } else { - sTrace("syncNodeSendMsgByInfo pSyncNode->FpSendMsg is NULL"); + sError("vgId:%d, sync send msg by info error, fp-send-msg is null", pSyncNode->vgId); } return 0; } @@ -1389,7 +1391,7 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { cJSON_AddItemToObject(pRoot, "leaderCache", pLaderCache); // life cycle - snprintf(u64buf, sizeof(u64buf), "%ld", pSyncNode->rid); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pSyncNode->rid); cJSON_AddStringToObject(pRoot, "rid", u64buf); // tla+ server vars @@ -1407,7 +1409,7 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { // tla+ log vars cJSON_AddItemToObject(pRoot, "pLogStore", logStore2Json(pSyncNode->pLogStore)); - snprintf(u64buf, sizeof(u64buf), "%" PRId64 "", pSyncNode->commitIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pSyncNode->commitIndex); cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); // timer ms init @@ -1419,39 +1421,39 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pPingTimer); cJSON_AddStringToObject(pRoot, "pPingTimer", u64buf); cJSON_AddNumberToObject(pRoot, "pingTimerMS", pSyncNode->pingTimerMS); - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerLogicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSyncNode->pingTimerLogicClock); cJSON_AddStringToObject(pRoot, "pingTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerLogicClockUser); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSyncNode->pingTimerLogicClockUser); cJSON_AddStringToObject(pRoot, "pingTimerLogicClockUser", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpPingTimerCB); cJSON_AddStringToObject(pRoot, "FpPingTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerCounter); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSyncNode->pingTimerCounter); cJSON_AddStringToObject(pRoot, "pingTimerCounter", u64buf); // elect timer snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pElectTimer); cJSON_AddStringToObject(pRoot, "pElectTimer", u64buf); cJSON_AddNumberToObject(pRoot, "electTimerMS", pSyncNode->electTimerMS); - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerLogicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSyncNode->electTimerLogicClock); cJSON_AddStringToObject(pRoot, "electTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerLogicClockUser); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSyncNode->electTimerLogicClockUser); cJSON_AddStringToObject(pRoot, "electTimerLogicClockUser", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpElectTimerCB); cJSON_AddStringToObject(pRoot, "FpElectTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerCounter); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSyncNode->electTimerCounter); cJSON_AddStringToObject(pRoot, "electTimerCounter", u64buf); // heartbeat timer snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pHeartbeatTimer); cJSON_AddStringToObject(pRoot, "pHeartbeatTimer", u64buf); cJSON_AddNumberToObject(pRoot, "heartbeatTimerMS", pSyncNode->heartbeatTimerMS); - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerLogicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSyncNode->heartbeatTimerLogicClock); cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerLogicClockUser); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSyncNode->heartbeatTimerLogicClockUser); cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClockUser", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpHeartbeatTimerCB); cJSON_AddStringToObject(pRoot, "FpHeartbeatTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerCounter); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSyncNode->heartbeatTimerCounter); cJSON_AddStringToObject(pRoot, "heartbeatTimerCounter", u64buf); // callback @@ -1525,10 +1527,10 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) { char logBuf[256 + 256]; if (pSyncNode != NULL && pSyncNode->pRaftCfg != NULL && pSyncNode->pRaftStore != NULL) { snprintf(logBuf, sizeof(logBuf), - "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " + "vgId:%d, sync %s %s, term:%" PRIu64 ", commit:%" PRId64 ", beginlog:%" PRId64 ", lastlog:%" PRId64 ", lastsnapshot:%" PRId64 ", standby:%d, " "strategy:%d, batch:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d, restore:%d, %s", + "lconfig:%" PRId64 ", changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy, pSyncNode->pRaftCfg->batchSize, @@ -1544,10 +1546,10 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) { char* s = (char*)taosMemoryMalloc(len); if (pSyncNode != NULL && pSyncNode->pRaftCfg != NULL && pSyncNode->pRaftStore != NULL) { snprintf(s, len, - "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " + "vgId:%d, sync %s %s, term:%" PRIu64 ", commit:%" PRId64 ", beginlog:%" PRId64 ", lastlog:%" PRId64 ", lastsnapshot:%" PRId64 ", standby:%d, " "strategy:%d, batch:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d, restore:%d, %s", + "lconfig:%" PRId64 ", changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->pRaftCfg->snapshotStrategy, pSyncNode->pRaftCfg->batchSize, @@ -1588,9 +1590,9 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) { char logBuf[256 + 256]; if (pSyncNode != NULL && pSyncNode->pRaftCfg != NULL && pSyncNode->pRaftStore != NULL) { snprintf(logBuf, sizeof(logBuf), - "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " + "vgId:%d, sync %s %s, term:%" PRIu64 ", commit:%" PRId64 ", beginlog:%" PRId64 ", lastlog:%" PRId64 ", lastsnapshot:%" PRId64 ", standby:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d, restore:%d, %s", + "lconfig:%" PRId64 ", changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, @@ -1605,9 +1607,9 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) { char* s = (char*)taosMemoryMalloc(len); if (pSyncNode != NULL && pSyncNode->pRaftCfg != NULL && pSyncNode->pRaftStore != NULL) { snprintf(s, len, - "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " + "vgId:%d, sync %s %s, term:%" PRIu64 ", commit:%" PRId64 ", beginlog:%" PRId64 ", lastlog:%" PRId64 ", lastsnapshot:%" PRId64 ", standby:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d, restore:%d, %s", + "lconfig:%" PRId64 ", changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, @@ -1634,9 +1636,9 @@ char* syncNode2SimpleStr(const SSyncNode* pSyncNode) { SyncIndex logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); snprintf(s, len, - "vgId:%d, sync %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " + "vgId:%d, sync %s, term:%" PRIu64 ", commit:%" PRId64 ", beginlog:%" PRId64 ", lastlog:%" PRId64 ", lastsnapshot:%" PRId64 ", standby:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d, restore:%d", + "lconfig:%" PRId64 ", changing:%d, restore:%d", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish); @@ -1781,7 +1783,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde do { char eventLog[256]; - snprintf(eventLog, sizeof(eventLog), "snapshot sender reset for %lu, newIndex:%d, %s:%d, %p", + snprintf(eventLog, sizeof(eventLog), "snapshot sender reset for: %" PRIu64 ", newIndex:%d, %s:%d, %p", (pSyncNode->replicasId)[i].addr, i, host, port, oldSenders[j]); syncNodeEventLog(pSyncNode, eventLog); } while (0); @@ -1837,7 +1839,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde char tmpbuf[512]; char* oldStr = syncCfg2SimpleStr(&oldConfig); char* newStr = syncCfg2SimpleStr(pNewConfig); - snprintf(tmpbuf, sizeof(tmpbuf), "config change from %d to %d, index:%ld, %s --> %s", oldConfig.replicaNum, + snprintf(tmpbuf, sizeof(tmpbuf), "config change from %d to %d, index:%" PRId64 ", %s --> %s", oldConfig.replicaNum, pNewConfig->replicaNum, lastConfigChangeIndex, oldStr, newStr); taosMemoryFree(oldStr); taosMemoryFree(newStr); @@ -1861,7 +1863,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde char tmpbuf[512]; char* oldStr = syncCfg2SimpleStr(&oldConfig); char* newStr = syncCfg2SimpleStr(pNewConfig); - snprintf(tmpbuf, sizeof(tmpbuf), "do not config change from %d to %d, index:%ld, %s --> %s", oldConfig.replicaNum, + snprintf(tmpbuf, sizeof(tmpbuf), "do not config change from %d to %d, index:%" PRId64 ", %s --> %s", oldConfig.replicaNum, pNewConfig->replicaNum, lastConfigChangeIndex, oldStr, newStr); taosMemoryFree(oldStr); taosMemoryFree(newStr); @@ -1899,7 +1901,7 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) { if (term > pSyncNode->pRaftStore->currentTerm) { raftStoreSetTerm(pSyncNode->pRaftStore, term); char tmpBuf[64]; - snprintf(tmpBuf, sizeof(tmpBuf), "update term to %lu", term); + snprintf(tmpBuf, sizeof(tmpBuf), "update term to %" PRIu64, term); syncNodeBecomeFollower(pSyncNode, tmpBuf); raftStoreClearVote(pSyncNode->pRaftStore); } @@ -2187,7 +2189,7 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) { do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "sync node get pre term error, index:%ld", index); + snprintf(logBuf, sizeof(logBuf), "sync node get pre term error, index:%" PRId64, index); syncNodeErrorLog(pSyncNode, logBuf); } while (0); @@ -2204,35 +2206,35 @@ int32_t syncNodeGetPreIndexTerm(SSyncNode* pSyncNode, SyncIndex index, SyncIndex // for debug -------------- void syncNodePrint(SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); - printf("syncNodePrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncNodePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncNodePrint2(char* s, SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); - printf("syncNodePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncNodePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncNodeLog(SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); - sTraceLong("syncNodeLog | len:%lu | %s", strlen(serialized), serialized); + sTraceLong("syncNodeLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncNodeLog2(char* s, SSyncNode* pObj) { if (gRaftDetailLog) { char* serialized = syncNode2Str(pObj); - sTraceLong("syncNodeLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTraceLong("syncNodeLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } void syncNodeLog3(char* s, SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); - sTraceLong("syncNodeLog3 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTraceLong("syncNodeLog3 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } @@ -2267,7 +2269,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) { } } else { - sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%" PRIu64 ", pingTimerLogicClockUser:%" PRIu64 "", + sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%" PRIu64 ", pingTimerLogicClockUser:%" PRIu64, pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser); } } @@ -2302,7 +2304,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) { sError("sync env is stop, syncNodeEqElectTimer"); } } else { - sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%" PRIu64 ", electTimerLogicClockUser:%" PRIu64 "", + sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%" PRIu64 ", electTimerLogicClockUser:%" PRIu64, pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser); } } @@ -2397,8 +2399,8 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) { // log state char logBuf[1024] = {0}; snprintf(logBuf, sizeof(logBuf), - "==syncNodeOnPingCb== vgId:%d, state: %d, %s, term:%lu electTimerLogicClock:%lu, " - "electTimerLogicClockUser:%lu, electTimerMS:%d", + "==syncNodeOnPingCb== vgId:%d, state: %d, %s, term:%" PRIu64 " electTimerLogicClock:%" PRIu64 ", " + "electTimerLogicClockUser:%" PRIu64 ", electTimerMS:%d", ths->vgId, ths->state, syncUtilState2String(ths->state), ths->pRaftStore->currentTerm, ths->electTimerLogicClock, ths->electTimerLogicClockUser, ths->electTimerMS); @@ -2608,7 +2610,7 @@ static int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE ASSERT(ret == 0); char eventLog[256]; - snprintf(eventLog, sizeof(eventLog), "maybe leader transfer to %s:%d %lu", + snprintf(eventLog, sizeof(eventLog), "maybe leader transfer to %s:%d %" PRIu64, pSyncLeaderTransfer->newNodeInfo.nodeFqdn, pSyncLeaderTransfer->newNodeInfo.nodePort, pSyncLeaderTransfer->newLeaderId.addr); syncNodeEventLog(ths, eventLog); @@ -2678,7 +2680,7 @@ static int32_t syncNodeConfigChangeFinish(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyn char tmpbuf[512]; char* oldStr = syncCfg2SimpleStr(&(pFinish->oldCfg)); char* newStr = syncCfg2SimpleStr(&(pFinish->newCfg)); - snprintf(tmpbuf, sizeof(tmpbuf), "config change finish from %d to %d, index:%ld, %s --> %s", + snprintf(tmpbuf, sizeof(tmpbuf), "config change finish from %d to %d, index:%" PRId64 ", %s --> %s", pFinish->oldCfg.replicaNum, pFinish->newCfg.replicaNum, pFinish->newCfgIndex, oldStr, newStr); taosMemoryFree(oldStr); taosMemoryFree(newStr); @@ -2739,7 +2741,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, ESyncState state = flag; char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "commit by wal from index:%ld to index:%ld", beginIndex, endIndex); + snprintf(eventLog, sizeof(eventLog), "commit by wal from index:%" PRId64 " to index:%" PRId64, beginIndex, endIndex); syncNodeEventLog(ths, eventLog); // execute fsm @@ -2763,7 +2765,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "index:%ld, internalExecute:%d", i, internalExecute); + snprintf(logBuf, sizeof(logBuf), "index:%" PRId64 ", internalExecute:%d", i, internalExecute); syncNodeEventLog(ths, logBuf); } while (0); @@ -2820,7 +2822,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, ths->restoreFinish = true; char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "restore finish, index:%ld", pEntry->index); + snprintf(eventLog, sizeof(eventLog), "restore finish, index:%" PRId64, pEntry->index); syncNodeEventLog(ths, eventLog); } } diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 697c25f304..42a3290d5b 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -133,28 +133,28 @@ char* syncRpcMsg2Str(SRpcMsg* pRpcMsg) { // for debug ---------------------- void syncRpcMsgPrint(SRpcMsg* pMsg) { char* serialized = syncRpcMsg2Str(pMsg); - printf("syncRpcMsgPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncRpcMsgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRpcMsgPrint2(char* s, SRpcMsg* pMsg) { char* serialized = syncRpcMsg2Str(pMsg); - printf("syncRpcMsgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncRpcMsgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRpcMsgLog(SRpcMsg* pMsg) { char* serialized = syncRpcMsg2Str(pMsg); - sTrace("syncRpcMsgLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncRpcMsgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncRpcMsgLog2(char* s, SRpcMsg* pMsg) { if (gRaftDetailLog) { char* serialized = syncRpcMsg2Str(pMsg); - sTrace("syncRpcMsgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncRpcMsgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -242,7 +242,7 @@ cJSON* syncTimeout2Json(const SyncTimeout* pMsg) { cJSON_AddNumberToObject(pRoot, "vgId", pMsg->vgId); cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON_AddNumberToObject(pRoot, "timeoutType", pMsg->timeoutType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->logicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->logicClock); cJSON_AddStringToObject(pRoot, "logicClock", u64buf); cJSON_AddNumberToObject(pRoot, "timerMS", pMsg->timerMS); snprintf(u64buf, sizeof(u64buf), "%p", pMsg->data); @@ -271,21 +271,21 @@ void syncTimeoutPrint(const SyncTimeout* pMsg) { void syncTimeoutPrint2(char* s, const SyncTimeout* pMsg) { char* serialized = syncTimeout2Str(pMsg); - printf("syncTimeoutPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncTimeoutPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncTimeoutLog(const SyncTimeout* pMsg) { char* serialized = syncTimeout2Str(pMsg); - sTrace("syncTimeoutLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncTimeoutLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncTimeoutLog2(char* s, const SyncTimeout* pMsg) { if (gRaftDetailLog) { char* serialized = syncTimeout2Str(pMsg); - sTrace("syncTimeoutLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncTimeoutLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -472,7 +472,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -487,7 +487,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -526,28 +526,28 @@ char* syncPing2Str(const SyncPing* pMsg) { // for debug ---------------------- void syncPingPrint(const SyncPing* pMsg) { char* serialized = syncPing2Str(pMsg); - printf("syncPingPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncPingPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncPingPrint2(char* s, const SyncPing* pMsg) { char* serialized = syncPing2Str(pMsg); - printf("syncPingPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncPingPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncPingLog(const SyncPing* pMsg) { char* serialized = syncPing2Str(pMsg); - sTrace("syncPingLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncPingLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncPingLog2(char* s, const SyncPing* pMsg) { if (gRaftDetailLog) { char* serialized = syncPing2Str(pMsg); - sTrace("syncPingLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncPingLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -734,7 +734,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -749,7 +749,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -902,7 +902,7 @@ cJSON* syncClientRequest2Json(const SyncClientRequest* pMsg) { cJSON_AddNumberToObject(pRoot, "vgId", pMsg->vgId); cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON_AddNumberToObject(pRoot, "originalRpcType", pMsg->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->seqNum); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->seqNum); cJSON_AddStringToObject(pRoot, "seqNum", u64buf); cJSON_AddNumberToObject(pRoot, "isWeak", pMsg->isWeak); cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); @@ -931,28 +931,28 @@ char* syncClientRequest2Str(const SyncClientRequest* pMsg) { // for debug ---------------------- void syncClientRequestPrint(const SyncClientRequest* pMsg) { char* serialized = syncClientRequest2Str(pMsg); - printf("syncClientRequestPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncClientRequestPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncClientRequestPrint2(char* s, const SyncClientRequest* pMsg) { char* serialized = syncClientRequest2Str(pMsg); - printf("syncClientRequestPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncClientRequestPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncClientRequestLog(const SyncClientRequest* pMsg) { char* serialized = syncClientRequest2Str(pMsg); - sTrace("syncClientRequestLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncClientRequestLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg) { if (gRaftDetailLog) { char* serialized = syncClientRequest2Str(pMsg); - sTrace("syncClientRequestLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncClientRequestLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1101,28 +1101,28 @@ char* syncClientRequestBatch2Str(const SyncClientRequestBatch* pMsg) { // for debug ---------------------- void syncClientRequestBatchPrint(const SyncClientRequestBatch* pMsg) { char* serialized = syncClientRequestBatch2Str(pMsg); - printf("syncClientRequestBatchPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncClientRequestBatchPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncClientRequestBatchPrint2(char* s, const SyncClientRequestBatch* pMsg) { char* serialized = syncClientRequestBatch2Str(pMsg); - printf("syncClientRequestBatchPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncClientRequestBatchPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncClientRequestBatchLog(const SyncClientRequestBatch* pMsg) { char* serialized = syncClientRequestBatch2Str(pMsg); - sTrace("syncClientRequestBatchLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncClientRequestBatchLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncClientRequestBatchLog2(char* s, const SyncClientRequestBatch* pMsg) { if (gRaftDetailLog) { char* serialized = syncClientRequestBatch2Str(pMsg); - sTraceLong("syncClientRequestBatchLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTraceLong("syncClientRequestBatchLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1201,7 +1201,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -1229,11 +1229,11 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->lastLogIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->lastLogIndex); cJSON_AddStringToObject(pRoot, "lastLogIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->lastLogTerm); cJSON_AddStringToObject(pRoot, "lastLogTerm", u64buf); } @@ -1252,28 +1252,28 @@ char* syncRequestVote2Str(const SyncRequestVote* pMsg) { // for debug ---------------------- void syncRequestVotePrint(const SyncRequestVote* pMsg) { char* serialized = syncRequestVote2Str(pMsg); - printf("syncRequestVotePrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncRequestVotePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRequestVotePrint2(char* s, const SyncRequestVote* pMsg) { char* serialized = syncRequestVote2Str(pMsg); - printf("syncRequestVotePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncRequestVotePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRequestVoteLog(const SyncRequestVote* pMsg) { char* serialized = syncRequestVote2Str(pMsg); - sTrace("syncRequestVoteLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncRequestVoteLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncRequestVoteLog2(char* s, const SyncRequestVote* pMsg) { if (gRaftDetailLog) { char* serialized = syncRequestVote2Str(pMsg); - sTrace("syncRequestVoteLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncRequestVoteLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1352,7 +1352,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -1380,7 +1380,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "vote_granted", pMsg->voteGranted); } @@ -1400,28 +1400,28 @@ char* syncRequestVoteReply2Str(const SyncRequestVoteReply* pMsg) { // for debug ---------------------- void syncRequestVoteReplyPrint(const SyncRequestVoteReply* pMsg) { char* serialized = syncRequestVoteReply2Str(pMsg); - printf("syncRequestVoteReplyPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncRequestVoteReplyPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRequestVoteReplyPrint2(char* s, const SyncRequestVoteReply* pMsg) { char* serialized = syncRequestVoteReply2Str(pMsg); - printf("syncRequestVoteReplyPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncRequestVoteReplyPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRequestVoteReplyLog(const SyncRequestVoteReply* pMsg) { char* serialized = syncRequestVoteReply2Str(pMsg); - sTrace("syncRequestVoteReplyLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncRequestVoteReplyLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncRequestVoteReplyLog2(char* s, const SyncRequestVoteReply* pMsg) { if (gRaftDetailLog) { char* serialized = syncRequestVoteReply2Str(pMsg); - sTrace("syncRequestVoteReplyLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncRequestVoteReplyLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1502,7 +1502,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -1517,7 +1517,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -1531,19 +1531,19 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->privateTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->privateTerm); cJSON_AddStringToObject(pRoot, "privateTerm", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->prevLogIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->prevLogIndex); cJSON_AddStringToObject(pRoot, "prevLogIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->prevLogTerm); cJSON_AddStringToObject(pRoot, "pre_log_term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->commitIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->commitIndex); cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); @@ -1571,28 +1571,28 @@ char* syncAppendEntries2Str(const SyncAppendEntries* pMsg) { // for debug ---------------------- void syncAppendEntriesPrint(const SyncAppendEntries* pMsg) { char* serialized = syncAppendEntries2Str(pMsg); - printf("syncAppendEntriesPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncAppendEntriesPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesPrint2(char* s, const SyncAppendEntries* pMsg) { char* serialized = syncAppendEntries2Str(pMsg); - printf("syncAppendEntriesPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncAppendEntriesPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesLog(const SyncAppendEntries* pMsg) { char* serialized = syncAppendEntries2Str(pMsg); - sTrace("syncAppendEntriesLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncAppendEntriesLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncAppendEntriesLog2(char* s, const SyncAppendEntries* pMsg) { if (gRaftDetailLog) { char* serialized = syncAppendEntries2Str(pMsg); - sTrace("syncAppendEntriesLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncAppendEntriesLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1714,7 +1714,7 @@ cJSON* syncAppendEntriesBatch2Json(const SyncAppendEntriesBatch* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -1729,7 +1729,7 @@ cJSON* syncAppendEntriesBatch2Json(const SyncAppendEntriesBatch* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -1743,19 +1743,19 @@ cJSON* syncAppendEntriesBatch2Json(const SyncAppendEntriesBatch* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->prevLogIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->prevLogIndex); cJSON_AddStringToObject(pRoot, "prevLogIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->prevLogTerm); cJSON_AddStringToObject(pRoot, "prevLogTerm", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->commitIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->commitIndex); cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->privateTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->privateTerm); cJSON_AddStringToObject(pRoot, "privateTerm", u64buf); cJSON_AddNumberToObject(pRoot, "dataCount", pMsg->dataCount); @@ -1810,28 +1810,28 @@ char* syncAppendEntriesBatch2Str(const SyncAppendEntriesBatch* pMsg) { // for debug ---------------------- void syncAppendEntriesBatchPrint(const SyncAppendEntriesBatch* pMsg) { char* serialized = syncAppendEntriesBatch2Str(pMsg); - printf("syncAppendEntriesBatchPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncAppendEntriesBatchPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesBatchPrint2(char* s, const SyncAppendEntriesBatch* pMsg) { char* serialized = syncAppendEntriesBatch2Str(pMsg); - printf("syncAppendEntriesBatchPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncAppendEntriesBatchPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesBatchLog(const SyncAppendEntriesBatch* pMsg) { char* serialized = syncAppendEntriesBatch2Str(pMsg); - sTrace("syncAppendEntriesBatchLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncAppendEntriesBatchLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncAppendEntriesBatchLog2(char* s, const SyncAppendEntriesBatch* pMsg) { if (gRaftDetailLog) { char* serialized = syncAppendEntriesBatch2Str(pMsg); - sTraceLong("syncAppendEntriesBatchLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTraceLong("syncAppendEntriesBatchLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1910,7 +1910,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -1925,7 +1925,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -1939,13 +1939,13 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->privateTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->privateTerm); cJSON_AddStringToObject(pRoot, "privateTerm", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "success", pMsg->success); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->matchIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->matchIndex); cJSON_AddStringToObject(pRoot, "matchIndex", u64buf); } @@ -1964,28 +1964,28 @@ char* syncAppendEntriesReply2Str(const SyncAppendEntriesReply* pMsg) { // for debug ---------------------- void syncAppendEntriesReplyPrint(const SyncAppendEntriesReply* pMsg) { char* serialized = syncAppendEntriesReply2Str(pMsg); - printf("syncAppendEntriesReplyPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncAppendEntriesReplyPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesReplyPrint2(char* s, const SyncAppendEntriesReply* pMsg) { char* serialized = syncAppendEntriesReply2Str(pMsg); - printf("syncAppendEntriesReplyPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncAppendEntriesReplyPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesReplyLog(const SyncAppendEntriesReply* pMsg) { char* serialized = syncAppendEntriesReply2Str(pMsg); - sTrace("syncAppendEntriesReplyLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncAppendEntriesReplyLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncAppendEntriesReplyLog2(char* s, const SyncAppendEntriesReply* pMsg) { if (gRaftDetailLog) { char* serialized = syncAppendEntriesReply2Str(pMsg); - sTrace("syncAppendEntriesReplyLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncAppendEntriesReplyLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2083,13 +2083,13 @@ cJSON* syncApplyMsg2Json(const SyncApplyMsg* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON_AddNumberToObject(pRoot, "originalRpcType", pMsg->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->fsmMeta.index); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->fsmMeta.index); cJSON_AddStringToObject(pRoot, "fsmMeta.index", u64buf); cJSON_AddNumberToObject(pRoot, "fsmMeta.isWeak", pMsg->fsmMeta.isWeak); cJSON_AddNumberToObject(pRoot, "fsmMeta.code", pMsg->fsmMeta.code); cJSON_AddNumberToObject(pRoot, "fsmMeta.state", pMsg->fsmMeta.state); cJSON_AddStringToObject(pRoot, "fsmMeta.state.str", syncUtilState2String(pMsg->fsmMeta.state)); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->fsmMeta.seqNum); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->fsmMeta.seqNum); cJSON_AddStringToObject(pRoot, "fsmMeta.seqNum", u64buf); cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); @@ -2117,28 +2117,28 @@ char* syncApplyMsg2Str(const SyncApplyMsg* pMsg) { // for debug ---------------------- void syncApplyMsgPrint(const SyncApplyMsg* pMsg) { char* serialized = syncApplyMsg2Str(pMsg); - printf("syncApplyMsgPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncApplyMsgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncApplyMsgPrint2(char* s, const SyncApplyMsg* pMsg) { char* serialized = syncApplyMsg2Str(pMsg); - printf("syncApplyMsgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncApplyMsgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncApplyMsgLog(const SyncApplyMsg* pMsg) { char* serialized = syncApplyMsg2Str(pMsg); - sTrace("ssyncApplyMsgLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("ssyncApplyMsgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncApplyMsgLog2(char* s, const SyncApplyMsg* pMsg) { if (gRaftDetailLog) { char* serialized = syncApplyMsg2Str(pMsg); - sTrace("syncApplyMsgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncApplyMsgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2219,7 +2219,7 @@ cJSON* syncSnapshotSend2Json(const SyncSnapshotSend* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -2234,7 +2234,7 @@ cJSON* syncSnapshotSend2Json(const SyncSnapshotSend* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -2248,23 +2248,23 @@ cJSON* syncSnapshotSend2Json(const SyncSnapshotSend* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->privateTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->privateTerm); cJSON_AddStringToObject(pRoot, "privateTerm", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->beginIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->beginIndex); cJSON_AddStringToObject(pRoot, "beginIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->lastIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->lastIndex); cJSON_AddStringToObject(pRoot, "lastIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->lastConfigIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->lastConfigIndex); cJSON_AddStringToObject(pRoot, "lastConfigIndex", u64buf); cJSON_AddItemToObject(pRoot, "lastConfig", syncCfg2Json((SSyncCfg*)&(pMsg->lastConfig))); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->lastTerm); cJSON_AddStringToObject(pRoot, "lastTerm", u64buf); cJSON_AddNumberToObject(pRoot, "seq", pMsg->seq); @@ -2294,28 +2294,28 @@ char* syncSnapshotSend2Str(const SyncSnapshotSend* pMsg) { // for debug ---------------------- void syncSnapshotSendPrint(const SyncSnapshotSend* pMsg) { char* serialized = syncSnapshotSend2Str(pMsg); - printf("syncSnapshotSendPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncSnapshotSendPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncSnapshotSendPrint2(char* s, const SyncSnapshotSend* pMsg) { char* serialized = syncSnapshotSend2Str(pMsg); - printf("syncSnapshotSendPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncSnapshotSendPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncSnapshotSendLog(const SyncSnapshotSend* pMsg) { char* serialized = syncSnapshotSend2Str(pMsg); - sTrace("syncSnapshotSendLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncSnapshotSendLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncSnapshotSendLog2(char* s, const SyncSnapshotSend* pMsg) { if (gRaftDetailLog) { char* serialized = syncSnapshotSend2Str(pMsg); - sTrace("syncSnapshotSendLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncSnapshotSendLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2394,7 +2394,7 @@ cJSON* syncSnapshotRsp2Json(const SyncSnapshotRsp* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -2409,7 +2409,7 @@ cJSON* syncSnapshotRsp2Json(const SyncSnapshotRsp* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -2423,16 +2423,16 @@ cJSON* syncSnapshotRsp2Json(const SyncSnapshotRsp* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->privateTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->privateTerm); cJSON_AddStringToObject(pRoot, "privateTerm", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->lastIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->lastIndex); cJSON_AddStringToObject(pRoot, "lastIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->lastTerm); cJSON_AddStringToObject(pRoot, "lastTerm", u64buf); cJSON_AddNumberToObject(pRoot, "ack", pMsg->ack); @@ -2454,28 +2454,28 @@ char* syncSnapshotRsp2Str(const SyncSnapshotRsp* pMsg) { // for debug ---------------------- void syncSnapshotRspPrint(const SyncSnapshotRsp* pMsg) { char* serialized = syncSnapshotRsp2Str(pMsg); - printf("syncSnapshotRspPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncSnapshotRspPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncSnapshotRspPrint2(char* s, const SyncSnapshotRsp* pMsg) { char* serialized = syncSnapshotRsp2Str(pMsg); - printf("syncSnapshotRspPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncSnapshotRspPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncSnapshotRspLog(const SyncSnapshotRsp* pMsg) { char* serialized = syncSnapshotRsp2Str(pMsg); - sTrace("syncSnapshotRspLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncSnapshotRspLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncSnapshotRspLog2(char* s, const SyncSnapshotRsp* pMsg) { if (gRaftDetailLog) { char* serialized = syncSnapshotRsp2Str(pMsg); - sTrace("syncSnapshotRspLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncSnapshotRspLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2555,7 +2555,7 @@ cJSON* syncLeaderTransfer2Json(const SyncLeaderTransfer* pMsg) { /* cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -2570,7 +2570,7 @@ cJSON* syncLeaderTransfer2Json(const SyncLeaderTransfer* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -2586,7 +2586,7 @@ cJSON* syncLeaderTransfer2Json(const SyncLeaderTransfer* pMsg) { */ cJSON* pNewerId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->newLeaderId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->newLeaderId.addr); cJSON_AddStringToObject(pNewerId, "addr", u64buf); { uint64_t u64 = pMsg->newLeaderId.addr; @@ -2616,28 +2616,28 @@ char* syncLeaderTransfer2Str(const SyncLeaderTransfer* pMsg) { // for debug ---------------------- void syncLeaderTransferPrint(const SyncLeaderTransfer* pMsg) { char* serialized = syncLeaderTransfer2Str(pMsg); - printf("syncLeaderTransferPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncLeaderTransferPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncLeaderTransferPrint2(char* s, const SyncLeaderTransfer* pMsg) { char* serialized = syncLeaderTransfer2Str(pMsg); - printf("syncLeaderTransferPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncLeaderTransferPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncLeaderTransferLog(const SyncLeaderTransfer* pMsg) { char* serialized = syncLeaderTransfer2Str(pMsg); - sTrace("syncLeaderTransferLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncLeaderTransferLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncLeaderTransferLog2(char* s, const SyncLeaderTransfer* pMsg) { if (gRaftDetailLog) { char* serialized = syncLeaderTransfer2Str(pMsg); - sTrace("syncLeaderTransferLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncLeaderTransferLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2720,13 +2720,13 @@ cJSON* syncReconfigFinish2Json(const SyncReconfigFinish* pMsg) { cJSON_AddItemToObject(pRoot, "oldCfg", pOldCfg); cJSON_AddItemToObject(pRoot, "newCfg", pNewCfg); - snprintf(u64buf, sizeof(u64buf), "%ld", pMsg->newCfgIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->newCfgIndex); cJSON_AddStringToObject(pRoot, "newCfgIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->newCfgTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->newCfgTerm); cJSON_AddStringToObject(pRoot, "newCfgTerm", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->newCfgSeqNum); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->newCfgSeqNum); cJSON_AddStringToObject(pRoot, "newCfgSeqNum", u64buf); } @@ -2745,28 +2745,28 @@ char* syncReconfigFinish2Str(const SyncReconfigFinish* pMsg) { // for debug ---------------------- void syncReconfigFinishPrint(const SyncReconfigFinish* pMsg) { char* serialized = syncReconfigFinish2Str(pMsg); - printf("syncReconfigFinishPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncReconfigFinishPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncReconfigFinishPrint2(char* s, const SyncReconfigFinish* pMsg) { char* serialized = syncReconfigFinish2Str(pMsg); - printf("syncReconfigFinishPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncReconfigFinishPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncReconfigFinishLog(const SyncReconfigFinish* pMsg) { char* serialized = syncReconfigFinish2Str(pMsg); - sTrace("syncReconfigFinishLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncReconfigFinishLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg) { if (gRaftDetailLog) { char* serialized = syncReconfigFinish2Str(pMsg); - sTrace("syncReconfigFinishLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncReconfigFinishLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } \ No newline at end of file diff --git a/source/libs/sync/src/syncOnMessage.c b/source/libs/sync/src/syncOnMessage.c deleted file mode 100644 index ce8bed9cd3..0000000000 --- a/source/libs/sync/src/syncOnMessage.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "syncOnMessage.h" - -// TLA+ Spec -// Receive(m) == -// LET i == m.mdest -// j == m.msource -// IN \* Any RPC with a newer term causes the recipient to advance -// \* its term first. Responses with stale terms are ignored. -// \/ UpdateTerm(i, j, m) -// \/ /\ m.mtype = RequestVoteRequest -// /\ HandleRequestVoteRequest(i, j, m) -// \/ /\ m.mtype = RequestVoteResponse -// /\ \/ DropStaleResponse(i, j, m) -// \/ HandleRequestVoteResponse(i, j, m) -// \/ /\ m.mtype = AppendEntriesRequest -// /\ HandleAppendEntriesRequest(i, j, m) -// \/ /\ m.mtype = AppendEntriesResponse -// /\ \/ DropStaleResponse(i, j, m) -// \/ HandleAppendEntriesResponse(i, j, m) - -// DuplicateMessage(m) == -// /\ Send(m) -// /\ UNCHANGED <> - -// DropMessage(m) == -// /\ Discard(m) -// /\ UNCHANGED <> - -// Next == /\ \/ \E i \in Server : Restart(i) -// \/ \E i \in Server : Timeout(i) -// \/ \E i,j \in Server : RequestVote(i, j) -// \/ \E i \in Server : BecomeLeader(i) -// \/ \E i \in Server, v \in Value : ClientRequest(i, v) -// \/ \E i \in Server : AdvanceCommitIndex(i) -// \/ \E i,j \in Server : AppendEntries(i, j) -// \/ \E m \in DOMAIN messages : Receive(m) -// \/ \E m \in DOMAIN messages : DuplicateMessage(m) -// \/ \E m \in DOMAIN messages : DropMessage(m) -// \* History variable that tracks every log ever: -// /\ allLogs' = allLogs \cup {log[i] : i \in Server} -// \ No newline at end of file diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index 6c381f6e7d..c06bd2338d 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -186,14 +186,14 @@ cJSON *raftCfg2Json(SRaftCfg *pRaftCfg) { cJSON_AddNumberToObject(pRoot, "batchSize", pRaftCfg->batchSize); char buf64[128]; - snprintf(buf64, sizeof(buf64), "%ld", pRaftCfg->lastConfigIndex); + snprintf(buf64, sizeof(buf64), "%" PRId64, pRaftCfg->lastConfigIndex); cJSON_AddStringToObject(pRoot, "lastConfigIndex", buf64); cJSON_AddNumberToObject(pRoot, "configIndexCount", pRaftCfg->configIndexCount); cJSON *pIndexArr = cJSON_CreateArray(); cJSON_AddItemToObject(pRoot, "configIndexArr", pIndexArr); for (int i = 0; i < pRaftCfg->configIndexCount; ++i) { - snprintf(buf64, sizeof(buf64), "%ld", (pRaftCfg->configIndexArr)[i]); + snprintf(buf64, sizeof(buf64), "%" PRId64, (pRaftCfg->configIndexArr)[i]); cJSON *pIndexObj = cJSON_CreateObject(); cJSON_AddStringToObject(pIndexObj, "index", buf64); cJSON_AddItemToArray(pIndexArr, pIndexObj); @@ -306,58 +306,58 @@ int32_t raftCfgFromStr(const char *s, SRaftCfg *pRaftCfg) { // for debug ---------------------- void syncCfgPrint(SSyncCfg *pCfg) { char *serialized = syncCfg2Str(pCfg); - printf("syncCfgPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncCfgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncCfgPrint2(char *s, SSyncCfg *pCfg) { char *serialized = syncCfg2Str(pCfg); - printf("syncCfgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncCfgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncCfgLog(SSyncCfg *pCfg) { char *serialized = syncCfg2Str(pCfg); - sTrace("syncCfgLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncCfgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncCfgLog2(char *s, SSyncCfg *pCfg) { char *serialized = syncCfg2Str(pCfg); - sTrace("syncCfgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncCfgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } void syncCfgLog3(char *s, SSyncCfg *pCfg) { char *serialized = syncCfg2SimpleStr(pCfg); - sTrace("syncCfgLog3 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncCfgLog3 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } void raftCfgPrint(SRaftCfg *pCfg) { char *serialized = raftCfg2Str(pCfg); - printf("raftCfgPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("raftCfgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCfgPrint2(char *s, SRaftCfg *pCfg) { char *serialized = raftCfg2Str(pCfg); - printf("raftCfgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("raftCfgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCfgLog(SRaftCfg *pCfg) { char *serialized = raftCfg2Str(pCfg); - sTrace("raftCfgLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("raftCfgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void raftCfgLog2(char *s, SRaftCfg *pCfg) { char *serialized = raftCfg2Str(pCfg); - sTrace("raftCfgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("raftCfgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index 0ee4684ea8..465584a40f 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -130,12 +130,12 @@ cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) { cJSON_AddNumberToObject(pRoot, "bytes", pEntry->bytes); cJSON_AddNumberToObject(pRoot, "msgType", pEntry->msgType); cJSON_AddNumberToObject(pRoot, "originalRpcType", pEntry->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->seqNum); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pEntry->seqNum); cJSON_AddStringToObject(pRoot, "seqNum", u64buf); cJSON_AddNumberToObject(pRoot, "isWeak", pEntry->isWeak); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pEntry->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pEntry->index); cJSON_AddStringToObject(pRoot, "index", u64buf); cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen); @@ -246,7 +246,7 @@ int32_t raftCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry do { char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "raft cache add, type:%s,%d, type2:%s,%d, index:%ld, bytes:%d", + snprintf(eventLog, sizeof(eventLog), "raft cache add, type:%s,%d, type2:%s,%d, index:%" PRId64 ", bytes:%d", TMSG_INFO(pEntry->msgType), pEntry->msgType, TMSG_INFO(pEntry->originalRpcType), pEntry->originalRpcType, pEntry->index, pEntry->bytes); syncNodeEventLog(pCache->pSyncNode, eventLog); @@ -274,7 +274,7 @@ int32_t raftCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSync do { char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "raft cache get, type:%s,%d, type2:%s,%d, index:%ld", + snprintf(eventLog, sizeof(eventLog), "raft cache get, type:%s,%d, type2:%s,%d, index:%" PRId64, TMSG_INFO((*ppEntry)->msgType), (*ppEntry)->msgType, TMSG_INFO((*ppEntry)->originalRpcType), (*ppEntry)->originalRpcType, (*ppEntry)->index); syncNodeEventLog(pCache->pSyncNode, eventLog); @@ -306,7 +306,7 @@ int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyn do { char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "raft cache get, type:%s,%d, type2:%s,%d, index:%ld", + snprintf(eventLog, sizeof(eventLog), "raft cache get, type:%s,%d, type2:%s,%d, index:%" PRId64, TMSG_INFO((*ppEntry)->msgType), (*ppEntry)->msgType, TMSG_INFO((*ppEntry)->originalRpcType), (*ppEntry)->originalRpcType, (*ppEntry)->index); syncNodeEventLog(pCache->pSyncNode, eventLog); @@ -344,7 +344,7 @@ int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyn do { char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "raft cache get-and-del, type:%s,%d, type2:%s,%d, index:%ld", + snprintf(eventLog, sizeof(eventLog), "raft cache get-and-del, type:%s,%d, type2:%s,%d, index:%" PRId64, TMSG_INFO((*ppEntry)->msgType), (*ppEntry)->msgType, TMSG_INFO((*ppEntry)->originalRpcType), (*ppEntry)->originalRpcType, (*ppEntry)->index); syncNodeEventLog(pCache->pSyncNode, eventLog); @@ -415,28 +415,28 @@ char* raftCache2Str(SRaftEntryCache* pCache) { void raftCachePrint(SRaftEntryCache* pCache) { char* serialized = raftCache2Str(pCache); - printf("raftCachePrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("raftCachePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCachePrint2(char* s, SRaftEntryCache* pCache) { char* serialized = raftCache2Str(pCache); - printf("raftCachePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("raftCachePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCacheLog(SRaftEntryCache* pCache) { char* serialized = raftCache2Str(pCache); - sTrace("raftCacheLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("raftCacheLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void raftCacheLog2(char* s, SRaftEntryCache* pCache) { if (gRaftDetailLog) { char* serialized = raftCache2Str(pCache); - sTraceLong("raftCacheLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTraceLong("raftCacheLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } \ No newline at end of file diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index c5d339b08f..a135002f44 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -122,7 +122,7 @@ static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncI char logBuf[128]; snprintf(logBuf, sizeof(logBuf), - "wal restore from snapshot error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", snapshotIndex, err, + "wal restore from snapshot error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", snapshotIndex, err, err, errStr, sysErr, sysErrStr); syncNodeErrorLog(pData->pSyncNode, logBuf); @@ -207,7 +207,7 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr SyncIndex writeIndex = raftLogWriteIndex(pLogStore); if (pEntry->index != writeIndex) { - sError("vgId:%d wal write index error, entry-index:%ld update to %ld", pData->pSyncNode->vgId, pEntry->index, + sError("vgId:%d wal write index error, entry-index:%" PRId64 " update to %" PRId64, pData->pSyncNode->vgId, pEntry->index, writeIndex); pEntry->index = writeIndex; } @@ -225,7 +225,7 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr const char* sysErrStr = strerror(errno); char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "wal write error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", + snprintf(logBuf, sizeof(logBuf), "wal write error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pEntry->index, err, err, errStr, sysErr, sysErrStr); syncNodeErrorLog(pData->pSyncNode, logBuf); @@ -236,7 +236,7 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr do { char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "write index:%ld, type:%s,%d, type2:%s,%d", pEntry->index, + snprintf(eventLog, sizeof(eventLog), "write index:%" PRId64 ", type:%s,%d, type2:%s,%d", pEntry->index, TMSG_INFO(pEntry->msgType), pEntry->msgType, TMSG_INFO(pEntry->originalRpcType), pEntry->originalRpcType); syncNodeEventLog(pData->pSyncNode, eventLog); } while (0); @@ -272,7 +272,7 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "wal read error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", index, err, + snprintf(logBuf, sizeof(logBuf), "wal read error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", index, err, err, errStr, sysErr, sysErrStr); if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) { syncNodeEventLog(pData->pSyncNode, logBuf); @@ -321,11 +321,19 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn const char* errStr = tstrerror(err); int32_t sysErr = errno; const char* sysErrStr = strerror(errno); - sError("vgId:%d wal truncate error, from-index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", + sError("vgId:%d wal truncate error, from-index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pData->pSyncNode->vgId, fromIndex, err, err, errStr, sysErr, sysErrStr); ASSERT(0); } + + // event log + do { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "wal truncate, from-index:%" PRId64, fromIndex); + syncNodeEventLog(pData->pSyncNode, logBuf); + } while (0); + return code; } @@ -373,7 +381,7 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { const char* sysErrStr = strerror(errno); char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "wal write error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", + snprintf(logBuf, sizeof(logBuf), "wal write error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pEntry->index, err, err, errStr, sysErr, sysErrStr); syncNodeErrorLog(pData->pSyncNode, logBuf); @@ -383,7 +391,7 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { // walFsync(pWal, true); char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "old write index:%ld, type:%s,%d, type2:%s,%d", pEntry->index, + snprintf(eventLog, sizeof(eventLog), "old write index:%" PRId64 ", type:%s,%d, type2:%s,%d", pEntry->index, TMSG_INFO(pEntry->msgType), pEntry->msgType, TMSG_INFO(pEntry->originalRpcType), pEntry->originalRpcType); syncNodeEventLog(pData->pSyncNode, eventLog); @@ -410,7 +418,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) { do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "wal read error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", index, + snprintf(logBuf, sizeof(logBuf), "wal read error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", index, err, err, errStr, sysErr, sysErrStr); if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) { syncNodeEventLog(pData->pSyncNode, logBuf); @@ -458,11 +466,19 @@ int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex) { const char* errStr = tstrerror(err); int32_t sysErr = errno; const char* sysErrStr = strerror(errno); - sError("vgId:%d wal truncate error, from-index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", + sError("vgId:%d wal truncate error, from-index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pData->pSyncNode->vgId, fromIndex, err, err, errStr, sysErr, sysErrStr); ASSERT(0); } + + // event log + do { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "wal truncate, from-index:%" PRId64, fromIndex); + syncNodeEventLog(pData->pSyncNode, logBuf); + } while (0); + return 0; } @@ -493,7 +509,7 @@ int32_t logStoreUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) { const char* errStr = tstrerror(err); int32_t sysErr = errno; const char* sysErrStr = strerror(errno); - sError("vgId:%d wal update commit index error, index:%ld, err:%d %X, msg:%s, syserr:%d, sysmsg:%s", + sError("vgId:%d wal update commit index error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pData->pSyncNode->vgId, index, err, err, errStr, sysErr, sysErrStr); ASSERT(0); @@ -530,25 +546,25 @@ cJSON* logStore2Json(SSyncLogStore* pLogStore) { cJSON_AddStringToObject(pRoot, "pWal", u64buf); SyncIndex beginIndex = raftLogBeginIndex(pLogStore); - snprintf(u64buf, sizeof(u64buf), "%ld", beginIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, beginIndex); cJSON_AddStringToObject(pRoot, "beginIndex", u64buf); SyncIndex endIndex = raftLogEndIndex(pLogStore); - snprintf(u64buf, sizeof(u64buf), "%ld", endIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, endIndex); cJSON_AddStringToObject(pRoot, "endIndex", u64buf); int32_t count = raftLogEntryCount(pLogStore); cJSON_AddNumberToObject(pRoot, "entryCount", count); - snprintf(u64buf, sizeof(u64buf), "%ld", raftLogWriteIndex(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, raftLogWriteIndex(pLogStore)); cJSON_AddStringToObject(pRoot, "WriteIndex", u64buf); snprintf(u64buf, sizeof(u64buf), "%d", raftLogIsEmpty(pLogStore)); cJSON_AddStringToObject(pRoot, "IsEmpty", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", raftLogLastIndex(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, raftLogLastIndex(pLogStore)); cJSON_AddStringToObject(pRoot, "LastIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", raftLogLastTerm(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, raftLogLastTerm(pLogStore)); cJSON_AddStringToObject(pRoot, "LastTerm", u64buf); cJSON* pEntries = cJSON_CreateArray(); @@ -587,25 +603,25 @@ cJSON* logStoreSimple2Json(SSyncLogStore* pLogStore) { cJSON_AddStringToObject(pRoot, "pWal", u64buf); SyncIndex beginIndex = raftLogBeginIndex(pLogStore); - snprintf(u64buf, sizeof(u64buf), "%ld", beginIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, beginIndex); cJSON_AddStringToObject(pRoot, "beginIndex", u64buf); SyncIndex endIndex = raftLogEndIndex(pLogStore); - snprintf(u64buf, sizeof(u64buf), "%ld", endIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, endIndex); cJSON_AddStringToObject(pRoot, "endIndex", u64buf); int32_t count = raftLogEntryCount(pLogStore); cJSON_AddNumberToObject(pRoot, "entryCount", count); - snprintf(u64buf, sizeof(u64buf), "%ld", raftLogWriteIndex(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, raftLogWriteIndex(pLogStore)); cJSON_AddStringToObject(pRoot, "WriteIndex", u64buf); snprintf(u64buf, sizeof(u64buf), "%d", raftLogIsEmpty(pLogStore)); cJSON_AddStringToObject(pRoot, "IsEmpty", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", raftLogLastIndex(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRId64, raftLogLastIndex(pLogStore)); cJSON_AddStringToObject(pRoot, "LastIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", raftLogLastTerm(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, raftLogLastTerm(pLogStore)); cJSON_AddStringToObject(pRoot, "LastTerm", u64buf); } @@ -630,14 +646,14 @@ SyncIndex logStoreFirstIndex(SSyncLogStore* pLogStore) { // for debug ----------------- void logStorePrint(SSyncLogStore* pLogStore) { char* serialized = logStore2Str(pLogStore); - printf("logStorePrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("logStorePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void logStorePrint2(char* s, SSyncLogStore* pLogStore) { char* serialized = logStore2Str(pLogStore); - printf("logStorePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("logStorePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } @@ -645,7 +661,7 @@ void logStorePrint2(char* s, SSyncLogStore* pLogStore) { void logStoreLog(SSyncLogStore* pLogStore) { if (gRaftDetailLog) { char* serialized = logStore2Str(pLogStore); - sTraceLong("logStoreLog | len:%lu | %s", strlen(serialized), serialized); + sTraceLong("logStoreLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } } @@ -653,7 +669,7 @@ void logStoreLog(SSyncLogStore* pLogStore) { void logStoreLog2(char* s, SSyncLogStore* pLogStore) { if (gRaftDetailLog) { char* serialized = logStore2Str(pLogStore); - sTraceLong("logStoreLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTraceLong("logStoreLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -661,28 +677,28 @@ void logStoreLog2(char* s, SSyncLogStore* pLogStore) { // for debug ----------------- void logStoreSimplePrint(SSyncLogStore* pLogStore) { char* serialized = logStoreSimple2Str(pLogStore); - printf("logStoreSimplePrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("logStoreSimplePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void logStoreSimplePrint2(char* s, SSyncLogStore* pLogStore) { char* serialized = logStoreSimple2Str(pLogStore); - printf("logStoreSimplePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("logStoreSimplePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void logStoreSimpleLog(SSyncLogStore* pLogStore) { char* serialized = logStoreSimple2Str(pLogStore); - sTrace("logStoreSimpleLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("logStoreSimpleLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void logStoreSimpleLog2(char* s, SSyncLogStore* pLogStore) { if (gRaftDetailLog) { char* serialized = logStoreSimple2Str(pLogStore); - sTrace("logStoreSimpleLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("logStoreSimpleLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 17d9aeaea0..18e94e0523 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -135,7 +135,7 @@ int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode) { SyncIndex newNextIndex = syncNodeGetLastIndex(pSyncNode) + 1; syncIndexMgrSetIndex(pSyncNode->pNextIndex, pDestId, newNextIndex); syncIndexMgrSetIndex(pSyncNode->pMatchIndex, pDestId, SYNC_INDEX_INVALID); - sError("vgId:%d sync get pre term error, nextIndex:%ld, update next-index:%ld, match-index:%d, raftid:%ld", + sError("vgId:%d sync get pre term error, nextIndex:%" PRId64 ", update next-index:%" PRId64 ", match-index:%d, raftid:%" PRId64, pSyncNode->vgId, nextIndex, newNextIndex, SYNC_INDEX_INVALID, pDestId->addr); return -1; @@ -151,14 +151,6 @@ int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode) { for (int32_t i = 0; i < pSyncNode->pRaftCfg->batchSize; ++i) { SSyncRaftEntry* pEntry = NULL; int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, getEntryIndex, &pEntry); - - // event log - do { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "get index:%d, code:%d, %s", getEntryIndex, code, tstrerror(terrno)); - syncNodeEventLog(pSyncNode, logBuf); - } while (0); - if (code == 0) { ASSERT(pEntry != NULL); entryPArr[i] = pEntry; @@ -172,8 +164,11 @@ int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode) { // event log do { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "build batch:%d", getCount); + char logBuf[128]; + char host[64]; + uint16_t port; + syncUtilU642Addr(pDestId->addr, host, sizeof(host), &port); + snprintf(logBuf, sizeof(logBuf), "build batch:%d for %s:%d", getCount, host, port); syncNodeEventLog(pSyncNode, logBuf); } while (0); @@ -229,7 +224,7 @@ int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode) { SyncIndex newNextIndex = syncNodeGetLastIndex(pSyncNode) + 1; syncIndexMgrSetIndex(pSyncNode->pNextIndex, pDestId, newNextIndex); syncIndexMgrSetIndex(pSyncNode->pMatchIndex, pDestId, SYNC_INDEX_INVALID); - sError("vgId:%d sync get pre term error, nextIndex:%ld, update next-index:%ld, match-index:%d, raftid:%ld", + sError("vgId:%d sync get pre term error, nextIndex:%" PRId64 ", update next-index:%" PRId64 ", match-index:%d, raftid:%" PRId64, pSyncNode->vgId, nextIndex, newNextIndex, SYNC_INDEX_INVALID, pDestId->addr); return -1; @@ -320,7 +315,7 @@ int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, c uint16_t port; syncUtilU642Addr(destRaftId->addr, host, sizeof(host), &port); sDebug( - "vgId:%d, send sync-append-entries to %s:%d, {term:%lu, pre-index:%ld, pre-term:%lu, pterm:%lu, commit:%ld, " + "vgId:%d, send sync-append-entries to %s:%d, {term:%" PRIu64 ", pre-index:%" PRId64 ", pre-term:%" PRIu64 ", pterm:%" PRIu64 ", commit:%" PRId64 ", " "datalen:%d}", pSyncNode->vgId, host, port, pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->privateTerm, pMsg->commitIndex, pMsg->dataLen); @@ -338,12 +333,10 @@ int32_t syncNodeAppendEntriesBatch(SSyncNode* pSyncNode, const SRaftId* destRaft char host[128]; uint16_t port; syncUtilU642Addr(destRaftId->addr, host, sizeof(host), &port); - sDebug( - "vgId:%d, send sync-append-entries-batch to %s:%d, {term:%lu, pre-index:%ld, pre-term:%lu, pterm:%lu, " - "commit:%ld, " - "datalen:%d, dataCount:%d}", - pSyncNode->vgId, host, port, pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->privateTerm, - pMsg->commitIndex, pMsg->dataLen, pMsg->dataCount); + sDebug("vgId:%d, send sync-append-entries-batch to %s:%d, {term:%" PRIu64 ", pre-index:%" PRId64 + ", pre-term:%" PRIu64 ", pterm:%" PRIu64 ", commit:%" PRId64 ", datalen:%d, datacount:%d}", + pSyncNode->vgId, host, port, pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->privateTerm, + pMsg->commitIndex, pMsg->dataLen, pMsg->dataCount); } while (0); SRpcMsg rpcMsg; diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index d272e0175f..db1a33c28b 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -55,7 +55,7 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) { uint16_t port; syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); snprintf(logBuf, sizeof(logBuf), - "recv sync-request-vote from %s:%d, term:%lu, lindex:%ld, lterm:%lu, maybe replica already dropped", + "recv sync-request-vote from %s:%d, term:%" PRIu64 ", lindex:%" PRId64 ", lterm:%" PRIu64 ", maybe replica already dropped", host, port, pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm); syncNodeEventLog(ths, logBuf); } while (0); @@ -97,7 +97,7 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) { uint16_t port; syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); snprintf(logBuf, sizeof(logBuf), - "recv sync-request-vote from %s:%d, term:%lu, lindex:%ld, lterm:%lu, reply-grant:%d", host, port, + "recv sync-request-vote from %s:%d, term:%" PRIu64 ", lindex:%" PRId64 ", lterm:%" PRIu64 ", reply-grant:%d", host, port, pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, pReply->voteGranted); syncNodeEventLog(ths, logBuf); } while (0); @@ -115,7 +115,7 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) { int32_t ret = 0; char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteCb== term:%lu", ths->pRaftStore->currentTerm); + snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteCb== term:%" PRIu64, ths->pRaftStore->currentTerm); syncRequestVoteLog2(logBuf, pMsg); if (pMsg->term > ths->pRaftStore->currentTerm) { @@ -181,7 +181,7 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) { uint16_t port; syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); snprintf(logBuf, sizeof(logBuf), - "recv sync-request-vote from %s:%d, term:%lu, lindex:%ld, lterm:%lu, maybe replica already dropped", + "recv sync-request-vote from %s:%d, term:%" PRIu64 ", lindex:%" PRId64 ", lterm:%" PRIu64 ", maybe replica already dropped", host, port, pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm); syncNodeEventLog(ths, logBuf); } while (0); @@ -221,7 +221,7 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) { uint16_t port; syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); snprintf(logBuf, sizeof(logBuf), - "recv sync-request-vote from %s:%d, term:%lu, lindex:%ld, lterm:%lu, reply-grant:%d", host, port, + "recv sync-request-vote from %s:%d, term:%" PRIu64 ", lindex:%" PRId64 ", lterm:%" PRIu64 ", reply-grant:%d", host, port, pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, pReply->voteGranted); syncNodeEventLog(ths, logBuf); } while (0); diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 4c205d16ec..12af7cf531 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -42,7 +42,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) // print log char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteReplyCb== term:%lu", ths->pRaftStore->currentTerm); + snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteReplyCb== term:%" PRIu64, ths->pRaftStore->currentTerm); syncRequestVoteReplyLog2(logBuf, pMsg); // if already drop replica, do not process @@ -53,7 +53,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) // drop stale response if (pMsg->term < ths->pRaftStore->currentTerm) { - sTrace("recv SyncRequestVoteReply, drop stale response, receive_term:%lu current_term:%lu", pMsg->term, + sTrace("recv SyncRequestVoteReply, drop stale response, receive_term:%" PRIu64 " current_term:%" PRIu64, pMsg->term, ths->pRaftStore->currentTerm); return ret; } @@ -66,7 +66,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) if (pMsg->term > ths->pRaftStore->currentTerm) { char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "syncNodeOnRequestVoteReplyCb error term, receive:%lu current:%lu", pMsg->term, + snprintf(logBuf, sizeof(logBuf), "syncNodeOnRequestVoteReplyCb error term, receive:%" PRIu64 " current:%" PRIu64, pMsg->term, ths->pRaftStore->currentTerm); syncNodePrint2(logBuf, ths); sError("%s", logBuf); @@ -107,7 +107,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) int32_t ret = 0; char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteReplyCb== term:%lu", ths->pRaftStore->currentTerm); + snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteReplyCb== term:%" PRIu64, ths->pRaftStore->currentTerm); syncRequestVoteReplyLog2(logBuf, pMsg); if (pMsg->term < ths->pRaftStore->currentTerm) { @@ -124,7 +124,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) if (pMsg->term > ths->pRaftStore->currentTerm) { char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "syncNodeOnRequestVoteReplyCb error term, receive:%lu current:%lu", pMsg->term, + snprintf(logBuf, sizeof(logBuf), "syncNodeOnRequestVoteReplyCb error term, receive:%" PRIu64 " current:%" PRIu64, pMsg->term, ths->pRaftStore->currentTerm); syncNodePrint2(logBuf, ths); sError("%s", logBuf); @@ -166,7 +166,7 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl // print log char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "recv SyncRequestVoteReply, term:%lu", ths->pRaftStore->currentTerm); + snprintf(logBuf, sizeof(logBuf), "recv SyncRequestVoteReply, term:%" PRIu64, ths->pRaftStore->currentTerm); syncRequestVoteReplyLog2(logBuf, pMsg); // if already drop replica, do not process @@ -177,7 +177,7 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl // drop stale response if (pMsg->term < ths->pRaftStore->currentTerm) { - sTrace("recv SyncRequestVoteReply, drop stale response, receive_term:%lu current_term:%lu", pMsg->term, + sTrace("recv SyncRequestVoteReply, drop stale response, receive_term:%" PRIu64 " current_term:%" PRIu64, pMsg->term, ths->pRaftStore->currentTerm); return ret; } @@ -190,7 +190,7 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl if (pMsg->term > ths->pRaftStore->currentTerm) { char logBuf[128] = {0}; - snprintf(logBuf, sizeof(logBuf), "recv SyncRequestVoteReply, error term, receive_term:%lu current_term:%lu", + snprintf(logBuf, sizeof(logBuf), "recv SyncRequestVoteReply, error term, receive_term:%" PRIu64 " current_term:%" PRIu64, pMsg->term, ths->pRaftStore->currentTerm); syncNodePrint2(logBuf, ths); sError("%s", logBuf); diff --git a/source/libs/sync/src/syncRespMgr.c b/source/libs/sync/src/syncRespMgr.c index 8dd1349edb..eaeadd3991 100644 --- a/source/libs/sync/src/syncRespMgr.c +++ b/source/libs/sync/src/syncRespMgr.c @@ -50,7 +50,7 @@ int64_t syncRespMgrAdd(SSyncRespMgr *pObj, SRespStub *pStub) { SSyncNode *pSyncNode = pObj->data; char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "resp mgr add, type:%s,%d, seq:%lu, handle:%p, ahandle:%p", + snprintf(eventLog, sizeof(eventLog), "resp mgr add, type:%s,%d, seq:%" PRIu64 ", handle:%p, ahandle:%p", TMSG_INFO(pStub->rpcMsg.msgType), pStub->rpcMsg.msgType, keyCode, pStub->rpcMsg.info.handle, pStub->rpcMsg.info.ahandle); syncNodeEventLog(pSyncNode, eventLog); @@ -77,7 +77,7 @@ int32_t syncRespMgrGet(SSyncRespMgr *pObj, uint64_t index, SRespStub *pStub) { SSyncNode *pSyncNode = pObj->data; char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "resp mgr get, type:%s,%d, seq:%lu, handle:%p, ahandle:%p", + snprintf(eventLog, sizeof(eventLog), "resp mgr get, type:%s,%d, seq:%" PRIu64 ", handle:%p, ahandle:%p", TMSG_INFO(pStub->rpcMsg.msgType), pStub->rpcMsg.msgType, index, pStub->rpcMsg.info.handle, pStub->rpcMsg.info.ahandle); syncNodeEventLog(pSyncNode, eventLog); @@ -98,7 +98,7 @@ int32_t syncRespMgrGetAndDel(SSyncRespMgr *pObj, uint64_t index, SRespStub *pStu SSyncNode *pSyncNode = pObj->data; char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "resp mgr get-and-del, type:%s,%d, seq:%lu, handle:%p, ahandle:%p", + snprintf(eventLog, sizeof(eventLog), "resp mgr get-and-del, type:%s,%d, seq:%" PRIu64 ", handle:%p, ahandle:%p", TMSG_INFO(pStub->rpcMsg.msgType), pStub->rpcMsg.msgType, index, pStub->rpcMsg.info.handle, pStub->rpcMsg.info.ahandle); syncNodeEventLog(pSyncNode, eventLog); diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index a33f66733b..3079aa17ca 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -153,7 +153,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshotParam snapsho // event log do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "snapshot sender update lcindex from %ld to %ld", oldLastConfigIndex, + snprintf(logBuf, sizeof(logBuf), "snapshot sender update lcindex from %" PRId64 " to %" PRId64, oldLastConfigIndex, newLastConfigIndex); char *eventLog = snapshotSender2SimpleStr(pSender, logBuf); syncNodeEventLog(pSender->pSyncNode, eventLog); @@ -350,19 +350,19 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) { } cJSON *pSnapshot = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pSender->snapshot.lastApplyIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSender->snapshot.lastApplyIndex); cJSON_AddStringToObject(pSnapshot, "lastApplyIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSender->snapshot.lastApplyTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSender->snapshot.lastApplyTerm); cJSON_AddStringToObject(pSnapshot, "lastApplyTerm", u64buf); cJSON_AddItemToObject(pRoot, "snapshot", pSnapshot); - snprintf(u64buf, sizeof(u64buf), "%lu", pSender->sendingMS); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSender->sendingMS); cJSON_AddStringToObject(pRoot, "sendingMS", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSender->pSyncNode); cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); cJSON_AddNumberToObject(pRoot, "replicaIndex", pSender->replicaIndex); - snprintf(u64buf, sizeof(u64buf), "%lu", pSender->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSender->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSender->privateTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pSender->privateTerm); cJSON_AddStringToObject(pRoot, "privateTerm", u64buf); cJSON_AddNumberToObject(pRoot, "finish", pSender->finish); } @@ -389,7 +389,7 @@ char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event) { syncUtilU642Addr(destId.addr, host, sizeof(host), &port); snprintf(s, len, - "%s {%p s-param:%ld e-param:%ld laindex:%ld laterm:%lu lcindex:%ld seq:%d ack:%d finish:%d pterm:%lu " + "%s {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64 " seq:%d ack:%d finish:%d pterm:%" PRIu64 " " "replica-index:%d %s:%d}", event, pSender, pSender->snapshotParam.start, pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, @@ -640,7 +640,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); cJSON *pFromId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pReceiver->fromId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pReceiver->fromId.addr); cJSON_AddStringToObject(pFromId, "addr", u64buf); { uint64_t u64 = pReceiver->fromId.addr; @@ -654,19 +654,19 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { cJSON_AddNumberToObject(pFromId, "vgId", pReceiver->fromId.vgId); cJSON_AddItemToObject(pRoot, "fromId", pFromId); - snprintf(u64buf, sizeof(u64buf), "%lu", pReceiver->snapshot.lastApplyIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pReceiver->snapshot.lastApplyIndex); cJSON_AddStringToObject(pRoot, "snapshot.lastApplyIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pReceiver->snapshot.lastApplyTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pReceiver->snapshot.lastApplyTerm); cJSON_AddStringToObject(pRoot, "snapshot.lastApplyTerm", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pReceiver->snapshot.lastConfigIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pReceiver->snapshot.lastConfigIndex); cJSON_AddStringToObject(pRoot, "snapshot.lastConfigIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pReceiver->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pReceiver->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pReceiver->privateTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pReceiver->privateTerm); cJSON_AddStringToObject(pRoot, "privateTerm", u64buf); } @@ -692,8 +692,8 @@ char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event) syncUtilU642Addr(fromId.addr, host, sizeof(host), &port); snprintf(s, len, - "%s {%p start:%d ack:%d term:%lu pterm:%lu from:%s:%d s-param:%ld e-param:%ld laindex:%ld laterm:%lu " - "lcindex:%ld}", + "%s {%p start:%d ack:%d term:%" PRIu64 " pterm:%" PRIu64 " from:%s:%d s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " " + "lcindex:%" PRId64 "}", event, pReceiver, pReceiver->start, pReceiver->ack, pReceiver->term, pReceiver->privateTerm, host, port, pReceiver->snapshotParam.start, pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, pReceiver->snapshot.lastConfigIndex); diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 2c43312064..1d46d71a05 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -109,7 +109,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { cJSON_AddItemToObject(pRoot, "isGranted", pIsGranted); cJSON_AddNumberToObject(pRoot, "votes", pVotesGranted->votes); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesGranted->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pVotesGranted->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum); cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader); @@ -135,27 +135,27 @@ char *voteGranted2Str(SVotesGranted *pVotesGranted) { // for debug ------------------- void voteGrantedPrint(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("voteGrantedPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void voteGrantedPrint2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("voteGrantedPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void voteGrantedLog(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("voteGrantedLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void voteGrantedLog2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("voteGrantedLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } @@ -243,7 +243,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { cJSON_AddItemToObject(pRoot, "isRespond", pIsRespond); cJSON_AddNumberToObject(pRoot, "respondNum", respondNum); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesRespond->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pVotesRespond->term); cJSON_AddStringToObject(pRoot, "term", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode); cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); @@ -264,26 +264,26 @@ char *votesRespond2Str(SVotesRespond *pVotesRespond) { // for debug ------------------- void votesRespondPrint(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("votesRespondPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void votesRespondPrint2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("votesRespondPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void votesRespondLog(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("votesRespondLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void votesRespondLog2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("votesRespondLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index 37d9707cfd..e1f3a2b2fc 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -54,6 +54,7 @@ add_executable(syncRaftLogTest2 "") add_executable(syncRaftLogTest3 "") add_executable(syncLeaderTransferTest "") add_executable(syncReconfigFinishTest "") +add_executable(syncRestoreFromSnapshot "") target_sources(syncTest @@ -280,6 +281,10 @@ target_sources(syncReconfigFinishTest PRIVATE "syncReconfigFinishTest.cpp" ) +target_sources(syncRestoreFromSnapshot + PRIVATE + "syncRestoreFromSnapshot.cpp" +) target_include_directories(syncTest @@ -562,6 +567,11 @@ target_include_directories(syncReconfigFinishTest "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncRestoreFromSnapshot + PUBLIC + "${TD_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_link_libraries(syncTest @@ -788,6 +798,10 @@ target_link_libraries(syncReconfigFinishTest sync gtest_main ) +target_link_libraries(syncRestoreFromSnapshot + sync + gtest_main +) enable_testing() diff --git a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp index 7cd97695f9..de82df3fbd 100644 --- a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp +++ b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp @@ -45,19 +45,19 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { if (cbMeta.index > beginIndex) { char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), - "==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, flag:%lu, term:%lu \n", + "==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64 ", term:%" PRIu64 " \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag, cbMeta.term); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); } else { - sTrace("==callback== ==CommitCb== do not apply again %ld", cbMeta.index); + sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index); } } void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), - "==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s flag:%lu\n", pFsm, + "==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); } @@ -65,7 +65,7 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256]; snprintf(logBuf, sizeof(logBuf), - "==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s flag:%lu\n", pFsm, + "==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); } @@ -147,7 +147,7 @@ int32_t SnapshotDoWrite(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_ void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb=="); } void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta) { - sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%ld, code:%d, currentTerm:%lu, term:%lu", cbMeta.flag, + sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64, cbMeta.flag, cbMeta.index, cbMeta.code, cbMeta.currentTerm, cbMeta.term); } @@ -267,7 +267,7 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) { pMsg->msgType = 9999; pMsg->contLen = 256; pMsg->pCont = rpcMallocCont(pMsg->contLen); - snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-%ld", myIndex, i, count, taosGetTimestampMs()); + snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-" PRId64, myIndex, i, count, taosGetTimestampMs()); return pMsg; } diff --git a/source/libs/sync/test/syncConfigChangeTest.cpp b/source/libs/sync/test/syncConfigChangeTest.cpp index c96e337378..80a5e65274 100644 --- a/source/libs/sync/test/syncConfigChangeTest.cpp +++ b/source/libs/sync/test/syncConfigChangeTest.cpp @@ -44,18 +44,18 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { if (cbMeta.index > beginIndex) { char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), - "==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s flag:%lu\n", pFsm, + "==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); } else { - sTrace("==callback== ==CommitCb== do not apply again %ld", cbMeta.index); + sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index); } } void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), - "==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s flag:%lu\n", pFsm, + "==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); } @@ -63,7 +63,7 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256]; snprintf(logBuf, sizeof(logBuf), - "==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s flag:%lu\n", pFsm, + "==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s flag:%" PRIu64 "\n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); } @@ -78,7 +78,7 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) { void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb=="); } void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta) { - sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%ld, code:%d, currentTerm:%lu, term:%lu", cbMeta.flag, + sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64, cbMeta.flag, cbMeta.index, cbMeta.code, cbMeta.currentTerm, cbMeta.term); } @@ -188,7 +188,7 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) { pMsg->msgType = 9999; pMsg->contLen = 256; pMsg->pCont = rpcMallocCont(pMsg->contLen); - snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-%ld", myIndex, i, count, taosGetTimestampMs()); + snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-" PRId64, myIndex, i, count, taosGetTimestampMs()); return pMsg; } diff --git a/source/libs/sync/test/syncIndexMgrTest.cpp b/source/libs/sync/test/syncIndexMgrTest.cpp index 0ad69f0f51..23b8693a0b 100644 --- a/source/libs/sync/test/syncIndexMgrTest.cpp +++ b/source/libs/sync/test/syncIndexMgrTest.cpp @@ -81,7 +81,7 @@ int main(int argc, char** argv) { for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { SyncIndex idx = syncIndexMgrGetIndex(pSyncIndexMgr, &ids[i]); // SyncTerm term = syncIndexMgrGetTerm(pSyncIndexMgr, &ids[i]); - // printf("%d: index:%ld term:%lu \n", i, idx, term); + // printf("%d: index:%" PRId64 " term:%" PRIu64 " \n", i, idx, term); } printf("---------------------------------------\n"); diff --git a/source/libs/sync/test/syncIndexTest.cpp b/source/libs/sync/test/syncIndexTest.cpp index 07a05d437e..91c7800756 100644 --- a/source/libs/sync/test/syncIndexTest.cpp +++ b/source/libs/sync/test/syncIndexTest.cpp @@ -13,7 +13,7 @@ void print(SHashObj *pNextIndex) { SRaftId *pRaftId = (SRaftId *)key; - printf("key:<%lu, %d>, value:%lu \n", pRaftId->addr, pRaftId->vgId, *p); + printf("key:<" PRIu64 ", %d>, value:%" PRIu64 " \n", pRaftId->addr, pRaftId->vgId, *p); p = (uint64_t *)taosHashIterate(pNextIndex, p); } } diff --git a/source/libs/sync/test/syncLogStoreTest.cpp b/source/libs/sync/test/syncLogStoreTest.cpp index 27e1009335..9cb8194aa7 100644 --- a/source/libs/sync/test/syncLogStoreTest.cpp +++ b/source/libs/sync/test/syncLogStoreTest.cpp @@ -85,6 +85,7 @@ void logStoreTest() { } int main(int argc, char** argv) { + gRaftDetailLog = true; tsAsyncLog = 0; sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE; diff --git a/source/libs/sync/test/syncRaftIdCheck.cpp b/source/libs/sync/test/syncRaftIdCheck.cpp index 90560e91e7..65da0f6631 100644 --- a/source/libs/sync/test/syncRaftIdCheck.cpp +++ b/source/libs/sync/test/syncRaftIdCheck.cpp @@ -15,14 +15,14 @@ int main(int argc, char** argv) { char host[128]; uint16_t port; syncUtilU642Addr(u64, host, sizeof(host), &port); - printf("%lu -> %s:%d \n", u64, host, port); + printf("" PRIu64 " -> %s:%d \n", u64, host, port); } else if (argc == 3) { uint64_t u64; char* host = argv[1]; uint16_t port = atoi(argv[2]); u64 = syncUtilAddr2U64(host, port); - printf("%s:%d -> %lu \n", host, port, u64); + printf("%s:%d ->: %" PRIu64 " \n", host, port, u64); } else { usage(argv[0]); exit(-1); diff --git a/source/libs/sync/test/syncRaftLogTest.cpp b/source/libs/sync/test/syncRaftLogTest.cpp index 7903e86749..278113919a 100644 --- a/source/libs/sync/test/syncRaftLogTest.cpp +++ b/source/libs/sync/test/syncRaftLogTest.cpp @@ -38,7 +38,7 @@ void test1() { int64_t firstVer = walGetFirstVer(pWal); int64_t lastVer = walGetLastVer(pWal); - printf("firstVer:%ld lastVer:%ld \n", firstVer, lastVer); + printf("firstVer:%" PRId64 " lastVer:%" PRId64 " \n", firstVer, lastVer); walClose(pWal); } @@ -68,7 +68,7 @@ void test2() { int64_t firstVer = walGetFirstVer(pWal); int64_t lastVer = walGetLastVer(pWal); - printf("firstVer:%ld lastVer:%ld \n", firstVer, lastVer); + printf("firstVer:%" PRId64 " lastVer:%" PRId64 " \n", firstVer, lastVer); walClose(pWal); } @@ -92,7 +92,7 @@ void test3() { int64_t firstVer = walGetFirstVer(pWal); int64_t lastVer = walGetLastVer(pWal); - printf("firstVer:%ld lastVer:%ld \n", firstVer, lastVer); + printf("firstVer:%" PRId64 " lastVer:%" PRId64 " \n", firstVer, lastVer); walClose(pWal); } @@ -124,7 +124,7 @@ void test4() { int64_t firstVer = walGetFirstVer(pWal); int64_t lastVer = walGetLastVer(pWal); - printf("firstVer:%ld lastVer:%ld \n", firstVer, lastVer); + printf("firstVer:%" PRId64 " lastVer:%" PRId64 " \n", firstVer, lastVer); walClose(pWal); } @@ -149,7 +149,7 @@ void test5() { int64_t firstVer = walGetFirstVer(pWal); int64_t lastVer = walGetLastVer(pWal); - printf("firstVer:%ld lastVer:%ld \n", firstVer, lastVer); + printf("firstVer:%" PRId64 " lastVer:%" PRId64 " \n", firstVer, lastVer); walClose(pWal); } diff --git a/source/libs/sync/test/syncRaftLogTest2.cpp b/source/libs/sync/test/syncRaftLogTest2.cpp index 9e0c2ecc29..0cb9b51fba 100644 --- a/source/libs/sync/test/syncRaftLogTest2.cpp +++ b/source/libs/sync/test/syncRaftLogTest2.cpp @@ -413,7 +413,7 @@ void test6() { SyncIndex firstVer = walGetFirstVer(pWal); SyncIndex lastVer = walGetLastVer(pWal); bool isEmpty = walIsEmpty(pWal); - printf("before -------- firstVer:%ld lastVer:%ld isEmpty:%d \n", firstVer, lastVer, isEmpty); + printf("before -------- firstVer:%" PRId64 " lastVer:%" PRId64 " isEmpty:%d \n", firstVer, lastVer, isEmpty); } while (0); logStoreDestory(pLogStore); @@ -429,7 +429,7 @@ void test6() { SyncIndex firstVer = walGetFirstVer(pWal); SyncIndex lastVer = walGetLastVer(pWal); bool isEmpty = walIsEmpty(pWal); - printf("after -------- firstVer:%ld lastVer:%ld isEmpty:%d \n", firstVer, lastVer, isEmpty); + printf("after -------- firstVer:%" PRId64 " lastVer:%" PRId64 " isEmpty:%d \n", firstVer, lastVer, isEmpty); } while (0); logStoreLog2((char*)"\n\n\ntest6 restart ----- ", pLogStore); diff --git a/source/libs/sync/test/syncRaftLogTest3.cpp b/source/libs/sync/test/syncRaftLogTest3.cpp index ea1788c545..fd4cade31c 100644 --- a/source/libs/sync/test/syncRaftLogTest3.cpp +++ b/source/libs/sync/test/syncRaftLogTest3.cpp @@ -92,13 +92,13 @@ void test1() { SyncIndex syncStartIndex = syncNodeSyncStartIndex(pSyncNode); sTrace("test1"); - sTrace("hasSnapshot:%d, lastApplyIndex:%ld, lastApplyTerm:%lu", hasSnapshot, snapshot.lastApplyIndex, + sTrace("hasSnapshot:%d, lastApplyIndex:%" PRId64 ", lastApplyTerm:%" PRIu64, hasSnapshot, snapshot.lastApplyIndex, snapshot.lastApplyTerm); - sTrace("lastIndex: %ld", lastIndex); - sTrace("lastTerm: %lu", lastTerm); - sTrace("syncStartIndex: %ld", syncStartIndex); - sTrace("%ld's preIndex: %ld", testIndex, preIndex); - sTrace("%ld's preTerm: %lu", testIndex, preTerm); + sTrace("lastIndex: %" PRId64, lastIndex); + sTrace("lastTerm: %" PRIu64, lastTerm); + sTrace("syncStartIndex: %" PRId64, syncStartIndex); + sTrace("" PRId64 "'s preIndex: %" PRId64, testIndex, preIndex); + sTrace("" PRId64 "'s preTerm: %" PRIu64, testIndex, preTerm); if (gAssert) { assert(lastIndex == -1); @@ -154,11 +154,11 @@ void test2() { SyncIndex syncStartIndex = syncNodeSyncStartIndex(pSyncNode); sTrace("test2"); - sTrace("hasSnapshot:%d, lastApplyIndex:%ld, lastApplyTerm:%lu", hasSnapshot, snapshot.lastApplyIndex, + sTrace("hasSnapshot:%d, lastApplyIndex:%" PRId64 ", lastApplyTerm:%" PRIu64, hasSnapshot, snapshot.lastApplyIndex, snapshot.lastApplyTerm); - sTrace("lastIndex: %ld", lastIndex); - sTrace("lastTerm: %lu", lastTerm); - sTrace("syncStartIndex: %ld", syncStartIndex); + sTrace("lastIndex: %" PRId64, lastIndex); + sTrace("lastTerm: %" PRIu64, lastTerm); + sTrace("syncStartIndex: %" PRId64, syncStartIndex); if (gAssert) { assert(lastIndex == 10); @@ -170,8 +170,8 @@ void test2() { SyncIndex preIndex = syncNodeGetPreIndex(pSyncNode, i); SyncTerm preTerm = syncNodeGetPreTerm(pSyncNode, i); - sTrace("%ld's preIndex: %ld", i, preIndex); - sTrace("%ld's preTerm: %lu", i, preTerm); + sTrace("" PRId64 "'s preIndex: %" PRId64, i, preIndex); + sTrace("" PRId64 "'s preTerm: %" PRIu64, i, preTerm); if (gAssert) { SyncIndex preIndexArr[12] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; @@ -214,13 +214,13 @@ void test3() { SyncIndex syncStartIndex = syncNodeSyncStartIndex(pSyncNode); sTrace("test3"); - sTrace("hasSnapshot:%d, lastApplyIndex:%ld, lastApplyTerm:%lu", hasSnapshot, snapshot.lastApplyIndex, + sTrace("hasSnapshot:%d, lastApplyIndex:%" PRId64 ", lastApplyTerm:%" PRIu64, hasSnapshot, snapshot.lastApplyIndex, snapshot.lastApplyTerm); - sTrace("lastIndex: %ld", lastIndex); - sTrace("lastTerm: %lu", lastTerm); - sTrace("syncStartIndex: %ld", syncStartIndex); - sTrace("%d's preIndex: %ld", 6, preIndex); - sTrace("%d's preTerm: %lu", 6, preTerm); + sTrace("lastIndex: %" PRId64, lastIndex); + sTrace("lastTerm: %" PRIu64, lastTerm); + sTrace("syncStartIndex: %" PRId64, syncStartIndex); + sTrace("%d's preIndex: %" PRId64, 6, preIndex); + sTrace("%d's preTerm: %" PRIu64, 6, preTerm); if (gAssert) { assert(lastIndex == 5); @@ -276,11 +276,11 @@ void test4() { SyncIndex syncStartIndex = syncNodeSyncStartIndex(pSyncNode); sTrace("test4"); - sTrace("hasSnapshot:%d, lastApplyIndex:%ld, lastApplyTerm:%lu", hasSnapshot, snapshot.lastApplyIndex, + sTrace("hasSnapshot:%d, lastApplyIndex:%" PRId64 ", lastApplyTerm:%" PRIu64, hasSnapshot, snapshot.lastApplyIndex, snapshot.lastApplyTerm); - sTrace("lastIndex: %ld", lastIndex); - sTrace("lastTerm: %lu", lastTerm); - sTrace("syncStartIndex: %ld", syncStartIndex); + sTrace("lastIndex: %" PRId64, lastIndex); + sTrace("lastTerm: %" PRIu64, lastTerm); + sTrace("syncStartIndex: %" PRId64, syncStartIndex); if (gAssert) { assert(lastIndex == 10); @@ -292,8 +292,8 @@ void test4() { SyncIndex preIndex = syncNodeGetPreIndex(pSyncNode, i); SyncTerm preTerm = syncNodeGetPreTerm(pSyncNode, i); - sTrace("%ld's preIndex: %ld", i, preIndex); - sTrace("%ld's preTerm: %lu", i, preTerm); + sTrace("" PRId64 "'s preIndex: %" PRId64, i, preIndex); + sTrace("" PRId64 "'s preTerm: %" PRIu64, i, preTerm); } logStoreDestory(pLogStore); @@ -344,18 +344,18 @@ void test5() { SyncIndex syncStartIndex = syncNodeSyncStartIndex(pSyncNode); sTrace("test5"); - sTrace("hasSnapshot:%d, lastApplyIndex:%ld, lastApplyTerm:%lu", hasSnapshot, snapshot.lastApplyIndex, + sTrace("hasSnapshot:%d, lastApplyIndex:%" PRId64 ", lastApplyTerm:%" PRIu64, hasSnapshot, snapshot.lastApplyIndex, snapshot.lastApplyTerm); - sTrace("lastIndex: %ld", lastIndex); - sTrace("lastTerm: %lu", lastTerm); - sTrace("syncStartIndex: %ld", syncStartIndex); + sTrace("lastIndex: %" PRId64, lastIndex); + sTrace("lastTerm: %" PRIu64, lastTerm); + sTrace("syncStartIndex: %" PRId64, syncStartIndex); for (SyncIndex i = 11; i >= 6; --i) { SyncIndex preIndex = syncNodeGetPreIndex(pSyncNode, i); SyncTerm preTerm = syncNodeGetPreTerm(pSyncNode, i); - sTrace("%ld's preIndex: %ld", i, preIndex); - sTrace("%ld's preTerm: %lu", i, preTerm); + sTrace("" PRId64 "'s preIndex: %" PRId64, i, preIndex); + sTrace("" PRId64 "'s preTerm: %" PRIu64, i, preTerm); if (gAssert) { SyncIndex preIndexArr[12] = {9999, 9999, 9999, 9999, 9999, 9999, 5, 6, 7, 8, 9, 10}; diff --git a/source/libs/sync/test/syncRefTest.cpp b/source/libs/sync/test/syncRefTest.cpp index 96062b1a91..90923a87ee 100644 --- a/source/libs/sync/test/syncRefTest.cpp +++ b/source/libs/sync/test/syncRefTest.cpp @@ -32,7 +32,7 @@ typedef struct SyncObj { static void syncFreeObj(void *param) { SyncObj *pObj = (SyncObj *)param; - printf("syncFreeObj name:%s rid:%ld \n", pObj->name, pObj->rid); + printf("syncFreeObj name:%s rid:%" PRId64 " \n", pObj->name, pObj->rid); taosMemoryFree(pObj); } @@ -66,7 +66,7 @@ int64_t start() { return -1; } - printf("start name:%s rid:%ld \n", pObj->name, pObj->rid); + printf("start name:%s rid:%" PRId64 " \n", pObj->name, pObj->rid); return pObj->rid; } @@ -74,7 +74,7 @@ void stop(int64_t rid) { SyncObj *pObj = (SyncObj *)taosAcquireRef(tsNodeRefId, rid); if (pObj == NULL) return; - printf("stop name:%s rid:%ld \n", pObj->name, pObj->rid); + printf("stop name:%s rid:%" PRId64 " \n", pObj->name, pObj->rid); pObj->data = NULL; taosReleaseRef(tsNodeRefId, pObj->rid); @@ -89,7 +89,7 @@ void *func(void *param) { SyncObj *pObj = (SyncObj *)taosAcquireRef(tsNodeRefId, rid); if (pObj != NULL) { - printf("taosAcquireRef sleep:%d, name:%s, rid:%ld \n", ms, pObj->name, pObj->rid); + printf("taosAcquireRef sleep:%d, name:%s, rid:%" PRId64 " \n", ms, pObj->name, pObj->rid); } else { printf("taosAcquireRef sleep:%d, NULL! \n", ms); } diff --git a/source/libs/sync/test/syncReplicateTest.cpp b/source/libs/sync/test/syncReplicateTest.cpp index 66f347b620..9148ab6195 100644 --- a/source/libs/sync/test/syncReplicateTest.cpp +++ b/source/libs/sync/test/syncReplicateTest.cpp @@ -40,25 +40,25 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { if (cbMeta.index > beginIndex) { char logBuf[256]; - snprintf(logBuf, sizeof(logBuf), "==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", + snprintf(logBuf, sizeof(logBuf), "==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state)); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); } else { - sTrace("==callback== ==CommitCb== do not apply again %ld", cbMeta.index); + sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index); } } void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256]; snprintf(logBuf, sizeof(logBuf), - "==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, + "==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state)); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); } void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256]; - snprintf(logBuf, sizeof(logBuf), "==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", + snprintf(logBuf, sizeof(logBuf), "==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state)); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); } @@ -143,7 +143,7 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) { pMsg->msgType = 9999; pMsg->contLen = 256; pMsg->pCont = rpcMallocCont(pMsg->contLen); - snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-%ld", myIndex, i, count, taosGetTimestampMs()); + snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-" PRId64, myIndex, i, count, taosGetTimestampMs()); return pMsg; } diff --git a/source/libs/sync/test/syncRespMgrTest.cpp b/source/libs/sync/test/syncRespMgrTest.cpp index 93a7ce430f..9e982e0a59 100644 --- a/source/libs/sync/test/syncRespMgrTest.cpp +++ b/source/libs/sync/test/syncRespMgrTest.cpp @@ -23,7 +23,7 @@ void syncRespMgrInsert(uint64_t count) { stub.rpcMsg.info.ahandle = (void *)(200 + i); stub.rpcMsg.info.handle = (void *)(300 + i); uint64_t ret = syncRespMgrAdd(pMgr, &stub); - printf("insert %lu \n", ret); + printf("insert: %" PRIu64 " \n", ret); } } @@ -35,7 +35,7 @@ void syncRespMgrDelTest(uint64_t begin, uint64_t end) { } void printStub(SRespStub *p) { - printf("createTime:%ld, rpcMsg.code:%d rpcMsg.ahandle:%ld rpcMsg.handle:%ld \n", p->createTime, p->rpcMsg.code, + printf("createTime:%" PRId64 ", rpcMsg.code:%d rpcMsg.ahandle:%" PRId64 " rpcMsg.handle:%" PRId64 " \n", p->createTime, p->rpcMsg.code, (int64_t)(p->rpcMsg.info.ahandle), (int64_t)(p->rpcMsg.info.handle)); } void syncRespMgrPrint() { @@ -52,24 +52,24 @@ void syncRespMgrPrint() { } void syncRespMgrGetTest(uint64_t i) { - printf("------syncRespMgrGetTest------- %lu -- \n", i); + printf("------syncRespMgrGetTest-------: %" PRIu64 " -- \n", i); SRespStub stub; int32_t ret = syncRespMgrGet(pMgr, i, &stub); if (ret == 1) { printStub(&stub); } else if (ret == 0) { - printf("%ld notFound \n", i); + printf("" PRId64 " notFound \n", i); } } void syncRespMgrGetAndDelTest(uint64_t i) { - printf("------syncRespMgrGetAndDelTest-------%lu-- \n", i); + printf("------syncRespMgrGetAndDelTest-------" PRIu64 "-- \n", i); SRespStub stub; int32_t ret = syncRespMgrGetAndDel(pMgr, i, &stub); if (ret == 1) { printStub(&stub); } else if (ret == 0) { - printf("%ld notFound \n", i); + printf("" PRId64 " notFound \n", i); } } diff --git a/source/libs/sync/test/syncRestoreFromSnapshot.cpp b/source/libs/sync/test/syncRestoreFromSnapshot.cpp new file mode 100644 index 0000000000..470dd678b0 --- /dev/null +++ b/source/libs/sync/test/syncRestoreFromSnapshot.cpp @@ -0,0 +1,78 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftLog.h" +#include "syncRaftStore.h" +#include "syncUtil.h" +#include "wal.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +void init() { + int code = walInit(); + assert(code == 0); +} + +void cleanup() { walCleanUp(); } + +SWal* createWal(char* path, int32_t vgId) { + SWalCfg walCfg; + memset(&walCfg, 0, sizeof(SWalCfg)); + walCfg.vgId = vgId; + walCfg.fsyncPeriod = 1000; + walCfg.retentionPeriod = 1000; + walCfg.rollPeriod = 1000; + walCfg.retentionSize = 1000; + walCfg.segSize = 1000; + walCfg.level = TAOS_WAL_FSYNC; + SWal* pWal = walOpen(path, &walCfg); + assert(pWal != NULL); + return pWal; +} + +SSyncNode* createSyncNode(SWal* pWal) { + SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(SSyncNode)); + memset(pSyncNode, 0, sizeof(SSyncNode)); + pSyncNode->pWal = pWal; + return pSyncNode; +} + +void usage(char* exe) { printf("usage: %s path vgId snapshotIndex \n", exe); } + +int main(int argc, char** argv) { + if (argc != 4) { + usage(argv[0]); + exit(-1); + } + char* path = argv[1]; + int32_t vgId = atoi(argv[2]); + int64_t snapshotIndex = atoll(argv[3]); + + init(); + SWal* pWal = createWal(path, vgId); + assert(pWal != NULL); + SSyncNode* pSyncNode = createSyncNode(pWal); + assert(pSyncNode != NULL); + + SSyncLogStore* pLog = logStoreCreate(pSyncNode); + assert(pLog != NULL); + + int32_t code = pLog->syncLogRestoreFromSnapshot(pLog, snapshotIndex); + assert(code == 0); + + walClose(pWal); + logStoreDestory(pLog); + taosMemoryFree(pSyncNode); + + cleanup(); + return 0; +} diff --git a/source/libs/sync/test/syncSnapshotTest.cpp b/source/libs/sync/test/syncSnapshotTest.cpp index 954bdd8ea5..9e50fa62ef 100644 --- a/source/libs/sync/test/syncSnapshotTest.cpp +++ b/source/libs/sync/test/syncSnapshotTest.cpp @@ -43,25 +43,25 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { if (cbMeta.index > beginIndex) { char logBuf[256]; - snprintf(logBuf, sizeof(logBuf), "==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", + snprintf(logBuf, sizeof(logBuf), "==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state)); syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); } else { - sTrace("==callback== ==CommitCb== do not apply again %ld", cbMeta.index); + sTrace("==callback== ==CommitCb== do not apply again %" PRId64, cbMeta.index); } } void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { char logBuf[256]; snprintf(logBuf, sizeof(logBuf), - "==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, + "==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state)); syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); } void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { char logBuf[256]; - snprintf(logBuf, sizeof(logBuf), "==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", + snprintf(logBuf, sizeof(logBuf), "==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state)); syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); } @@ -172,7 +172,7 @@ int main(int argc, char **argv) { if (argc >= 2) { snapshotLastApplyIndex = atoi(argv[1]); } - sTrace("--snapshotLastApplyIndex : %ld \n", snapshotLastApplyIndex); + sTrace("--snapshotLastApplyIndex : %" PRId64 " \n", snapshotLastApplyIndex); int32_t ret = syncIOStart((char *)"127.0.0.1", ports[myIndex]); assert(ret == 0); diff --git a/source/libs/sync/test/syncTestTool.cpp b/source/libs/sync/test/syncTestTool.cpp index 2c08910aa8..714b73a9e5 100644 --- a/source/libs/sync/test/syncTestTool.cpp +++ b/source/libs/sync/test/syncTestTool.cpp @@ -40,8 +40,8 @@ void cleanup() { walCleanUp(); } void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), - "==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, flag:%lu, term:%lu " - "currentTerm:%lu \n", + "==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64 ", term:%" PRIu64 " " + "currentTerm:%" PRIu64 " \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag, cbMeta.term, cbMeta.currentTerm); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); @@ -50,8 +50,8 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), - "==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, flag:%lu, term:%lu " - "currentTerm:%lu \n", + "==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64 ", term:%" PRIu64 " " + "currentTerm:%" PRIu64 " \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag, cbMeta.term, cbMeta.currentTerm); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); @@ -60,8 +60,8 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), - "==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, flag:%lu, term:%lu " - "currentTerm:%lu \n", + "==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64 ", term:%" PRIu64 " " + "currentTerm:%" PRIu64 " \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag, cbMeta.term, cbMeta.currentTerm); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); @@ -128,8 +128,8 @@ int32_t SnapshotStopWrite(struct SSyncFSM* pFsm, void* pWriter, bool isApply) { char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), - "==callback== ==SnapshotStopWrite== pFsm:%p, pWriter:%p, isApply:%d, gSnapshotLastApplyIndex:%ld, " - "gSnapshotLastApplyTerm:%ld", + "==callback== ==SnapshotStopWrite== pFsm:%p, pWriter:%p, isApply:%d, gSnapshotLastApplyIndex:%" PRId64 ", " + "gSnapshotLastApplyTerm:%" PRId64, pFsm, pWriter, isApply, gSnapshotLastApplyIndex, gSnapshotLastApplyTerm); sTrace("%s", logBuf); @@ -148,7 +148,7 @@ void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFini void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMeta) { char* s = syncCfg2Str(&(cbMeta.newCfg)); - sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%ld, code:%d, currentTerm:%lu, term:%lu, newCfg:%s", + sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64 ", newCfg:%s", cbMeta.flag, cbMeta.index, cbMeta.code, cbMeta.currentTerm, cbMeta.term, s); taosMemoryFree(s); } @@ -156,8 +156,8 @@ void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMe void LeaderTransferCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) { char logBuf[256] = {0}; snprintf(logBuf, sizeof(logBuf), - "==callback== ==LeaderTransferCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, flag:%lu, term:%lu " - "currentTerm:%lu \n", + "==callback== ==LeaderTransferCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s, flag:%" PRIu64 ", term:%" PRIu64 " " + "currentTerm:%" PRIu64 " \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), cbMeta.flag, cbMeta.term, cbMeta.currentTerm); syncRpcMsgLog2(logBuf, (SRpcMsg*)pMsg); @@ -300,7 +300,7 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) { pMsg->msgType = TDMT_VND_SUBMIT; pMsg->contLen = 256; pMsg->pCont = rpcMallocCont(pMsg->contLen); - snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-%ld", myIndex, i, count, taosGetTimestampMs()); + snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-" PRId64, myIndex, i, count, taosGetTimestampMs()); return pMsg; } diff --git a/source/libs/sync/test/syncWriteTest.cpp b/source/libs/sync/test/syncWriteTest.cpp index 34c8eb0f56..d99923a8b9 100644 --- a/source/libs/sync/test/syncWriteTest.cpp +++ b/source/libs/sync/test/syncWriteTest.cpp @@ -33,7 +33,7 @@ const char *pDir = "./syncWriteTest"; void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { char logBuf[256]; - snprintf(logBuf, sizeof(logBuf), "==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", + snprintf(logBuf, sizeof(logBuf), "==callback== ==CommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state)); syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); } @@ -41,14 +41,14 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { char logBuf[256]; snprintf(logBuf, sizeof(logBuf), - "==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, + "==callback== ==PreCommitCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state)); syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); } void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { char logBuf[256]; - snprintf(logBuf, sizeof(logBuf), "==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", + snprintf(logBuf, sizeof(logBuf), "==callback== ==RollBackCb== pFsm:%p, index:%" PRId64 ", isWeak:%d, code:%d, state:%d %s \n", pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state)); syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); } diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index cdae73bfb9..22229ea0e8 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -258,8 +258,8 @@ static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage) { } static void tdbPCacheRemovePageFromHash(SPCache *pCache, SPage *pPage) { - SPage **ppPage; - int h; + SPage **ppPage; + uint32_t h; h = tdbPCachePageHash(&(pPage->pgid)); for (ppPage = &(pCache->pgHash[h % pCache->nHash]); (*ppPage) && *ppPage != pPage; ppPage = &((*ppPage)->pHashNext)) diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index dad4511491..60eaf467ae 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -370,7 +370,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage init = 1; nRead = tdbOsPRead(pPager->fd, pPage->pData, pPage->pageSize, ((i64)pPage->pageSize) * (pgno - 1)); - tdbTrace("tdbttl pager:%p, pgno:%d, nRead:%ld", pPager, pgno, nRead); + tdbTrace("tdbttl pager:%p, pgno:%d, nRead:%" PRId64, pPager, pgno, nRead); if (nRead < pPage->pageSize) { ASSERT(0); return -1; diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index f699df6883..e73ddedd73 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -249,30 +249,30 @@ int transAsyncSend(SAsyncPool* pool, queue* mq); } \ } while (0) -#define ASYNC_CHECK_HANDLE(exh1, id) \ - do { \ - if (id > 0) { \ - tTrace("handle step1"); \ - SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), id); \ - if (exh2 == NULL || id != exh2->refId) { \ - tTrace("handle %p except, may already freed, ignore msg, ref1: %" PRIu64 ", ref2 : %" PRIu64 "", exh1, \ - exh2 ? exh2->refId : 0, id); \ - goto _return1; \ - } \ - } else if (id == 0) { \ - tTrace("handle step2"); \ - SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), id); \ - if (exh2 == NULL || id == exh2->refId) { \ - tTrace("handle %p except, may already freed, ignore msg, ref1: %" PRIu64 ", ref2 : %" PRIu64 "", exh1, id, \ - exh2 ? exh2->refId : 0); \ - goto _return1; \ - } else { \ - id = exh1->refId; \ - } \ - } else if (id < 0) { \ - tTrace("handle step3"); \ - goto _return2; \ - } \ +#define ASYNC_CHECK_HANDLE(exh1, id) \ + do { \ + if (id > 0) { \ + tTrace("handle step1"); \ + SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), id); \ + if (exh2 == NULL || id != exh2->refId) { \ + tTrace("handle %p except, may already freed, ignore msg, ref1:%" PRIu64 ", ref2:%" PRIu64, exh1, \ + exh2 ? exh2->refId : 0, id); \ + goto _return1; \ + } \ + } else if (id == 0) { \ + tTrace("handle step2"); \ + SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), id); \ + if (exh2 == NULL || id == exh2->refId) { \ + tTrace("handle %p except, may already freed, ignore msg, ref1:%" PRIu64 ", ref2:%" PRIu64, exh1, id, \ + exh2 ? exh2->refId : 0); \ + goto _return1; \ + } else { \ + id = exh1->refId; \ + } \ + } else if (id < 0) { \ + tTrace("handle step3"); \ + goto _return2; \ + } \ } while (0) int transInitBuffer(SConnBuffer* buf); diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 48e7d7c91d..e9e439971c 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -58,7 +58,7 @@ void* rpcOpen(const SRpcInit* pInit) { uint32_t ip = 0; if (pInit->connType == TAOS_CONN_SERVER) { if (transValidLocalFqdn(pInit->localFqdn, &ip) != 0) { - tError("invalid fqdn: %s, errmsg: %s", pInit->localFqdn, terrstr()); + tError("invalid fqdn:%s, errmsg:%s", pInit->localFqdn, terrstr()); taosMemoryFree(pRpc); return NULL; } @@ -86,7 +86,7 @@ void rpcClose(void* arg) { tInfo("start to close rpc"); transRemoveExHandle(transGetInstMgt(), (int64_t)arg); transReleaseExHandle(transGetInstMgt(), (int64_t)arg); - tInfo("finish to close rpc"); + tInfo("rpc is closed"); return; } void rpcCloseImpl(void* arg) { @@ -112,7 +112,7 @@ void* rpcMallocCont(int32_t contLen) { void rpcFreeCont(void* cont) { if (cont == NULL) return; taosMemoryFree((char*)cont - TRANS_MSG_OVERHEAD); - tTrace("free mem: %p", (char*)cont - TRANS_MSG_OVERHEAD); + tTrace("free mem:%p", (char*)cont - TRANS_MSG_OVERHEAD); } void* rpcReallocCont(void* ptr, int32_t contLen) { diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 4b6ff43ba8..0600b1130d 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -184,22 +184,22 @@ static void cliReleaseUnfinishedMsg(SCliConn* conn) { #define CONN_PERSIST_TIME(para) (para * 1000 * 10) #define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL) #define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrd*)(conn)->hostThrd)->pTransInst))->label) -#define CONN_SHOULD_RELEASE(conn, head) \ - do { \ - if ((head)->release == 1 && (head->msgLen) == sizeof(*head)) { \ - uint64_t ahandle = head->ahandle; \ - CONN_GET_MSGCTX_BY_AHANDLE(conn, ahandle); \ - transClearBuffer(&conn->readBuf); \ - transFreeMsg(transContFromHead((char*)head)); \ - tDebug("%s conn %p receive release request, ref: %d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn)); \ - if (T_REF_VAL_GET(conn) > 1) { \ - transUnrefCliHandle(conn); \ - } \ - destroyCmsg(pMsg); \ - cliReleaseUnfinishedMsg(conn); \ - addConnToPool(((SCliThrd*)conn->hostThrd)->pool, conn); \ - return; \ - } \ +#define CONN_SHOULD_RELEASE(conn, head) \ + do { \ + if ((head)->release == 1 && (head->msgLen) == sizeof(*head)) { \ + uint64_t ahandle = head->ahandle; \ + CONN_GET_MSGCTX_BY_AHANDLE(conn, ahandle); \ + transClearBuffer(&conn->readBuf); \ + transFreeMsg(transContFromHead((char*)head)); \ + tDebug("%s conn %p receive release request, ref:%d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn)); \ + if (T_REF_VAL_GET(conn) > 1) { \ + transUnrefCliHandle(conn); \ + } \ + destroyCmsg(pMsg); \ + cliReleaseUnfinishedMsg(conn); \ + addConnToPool(((SCliThrd*)conn->hostThrd)->pool, conn); \ + return; \ + } \ } while (0) #define CONN_GET_MSGCTX_BY_AHANDLE(conn, ahandle) \ @@ -353,7 +353,7 @@ void cliHandleResp(SCliConn* conn) { } STraceId* trace = &transMsg.info.traceId; - tGTrace("%s conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, code: %d", CONN_GET_INST_LABEL(conn), + tGTrace("%s conn %p %s received from %s:%d, local info:%s:%d, msg size:%d, code:0x%x", CONN_GET_INST_LABEL(conn), conn, TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port), taosInetNtoa(conn->localAddr.sin_addr), ntohs(conn->localAddr.sin_port), transMsg.contLen, transMsg.code); @@ -573,7 +573,7 @@ static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { return; } if (nread < 0) { - tWarn("%s conn %p read error: %s, ref: %d", CONN_GET_INST_LABEL(conn), conn, uv_err_name(nread), + tWarn("%s conn %p read error:%s, ref:%d", CONN_GET_INST_LABEL(conn), conn, uv_err_name(nread), T_REF_VAL_GET(conn)); conn->broken = true; cliHandleExcept(conn); @@ -655,7 +655,7 @@ static void cliSendCb(uv_write_t* req, int status) { if (status == 0) { tTrace("%s conn %p data already was written out", CONN_GET_INST_LABEL(pConn), pConn); } else { - tError("%s conn %p failed to write: %s", CONN_GET_INST_LABEL(pConn), pConn, uv_err_name(status)); + tError("%s conn %p failed to write:%s", CONN_GET_INST_LABEL(pConn), pConn, uv_err_name(status)); cliHandleExcept(pConn); return; } @@ -719,7 +719,7 @@ void cliConnCb(uv_connect_t* req, int status) { // impl later SCliConn* pConn = req->data; if (status != 0) { - tError("%s conn %p failed to connect server: %s", CONN_GET_INST_LABEL(pConn), pConn, uv_strerror(status)); + tError("%s conn %p failed to connect server:%s", CONN_GET_INST_LABEL(pConn), pConn, uv_strerror(status)); cliHandleExcept(pConn); return; } @@ -852,7 +852,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { tTrace("%s conn %p try to connect to %s:%d", pTransInst->label, conn, conn->ip, conn->port); ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb); if (ret != 0) { - tTrace("%s conn %p failed to connect to %s:%d, reason: %s", pTransInst->label, conn, conn->ip, conn->port, + tTrace("%s conn %p failed to connect to %s:%d, reason:%s", pTransInst->label, conn, conn->ip, conn->port, uv_err_name(ret)); cliHandleExcept(conn); return; @@ -883,7 +883,7 @@ static void cliAsyncCb(uv_async_t* handle) { count++; } if (count >= 2) { - tTrace("cli process batch size: %d", count); + tTrace("cli process batch size:%d", count); } } @@ -910,7 +910,7 @@ void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, int err = taosThreadCreate(&pThrd->thread, NULL, cliWorkThread, (void*)(pThrd)); if (err == 0) { - tDebug("success to create tranport-cli thread %d", i); + tDebug("success to create tranport-cli thread:%d", i); } cli->pThreadObj[i] = pThrd; } @@ -1222,7 +1222,7 @@ void transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra cliMsg->refId = (int64_t)shandle; STraceId* trace = &pReq->info.traceId; - tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", transLabel(pTransInst), pThrd->pid, + tGTrace("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); ASSERT(transAsyncSend(pThrd->asyncPool, &(cliMsg->q)) == 0); transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); @@ -1260,7 +1260,7 @@ void transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransM cliMsg->refId = (int64_t)shandle; STraceId* trace = &pReq->info.traceId; - tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", transLabel(pTransInst), pThrd->pid, + tGTrace("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); transAsyncSend(pThrd->asyncPool, &(cliMsg->q)); @@ -1294,7 +1294,7 @@ void transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { cliMsg->refId = (int64_t)shandle; SCliThrd* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[i]; - tDebug("%s update epset at thread:%08" PRId64 "", pTransInst->label, thrd->pid); + tDebug("%s update epset at thread:%08" PRId64, pTransInst->label, thrd->pid); transAsyncSend(thrd->asyncPool, &(cliMsg->q)); } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 5f6e3db615..812123441c 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -136,7 +136,7 @@ int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) { } else { p->cap = p->total; p->buf = taosMemoryRealloc(p->buf, p->cap); - tTrace("internal malloc mem: %p, size: %d", p->buf, p->cap); + tTrace("internal malloc mem:%p, size:%d", p->buf, p->cap); uvBuf->base = p->buf + p->len; uvBuf->len = p->cap - p->len; @@ -221,7 +221,7 @@ int transAsyncSend(SAsyncPool* pool, queue* q) { taosThreadMutexUnlock(&item->mtx); int64_t el = taosGetTimestampUs() - st; if (el > 50) { - // tInfo("lock and unlock cost: %d", (int)el); + // tInfo("lock and unlock cost:%d", (int)el); } return uv_async_send(async); } @@ -446,7 +446,7 @@ int transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_ } } - tTrace("timer %p put task into delay queue, timeoutMs: %" PRIu64 "", queue->timer, timeoutMs); + tTrace("timer %p put task into delay queue, timeoutMs:%" PRIu64, queue->timer, timeoutMs); heapInsert(queue->heap, &task->node); uv_timer_start(queue->timer, transDQTimeout, timeoutMs, 0); return 0; diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index b805aa929c..a239f90c29 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -245,11 +245,11 @@ static void uvHandleReq(SSvrConn* pConn) { if (pConn->status == ConnNormal && pHead->noResp == 0) { transRefSrvHandle(pConn); - tGTrace("%s conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", transLabel(pTransInst), pConn, + tGTrace("%s conn %p %s received from %s:%d, local info:%s:%d, msg size:%d", transLabel(pTransInst), pConn, TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen); } else { - tGTrace("%s conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, resp:%d, code: %d", + tGTrace("%s conn %p %s received from %s:%d, local info:%s:%d, msg size:%d, resp:%d, code:%d", transLabel(pTransInst), pConn, TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen, pHead->noResp, transMsg.code); @@ -265,7 +265,7 @@ static void uvHandleReq(SSvrConn* pConn) { transMsg.info.refId = pConn->refId; transMsg.info.traceId = pHead->traceId; - tGTrace("%s handle %p conn: %p translated to app, refId: %" PRIu64 "", transLabel(pTransInst), transMsg.info.handle, + tGTrace("%s handle %p conn:%p translated to app, refId:%" PRIu64, transLabel(pTransInst), transMsg.info.handle, pConn, pConn->refId); assert(transMsg.info.handle != NULL); @@ -292,7 +292,7 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) { STrans* pTransInst = conn->pTransInst; if (nread > 0) { pBuf->len += nread; - tTrace("%s conn %p total read: %d, current read: %d", transLabel(pTransInst), conn, pBuf->len, (int)nread); + tTrace("%s conn %p total read:%d, current read:%d", transLabel(pTransInst), conn, pBuf->len, (int)nread); if (transReadComplete(pBuf)) { tTrace("%s conn %p alread read complete packet", transLabel(pTransInst), conn); uvHandleReq(conn); @@ -305,7 +305,7 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) { return; } - tWarn("%s conn %p read error: %s", transLabel(pTransInst), conn, uv_err_name(nread)); + tWarn("%s conn %p read error:%s", transLabel(pTransInst), conn, uv_err_name(nread)); if (nread < 0) { conn->broken = true; if (conn->status == ConnAcquire) { @@ -390,8 +390,9 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { pHead->traceId = pMsg->info.traceId; pHead->hasEpSet = pMsg->info.hasEpSet; + if (pConn->status == ConnNormal) { - pHead->msgType = pConn->inType + 1; + pHead->msgType = (0 == pMsg->msgType ? pConn->inType + 1 : pMsg->msgType); } else { if (smsg->type == Release) { pHead->msgType = 0; @@ -400,11 +401,8 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { destroyConnRegArg(pConn); transUnrefSrvHandle(pConn); } else { - pHead->msgType = pMsg->msgType; // set up resp msg type - if (pHead->msgType == 0 && transMsgLenFromCont(pMsg->contLen) == sizeof(STransMsgHead)) { - pHead->msgType = pConn->inType + 1; - } + pHead->msgType = (0 == pMsg->msgType ? pConn->inType + 1 : pMsg->msgType); } } @@ -416,7 +414,7 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { STrans* pTransInst = pConn->pTransInst; STraceId* trace = &pMsg->info.traceId; - tGTrace("%s conn %p %s is sent to %s:%d, local info: %s:%d, msglen:%d", transLabel(pTransInst), pConn, + tGTrace("%s conn %p %s is sent to %s:%d, local info:%s:%d, msglen:%d", transLabel(pTransInst), pConn, TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), len); pHead->msgLen = htonl(len); @@ -540,7 +538,7 @@ static void uvAcceptAsyncCb(uv_async_t* async) { static void uvShutDownCb(uv_shutdown_t* req, int status) { if (status != 0) { - tDebug("conn failed to shut down: %s", uv_err_name(status)); + tDebug("conn failed to shut down:%s", uv_err_name(status)); } uv_close((uv_handle_t*)req->handle, uvDestroyConn); taosMemoryFree(req); @@ -601,7 +599,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { tError("read error %s", uv_err_name(nread)); } // TODO(log other failure reason) - tError("failed to create connect: %p", q); + tWarn("failed to create connect:%p", q); taosMemoryFree(buf->base); uv_close((uv_handle_t*)q, NULL); // taosMemoryFree(q); @@ -644,7 +642,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { if (uv_accept(q, (uv_stream_t*)(pConn->pTcp)) == 0) { uv_os_fd_t fd; uv_fileno((const uv_handle_t*)pConn->pTcp, &fd); - tTrace("conn %p created, fd: %d", pConn, fd); + tTrace("conn %p created, fd:%d", pConn, fd); int addrlen = sizeof(pConn->addr); if (0 != uv_tcp_getpeername(pConn->pTcp, (struct sockaddr*)&pConn->addr, &addrlen)) { @@ -712,7 +710,7 @@ static bool addHandleToAcceptloop(void* arg) { int err = 0; if ((err = uv_tcp_init(srv->loop, &srv->server)) != 0) { - tError("failed to init accept server: %s", uv_err_name(err)); + tError("failed to init accept server:%s", uv_err_name(err)); return false; } @@ -724,11 +722,11 @@ static bool addHandleToAcceptloop(void* arg) { struct sockaddr_in bind_addr; uv_ip4_addr("0.0.0.0", srv->port, &bind_addr); if ((err = uv_tcp_bind(&srv->server, (const struct sockaddr*)&bind_addr, 0)) != 0) { - tError("failed to bind: %s", uv_err_name(err)); + tError("failed to bind:%s", uv_err_name(err)); return false; } if ((err = uv_listen((uv_stream_t*)&srv->server, 512, uvOnAcceptCb)) != 0) { - tError("failed to listen: %s", uv_err_name(err)); + tError("failed to listen:%s", uv_err_name(err)); terrno = TSDB_CODE_RPC_PORT_EADDRINUSE; return false; } @@ -765,7 +763,7 @@ static SSvrConn* createConn(void* hThrd) { STrans* pTransInst = pThrd->pTransInst; pConn->refId = exh->refId; transRefSrvHandle(pConn); - tTrace("%s handle %p, conn %p created, refId: %" PRId64 "", transLabel(pTransInst), exh, pConn, pConn->refId); + tTrace("%s handle %p, conn %p created, refId:%" PRId64, transLabel(pTransInst), exh, pConn, pConn->refId); return pConn; } @@ -868,10 +866,10 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, assert(0 == uv_pipe_init(srv->loop, &srv->pipeListen, 0)); #ifdef WINDOWS char pipeName[64]; - snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%p-%lu", taosSafeRand(), GetCurrentProcessId()); + snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%p-" PRIu64, taosSafeRand(), GetCurrentProcessId()); #else char pipeName[PATH_MAX] = {0}; - snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08X-%lu", tsTempDir, TD_DIRSEP, taosSafeRand(), + snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08X-" PRIu64, tsTempDir, TD_DIRSEP, taosSafeRand(), taosGetSelfPthreadId()); #endif assert(0 == uv_pipe_bind(&srv->pipeListen, pipeName)); @@ -892,17 +890,16 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, } int err = taosThreadCreate(&(thrd->thread), NULL, transWorkerThread, (void*)(thrd)); if (err == 0) { - tDebug("sucess to create worker-thread %d", i); - // printf("thread %d create\n", i); + tDebug("success to create worker-thread:%d", i); } else { // TODO: clear all other resource later - tError("failed to create worker-thread %d", i); + tError("failed to create worker-thread:%d", i); goto End; } } if (false == taosValidIpAndPort(srv->ip, srv->port)) { terrno = TAOS_SYSTEM_ERROR(errno); - tError("invalid ip/port, %d:%d, reason: %s", srv->ip, srv->port, terrstr()); + tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr()); goto End; } if (false == addHandleToAcceptloop(srv)) { @@ -1023,7 +1020,7 @@ void transRefSrvHandle(void* handle) { return; } int ref = T_REF_INC((SSvrConn*)handle); - tDebug("conn %p ref count: %d", handle, ref); + tDebug("conn %p ref count:%d", handle, ref); } void transUnrefSrvHandle(void* handle) { @@ -1031,7 +1028,7 @@ void transUnrefSrvHandle(void* handle) { return; } int ref = T_REF_DEC((SSvrConn*)handle); - tDebug("conn %p ref count: %d", handle, ref); + tDebug("conn %p ref count:%d", handle, ref); if (ref == 0) { destroyConn((SSvrConn*)handle, true); } diff --git a/source/libs/transport/test/CMakeLists.txt b/source/libs/transport/test/CMakeLists.txt index 98a252e008..5645f49284 100644 --- a/source/libs/transport/test/CMakeLists.txt +++ b/source/libs/transport/test/CMakeLists.txt @@ -1,30 +1,16 @@ add_executable(transportTest "") -add_executable(client "") -add_executable(server "") add_executable(transUT "") -add_executable(syncClient "") add_executable(pushServer "") target_sources(transUT PRIVATE "transUT.cpp" -) +) + target_sources(transportTest PRIVATE "transportTests.cpp" -) -target_sources (client - PRIVATE - "rclient.c" -) -target_sources (server - PRIVATE - "rserver.c" -) -target_sources (syncClient - PRIVATE - "syncClient.c" -) +) target_sources(pushServer PRIVATE @@ -35,7 +21,7 @@ target_include_directories(transportTest PUBLIC "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" -) +) target_link_libraries (transportTest os @@ -44,6 +30,7 @@ target_link_libraries (transportTest gtest_main transport ) + target_link_libraries (transUT os util @@ -52,56 +39,18 @@ target_link_libraries (transUT transport ) -target_include_directories(client - PUBLIC - "${TD_SOURCE_DIR}/include/libs/transport" - "${CMAKE_CURRENT_SOURCE_DIR}/../inc" -) - -target_link_libraries (client - os - util - common - gtest_main - transport -) -target_include_directories(server - PUBLIC - "${TD_SOURCE_DIR}/include/libs/transport" - "${CMAKE_CURRENT_SOURCE_DIR}/../inc" -) - target_include_directories(transUT PUBLIC "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" -) - -target_link_libraries (server - os - util - common - gtest_main - transport -) -target_include_directories(syncClient - PUBLIC - "${TD_SOURCE_DIR}/include/libs/transport" - "${CMAKE_CURRENT_SOURCE_DIR}/../inc" -) -target_link_libraries (syncClient - os - util - common - gtest_main - transport ) target_include_directories(pushServer PUBLIC "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" -) +) + target_link_libraries (pushServer os util @@ -110,7 +59,6 @@ target_link_libraries (pushServer transport ) - add_test( NAME transUT COMMAND transUT diff --git a/source/libs/transport/test/pushServer.c b/source/libs/transport/test/pushServer.c index 8b1dcd46cf..6a4ff213d0 100644 --- a/source/libs/transport/test/pushServer.c +++ b/source/libs/transport/test/pushServer.c @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) { dDebugFlag = rpcDebugFlag; uDebugFlag = rpcDebugFlag; } else { - printf("\nusage: %s [options] \n", argv[0]); + printf("\nusage:% [options] \n", argv[0]); printf(" [-p port]: server port number, default is:%d\n", rpcInit.localPort); printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads); printf(" [-s sessions]: number of sessions, default is:%d\n", rpcInit.sessions); diff --git a/source/libs/transport/test/rclient.c b/source/libs/transport/test/rclient.c deleted file mode 100644 index 55e6dd000a..0000000000 --- a/source/libs/transport/test/rclient.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -#include -#include "os.h" -#include "taoserror.h" -#include "tglobal.h" -#include "transLog.h" -#include "trpc.h" -#include "tutil.h" - -typedef struct { - int index; - SEpSet epSet; - int num; - int numOfReqs; - int msgSize; - tsem_t rspSem; - tsem_t * pOverSem; - TdThread thread; - void * pRpc; -} SInfo; -static void processResponse(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) { - SInfo *pInfo = (SInfo *)pMsg->info.ahandle; - // tError("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, - // pMsg->code); - - if (pEpSet) pInfo->epSet = *pEpSet; - - rpcFreeCont(pMsg->pCont); - // tsem_post(&pInfo->rspSem); - tsem_post(&pInfo->rspSem); -} - -static int tcount = 0; - -static void *sendRequest(void *param) { - SInfo * pInfo = (SInfo *)param; - SRpcMsg rpcMsg = {0}; - - tError("thread:%d, start to send request", pInfo->index); - - tError("thread:%d, reqs: %d", pInfo->index, pInfo->numOfReqs); - int u100 = 0; - int u500 = 0; - int u1000 = 0; - int u10000 = 0; - - while (pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) { - pInfo->num++; - rpcMsg.pCont = rpcMallocCont(pInfo->msgSize); - rpcMsg.contLen = pInfo->msgSize; - rpcMsg.info.ahandle = pInfo; - rpcMsg.msgType = 1; - // tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num); - int64_t start = taosGetTimestampUs(); - rpcSendRequest(pInfo->pRpc, &pInfo->epSet, &rpcMsg, NULL); - if (pInfo->num % 20000 == 0) tError("thread:%d, %d requests have been sent", pInfo->index, pInfo->num); - // tsem_wait(&pInfo->rspSem); - tsem_wait(&pInfo->rspSem); - int64_t end = taosGetTimestampUs() - start; - if (end <= 100) { - u100++; - } else if (end > 100 && end <= 500) { - u500++; - } else if (end > 500 && end < 1000) { - u1000++; - } else { - u10000++; - } - - tDebug("recv response succefully"); - - // taosSsleep(100); - } - - tError("send and recv sum: %d, %d, %d, %d", u100, u500, u1000, u10000); - tError("thread:%d, it is over", pInfo->index); - tcount++; - - return NULL; -} - -int main(int argc, char *argv[]) { - SRpcInit rpcInit; - SEpSet epSet = {0}; - int msgSize = 128; - int numOfReqs = 0; - int appThreads = 1; - char serverIp[40] = "127.0.0.1"; - char secret[20] = "mypassword"; - struct timeval systemTime; - int64_t startTime, endTime; - TdThreadAttr thattr; - - // server info - epSet.inUse = 0; - addEpIntoEpSet(&epSet, serverIp, 7000); - addEpIntoEpSet(&epSet, "192.168.0.1", 7000); - - // client info - memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = 0; - rpcInit.label = "APP"; - rpcInit.numOfThreads = 1; - rpcInit.cfp = processResponse; - rpcInit.sessions = 100; - rpcInit.idleTime = 100; - rpcInit.user = "michael"; - rpcInit.connType = TAOS_CONN_CLIENT; - rpcDebugFlag = 131; - - for (int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { - epSet.eps[0].port = atoi(argv[++i]); - } else if (strcmp(argv[i], "-i") == 0 && i < argc - 1) { - tstrncpy(epSet.eps[0].fqdn, argv[++i], sizeof(epSet.eps[0].fqdn)); - } else if (strcmp(argv[i], "-t") == 0 && i < argc - 1) { - rpcInit.numOfThreads = atoi(argv[++i]); - } else if (strcmp(argv[i], "-m") == 0 && i < argc - 1) { - msgSize = atoi(argv[++i]); - } else if (strcmp(argv[i], "-s") == 0 && i < argc - 1) { - rpcInit.sessions = atoi(argv[++i]); - } else if (strcmp(argv[i], "-n") == 0 && i < argc - 1) { - numOfReqs = atoi(argv[++i]); - } else if (strcmp(argv[i], "-a") == 0 && i < argc - 1) { - appThreads = atoi(argv[++i]); - } else if (strcmp(argv[i], "-o") == 0 && i < argc - 1) { - tsCompressMsgSize = atoi(argv[++i]); - } else if (strcmp(argv[i], "-u") == 0 && i < argc - 1) { - rpcInit.user = argv[++i]; - } else if (strcmp(argv[i], "-k") == 0 && i < argc - 1) { - } else if (strcmp(argv[i], "-spi") == 0 && i < argc - 1) { - } else if (strcmp(argv[i], "-d") == 0 && i < argc - 1) { - rpcDebugFlag = atoi(argv[++i]); - } else { - printf("\nusage: %s [options] \n", argv[0]); - printf(" [-i ip]: first server IP address, default is:%s\n", serverIp); - printf(" [-p port]: server port number, default is:%d\n", epSet.eps[0].port); - printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads); - printf(" [-s sessions]: number of rpc sessions, default is:%d\n", rpcInit.sessions); - printf(" [-m msgSize]: message body size, default is:%d\n", msgSize); - printf(" [-a threads]: number of app threads, default is:%d\n", appThreads); - printf(" [-n requests]: number of requests per thread, default is:%d\n", numOfReqs); - printf(" [-o compSize]: compression message size, default is:%d\n", tsCompressMsgSize); - printf(" [-u user]: user name for the connection, default is:%s\n", rpcInit.user); - printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag); - printf(" [-h help]: print out this help\n\n"); - exit(0); - } - } - - const char *path = TD_TMP_DIR_PATH "transport/client"; - taosRemoveDir(path); - taosMkDir(path); - tstrncpy(tsLogDir, path, PATH_MAX); - taosInitLog("client.log", 10); - - void *pRpc = rpcOpen(&rpcInit); - if (pRpc == NULL) { - tError("failed to initialize RPC"); - return -1; - } - - tError("client is initialized"); - tError("threads:%d msgSize:%d requests:%d", appThreads, msgSize, numOfReqs); - - taosGetTimeOfDay(&systemTime); - startTime = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - - SInfo *pInfo = (SInfo *)taosMemoryCalloc(1, sizeof(SInfo) * appThreads); - - taosThreadAttrInit(&thattr); - taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE); - - for (int i = 0; i < appThreads; ++i) { - pInfo->index = i; - pInfo->epSet = epSet; - pInfo->numOfReqs = numOfReqs; - pInfo->msgSize = msgSize; - tsem_init(&pInfo->rspSem, 0, 0); - pInfo->pRpc = pRpc; - taosThreadCreate(&pInfo->thread, &thattr, sendRequest, pInfo); - pInfo++; - } - - do { - taosUsleep(1); - } while (tcount < appThreads); - - taosGetTimeOfDay(&systemTime); - endTime = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - float usedTime = (endTime - startTime) / 1000.0f; // mseconds - - tError("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs * appThreads); - tError("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0 * numOfReqs * appThreads / usedTime, - msgSize); - - int ch = getchar(); - UNUSED(ch); - - taosCloseLog(); - - return 0; -} diff --git a/source/libs/transport/test/rsclient.c b/source/libs/transport/test/rsclient.c deleted file mode 100644 index e7fc7b45e1..0000000000 --- a/source/libs/transport/test/rsclient.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - - -#include "os.h" -#include "tutil.h" -#include "tglobal.h" -#include "rpcLog.h" -#include "trpc.h" -#include "taoserror.h" - -typedef struct { - int index; - SRpcEpSet epSet; - int num; - int numOfReqs; - int msgSize; - tsem_t rspSem; - tsem_t *pOverSem; - TdThread thread; - void *pRpc; -} SInfo; - - -static int tcount = 0; -static int terror = 0; - -static void *sendRequest(void *param) { - SInfo *pInfo = (SInfo *)param; - SRpcMsg rpcMsg, rspMsg; - - tDebug("thread:%d, start to send request", pInfo->index); - - while ( pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) { - pInfo->num++; - rpcMsg.pCont = rpcMallocCont(pInfo->msgSize); - rpcMsg.contLen = pInfo->msgSize; - rpcMsg.handle = pInfo; - rpcMsg.msgType = 1; - tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num); - - rpcSendRecv(pInfo->pRpc, &pInfo->epSet, &rpcMsg, &rspMsg); - - // handle response - if (rspMsg.code != 0) terror++; - - tDebug("thread:%d, rspLen:%d code:%d", pInfo->index, rspMsg.contLen, rspMsg.code); - - rpcFreeCont(rspMsg.pCont); - - if ( pInfo->num % 20000 == 0 ) - tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num); - } - - tDebug("thread:%d, it is over", pInfo->index); - tcount++; - - return NULL; -} - -int main(int argc, char *argv[]) { - SRpcInit rpcInit; - SRpcEpSet epSet; - int msgSize = 128; - int numOfReqs = 0; - int appThreads = 1; - char serverIp[40] = "127.0.0.1"; - char secret[TSDB_KEY_LEN] = "mypassword"; - struct timeval systemTime; - int64_t startTime, endTime; - TdThreadAttr thattr; - - // server info - epSet.numOfEps = 1; - epSet.inUse = 0; - epSet.port[0] = 7000; - epSet.port[1] = 7000; - strcpy(epSet.fqdn[0], serverIp); - strcpy(epSet.fqdn[1], "192.168.0.1"); - - // client info - memset(&rpcInit, 0, sizeof(rpcInit)); - //rpcInit.localIp = "0.0.0.0"; - rpcInit.localPort = 0; - rpcInit.label = "APP"; - rpcInit.numOfThreads = 1; - rpcInit.sessions = 100; - rpcInit.idleTime = 3000; //tsShellActivityTimer*1000; - rpcInit.user = "michael"; - rpcInit.secret = secret; - rpcInit.ckey = "key"; - rpcInit.spi = 1; - rpcInit.connType = TAOS_CONN_CLIENT; - - for (int i=1; iindex = i; - pInfo->epSet = epSet; - pInfo->numOfReqs = numOfReqs; - pInfo->msgSize = msgSize; - tsem_init(&pInfo->rspSem, 0, 0); - pInfo->pRpc = pRpc; - taosThreadCreate(&pInfo->thread, &thattr, sendRequest, pInfo); - pInfo++; - } - - do { - taosUsleep(1); - } while ( tcount < appThreads); - - taosGetTimeOfDay(&systemTime); - endTime = systemTime.tv_sec*1000000 + systemTime.tv_usec; - float usedTime = (endTime - startTime)/1000.0; // mseconds - - tInfo("it takes %.3f mseconds to send %d requests to server, error num:%d", usedTime, numOfReqs*appThreads, terror); - tInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0*numOfReqs*appThreads/usedTime, msgSize); - - taosCloseLog(); - - return 0; -} - - diff --git a/source/libs/transport/test/rserver.c b/source/libs/transport/test/rserver.c deleted file mode 100644 index 1fd78be77d..0000000000 --- a/source/libs/transport/test/rserver.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -//#define _DEFAULT_SOURCE -#include "os.h" -#include "tglobal.h" -#include "tqueue.h" -#include "transLog.h" -#include "trpc.h" - -int msgSize = 128; -int commit = 0; -TdFilePtr pDataFile = NULL; -STaosQueue *qhandle = NULL; -STaosQset * qset = NULL; - -void processShellMsg() { - static int num = 0; - STaosQall *qall; - SRpcMsg * pRpcMsg, rpcMsg; - int type; - void * pvnode; - - qall = taosAllocateQall(); - - while (1) { - int numOfMsgs = taosReadAllQitemsFromQset(qset, qall, &pvnode, NULL); - tDebug("%d shell msgs are received", numOfMsgs); - if (numOfMsgs <= 0) break; - - for (int i = 0; i < numOfMsgs; ++i) { - taosGetQitem(qall, (void **)&pRpcMsg); - - if (pDataFile != NULL) { - if (taosWriteFile(pDataFile, pRpcMsg->pCont, pRpcMsg->contLen) < 0) { - tInfo("failed to write data file, reason:%s", strerror(errno)); - } - } - } - - if (commit >= 2) { - num += numOfMsgs; - // if (taosFsync(pDataFile) < 0) { - // tInfo("failed to flush data to file, reason:%s", strerror(errno)); - //} - - if (num % 10000 == 0) { - tInfo("%d request have been written into disk", num); - } - } - - taosResetQitems(qall); - for (int i = 0; i < numOfMsgs; ++i) { - taosGetQitem(qall, (void **)&pRpcMsg); - rpcFreeCont(pRpcMsg->pCont); - - memset(&rpcMsg, 0, sizeof(rpcMsg)); - rpcMsg.pCont = rpcMallocCont(msgSize); - rpcMsg.contLen = msgSize; - rpcMsg.info = pRpcMsg->info; - rpcMsg.code = 0; - rpcSendResponse(&rpcMsg); - - taosFreeQitem(pRpcMsg); - } - } - - taosFreeQall(qall); -} - -int retrieveAuthInfo(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey) { - // app shall retrieve the auth info based on meterID from DB or a data file - // demo code here only for simple demo - int ret = 0; - - if (strcmp(meterId, "michael") == 0) { - *spi = 1; - *encrypt = 0; - strcpy(secret, "mypassword"); - strcpy(ckey, "key"); - } else if (strcmp(meterId, "jeff") == 0) { - *spi = 0; - *encrypt = 0; - } else { - ret = -1; // user not there - } - - return ret; -} - -void processRequestMsg(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) { - SRpcMsg *pTemp; - - pTemp = taosAllocateQitem(sizeof(SRpcMsg), DEF_QITEM); - memcpy(pTemp, pMsg, sizeof(SRpcMsg)); - - tDebug("request is received, type:%d, contLen:%d, item:%p", pMsg->msgType, pMsg->contLen, pTemp); - taosWriteQitem(qhandle, pTemp); -} - -int main(int argc, char *argv[]) { - SRpcInit rpcInit; - char dataName[20] = "server.data"; - - taosBlockSIGPIPE(); - - memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = 7000; - rpcInit.label = "SER"; - rpcInit.numOfThreads = 1; - rpcInit.cfp = processRequestMsg; - rpcInit.sessions = 1000; - rpcInit.idleTime = 2 * 1500; - - rpcDebugFlag = 131; - - for (int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { - rpcInit.localPort = atoi(argv[++i]); - } else if (strcmp(argv[i], "-t") == 0 && i < argc - 1) { - rpcInit.numOfThreads = atoi(argv[++i]); - } else if (strcmp(argv[i], "-m") == 0 && i < argc - 1) { - msgSize = atoi(argv[++i]); - } else if (strcmp(argv[i], "-s") == 0 && i < argc - 1) { - rpcInit.sessions = atoi(argv[++i]); - } else if (strcmp(argv[i], "-o") == 0 && i < argc - 1) { - tsCompressMsgSize = atoi(argv[++i]); - } else if (strcmp(argv[i], "-w") == 0 && i < argc - 1) { - commit = atoi(argv[++i]); - } else if (strcmp(argv[i], "-d") == 0 && i < argc - 1) { - rpcDebugFlag = atoi(argv[++i]); - dDebugFlag = rpcDebugFlag; - uDebugFlag = rpcDebugFlag; - } else { - printf("\nusage: %s [options] \n", argv[0]); - printf(" [-p port]: server port number, default is:%d\n", rpcInit.localPort); - printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads); - printf(" [-s sessions]: number of sessions, default is:%d\n", rpcInit.sessions); - printf(" [-m msgSize]: message body size, default is:%d\n", msgSize); - printf(" [-o compSize]: compression message size, default is:%d\n", tsCompressMsgSize); - printf(" [-w write]: write received data to file(0, 1, 2), default is:%d\n", commit); - printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag); - printf(" [-h help]: print out this help\n\n"); - exit(0); - } - } - - tsAsyncLog = 0; - rpcInit.connType = TAOS_CONN_SERVER; - - const char *path = TD_TMP_DIR_PATH "transport/server"; - taosRemoveDir(path); - taosMkDir(path); - tstrncpy(tsLogDir, path, PATH_MAX); - taosInitLog("server.log", 10); - - void *pRpc = rpcOpen(&rpcInit); - if (pRpc == NULL) { - tError("failed to start RPC server"); - return -1; - } - // sleep(5); - - tInfo("RPC server is running, ctrl-c to exit"); - - if (commit) { - pDataFile = taosOpenFile(dataName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND); - if (pDataFile == NULL) tInfo("failed to open data file, reason:%s", strerror(errno)); - } - qhandle = taosOpenQueue(); - qset = taosOpenQset(); - taosAddIntoQset(qset, qhandle, NULL); - - processShellMsg(); - - if (pDataFile != NULL) { - taosCloseFile(&pDataFile); - taosRemoveFile(dataName); - } - - return 0; -} diff --git a/source/libs/transport/test/syncClient.c b/source/libs/transport/test/syncClient.c deleted file mode 100644 index bc6461eaed..0000000000 --- a/source/libs/transport/test/syncClient.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -#include -#include "os.h" -#include "taoserror.h" -#include "tglobal.h" -#include "transLog.h" -#include "trpc.h" -#include "tutil.h" - -typedef struct { - int index; - SEpSet epSet; - int num; - int numOfReqs; - int msgSize; - tsem_t rspSem; - tsem_t * pOverSem; - TdThread thread; - void * pRpc; -} SInfo; -static void processResponse(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet) { - SInfo *pInfo = (SInfo *)pMsg->info.ahandle; - tDebug("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, - pMsg->code); - - if (pEpSet) pInfo->epSet = *pEpSet; - - rpcFreeCont(pMsg->pCont); - // tsem_post(&pInfo->rspSem); - tsem_post(&pInfo->rspSem); -} - -static int tcount = 0; - -static void *sendRequest(void *param) { - SInfo * pInfo = (SInfo *)param; - SRpcMsg rpcMsg = {0}; - - tDebug("thread:%d, start to send request", pInfo->index); - - tDebug("thread:%d, reqs: %d", pInfo->index, pInfo->numOfReqs); - int u100 = 0; - int u500 = 0; - int u1000 = 0; - int u10000 = 0; - SRpcMsg respMsg = {0}; - while (pInfo->numOfReqs == 0 || pInfo->num < pInfo->numOfReqs) { - pInfo->num++; - rpcMsg.pCont = rpcMallocCont(pInfo->msgSize); - rpcMsg.contLen = pInfo->msgSize; - rpcMsg.info.ahandle = pInfo; - rpcMsg.msgType = 1; - // tDebug("thread:%d, send request, contLen:%d num:%d", pInfo->index, pInfo->msgSize, pInfo->num); - int64_t start = taosGetTimestampUs(); - rpcSendRecv(pInfo->pRpc, &pInfo->epSet, &rpcMsg, &respMsg); - // rpcSendRequest(pInfo->pRpc, &pInfo->epSet, &rpcMsg, NULL); - if (pInfo->num % 20000 == 0) tInfo("thread:%d, %d requests have been sent", pInfo->index, pInfo->num); - // tsem_wait(&pInfo->rspSem); - // wtsem_wait(&pInfo->rspSem); - int64_t end = taosGetTimestampUs() - start; - if (end <= 100) { - u100++; - } else if (end > 100 && end <= 500) { - u500++; - } else if (end > 500 && end < 1000) { - u1000++; - } else { - u10000++; - } - - tDebug("recv response succefully"); - - // taosSsleep(100); - } - - tError("send and recv sum: %d, %d, %d, %d", u100, u500, u1000, u10000); - tDebug("thread:%d, it is over", pInfo->index); - tcount++; - - return NULL; -} - -int main(int argc, char *argv[]) { - SRpcInit rpcInit; - SEpSet epSet = {0}; - int msgSize = 128; - int numOfReqs = 0; - int appThreads = 1; - char serverIp[40] = "127.0.0.1"; - char secret[20] = "mypassword"; - struct timeval systemTime; - int64_t startTime, endTime; - TdThreadAttr thattr; - - // server info - epSet.inUse = 0; - addEpIntoEpSet(&epSet, serverIp, 7000); - addEpIntoEpSet(&epSet, "192.168.0.1", 7000); - - // client info - memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = 0; - rpcInit.label = "APP"; - rpcInit.numOfThreads = 1; - rpcInit.cfp = processResponse; - rpcInit.sessions = 100; - rpcInit.idleTime = 100; - rpcInit.user = "michael"; - rpcInit.connType = TAOS_CONN_CLIENT; - - for (int i = 1; i < argc; ++i) { - if (strcmp(argv[i], "-p") == 0 && i < argc - 1) { - epSet.eps[0].port = atoi(argv[++i]); - } else if (strcmp(argv[i], "-i") == 0 && i < argc - 1) { - tstrncpy(epSet.eps[0].fqdn, argv[++i], sizeof(epSet.eps[0].fqdn)); - } else if (strcmp(argv[i], "-t") == 0 && i < argc - 1) { - rpcInit.numOfThreads = atoi(argv[++i]); - } else if (strcmp(argv[i], "-m") == 0 && i < argc - 1) { - msgSize = atoi(argv[++i]); - } else if (strcmp(argv[i], "-s") == 0 && i < argc - 1) { - rpcInit.sessions = atoi(argv[++i]); - } else if (strcmp(argv[i], "-n") == 0 && i < argc - 1) { - numOfReqs = atoi(argv[++i]); - } else if (strcmp(argv[i], "-a") == 0 && i < argc - 1) { - appThreads = atoi(argv[++i]); - } else if (strcmp(argv[i], "-o") == 0 && i < argc - 1) { - tsCompressMsgSize = atoi(argv[++i]); - } else if (strcmp(argv[i], "-u") == 0 && i < argc - 1) { - rpcInit.user = argv[++i]; - } else if (strcmp(argv[i], "-k") == 0 && i < argc - 1) { - } else if (strcmp(argv[i], "-spi") == 0 && i < argc - 1) { - } else if (strcmp(argv[i], "-d") == 0 && i < argc - 1) { - rpcDebugFlag = atoi(argv[++i]); - } else { - printf("\nusage: %s [options] \n", argv[0]); - printf(" [-i ip]: first server IP address, default is:%s\n", serverIp); - printf(" [-p port]: server port number, default is:%d\n", epSet.eps[0].port); - printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads); - printf(" [-s sessions]: number of rpc sessions, default is:%d\n", rpcInit.sessions); - printf(" [-m msgSize]: message body size, default is:%d\n", msgSize); - printf(" [-a threads]: number of app threads, default is:%d\n", appThreads); - printf(" [-n requests]: number of requests per thread, default is:%d\n", numOfReqs); - printf(" [-o compSize]: compression message size, default is:%d\n", tsCompressMsgSize); - printf(" [-u user]: user name for the connection, default is:%s\n", rpcInit.user); - printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag); - printf(" [-h help]: print out this help\n\n"); - exit(0); - } - } - - taosInitLog("client.log", 10); - - void *pRpc = rpcOpen(&rpcInit); - if (pRpc == NULL) { - tError("failed to initialize RPC"); - return -1; - } - - tInfo("client is initialized"); - tInfo("threads:%d msgSize:%d requests:%d", appThreads, msgSize, numOfReqs); - - taosGetTimeOfDay(&systemTime); - startTime = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - - SInfo *pInfo = (SInfo *)taosMemoryCalloc(1, sizeof(SInfo) * appThreads); - - taosThreadAttrInit(&thattr); - taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE); - - for (int i = 0; i < appThreads; ++i) { - pInfo->index = i; - pInfo->epSet = epSet; - pInfo->numOfReqs = numOfReqs; - pInfo->msgSize = msgSize; - tsem_init(&pInfo->rspSem, 0, 0); - pInfo->pRpc = pRpc; - taosThreadCreate(&pInfo->thread, &thattr, sendRequest, pInfo); - pInfo++; - } - - do { - taosUsleep(1); - } while (tcount < appThreads); - - taosGetTimeOfDay(&systemTime); - endTime = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - float usedTime = (endTime - startTime) / 1000.0f; // mseconds - - tInfo("it takes %.3f mseconds to send %d requests to server", usedTime, numOfReqs * appThreads); - tInfo("Performance: %.3f requests per second, msgSize:%d bytes", 1000.0 * numOfReqs * appThreads / usedTime, msgSize); - - int ch = getchar(); - UNUSED(ch); - - taosCloseLog(); - - return 0; -} diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index b5c75ce3c4..2d910a85b8 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -30,8 +30,9 @@ SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond) { pRead->pWal = pWal; pRead->pIdxFile = NULL; pRead->pLogFile = NULL; - pRead->curVersion = -1; + pRead->curVersion = -5; pRead->curFileFirstVer = -1; + pRead->curInvalid = 1; pRead->capacity = 0; if (cond) pRead->cond = *cond; @@ -94,17 +95,19 @@ static int64_t walReadSeekFilePos(SWalReader *pRead, int64_t fileFirstVer, int64 ret = taosLSeekFile(pIdxTFile, offset, SEEK_SET); if (ret < 0) { terrno = TAOS_SYSTEM_ERROR(errno); - wError("failed to seek idx file, ver %ld, pos: %ld, since %s", ver, offset, terrstr()); + wError("vgId:%d, failed to seek idx file, index:%" PRId64 ", pos:%" PRId64 ", since %s", pRead->pWal->cfg.vgId, ver, + offset, terrstr()); return -1; } SWalIdxEntry entry = {0}; if ((ret = taosReadFile(pIdxTFile, &entry, sizeof(SWalIdxEntry))) != sizeof(SWalIdxEntry)) { if (ret < 0) { terrno = TAOS_SYSTEM_ERROR(errno); - wError("failed to read idx file, since %s", terrstr()); + wError("vgId:%d, failed to read idx file, since %s", pRead->pWal->cfg.vgId, terrstr()); } else { terrno = TSDB_CODE_WAL_FILE_CORRUPTED; - wError("read idx file incompletely, read bytes %ld, bytes should be %lu", ret, sizeof(SWalIdxEntry)); + wError("vgId:%d, read idx file incompletely, read bytes %" PRId64 ", bytes should be %" PRIu64, + pRead->pWal->cfg.vgId, ret, sizeof(SWalIdxEntry)); } return -1; } @@ -113,7 +116,8 @@ static int64_t walReadSeekFilePos(SWalReader *pRead, int64_t fileFirstVer, int64 ret = taosLSeekFile(pLogTFile, entry.offset, SEEK_SET); if (ret < 0) { terrno = TAOS_SYSTEM_ERROR(errno); - wError("failed to seek log file, ver %ld, pos: %ld, since %s", ver, entry.offset, terrstr()); + wError("vgId:%d, failed to seek log file, index:%" PRId64 ", pos:%" PRId64 ", since %s", pRead->pWal->cfg.vgId, ver, + entry.offset, terrstr()); return -1; } return ret; @@ -129,7 +133,7 @@ static int32_t walReadChangeFile(SWalReader *pRead, int64_t fileFirstVer) { TdFilePtr pLogTFile = taosOpenFile(fnameStr, TD_FILE_READ); if (pLogTFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); - wError("cannot open file %s, since %s", fnameStr, terrstr()); + wError("vgId:%d, cannot open file %s, since %s", pRead->pWal->cfg.vgId, fnameStr, terrstr()); return -1; } @@ -139,7 +143,7 @@ static int32_t walReadChangeFile(SWalReader *pRead, int64_t fileFirstVer) { TdFilePtr pIdxTFile = taosOpenFile(fnameStr, TD_FILE_READ); if (pIdxTFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); - wError("cannot open file %s, since %s", fnameStr, terrstr()); + wError("vgId:%d, cannot open file %s, since %s", pRead->pWal->cfg.vgId, fnameStr, terrstr()); return -1; } @@ -147,13 +151,19 @@ static int32_t walReadChangeFile(SWalReader *pRead, int64_t fileFirstVer) { return 0; } -static int32_t walReadSeekVer(SWalReader *pRead, int64_t ver) { +int32_t walReadSeekVer(SWalReader *pRead, int64_t ver) { SWal *pWal = pRead->pWal; - if (ver == pRead->curVersion) { + if (!pRead->curInvalid && ver == pRead->curVersion) { + wDebug("wal version %ld match, no need to reset", ver); return 0; } + + pRead->curInvalid = 1; + pRead->curVersion = ver; + if (ver > pWal->vers.lastVer || ver < pWal->vers.firstVer) { - wError("invalid version: % " PRId64 ", first ver %ld, last ver %ld", ver, pWal->vers.firstVer, pWal->vers.lastVer); + wDebug("vgId:%d, invalid index:%" PRId64 ", first index:%" PRId64 ", last index:%" PRId64, pRead->pWal->cfg.vgId, + ver, pWal->vers.firstVer, pWal->vers.lastVer); terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; return -1; } @@ -166,17 +176,19 @@ static int32_t walReadSeekVer(SWalReader *pRead, int64_t ver) { SWalFileInfo *pRet = taosArraySearch(pWal->fileInfoSet, &tmpInfo, compareWalFileInfo, TD_LE); ASSERT(pRet != NULL); if (pRead->curFileFirstVer != pRet->firstVer) { - // error code set inner + // error code was set inner if (walReadChangeFile(pRead, pRet->firstVer) < 0) { return -1; } } - // error code set inner + // error code was set inner if (walReadSeekFilePos(pRead, pRet->firstVer, ver) < 0) { return -1; } + wDebug("wal version reset from %ld to %ld", pRead->curVersion, ver); + pRead->curVersion = ver; return 0; @@ -186,8 +198,13 @@ void walSetReaderCapacity(SWalReader *pRead, int32_t capacity) { pRead->capacity static int32_t walFetchHeadNew(SWalReader *pRead, int64_t fetchVer) { int64_t contLen; - if (pRead->curVersion != fetchVer) { - if (walReadSeekVer(pRead, fetchVer) < 0) return -1; + if (pRead->curInvalid || pRead->curVersion != fetchVer) { + if (walReadSeekVer(pRead, fetchVer) < 0) { + ASSERT(0); + pRead->curVersion = fetchVer; + pRead->curInvalid = 1; + return -1; + } } contLen = taosReadFile(pRead->pLogFile, pRead->pHead, sizeof(SWalCkHead)); if (contLen != sizeof(SWalCkHead)) { @@ -196,7 +213,8 @@ static int32_t walFetchHeadNew(SWalReader *pRead, int64_t fetchVer) { } else { terrno = TSDB_CODE_WAL_FILE_CORRUPTED; } - pRead->curVersion = -1; + ASSERT(0); + pRead->curInvalid = 1; return -1; } return 0; @@ -220,35 +238,37 @@ static int32_t walFetchBodyNew(SWalReader *pRead) { if (pReadHead->bodyLen != taosReadFile(pRead->pLogFile, pReadHead->body, pReadHead->bodyLen)) { if (pReadHead->bodyLen < 0) { terrno = TAOS_SYSTEM_ERROR(errno); - wError("wal fetch body error: %" PRId64 ", read request version:%" PRId64 ", since %s", - pRead->pHead->head.version, ver, tstrerror(terrno)); + wError("vgId:%d, wal fetch body error:%" PRId64 ", read request index:%" PRId64 ", since %s", + pRead->pWal->cfg.vgId, pRead->pHead->head.version, ver, tstrerror(terrno)); } else { - wError("wal fetch body error: %" PRId64 ", read request version:%" PRId64 ", since file corrupted", - pRead->pHead->head.version, ver); + wError("vgId:%d, wal fetch body error:%" PRId64 ", read request index:%" PRId64 ", since file corrupted", + pRead->pWal->cfg.vgId, pRead->pHead->head.version, ver); terrno = TSDB_CODE_WAL_FILE_CORRUPTED; } - pRead->curVersion = -1; + pRead->curInvalid = 1; ASSERT(0); return -1; } if (pReadHead->version != ver) { - wError("wal fetch body error: %" PRId64 ", read request version:%" PRId64 "", pRead->pHead->head.version, ver); - pRead->curVersion = -1; + wError("vgId:%d, wal fetch body error:%" PRId64 ", read request index:%" PRId64, pRead->pWal->cfg.vgId, + pRead->pHead->head.version, ver); + pRead->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; ASSERT(0); return -1; } if (walValidBodyCksum(pRead->pHead) != 0) { - wError("wal fetch body error: % " PRId64 ", since body checksum not passed", ver); - pRead->curVersion = -1; + wError("vgId:%d, wal fetch body error:%" PRId64 ", since body checksum not passed", pRead->pWal->cfg.vgId, ver); + pRead->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; ASSERT(0); return -1; } pRead->curVersion = ver + 1; + wDebug("version advance to %ld, fetch body", pRead->curVersion); return 0; } @@ -260,11 +280,13 @@ static int32_t walSkipFetchBodyNew(SWalReader *pRead) { code = taosLSeekFile(pRead->pLogFile, pRead->pHead->head.bodyLen, SEEK_CUR); if (code < 0) { terrno = TAOS_SYSTEM_ERROR(errno); - pRead->curVersion = -1; + pRead->curInvalid = 1; + ASSERT(0); return -1; } pRead->curVersion++; + wDebug("version advance to %ld, skip fetch", pRead->curVersion); return 0; } @@ -277,7 +299,7 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) { return -1; } - if (pRead->curVersion != ver) { + if (pRead->curInvalid || pRead->curVersion != ver) { code = walReadSeekVer(pRead, ver); if (code < 0) return -1; } @@ -292,7 +314,7 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) { code = walValidHeadCksum(pHead); if (code != 0) { - wError("unexpected wal log version: % " PRId64 ", since head checksum not passed", ver); + wError("vgId:%d, unexpected wal log index:%" PRId64 ", since head checksum not passed", pRead->pWal->cfg.vgId, ver); terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } @@ -308,7 +330,7 @@ int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead) { code = taosLSeekFile(pRead->pLogFile, pHead->head.bodyLen, SEEK_CUR); if (code < 0) { terrno = TAOS_SYSTEM_ERROR(errno); - pRead->curVersion = -1; + pRead->curInvalid = 1; return -1; } @@ -338,15 +360,16 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) { } if (pReadHead->version != ver) { - wError("wal fetch body error: %" PRId64 ", read request version:%" PRId64 "", pRead->pHead->head.version, ver); - pRead->curVersion = -1; + wError("vgId:%d, wal fetch body error:%" PRId64 ", read request index:%" PRId64, pRead->pWal->cfg.vgId, + pRead->pHead->head.version, ver); + pRead->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } if (walValidBodyCksum(*ppHead) != 0) { - wError("wal fetch body error: % " PRId64 ", since body checksum not passed", ver); - pRead->curVersion = -1; + wError("vgId:%d, wal fetch body error:%" PRId64 ", since body checksum not passed", pRead->pWal->cfg.vgId, ver); + pRead->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } @@ -355,22 +378,6 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) { return 0; } -int32_t walReadWithHandle_s(SWalReader *pRead, int64_t ver, SWalCont **ppHead) { - taosThreadMutexLock(&pRead->mutex); - if (walReadVer(pRead, ver) < 0) { - taosThreadMutexUnlock(&pRead->mutex); - return -1; - } - *ppHead = taosMemoryMalloc(sizeof(SWalCont) + pRead->pHead->head.bodyLen); - if (*ppHead == NULL) { - taosThreadMutexUnlock(&pRead->mutex); - return -1; - } - memcpy(*ppHead, &pRead->pHead->head, sizeof(SWalCont) + pRead->pHead->head.bodyLen); - taosThreadMutexUnlock(&pRead->mutex); - return 0; -} - int32_t walReadVer(SWalReader *pRead, int64_t ver) { int64_t code; @@ -379,17 +386,16 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) { return -1; } - // TODO: check wal life - if (pRead->curVersion != ver) { + if (pRead->curInvalid || pRead->curVersion != ver) { if (walReadSeekVer(pRead, ver) < 0) { - wError("unexpected wal log version: % " PRId64 ", since %s", ver, terrstr()); + wError("vgId:%d, unexpected wal log index:%" PRId64 ", since %s", pRead->pWal->cfg.vgId, ver, terrstr()); return -1; } } if (ver > pRead->pWal->vers.lastVer || ver < pRead->pWal->vers.firstVer) { - wError("invalid version: % " PRId64 ", first ver %ld, last ver %ld", ver, pRead->pWal->vers.firstVer, - pRead->pWal->vers.lastVer); + wError("vgId:%d, invalid index:%" PRId64 ", first index:%" PRId64 ", last index:%" PRId64, pRead->pWal->cfg.vgId, + ver, pRead->pWal->vers.firstVer, pRead->pWal->vers.lastVer); terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; return -1; } @@ -409,7 +415,7 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) { code = walValidHeadCksum(pRead->pHead); if (code != 0) { - wError("unexpected wal log version: % " PRId64 ", since head checksum not passed", ver); + wError("vgId:%d, unexpected wal log index:%" PRId64 ", since head checksum not passed", pRead->pWal->cfg.vgId, ver); terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } @@ -436,17 +442,17 @@ int32_t walReadVer(SWalReader *pRead, int64_t ver) { } if (pRead->pHead->head.version != ver) { - wError("unexpected wal log version: %" PRId64 ", read request version:%" PRId64 "", pRead->pHead->head.version, - ver); - pRead->curVersion = -1; + wError("vgId:%d, unexpected wal log index:%" PRId64 ", read request index:%" PRId64, pRead->pWal->cfg.vgId, + pRead->pHead->head.version, ver); + pRead->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } code = walValidBodyCksum(pRead->pHead); if (code != 0) { - wError("unexpected wal log version: % " PRId64 ", since body checksum not passed", ver); - pRead->curVersion = -1; + wError("vgId:%d, unexpected wal log index:%" PRId64 ", since body checksum not passed", pRead->pWal->cfg.vgId, ver); + pRead->curInvalid = 1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index 445cdea45b..900d866a1d 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -318,7 +318,8 @@ int walRoll(SWal *pWal) { static int walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) { SWalIdxEntry entry = {.ver = ver, .offset = offset}; int64_t idxOffset = taosLSeekFile(pWal->pWriteIdxTFile, 0, SEEK_END); - wDebug("write index: ver: %ld, offset: %ld, at %ld", ver, offset, idxOffset); + wDebug("vgId:%d, write index, index:%" PRId64 ", offset:%" PRId64 ", at %" PRId64, pWal->cfg.vgId, ver, offset, + idxOffset); int64_t size = taosWriteFile(pWal->pWriteIdxTFile, &entry, sizeof(SWalIdxEntry)); if (size != sizeof(SWalIdxEntry)) { terrno = TAOS_SYSTEM_ERROR(errno); diff --git a/source/os/src/osSemaphore.c b/source/os/src/osSemaphore.c index 7ee73d8e2f..3275774cce 100644 --- a/source/os/src/osSemaphore.c +++ b/source/os/src/osSemaphore.c @@ -210,7 +210,7 @@ int32_t tsem_timewait(tsem_t* sem, int64_t nanosecs) { // id = 0; // } // char name[NAME_MAX - 4]; -// snprintf(name, sizeof(name), "/t%ld", id); +// snprintf(name, sizeof(name), "/t" PRId64, id); // p->sem = sem_open(name, O_CREAT | O_EXCL, pshared, value); // p->id = id; // if (p->sem != SEM_FAILED) break; @@ -366,7 +366,7 @@ int32_t tsem_timewait(tsem_t* sem, int64_t nanosecs) { // } // #elif defined(SEM_USE_POSIX) // char name[NAME_MAX - 4]; -// snprintf(name, sizeof(name), "/t%ld", p->id); +// snprintf(name, sizeof(name), "/t" PRId64, p->id); // int r = sem_unlink(name); // if (r) { // int e = errno; diff --git a/source/os/src/osStrptime.c b/source/os/src/osStrptime.c deleted file mode 100644 index 8d878577ea..0000000000 --- a/source/os/src/osStrptime.c +++ /dev/null @@ -1,405 +0,0 @@ -/* $Id$ */ -/* $NetBSD: strptime.c,v 1.18 1999/04/29 02:58:30 tv Exp $ */ - -/*- -* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. -* All rights reserved. -* -* This code was contributed to The NetBSD Foundation by Klaus Klein. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. All advertising materials mentioning features or use of this software -* must display the following acknowledgement: -* This product includes software developed by the NetBSD -* Foundation, Inc. and its contributors. -* 4. Neither the name of The NetBSD Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*/ -// -//#include "lukemftp.h" - -// #ifdef WINDOWS - -// #include -// #include -// #include -// #include -// //#define TM_YEAR_BASE 1970 //origin -// #define TM_YEAR_BASE 1900 //slguan -// /* -// * We do not implement alternate representations. However, we always -// * check whether a given modifier is allowed for a certain conversion. -// */ -// #define ALT_E 0x01 -// #define ALT_O 0x02 -// #define LEGAL_ALT(x) { if (alt_format & ~(x)) return (0); } - - -// static int conv_num(const char **buf, int *dest, int llim, int ulim) -// { -// int result = 0; - -// /* The limit also determines the number of valid digits. */ -// int rulim = ulim; - -// if (**buf < '0' || **buf > '9') -// return (0); - -// do { -// result *= 10; -// result += *(*buf)++ - '0'; -// rulim /= 10; -// } while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9'); - -// if (result < llim || result > ulim) -// return (0); - -// *dest = result; -// return (1); -// } - -// static const char *day[7] = { -// "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", -// "Friday", "Saturday" -// }; -// static const char *abday[7] = { -// "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" -// }; -// static const char *mon[12] = { -// "January", "February", "March", "April", "May", "June", "July", -// "August", "September", "October", "November", "December" -// }; -// static const char *abmon[12] = { -// "Jan", "Feb", "Mar", "Apr", "May", "Jun", -// "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -// }; -// static const char *am_pm[2] = { -// "AM", "PM" -// }; - -// #endif - -// char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm) { -// #ifdef WINDOWS -// char c; -// const char *bp; -// size_t len = 0; -// int alt_format, i, split_year = 0; - -// bp = buf; - -// while ((c = *fmt) != '\0') { -// /* Clear `alternate' modifier prior to new conversion. */ -// alt_format = 0; - -// /* Eat up white-space. */ -// if (isspace(c)) { -// while (isspace(*bp)) -// bp++; - -// fmt++; -// continue; -// } - -// if ((c = *fmt++) != '%') -// goto literal; - - -// again: switch (c = *fmt++) { -// case '%': /* "%%" is converted to "%". */ -// literal : -// if (c != *bp++) -// return (0); -// break; - -// /* -// * "Alternative" modifiers. Just set the appropriate flag -// * and start over again. -// */ -// case 'E': /* "%E?" alternative conversion modifier. */ -// LEGAL_ALT(0); -// alt_format |= ALT_E; -// goto again; - -// case 'O': /* "%O?" alternative conversion modifier. */ -// LEGAL_ALT(0); -// alt_format |= ALT_O; -// goto again; - -// /* -// * "Complex" conversion rules, implemented through recursion. -// */ -// case 'c': /* Date and time, using the locale's format. */ -// LEGAL_ALT(ALT_E); -// if (!(bp = taosStrpTime(bp, "%x %X", tm))) -// return (0); -// break; - -// case 'D': /* The date as "%m/%d/%y". */ -// LEGAL_ALT(0); -// if (!(bp = taosStrpTime(bp, "%m/%d/%y", tm))) -// return (0); -// break; - -// case 'R': /* The time as "%H:%M". */ -// LEGAL_ALT(0); -// if (!(bp = taosStrpTime(bp, "%H:%M", tm))) -// return (0); -// break; - -// case 'r': /* The time in 12-hour clock representation. */ -// LEGAL_ALT(0); -// if (!(bp = taosStrpTime(bp, "%I:%M:%S %p", tm))) -// return (0); -// break; - -// case 'T': /* The time as "%H:%M:%S". */ -// LEGAL_ALT(0); -// if (!(bp = taosStrpTime(bp, "%H:%M:%S", tm))) -// return (0); -// break; - -// case 'X': /* The time, using the locale's format. */ -// LEGAL_ALT(ALT_E); -// if (!(bp = taosStrpTime(bp, "%H:%M:%S", tm))) -// return (0); -// break; - -// case 'x': /* The date, using the locale's format. */ -// LEGAL_ALT(ALT_E); -// if (!(bp = taosStrpTime(bp, "%m/%d/%y", tm))) -// return (0); -// break; - -// /* -// * "Elementary" conversion rules. -// */ -// case 'A': /* The day of week, using the locale's form. */ -// case 'a': -// LEGAL_ALT(0); -// for (i = 0; i < 7; i++) { -// /* Full name. */ -// len = strlen(day[i]); -// if (strncmp(day[i], bp, len) == 0) -// break; - -// /* Abbreviated name. */ -// len = strlen(abday[i]); -// if (strncmp(abday[i], bp, len) == 0) -// break; -// } - -// /* Nothing matched. */ -// if (i == 7) -// return (0); - -// tm->tm_wday = i; -// bp += len; -// break; - -// case 'B': /* The month, using the locale's form. */ -// case 'b': -// case 'h': -// LEGAL_ALT(0); -// for (i = 0; i < 12; i++) { -// /* Full name. */ -// len = strlen(mon[i]); -// if (strncmp(mon[i], bp, len) == 0) -// break; - -// /* Abbreviated name. */ -// len = strlen(abmon[i]); -// if (strncmp(abmon[i], bp, len) == 0) -// break; -// } - -// /* Nothing matched. */ -// if (i == 12) -// return (0); - -// tm->tm_mon = i; -// bp += len; -// break; - -// case 'C': /* The century number. */ -// LEGAL_ALT(ALT_E); -// if (!(conv_num(&bp, &i, 0, 99))) -// return (0); - -// if (split_year) { -// tm->tm_year = (tm->tm_year % 100) + (i * 100); -// } -// else { -// tm->tm_year = i * 100; -// split_year = 1; -// } -// break; - -// case 'd': /* The day of month. */ -// case 'e': -// LEGAL_ALT(ALT_O); -// if (!(conv_num(&bp, &tm->tm_mday, 1, 31))) -// return (0); -// break; - -// case 'k': /* The hour (24-hour clock representation). */ -// LEGAL_ALT(0); -// /* FALLTHROUGH */ -// case 'H': -// LEGAL_ALT(ALT_O); -// if (!(conv_num(&bp, &tm->tm_hour, 0, 23))) -// return (0); -// break; - -// case 'l': /* The hour (12-hour clock representation). */ -// LEGAL_ALT(0); -// /* FALLTHROUGH */ -// case 'I': -// LEGAL_ALT(ALT_O); -// if (!(conv_num(&bp, &tm->tm_hour, 1, 12))) -// return (0); -// if (tm->tm_hour == 12) -// tm->tm_hour = 0; -// break; - -// case 'j': /* The day of year. */ -// LEGAL_ALT(0); -// if (!(conv_num(&bp, &i, 1, 366))) -// return (0); -// tm->tm_yday = i - 1; -// break; - -// case 'M': /* The minute. */ -// LEGAL_ALT(ALT_O); -// if (!(conv_num(&bp, &tm->tm_min, 0, 59))) -// return (0); -// break; - -// case 'm': /* The month. */ -// LEGAL_ALT(ALT_O); -// if (!(conv_num(&bp, &i, 1, 12))) -// return (0); -// tm->tm_mon = i - 1; -// break; - -// case 'p': /* The locale's equivalent of AM/PM. */ -// LEGAL_ALT(0); -// /* AM? */ -// if (strcmp(am_pm[0], bp) == 0) { -// if (tm->tm_hour > 11) -// return (0); - -// bp += strlen(am_pm[0]); -// break; -// } -// /* PM? */ -// else if (strcmp(am_pm[1], bp) == 0) { -// if (tm->tm_hour > 11) -// return (0); - -// tm->tm_hour += 12; -// bp += strlen(am_pm[1]); -// break; -// } - -// /* Nothing matched. */ -// return (0); - -// case 'S': /* The seconds. */ -// LEGAL_ALT(ALT_O); -// if (!(conv_num(&bp, &tm->tm_sec, 0, 61))) -// return (0); -// break; - -// case 'U': /* The week of year, beginning on sunday. */ -// case 'W': /* The week of year, beginning on monday. */ -// LEGAL_ALT(ALT_O); -// /* -// * XXX This is bogus, as we can not assume any valid -// * information present in the tm structure at this -// * point to calculate a real value, so just check the -// * range for now. -// */ -// if (!(conv_num(&bp, &i, 0, 53))) -// return (0); -// break; - -// case 'w': /* The day of week, beginning on sunday. */ -// LEGAL_ALT(ALT_O); -// if (!(conv_num(&bp, &tm->tm_wday, 0, 6))) -// return (0); -// break; - -// case 'Y': /* The year. */ -// LEGAL_ALT(ALT_E); -// if (!(conv_num(&bp, &i, 0, 9999))) -// return (0); - -// tm->tm_year = i - TM_YEAR_BASE; -// break; - -// case 'y': /* The year within 100 years of the epoch. */ -// LEGAL_ALT(ALT_E | ALT_O); -// if (!(conv_num(&bp, &i, 0, 99))) -// return (0); - -// if (split_year) { -// tm->tm_year = ((tm->tm_year / 100) * 100) + i; -// break; -// } -// split_year = 1; -// if (i <= 68) -// tm->tm_year = i + 2000 - TM_YEAR_BASE; -// else -// tm->tm_year = i + 1900 - TM_YEAR_BASE; -// break; - -// /* -// * Miscellaneous conversions. -// */ -// case 'n': /* Any kind of white-space. */ -// case 't': -// LEGAL_ALT(0); -// while (isspace(*bp)) -// bp++; -// break; - - -// default: /* Unknown/unsupported conversion. */ -// return (0); -// } - - -// } - -// /* LINTED functional specification */ -// return ((char *)bp); -// #elif defined(_TD_DARWIN_64) -// return strptime(buf, fmt, tm); -// #else -// return strptime(buf, fmt, tm); -// #endif -// } - - - diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 0301b842c4..ef6697b3b5 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -251,6 +251,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_ALREADY_EXIST, "Column already exists TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_NOT_EXIST, "Column does not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC,"Field used by topic") TAOS_DEFINE_ERROR(TSDB_CODE_MND_SINGLE_STB_MODE_DB, "Database is single stable mode") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SCHEMA_VER, "Invalid schema version while alter stb") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_STABLE_UID_NOT_MATCH, "Invalid stable uid while alter stb") // mnode-infoSchema TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SYS_TABLENAME, "Invalid system table name") diff --git a/source/util/src/tjson.c b/source/util/src/tjson.c index 45a2ffec77..cc823decf4 100644 --- a/source/util/src/tjson.c +++ b/source/util/src/tjson.c @@ -202,9 +202,8 @@ int32_t tjsonGetBigIntValue(const SJson* pJson, const char* pName, int64_t* pVal return TSDB_CODE_FAILED; } #ifdef WINDOWS - sscanf(p, "%lld", pVal); + sscanf(p, "%" PRId64, pVal); #else - // sscanf(p,"%ld",pVal); *pVal = taosStr2Int64(p, NULL, 10); #endif return TSDB_CODE_SUCCESS; @@ -237,9 +236,8 @@ int32_t tjsonGetUBigIntValue(const SJson* pJson, const char* pName, uint64_t* pV return TSDB_CODE_FAILED; } #ifdef WINDOWS - sscanf(p, "%llu", pVal); + sscanf(p, "%" PRIu64, pVal); #else - // sscanf(p,"%ld",pVal); *pVal = taosStr2UInt64(p, NULL, 10); #endif return TSDB_CODE_SUCCESS; diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 0439ed148b..9d7656de35 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -94,7 +94,7 @@ int32_t tdbDebugFlag = 131; int32_t tqDebugFlag = 135; int32_t fsDebugFlag = 135; int32_t metaDebugFlag = 135; -int32_t fnDebugFlag = 135; +int32_t udfDebugFlag = 135; int32_t smaDebugFlag = 135; int32_t idxDebugFlag = 135; @@ -758,7 +758,7 @@ void taosSetAllDebugFlag(int32_t flag) { tsdbDebugFlag = flag; tqDebugFlag = flag; fsDebugFlag = flag; - fnDebugFlag = flag; + udfDebugFlag = flag; smaDebugFlag = flag; idxDebugFlag = flag; diff --git a/source/util/src/ttrace.c b/source/util/src/ttrace.c deleted file mode 100644 index f183fd58fd..0000000000 --- a/source/util/src/ttrace.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -#include "ttrace.h" -#include "taos.h" -#include "thash.h" -#include "tuuid.h" - -// clang-format off -//static TdThreadOnce init = PTHREAD_ONCE_INIT; -//static void * ids = NULL; -//static TdThreadMutex mtx; -// -//void traceInit() { -// ids = taosHashInit(4096, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); -// taosThreadMutexInit(&mtx, NULL); -//} -//void traceCreateEnv() { -// taosThreadOnce(&init, traceInit); -//} -//void traceDestroyEnv() { -// taosThreadMutexDestroy(&mtx); -// taosHashCleanup(ids); -//} -// -//STraceId traceInitId(STraceSubId *h, STraceSubId *l) { -// STraceId id = *h; -// id = ((id << 32) & 0xFFFFFFFF) | ((*l) & 0xFFFFFFFF); -// return id; -//} -//void traceId2Str(STraceId *id, char *buf) { -// int32_t f = (*id >> 32) & 0xFFFFFFFF; -// int32_t s = (*id) & 0xFFFFFFFF; -// sprintf(buf, "%d:%d", f, s); -//} -// -//void traceSetSubId(STraceId *id, STraceSubId *subId) { -// int32_t parent = ((*id >> 32) & 0xFFFFFFFF); -// taosThreadMutexLock(&mtx); -// taosHashPut(ids, subId, sizeof(*subId), &parent, sizeof(parent)); -// taosThreadMutexUnlock(&mtx); -//} -// -//STraceSubId traceGetParentId(STraceId *id) { -// int32_t parent = ((*id >> 32) & 0xFFFFFFFF); -// taosThreadMutexLock(&mtx); -// STraceSubId *p = taosHashGet(ids, (void *)&parent, sizeof(parent)); -// parent = *p; -// taosThreadMutexUnlock(&mtx); -// -// return parent; -//} -// -//STraceSubId traceGenSubId() { -// return tGenIdPI32(); -//} -//void traceSetRootId(STraceId *traceid, int64_t rootId) { -// traceId->rootId = rootId; -//} -//int64_t traceGetRootId(STraceId *traceId); -// -//void traceSetMsgId(STraceId *traceid, int64_t msgId); -//int64_t traceGetMsgId(STraceId *traceid); -// -//char *trace2Str(STraceId *id); -// -//void traceSetSubId(STraceId *id, int32_t *subId); -// clang-format on diff --git a/tests/pytest/crash_gen.sh b/tests/pytest/crash_gen.sh index 127e13c5be..539314dea4 100755 --- a/tests/pytest/crash_gen.sh +++ b/tests/pytest/crash_gen.sh @@ -48,7 +48,12 @@ fi PYTHON_EXEC=python3.8 # First we need to set up a path for Python to find our own TAOS modules, so that "import" can work. -export PYTHONPATH=$(pwd)/../../src/connector/python:$(pwd) +# export PYTHONPATH=$(pwd)/../../src/connector/python:$(pwd) +# NOTE: we are now pointing outside the current github, per Wade on 7/7/2022, we'll be keeping connectors outside +# and there does not seem to be a module to reference that. +PROJECT_PARENT=$(pwd)/../../.. +TAOS_PYTHON_PROJECT_DIR=$PROJECT_PARENT/taos-connector-python +export PYTHONPATH=$TAOS_PYTHON_PROJECT_DIR:$(pwd) # Then let us set up the library path so that our compiled SO file can be loaded by Python export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR diff --git a/tests/pytest/crash_gen/crash_gen_main.py b/tests/pytest/crash_gen/crash_gen_main.py index b743eee2ef..08155f656b 100755 --- a/tests/pytest/crash_gen/crash_gen_main.py +++ b/tests/pytest/crash_gen/crash_gen_main.py @@ -466,6 +466,7 @@ class ThreadCoordinator: self._te = None # No more executor, time to end Logging.debug("Main thread tapping all threads one last time...") self.tapAllThreads() # Let the threads run one last time + #TODO: looks like we are not capturing the failures for the last step yet (i.e. calling registerFailure if neccessary) Logging.debug("\r\n\n--> Main thread ready to finish up...") Logging.debug("Main thread joining all threads") @@ -1290,6 +1291,7 @@ class Task(): def _isErrAcceptable(self, errno, msg): if errno in [ + # TDengine 2.x Error Codes: 0x05, # TSDB_CODE_RPC_NOT_READY 0x0B, # Unable to establish connection, more details in TD-1648 # 0x200, # invalid SQL, TODO: re-examine with TD-934 @@ -1310,6 +1312,18 @@ class Task(): 0x14, # db not ready, errno changed 0x600, # Invalid table ID, why? 0x218, # Table does not exist + + # TDengine 3.0 Error Codes: + 0x0333, # Object is creating # TODO: this really is NOT an acceptable error + 0x03A0, # STable already exists + 0x03A1, # STable [does] not exist + 0x03AA, # Tag already exists + 0x0603, # Table already exists + 0x2602, # Table does not exist + 0x260d, # Tags number not matched + + + 1000 # REST catch-all error ]: return True # These are the ALWAYS-ACCEPTABLE ones @@ -1749,6 +1763,8 @@ class TdSuperTable: tagType = tags[tagName] if tagType == 'BINARY': tagStrs.append("'Beijing-Shanghai-LosAngeles'") + elif tagType== 'VARCHAR': + tagStrs.append("'London-Paris-Berlin'") elif tagType == 'FLOAT': tagStrs.append('9.9') elif tagType == 'INT': diff --git a/tests/script/general/insert/insert_select.sim b/tests/script/general/insert/insert_select.sim new file mode 100644 index 0000000000..c44197d7d4 --- /dev/null +++ b/tests/script/general/insert/insert_select.sim @@ -0,0 +1,45 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======== step1 +sql drop database if exists db1; +sql create database db1 vgroups 3; +sql use db1; +sql create stable st1 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int); +sql create table tb1 using st1 tags(1); +sql insert into tb1 values ('2022-07-07 10:01:01', 11, "aaa"); +sql insert into tb1 values ('2022-07-07 11:01:02', 12, "bbb"); +sql create table tb2 using st1 tags(2); +sql insert into tb2 values ('2022-07-07 10:02:01', 21, "aaa"); +sql insert into tb2 values ('2022-07-07 11:02:02', 22, "bbb"); +sql create table tb3 using st1 tags(3); +sql insert into tb3 values ('2022-07-07 10:03:01', 31, "aaa"); +sql insert into tb3 values ('2022-07-07 11:03:02', 32, "bbb"); +sql create table tb4 using st1 tags(4); +sql insert into tb4 select * from tb1; +sql select * from tb4; +if $rows != 2 then + return -1 +endi +sql insert into tb4 select ts,f1,f2 from st1; +sql select * from tb4; +if $rows != 6 then + return -1 +endi +sql create table tba (ts timestamp, f1 binary(10), f2 bigint, f3 double); +sql_error insert into tba select * from tb1; +sql insert into tba (ts,f2,f1) select * from tb1; +sql select * from tba; +if $rows != 2 then + return -1 +endi +sql create table tbb (ts timestamp, f1 binary(10), f2 bigint, f3 double); +sql insert into tbb (f2,f1,ts) select f1+1,f2,ts+3 from tb2; +sql select * from tbb; +if $rows != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 0783aa0fd1..79f0034052 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -80,7 +80,7 @@ ./test.sh -f tsim/mnode/basic1.sim ./test.sh -f tsim/mnode/basic2.sim ./test.sh -f tsim/mnode/basic3.sim -./test.sh -f tsim/mnode/basic4.sim +#./test.sh -f tsim/mnode/basic4.sim ./test.sh -f tsim/mnode/basic5.sim # ---- show @@ -163,8 +163,8 @@ # --- sma ./test.sh -f tsim/sma/drop_sma.sim ./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim -./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim -./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim +#./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim +#./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim # --- valgrind ./test.sh -f tsim/valgrind/checkError1.sim diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 1deea26337..4d93878a98 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -134,10 +134,14 @@ echo "cDebugFlag 143" >> $TAOS_CFG echo "jniDebugFlag 143" >> $TAOS_CFG echo "qDebugFlag 143" >> $TAOS_CFG echo "rpcDebugFlag 143" >> $TAOS_CFG -echo "tmrDebugFlag 131" >> $TAOS_CFG -echo "uDebugFlag 143" >> $TAOS_CFG echo "sDebugFlag 143" >> $TAOS_CFG echo "wDebugFlag 143" >> $TAOS_CFG +echo "idxDebugFlag 143" >> $TAOS_CFG +echo "fsDebugFlag 143" >> $TAOS_CFG +echo "udfDebugFlag 143" >> $TAOS_CFG +echo "smaDebugFlag 143" >> $TAOS_CFG +echo "tmrDebugFlag 131" >> $TAOS_CFG +echo "uDebugFlag 131" >> $TAOS_CFG echo "numOfLogLines 20000000" >> $TAOS_CFG echo "statusInterval 1" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG diff --git a/tests/script/tsim/sync/vnodesnapshot-restart.sim b/tests/script/tsim/sync/vnodesnapshot-restart.sim new file mode 100644 index 0000000000..3ed82fdfe7 --- /dev/null +++ b/tests/script/tsim/sync/vnodesnapshot-restart.sim @@ -0,0 +1,14 @@ +system sh/stop_dnodes.sh + +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT +#system sh/exec.sh -n dnode2 -s stop -x SIGINT +#system sh/exec.sh -n dnode3 -s stop -x SIGINT +#system sh/exec.sh -n dnode4 -s stop -x SIGINT + diff --git a/tests/script/tsim/sync/vnodesnapshot.sim b/tests/script/tsim/sync/vnodesnapshot.sim index da97f40f1a..347255b489 100644 --- a/tests/script/tsim/sync/vnodesnapshot.sim +++ b/tests/script/tsim/sync/vnodesnapshot.sim @@ -140,23 +140,31 @@ endi sql create table ct1 using stb tags(1000) -system sh/exec.sh -n dnode4 -s stop -x SIGINT -sql insert into ct1 values(now+0s, 10, 2.0, 3.0) -sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) +$N = 100 +$count = 0 +while $count < $N + $ms = 1591200000000 + $count + sql insert into ct1 values( $ms , $count , 2.1, 3.1) + $count = $count + 1 +endw + + +#sql insert into ct1 values(now+0s, 10, 2.0, 3.0) +#sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) #sql flush database db; -#system sh/exec.sh -n dnode4 -s start - -sql insert into ct1 values(now+1s, 81, 8.1, 8.1)(now+2s, -92, -9.2, -9.2)(now+3s, -73, -7.3, -7.3) -#system sh/exec.sh -n dnode1 -s stop -x SIGINT -#system sh/exec.sh -n dnode2 -s stop -x SIGINT -#system sh/exec.sh -n dnode3 -s stop -x SIGINT -#system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 5000 + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/tsim/sync/vnodesnapshot2.sim b/tests/script/tsim/sync/vnodesnapshot2.sim new file mode 100644 index 0000000000..c5df5644b1 --- /dev/null +++ b/tests/script/tsim/sync/vnodesnapshot2.sim @@ -0,0 +1,40 @@ +system sh/stop_dnodes.sh + + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + + + +sleep 5000 + + +sql use db + + + + +$N = 100 +$count = 0 +while $count < $N + $ms = 1591201000000 + $count + sql insert into ct1 values( $ms , $count , 2.1, 3.1) + $count = $count + 1 +endw + + + + + + + +sleep 5000 + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + + + diff --git a/tests/script/tsim/valgrind/basic1.sim b/tests/script/tsim/valgrind/basic1.sim index 7d8991c095..2c5b8a5d96 100644 --- a/tests/script/tsim/valgrind/basic1.sim +++ b/tests/script/tsim/valgrind/basic1.sim @@ -10,16 +10,19 @@ step1: $x = $x + 1 sleep 1000 if $x == 10 then - print ----> dnode not ready! + print ---> dnode not ready! return -1 endi sql show dnodes -print ----> $data00 $data01 $data02 $data03 $data04 $data05 +print ---> $data00 $data01 $data02 $data03 $data04 $data05 if $rows != 1 then return -1 endi +if $data(1)[4] != ready then + goto step1 +endi -print =============== step2: create show database +print =============== step2: create db sql create database d1 vgroups 1 buffer 3 sql show databases sql use d1 @@ -32,7 +35,7 @@ if $rows != 1 then return -1 endi -print =============== step4: create show table +print =============== step3: create show table sql create table ct1 using stb tags(1000) sql show tables if $rows != 1 then @@ -40,8 +43,28 @@ if $rows != 1 then endi print =============== step5: insert data +sql insert into ct1 values(now+0s, 10, 2.0, 3.0) +sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) print =============== step6: select data +#sql select * from ct1 +#sql select * from stb _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT + +print =============== check +print ----> start to check if there are ERRORS in vagrind log file for each dnode +system_content sh/checkValgrind.sh -n dnode1 + +print cmd return result ----> [ $system_content ] +if $system_content <= 0 then + return 0 +endi + +$null= +if $system_content == $null then + return 0 +endi + +return -1 diff --git a/tests/script/tsim/valgrind/basic2.sim b/tests/script/tsim/valgrind/basic2.sim index 1a76d8ce5c..eb61f85444 100644 --- a/tests/script/tsim/valgrind/basic2.sim +++ b/tests/script/tsim/valgrind/basic2.sim @@ -4,7 +4,7 @@ system sh/cfg.sh -n dnode1 -c debugflag -v 131 system sh/exec.sh -n dnode1 -s start -v sql connect -print =============== step1: show dnodes +print =============== step1: create drop show dnodes $x = 0 step1: $x = $x + 1 @@ -22,75 +22,35 @@ if $data(1)[4] != ready then goto step1 endi -print =============== step2: create alter drop show user -sql create user u1 pass 'taosdata' -sql show users -sql alter user u1 sysinfo 1 -sql alter user u1 enable 1 -sql alter user u1 pass 'taosdata' -sql drop user u1 -sql_error alter user u2 sysinfo 0 - -print =============== step3: create drop dnode -sql create dnode $hostname port 7200 -sql drop dnode 2 -sql alter dnode 1 'debugflag 131' - -print =============== step4: - -print =============== run show xxxx -sql show dnodes -if $rows != 1 then - return -1 -endi - -sql show mnodes -if $rows != 1 then - return -1 -endi - +print =============== step2: create db +sql create database d1 vgroups 1 buffer 3 sql show databases -if $rows != 2 then - return -1 -endi +sql use d1 +sql show vgroups -sql show users +print =============== step3: create show stable +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned) +sql show stables if $rows != 1 then return -1 endi -print =============== run select * from information_schema.xxxx -sql select * from information_schema.`dnodes` -if $rows != 1 then - return -1 -endi +print =============== step3: create show table +sql create table ct1 using stb tags(1000) +#sql show tables +#if $rows != 1 then +# return -1 +#endi -sql select * from information_schema.`mnodes` -if $rows != 1 then - return -1 -endi +print =============== step5: insert data +sql insert into ct1 values(now+0s, 10, 2.0, 3.0) +sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3) -sql select * from information_schema.user_users -if $rows != 1 then - return -1 -endi +print =============== step6: select data +sql select * from ct1 +#sql select * from stb -sql show variables; -if $rows != 4 then - return -1 -endi - -sql show dnode 1 variables; -if $rows <= 0 then - return -1 -endi - -sql show local variables; -if $rows <= 0 then - return -1 -endi - -print =============== stop +_OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT print =============== check diff --git a/tests/script/tsim/valgrind/basic3.sim b/tests/script/tsim/valgrind/basic3.sim new file mode 100644 index 0000000000..7fba66c468 --- /dev/null +++ b/tests/script/tsim/valgrind/basic3.sim @@ -0,0 +1,152 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/exec.sh -n dnode1 -s start -v +system sh/exec.sh -n dnode2 -s start -v +sql connect + +print =============== add dnode2 into cluster +sql create dnode $hostname port 7200 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ---> dnode not ready! + return -1 + endi +sql show dnodes +print ---> $data00 $data01 $data02 $data03 $data04 $data05 +print ---> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi + +print =============== create database, stable, table +sql create database db vgroups 3 +sql use db +sql create table stb (ts timestamp, c int) tags (t int) +sql create table t0 using stb tags (0) +sql create table tba (ts timestamp, c1 binary(10), c2 nchar(10)); + +print =============== run show xxxx +sql show dnodes +if $rows != 2 then + return -1 +endi + +sql show mnodes +if $rows != 1 then + return -1 +endi + +sql show databases +if $rows != 3 then + return -1 +endi + +sql show stables +if $rows != 1 then + return -1 +endi + +sql show tables +if $rows != 2 then + return -1 +endi + +sql show users +if $rows != 1 then + return -1 +endi + +sql show vgroups +if $rows != 3 then + return -1 +endi + +print =============== run select * from information_schema.xxxx +sql select * from information_schema.`dnodes` +if $rows != 2 then + return -1 +endi + +sql select * from information_schema.`mnodes` +if $rows != 1 then + return -1 +endi + +sql select * from information_schema.user_databases +if $rows != 3 then + return -1 +endi + +sql select * from information_schema.user_stables +if $rows != 1 then + return -1 +endi + +sql select * from information_schema.user_tables +if $rows != 31 then + return -1 +endi + +sql select * from information_schema.user_users +if $rows != 1 then + return -1 +endi + +sql select * from information_schema.`vgroups` +if $rows != 3 then + return -1 +endi + +sql show variables; +if $rows != 4 then + return -1 +endi + +sql show dnode 1 variables; +if $rows <= 0 then + return -1 +endi + +sql show local variables; +if $rows <= 0 then + return -1 +endi + +print ==== stop dnode1 and dnode2, and restart dnodes +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT + +print =============== check dnode1 +system_content sh/checkValgrind.sh -n dnode1 +print cmd return result ----> [ $system_content ] +if $system_content <= 0 then + return 0 +endi + +$null= +if $system_content == $null then + return 0 +endi + +print =============== check dnode2 +system_content sh/checkValgrind.sh -n dnode2 +print cmd return result ----> [ $system_content ] +if $system_content <= 0 then + return 0 +endi + +$null= +if $system_content == $null then + return 0 +endi diff --git a/tests/script/tsim/valgrind/checkError1.sim b/tests/script/tsim/valgrind/checkError1.sim index 62653bbdd3..1a76d8ce5c 100644 --- a/tests/script/tsim/valgrind/checkError1.sim +++ b/tests/script/tsim/valgrind/checkError1.sim @@ -36,6 +36,60 @@ sql create dnode $hostname port 7200 sql drop dnode 2 sql alter dnode 1 'debugflag 131' +print =============== step4: + +print =============== run show xxxx +sql show dnodes +if $rows != 1 then + return -1 +endi + +sql show mnodes +if $rows != 1 then + return -1 +endi + +sql show databases +if $rows != 2 then + return -1 +endi + +sql show users +if $rows != 1 then + return -1 +endi + +print =============== run select * from information_schema.xxxx +sql select * from information_schema.`dnodes` +if $rows != 1 then + return -1 +endi + +sql select * from information_schema.`mnodes` +if $rows != 1 then + return -1 +endi + +sql select * from information_schema.user_users +if $rows != 1 then + return -1 +endi + +sql show variables; +if $rows != 4 then + return -1 +endi + +sql show dnode 1 variables; +if $rows <= 0 then + return -1 +endi + +sql show local variables; +if $rows <= 0 then + return -1 +endi + print =============== stop system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/checkError3.sim b/tests/script/tsim/valgrind/checkError3.sim index 6bf82b4ef4..5a60dfe254 100644 --- a/tests/script/tsim/valgrind/checkError3.sim +++ b/tests/script/tsim/valgrind/checkError3.sim @@ -1,13 +1,10 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c debugflag -v 131 system sh/exec.sh -n dnode1 -s start -v -system sh/exec.sh -n dnode2 -s start -v sql connect -print =============== add dnode2 into cluster -sql create dnode $hostname port 7200 - +print =============== step1: show dnodes $x = 0 step1: $x = $x + 1 @@ -18,16 +15,26 @@ step1: endi sql show dnodes print ---> $data00 $data01 $data02 $data03 $data04 $data05 -print ---> $data10 $data11 $data12 $data13 $data14 $data15 -if $rows != 2 then +if $rows != 1 then return -1 endi if $data(1)[4] != ready then goto step1 endi -if $data(2)[4] != ready then - goto step1 -endi + +print =============== step2: create alter drop show user +sql create user u1 pass 'taosdata' +sql show users +sql alter user u1 sysinfo 1 +sql alter user u1 enable 1 +sql alter user u1 pass 'taosdata' +sql drop user u1 +sql_error alter user u2 sysinfo 0 + +print =============== step3: create drop dnode +sql create dnode $hostname port 7200 +sql drop dnode 2 +sql alter dnode 1 'debugflag 131' print =============== create database, stable, table sql create database db vgroups 3 @@ -38,7 +45,7 @@ sql create table tba (ts timestamp, c1 binary(10), c2 nchar(10)); print =============== run show xxxx sql show dnodes -if $rows != 2 then +if $rows != 1 then return -1 endi @@ -67,14 +74,9 @@ if $rows != 1 then return -1 endi -sql show vgroups -if $rows != 3 then - return -1 -endi - print =============== run select * from information_schema.xxxx sql select * from information_schema.`dnodes` -if $rows != 2 then +if $rows != 1 then return -1 endi @@ -123,12 +125,13 @@ if $rows <= 0 then return -1 endi -print ==== stop dnode1 and dnode2, and restart dnodes +print =============== stop system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode2 -s stop -x SIGINT -print =============== check dnode1 +print =============== check +print ----> start to check if there are ERRORS in vagrind log file for each dnode system_content sh/checkValgrind.sh -n dnode1 + print cmd return result ----> [ $system_content ] if $system_content <= 0 then return 0 @@ -140,17 +143,3 @@ if $system_content == $null then endi return -1 - -print =============== check dnode2 -system_content sh/checkValgrind.sh -n dnode2 -print cmd return result ----> [ $system_content ] -if $system_content <= 0 then - return 0 -endi - -$null= -if $system_content == $null then - return 0 -endi - -return -1 \ No newline at end of file diff --git a/tests/system-test/0-others/cachelast.py b/tests/system-test/0-others/cachelast.py index 7e912eda9a..b7b4148179 100644 --- a/tests/system-test/0-others/cachelast.py +++ b/tests/system-test/0-others/cachelast.py @@ -13,7 +13,7 @@ from util.dnodes import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), True) diff --git a/tests/system-test/0-others/taosShellError.py b/tests/system-test/0-others/taosShellError.py index 825ac015fb..5735e55c03 100644 --- a/tests/system-test/0-others/taosShellError.py +++ b/tests/system-test/0-others/taosShellError.py @@ -162,28 +162,28 @@ class TDTestCase: keyDict['h'] = 'abc' retCode, retVal = taos_command(buildPath, "h", keyDict['h'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal): - tdLog.info("taos -h %s test suceess"%keyDict['h']) + tdLog.info("taos -h %s test success"%keyDict['h']) else: tdLog.exit("taos -h %s fail"%keyDict['h']) keyDict['h'] = '\'abc\'' retCode, retVal = taos_command(buildPath, "h", keyDict['h'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal): - tdLog.info("taos -h %s test suceess"%keyDict['h']) + tdLog.info("taos -h %s test success"%keyDict['h']) else: tdLog.exit("taos -h %s fail"%keyDict['h']) keyDict['h'] = '3' retCode, retVal = taos_command(buildPath, "h", keyDict['h'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal): - tdLog.info("taos -h %s test suceess"%keyDict['h']) + tdLog.info("taos -h %s test success"%keyDict['h']) else: tdLog.exit("taos -h %s fail"%keyDict['h']) keyDict['h'] = '\'3\'' retCode, retVal = taos_command(buildPath, "h", keyDict['h'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal): - tdLog.info("taos -h %s test suceess"%keyDict['h']) + tdLog.info("taos -h %s test success"%keyDict['h']) else: tdLog.exit("taos -h %s fail"%keyDict['h']) @@ -193,42 +193,42 @@ class TDTestCase: keyDict['P'] = 'abc' retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Invalid port" in retVal): - tdLog.info("taos -P %s test suceess"%keyDict['P']) + tdLog.info("taos -P %s test success"%keyDict['P']) else: tdLog.exit("taos -P %s fail"%keyDict['P']) keyDict['P'] = '\'abc\'' retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Invalid port" in retVal): - tdLog.info("taos -P %s test suceess"%keyDict['P']) + tdLog.info("taos -P %s test success"%keyDict['P']) else: tdLog.exit("taos -P %s fail"%keyDict['P']) keyDict['P'] = '3' retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal): - tdLog.info("taos -P %s test suceess"%keyDict['P']) + tdLog.info("taos -P %s test success"%keyDict['P']) else: tdLog.exit("taos -P %s fail"%keyDict['P']) keyDict['P'] = '\'3\'' retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal): - tdLog.info("taos -P %s test suceess"%keyDict['P']) + tdLog.info("taos -P %s test success"%keyDict['P']) else: tdLog.exit("taos -P %s fail"%keyDict['P']) keyDict['P'] = '12ab' retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal): - tdLog.info("taos -P %s test suceess"%keyDict['P']) + tdLog.info("taos -P %s test success"%keyDict['P']) else: tdLog.exit("taos -P %s fail"%keyDict['P']) keyDict['P'] = '\'12ab\'' retCode, retVal = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], '') if (retCode == "TAOS_FAIL") and ("Unable to establish connection" in retVal): - tdLog.info("taos -P %s test suceess"%keyDict['P']) + tdLog.info("taos -P %s test success"%keyDict['P']) else: tdLog.exit("taos -P %s fail"%keyDict['P']) @@ -293,7 +293,7 @@ class TDTestCase: keyDict['p'] = 'errorPassword' retCode, retVal = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'p', keyDict['p']) if retCode == "TAOS_FAIL" and "Authentication failure" in retVal: - tdLog.info("taos -p %s test suceess"%keyDict['p']) + tdLog.info("taos -p %s test success"%keyDict['p']) else: tdLog.exit("taos -u %s -p %s"%(keyDict['u'], keyDict['p'])) diff --git a/tests/system-test/2-query/abs.py b/tests/system-test/2-query/abs.py index 90a1b8f343..5e5bb0df3c 100644 --- a/tests/system-test/2-query/abs.py +++ b/tests/system-test/2-query/abs.py @@ -12,7 +12,7 @@ import random class TDTestCase: updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143, "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143, - "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "fnDebugFlag": 143} + "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/2-query/and_or_for_byte.py b/tests/system-test/2-query/and_or_for_byte.py index 28d3e1cf43..aab9cce040 100644 --- a/tests/system-test/2-query/and_or_for_byte.py +++ b/tests/system-test/2-query/and_or_for_byte.py @@ -12,7 +12,7 @@ import random class TDTestCase: updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143, "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143, - "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "fnDebugFlag": 143} + "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") @@ -230,7 +230,7 @@ class TDTestCase: work_sql += f"cast({arg} as bigint){opera}" if not agg: - work_sql+= f" from {tbname} order by ts" + work_sql+= f" from {tbname} order by tbname ,ts" else: work_sql+= f" from {tbname} " tdSql.query(work_sql) @@ -243,7 +243,7 @@ class TDTestCase: else: origin_sql += f"cast({arg} as bigint)," if not agg: - origin_sql+= f" from {tbname} order by ts" + origin_sql+= f" from {tbname} order by tbname ,ts" else: origin_sql+= f" from {tbname} " tdSql.query(origin_sql) diff --git a/tests/system-test/2-query/arccos.py b/tests/system-test/2-query/arccos.py index edb9e25c11..e7e5ecb114 100644 --- a/tests/system-test/2-query/arccos.py +++ b/tests/system-test/2-query/arccos.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) diff --git a/tests/system-test/2-query/arcsin.py b/tests/system-test/2-query/arcsin.py index faed5ef3c4..80c89a47ab 100644 --- a/tests/system-test/2-query/arcsin.py +++ b/tests/system-test/2-query/arcsin.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) diff --git a/tests/system-test/2-query/arctan.py b/tests/system-test/2-query/arctan.py index 80d28b5ee5..db59693425 100644 --- a/tests/system-test/2-query/arctan.py +++ b/tests/system-test/2-query/arctan.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) diff --git a/tests/system-test/2-query/avg.py b/tests/system-test/2-query/avg.py index 2e30ac7ea7..607968936d 100644 --- a/tests/system-test/2-query/avg.py +++ b/tests/system-test/2-query/avg.py @@ -10,7 +10,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), True) diff --git a/tests/system-test/2-query/ceil.py b/tests/system-test/2-query/ceil.py index b269b54a17..9816751e55 100644 --- a/tests/system-test/2-query/ceil.py +++ b/tests/system-test/2-query/ceil.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/2-query/check_tsdb.py b/tests/system-test/2-query/check_tsdb.py index 33bf351207..0ae1648d99 100644 --- a/tests/system-test/2-query/check_tsdb.py +++ b/tests/system-test/2-query/check_tsdb.py @@ -11,7 +11,7 @@ from util.dnodes import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), True) diff --git a/tests/system-test/2-query/cos.py b/tests/system-test/2-query/cos.py index 1165d8d681..e50ec6d523 100644 --- a/tests/system-test/2-query/cos.py +++ b/tests/system-test/2-query/cos.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) diff --git a/tests/system-test/2-query/distribute_agg_apercentile.py b/tests/system-test/2-query/distribute_agg_apercentile.py index 022d13c5ae..632bda6bc6 100644 --- a/tests/system-test/2-query/distribute_agg_apercentile.py +++ b/tests/system-test/2-query/distribute_agg_apercentile.py @@ -8,7 +8,7 @@ import random class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): diff --git a/tests/system-test/2-query/distribute_agg_avg.py b/tests/system-test/2-query/distribute_agg_avg.py index c690a17b4a..d23a597e92 100644 --- a/tests/system-test/2-query/distribute_agg_avg.py +++ b/tests/system-test/2-query/distribute_agg_avg.py @@ -9,7 +9,7 @@ import platform class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): diff --git a/tests/system-test/2-query/distribute_agg_count.py b/tests/system-test/2-query/distribute_agg_count.py index b3638dac4b..ebca81545c 100644 --- a/tests/system-test/2-query/distribute_agg_count.py +++ b/tests/system-test/2-query/distribute_agg_count.py @@ -8,7 +8,7 @@ import random class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): diff --git a/tests/system-test/2-query/distribute_agg_max.py b/tests/system-test/2-query/distribute_agg_max.py index 0924ea16ac..c7e074095b 100644 --- a/tests/system-test/2-query/distribute_agg_max.py +++ b/tests/system-test/2-query/distribute_agg_max.py @@ -8,7 +8,7 @@ import random class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): diff --git a/tests/system-test/2-query/distribute_agg_min.py b/tests/system-test/2-query/distribute_agg_min.py index 8d077fd59b..d8f93a01f5 100644 --- a/tests/system-test/2-query/distribute_agg_min.py +++ b/tests/system-test/2-query/distribute_agg_min.py @@ -8,7 +8,7 @@ import random class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): diff --git a/tests/system-test/2-query/distribute_agg_spread.py b/tests/system-test/2-query/distribute_agg_spread.py index c91fd1d30b..8d611007f3 100644 --- a/tests/system-test/2-query/distribute_agg_spread.py +++ b/tests/system-test/2-query/distribute_agg_spread.py @@ -8,7 +8,7 @@ import random class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): diff --git a/tests/system-test/2-query/distribute_agg_stddev.py b/tests/system-test/2-query/distribute_agg_stddev.py index 09a6b86d34..22c7c598b4 100644 --- a/tests/system-test/2-query/distribute_agg_stddev.py +++ b/tests/system-test/2-query/distribute_agg_stddev.py @@ -9,7 +9,7 @@ import math class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): diff --git a/tests/system-test/2-query/distribute_agg_sum.py b/tests/system-test/2-query/distribute_agg_sum.py index 8dcd902b3d..d4e9dfb1fb 100644 --- a/tests/system-test/2-query/distribute_agg_sum.py +++ b/tests/system-test/2-query/distribute_agg_sum.py @@ -9,7 +9,7 @@ import platform class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): diff --git a/tests/system-test/2-query/floor.py b/tests/system-test/2-query/floor.py index 7362191958..7f5c7f5591 100644 --- a/tests/system-test/2-query/floor.py +++ b/tests/system-test/2-query/floor.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/2-query/function_null.py b/tests/system-test/2-query/function_null.py index 545872b39d..c1c6dd421a 100644 --- a/tests/system-test/2-query/function_null.py +++ b/tests/system-test/2-query/function_null.py @@ -12,7 +12,7 @@ import random class TDTestCase: updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143, "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143, - "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "fnDebugFlag": 143} + "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/2-query/function_stateduration.py b/tests/system-test/2-query/function_stateduration.py index bdbd92acd6..a716d67236 100644 --- a/tests/system-test/2-query/function_stateduration.py +++ b/tests/system-test/2-query/function_stateduration.py @@ -13,7 +13,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/2-query/irate.py b/tests/system-test/2-query/irate.py index d0573a6bf4..e40920c06c 100644 --- a/tests/system-test/2-query/irate.py +++ b/tests/system-test/2-query/irate.py @@ -12,7 +12,7 @@ import random class TDTestCase: updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143, "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143, - "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "fnDebugFlag": 143} + "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/2-query/log.py b/tests/system-test/2-query/log.py index f9d6e91199..f08a4b20de 100644 --- a/tests/system-test/2-query/log.py +++ b/tests/system-test/2-query/log.py @@ -12,7 +12,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) diff --git a/tests/system-test/2-query/max.py b/tests/system-test/2-query/max.py index 3cd023648e..0ca3f8f71a 100644 --- a/tests/system-test/2-query/max.py +++ b/tests/system-test/2-query/max.py @@ -7,7 +7,7 @@ import numpy as np class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) diff --git a/tests/system-test/2-query/nestedQuery.py b/tests/system-test/2-query/nestedQuery.py index 871054de3a..9f2b8c4b56 100755 --- a/tests/system-test/2-query/nestedQuery.py +++ b/tests/system-test/2-query/nestedQuery.py @@ -25,7 +25,7 @@ from util.dnodes import * class TDTestCase: updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) diff --git a/tests/system-test/2-query/nestedQuery_str.py b/tests/system-test/2-query/nestedQuery_str.py index 8214c98c5c..6244b37ba4 100755 --- a/tests/system-test/2-query/nestedQuery_str.py +++ b/tests/system-test/2-query/nestedQuery_str.py @@ -26,7 +26,7 @@ from util.dnodes import * class TDTestCase: updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) diff --git a/tests/system-test/2-query/pow.py b/tests/system-test/2-query/pow.py index c67162961b..1af8bd3839 100644 --- a/tests/system-test/2-query/pow.py +++ b/tests/system-test/2-query/pow.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) diff --git a/tests/system-test/2-query/round.py b/tests/system-test/2-query/round.py index cc272abf42..9111586472 100644 --- a/tests/system-test/2-query/round.py +++ b/tests/system-test/2-query/round.py @@ -10,7 +10,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/2-query/sin.py b/tests/system-test/2-query/sin.py index 2c4d90d3e7..7cb559c510 100644 --- a/tests/system-test/2-query/sin.py +++ b/tests/system-test/2-query/sin.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) diff --git a/tests/system-test/2-query/sqrt.py b/tests/system-test/2-query/sqrt.py index 772056fd93..e21f5b397e 100644 --- a/tests/system-test/2-query/sqrt.py +++ b/tests/system-test/2-query/sqrt.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) diff --git a/tests/system-test/2-query/statecount.py b/tests/system-test/2-query/statecount.py index ed97521c51..162a5a61fe 100644 --- a/tests/system-test/2-query/statecount.py +++ b/tests/system-test/2-query/statecount.py @@ -13,7 +13,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/2-query/tail.py b/tests/system-test/2-query/tail.py index 1cf63e082e..d708873d6f 100644 --- a/tests/system-test/2-query/tail.py +++ b/tests/system-test/2-query/tail.py @@ -12,7 +12,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/2-query/tan.py b/tests/system-test/2-query/tan.py index 9610ffef24..da47c1c2b2 100644 --- a/tests/system-test/2-query/tan.py +++ b/tests/system-test/2-query/tan.py @@ -11,7 +11,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) diff --git a/tests/system-test/2-query/twa.py b/tests/system-test/2-query/twa.py index 9f0e189a5f..dde903af00 100644 --- a/tests/system-test/2-query/twa.py +++ b/tests/system-test/2-query/twa.py @@ -9,7 +9,7 @@ import math class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): diff --git a/tests/system-test/2-query/unique.py b/tests/system-test/2-query/unique.py index 456922ea21..4467dcb471 100644 --- a/tests/system-test/2-query/unique.py +++ b/tests/system-test/2-query/unique.py @@ -13,7 +13,7 @@ from util.cases import * class TDTestCase: updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py index bd8531d7c8..d22d183e86 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py @@ -64,8 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase1(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py index 1d2aaccda5..951a747069 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py @@ -64,8 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase1(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py index 2720b7cdce..6ee089af4e 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py @@ -64,9 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - # tdDnodes.start(1) - tdDnodes.starttaosd(1) + # tdDnodes.stop(1) + # tdDnodes.starttaosd(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase1(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py index 0b2dddd24a..882989bfb6 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py @@ -64,9 +64,10 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - # tdDnodes.start(1) - tdDnodes.starttaosd(1) + # tdDnodes.stop(1) + # # tdDnodes.start(1) + # tdDnodes.starttaosd(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase1(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py index a4d6648276..c334ff752b 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py @@ -64,9 +64,10 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - # tdDnodes.start(1) - tdDnodes.starttaosd(1) + # tdDnodes.stop(1) + # # tdDnodes.start(1) + # tdDnodes.starttaosd(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase1(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb.py b/tests/system-test/7-tmq/tmqConsFromTsdb.py index c18474dcc3..a4a242365a 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb.py @@ -64,8 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase1(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py index 540c9dbbe1..ec11b3286c 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py @@ -64,8 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase3(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py index 5cb373092b..4878652593 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py @@ -64,8 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase3(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py index eaef134845..451dc43343 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py @@ -64,8 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase3(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py index c1b327e5f1..3b3467f9f9 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py @@ -64,8 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase3(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py index dd8a0ad33a..d1fe69f0b7 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py @@ -64,8 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase3(self): diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1.py b/tests/system-test/7-tmq/tmqConsFromTsdb1.py index a183eda1c7..597f7968ae 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1.py @@ -64,8 +64,9 @@ class TDTestCase: startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) tdLog.info("restart taosd to ensure that the data falls into the disk") - tdDnodes.stop(1) - tdDnodes.start(1) + # tdDnodes.stop(1) + # tdDnodes.start(1) + tdSql.query("flush database %s"%(paraDict['dbName'])) return def tmqCase3(self): diff --git a/tests/system-test/failed.txt b/tests/system-test/failed.txt index d0b66b1769..59c4d625d9 100644 --- a/tests/system-test/failed.txt +++ b/tests/system-test/failed.txt @@ -1 +1,2 @@ #python3 ./test.py -f 2-query/last.py -Q 3 +#./test.sh -f tsim/mnode/basic4.sim diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 0aa9e395db..9f165d6404 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -117,7 +117,7 @@ python3 ./test.py -f 2-query/distribute_agg_avg.py python3 ./test.py -f 2-query/distribute_agg_stddev.py python3 ./test.py -f 2-query/twa.py python3 ./test.py -f 2-query/irate.py -#python3 ./test.py -f 2-query/and_or_for_byte.py +python3 ./test.py -f 2-query/and_or_for_byte.py python3 ./test.py -f 2-query/function_null.py python3 ./test.py -f 2-query/queryQnode.py diff --git a/tests/test/c/sdbDump.c b/tests/test/c/sdbDump.c index a62c30660d..42f1bb4062 100644 --- a/tests/test/c/sdbDump.c +++ b/tests/test/c/sdbDump.c @@ -24,6 +24,7 @@ #define TMP_MNODE_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" #define TMP_SDB_DATA_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "data" #define TMP_SDB_SYNC_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "sync" +#define TMP_SDB_MNODE_JSON TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "mnode.json" #define TMP_SDB_DATA_FILE TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "data" TD_DIRSEP "sdb.data" #define TMP_SDB_RAFT_CFG_FILE TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "sync" TD_DIRSEP "raft_config.json" #define TMP_SDB_RAFT_STORE_FILE TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "sync" TD_DIRSEP "raft_store.json" @@ -412,9 +413,11 @@ int32_t parseArgs(int32_t argc, char *argv[]) { return -1; } + char mnodeJson[PATH_MAX] = {0}; char dataFile[PATH_MAX] = {0}; char raftCfgFile[PATH_MAX] = {0}; char raftStoreFile[PATH_MAX] = {0}; + snprintf(mnodeJson, PATH_MAX, "%s" TD_DIRSEP "mnode" TD_DIRSEP "mnode.json", tsDataDir); snprintf(dataFile, PATH_MAX, "%s" TD_DIRSEP "mnode" TD_DIRSEP "data" TD_DIRSEP "sdb.data", tsDataDir); snprintf(raftCfgFile, PATH_MAX, "%s" TD_DIRSEP "mnode" TD_DIRSEP "sync" TD_DIRSEP "raft_config.json", tsDataDir); snprintf(raftStoreFile, PATH_MAX, "%s" TD_DIRSEP "mnode" TD_DIRSEP "sync" TD_DIRSEP "raft_store.json", tsDataDir); @@ -425,6 +428,8 @@ int32_t parseArgs(int32_t argc, char *argv[]) { #ifdef WINDOWS taosMulMkDir(TMP_SDB_DATA_DIR); taosMulMkDir(TMP_SDB_SYNC_DIR); + snprintf(cmd, sizeof(cmd), "cp %s %s 2>nul", mnodeJson, TMP_SDB_MNODE_JSON); + system(cmd); snprintf(cmd, sizeof(cmd), "cp %s %s 2>nul", dataFile, TMP_SDB_DATA_FILE); system(cmd); snprintf(cmd, sizeof(cmd), "cp %s %s 2>nul", raftCfgFile, TMP_SDB_RAFT_CFG_FILE); @@ -436,6 +441,8 @@ int32_t parseArgs(int32_t argc, char *argv[]) { system(cmd); snprintf(cmd, sizeof(cmd), "mkdir -p %s", TMP_SDB_SYNC_DIR); system(cmd); + snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", mnodeJson, TMP_SDB_MNODE_JSON); + system(cmd); snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", dataFile, TMP_SDB_DATA_FILE); system(cmd); snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", raftCfgFile, TMP_SDB_RAFT_CFG_FILE); diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index da1afe84a7..59908cca8a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,3 +1,27 @@ +IF (TD_WEBSOCKET) + MESSAGE("${Green} use libtaos-ws${ColourReset}") + IF (TD_LINUX) + include(ExternalProject) + ExternalProject_Add(taosws-rs + PREFIX "taosws-rs" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs + BUILD_ALWAYS off + DEPENDS taos + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" + PATCH_COMMAND + COMMAND git clean -f -d + BUILD_COMMAND + COMMAND cargo build --release -p taos-ws-sys + COMMAND ./taos-ws-sys/ci/package.sh + INSTALL_COMMAND + COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib + COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include + COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include + ) + ENDIF() +ENDIF () + IF (TD_TAOS_TOOLS) INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/tools/taos_tools/deps/avro/lang/c/src) INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/client) diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 295fae68b3..2dc5870c4a 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -1,10 +1,19 @@ aux_source_directory(src SHELL_SRC) add_executable(shell ${SHELL_SRC}) + +IF (TD_LINUX AND TD_WEBSOCKET) + ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include -ltaosws) + SET(LINK_WEBSOCKET "-L${CMAKE_BINARY_DIR}/build/lib -ltaosws") + ADD_DEPENDENCIES(shell taosws-rs) +ELSE () + SET(LINK_WEBSOCKET "") +ENDIF () + if(TD_WINDOWS) - target_link_libraries(shell PUBLIC taos_static) + target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET}) else() - target_link_libraries(shell PUBLIC taos) + target_link_libraries(shell PUBLIC taos ${LINK_WEBSOCKET}) endif () target_link_libraries( shell diff --git a/tools/taos-tools b/tools/taos-tools index c9308b0481..9cb71e3c4c 160000 --- a/tools/taos-tools +++ b/tools/taos-tools @@ -1 +1 @@ -Subproject commit c9308b04810faa653548db5f07c753a9d00990eb +Subproject commit 9cb71e3c4c0474553aa961cbe19795541c29b5c7 diff --git a/tools/taosadapter b/tools/taosadapter index 389047db71..c885e967e4 160000 --- a/tools/taosadapter +++ b/tools/taosadapter @@ -1 +1 @@ -Subproject commit 389047db713a3dddfbce292c3260b0864b17d936 +Subproject commit c885e967e490105999b84d009a15168728dfafaf diff --git a/tools/taosws-rs b/tools/taosws-rs new file mode 160000 index 0000000000..430982a0c2 --- /dev/null +++ b/tools/taosws-rs @@ -0,0 +1 @@ +Subproject commit 430982a0c2c29a819ffc414d11f49f2d424ca3fe