Merge branch '3.0' into fix/syntax
This commit is contained in:
commit
e4e701a59e
|
@ -25,7 +25,7 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name [comment 'string_value'] [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
type_name [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
|
||||
table_options:
|
||||
table_option ...
|
||||
|
|
|
@ -13,7 +13,7 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name [comment 'string_value'] [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
type_name [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
|
||||
table_options:
|
||||
table_option ...
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
title: "View"
|
||||
sidebar_label: "View"
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
Starting from TDengine 3.2.1.0, TDengine Enterprise Edition provides view function, which is convenient for users to simplify operation and improve sharing ability among users.
|
||||
|
||||
A view is essentially a query statement stored in a database. The view (non-materialized view) itself does not contain data, and only dynamically executes the query statement specified by the view when reading data from the view. We specify a name when creating a view, and then we can query it like using a regular table. The use of views should follow the following rules:
|
||||
- Views can be defined and used nested, and are bound to the specified or current database when created.
|
||||
- Within the same database, duplicate view names are not allowed, and it is recommended not to have duplicate view names and table names (not mandatory). When the view and table names have the same name, operations such as writing, querying, authorizing, and revoking permissions will prioritize using the same-named table.
|
||||
|
||||
|
||||
|
||||
## Grammar
|
||||
|
||||
### Create (update) view
|
||||
|
||||
```sql
|
||||
CREATE [ OR REPLACE ] VIEW [db_name.]view_name AS query
|
||||
```
|
||||
|
||||
Description:
|
||||
- When creating a view, you can specify the database name ( db_name ) to which the view is bound. If not explicitly specified, it defaults to the database bound to the current connection.
|
||||
- It is recommended to specify the database name in the query statement, support cross-database views, and default to the database bound to the view when not specified (it may not be the database specified by the current connection);
|
||||
|
||||
### View View
|
||||
|
||||
1. View all views under a database
|
||||
|
||||
```sql
|
||||
SHOW [db_name.]VIEWS;
|
||||
```
|
||||
|
||||
2. View the creation statement of the view
|
||||
|
||||
```sql
|
||||
SHOW CREATE VIEW [db_name.]view_name;
|
||||
```
|
||||
|
||||
3. View view column information
|
||||
|
||||
```sql
|
||||
DESCRIBE [db_name.]view_name;
|
||||
```
|
||||
|
||||
4. View all view information
|
||||
|
||||
```sql
|
||||
SELECT ... FROM information_schema.ins_views;
|
||||
```
|
||||
|
||||
### Delete a view
|
||||
|
||||
```sql
|
||||
DROP VIEW [IF EXISTS] [db_name.]view_name;
|
||||
```
|
||||
|
||||
## Permissions
|
||||
|
||||
### Description
|
||||
View permissions are divided into three types: READ, WRITE, and ALTER. Query operations require READ permissions, write operations require WRITE permissions, and delete and modify operations on the view itself require ALTER permissions.
|
||||
|
||||
### Rules
|
||||
- The creator of the view and the root user have all permissions by default.
|
||||
- Authorization and revocation of permissions for other users can be performed through the GRANT and REVOKE statements, which can only be performed by the root user.
|
||||
- View permissions need to be authorized and revoked separately. Authorization and revocation through db. * do not include view permissions.
|
||||
- Views can be defined and used nested, and the verification of view permissions is also performed by recursion.
|
||||
- In order to facilitate the sharing and use of views, the concept of view effective user (i.e. the user who creates the view) is introduced. Authorized users can use the read and write permissions of the view effective user's library, table, and nested view. Note: After the view is REPLACE, the effective user will also be updated.
|
||||
|
||||
The detailed rules for controlling relevant permissions are summarized as follows:
|
||||
|
||||
| Serial number | Operation | Permission requirements |
|
||||
| --- | --- | --- |
|
||||
| 1 | CREATE OR REPLACE VIEW (Create a new view) | The user has WRITE permission on the database to which the view belongs And Users have query permissions for the target library, table, and view of the view. If the object in the query is a view, it must meet rule 8 in the current table. |
|
||||
| 2 | CREATE OR REPLACE VIEW (Overwrite old view) | The user has WRITE permission on the database to which the view belongs, and ALTER permission on the old view And Users have query permissions for the target library, table, and view of the view. If the object in the query is a view, it must meet rule 8 in the current table. |
|
||||
| 3 | DROP VIEW | The user has ALTER permission on the view |
|
||||
| 4 | SHOW VIEWS | No |
|
||||
| 5 | SHOW CREATE VIEW | No |
|
||||
| 6 | DESCRIBE VIEW | No |
|
||||
| 7 | System table query | No |
|
||||
| 8 | SELECT FROM VIEW | The operating user has READ permissions for the view And Operating users or view effective users have READ permissions on the target library, table, and view of the view |
|
||||
| 9 | INSERT INTO VIEW | The operation user has WRITE permission on the view And Operating users or view effective users have WRITE permissions on the target library, table, and view of the view |
|
||||
| 10 | GRANT/REVOKE | Only the root user has permission |
|
||||
|
||||
|
||||
### Grammar
|
||||
|
||||
#### Authorization
|
||||
|
||||
```sql
|
||||
GRANT privileges ON [db_name.]view_name TO user_name
|
||||
privileges: {
|
||||
ALL,
|
||||
| priv_type [, priv_type] ...
|
||||
}
|
||||
priv_type: {
|
||||
READ
|
||||
| WRITE
|
||||
| ALTER
|
||||
}
|
||||
```
|
||||
|
||||
#### Recover permissions
|
||||
|
||||
```sql
|
||||
REVOKE privileges ON [db_name.]view_name FROM user_name
|
||||
privileges: {
|
||||
ALL,
|
||||
| priv_type [, priv_type] ...
|
||||
}
|
||||
priv_type: {
|
||||
READ
|
||||
| WRITE
|
||||
| ALTER
|
||||
}
|
||||
```
|
||||
|
||||
## Usage scenarios
|
||||
|
||||
| SQL query | SQL write | STMT query | STMT write | Subscribe | Stream |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| Support | Not supported yet | Not supported yet | Not supported yet | Support | Not supported yet |
|
||||
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
- Create a view
|
||||
|
||||
```sql
|
||||
CREATE VIEW view1 AS SELECT _wstart, count(*) FROM table1 INTERVAL(1d);
|
||||
CREATE VIEW view2 AS SELECT ts, col2 FROM table1;
|
||||
CREATE VIEW view3 AS SELECT * from view1;
|
||||
```
|
||||
|
||||
- Query data
|
||||
|
||||
```sql
|
||||
SELECT * from view1;
|
||||
```
|
||||
|
||||
- Delete data
|
||||
|
||||
```sql
|
||||
DROP VIEW view1;
|
||||
```
|
|
@ -91,7 +91,7 @@ toc_max_heading_level: 4
|
|||
|
||||
5. 对于小数据量场景,私有化部署太重:在物联网、车联网场景中,因为涉及到生产经营数据的安全,很多还是采取私有化部署。而每个私有化部署,处理的数据量有很大的区别,从几百台联网设备到数千万台设备不等。对于数据量小的场景,通用的大数据解决方案就显得过于臃肿,投入产出不成正比。因此有的平台提供商往往有两套方案,一套针对大数据场景,使用通用的大数据平台,一套针对小数据规模场景,就使用 MySQL 或其他数据库来搞定一切,但是随着历史数据的累积,或接入设备量的增长,关系型数据库性能不足、运维复杂、扩展性差等缺点都会逐渐暴露出来,终究不是长久之计。
|
||||
|
||||
由于存在这些根本性的缺陷,导致高速增长的时序大数据市场一直没有一个简单好用而又高效的工具。于是,近些年一批专注时序数据处理的企业杀入了这个赛道,比如美国的 InfluxData,其产品 InfluxDB 在 IT 运维监测方面有相当的市场占有率。开源社区也十分活跃,比如基于 HBase 开发的 OpenTSDB,中国国内,阿里、百度、华为都有基于 OpenTSDB 的产品,涛思数据不依赖任何第三方,推出了自主研发而且开源的的 TDengine。
|
||||
由于存在这些根本性的缺陷,导致高速增长的时序大数据市场一直没有一个简单好用而又高效的工具。于是,近些年一批专注时序数据处理的企业杀入了这个赛道,比如美国的 InfluxData,其产品 InfluxDB 在 IT 运维监测方面有相当的市场占有率。开源社区也十分活跃,比如基于 HBase 开发的 OpenTSDB,中国国内,阿里、百度、华为都有基于 OpenTSDB 的产品,涛思数据不依赖任何第三方,推出了自主研发而且开源的 TDengine。
|
||||
|
||||
由于数据量巨大且应用方式特殊,对时序数据的处理具有相当大的技术挑战,因此要使用专业的大数据平台。对实时时序数据的科学合理地高效处理能够帮助企业实时监控生产与经营过程,对历史时序数据的分析有助于对资源的使用和生产配置做出科学的决策。
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ TDengine 经过特别优化,以适应时间序列数据的独特需求,引
|
|||
|
||||
1. 写入数据:TDengine 支持多种数据写入方式。首先,它完全兼容 SQL,允许用户使用标准的 SQL 语法进行数据写入。而且 TDengine 还支持无模式(Schemaless)写入,包括流行的 InfluxDB Line 协议、OpenTSDB 的 Telnet 和 JSON 协议,这些协议的加入使得数据的导入变得更加灵活和高效。更进一步,TDengine 与众多第三方工具实现了无缝集成,例如 Telegraf、Prometheus、EMQX、StatsD、collectd 和 HiveMQ 等。在 TDengine Enterprise 中, 还提供了 MQTT、OPC-UA、OPC-DA、PI、Wonderware、Kafka、InfluxDB、OpenTSDB、MySQL、Oracle 和 SQL Server 等连接器。这些工具通过简单的配置,无需一行代码,就可以将来自各种数据源的数据源源不断的写入数据库,极大地简化了数据收集和存储的过程。
|
||||
|
||||
2. 查询数据:TDengine 提供标准的 SQL 查询语法,并针对时序数据和业务的特点优化和新增了许多语法和功能,例如降采样、插值、累计求和、时间加权平均、状态窗口、时间窗口、会话窗口、滑动窗口等。TDengine 还支持用户自定义函数(UDF)
|
||||
2. 查询数据:TDengine 提供标准的 SQL 查询语法,并针对时序数据和业务的特点优化和新增了许多语法和功能,例如降采样、插值、累计求和、时间加权平均、状态窗口、时间窗口、会话窗口、滑动窗口等。TDengine 还支持用户自定义函数(UDF)。
|
||||
|
||||
3. 缓存:TDengine 使用时间驱动缓存管理策略(First-In-First-Out,FIFO),将最近到达的(当前状态)数据保存在缓存中,这样便于获取任何监测对象的实时状态,而无需使用 Redis 等其他缓存工具,简化系统架构和运营成本。
|
||||
|
||||
4. 流式计算:TDengine 流式计算引擎提供了实时处理写入的数据流的能力,不仅支持连续查询,还支持事件驱动的流式计算。它提供了替代复杂流处理系统的轻量级解决方案,并能够在高吞吐的数据写入的情况下,提供毫秒级的计算结果延迟
|
||||
4. 流式计算:TDengine 流式计算引擎提供了实时处理写入的数据流的能力,不仅支持连续查询,还支持事件驱动的流式计算。它提供了替代复杂流处理系统的轻量级解决方案,并能够在高吞吐的数据写入的情况下,提供毫秒级的计算结果延迟。
|
||||
|
||||
5. 数据订阅:TDengine 提供了类似 Kafka 的数据订阅功能。但用户可以通过 SQL 来灵活控制订阅的数据内容,并使用 Kafka 相同的 API 来订阅一张表、一组表、全部列或部分列、甚至整个数据库的数据。TDengine 可以替代需要集成消息队列产品的场景, 从而简化系统设计的复杂度,降低运营维护成本。
|
||||
|
||||
|
@ -38,13 +38,13 @@ TDengine 经过特别优化,以适应时间序列数据的独特需求,引
|
|||
|
||||
8. 数据迁移:TDengine 提供了多种便捷的数据导入导出功能,包括脚本文件导入导出、数据文件导入导出、taosdump 工具导入导出等。
|
||||
|
||||
9. 编程连接器:TDengine 提供不同语言的连接器,包括 C/C++、Java、Go、Node.js、Rust、Python、C#、R、PHP 等。这些连接器大多都支持原生连接和 WebSocket 两种连接方式。TDengine 也提供 REST 接口,任何语言的应用程序可以直接通过 HTTP 请求访问数据库。
|
||||
9. 编程连接器:TDengine 提供不同语言的连接器,包括 C/C++、Java、Go、Node.js、Rust、Python、C#、R、PHP 等。这些连接器大多都支持原生连接和 WebSocket 两种连接方式。TDengine 也提供 RESTful 接口,任何语言的应用程序可以直接通过 HTTP 请求访问数据库。
|
||||
|
||||
10. 数据安全:TDengine 提供了丰富的用户管理和权限管理功能以控制不同用户对数据库和表的访问权限,提供了 IP 白名单功能以控制不同帐号只能从特定的服务器接入集群。TDengine 支持系统管理员对不同数据库按需加密,数据加密后对读写完全透明且对性能的影响很小。还提供了审计日志功能以记录系统中的敏感操作。
|
||||
|
||||
11. 常用工具:TDengine 还提供了交互式命令行程序(CLI),便于管理集群、检查系统状态、做即时查询。压力测试工具 taosBenchmark,用于测试 TDengine 的性能。TDengine 还提供了图形化管理界面,简化了操作和管理过程。
|
||||
|
||||
12. 零代码数据接入:TDengine 企业版提供了丰富的数据接入功能,依托强大的数据接入平台,无需一行代码,只需要做简单的配置即可实现多种数据源的数据接入,目前已经支持的数据源包括:OPC UA, OPC DA, Pi, MQTT, Kafka, InfluxDB, OpenTSDB, MySql, SQL Server, Oracle, Wonderware Historian, MongoDB。
|
||||
12. 零代码数据接入:TDengine 企业版提供了丰富的数据接入功能,依托强大的数据接入平台,无需一行代码,只需要做简单的配置即可实现多种数据源的数据接入,目前已经支持的数据源包括:OPC-UA、OPC-DA、PI、MQTT、Kafka、InfluxDB、OpenTSDB、MySQL、SQL Server、Oracle、Wonderware Historian、MongoDB。
|
||||
|
||||
## TDengine 与典型时序数据库的区别
|
||||
|
||||
|
@ -58,16 +58,14 @@ TDengine 经过特别优化,以适应时间序列数据的独特需求,引
|
|||
|
||||
4. 强大的分析能力:TDengine 不仅支持标准 SQL 查询,还为时序数据特有的分析提供了 SQL 扩展。通过超级表、存储计算分离、分区分片、预计算、UDF 等先进技术,TDengine 展现出强大的数据分析能力。
|
||||
|
||||
5. 简单易用:TDengine 安装无依赖,集群部署仅需几秒即可完成。它提供了 REST ful接口和多种编程语言的连接器,与众多第三方工具无缝集成。此外,命令行程序和丰富的运维工具也极大地方便了用户的管理和即时查询需求。
|
||||
5. 简单易用:TDengine 安装无依赖,集群部署仅需几秒即可完成。它提供了 RESTful 接口和多种编程语言的连接器,与众多第三方工具无缝集成。此外,命令行程序和丰富的运维工具也极大地方便了用户的管理和即时查询需求。
|
||||
|
||||
6. 核心开源:TDengine 的核心代码,包括集群功能,均在开源协议下公开发布。它在GitHub 网站全球趋势排行榜上多次位居榜首,显示出其受欢迎程度。同时,TDengine
|
||||
拥有一个活跃的开发者社区,为技术的持续发展和创新提供了有力支持。
|
||||
6. 核心开源:TDengine 的核心代码,包括集群功能,均在开源协议下公开发布。它在 GitHub 网站全球趋势排行榜上多次位居榜首,显示出其受欢迎程度。同时,TDengine 拥有一个活跃的开发者社区,为技术的持续发展和创新提供了有力支持。
|
||||
|
||||
采用 TDengine,企业可以在物联网、车联网、工业互联网等典型场景中显著降低大数据平台的总拥有成本,主要体现在以下几个方面:
|
||||
1. 高性能带来的成本节约:TDengine 卓越的写入、查询和存储性能意味着系统所需的计算资源和存储资源可以大幅度减少。这不仅降低了硬件成本,还减少了能源消耗和维护费用。
|
||||
2. 标准化与兼容性带来的成本效益:由于 TDengine 支持标准 SQL,并与众多第三方软件实现了无缝集成,用户可以轻松地将现有系统迁移到 TDengine 上,无须重写大量代码。这种标准化和兼容性大大降低了学习和迁移成本,缩短了项目周期。
|
||||
3. 简化系统架构带来的成本降低:作为一个极简的时序数据平台,TDengine 集成了消息队列、缓存、流计算等必要功能,避免了额外集成众多其他组件的需要。这
|
||||
种简化的系统架构显著降低了系统的复杂度,从而减少了研发和运营成本,提高了整体运营效率。
|
||||
3. 简化系统架构带来的成本降低:作为一个极简的时序数据平台,TDengine 集成了消息队列、缓存、流计算等必要功能,避免了额外集成众多其他组件的需要。这种简化的系统架构显著降低了系统的复杂度,从而减少了研发和运营成本,提高了整体运营效率。
|
||||
|
||||
## 技术生态
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ Note: 从 3.0.1.7 开始,只提供 TDengine 客户端的 Windows 客户端的
|
|||
</Tabs>
|
||||
|
||||
:::info
|
||||
下载其他组件、最新 Beta 版及之前版本的安装包,请点击[发布历史页面](../../releases/tdengine)。
|
||||
下载其他组件、最新 Beta 版及之前版本的安装包,请点击[发布历史页面](https://docs.taosdata.com/releases/tdengine/)。
|
||||
:::
|
||||
|
||||
:::note
|
||||
|
|
|
@ -4,8 +4,6 @@ title: 集群维护
|
|||
sidebar_label: 集群维护
|
||||
---
|
||||
|
||||
## 简介
|
||||
|
||||
本节介绍 TDengine Enterprise 中提供的高阶集群维护手段,能够使 TDengine 集群长期运行得更健壮和高效。
|
||||
|
||||
## 节点管理
|
||||
|
|
|
@ -4,7 +4,7 @@ sidebar_label: 双活系统
|
|||
toc_max_heading_level: 4
|
||||
---
|
||||
|
||||
## 简介
|
||||
本节介绍 TDengine 双活系统的配置和使用。
|
||||
|
||||
1. 部分用户因为部署环境的特殊性只能部署两台服务器,同时希望实现一定的服务高可用和数据高可靠。本文主要描述基于数据复制和客户端 Failover 两项关键技术的 TDengine 双活系统的产品行为,包括双活系统的架构、配置、运维等。TDengine 双活既可以用于前面所述资源受限的环境,也可用于在两套 TDengine 集群(不限资源)之间的灾备场景。双活是 TDengine Enterprise 特有功能,在 3.3.0.0 版本中第一次发布,建议使用最新版本。
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ TDengine 提供了丰富的应用程序开发接口,为了便于用户快速
|
|||
- **安装前准备**
|
||||
- 安装 Python。新近版本 taospy 包要求 Python 3.6.2+。早期版本 taospy 包要求 Python 3.7+。taos-ws-py 包要求 Python 3.7+。如果系统上还没有 Python 可参考 [Python BeginnersGuide](https://wiki.python.org/moin/BeginnersGuide/Download) 安装。
|
||||
- 安装 [pip](https://pypi.org/project/pip/)。大部分情况下 Python 的安装包都自带了 pip 工具, 如果没有请参考 [pip documentation](https://pip.pypa.io/en/stable/installation/) 安装。
|
||||
- 如果使用原生连接,还需[安装客户端驱动](../#安装客户端驱动)。客户端软件包含了 TDengine 客户端动态链接库(libtaos.so 或 taos.dll) 和 TDengine CLI。
|
||||
- 如果使用原生连接,还需[安装客户端驱动](../connect/#安装客户端驱动-taosc)。客户端软件包含了 TDengine 客户端动态链接库(libtaos.so 或 taos.dll) 和 TDengine CLI。
|
||||
|
||||
- **使用 pip 安装**
|
||||
- 卸载旧版本
|
||||
|
|
|
@ -492,7 +492,7 @@ Rust 连接器创建消费者的参数为 DSN, 可以设置的参数列表请
|
|||
3. 对于每个分配,使用 `tmq_offset_seek` 函数将消费者的偏移量设置到最早的偏移量。
|
||||
4. 如果设置偏移量失败,则打印错误信息。
|
||||
5. 释放分配信息数组以释放资源。
|
||||
6. 调用 `basic_consume_loop` 函数开始新的的消费循环,处理消息。
|
||||
6. 调用 `basic_consume_loop` 函数开始新的消费循环,处理消息。
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="REST API" value="rest">
|
||||
|
|
|
@ -143,7 +143,7 @@ charset 的有效值是 UTF-8。
|
|||
|
||||
| 参数名称 | 参数说明 |
|
||||
| :--------------: | :--------------------------------------------------------------------: |
|
||||
| dataDir | 数据文件目录,所有的数据文件都将写入该目录,缺省值:/var/lib |
|
||||
| dataDir | 数据文件目录,所有的数据文件都将写入该目录,缺省值:/var/lib/taos |
|
||||
| tempDir | 指定所有系统运行过程中的临时文件生成的目录,缺省值:/tmp |
|
||||
| minimalTmpDirGB | tempDir 所指定的临时文件目录所需要保留的最小空间,单位 GB,缺省值: 1 |
|
||||
| minimalDataDirGB | dataDir 指定的时序数据存储目录所需要保留的最小空间,单位 GB,缺省值: 2 |
|
||||
|
@ -168,7 +168,7 @@ charset 的有效值是 UTF-8。
|
|||
| minimalLogDirGB | 当日志文件夹所在磁盘可用空间大小小于该值时,停止写日志,单位GB,缺省值:1 |
|
||||
| numOfLogLines | 单个日志文件允许的最大行数,缺省值:10,000,000 |
|
||||
| asyncLog | 日志写入模式,0: 同步,1: 异步,缺省值: 1 |
|
||||
| logKeepDays | 日志文件的最长保存时间 ,单位:天,缺省值:0,意味着无限保存;当设置为大于0 的值时,日志文件会被重命名为 taosdlog.xxx,其中 xxx 为日志文件最后修改的时间戳。 |
|
||||
| logKeepDays | 日志文件的最长保存时间 ,单位:天,缺省值:0,意味着无限保存,日志文件不会被重命名,也不会有新的日志文件滚动产生,但日志文件的内容有可能会不断滚动,取决于日志文件大小的设置;当设置为大于0 的值时,当日志文件大小达到设置的上限时会被重命名为 taosdlog.xxx,其中 xxx 为日志文件最后修改的时间戳,并滚动产生新的日志文件 |
|
||||
| slowLogThreshold | 慢查询门限值,大于等于门限值认为是慢查询,单位秒,默认值: 3 |
|
||||
| slowLogScope | 定启动记录哪些类型的慢查询,可选值:ALL, QUERY, INSERT, OHTERS, NONE; 默认值:ALL |
|
||||
| debugFlag | 运行日志开关,131(输出错误和警告日志),135(输出错误、警告和调试日志),143(输出错误、警告、调试和跟踪日志); 默认值:131 或 135 (取决于不同模块) |
|
||||
|
|
|
@ -18,7 +18,7 @@ TDengine 客户端驱动提供了应用编程所需要的全部 API,并且在
|
|||
|queryPolicy | 查询语句的执行策略,1: 只使用 vnode,不使用 qnode; 2: 没有扫描算子的子任务在 qnode 执行,带扫描算子的子任务在 vnode 执行; 3: vnode 只运行扫描算子,其余算子均在 qnode 执行 ;缺省值:1 |
|
||||
|querySmaOptimize | sma index 的优化策略,0: 表示不使用 sma index,永远从原始数据进行查询; 1: 表示使用 sma index,对符合的语句,直接从预计算的结果进行查询;缺省值:0 |
|
||||
|keepColumnName | Last、First、LastRow 函数查询且未指定别名时,自动设置别名为列名(不含函数名),因此 order by 子句如果引用了该列名将自动引用该列对应的函数; 1: 表示自动设置别名为列名(不包含函数名), 0: 表示不自动设置别名; 缺省值: 0 |
|
||||
|countAlwaysReturnValue | ount/hyperloglog函数在输入数据为空或者NULL的情况下是否返回值; 0:返回空行,1:返回; 缺省值 1; 该参数设置为 1 时,如果查询中含有 INTERVAL 子句或者该查询使用了TSMA时, 且相应的组或窗口内数据为空或者NULL, 对应的组或窗口将不返回查询结果. 注意此参数客户端和服务端值应保持一致. |
|
||||
|countAlwaysReturnValue | count/hyperloglog函数在输入数据为空或者NULL的情况下是否返回值; 0:返回空行,1:返回; 缺省值 1; 该参数设置为 1 时,如果查询中含有 INTERVAL 子句或者该查询使用了TSMA时, 且相应的组或窗口内数据为空或者NULL, 对应的组或窗口将不返回查询结果. 注意此参数客户端和服务端值应保持一致. |
|
||||
|multiResultFunctionStarReturnTags | 查询超级表时,last(\*)/last_row(\*)/first(\*) 是否返回标签列;查询普通表、子表时,不受该参数影响; 0:不返回标签列,1:返回标签列 ; 缺省值: 0; 该参数设置为 0 时,last(\*)/last_row(\*)/first(\*) 只返回超级表的普通列;为 1 时,返回超级表的普通列和标签列 |
|
||||
|maxTsmaCalcDelay| 查询时客户端可允许的tsma计算延迟, 若tsma的计算延迟大于配置值, 则该TSMA将不会被使用.; 取值范围: 600s - 86400s, 即10分钟-1小时 ; 缺省值:600 秒|
|
||||
|tsmaDataDeleteMark |TSMA计算的历史数据中间结果保存时间, 单位为毫秒; 取值范围:>= 3600000, 即大于等于1h; 缺省值: 86400000, 即1d |
|
||||
|
|
|
@ -7,8 +7,6 @@ toc_max_heading_level: 4
|
|||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
## 简介
|
||||
|
||||
taosKeeper 是 TDengine 3.0 版本监控指标的导出工具,通过简单的几项配置即可获取 TDengine 的运行状态。taosKeeper 使用 TDengine RESTful 接口,所以不需要安装 TDengine 客户端即可使用。
|
||||
|
||||
## 安装
|
||||
|
|
|
@ -4,8 +4,6 @@ sidebar_label: taosdump
|
|||
toc_max_heading_level: 4
|
||||
---
|
||||
|
||||
## 简介
|
||||
|
||||
taosdump 是一个支持从运行中的 TDengine 集群备份数据并将备份的数据恢复到相同或另一个运行中的 TDengine 集群中的工具应用程序。
|
||||
|
||||
taosdump 可以用数据库、超级表或普通表作为逻辑数据单元进行备份,也可以对数据库、超级
|
||||
|
|
|
@ -4,8 +4,6 @@ sidebar_label: taosBenchmark
|
|||
toc_max_heading_level: 4
|
||||
---
|
||||
|
||||
## 简介
|
||||
|
||||
taosBenchmark (曾用名 taosdemo ) 是一个用于测试 TDengine 产品性能的工具。taosBenchmark 可以测试 TDengine 的插入、查询和订阅等功能的性能,它可以模拟由大量设备产生的大量数据,还可以灵活地控制数据库、超级表、标签列的数量和类型、数据列的数量和类型、子表的数量、每张子表的数据量、插入数据的时间间隔、taosBenchmark 的工作线程数量、是否以及如何插入乱序数据等。为了兼容过往用户的使用习惯,安装包提供 了 taosdemo 作为 taosBenchmark 的软链接。
|
||||
|
||||
## 安装
|
||||
|
|
|
@ -26,7 +26,7 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name [comment 'string_value'] [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
type_name [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
|
||||
table_options:
|
||||
table_option ...
|
||||
|
|
|
@ -13,7 +13,7 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name [comment 'string_value'] [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
type_name [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
|
||||
table_options:
|
||||
table_option ...
|
||||
|
|
|
@ -4,9 +4,7 @@ title: 标签索引
|
|||
description: 使用标签索引提升查询性能
|
||||
---
|
||||
|
||||
## 简介
|
||||
|
||||
在 TDengine 3.0.3.0 版本之前(不含),默认在第一列 TAG 上建立索引,但不支持给其它列动态添加索引。从 3.0.3.0 版本开始,可以动态地为其它 TAG 列添加索引。对于第一个 TAG 列上自动建立的索引,其在查询中默认生效,且用户无法对其进行任何干预。适当地使用索引能够有效地提升查询性能。
|
||||
本节说明 TDengine 的索引机制。在 TDengine 3.0.3.0 版本之前(不含),默认在第一列 TAG 上建立索引,但不支持给其它列动态添加索引。从 3.0.3.0 版本开始,可以动态地为其它 TAG 列添加索引。对于第一个 TAG 列上自动建立的索引,其在查询中默认生效,且用户无法对其进行任何干预。适当地使用索引能够有效地提升查询性能。
|
||||
|
||||
## 语法
|
||||
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
title: "视图"
|
||||
sidebar_label: "视图"
|
||||
---
|
||||
|
||||
从 TDengine 3.2.1.0 开始,TDengine 企业版提供视图功能,便于用户简化操作,提升用户间的分享能力。
|
||||
|
||||
视图(View)本质上是一个存储在数据库中的查询语句。视图(非物化视图)本身不包含数据,只有在从视图读取数据时才动态执行视图所指定的查询语句。我们在创建视图时指定一个名称,然后可以像使用普通表一样对其进行查询等操作。视图的使用需遵循以下规则:
|
||||
- 视图可以嵌套定义和使用,视图与创建时指定的或当前数据库绑定使用。
|
||||
- 在同一个数据库内,视图名称不允许重名,视图名跟表名也推荐不重名(不强制)。当出现视图与表名重名时,写入、查询、授权、回收权限等操作优先使用同名表。
|
||||
|
||||
|
||||
|
||||
## 语法
|
||||
|
||||
### 创建(更新)视图
|
||||
|
||||
```sql
|
||||
CREATE [ OR REPLACE ] VIEW [db_name.]view_name AS query
|
||||
```
|
||||
|
||||
说明:
|
||||
- 创建视图时可以指定视图绑定的数据库名(db_name),未明确指定时默认为当前连接绑定的数据库;
|
||||
- 查询语句(query)中推荐指定数据库名,支持跨库视图,未指定时默认为与视图绑定的数据库(有可能非当前连接指定的数据库);
|
||||
|
||||
### 查看视图
|
||||
1. 查看某个数据库下的所有视图
|
||||
```sql
|
||||
SHOW [db_name.]VIEWS;
|
||||
```
|
||||
|
||||
2. 查看视图的创建语句
|
||||
```sql
|
||||
SHOW CREATE VIEW [db_name.]view_name;
|
||||
```
|
||||
|
||||
3. 查看视图列信息
|
||||
```sql
|
||||
DESCRIBE [db_name.]view_name;
|
||||
```
|
||||
|
||||
4. 查看所有视图信息
|
||||
```sql
|
||||
SELECT ... FROM information_schema.ins_views;
|
||||
```
|
||||
|
||||
### 删除视图
|
||||
```sql
|
||||
DROP VIEW [IF EXISTS] [db_name.]view_name;
|
||||
```
|
||||
|
||||
## 权限
|
||||
|
||||
### 说明
|
||||
视图的权限分为 READ、WRITE、ALTER 三种,查询操作需要具备 READ 权限,写入操作需要具备 WRITE 权限,对视图本身的删改操作需要具备 ALTER 权限。
|
||||
|
||||
### 规则
|
||||
- 视图的创建者和 root 用户默认具备所有权限。
|
||||
- 对其他用户进行授权与回收权限可以通过 GRANT 和 REVOKE 语句进行,该操作只能由 root 用户进行。
|
||||
- 视图权限需单独授权与回收,通过db.*进行的授权与回收不含视图权限。
|
||||
- 视图可以嵌套定义与使用,同理对视图权限的校验也是递归进行的。
|
||||
- 为了方便视图的分享与使用,引入视图有效用户(即视图的创建用户)的概念,被授权用户可以使用视图有效用户的库、表及嵌套视图的读写权限。注:视图被 REPLACE 后有效用户也会被更新。
|
||||
|
||||
具体相关权限控制细则如下表所示:
|
||||
|
||||
| 序号 | 操作 | 权限要求 |
|
||||
| ---- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 1 | CREATE VIEW <br/>(创建新用户) | 用户对视图所属数据库有 WRITE 权限<br/>且<br/> 用户对视图的目标库、表、视图有查询权限,若查询中的对象是视图需满足当前表中第8条规则 |
|
||||
| 2 | CREATE OR REPLACE VIEW <br/>(覆盖旧视图) | 用户对视图所属数据库有 WRITE 权限 且 对旧有视图有 ALTER 权限 <br/>且<br/> 用户对视图的目标库、表、视图有查询权限,若查询中的对象是视图需满足当前表中第8条规则 |
|
||||
| 3 | DROP VIEW | 用户对视图有 ALTER 权限 |
|
||||
| 4 | SHOW VIEWS | 无 |
|
||||
| 5 | SHOW CREATE VIEW | 无 |
|
||||
| 6 | DESCRIBE VIEW | 无 |
|
||||
| 7 | 系统表查询 | 无 |
|
||||
| 8 | SELECT FROM VIEW | 操作用户对视图有 READ 权限 且 操作用户或视图有效用户对视图的目标库、表、视图有 READ 权限 |
|
||||
| 9 | INSERT INTO VIEW | 操作用户对视图有 WRITE 权限 且 操作用户或视图有效用户对视图的目标库、表、视图有 WRITE 权限 |
|
||||
| 10 | GRANT/REVOKE | 只有 root 用户有权限 |
|
||||
|
||||
### 语法
|
||||
|
||||
#### 授权
|
||||
|
||||
```sql
|
||||
GRANT privileges ON [db_name.]view_name TO user_name
|
||||
privileges: {
|
||||
ALL,
|
||||
| priv_type [, priv_type] ...
|
||||
}
|
||||
priv_type: {
|
||||
READ
|
||||
| WRITE
|
||||
| ALTER
|
||||
}
|
||||
```
|
||||
|
||||
#### 回收权限
|
||||
|
||||
```sql
|
||||
REVOKE privileges ON [db_name.]view_name FROM user_name
|
||||
privileges: {
|
||||
ALL,
|
||||
| priv_type [, priv_type] ...
|
||||
}
|
||||
priv_type: {
|
||||
READ
|
||||
| WRITE
|
||||
| ALTER
|
||||
}
|
||||
```
|
||||
|
||||
## 使用场景
|
||||
|
||||
| SQL 查询 | SQL 写入 | STMT 查询 | STMT 写入 | 订阅 | 流计算 |
|
||||
| -------- | -------- | --------- | --------- | ---- | -------- |
|
||||
| 支持 | 暂不支持 | 暂不支持 | 暂不支持 | 支持 | 暂不支持 |
|
||||
|
||||
|
||||
## 举例
|
||||
|
||||
- 创建视图
|
||||
|
||||
```sql
|
||||
CREATE VIEW view1 AS SELECT _wstart, count(*) FROM table1 INTERVAL(1d);
|
||||
CREATE VIEW view2 AS SELECT ts, col2 FROM table1;
|
||||
CREATE VIEW view3 AS SELECT * from view1;
|
||||
```
|
||||
- 查询数据
|
||||
|
||||
```sql
|
||||
SELECT * from view1;
|
||||
```
|
||||
- 删除视图
|
||||
|
||||
```sql
|
||||
DROP VIEW view1;
|
||||
```
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
sidebar_label: C/C++
|
||||
title: C/C++ Connector
|
||||
toc_max_heading_level: 4
|
||||
---
|
||||
|
||||
C/C++ 开发人员可以使用 TDengine 的客户端驱动,即 C/C++连接器 (以下都用 TDengine 客户端驱动表示),开发自己的应用来连接 TDengine 集群完成数据存储、查询以及其他功能。TDengine 客户端驱动的 API 类似于 MySQL 的 C API。应用程序使用时,需要包含 TDengine 头文件 _taos.h_,里面列出了提供的 API 的函数原型;应用程序还要链接到所在平台上对应的动态库。
|
||||
|
@ -783,7 +784,7 @@ TDengine 的异步 API 均采用非阻塞调用模式。应用程序可以用多
|
|||
- **返回值**:非 `NULL`:成功,返回一个 TAOS * 类型的指针,指向与 TDengine 数据库的连接句柄。`NULL`:失败,非法的输入参数。
|
||||
|
||||
- `const char *tmq_get_table_name(TAOS_RES *res)`
|
||||
- **接口说明**:从 TMQ 消费者获取的消息结果中获取所属的的表名。
|
||||
- **接口说明**:从 TMQ 消费者获取的消息结果中获取所属的表名。
|
||||
- res:[入参] 指向一个有效的 TAOS_RES 结构体指针,该结构体包含了从 TMQ 消费者轮询得到的消息。
|
||||
- **返回值**:非 `NULL`:成功,返回一个 const char * 类型的指针,指向表名字符串。`NULL`:失败,非法的输入参数。
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ TaosResult 对象可以通过循环遍历获取查询到的数据。
|
|||
- **参数说明**:
|
||||
- `topic`: 订阅的主题。
|
||||
- `vg_id`: vgroupid。
|
||||
- `offset`:需要设置的的偏移量。
|
||||
- `offset`:需要设置的偏移量。
|
||||
- **异常**:操作失败抛出 ConsumerException 异常。
|
||||
- `fn committed(&mut self, topic: &str, vg_id: i32) -> PyResult<i64>`
|
||||
- **接口说明**:获取订阅主题的vgroupid分区最后提交的偏移量。
|
||||
|
@ -489,7 +489,7 @@ TaosResult 对象可以通过循环遍历获取查询到的数据。
|
|||
- `def seek(self, partition)`
|
||||
- **接口说明**:将给定分区的偏移量设置到指定的位置。
|
||||
- **参数说明**:
|
||||
- `partition`: 需要设置的的偏移量。
|
||||
- `partition`: 需要设置的偏移量。
|
||||
- `topic`: 订阅的主题
|
||||
- `partition`: 分区
|
||||
- `offset`: 偏移量
|
||||
|
@ -497,7 +497,7 @@ TaosResult 对象可以通过循环遍历获取查询到的数据。
|
|||
- `def committed(self, partitions)`
|
||||
- **接口说明**:获取订阅主题的分区最后提交的偏移量。
|
||||
- **参数说明**:
|
||||
- `partition`: 需要设置的的偏移量。
|
||||
- `partition`: 需要设置的偏移量。
|
||||
- `topic`: 订阅的主题
|
||||
- `partition`: 分区
|
||||
- **返回值**:`partition`,分区最后提交的偏移量。
|
||||
|
@ -505,7 +505,7 @@ TaosResult 对象可以通过循环遍历获取查询到的数据。
|
|||
- `def position(self, partitions)`
|
||||
- **接口说明**:获取给定分区当前的偏移量。
|
||||
- **参数说明**:
|
||||
- `partition`: 需要设置的的偏移量。
|
||||
- `partition`: 需要设置的偏移量。
|
||||
- `topic`: 订阅的主题
|
||||
- `partition`: 分区
|
||||
- **返回值**:`partition`,分区最后提交的偏移量。
|
||||
|
|
|
@ -8,7 +8,7 @@ import Tabs from "@theme/Tabs";
|
|||
import TabItem from "@theme/TabItem";
|
||||
import RequestId from "./_request_id.mdx";
|
||||
|
||||
`@tdengine/websocket` 是 TDengine 的官方 Node.js 语言连接器。Node.js 开发人员可以通过它开发存取 TDengine 数据库的的应用软件。
|
||||
`@tdengine/websocket` 是 TDengine 的官方 Node.js 语言连接器。Node.js 开发人员可以通过它开发存取 TDengine 数据库的应用软件。
|
||||
|
||||
Node.js 连接器源码托管在 [GitHub](https://github.com/taosdata/taos-connector-node/tree/main)。
|
||||
|
||||
|
@ -194,7 +194,7 @@ WSConfig 中的配置如下:
|
|||
|
||||
### 数据集
|
||||
- `getMeta():Array<TDengineMeta> | null`
|
||||
- **接口说明**:获取查询结果的的列的数量、类型和长度。
|
||||
- **接口说明**:获取查询结果的列的数量、类型和长度。
|
||||
- **返回值**:TDengineMeta 数据对象数组。
|
||||
```js
|
||||
export interface TDengineMeta {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
sidebar_label: PHP
|
||||
title: PHP Connector
|
||||
toc_max_heading_level: 4
|
||||
---
|
||||
|
||||
`php-tdengine` 是由社区贡献的 PHP 连接器扩展,还特别支持了 Swoole 协程化。
|
||||
|
|
|
@ -3,9 +3,6 @@ sidebar_label: ODBC
|
|||
title: TDengine ODBC
|
||||
---
|
||||
|
||||
|
||||
## 简介
|
||||
|
||||
TDengine ODBC 是为 TDengine 实现的 ODBC 驱动程序,支持 Windows 系统的应用(如 [PowerBI](https://powerbi.microsoft.com/zh-cn/) 等)通过 ODBC 标准接口访问本地、远程和云服务的 TDengine 数据库。
|
||||
|
||||
TDengine ODBC 提供基于 WebSocket(推荐)和 原生连接两种方式连接 TDengine 数据库,使用时可以为 TDengine 数据源设置不同的连接方式。访问云服务时必须使用 WebSocket 连接方式。
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
title: REST API
|
||||
sidebar_label: REST API
|
||||
toc_max_heading_level: 4
|
||||
description: 详细介绍 TDengine 提供的 RESTful API.
|
||||
---
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ description: "TDengine 服务端、客户端和连接器支持的平台列表"
|
|||
| M1 | | | | | | | | ● |
|
||||
|
||||
注:1) ● 表示经过官方测试验证, ○ 表示非官方测试验证,E 表示仅企业版支持。
|
||||
2) 社区版仅支持主流操作系统的较新版本,包括 Ubuntu 18+/CentOS 7+/RetHat/Debian/CoreOS/FreeBSD/OpenSUSE/SUSE Linux/Fedora/macOS 等。如果有其他操作系统及版本的需求,请联系企业版支持。
|
||||
2) 社区版仅支持主流操作系统的较新版本,包括 Ubuntu 18+/CentOS 7+/RedHat/Debian/CoreOS/FreeBSD/OpenSUSE/SUSE Linux/Fedora/macOS 等。如果有其他操作系统及版本的需求,请联系企业版支持。
|
||||
|
||||
## TDengine 客户端和连接器支持的平台列表
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ description: TDengine 服务端的错误码列表和详细说明
|
|||
| 0x80000335 | Cluster cfg inconsistent | 配置不一致 | 检查dnode节点与mnode节点配置是否一致。检查方式:1.节点启动时,在日志中输出 2.使用show variables |
|
||||
| 0x8000033B | Cluster id not match | 节点配置数据不一致 | 检查各节点data/dnode/dnodes.json文件中的clusterid |
|
||||
| 0x80000340 | Account already exists | (仅企业版)内部错误 | 上报issue |
|
||||
| 0x80000342 | Invalid account options | (仅企业版)操作不zh | 确认操作是否正确 |
|
||||
| 0x80000342 | Invalid account options | (仅企业版)该操作不支持 | 确认操作是否正确 |
|
||||
| 0x80000344 | Invalid account | 账户不存在 | 确认账户是否正确 |
|
||||
| 0x80000350 | User already exists | Create user, 重复创建 | 确认操作是否正确 |
|
||||
| 0x80000351 | Invalid user | 用户不存在 | 确认操作是否正确 |
|
||||
|
@ -311,7 +311,7 @@ description: TDengine 服务端的错误码列表和详细说明
|
|||
| ---------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
|
||||
| 0x80000903 | Sync timeout | 场景1:发生了切主;旧主节点上已经开始协商但尚未达成一致的请求将超时。 场景2:从节点响应超时,导致协商超时。 | 检查集群状态,例如:show vgroups;查看服务端日志,以及服务端节点之间的网络状况。 |
|
||||
| 0x8000090C | Sync leader is unreachable | 场景1:选主过程中 场景2:客户端请求路由到了从节点,且重定向失败 场景3:客户端或服务端网络配置错误 | 检查集群状态、网络配置、应用程序访问状态等。查看服务端日志,以及服务端节点之间的网络状况。 |
|
||||
| 0x8000090F | Sync new config error | 成员变更新配置错误 | 预留 |
|
||||
| 0x8000090F | Sync new config error | 成员变更配置错误 | 内部错误,用户无法干预 |
|
||||
| 0x80000911 | Sync not ready to propose | 场景1:恢复未完成 | 检查集群状态,例如:show vgroups。查看服务端日志,以及服务端节点之间的网络状况。 |
|
||||
| 0x80000914 | Sync leader is restoring | 场景1:发生了切主;选主后,日志重演中 | 检查集群状态,例如:show vgroups。查看服务端日志,观察恢复进度。 |
|
||||
| 0x80000915 | Sync invalid snapshot msg | 快照复制消息错误 | 服务端内部错误 |
|
||||
|
|
|
@ -101,7 +101,7 @@ head 文件是时序数据存储文件(data 文件)的 BRIN(Block Range In
|
|||
|
||||
head 文件中存储了多个 BRIN 记录块及其索引。BRIN 记录块采用列存压缩的方式,这种方式可以大大减少空间占用,同时保持较高的查询性能。BRIN 索引结构如下图所示:
|
||||
|
||||

|
||||

|
||||
|
||||
#### data 文件
|
||||
|
||||
|
@ -121,4 +121,4 @@ data 文件是实际存储时序数据的文件。在 data 文件中,时序数
|
|||
|
||||
在少表高频的场景下,系统仅维护一个 stt 文件。该文件专门用于存储每次数据落盘后剩余的碎片数据。这样,在下一次数据落盘时,这些碎片数据可以与内存中的新数据合并,形成较大的数据块,随后一并写入 data 文件中。这种机制有效地避免了数据文件的碎片化,确保了数据存储的连续性和高效性。
|
||||
|
||||
对于多表低频的场景,建议配置多个 stt 文件。这种场景下的核心思想是,尽管单张表每次落盘的数据量可能不大,但同一超级表下的所有子表累积的数据量却相当可观。通过合并这些数据,可以生成较大的数据块,从而减少数据块的碎片化。这不仅提升了数据的写入效率,还能显著提高查询性能,因为连续的数据存储更有利于快速的数据检索和访问。
|
||||
对于多表低频的场景,建议配置多个 stt 文件。这种场景下的核心思想是,尽管单张表每次落盘的数据量可能不大,但同一超级表下的所有子表累积的数据量却相当可观。通过合并这些数据,可以生成较大的数据块,从而减少数据块的碎片化。这不仅提升了数据的写入效率,还能显著提高查询性能,因为连续的数据存储更有利于快速的数据检索和访问。
|
||||
|
|
|
@ -265,7 +265,7 @@ TDengine 在写入数据时如果有很严重的乱序写入问题,会严重
|
|||
### 26 遇到报错 “DND ERROR Version not compatible,cliver : 3000700swr wer : 3020300”
|
||||
说明客户端和服务端版本不兼容,这里cliver的版本是3.0.7.0,server版本是 3.2.3.0。目前的兼容策略是前三位一致,client 和 sever才能兼容。
|
||||
|
||||
### 27 修改database的root密码后,启动taos遇到报错 “failed to connect to server, reason: Authen tication failure”
|
||||
### 27 修改database的root密码后,启动taos遇到报错 “failed to connect to server, reason: Authentication failure”
|
||||
默认情况,启动taos服务会使用系统默认的用户名(root)和密码尝试连接taosd,在root密码修改后,启用taos连接就需要指明用户名和密码,例如: taos -h xxx.xxx.xxx.xxx -u root -p,然后输入新密码进行连接。
|
||||
|
||||
### 28 修改database的root密码后,Grafana监控插件TDinsight无数据展示
|
||||
|
|
|
@ -86,7 +86,7 @@ extern int32_t tsNumOfQnodeQueryThreads;
|
|||
extern int32_t tsNumOfQnodeFetchThreads;
|
||||
extern int32_t tsNumOfSnodeStreamThreads;
|
||||
extern int32_t tsNumOfSnodeWriteThreads;
|
||||
extern int64_t tsRpcQueueMemoryAllowed;
|
||||
extern int64_t tsQueueMemoryAllowed;
|
||||
extern int32_t tsRetentionSpeedLimitMB;
|
||||
|
||||
// sync raft
|
||||
|
|
|
@ -1547,6 +1547,8 @@ typedef struct {
|
|||
SDbCfgRsp* cfgRsp;
|
||||
STableTSMAInfoRsp* pTsmaRsp;
|
||||
int32_t dbTsmaVersion;
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int64_t dbId;
|
||||
} SDbHbRsp;
|
||||
|
||||
typedef struct {
|
||||
|
@ -2837,6 +2839,8 @@ typedef struct {
|
|||
int64_t consumerId;
|
||||
char cgroup[TSDB_CGROUP_LEN];
|
||||
char clientId[TSDB_CLIENT_ID_LEN];
|
||||
char user[TSDB_USER_LEN];
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
SArray* topicNames; // SArray<char**>
|
||||
|
||||
int8_t withTbName;
|
||||
|
@ -2870,6 +2874,8 @@ static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubsc
|
|||
tlen += taosEncodeFixedI8(buf, pReq->enableBatchMeta);
|
||||
tlen += taosEncodeFixedI32(buf, pReq->sessionTimeoutMs);
|
||||
tlen += taosEncodeFixedI32(buf, pReq->maxPollIntervalMs);
|
||||
tlen += taosEncodeString(buf, pReq->user);
|
||||
tlen += taosEncodeString(buf, pReq->fqdn);
|
||||
|
||||
return tlen;
|
||||
}
|
||||
|
@ -2904,6 +2910,8 @@ static FORCE_INLINE int32_t tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeR
|
|||
if ((char*)buf - (char*)start < len) {
|
||||
buf = taosDecodeFixedI32(buf, &pReq->sessionTimeoutMs);
|
||||
buf = taosDecodeFixedI32(buf, &pReq->maxPollIntervalMs);
|
||||
buf = taosDecodeStringTo(buf, pReq->user);
|
||||
buf = taosDecodeStringTo(buf, pReq->fqdn);
|
||||
} else {
|
||||
pReq->sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT;
|
||||
pReq->maxPollIntervalMs = DEFAULT_MAX_POLL_INTERVAL;
|
||||
|
|
|
@ -281,118 +281,125 @@
|
|||
#define TK_IROWTS 263
|
||||
#define TK_ISFILLED 264
|
||||
#define TK_CAST 265
|
||||
#define TK_NOW 266
|
||||
#define TK_TODAY 267
|
||||
#define TK_TIMEZONE 268
|
||||
#define TK_CLIENT_VERSION 269
|
||||
#define TK_SERVER_VERSION 270
|
||||
#define TK_SERVER_STATUS 271
|
||||
#define TK_CURRENT_USER 272
|
||||
#define TK_CASE 273
|
||||
#define TK_WHEN 274
|
||||
#define TK_THEN 275
|
||||
#define TK_ELSE 276
|
||||
#define TK_BETWEEN 277
|
||||
#define TK_IS 278
|
||||
#define TK_NK_LT 279
|
||||
#define TK_NK_GT 280
|
||||
#define TK_NK_LE 281
|
||||
#define TK_NK_GE 282
|
||||
#define TK_NK_NE 283
|
||||
#define TK_MATCH 284
|
||||
#define TK_NMATCH 285
|
||||
#define TK_CONTAINS 286
|
||||
#define TK_IN 287
|
||||
#define TK_JOIN 288
|
||||
#define TK_INNER 289
|
||||
#define TK_LEFT 290
|
||||
#define TK_RIGHT 291
|
||||
#define TK_OUTER 292
|
||||
#define TK_SEMI 293
|
||||
#define TK_ANTI 294
|
||||
#define TK_ASOF 295
|
||||
#define TK_WINDOW 296
|
||||
#define TK_WINDOW_OFFSET 297
|
||||
#define TK_JLIMIT 298
|
||||
#define TK_SELECT 299
|
||||
#define TK_NK_HINT 300
|
||||
#define TK_DISTINCT 301
|
||||
#define TK_WHERE 302
|
||||
#define TK_PARTITION 303
|
||||
#define TK_BY 304
|
||||
#define TK_SESSION 305
|
||||
#define TK_STATE_WINDOW 306
|
||||
#define TK_EVENT_WINDOW 307
|
||||
#define TK_COUNT_WINDOW 308
|
||||
#define TK_SLIDING 309
|
||||
#define TK_FILL 310
|
||||
#define TK_VALUE 311
|
||||
#define TK_VALUE_F 312
|
||||
#define TK_NONE 313
|
||||
#define TK_PREV 314
|
||||
#define TK_NULL_F 315
|
||||
#define TK_LINEAR 316
|
||||
#define TK_NEXT 317
|
||||
#define TK_HAVING 318
|
||||
#define TK_RANGE 319
|
||||
#define TK_EVERY 320
|
||||
#define TK_ORDER 321
|
||||
#define TK_SLIMIT 322
|
||||
#define TK_SOFFSET 323
|
||||
#define TK_LIMIT 324
|
||||
#define TK_OFFSET 325
|
||||
#define TK_ASC 326
|
||||
#define TK_NULLS 327
|
||||
#define TK_ABORT 328
|
||||
#define TK_AFTER 329
|
||||
#define TK_ATTACH 330
|
||||
#define TK_BEFORE 331
|
||||
#define TK_BEGIN 332
|
||||
#define TK_BITAND 333
|
||||
#define TK_BITNOT 334
|
||||
#define TK_BITOR 335
|
||||
#define TK_BLOCKS 336
|
||||
#define TK_CHANGE 337
|
||||
#define TK_COMMA 338
|
||||
#define TK_CONCAT 339
|
||||
#define TK_CONFLICT 340
|
||||
#define TK_COPY 341
|
||||
#define TK_DEFERRED 342
|
||||
#define TK_DELIMITERS 343
|
||||
#define TK_DETACH 344
|
||||
#define TK_DIVIDE 345
|
||||
#define TK_DOT 346
|
||||
#define TK_EACH 347
|
||||
#define TK_FAIL 348
|
||||
#define TK_FOR 349
|
||||
#define TK_GLOB 350
|
||||
#define TK_ID 351
|
||||
#define TK_IMMEDIATE 352
|
||||
#define TK_IMPORT 353
|
||||
#define TK_INITIALLY 354
|
||||
#define TK_INSTEAD 355
|
||||
#define TK_ISNULL 356
|
||||
#define TK_MODULES 357
|
||||
#define TK_NK_BITNOT 358
|
||||
#define TK_NK_SEMI 359
|
||||
#define TK_NOTNULL 360
|
||||
#define TK_OF 361
|
||||
#define TK_PLUS 362
|
||||
#define TK_PRIVILEGE 363
|
||||
#define TK_RAISE 364
|
||||
#define TK_RESTRICT 365
|
||||
#define TK_ROW 366
|
||||
#define TK_STAR 367
|
||||
#define TK_STATEMENT 368
|
||||
#define TK_STRICT 369
|
||||
#define TK_STRING 370
|
||||
#define TK_TIMES 371
|
||||
#define TK_VALUES 372
|
||||
#define TK_VARIABLE 373
|
||||
#define TK_WAL 374
|
||||
#define TK_ENCODE 375
|
||||
#define TK_COMPRESS 376
|
||||
#define TK_LEVEL 377
|
||||
#define TK_POSITION 266
|
||||
#define TK_IN 267
|
||||
#define TK_FOR 268
|
||||
#define TK_NOW 269
|
||||
#define TK_TODAY 270
|
||||
#define TK_SUBSTR 271
|
||||
#define TK_SUBSTRING 272
|
||||
#define TK_BOTH 273
|
||||
#define TK_TRAILING 274
|
||||
#define TK_LEADING 275
|
||||
#define TK_TIMEZONE 276
|
||||
#define TK_CLIENT_VERSION 277
|
||||
#define TK_SERVER_VERSION 278
|
||||
#define TK_SERVER_STATUS 279
|
||||
#define TK_CURRENT_USER 280
|
||||
#define TK_PI 281
|
||||
#define TK_CASE 282
|
||||
#define TK_WHEN 283
|
||||
#define TK_THEN 284
|
||||
#define TK_ELSE 285
|
||||
#define TK_BETWEEN 286
|
||||
#define TK_IS 287
|
||||
#define TK_NK_LT 288
|
||||
#define TK_NK_GT 289
|
||||
#define TK_NK_LE 290
|
||||
#define TK_NK_GE 291
|
||||
#define TK_NK_NE 292
|
||||
#define TK_MATCH 293
|
||||
#define TK_NMATCH 294
|
||||
#define TK_CONTAINS 295
|
||||
#define TK_JOIN 296
|
||||
#define TK_INNER 297
|
||||
#define TK_LEFT 298
|
||||
#define TK_RIGHT 299
|
||||
#define TK_OUTER 300
|
||||
#define TK_SEMI 301
|
||||
#define TK_ANTI 302
|
||||
#define TK_ASOF 303
|
||||
#define TK_WINDOW 304
|
||||
#define TK_WINDOW_OFFSET 305
|
||||
#define TK_JLIMIT 306
|
||||
#define TK_SELECT 307
|
||||
#define TK_NK_HINT 308
|
||||
#define TK_DISTINCT 309
|
||||
#define TK_WHERE 310
|
||||
#define TK_PARTITION 311
|
||||
#define TK_BY 312
|
||||
#define TK_SESSION 313
|
||||
#define TK_STATE_WINDOW 314
|
||||
#define TK_EVENT_WINDOW 315
|
||||
#define TK_COUNT_WINDOW 316
|
||||
#define TK_SLIDING 317
|
||||
#define TK_FILL 318
|
||||
#define TK_VALUE 319
|
||||
#define TK_VALUE_F 320
|
||||
#define TK_NONE 321
|
||||
#define TK_PREV 322
|
||||
#define TK_NULL_F 323
|
||||
#define TK_LINEAR 324
|
||||
#define TK_NEXT 325
|
||||
#define TK_HAVING 326
|
||||
#define TK_RANGE 327
|
||||
#define TK_EVERY 328
|
||||
#define TK_ORDER 329
|
||||
#define TK_SLIMIT 330
|
||||
#define TK_SOFFSET 331
|
||||
#define TK_LIMIT 332
|
||||
#define TK_OFFSET 333
|
||||
#define TK_ASC 334
|
||||
#define TK_NULLS 335
|
||||
#define TK_ABORT 336
|
||||
#define TK_AFTER 337
|
||||
#define TK_ATTACH 338
|
||||
#define TK_BEFORE 339
|
||||
#define TK_BEGIN 340
|
||||
#define TK_BITAND 341
|
||||
#define TK_BITNOT 342
|
||||
#define TK_BITOR 343
|
||||
#define TK_BLOCKS 344
|
||||
#define TK_CHANGE 345
|
||||
#define TK_COMMA 346
|
||||
#define TK_CONCAT 347
|
||||
#define TK_CONFLICT 348
|
||||
#define TK_COPY 349
|
||||
#define TK_DEFERRED 350
|
||||
#define TK_DELIMITERS 351
|
||||
#define TK_DETACH 352
|
||||
#define TK_DIVIDE 353
|
||||
#define TK_DOT 354
|
||||
#define TK_EACH 355
|
||||
#define TK_FAIL 356
|
||||
#define TK_GLOB 357
|
||||
#define TK_ID 358
|
||||
#define TK_IMMEDIATE 359
|
||||
#define TK_IMPORT 360
|
||||
#define TK_INITIALLY 361
|
||||
#define TK_INSTEAD 362
|
||||
#define TK_ISNULL 363
|
||||
#define TK_MODULES 364
|
||||
#define TK_NK_BITNOT 365
|
||||
#define TK_NK_SEMI 366
|
||||
#define TK_NOTNULL 367
|
||||
#define TK_OF 368
|
||||
#define TK_PLUS 369
|
||||
#define TK_PRIVILEGE 370
|
||||
#define TK_RAISE 371
|
||||
#define TK_RESTRICT 372
|
||||
#define TK_ROW 373
|
||||
#define TK_STAR 374
|
||||
#define TK_STATEMENT 375
|
||||
#define TK_STRICT 376
|
||||
#define TK_STRING 377
|
||||
#define TK_TIMES 378
|
||||
#define TK_VALUES 379
|
||||
#define TK_VARIABLE 380
|
||||
#define TK_WAL 381
|
||||
#define TK_ENCODE 382
|
||||
#define TK_COMPRESS 383
|
||||
#define TK_LEVEL 384
|
||||
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
|
|
|
@ -415,6 +415,8 @@ int32_t catalogGetTableTsmas(SCatalog* pCtg, SRequestConnInfo* pConn, const SNam
|
|||
|
||||
int32_t catalogGetTsma(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTsmaName, STableTSMAInfo** pTsma);
|
||||
|
||||
int32_t catalogAsyncUpdateDbTsmaVersion(SCatalog* pCtg, int32_t tsmaVersion, const char* dbFName, int64_t dbId);
|
||||
|
||||
/**
|
||||
* Destroy catalog and relase all resources
|
||||
*/
|
||||
|
|
|
@ -45,6 +45,7 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_TWA,
|
||||
FUNCTION_TYPE_HISTOGRAM,
|
||||
FUNCTION_TYPE_HYPERLOGLOG,
|
||||
FUNCTION_TYPE_STDVAR,
|
||||
|
||||
// nonstandard SQL function
|
||||
FUNCTION_TYPE_BOTTOM = 500,
|
||||
|
@ -77,6 +78,15 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_ASIN,
|
||||
FUNCTION_TYPE_ACOS,
|
||||
FUNCTION_TYPE_ATAN,
|
||||
FUNCTION_TYPE_PI,
|
||||
FUNCTION_TYPE_EXP,
|
||||
FUNCTION_TYPE_LN,
|
||||
FUNCTION_TYPE_MOD,
|
||||
FUNCTION_TYPE_RAND,
|
||||
FUNCTION_TYPE_SIGN,
|
||||
FUNCTION_TYPE_DEGREES,
|
||||
FUNCTION_TYPE_RADIANS,
|
||||
FUNCTION_TYPE_TRUNCATE,
|
||||
|
||||
// string function
|
||||
FUNCTION_TYPE_LENGTH = 1500,
|
||||
|
@ -89,6 +99,13 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_RTRIM,
|
||||
FUNCTION_TYPE_SUBSTR,
|
||||
FUNCTION_TYPE_MD5,
|
||||
FUNCTION_TYPE_CHAR,
|
||||
FUNCTION_TYPE_ASCII,
|
||||
FUNCTION_TYPE_POSITION,
|
||||
FUNCTION_TYPE_TRIM,
|
||||
FUNCTION_TYPE_REPLACE,
|
||||
FUNCTION_TYPE_REPEAT,
|
||||
FUNCTION_TYPE_SUBSTR_IDX,
|
||||
|
||||
// conversion function
|
||||
FUNCTION_TYPE_CAST = 2000,
|
||||
|
@ -104,6 +121,10 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_TIMETRUNCATE,
|
||||
FUNCTION_TYPE_TIMEZONE,
|
||||
FUNCTION_TYPE_TODAY,
|
||||
FUNCTION_TYPE_WEEK,
|
||||
FUNCTION_TYPE_WEEKDAY,
|
||||
FUNCTION_TYPE_WEEKOFYEAR,
|
||||
FUNCTION_TYPE_DAYOFWEEK,
|
||||
|
||||
// system function
|
||||
FUNCTION_TYPE_DATABASE = 3000,
|
||||
|
@ -162,8 +183,9 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_LAST_MERGE,
|
||||
FUNCTION_TYPE_AVG_PARTIAL,
|
||||
FUNCTION_TYPE_AVG_MERGE,
|
||||
FUNCTION_TYPE_STDDEV_PARTIAL,
|
||||
FUNCTION_TYPE_STD_PARTIAL,
|
||||
FUNCTION_TYPE_STDDEV_MERGE,
|
||||
FUNCTION_TYPE_STDVAR_MERGE,
|
||||
FUNCTION_TYPE_IRATE_PARTIAL,
|
||||
FUNCTION_TYPE_IRATE_MERGE,
|
||||
FUNCTION_TYPE_AVG_STATE,
|
||||
|
@ -174,8 +196,8 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_LAST_STATE_MERGE,
|
||||
FUNCTION_TYPE_SPREAD_STATE,
|
||||
FUNCTION_TYPE_SPREAD_STATE_MERGE,
|
||||
FUNCTION_TYPE_STDDEV_STATE,
|
||||
FUNCTION_TYPE_STDDEV_STATE_MERGE,
|
||||
FUNCTION_TYPE_STD_STATE,
|
||||
FUNCTION_TYPE_STD_STATE_MERGE,
|
||||
FUNCTION_TYPE_HYPERLOGLOG_STATE,
|
||||
FUNCTION_TYPE_HYPERLOGLOG_STATE_MERGE,
|
||||
|
||||
|
|
|
@ -170,6 +170,12 @@ typedef struct SNodeListNode {
|
|||
SNodeList* pNodeList;
|
||||
} SNodeListNode;
|
||||
|
||||
typedef enum ETrimType {
|
||||
TRIM_TYPE_LEADING = 1,
|
||||
TRIM_TYPE_TRAILING,
|
||||
TRIM_TYPE_BOTH,
|
||||
} ETrimType;
|
||||
|
||||
typedef struct SFunctionNode {
|
||||
SExprNode node; // QUERY_NODE_FUNCTION
|
||||
char functionName[TSDB_FUNC_NAME_LEN];
|
||||
|
@ -181,6 +187,7 @@ typedef struct SFunctionNode {
|
|||
int32_t pkBytes;
|
||||
bool hasOriginalFunc;
|
||||
int32_t originalFuncId;
|
||||
ETrimType trimType;
|
||||
} SFunctionNode;
|
||||
|
||||
typedef struct STableNode {
|
||||
|
|
|
@ -61,6 +61,15 @@ int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
int32_t ceilFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t floorFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t roundFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t truncFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
int32_t piFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t expFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t lnFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t modFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t signFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t degreesFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t radiansFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
/* String functions */
|
||||
int32_t lengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
@ -73,6 +82,13 @@ int32_t ltrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut
|
|||
int32_t rtrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t md5Function(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOutput);
|
||||
int32_t charFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t asciiFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t positionFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t trimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t replaceFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t repeatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t substrIdxFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
/* Conversion functions */
|
||||
int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
@ -89,6 +105,10 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t timezoneFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t weekdayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t dayofweekFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t weekFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t weekofyearFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
bool getTimePseudoFuncEnv(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv);
|
||||
|
||||
|
@ -106,7 +126,7 @@ int32_t sumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *
|
|||
int32_t minScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t maxScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t avgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t stddevScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t stdScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t percentileScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t apercentileScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
|
|
@ -877,6 +877,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x280B)
|
||||
#define TSDB_CODE_FUNC_INVALID_VALUE_RANGE TAOS_DEF_ERROR_CODE(0, 0x280C)
|
||||
#define TSDB_CODE_FUNC_SETUP_ERROR TAOS_DEF_ERROR_CODE(0, 0x280D)
|
||||
#define TSDB_CODE_FUNC_INVALID_RES_LENGTH TAOS_DEF_ERROR_CODE(0, 0x280E)
|
||||
|
||||
|
||||
//udf
|
||||
|
|
|
@ -29,7 +29,7 @@ static FORCE_INLINE TSCKSUM taosCalcChecksum(TSCKSUM csi, const uint8_t *stream,
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t taosCalcChecksumAppend(TSCKSUM csi, uint8_t *stream, uint32_t ssize) {
|
||||
if (ssize < sizeof(TSCKSUM)) return -1;
|
||||
if (ssize < sizeof(TSCKSUM)) return TSDB_CODE_INVALID_PARA;
|
||||
|
||||
*((TSCKSUM *)(stream + ssize - sizeof(TSCKSUM))) = (*crc32c)(csi, stream, (size_t)(ssize - sizeof(TSCKSUM)));
|
||||
|
||||
|
|
|
@ -269,6 +269,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
|||
TSC_ERR_JRET(catalogAsyncUpdateTSMA(pCatalog, &pTsma, rsp->dbTsmaVersion));
|
||||
}
|
||||
taosArrayClear(rsp->pTsmaRsp->pTsmas);
|
||||
} else {
|
||||
TSC_ERR_JRET(catalogAsyncUpdateDbTsmaVersion(pCatalog, rsp->dbTsmaVersion, rsp->db, rsp->dbId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,8 @@ struct tmq_t {
|
|||
int64_t refId;
|
||||
char groupId[TSDB_CGROUP_LEN];
|
||||
char clientId[TSDB_CLIENT_ID_LEN];
|
||||
char user[TSDB_USER_LEN];
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
int8_t withTbName;
|
||||
int8_t useSnapshot;
|
||||
int8_t autoCommit;
|
||||
|
@ -1265,6 +1267,10 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
pTmq->replayEnable = conf->replayEnable;
|
||||
pTmq->sourceExcluded = conf->sourceExcluded;
|
||||
pTmq->enableBatchMeta = conf->enableBatchMeta;
|
||||
tstrncpy(pTmq->user, user, TSDB_USER_LEN);
|
||||
if (taosGetFqdn(pTmq->fqdn) != 0) {
|
||||
(void)strcpy(pTmq->fqdn, "localhost");
|
||||
}
|
||||
if (conf->replayEnable) {
|
||||
pTmq->autoCommit = false;
|
||||
}
|
||||
|
@ -1332,6 +1338,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
req.consumerId = tmq->consumerId;
|
||||
tstrncpy(req.clientId, tmq->clientId, TSDB_CLIENT_ID_LEN);
|
||||
tstrncpy(req.cgroup, tmq->groupId, TSDB_CGROUP_LEN);
|
||||
tstrncpy(req.user, tmq->user, TSDB_USER_LEN);
|
||||
tstrncpy(req.fqdn, tmq->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
req.topicNames = taosArrayInit(sz, sizeof(void*));
|
||||
if (req.topicNames == NULL) {
|
||||
|
|
|
@ -35,6 +35,13 @@ TARGET_INCLUDE_DIRECTORIES(
|
|||
PRIVATE "${TD_SOURCE_DIR}/source/client/inc"
|
||||
)
|
||||
|
||||
IF(${TD_LINUX})
|
||||
add_test(
|
||||
NAME clientTest
|
||||
COMMAND clientTest
|
||||
)
|
||||
ENDIF ()
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(
|
||||
tmqTest
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/client/"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include "clientInt.h"
|
||||
#include "osSemaphore.h"
|
||||
#include "taoserror.h"
|
||||
#include "tglobal.h"
|
||||
#include "thash.h"
|
||||
|
@ -126,6 +127,9 @@ void queryCallback(void* param, void* res, int32_t code) {
|
|||
}
|
||||
(void)printf("start to fetch data\n");
|
||||
taos_fetch_raw_block_a(res, fetchCallback, param);
|
||||
taos_free_result(res);
|
||||
tsem_t *sem = (tsem_t *)param;
|
||||
tsem_post(sem);
|
||||
}
|
||||
|
||||
void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t startTs, const char* pVarchar) {
|
||||
|
@ -189,7 +193,7 @@ void* queryThread(void* arg) {
|
|||
|
||||
int64_t el = 0;
|
||||
|
||||
for (int32_t i = 0; i < 5000000; ++i) {
|
||||
for (int32_t i = 0; i < 5; ++i) {
|
||||
int64_t st = taosGetTimestampUs();
|
||||
TAOS_RES* pRes = taos_query(pConn,
|
||||
"SELECT _wstart as ts,max(usage_user) FROM benchmarkcpu.host_49 WHERE ts >= "
|
||||
|
@ -320,6 +324,13 @@ TEST(clientCase, connect_Test) {
|
|||
if (pConn == NULL) {
|
||||
(void)printf("failed to connect to server, reason:%s\n", taos_errstr(NULL));
|
||||
}
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "drop database abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
(void)printf("error in drop db, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
|
@ -412,7 +423,7 @@ TEST(clientCase, show_db_Test) {
|
|||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
(void)printf("%s\n", str);
|
||||
}
|
||||
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
|
@ -437,6 +448,7 @@ TEST(clientCase, create_db_Test) {
|
|||
if (taos_errno(pRes) != 0) {
|
||||
(void)printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
|
@ -473,6 +485,7 @@ TEST(clientCase, drop_dnode_Test) {
|
|||
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
ASSERT_EQ(numOfFields, 0);
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "drop dnode 4");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
|
@ -498,31 +511,10 @@ TEST(clientCase, use_db_test) {
|
|||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
ASSERT_EQ(numOfFields, 0);
|
||||
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
// TEST(clientCase, drop_db_test) {
|
||||
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
// assert(pConn != NULL);
|
||||
//
|
||||
// showDB(pConn);
|
||||
//
|
||||
// TAOS_RES* pRes = taos_query(pConn, "drop database abc1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("failed to drop db, reason:%s\n", taos_errstr(pRes));
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
//
|
||||
// showDB(pConn);
|
||||
//
|
||||
// pRes = taos_query(pConn, "create database abc1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("create to drop db, reason:%s\n", taos_errstr(pRes));
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
// taos_close(pConn);
|
||||
//}
|
||||
|
||||
TEST(clientCase, create_stable_Test) {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
|
@ -534,6 +526,7 @@ TEST(clientCase, create_stable_Test) {
|
|||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "use abc1");
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists abc1.st1(ts timestamp, k int) tags(a int)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
|
@ -547,18 +540,6 @@ TEST(clientCase, create_stable_Test) {
|
|||
ASSERT_EQ(numOfFields, 0);
|
||||
taos_free_result(pRes);
|
||||
|
||||
// pRes = taos_query(pConn, "create stable if not exists abc1.`123_$^)` (ts timestamp, `abc` int) tags(a int)");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes));
|
||||
// }
|
||||
//
|
||||
// pRes = taos_query(pConn, "use abc1");
|
||||
// taos_free_result(pRes);
|
||||
// pRes = taos_query(pConn, "drop stable `123_$^)`");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes));
|
||||
// }
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
|
@ -743,7 +724,8 @@ TEST(clientCase, show_table_Test) {
|
|||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
(void)taos_query(pConn, "use abc1");
|
||||
pRes = taos_query(pConn, "use abc1");
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "show tables");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
|
@ -760,38 +742,15 @@ TEST(clientCase, show_table_Test) {
|
|||
|
||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
(void)printf("%d: %s\n", ++count, str);
|
||||
if(code > 0) {
|
||||
(void)printf("%d: %s\n", ++count, str);
|
||||
}
|
||||
}
|
||||
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
// TEST(clientCase, drop_stable_Test) {
|
||||
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
// assert(pConn != nullptr);
|
||||
//
|
||||
// TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("error in creating db, reason:%s\n", taos_errstr(pRes));
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
//
|
||||
// pRes = taos_query(pConn, "use abc1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("error in using db, reason:%s\n", taos_errstr(pRes));
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
//
|
||||
// pRes = taos_query(pConn, "drop stable st1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("failed to drop stable, reason:%s\n", taos_errstr(pRes));
|
||||
// }
|
||||
//
|
||||
// taos_free_result(pRes);
|
||||
// taos_close(pConn);
|
||||
// }
|
||||
|
||||
TEST(clientCase, generated_request_id_test) {
|
||||
SHashObj* phash = taosHashInit(10000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
|
||||
|
@ -832,11 +791,6 @@ TEST(clientCase, projection_query_tables) {
|
|||
|
||||
TAOS_RES* pRes = NULL;
|
||||
|
||||
// TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||
// }
|
||||
// taos_free_result(pRes);
|
||||
pRes= taos_query(pConn, "use abc1");
|
||||
taos_free_result(pRes);
|
||||
|
||||
|
@ -846,6 +800,12 @@ TEST(clientCase, projection_query_tables) {
|
|||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table st2 (ts timestamp, v1 int) tags(t1 int)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
(void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
int64_t start = 1685959190000;
|
||||
const char* pstr =
|
||||
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh"
|
||||
|
@ -861,7 +821,7 @@ TEST(clientCase, projection_query_tables) {
|
|||
|
||||
TAOS_RES* px = taos_query(pConn, str);
|
||||
if (taos_errno(px) != 0) {
|
||||
(void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
||||
(void)printf("failed to create table tu, reason:%s\n", taos_errstr(px));
|
||||
}
|
||||
taos_free_result(px);
|
||||
}
|
||||
|
@ -869,26 +829,26 @@ TEST(clientCase, projection_query_tables) {
|
|||
for(int32_t j = 0; j < 1; ++j) {
|
||||
start += 20;
|
||||
for (int32_t i = 0; i < 1; ++i) {
|
||||
createNewTable(pConn, i, 100000, 0, pstr);
|
||||
createNewTable(pConn, i, 10000, 0, pstr);
|
||||
}
|
||||
}
|
||||
|
||||
pRes = taos_query(pConn, "select * from abc1.st2");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
(void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
pRes = taos_query(pConn, "select * from abc1.st2");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
(void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
TAOS_ROW pRow = NULL;
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
|
||||
char str[512] = {0};
|
||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
// (void)printf("%s\n", str);
|
||||
}
|
||||
char str[512] = {0};
|
||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
// (void)printf("%s\n", str);
|
||||
}
|
||||
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
|
@ -900,7 +860,9 @@ TEST(clientCase, tsbs_perf_test) {
|
|||
for (int32_t i = 0; i < numOfThreads; ++i) {
|
||||
(void)taosThreadCreate(&qid[i], NULL, queryThread, NULL);
|
||||
}
|
||||
getchar();
|
||||
for (int32_t i = 0; i < numOfThreads; ++i) {
|
||||
(void)taosThreadJoin(qid[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(clientCase, projection_query_stables) {
|
||||
|
@ -908,14 +870,6 @@ TEST(clientCase, projection_query_stables) {
|
|||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "explain select * from dbvg.st where tbname='ct1'");
|
||||
// taos_free_result(pRes);
|
||||
|
||||
// pRes = taos_query(pConn, "select * from st2");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
// taos_free_result(pRes);
|
||||
// ASSERT_TRUE(false);
|
||||
// }
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
|
@ -939,12 +893,6 @@ TEST(clientCase, projection_query_stables) {
|
|||
}
|
||||
//(void)printf("%d\n", i);
|
||||
}
|
||||
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
// if (i++ % 100000 == 0) {
|
||||
// (void)printf("%d\n", i);
|
||||
// }
|
||||
// }
|
||||
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
|
@ -971,55 +919,41 @@ TEST(clientCase, agg_query_tables) {
|
|||
pRes = taos_query(pConn, s);
|
||||
|
||||
int32_t ret = taos_errno(pRes);
|
||||
taos_free_result(pRes);
|
||||
if (ret == 0) {
|
||||
break;
|
||||
|
||||
if (ret != 0) {
|
||||
(void)printf("failed to insert into table, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
break;
|
||||
}
|
||||
|
||||
// while (1) {
|
||||
// sprintf(s, "insert into t2 values(%ld, %d)", st + i, i);
|
||||
// pRes = taos_query(pConn, s);
|
||||
// int32_t ret = taos_errno(pRes);
|
||||
//
|
||||
// taos_free_result(pRes);
|
||||
// if (ret == 0) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// pRes = taos_query(pConn, "show table distributed tup");
|
||||
// if (taos_errno(pRes) != 0) {
|
||||
// (void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
// taos_free_result(pRes);
|
||||
// ASSERT_TRUE(false);
|
||||
// }
|
||||
|
||||
printResult(pRes);
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
/*
|
||||
--- copy the following script in the shell to setup the environment ---
|
||||
// --- copy the following script in the shell to setup the environment ---
|
||||
//
|
||||
// create database test;
|
||||
// use test;
|
||||
// create table m1(ts timestamp, k int) tags(a int);
|
||||
// create table tm0 using m1 tags(1);
|
||||
// create table tm1 using m1 tags(2);
|
||||
// insert into tm0 values('2021-1-1 1:1:1.120', 1) ('2021-1-1 1:1:2.9', 2) tm1 values('2021-1-1 1:1:1.120', 11) ('2021-1-1
|
||||
// 1:1:2.99', 22);
|
||||
|
||||
create database test;
|
||||
use test;
|
||||
create table m1(ts timestamp, k int) tags(a int);
|
||||
create table tm0 using m1 tags(1);
|
||||
create table tm1 using m1 tags(2);
|
||||
insert into tm0 values('2021-1-1 1:1:1.120', 1) ('2021-1-1 1:1:2.9', 2) tm1 values('2021-1-1 1:1:1.120', 11) ('2021-1-1
|
||||
1:1:2.99', 22);
|
||||
|
||||
*/
|
||||
TEST(clientCase, async_api_test) {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
(void)taos_query(pConn, "use abc1");
|
||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
(void)printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
return;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "insert into tu(ts) values('2022-02-27 12:12:61')");
|
||||
pRes = taos_query(pConn, "insert into tu(ts) values('2022-02-27 12:12:61')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
(void)printf("failed, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
|
@ -1041,9 +975,12 @@ TEST(clientCase, async_api_test) {
|
|||
(void)printf("%s\n", str);
|
||||
(void)memset(str, 0, sizeof(str));
|
||||
}
|
||||
|
||||
taos_query_a(pConn, "select count(*) from tu", queryCallback, pConn);
|
||||
(void)getchar();
|
||||
taos_free_result(pRes);
|
||||
tsem_t sem;
|
||||
(void)tsem_init(&sem, 0, 0);
|
||||
taos_query_a(pConn, "select count(*) from tu", queryCallback, &sem);
|
||||
tsem_wait(&sem);
|
||||
tsem_destroy(&sem);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
|
@ -1055,6 +992,7 @@ TEST(clientCase, update_test) {
|
|||
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||
(void)printf("failed to create database, code:%s", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1064,6 +1002,7 @@ TEST(clientCase, update_test) {
|
|||
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||
(void)printf("failed to use db, code:%s", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
return;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
@ -1076,11 +1015,12 @@ TEST(clientCase, update_test) {
|
|||
taos_free_result(pRes);
|
||||
|
||||
char s[256] = {0};
|
||||
for (int32_t i = 0; i < 17000; ++i) {
|
||||
for (int32_t i = 0; i < 10; ++i) {
|
||||
(void)sprintf(s, "insert into tup values(now+%da, %d)", i, i);
|
||||
pRes = taos_query(pConn, s);
|
||||
taos_free_result(pRes);
|
||||
}
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
TEST(clientCase, sub_db_test) {
|
||||
|
@ -1158,10 +1098,13 @@ TEST(clientCase, sub_db_test) {
|
|||
(void)printf("precision: %d, row content: %s\n", precision, buf);
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
(void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
TEST(clientCase, tmq_commit) {
|
||||
|
@ -1550,38 +1493,125 @@ TEST(clientCase, sub_tb_mt_test) {
|
|||
}
|
||||
}
|
||||
|
||||
//static void concatStrings(SArray *list, char* buf, int size){
|
||||
// int len = 0;
|
||||
// for(int i = 0; i < taosArrayGetSize(list); i++){
|
||||
// char* db = (char*)taosArrayGet(list, i);
|
||||
// char* dot = strchr(db, '.');
|
||||
// if (dot != NULL) {
|
||||
// db = dot + 1;
|
||||
// }
|
||||
// if (i != 0){
|
||||
// strcat(buf, ",");
|
||||
// len += 1;
|
||||
// }
|
||||
// int ret = snprintf(buf + len, size - len, "%s", db);
|
||||
// if (ret < 0) {
|
||||
// (void)printf("snprintf failed, buf:%s, ret:%d", buf, ret);
|
||||
// break;
|
||||
// }
|
||||
// len += ret;
|
||||
// if (len >= size){
|
||||
// (void)printf("dbList is truncated, buf:%s, len:%d", buf, len);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//TEST(clientCase, concat_string_test) {
|
||||
// SArray* list = taosArrayInit(10, TSDB_DB_FNAME_LEN);
|
||||
// taosArrayPush(list, "1.db1");
|
||||
// taosArrayPush(list, "2.db2");
|
||||
//
|
||||
// char buf[32] = {0};
|
||||
// concatStrings(list, buf, sizeof(buf) - 1);
|
||||
//}
|
||||
TEST(clientCase, timezone_Test) {
|
||||
{
|
||||
// taos_options( TSDB_OPTION_TIMEZONE, "UTC-8");
|
||||
int code = taos_options(TSDB_OPTION_TIMEZONE, "UTC-8");
|
||||
ASSERT_TRUE(code == 0);
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "drop database if exists db1");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create database db1");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table db1.t1 (ts timestamp, v int)");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
taos_free_result(pRes);
|
||||
|
||||
char sql[256] = {0};
|
||||
(void)sprintf(sql, "insert into db1.t1 values('2023-09-16 17:00:00', 1)");
|
||||
pRes = taos_query(pConn, sql);
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "select * from db1.t1 where ts == '2023-09-16 17:00:00'");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
|
||||
char str[512] = {0};
|
||||
int rows = 0;
|
||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
rows++;
|
||||
}
|
||||
ASSERT_TRUE(rows == 1);
|
||||
|
||||
taos_free_result(pRes);
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
{
|
||||
// taos_options( TSDB_OPTION_TIMEZONE, "UTC+8");
|
||||
int code = taos_options(TSDB_OPTION_TIMEZONE, "UTC+8");
|
||||
ASSERT_TRUE(code == 0);
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "select * from db1.t1 where ts == '2023-09-16 01:00:00'");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
|
||||
int rows = 0;
|
||||
char str[512] = {0};
|
||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
rows++;
|
||||
}
|
||||
ASSERT_TRUE(rows == 1);
|
||||
|
||||
taos_free_result(pRes);
|
||||
|
||||
char sql[256] = {0};
|
||||
(void)sprintf(sql, "insert into db1.t1 values('2023-09-16 17:00:01', 1)");
|
||||
pRes = taos_query(pConn, sql);
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
taos_free_result(pRes);
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
{
|
||||
// taos_options( TSDB_OPTION_TIMEZONE, "UTC+0");
|
||||
int code = taos_options(TSDB_OPTION_TIMEZONE, "UTC+0");
|
||||
ASSERT_TRUE(code == 0);
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "select * from db1.t1 where ts == '2023-09-16 09:00:00'");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
|
||||
int rows = 0;
|
||||
char str[512] = {0};
|
||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
rows++;
|
||||
}
|
||||
ASSERT_TRUE(rows == 1);
|
||||
taos_free_result(pRes);
|
||||
|
||||
{
|
||||
TAOS_RES* pRes = taos_query(pConn, "select * from db1.t1 where ts == '2023-09-17 01:00:01'");
|
||||
ASSERT_EQ(taos_errno(pRes), TSDB_CODE_SUCCESS);
|
||||
|
||||
TAOS_ROW pRow = NULL;
|
||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||
int32_t numOfFields = taos_num_fields(pRes);
|
||||
|
||||
int rows = 0;
|
||||
char str[512] = {0};
|
||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
rows++;
|
||||
}
|
||||
ASSERT_TRUE(rows == 1);
|
||||
taos_free_result(pRes);
|
||||
}
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -9,7 +9,7 @@ extern int8_t tsS3EpNum;
|
|||
extern char tsS3Endpoint[][TSDB_FQDN_LEN];
|
||||
extern char tsS3AccessKeyId[][TSDB_FQDN_LEN];
|
||||
extern char tsS3AccessKeySecret[][TSDB_FQDN_LEN];
|
||||
extern char tsS3BucketName[][TSDB_FQDN_LEN];
|
||||
extern char tsS3BucketName[TSDB_FQDN_LEN];
|
||||
extern char tsS3AppId[][TSDB_FQDN_LEN];
|
||||
extern char tsS3Hostname[][TSDB_FQDN_LEN];
|
||||
extern int8_t tsS3Https;
|
||||
|
@ -130,13 +130,13 @@ int32_t s3CheckCfg() {
|
|||
(void)fprintf(stderr, "put object %s: success.\n\n", objectname[0]);
|
||||
|
||||
// list buckets
|
||||
(void)fprintf(stderr, "start to list bucket %s by prefix s3.\n", tsS3BucketName[i]);
|
||||
code = s3ListBucketByEp(tsS3BucketName[i], i);
|
||||
(void)fprintf(stderr, "start to list bucket %s by prefix s3.\n", tsS3BucketName);
|
||||
code = s3ListBucketByEp(tsS3BucketName, i);
|
||||
if (code != 0) {
|
||||
(void)fprintf(stderr, "listing bucket %s : failed.\n", tsS3BucketName[i]);
|
||||
(void)fprintf(stderr, "listing bucket %s : failed.\n", tsS3BucketName);
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
}
|
||||
(void)fprintf(stderr, "listing bucket %s: success.\n\n", tsS3BucketName[i]);
|
||||
(void)fprintf(stderr, "listing bucket %s: success.\n\n", tsS3BucketName);
|
||||
|
||||
// test range get
|
||||
uint8_t *pBlock = NULL;
|
||||
|
@ -974,8 +974,8 @@ int32_t s3PutObjectFromFile2ByEp(const char *file, const char *object_name, int8
|
|||
data.totalContentLength = data.totalOriginalContentLength = data.contentLength = data.originalContentLength =
|
||||
contentLength;
|
||||
|
||||
S3BucketContext bucketContext = {0,
|
||||
tsS3BucketName[epIndex],
|
||||
S3BucketContext bucketContext = {tsS3Hostname[epIndex],
|
||||
tsS3BucketName,
|
||||
protocolG,
|
||||
uriStyleG,
|
||||
tsS3AccessKeyId[epIndex],
|
||||
|
@ -1057,8 +1057,8 @@ static int32_t s3PutObjectFromFileOffsetByEp(const char *file, const char *objec
|
|||
data.totalContentLength = data.totalOriginalContentLength = data.contentLength = data.originalContentLength =
|
||||
contentLength;
|
||||
|
||||
S3BucketContext bucketContext = {0,
|
||||
tsS3BucketName[epIndex],
|
||||
S3BucketContext bucketContext = {tsS3Hostname[epIndex],
|
||||
tsS3BucketName,
|
||||
protocolG,
|
||||
uriStyleG,
|
||||
tsS3AccessKeyId[epIndex],
|
||||
|
@ -1153,8 +1153,8 @@ static void s3FreeObjectKey(void *pItem) {
|
|||
}
|
||||
|
||||
static SArray *getListByPrefixByEp(const char *prefix, int8_t epIndex) {
|
||||
S3BucketContext bucketContext = {0,
|
||||
tsS3BucketName[epIndex],
|
||||
S3BucketContext bucketContext = {tsS3Hostname[epIndex],
|
||||
tsS3BucketName,
|
||||
protocolG,
|
||||
uriStyleG,
|
||||
tsS3AccessKeyId[epIndex],
|
||||
|
@ -1221,8 +1221,8 @@ static SArray *getListByPrefix(const char *prefix) {
|
|||
static int32_t s3DeleteObjectsByEp(const char *object_name[], int nobject, int8_t epIndex) {
|
||||
int32_t code = 0;
|
||||
|
||||
S3BucketContext bucketContext = {0,
|
||||
tsS3BucketName[epIndex],
|
||||
S3BucketContext bucketContext = {tsS3Hostname[epIndex],
|
||||
tsS3BucketName,
|
||||
protocolG,
|
||||
uriStyleG,
|
||||
tsS3AccessKeyId[epIndex],
|
||||
|
@ -1297,8 +1297,8 @@ static int32_t s3GetObjectBlockByEp(const char *object_name, int64_t offset, int
|
|||
int64_t ifModifiedSince = -1, ifNotModifiedSince = -1;
|
||||
const char *ifMatch = 0, *ifNotMatch = 0;
|
||||
|
||||
S3BucketContext bucketContext = {0,
|
||||
tsS3BucketName[epIndex],
|
||||
S3BucketContext bucketContext = {tsS3Hostname[epIndex],
|
||||
tsS3BucketName,
|
||||
protocolG,
|
||||
uriStyleG,
|
||||
tsS3AccessKeyId[epIndex],
|
||||
|
@ -1370,8 +1370,8 @@ static int32_t s3GetObjectToFileByEp(const char *object_name, const char *fileNa
|
|||
int64_t ifModifiedSince = -1, ifNotModifiedSince = -1;
|
||||
const char *ifMatch = 0, *ifNotMatch = 0;
|
||||
|
||||
S3BucketContext bucketContext = {0,
|
||||
tsS3BucketName[epIndex],
|
||||
S3BucketContext bucketContext = {tsS3Hostname[epIndex],
|
||||
tsS3BucketName,
|
||||
protocolG,
|
||||
uriStyleG,
|
||||
tsS3AccessKeyId[epIndex],
|
||||
|
@ -1447,8 +1447,8 @@ static long s3SizeByEp(const char *object_name, int8_t epIndex) {
|
|||
long size = 0;
|
||||
int status = 0;
|
||||
|
||||
S3BucketContext bucketContext = {0,
|
||||
tsS3BucketName[epIndex],
|
||||
S3BucketContext bucketContext = {tsS3Hostname[epIndex],
|
||||
tsS3BucketName,
|
||||
protocolG,
|
||||
uriStyleG,
|
||||
tsS3AccessKeyId[epIndex],
|
||||
|
|
|
@ -344,7 +344,9 @@ static const SSysDbTableSchema subscriptionSchema[] = {
|
|||
{.name = "topic_name", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "consumer_id", .bytes = 32, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "consumer_id", .bytes = TSDB_CLIENT_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "fqdn", .bytes = TSDB_FQDN_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "offset", .bytes = TSDB_OFFSET_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "rows", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
};
|
||||
|
@ -480,11 +482,12 @@ static const SSysDbTableSchema connectionsSchema[] = {
|
|||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
|
||||
static const SSysDbTableSchema consumerSchema[] = {
|
||||
{.name = "consumer_id", .bytes = TSDB_CONSUMER_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "client_id", .bytes = TSDB_CLIENT_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "fqdn", .bytes = TSDB_FQDN_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "topics", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
/*{.name = "end_point", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},*/
|
||||
|
|
|
@ -299,7 +299,7 @@ char tsS3Endpoint[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<endpoint>"};
|
|||
char tsS3AccessKey[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<accesskey>"};
|
||||
char tsS3AccessKeyId[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<accesskeyid>"};
|
||||
char tsS3AccessKeySecret[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<accesskeysecrect>"};
|
||||
char tsS3BucketName[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<bucketname>"};
|
||||
char tsS3BucketName[TSDB_FQDN_LEN] = "<bucketname>";
|
||||
char tsS3AppId[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN] = {"<appid>"};
|
||||
int8_t tsS3Enabled = false;
|
||||
int8_t tsS3EnabledCfg = false;
|
||||
|
@ -404,10 +404,14 @@ int32_t taosSetS3Cfg(SConfig *pCfg) {
|
|||
}
|
||||
|
||||
TAOS_CHECK_RETURN(taosSplitS3Cfg(pCfg, "s3Endpoint", tsS3Endpoint, &num));
|
||||
if (num != tsS3EpNum) TAOS_RETURN(TSDB_CODE_INVALID_CFG);
|
||||
if (num != tsS3EpNum) {
|
||||
uError("invalid s3 ep num:%d, expected:%d, ", num, tsS3EpNum);
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_CFG);
|
||||
}
|
||||
|
||||
TAOS_CHECK_RETURN(taosSplitS3Cfg(pCfg, "s3BucketName", tsS3BucketName, &num));
|
||||
if (num != tsS3EpNum) TAOS_RETURN(TSDB_CODE_INVALID_CFG);
|
||||
SConfigItem *pItem = NULL;
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3BucketName");
|
||||
tstrncpy(tsS3BucketName, pItem->str, TSDB_FQDN_LEN);
|
||||
|
||||
for (int i = 0; i < tsS3EpNum; ++i) {
|
||||
char *proto = strstr(tsS3Endpoint[i], "https://");
|
||||
|
@ -419,9 +423,9 @@ int32_t taosSetS3Cfg(SConfig *pCfg) {
|
|||
|
||||
char *cos = strstr(tsS3Endpoint[i], "cos.");
|
||||
if (cos) {
|
||||
char *appid = strrchr(tsS3BucketName[i], '-');
|
||||
char *appid = strrchr(tsS3BucketName, '-');
|
||||
if (!appid) {
|
||||
uError("failed to locate appid in bucket:%s", tsS3BucketName[i]);
|
||||
uError("failed to locate appid in bucket:%s", tsS3BucketName);
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_CFG);
|
||||
} else {
|
||||
tstrncpy(tsS3AppId[i], appid + 1, TSDB_FQDN_LEN);
|
||||
|
@ -432,7 +436,7 @@ int32_t taosSetS3Cfg(SConfig *pCfg) {
|
|||
tsS3Https = (strstr(tsS3Endpoint[0], "https://") != NULL);
|
||||
tsS3Oss = (strstr(tsS3Endpoint[0], "aliyuncs.") != NULL);
|
||||
|
||||
if (tsS3BucketName[0][0] != '<') {
|
||||
if (tsS3BucketName[0] != '<') {
|
||||
#if defined(USE_COS) || defined(USE_S3)
|
||||
#ifdef TD_ENTERPRISE
|
||||
/*if (tsDiskCfgNum > 1) */ tsS3Enabled = true;
|
||||
|
@ -691,8 +695,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfSnodeWriteThreads = tsNumOfCores / 4;
|
||||
tsNumOfSnodeWriteThreads = TRANGE(tsNumOfSnodeWriteThreads, 2, 4);
|
||||
|
||||
tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1;
|
||||
tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||
tsQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1;
|
||||
tsQueueMemoryAllowed = TRANGE(tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||
|
||||
// clang-format off
|
||||
TAOS_CHECK_RETURN(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
|
@ -722,7 +726,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeStreamThreads, 2, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeWriteThreads, 2, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
|
||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncElectInterval", tsElectInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
|
@ -819,7 +823,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
|
||||
TAOS_CHECK_RETURN(cfgAddString(pCfg, "s3Accesskey", tsS3AccessKey[0], CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddString(pCfg, "s3Endpoint", tsS3Endpoint[0], CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddString(pCfg, "s3BucketName", tsS3BucketName[0], CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
TAOS_CHECK_RETURN(cfgAddString(pCfg, "s3BucketName", tsS3BucketName, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "s3PageCacheSize", tsS3PageCacheSize, 4, 1024 * 1024 * 1024, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "s3UploadDelaySec", tsS3UploadDelaySec, 1, 60 * 60 * 24 * 30, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
||||
|
@ -958,9 +962,9 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
|
|||
|
||||
pItem = cfgGetItem(pCfg, "rpcQueueMemoryAllowed");
|
||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||
tsRpcQueueMemoryAllowed = totalMemoryKB * 1024 * 0.1;
|
||||
tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||
pItem->i64 = tsRpcQueueMemoryAllowed;
|
||||
tsQueueMemoryAllowed = totalMemoryKB * 1024 * 0.1;
|
||||
tsQueueMemoryAllowed = TRANGE(tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL);
|
||||
pItem->i64 = tsQueueMemoryAllowed;
|
||||
pItem->stype = stype;
|
||||
}
|
||||
|
||||
|
@ -1357,7 +1361,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsNumOfSnodeWriteThreads = pItem->i32;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "rpcQueueMemoryAllowed");
|
||||
tsRpcQueueMemoryAllowed = pItem->i64;
|
||||
tsQueueMemoryAllowed = pItem->i64;
|
||||
|
||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "simdEnable");
|
||||
tsSIMDEnable = (bool)pItem->bval;
|
||||
|
|
|
@ -3824,7 +3824,8 @@ int32_t tSerializeSDbHbRspImp(SEncoder *pEncoder, const SDbHbRsp *pRsp) {
|
|||
if (tEncodeI8(pEncoder, 0) < 0) return -1;
|
||||
}
|
||||
if (tEncodeI32(pEncoder, pRsp->dbTsmaVersion) < 0) return -1;
|
||||
|
||||
if (tEncodeCStr(pEncoder, pRsp->db) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pRsp->dbId) < 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3915,6 +3916,10 @@ int32_t tDeserializeSDbHbRspImp(SDecoder *decoder, SDbHbRsp *pRsp) {
|
|||
if (!tDecodeIsEnd(decoder)) {
|
||||
if (tDecodeI32(decoder, &pRsp->dbTsmaVersion) < 0) return -1;
|
||||
}
|
||||
if (!tDecodeIsEnd(decoder)) {
|
||||
if (tDecodeCStrTo(decoder, pRsp->db) < 0) return -1;
|
||||
if (tDecodeI64(decoder, &pRsp->dbId) < 0) return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ void tNameAssign(SName* dst, const SName* src) { memcpy(dst, src, sizeof(SName))
|
|||
int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t nameLen) {
|
||||
// too long account id or too long db name
|
||||
if (nameLen <= 0 || nameLen >= tListLen(dst->dbname)) {
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
dst->type = TSDB_DB_NAME_T;
|
||||
|
|
|
@ -124,7 +124,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
req.numOfSupportVnodes = tsNumOfSupportVnodes;
|
||||
req.numOfDiskCfg = tsDiskCfgNum;
|
||||
req.memTotal = tsTotalMemoryKB * 1024;
|
||||
req.memAvail = req.memTotal - tsRpcQueueMemoryAllowed - 16 * 1024 * 1024;
|
||||
req.memAvail = req.memTotal - tsQueueMemoryAllowed - 16 * 1024 * 1024;
|
||||
tstrncpy(req.dnodeEp, tsLocalEp, TSDB_EP_LEN);
|
||||
tstrncpy(req.machineId, pMgmt->pData->machineId, TSDB_MACHINE_ID_LEN + 1);
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
|
||||
pRpc->info.wrapper = pWrapper;
|
||||
|
||||
EQItype itype = IsReq(pRpc) ? RPC_QITEM : DEF_QITEM; // rsp msg is not restricted by tsRpcQueueMemoryUsed
|
||||
EQItype itype = IsReq(pRpc) ? RPC_QITEM : DEF_QITEM; // rsp msg is not restricted by tsQueueMemoryUsed
|
||||
code = taosAllocateQitem(sizeof(SRpcMsg), itype, pRpc->contLen, (void **)&pMsg);
|
||||
if (code) goto _OVER;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ void Testbase::InitLog(const char* path) {
|
|||
tstrncpy(tsLogDir, path, PATH_MAX);
|
||||
|
||||
taosGetSystemInfo();
|
||||
tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 0.1;
|
||||
tsQueueMemoryAllowed = tsTotalMemoryKB * 0.1;
|
||||
if (taosInitLog("taosdlog", 1, false) != 0) {
|
||||
printf("failed to init log file\n");
|
||||
}
|
||||
|
|
|
@ -597,6 +597,8 @@ typedef struct {
|
|||
int64_t consumerId;
|
||||
char cgroup[TSDB_CGROUP_LEN];
|
||||
char clientId[TSDB_CLIENT_ID_LEN];
|
||||
char user[TSDB_USER_LEN];
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
int8_t updateType; // used only for update
|
||||
int32_t epoch;
|
||||
int32_t status;
|
||||
|
|
|
@ -152,6 +152,7 @@ bool streamTaskIterNextTask(SStreamTaskIter *pIter);
|
|||
int32_t streamTaskIterGetCurrent(SStreamTaskIter *pIter, SStreamTask **pTask);
|
||||
int32_t mndInitExecInfo();
|
||||
void mndInitStreamExecInfo(SMnode *pMnode, SStreamExecInfo *pExecInfo);
|
||||
void mndInitStreamExecInfoForLeader(SMnode *pMnode);
|
||||
int32_t removeExpiredNodeEntryAndTaskInBuf(SArray *pNodeSnapshot);
|
||||
void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode);
|
||||
|
||||
|
|
|
@ -903,6 +903,22 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
|||
MND_TMQ_NULL_CHECK(pColInfo);
|
||||
MND_TMQ_RETURN_CHECK(colDataSetVal(pColInfo, numOfRows, (const char *)clientId, false));
|
||||
|
||||
// user
|
||||
char user[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(user, pConsumer->user);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
MND_TMQ_NULL_CHECK(pColInfo);
|
||||
MND_TMQ_RETURN_CHECK(colDataSetVal(pColInfo, numOfRows, (const char *)user, false));
|
||||
|
||||
// fqdn
|
||||
char fqdn[TSDB_FQDN_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(fqdn, pConsumer->fqdn);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
MND_TMQ_NULL_CHECK(pColInfo);
|
||||
MND_TMQ_RETURN_CHECK(colDataSetVal(pColInfo, numOfRows, (const char *)fqdn, false));
|
||||
|
||||
// status
|
||||
const char *pStatusName = mndConsumerStatusName(pConsumer->status);
|
||||
status = taosMemoryCalloc(1, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
|
|
@ -1843,6 +1843,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs,
|
|||
pDbCacheInfo->tsmaVersion = htonl(pDbCacheInfo->tsmaVersion);
|
||||
|
||||
SDbHbRsp rsp = {0};
|
||||
(void)memcpy(rsp.db, pDbCacheInfo->dbFName, TSDB_DB_FNAME_LEN);
|
||||
rsp.dbId = pDbCacheInfo->dbId;
|
||||
|
||||
if ((0 == strcasecmp(pDbCacheInfo->dbFName, TSDB_INFORMATION_SCHEMA_DB) ||
|
||||
(0 == strcasecmp(pDbCacheInfo->dbFName, TSDB_PERFORMANCE_SCHEMA_DB)))) {
|
||||
|
|
|
@ -325,6 +325,8 @@ int32_t tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType,
|
|||
pConsumer->resetOffsetCfg = subscribe->resetOffsetCfg;
|
||||
pConsumer->maxPollIntervalMs = subscribe->maxPollIntervalMs;
|
||||
pConsumer->sessionTimeoutMs = subscribe->sessionTimeoutMs;
|
||||
tstrncpy(pConsumer->user, subscribe->user, TSDB_USER_LEN);
|
||||
tstrncpy(pConsumer->fqdn, subscribe->fqdn, TSDB_FQDN_LEN);
|
||||
|
||||
pConsumer->rebNewTopics = taosArrayDup(subscribe->topicNames, topicNameDup);
|
||||
if (pConsumer->rebNewTopics == NULL){
|
||||
|
@ -429,6 +431,8 @@ int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) {
|
|||
tlen += taosEncodeFixedI32(buf, pConsumer->resetOffsetCfg);
|
||||
tlen += taosEncodeFixedI32(buf, pConsumer->maxPollIntervalMs);
|
||||
tlen += taosEncodeFixedI32(buf, pConsumer->sessionTimeoutMs);
|
||||
tlen += taosEncodeString(buf, pConsumer->user);
|
||||
tlen += taosEncodeString(buf, pConsumer->fqdn);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
|
@ -503,6 +507,8 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s
|
|||
if (sver > 2){
|
||||
buf = taosDecodeFixedI32(buf, &pConsumer->maxPollIntervalMs);
|
||||
buf = taosDecodeFixedI32(buf, &pConsumer->sessionTimeoutMs);
|
||||
buf = taosDecodeStringTo(buf, pConsumer->user);
|
||||
buf = taosDecodeStringTo(buf, pConsumer->fqdn);
|
||||
} else{
|
||||
pConsumer->maxPollIntervalMs = DEFAULT_MAX_POLL_INTERVAL;
|
||||
pConsumer->sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT;
|
||||
|
|
|
@ -96,7 +96,7 @@ static void mndPullupTrans(SMnode *pMnode) {
|
|||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
//TODO check return value
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ static void mndPullupCompacts(SMnode *pMnode) {
|
|||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_COMPACT_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
//TODO check return value
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ static void mndPullupTtl(SMnode *pMnode) {
|
|||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TTL_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
//TODO check return value
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ static void mndPullupTrimDb(SMnode *pMnode) {
|
|||
mTrace("pullup s3migrate");
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_S3MIGRATE_DB_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRIM_DB_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
}
|
||||
|
@ -134,8 +134,8 @@ static void mndPullupS3MigrateDb(SMnode *pMnode) {
|
|||
mTrace("pullup trim");
|
||||
int32_t contLen = 0;
|
||||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRIM_DB_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_S3MIGRATE_DB_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ static int32_t mndCreateDir(SMnode *pMnode, const char *path) {
|
|||
|
||||
static int32_t mndInitWal(SMnode *pMnode) {
|
||||
int32_t code = 0;
|
||||
char path[PATH_MAX + 20] = {0};
|
||||
char path[PATH_MAX + 20] = {0};
|
||||
(void)snprintf(path, sizeof(path), "%s%swal", pMnode->path, TD_DIRSEP);
|
||||
SWalCfg cfg = {.vgId = 1,
|
||||
.fsyncPeriod = 0,
|
||||
|
@ -490,13 +490,12 @@ static int32_t mndInitWal(SMnode *pMnode) {
|
|||
.encryptKey = {0}};
|
||||
|
||||
#if defined(TD_ENTERPRISE)
|
||||
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_MNODE_WAL) == DND_CS_MNODE_WAL){
|
||||
cfg.encryptAlgorithm = (tsiEncryptScope & DND_CS_MNODE_WAL)? tsiEncryptAlgorithm : 0;
|
||||
if(tsEncryptKey[0] == '\0'){
|
||||
if (tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_MNODE_WAL) == DND_CS_MNODE_WAL) {
|
||||
cfg.encryptAlgorithm = (tsiEncryptScope & DND_CS_MNODE_WAL) ? tsiEncryptAlgorithm : 0;
|
||||
if (tsEncryptKey[0] == '\0') {
|
||||
code = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
(void)strncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
}
|
||||
}
|
||||
|
@ -911,7 +910,7 @@ int32_t mndProcessRpcMsg(SRpcMsg *pMsg, SQueueInfo *pQueueInfo) {
|
|||
} else if (code == 0) {
|
||||
mGTrace("msg:%p, successfully processed", pMsg);
|
||||
} else {
|
||||
//TODO removve this wrong set code
|
||||
// TODO removve this wrong set code
|
||||
if (code == -1) {
|
||||
code = terrno;
|
||||
}
|
||||
|
|
|
@ -2835,6 +2835,12 @@ void mndInitStreamExecInfo(SMnode *pMnode, SStreamExecInfo *pExecInfo) {
|
|||
pExecInfo->initTaskList = true;
|
||||
}
|
||||
|
||||
void mndInitStreamExecInfoForLeader(SMnode* pMnode) {
|
||||
execInfo.initTaskList = false;
|
||||
mInfo("init stream execInfo for leader");
|
||||
mndInitStreamExecInfo(pMnode, &execInfo);
|
||||
}
|
||||
|
||||
void addAllStreamTasksIntoBuf(SMnode *pMnode, SStreamExecInfo *pExecInfo) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SStreamObj *pStream = NULL;
|
||||
|
|
|
@ -1330,8 +1330,8 @@ END:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t consumerId, const char *topic,
|
||||
const char *cgroup, SArray *vgs, SArray *offsetRows) {
|
||||
static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t consumerId, const char* user, const char* fqdn,
|
||||
const char *topic, const char *cgroup, SArray *vgs, SArray *offsetRows) {
|
||||
int32_t code = 0;
|
||||
int32_t sz = taosArrayGetSize(vgs);
|
||||
for (int32_t j = 0; j < sz; j++) {
|
||||
|
@ -1355,7 +1355,7 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons
|
|||
MND_TMQ_RETURN_CHECK(colDataSetVal(pColInfo, *numOfRows, (const char *)&pVgEp->vgId, false));
|
||||
|
||||
// consumer id
|
||||
char consumerIdHex[32] = {0};
|
||||
char consumerIdHex[TSDB_CONSUMER_ID_LEN] = {0};
|
||||
(void)sprintf(varDataVal(consumerIdHex), "0x%" PRIx64, consumerId);
|
||||
varDataSetLen(consumerIdHex, strlen(varDataVal(consumerIdHex)));
|
||||
|
||||
|
@ -1363,6 +1363,18 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons
|
|||
MND_TMQ_NULL_CHECK(pColInfo);
|
||||
MND_TMQ_RETURN_CHECK(colDataSetVal(pColInfo, *numOfRows, (const char *)consumerIdHex, consumerId == -1));
|
||||
|
||||
char userStr[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
if (user) STR_TO_VARSTR(userStr, user);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
MND_TMQ_NULL_CHECK(pColInfo);
|
||||
MND_TMQ_RETURN_CHECK(colDataSetVal(pColInfo, *numOfRows, userStr, user == NULL));
|
||||
|
||||
char fqdnStr[TSDB_FQDN_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
if (fqdn) STR_TO_VARSTR(fqdnStr, fqdn);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
MND_TMQ_NULL_CHECK(pColInfo);
|
||||
MND_TMQ_RETURN_CHECK(colDataSetVal(pColInfo, *numOfRows, fqdnStr, fqdn == NULL));
|
||||
|
||||
mInfo("mnd show subscriptions: topic %s, consumer:0x%" PRIx64 " cgroup %s vgid %d", varDataVal(topic), consumerId,
|
||||
varDataVal(cgroup), pVgEp->vgId);
|
||||
|
||||
|
@ -1435,16 +1447,25 @@ int32_t mndRetrieveSubscribe(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock
|
|||
|
||||
SMqConsumerEp *pConsumerEp = NULL;
|
||||
void *pIter = NULL;
|
||||
|
||||
while (1) {
|
||||
pIter = taosHashIterate(pSub->consumerHash, pIter);
|
||||
if (pIter == NULL) break;
|
||||
pConsumerEp = (SMqConsumerEp *)pIter;
|
||||
|
||||
MND_TMQ_RETURN_CHECK(buildResult(pBlock, &numOfRows, pConsumerEp->consumerId, topic, cgroup, pConsumerEp->vgs,
|
||||
char *user = NULL;
|
||||
char *fqdn = NULL;
|
||||
SMqConsumerObj *pConsumer = sdbAcquire(pSdb, SDB_CONSUMER, &pConsumerEp->consumerId);
|
||||
if (pConsumer != NULL) {
|
||||
user = pConsumer->user;
|
||||
fqdn = pConsumer->fqdn;
|
||||
sdbRelease(pSdb, pConsumer);
|
||||
}
|
||||
MND_TMQ_RETURN_CHECK(buildResult(pBlock, &numOfRows, pConsumerEp->consumerId, user, fqdn, topic, cgroup, pConsumerEp->vgs,
|
||||
pConsumerEp->offsetRows));
|
||||
}
|
||||
|
||||
MND_TMQ_RETURN_CHECK(buildResult(pBlock, &numOfRows, -1, topic, cgroup, pSub->unassignedVgs, pSub->offsetRows));
|
||||
MND_TMQ_RETURN_CHECK(buildResult(pBlock, &numOfRows, -1, NULL, NULL, topic, cgroup, pSub->unassignedVgs, pSub->offsetRows));
|
||||
|
||||
pBlock->info.rows = numOfRows;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mndCluster.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
#include "mndStream.h"
|
||||
|
||||
static int32_t mndSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
||||
if (pMsg == NULL || pMsg->pCont == NULL) {
|
||||
|
@ -183,7 +184,7 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, SFsmCbMeta *pMeta) {
|
|||
code = mndTransValidate(pMnode, pRaw);
|
||||
if (code != 0) {
|
||||
mError("trans:%d, failed to validate requested trans since %s", transId, terrstr());
|
||||
code = 0;
|
||||
// code = 0;
|
||||
pMeta->code = code;
|
||||
goto _OUT;
|
||||
}
|
||||
|
@ -191,7 +192,7 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, SFsmCbMeta *pMeta) {
|
|||
code = sdbWriteWithoutFree(pMnode->pSdb, pRaw);
|
||||
if (code != 0) {
|
||||
mError("trans:%d, failed to write to sdb since %s", transId, terrstr());
|
||||
code = 0;
|
||||
// code = 0;
|
||||
pMeta->code = code;
|
||||
goto _OUT;
|
||||
}
|
||||
|
@ -206,7 +207,10 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, SFsmCbMeta *pMeta) {
|
|||
|
||||
if (pTrans->stage == TRN_STAGE_PREPARE) {
|
||||
bool continueExec = mndTransPerformPrepareStage(pMnode, pTrans, false);
|
||||
if (!continueExec) goto _OUT;
|
||||
if (!continueExec) {
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _OUT;
|
||||
}
|
||||
}
|
||||
|
||||
mndTransRefresh(pMnode, pTrans);
|
||||
|
@ -381,6 +385,7 @@ static void mndBecomeLearner(const SSyncFSM *pFsm) {
|
|||
static void mndBecomeLeader(const SSyncFSM *pFsm) {
|
||||
mInfo("vgId:1, become leader");
|
||||
SMnode *pMnode = pFsm->data;
|
||||
mndInitStreamExecInfoForLeader(pMnode);
|
||||
}
|
||||
|
||||
static bool mndApplyQueueEmpty(const SSyncFSM *pFsm) {
|
||||
|
|
|
@ -1569,6 +1569,7 @@ static int32_t mndTransExecuteUndoActionsSerial(SMnode *pMnode, STrans *pTrans,
|
|||
bool mndTransPerformPrepareStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||
bool continueExec = true;
|
||||
int32_t code = 0;
|
||||
terrno = 0;
|
||||
|
||||
int32_t numOfActions = taosArrayGetSize(pTrans->prepareActions);
|
||||
if (numOfActions == 0) goto _OVER;
|
||||
|
@ -1579,7 +1580,9 @@ bool mndTransPerformPrepareStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
|||
STransAction *pAction = taosArrayGet(pTrans->prepareActions, action);
|
||||
code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf);
|
||||
if (code != 0) {
|
||||
mError("trans:%d, failed to execute prepare action:%d, numOfActions:%d", pTrans->id, action, numOfActions);
|
||||
terrno = code;
|
||||
mError("trans:%d, failed to execute prepare action:%d, numOfActions:%d, since %s", pTrans->id, action,
|
||||
numOfActions, tstrerror(code));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -343,7 +343,6 @@ typedef struct {
|
|||
rocksdb_readoptions_t *readoptions;
|
||||
rocksdb_writebatch_t *writebatch;
|
||||
rocksdb_writebatch_t *rwritebatch;
|
||||
TdThreadMutex rMutex;
|
||||
STSchema *pTSchema;
|
||||
} SRocksCache;
|
||||
|
||||
|
@ -915,12 +914,20 @@ typedef enum {
|
|||
READER_EXEC_ROWS = 0x2,
|
||||
} EExecMode;
|
||||
|
||||
#define LAST_COL_VERSION (0x1)
|
||||
#define LAST_COL_VERSION_1 (0x1) // add primary key, version
|
||||
#define LAST_COL_VERSION_2 (0x2) // add cache status
|
||||
#define LAST_COL_VERSION LAST_COL_VERSION_2
|
||||
|
||||
typedef enum {
|
||||
TSDB_LAST_CACHE_VALID = 0, // last_cache has valid data
|
||||
TSDB_LAST_CACHE_NO_CACHE, // last_cache has no data, but tsdb may have data
|
||||
} ELastCacheStatus;
|
||||
|
||||
typedef struct {
|
||||
SRowKey rowKey;
|
||||
int8_t dirty;
|
||||
SColVal colVal;
|
||||
SRowKey rowKey;
|
||||
int8_t dirty;
|
||||
SColVal colVal;
|
||||
ELastCacheStatus cacheStatus;
|
||||
} SLastCol;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -271,7 +271,7 @@ int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
|
|||
if (*ppEntry) { // update
|
||||
if (pInfo->suid != (*ppEntry)->info.suid) {
|
||||
metaError("meta/cache: suid should be same as the one in cache.");
|
||||
return TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
if (pInfo->version > (*ppEntry)->info.version) {
|
||||
(*ppEntry)->info.version = pInfo->version;
|
||||
|
@ -543,7 +543,7 @@ int32_t metaGetCachedTableUidList(void* pVnode, tb_uid_t suid, const uint8_t* pK
|
|||
STagFilterResEntry** pEntry = taosHashGet(pTableMap, &suid, sizeof(uint64_t));
|
||||
if (NULL == pEntry) {
|
||||
metaError("meta/cache: pEntry should not be NULL.");
|
||||
return TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_NOT_FOUND;
|
||||
}
|
||||
|
||||
*acquireRes = 1;
|
||||
|
@ -750,7 +750,7 @@ int32_t metaGetCachedTbGroup(void* pVnode, tb_uid_t suid, const uint8_t* pKey, i
|
|||
STagFilterResEntry** pEntry = taosHashGet(pTableMap, &suid, sizeof(uint64_t));
|
||||
if (NULL == pEntry) {
|
||||
metaDebug("suid %" PRIu64 " not in tb group cache", suid);
|
||||
return TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_NOT_FOUND;
|
||||
}
|
||||
|
||||
*pList = taosArrayDup(taosLRUCacheValue(pCache, pHandle), NULL);
|
||||
|
|
|
@ -275,12 +275,14 @@ void metaPauseTbCursor(SMTbCursor *pTbCur) {
|
|||
int32_t metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) {
|
||||
int32_t code = 0;
|
||||
int32_t lino;
|
||||
|
||||
int8_t locked = 0;
|
||||
if (pTbCur->paused) {
|
||||
metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, META_READER_LOCK);
|
||||
|
||||
locked = 1;
|
||||
code = tdbTbcOpen(((SMeta *)pTbCur->pMeta)->pUidIdx, (TBC **)&pTbCur->pDbc, NULL);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
if (code != 0) {
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
if (first) {
|
||||
code = tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
|
||||
|
@ -304,6 +306,9 @@ int32_t metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) {
|
|||
}
|
||||
|
||||
_exit:
|
||||
if (code != 0 && locked) {
|
||||
metaReaderReleaseLock(&pTbCur->mr);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -791,6 +796,7 @@ void metaCloseSmaCursor(SMSmaCursor *pSmaCur) {
|
|||
if (pSmaCur->pMeta) metaULock(pSmaCur->pMeta);
|
||||
if (pSmaCur->pCur) {
|
||||
(void)tdbTbcClose(pSmaCur->pCur);
|
||||
pSmaCur->pCur = NULL;
|
||||
|
||||
tdbFree(pSmaCur->pKey);
|
||||
tdbFree(pSmaCur->pVal);
|
||||
|
@ -1307,7 +1313,8 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
}
|
||||
|
||||
TAOS_CHECK_GOTO(metaCreateTagIdxKey(pCursor->suid, pCursor->cid, tagData, nTagData, pCursor->type,
|
||||
param->reverse ? INT64_MAX : INT64_MIN, &pKey, &nKey), NULL, END);
|
||||
param->reverse ? INT64_MAX : INT64_MIN, &pKey, &nKey),
|
||||
NULL, END);
|
||||
|
||||
int cmp = 0;
|
||||
TAOS_CHECK_GOTO(tdbTbcMoveTo(pCursor->pCur, pKey, nKey, &cmp), 0, END);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -139,7 +139,7 @@ int32_t getPosInBlockInfoBuf(SBlockInfoBuf* pBuf, int32_t index, STableBlockScan
|
|||
int32_t bucketIndex = index / pBuf->numPerBucket;
|
||||
char** pBucket = taosArrayGet(pBuf->pData, bucketIndex);
|
||||
if (pBucket == NULL) {
|
||||
return TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_NOT_FOUND;
|
||||
}
|
||||
|
||||
*pInfo = (STableBlockScanInfo*)((*pBucket) + (index % pBuf->numPerBucket) * sizeof(STableBlockScanInfo));
|
||||
|
|
|
@ -301,8 +301,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
#if defined(TD_ENTERPRISE)
|
||||
if (pCfg->tdbEncryptAlgorithm == DND_CA_SM4) {
|
||||
if (tsEncryptKey[0] == 0) {
|
||||
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
return -1;
|
||||
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
} else {
|
||||
strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
}
|
||||
|
|
|
@ -413,9 +413,9 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
|||
pInfo->info.state.commitID, pInfo->info.state.committed, pInfo->info.state.commitTerm);
|
||||
|
||||
// persist wal before starting
|
||||
if (walPersist(pVnode->pWal) < 0) {
|
||||
vError("vgId:%d, failed to persist wal since %s", TD_VID(pVnode), terrstr());
|
||||
return -1;
|
||||
if ((code = walPersist(pVnode->pWal)) < 0) {
|
||||
vError("vgId:%d, failed to persist wal since %s", TD_VID(pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
@ -556,7 +556,6 @@ int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo) {
|
|||
pJson = tjsonParse(pData);
|
||||
if (pJson == NULL) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_INVALID_DATA_FMT, lino, _exit);
|
||||
return -1;
|
||||
}
|
||||
|
||||
code = tjsonToObject(pJson, "config", vnodeDecodeConfig, (void *)&pInfo->config);
|
||||
|
|
|
@ -39,13 +39,14 @@ static int32_t vnodeMkDir(STfs *pTfs, const char *path) {
|
|||
}
|
||||
|
||||
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs *pTfs) {
|
||||
int32_t code = 0;
|
||||
SVnodeInfo info = {0};
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
|
||||
// check config
|
||||
if (vnodeCheckCfg(pCfg) < 0) {
|
||||
vError("vgId:%d, failed to create vnode since:%s", pCfg->vgId, tstrerror(terrno));
|
||||
return -1;
|
||||
if ((code = vnodeCheckCfg(pCfg)) < 0) {
|
||||
vError("vgId:%d, failed to create vnode since:%s", pCfg->vgId, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
// create vnode env
|
||||
|
@ -72,9 +73,9 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs
|
|||
}
|
||||
|
||||
vInfo("vgId:%d, save config while create", info.config.vgId);
|
||||
if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir) < 0) {
|
||||
vError("vgId:%d, failed to save vnode config since %s", pCfg ? pCfg->vgId : 0, tstrerror(terrno));
|
||||
return -1;
|
||||
if ((code = vnodeSaveInfo(dir, &info)) < 0 || (code = vnodeCommitInfo(dir)) < 0) {
|
||||
vError("vgId:%d, failed to save vnode config since %s", pCfg ? pCfg->vgId : 0, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, vnode is created", info.config.vgId);
|
||||
|
@ -93,7 +94,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t
|
|||
ret = vnodeLoadInfo(dir, &info);
|
||||
if (ret < 0) {
|
||||
vError("vgId:%d, failed to read vnode config from %s since %s", pReq->vgId, path, tstrerror(terrno));
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
SSyncCfg *pCfg = &info.config.syncCfg;
|
||||
|
@ -144,13 +145,13 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t
|
|||
ret = vnodeSaveInfo(dir, &info);
|
||||
if (ret < 0) {
|
||||
vError("vgId:%d, failed to save vnode config since %s", pReq->vgId, tstrerror(terrno));
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = vnodeCommitInfo(dir);
|
||||
if (ret < 0) {
|
||||
vError("vgId:%d, failed to commit vnode config since %s", pReq->vgId, tstrerror(terrno));
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, vnode config is saved", info.config.vgId);
|
||||
|
@ -226,7 +227,7 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod
|
|||
ret = vnodeLoadInfo(dir, &info);
|
||||
if (ret < 0) {
|
||||
vError("vgId:%d, failed to read vnode config from %s since %s", pReq->srcVgId, srcPath, tstrerror(terrno));
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, alter hashrange from [%u, %u] to [%u, %u]", pReq->srcVgId, info.config.hashBegin, info.config.hashEnd,
|
||||
|
@ -256,13 +257,13 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod
|
|||
ret = vnodeSaveInfo(dir, &info);
|
||||
if (ret < 0) {
|
||||
vError("vgId:%d, failed to save vnode config since %s", pReq->dstVgId, tstrerror(terrno));
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = vnodeCommitInfo(dir);
|
||||
if (ret < 0) {
|
||||
vError("vgId:%d, failed to commit vnode config since %s", pReq->dstVgId, tstrerror(terrno));
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, rename %s to %s", pReq->dstVgId, srcPath, dstPath);
|
||||
|
@ -270,7 +271,7 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod
|
|||
if (ret < 0) {
|
||||
vError("vgId:%d, failed to rename vnode from %s to %s since %s", pReq->dstVgId, srcPath, dstPath,
|
||||
tstrerror(terrno));
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
vInfo("vgId:%d, vnode hashrange is altered", info.config.vgId);
|
||||
|
@ -293,9 +294,9 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s
|
|||
}
|
||||
|
||||
(void)vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
if (vnodeLoadInfo(dir, &info) < 0) {
|
||||
if ((code = vnodeLoadInfo(dir, &info)) < 0) {
|
||||
vError("vgId:%d, failed to read vnode config from %s since %s", srcVgId, srcPath, tstrerror(terrno));
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
|
||||
if (info.config.vgId == srcVgId) {
|
||||
|
|
|
@ -545,7 +545,7 @@ int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list) {
|
|||
SMCtbCursor *pCur = metaOpenCtbCursor(pVnode, uid, 1);
|
||||
if (NULL == pCur) {
|
||||
qError("vnode get all table list failed");
|
||||
return TSDB_CODE_FAILED;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -576,7 +576,7 @@ int32_t vnodeGetCtbIdList(void *pVnode, int64_t suid, SArray *list) {
|
|||
SMCtbCursor *pCur = metaOpenCtbCursor(pVnodeObj, suid, 1);
|
||||
if (NULL == pCur) {
|
||||
qError("vnode get all table list failed");
|
||||
return TSDB_CODE_FAILED;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -627,7 +627,7 @@ int32_t vnodeGetStbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bo
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
|
||||
if (!pCur) {
|
||||
return TSDB_CODE_FAILED;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
@ -655,7 +655,7 @@ _exit:
|
|||
int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num) {
|
||||
SMCtbCursor *pCur = metaOpenCtbCursor(pVnode, suid, 0);
|
||||
if (!pCur) {
|
||||
return TSDB_CODE_FAILED;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
*num = 0;
|
||||
|
@ -757,8 +757,7 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
|
|||
SArray *suidList = NULL;
|
||||
|
||||
if (!(suidList = taosArrayInit(1, sizeof(tb_uid_t)))) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_FAILED;
|
||||
return terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t tbFilterSize = 0;
|
||||
|
@ -774,7 +773,7 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
|
|||
(tbFilterSize && vnodeGetStbIdListByFilter(pVnode, 0, suidList, vnodeTimeSeriesFilter, pVnode) < 0)) {
|
||||
qError("vgId:%d, failed to get stb id list error: %s", TD_VID(pVnode), terrstr());
|
||||
taosArrayDestroy(suidList);
|
||||
return TSDB_CODE_FAILED;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
*num = 0;
|
||||
|
@ -799,7 +798,7 @@ _exit:
|
|||
int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num) {
|
||||
SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, 0);
|
||||
if (!pCur) {
|
||||
return TSDB_CODE_FAILED;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
*num = 0;
|
||||
|
|
|
@ -1980,7 +1980,7 @@ _err:
|
|||
tDecoderClear(&coder);
|
||||
vError("vgId:%d, failed to create tsma %s:%" PRIi64 " version %" PRIi64 "for table %" PRIi64 " since %s",
|
||||
TD_VID(pVnode), req.indexName, req.indexUid, ver, req.tableUid, terrstr());
|
||||
return -1;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -381,7 +381,7 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
|||
|
||||
static int32_t vnodeSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
||||
if (pMsg == NULL || pMsg->pCont == NULL) {
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
if (msgcb == NULL || msgcb->putToQueueFp == NULL) {
|
||||
|
|
|
@ -108,6 +108,7 @@ enum {
|
|||
CTG_OP_UPDATE_TB_TSMA,
|
||||
CTG_OP_DROP_TB_TSMA,
|
||||
CTG_OP_CLEAR_CACHE,
|
||||
CTG_OP_UPDATE_DB_TSMA_VERSION,
|
||||
CTG_OP_MAX
|
||||
};
|
||||
|
||||
|
@ -603,6 +604,7 @@ typedef struct SCtgUpdateTbTSMAMsg {
|
|||
STableTSMAInfo* pTsma;
|
||||
int32_t dbTsmaVersion;
|
||||
uint64_t dbId;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
} SCtgUpdateTbTSMAMsg;
|
||||
|
||||
typedef struct SCtgDropTbTSMAMsg {
|
||||
|
@ -1167,6 +1169,8 @@ int32_t ctgGetStreamProgressFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn,
|
|||
void* bInput);
|
||||
int32_t ctgAddTSMAFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t* fetchIdx, int32_t resIdx, int32_t flag,
|
||||
CTG_TSMA_FETCH_TYPE fetchType, const SName* sourceTbName);
|
||||
int32_t ctgOpUpdateDbTsmaVersion(SCtgCacheOperation* pOper);
|
||||
int32_t ctgUpdateDbTsmaVersionEnqueue(SCatalog* pCtg, int32_t tsmaVersion, const char* dbFName, int64_t dbId, bool syncOper);
|
||||
void ctgFreeTask(SCtgTask* pTask, bool freeRes);
|
||||
|
||||
extern SCatalogMgmt gCtgMgmt;
|
||||
|
|
|
@ -1933,6 +1933,18 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
int32_t catalogAsyncUpdateDbTsmaVersion(SCatalog* pCtg, int32_t tsmaVersion, const char* dbFName, int64_t dbId) {
|
||||
CTG_API_ENTER();
|
||||
if (!pCtg || !dbFName) {
|
||||
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
int32_t code = 0;
|
||||
CTG_ERR_JRET(ctgUpdateDbTsmaVersionEnqueue(pCtg, tsmaVersion, dbFName, dbId, false));
|
||||
|
||||
_return:
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
int32_t catalogClearCache(void) {
|
||||
CTG_API_ENTER_NOLOCK();
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ SCtgOperation gCtgCacheOperation[CTG_OP_MAX] = {{CTG_OP_UPDATE_VGROUP, "update v
|
|||
{CTG_OP_DROP_VIEW_META, "drop viewMeta", ctgOpDropViewMeta},
|
||||
{CTG_OP_UPDATE_TB_TSMA, "update tbTSMA", ctgOpUpdateTbTSMA},
|
||||
{CTG_OP_DROP_TB_TSMA, "drop tbTSMA", ctgOpDropTbTSMA},
|
||||
{CTG_OP_CLEAR_CACHE, "clear cache", ctgOpClearCache}};
|
||||
{CTG_OP_CLEAR_CACHE, "clear cache", ctgOpClearCache},
|
||||
{CTG_OP_UPDATE_DB_TSMA_VERSION, "update dbTsmaVersion", ctgOpUpdateDbTsmaVersion}};
|
||||
|
||||
SCtgCacheItemInfo gCtgStatItem[CTG_CI_MAX_VALUE] = {
|
||||
{"Cluster ", CTG_CI_FLAG_LEVEL_GLOBAL}, //CTG_CI_CLUSTER
|
||||
|
@ -1628,6 +1629,41 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgUpdateDbTsmaVersionEnqueue(SCatalog* pCtg, int32_t tsmaVersion, const char* dbFName, int64_t dbId, bool syncOp) {
|
||||
int32_t code = 0;
|
||||
SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation));
|
||||
if (NULL == op) {
|
||||
ctgError("malloc %d failed", (int32_t)sizeof(SCtgCacheOperation));
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
op->opId = CTG_OP_UPDATE_DB_TSMA_VERSION;
|
||||
op->syncOp = syncOp;
|
||||
|
||||
SCtgUpdateTbTSMAMsg *msg = taosMemoryMalloc(sizeof(SCtgUpdateTbTSMAMsg));
|
||||
if (NULL == msg) {
|
||||
ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateTbTSMAMsg));
|
||||
taosMemoryFree(op);
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
msg->pCtg = pCtg;
|
||||
msg->pTsma = NULL;
|
||||
msg->dbTsmaVersion = tsmaVersion;
|
||||
msg->dbId = dbId;
|
||||
memcpy(msg->dbFName, dbFName, TSDB_DB_FNAME_LEN);
|
||||
|
||||
op->data = msg;
|
||||
|
||||
CTG_ERR_JRET(ctgEnqueue(pCtg, op));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) {
|
||||
int32_t code = 0;
|
||||
|
@ -3010,6 +3046,32 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
static int32_t ctgOpUpdateDbRentForTsmaVersion(SCtgDBCache* pDbCache, SCtgUpdateTbTSMAMsg* pMsg) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (pDbCache && pMsg->dbTsmaVersion > 0) {
|
||||
pDbCache->tsmaVersion = pMsg->dbTsmaVersion;
|
||||
SDbCacheInfo cacheInfo = {0};
|
||||
cacheInfo.dbId = pDbCache->dbId;
|
||||
|
||||
if (pDbCache->cfgCache.cfgInfo) {
|
||||
cacheInfo.cfgVersion = pDbCache->cfgCache.cfgInfo->cfgVersion;
|
||||
tstrncpy(cacheInfo.dbFName, pDbCache->cfgCache.cfgInfo->db, TSDB_DB_FNAME_LEN);
|
||||
}
|
||||
|
||||
if (pDbCache->vgCache.vgInfo) {
|
||||
cacheInfo.vgVersion = pDbCache->vgCache.vgInfo->vgVersion;
|
||||
cacheInfo.numOfTable = pDbCache->vgCache.vgInfo->numOfTable;
|
||||
cacheInfo.stateTs = pDbCache->vgCache.vgInfo->stateTs;
|
||||
}
|
||||
|
||||
cacheInfo.tsmaVersion = pDbCache->tsmaVersion;
|
||||
CTG_ERR_JRET(ctgMetaRentUpdate(&pMsg->pCtg->dbRent, &cacheInfo, cacheInfo.dbId, sizeof(SDbCacheInfo),
|
||||
ctgDbCacheInfoSortCompare, ctgDbCacheInfoSearchCompare));
|
||||
}
|
||||
_return:
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgOpUpdateTbTSMA(SCtgCacheOperation *operation) {
|
||||
int32_t code = 0;
|
||||
SCtgUpdateTbTSMAMsg *msg = operation->data;
|
||||
|
@ -3023,27 +3085,7 @@ int32_t ctgOpUpdateTbTSMA(SCtgCacheOperation *operation) {
|
|||
|
||||
CTG_ERR_JRET(ctgGetAddDBCache(pCtg, pTsmaInfo->dbFName, pTsmaInfo->dbId, &dbCache));
|
||||
CTG_ERR_JRET(ctgWriteTbTSMAToCache(pCtg, dbCache, pTsmaInfo->dbFName, pTsmaInfo->tb, &pTsmaInfo));
|
||||
|
||||
if (dbCache && msg->dbTsmaVersion > 0) {
|
||||
dbCache->tsmaVersion = msg->dbTsmaVersion;
|
||||
SDbCacheInfo cacheInfo = {0};
|
||||
cacheInfo.dbId = dbCache->dbId;
|
||||
|
||||
if (dbCache->cfgCache.cfgInfo) {
|
||||
cacheInfo.cfgVersion = dbCache->cfgCache.cfgInfo->cfgVersion;
|
||||
tstrncpy(cacheInfo.dbFName, dbCache->cfgCache.cfgInfo->db, TSDB_DB_FNAME_LEN);
|
||||
}
|
||||
|
||||
if (dbCache->vgCache.vgInfo) {
|
||||
cacheInfo.vgVersion = dbCache->vgCache.vgInfo->vgVersion;
|
||||
cacheInfo.numOfTable = dbCache->vgCache.vgInfo->numOfTable;
|
||||
cacheInfo.stateTs = dbCache->vgCache.vgInfo->stateTs;
|
||||
}
|
||||
|
||||
cacheInfo.tsmaVersion = dbCache->tsmaVersion;
|
||||
CTG_ERR_JRET(ctgMetaRentUpdate(&msg->pCtg->dbRent, &cacheInfo, cacheInfo.dbId, sizeof(SDbCacheInfo),
|
||||
ctgDbCacheInfoSortCompare, ctgDbCacheInfoSearchCompare));
|
||||
}
|
||||
CTG_ERR_JRET(ctgOpUpdateDbRentForTsmaVersion(dbCache, msg));
|
||||
|
||||
_return:
|
||||
|
||||
|
@ -3057,6 +3099,22 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgOpUpdateDbTsmaVersion(SCtgCacheOperation *pOper) {
|
||||
int32_t code = 0;
|
||||
SCtgUpdateTbTSMAMsg *pMsg = pOper->data;
|
||||
SCatalog *pCtg = pMsg->pCtg;
|
||||
SCtgDBCache *pDbCache = NULL;
|
||||
|
||||
if (pCtg->stopUpdate) goto _return;
|
||||
|
||||
CTG_ERR_JRET(ctgGetAddDBCache(pCtg, pMsg->dbFName, pMsg->dbId, &pDbCache));
|
||||
CTG_ERR_JRET(ctgOpUpdateDbRentForTsmaVersion(pDbCache, pMsg));
|
||||
|
||||
_return:
|
||||
taosMemoryFreeClear(pMsg);
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
void ctgFreeCacheOperationData(SCtgCacheOperation *op) {
|
||||
if (NULL == op || NULL == op->data) {
|
||||
|
|
|
@ -128,9 +128,9 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprIn
|
|||
int32_t numOfNotFillCols, const struct SNodeListNode* val);
|
||||
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
|
||||
|
||||
void taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t capacity,
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t slotId,
|
||||
int32_t order, const char* id, SExecTaskInfo* pTaskInfo, SFillInfo** ppFillInfo);
|
||||
int32_t taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t capacity,
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t slotId,
|
||||
int32_t order, const char* id, SExecTaskInfo* pTaskInfo, SFillInfo** ppFillInfo);
|
||||
|
||||
void* taosDestroyFillInfo(struct SFillInfo* pFillInfo);
|
||||
int32_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity);
|
||||
|
|
|
@ -332,17 +332,12 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD
|
|||
goto _return;
|
||||
}
|
||||
|
||||
if (NULL == dispatcher->pDataBlocks) {
|
||||
taosMemoryFree(dispatcher);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
*pHandle = dispatcher;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
taosMemoryFree(pManager);
|
||||
if (dispatcher) {
|
||||
dsDestroyDataSinker(dispatcher);
|
||||
}
|
||||
return terrno;
|
||||
}
|
||||
|
|
|
@ -485,6 +485,9 @@ void freeSourceDataInfo(void* p) {
|
|||
}
|
||||
|
||||
void doDestroyExchangeOperatorInfo(void* param) {
|
||||
if (param == NULL) {
|
||||
return;
|
||||
}
|
||||
SExchangeInfo* pExInfo = (SExchangeInfo*)param;
|
||||
if (pExInfo->pFetchRpcHandles) {
|
||||
for (int32_t i = 0; i < pExInfo->pFetchRpcHandles->size; ++i) {
|
||||
|
|
|
@ -316,7 +316,6 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int3
|
|||
qTaskInfo_t pTaskInfo = NULL;
|
||||
code = qCreateExecTask(pReaderHandle, vgId, 0, pPlan, &pTaskInfo, NULL, 0, NULL, OPTR_EXEC_MODEL_QUEUE);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
qDestroyTask(pTaskInfo);
|
||||
terrno = code;
|
||||
return NULL;
|
||||
|
@ -352,7 +351,6 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t v
|
|||
qTaskInfo_t pTaskInfo = NULL;
|
||||
code = qCreateExecTask(readers, vgId, taskId, pPlan, &pTaskInfo, NULL, 0, NULL, OPTR_EXEC_MODEL_STREAM);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
qDestroyTask(pTaskInfo);
|
||||
terrno = code;
|
||||
return NULL;
|
||||
|
@ -360,7 +358,6 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t v
|
|||
|
||||
code = qStreamInfoResetTimewindowFilter(pTaskInfo);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
qDestroyTask(pTaskInfo);
|
||||
terrno = code;
|
||||
return NULL;
|
||||
|
|
|
@ -405,8 +405,12 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
|
|||
// STimeWindow w = {0};
|
||||
// getInitialStartTimeWindow(pInterval, startKey, &w, order == TSDB_ORDER_ASC);
|
||||
pInfo->pFillInfo = NULL;
|
||||
taosCreateFillInfo(startKey, numOfCols, numOfNotFillCols, capacity, pInterval, fillType, pColInfo,
|
||||
pInfo->primaryTsCol, order, id, pTaskInfo, &pInfo->pFillInfo);
|
||||
int32_t code = taosCreateFillInfo(startKey, numOfCols, numOfNotFillCols, capacity, pInterval, fillType, pColInfo,
|
||||
pInfo->primaryTsCol, order, id, pTaskInfo, &pInfo->pFillInfo);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
if (order == TSDB_ORDER_ASC) {
|
||||
pInfo->win.skey = win.skey;
|
||||
|
|
|
@ -73,6 +73,10 @@ static int32_t initGroupColsInfo(SGroupColsInfo* pCols, bool grpColsMayBeNull, S
|
|||
}
|
||||
|
||||
static void logGroupCacheExecInfo(SGroupCacheOperatorInfo* pGrpCacheOperator) {
|
||||
if (pGrpCacheOperator->downstreamNum <= 0 || NULL == pGrpCacheOperator->execInfo.pDownstreamBlkNum) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* buf = taosMemoryMalloc(pGrpCacheOperator->downstreamNum * 32 + 100);
|
||||
if (NULL == buf) {
|
||||
return;
|
||||
|
|
|
@ -65,6 +65,7 @@ int32_t doCreateTask(uint64_t queryId, uint64_t taskId, int32_t vgId, EOPTR_EXEC
|
|||
p->id.taskId = taskId;
|
||||
p->id.str = taosMemoryMalloc(64);
|
||||
if (p->id.str == NULL) {
|
||||
doDestroyTask(p);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -100,6 +101,7 @@ int32_t createExecTaskInfo(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHand
|
|||
int32_t vgId, char* sql, EOPTR_EXEC_MODEL model) {
|
||||
int32_t code = doCreateTask(pPlan->id.queryId, taskId, vgId, model, &pHandle->api, pTaskInfo);
|
||||
if (*pTaskInfo == NULL || code != 0) {
|
||||
nodesDestroyNode((SNode*)pPlan);
|
||||
taosMemoryFree(sql);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -255,21 +255,28 @@ static int32_t doFilterByBlockSMA(SFilterInfo* pFilterInfo, SColumnDataAgg* pCol
|
|||
return filterRangeExecute(pFilterInfo, pColsAgg, numOfCols, numOfRows, keep);
|
||||
}
|
||||
|
||||
static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
||||
static int32_t doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo,
|
||||
bool* pLoad) {
|
||||
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||
bool allColumnsHaveAgg = true;
|
||||
bool hasNullSMA = false;
|
||||
if (pLoad != NULL) {
|
||||
*pLoad = false;
|
||||
}
|
||||
|
||||
bool allColumnsHaveAgg = true;
|
||||
bool hasNullSMA = false;
|
||||
int32_t code = pAPI->tsdReader.tsdReaderRetrieveBlockSMAInfo(pTableScanInfo->dataReader, pBlock, &allColumnsHaveAgg,
|
||||
&hasNullSMA);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
return code;
|
||||
}
|
||||
|
||||
if (!allColumnsHaveAgg || hasNullSMA) {
|
||||
return false;
|
||||
*pLoad = false;
|
||||
} else {
|
||||
*pLoad = true;
|
||||
}
|
||||
return true;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static void doSetTagColumnData(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo,
|
||||
|
@ -330,14 +337,14 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
|
|||
int32_t lino = 0;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
|
||||
bool loadSMA = false;
|
||||
|
||||
SFileBlockLoadRecorder* pCost = &pTableScanInfo->readRecorder;
|
||||
|
||||
pCost->totalBlocks += 1;
|
||||
pCost->totalRows += pBlock->info.rows;
|
||||
|
||||
bool loadSMA = false;
|
||||
*status = pTableScanInfo->dataBlockLoadFlag;
|
||||
|
||||
if (pOperator->exprSupp.pFilterInfo != NULL) {
|
||||
(*status) = FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||
} else {
|
||||
|
@ -373,7 +380,14 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
|
|||
} else if (*status == FUNC_DATA_REQUIRED_SMA_LOAD) {
|
||||
pCost->loadBlockStatis += 1;
|
||||
loadSMA = true; // mark the operation of load sma;
|
||||
bool success = doLoadBlockSMA(pTableScanInfo, pBlock, pTaskInfo);
|
||||
bool success = true;
|
||||
code = doLoadBlockSMA(pTableScanInfo, pBlock, pTaskInfo, &success);
|
||||
if (code) {
|
||||
pAPI->tsdReader.tsdReaderReleaseDataBlock(pTableScanInfo->dataReader);
|
||||
qError("%s failed to retrieve sma info", GET_TASKID(pTaskInfo));
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
if (success) { // failed to load the block sma data, data block statistics does not exist, load data block instead
|
||||
qDebug("%s data block SMA loaded, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64, GET_TASKID(pTaskInfo),
|
||||
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||
|
@ -387,13 +401,21 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
|
|||
}
|
||||
|
||||
if(*status != FUNC_DATA_REQUIRED_DATA_LOAD) {
|
||||
qError("[loadDataBlock] invalid status:%d", *status);
|
||||
pAPI->tsdReader.tsdReaderReleaseDataBlock(pTableScanInfo->dataReader);
|
||||
qError("%s loadDataBlock invalid status:%d", GET_TASKID(pTaskInfo), *status);
|
||||
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
// try to filter data block according to sma info
|
||||
if (pOperator->exprSupp.pFilterInfo != NULL && (!loadSMA)) {
|
||||
bool success = doLoadBlockSMA(pTableScanInfo, pBlock, pTaskInfo);
|
||||
bool success = true;
|
||||
code = doLoadBlockSMA(pTableScanInfo, pBlock, pTaskInfo, &success);
|
||||
if (code) {
|
||||
pAPI->tsdReader.tsdReaderReleaseDataBlock(pTableScanInfo->dataReader);
|
||||
qError("%s failed to retrieve sma info", GET_TASKID(pTaskInfo));
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
size_t size = taosArrayGetSize(pBlock->pDataBlock);
|
||||
bool keep = false;
|
||||
|
@ -418,7 +440,10 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
|
|||
|
||||
// try to filter data block according to current results
|
||||
code = doDynamicPruneDataBlock(pOperator, pBlockInfo, status);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
if (code) {
|
||||
pAPI->tsdReader.tsdReaderReleaseDataBlock(pTableScanInfo->dataReader);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) {
|
||||
qDebug("%s data block skipped due to dynamic prune, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64,
|
||||
|
@ -514,9 +539,10 @@ static int32_t createTableCacheVal(const SMetaReader* pMetaReader, STableCachedV
|
|||
int32_t lino = 0;
|
||||
STableCachedVal* pVal = taosMemoryMalloc(sizeof(STableCachedVal));
|
||||
QUERY_CHECK_NULL(pVal, code, lino, _end, terrno);
|
||||
|
||||
pVal->pTags = NULL;
|
||||
pVal->pName = taosStrdup(pMetaReader->me.name);
|
||||
QUERY_CHECK_NULL(pVal->pName, code, lino, _end, terrno);
|
||||
pVal->pTags = NULL;
|
||||
|
||||
// only child table has tag value
|
||||
if (pMetaReader->me.type == TSDB_CHILD_TABLE) {
|
||||
|
@ -3806,6 +3832,9 @@ _end:
|
|||
}
|
||||
|
||||
static void destroyStreamScanOperatorInfo(void* param) {
|
||||
if (param == NULL) {
|
||||
return;
|
||||
}
|
||||
SStreamScanInfo* pStreamScan = (SStreamScanInfo*)param;
|
||||
|
||||
if (pStreamScan->pTableScanOp && pStreamScan->pTableScanOp->info) {
|
||||
|
|
|
@ -43,6 +43,9 @@ typedef struct SEventWindowInfo {
|
|||
} SEventWindowInfo;
|
||||
|
||||
void destroyStreamEventOperatorInfo(void* param) {
|
||||
if (param == NULL) {
|
||||
return;
|
||||
}
|
||||
SStreamEventAggOperatorInfo* pInfo = (SStreamEventAggOperatorInfo*)param;
|
||||
cleanupBasicInfo(&pInfo->binfo);
|
||||
destroyStreamAggSupporter(&pInfo->streamAggSup);
|
||||
|
|
|
@ -454,6 +454,9 @@ void clearGroupResInfo(SGroupResInfo* pGroupResInfo) {
|
|||
}
|
||||
|
||||
void destroyStreamFinalIntervalOperatorInfo(void* param) {
|
||||
if (param == NULL) {
|
||||
return;
|
||||
}
|
||||
SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)param;
|
||||
cleanupBasicInfo(&pInfo->binfo);
|
||||
cleanupAggSup(&pInfo->aggSup);
|
||||
|
@ -2031,6 +2034,9 @@ void destroyStreamAggSupporter(SStreamAggSupporter* pSup) {
|
|||
}
|
||||
|
||||
void destroyStreamSessionAggOperatorInfo(void* param) {
|
||||
if (param == NULL) {
|
||||
return;
|
||||
}
|
||||
SStreamSessionAggOperatorInfo* pInfo = (SStreamSessionAggOperatorInfo*)param;
|
||||
cleanupBasicInfo(&pInfo->binfo);
|
||||
destroyStreamAggSupporter(&pInfo->streamAggSup);
|
||||
|
@ -4106,6 +4112,9 @@ _error:
|
|||
}
|
||||
|
||||
void destroyStreamStateOperatorInfo(void* param) {
|
||||
if (param == NULL) {
|
||||
return;
|
||||
}
|
||||
SStreamStateAggOperatorInfo* pInfo = (SStreamStateAggOperatorInfo*)param;
|
||||
cleanupBasicInfo(&pInfo->binfo);
|
||||
destroyStreamAggSupporter(&pInfo->streamAggSup);
|
||||
|
|
|
@ -552,6 +552,8 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
|||
blockDataCleanup(pInfo->pRes);
|
||||
|
||||
pDataBlock = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_COLS);
|
||||
QUERY_CHECK_NULL(pDataBlock, code, lino, _end, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(pDataBlock, pOperator->resultInfo.capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
|
@ -568,7 +570,12 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
|
|||
if (pInfo->pCur == NULL) {
|
||||
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
||||
} else {
|
||||
(void)pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
||||
code = pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
||||
if (code != 0) {
|
||||
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
|
||||
pInfo->pCur = NULL;
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
}
|
||||
|
||||
if (pInfo->pSchema == NULL) {
|
||||
|
@ -708,6 +715,8 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
|||
int32_t numOfRows = 0;
|
||||
|
||||
dataBlock = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_TAGS);
|
||||
QUERY_CHECK_NULL(dataBlock, code, lino, _end, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(dataBlock, pOperator->resultInfo.capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
|
@ -782,7 +791,8 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
|
|||
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
|
||||
QUERY_CHECK_NULL(pInfo->pCur, code, lino, _end, terrno);
|
||||
} else {
|
||||
(void)pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
||||
code = pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
while ((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_SUPER_TABLE)) == 0) {
|
||||
|
@ -1354,6 +1364,8 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
|
|||
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||
|
||||
p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_TABLES);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(p, pOperator->resultInfo.capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
|
@ -1583,7 +1595,12 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
|
|||
firstMetaCursor = 1;
|
||||
}
|
||||
if (!firstMetaCursor) {
|
||||
(void)pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 1);
|
||||
code = pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 1);
|
||||
if (code != 0) {
|
||||
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
|
||||
pInfo->pCur = NULL;
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
}
|
||||
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
|
@ -2075,6 +2092,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
|
|||
int32_t tempRes = tSerializeSRetrieveTableReq(buf1, contLen, &pInfo->req);
|
||||
if (tempRes < 0) {
|
||||
code = terrno;
|
||||
taosMemoryFree(buf1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2083,6 +2101,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
|
|||
if (NULL == pMsgSendInfo) {
|
||||
qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo));
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(buf1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -523,14 +523,14 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
|
|||
return pFillInfo->numOfRows - pFillInfo->index;
|
||||
}
|
||||
|
||||
void taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t capacity,
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t primaryTsSlotId,
|
||||
int32_t order, const char* id, SExecTaskInfo* pTaskInfo, SFillInfo** ppFillInfo) {
|
||||
int32_t taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillCols, int32_t capacity,
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t primaryTsSlotId,
|
||||
int32_t order, const char* id, SExecTaskInfo* pTaskInfo, SFillInfo** ppFillInfo) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
if (fillType == TSDB_FILL_NONE) {
|
||||
(*ppFillInfo) = NULL;
|
||||
return;
|
||||
return code;
|
||||
}
|
||||
|
||||
SFillInfo* pFillInfo = taosMemoryCalloc(1, sizeof(SFillInfo));
|
||||
|
@ -572,10 +572,9 @@ _end:
|
|||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(pFillInfo->next.pRowVal);
|
||||
taosArrayDestroy(pFillInfo->prev.pRowVal);
|
||||
terrno = code;
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
(*ppFillInfo) = pFillInfo;
|
||||
return code;
|
||||
}
|
||||
|
||||
void taosResetFillInfo(SFillInfo* pFillInfo, TSKEY startTimestamp) {
|
||||
|
|
|
@ -1208,6 +1208,9 @@ static void freeItem(void* param) {
|
|||
}
|
||||
|
||||
void destroyIntervalOperatorInfo(void* param) {
|
||||
if (param == NULL) {
|
||||
return;
|
||||
}
|
||||
SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)param;
|
||||
cleanupBasicInfo(&pInfo->binfo);
|
||||
cleanupAggSup(&pInfo->aggSup);
|
||||
|
@ -1227,7 +1230,7 @@ void destroyIntervalOperatorInfo(void* param) {
|
|||
}
|
||||
|
||||
static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SIntervalAggOperatorInfo* pInfo,
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
bool* pRes) {
|
||||
// the primary timestamp column
|
||||
bool needed = false;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -1295,10 +1298,9 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
|
|||
_end:
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
pTaskInfo->code = code;
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
return needed;
|
||||
*pRes = needed;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo,
|
||||
|
@ -1387,7 +1389,10 @@ int32_t createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPhysiNode
|
|||
|
||||
code = initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->win);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
pInfo->timeWindowInterpo = timeWindowinterpNeeded(pSup->pCtx, num, pInfo, pTaskInfo);
|
||||
|
||||
pInfo->timeWindowInterpo = false;
|
||||
code = timeWindowinterpNeeded(pSup->pCtx, num, pInfo, &pInfo->timeWindowInterpo);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
if (pInfo->timeWindowInterpo) {
|
||||
pInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SOpenWindowInfo));
|
||||
if (pInfo->binfo.resultRowInfo.openWindow == NULL) {
|
||||
|
@ -2082,7 +2087,9 @@ int32_t createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
|
|||
code = initExecTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &iaInfo->win);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
iaInfo->timeWindowInterpo = timeWindowinterpNeeded(pSup->pCtx, num, iaInfo, pTaskInfo);
|
||||
iaInfo->timeWindowInterpo = false;
|
||||
code = timeWindowinterpNeeded(pSup->pCtx, num, iaInfo, &iaInfo->timeWindowInterpo);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
if (iaInfo->timeWindowInterpo) {
|
||||
iaInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SOpenWindowInfo));
|
||||
}
|
||||
|
@ -2413,7 +2420,9 @@ int32_t createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMergeInterva
|
|||
code = initExecTimeWindowInfo(&pIntervalInfo->twAggSup.timeWindowData, &pIntervalInfo->win);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
pIntervalInfo->timeWindowInterpo = timeWindowinterpNeeded(pExprSupp->pCtx, num, pIntervalInfo, pTaskInfo);
|
||||
pIntervalInfo->timeWindowInterpo = false;
|
||||
code = timeWindowinterpNeeded(pExprSupp->pCtx, num, pIntervalInfo, &pIntervalInfo->timeWindowInterpo);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
if (pIntervalInfo->timeWindowInterpo) {
|
||||
pIntervalInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SOpenWindowInfo));
|
||||
if (pIntervalInfo->binfo.resultRowInfo.openWindow == NULL) {
|
||||
|
|
|
@ -96,19 +96,20 @@ int32_t avgInvertFunction(SqlFunctionCtx* pCtx);
|
|||
int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
int32_t getAvgInfoSize();
|
||||
|
||||
bool getStddevFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
int32_t stddevFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t stddevFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
bool getStdFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
int32_t stdFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t stdFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t stdFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
int32_t stddevPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
int32_t stdvarFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
int32_t stdPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
||||
#ifdef BUILD_NO_CALL
|
||||
int32_t stddevInvertFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t stdInvertFunction(SqlFunctionCtx* pCtx);
|
||||
#endif
|
||||
|
||||
int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
int32_t getStddevInfoSize();
|
||||
int32_t stdCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||
int32_t getStdInfoSize();
|
||||
|
||||
bool getLeastSQRFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
int32_t leastSQRFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
|
|
|
@ -247,7 +247,7 @@ static int32_t addTimezoneParam(SNodeList* pList) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t addDbPrecisonParam(SNodeList** pList, uint8_t precision) {
|
||||
static int32_t addUint8Param(SNodeList** pList, uint8_t param) {
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||
if (pVal == NULL) {
|
||||
|
@ -259,9 +259,9 @@ static int32_t addDbPrecisonParam(SNodeList** pList, uint8_t precision) {
|
|||
pVal->notReserved = true;
|
||||
pVal->node.resType.type = TSDB_DATA_TYPE_TINYINT;
|
||||
pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TINYINT].bytes;
|
||||
pVal->node.resType.precision = precision;
|
||||
pVal->datum.i = (int64_t)precision;
|
||||
pVal->typeData = (int64_t)precision;
|
||||
pVal->node.resType.precision = param;
|
||||
pVal->datum.i = (int64_t)param;
|
||||
pVal->typeData = (int64_t)param;
|
||||
|
||||
code = nodesListMakeAppend(pList, (SNode*)pVal);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
@ -493,7 +493,7 @@ static int32_t translateAvgStateMerge(SFunctionNode* pFunc, char* pErrBuf, int32
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateStddevPartial(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
static int32_t translateStdPartial(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
@ -503,11 +503,11 @@ static int32_t translateStddevPartial(SFunctionNode* pFunc, char* pErrBuf, int32
|
|||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = getStddevInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
||||
pFunc->node.resType = (SDataType){.bytes = getStdInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateStddevMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
static int32_t translateStdMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ static int32_t translateStddevMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateStddevState(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
static int32_t translateStdState(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
@ -532,11 +532,11 @@ static int32_t translateStddevState(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
|||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = getStddevInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
||||
pFunc->node.resType = (SDataType){.bytes = getStdInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateStddevStateMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
static int32_t translateStdStateMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ static int32_t translateStddevStateMerge(SFunctionNode* pFunc, char* pErrBuf, in
|
|||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = getStddevInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
||||
pFunc->node.resType = (SDataType){.bytes = getStdInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ static int32_t translateNowToday(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
|||
|
||||
// add database precision as param
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec);
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -573,6 +573,53 @@ static int32_t translateNowToday(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translatePi(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
pFunc->node.resType =
|
||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateRound(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (2 != LIST_LENGTH(pFunc->pParameterList) && 1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if (!IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
} else if (IS_NULL_TYPE(paraType)) {
|
||||
paraType = TSDB_DATA_TYPE_BIGINT;
|
||||
}
|
||||
|
||||
if (2 == LIST_LENGTH(pFunc->pParameterList)) {
|
||||
uint8_t paraType2 = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 1))->type;
|
||||
if (!IS_NUMERIC_TYPE(paraType2) && !IS_NULL_TYPE(paraType2)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[paraType].bytes, .type = paraType};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTrunc(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if (!IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType2 = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 1))->type;
|
||||
if (!IS_NUMERIC_TYPE(paraType2) && !IS_NULL_TYPE(paraType2)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[paraType].bytes, .type = paraType};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// pseudo column do not need to check parameters
|
||||
|
||||
|
@ -1745,7 +1792,7 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
|
||||
// add database precision as param
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec);
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1776,7 +1823,7 @@ static int32_t translateIrateImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
|||
|
||||
// add database precision as param
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec);
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2032,7 +2079,22 @@ static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
if (!IS_STR_DATA_TYPE(getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type)) {
|
||||
uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if (!IS_STR_DATA_TYPE(paraType) && !IS_NULL_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCharLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if (paraType == TSDB_DATA_TYPE_VARBINARY || (!IS_STR_DATA_TYPE(paraType) && !IS_NULL_TYPE(paraType))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
|
@ -2124,31 +2186,193 @@ static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
|
||||
uint8_t para0Type = pPara0->resType.type;
|
||||
uint8_t para1Type = pPara1->resType.type;
|
||||
if (TSDB_DATA_TYPE_VARBINARY == para0Type || !IS_STR_DATA_TYPE(para0Type) || !IS_INTEGER_TYPE(para1Type)) {
|
||||
if (TSDB_DATA_TYPE_VARBINARY == para0Type ||
|
||||
(!IS_STR_DATA_TYPE(para0Type) && !IS_NULL_TYPE(para0Type)) ||
|
||||
(!IS_INTEGER_TYPE(para1Type) && !IS_NULL_TYPE(para1Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
if (((SValueNode*)pPara1)->datum.i == 0) {
|
||||
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
if (3 == numOfParams) {
|
||||
SExprNode* pPara2 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 2);
|
||||
uint8_t para2Type = pPara2->resType.type;
|
||||
if (!IS_INTEGER_TYPE(para2Type)) {
|
||||
if (!IS_INTEGER_TYPE(para2Type) && !IS_NULL_TYPE(para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
int64_t v = ((SValueNode*)pPara2)->datum.i;
|
||||
if (v < 0) {
|
||||
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = pPara0->resType.bytes, .type = pPara0->resType.type};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateSubstrIdx(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (3 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
SExprNode* pPara0 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||
SExprNode* pPara1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 1);
|
||||
SExprNode* pPara2 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 2);
|
||||
|
||||
uint8_t para0Type = pPara0->resType.type;
|
||||
uint8_t para1Type = pPara1->resType.type;
|
||||
uint8_t para2Type = pPara2->resType.type;
|
||||
if (TSDB_DATA_TYPE_VARBINARY == para0Type || (!IS_STR_DATA_TYPE(para0Type) && !IS_NULL_TYPE(para0Type)) ||
|
||||
TSDB_DATA_TYPE_VARBINARY == para1Type || (!IS_STR_DATA_TYPE(para1Type) && !IS_NULL_TYPE(para1Type)) ||
|
||||
(!IS_INTEGER_TYPE(para2Type) && !IS_NULL_TYPE(para2Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = pPara0->resType.bytes, .type = pPara0->resType.type};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateChar(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
SNode *node;
|
||||
FOREACH(node, pFunc->pParameterList) {
|
||||
uint8_t paraType = getSDataTypeFromNode(node)->type;
|
||||
if (paraType == TSDB_DATA_TYPE_VARBINARY ||
|
||||
(!IS_STR_DATA_TYPE(paraType) && !IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
||||
pFunc->node.resType = (SDataType){.bytes = 4 * numOfParams + 2, .type = TSDB_DATA_TYPE_VARCHAR};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateAscii(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if (paraType == TSDB_DATA_TYPE_VARBINARY ||
|
||||
(!IS_STR_DATA_TYPE(paraType) && !IS_NULL_TYPE(paraType))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_UTINYINT].bytes, .type = TSDB_DATA_TYPE_UTINYINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translatePosition(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para0Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if (para0Type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
(!IS_STR_DATA_TYPE(para0Type) && !IS_NULL_TYPE(para0Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 1))->type;
|
||||
if (para1Type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
(!IS_STR_DATA_TYPE(para1Type) && !IS_NULL_TYPE(para1Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTrim(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (2 != LIST_LENGTH(pFunc->pParameterList) && 1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para0Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if (para0Type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
(!IS_STR_DATA_TYPE(para0Type) && !IS_NULL_TYPE(para0Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
int32_t resLen = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->bytes;
|
||||
uint8_t type = para0Type;
|
||||
|
||||
if (2 == LIST_LENGTH(pFunc->pParameterList)) {
|
||||
uint8_t para1Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 1))->type;
|
||||
if (para1Type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
(!IS_STR_DATA_TYPE(para1Type) && !IS_NULL_TYPE(para1Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
resLen = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 1))->bytes;
|
||||
type = para1Type;
|
||||
}
|
||||
if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||
resLen *= TSDB_NCHAR_SIZE;
|
||||
}
|
||||
uint8_t trimType = pFunc->trimType;
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, trimType);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
pFunc->node.resType = (SDataType){.bytes = resLen, .type = type};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateReplace(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (3 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < 3; ++i) {
|
||||
uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, i))->type;
|
||||
if (paraType == TSDB_DATA_TYPE_VARBINARY ||
|
||||
(!IS_STR_DATA_TYPE(paraType) && !IS_NULL_TYPE(paraType))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t orgType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
uint8_t fromType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 1))->type;
|
||||
uint8_t toType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 2))->type;
|
||||
int32_t orgLen = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->bytes;
|
||||
int32_t fromLen = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 1))->bytes;
|
||||
int32_t toLen = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 2))->bytes;
|
||||
|
||||
int32_t resLen;
|
||||
// Since we don't know the accurate length of result, estimate the maximum length here.
|
||||
// To make the resLen bigger, we should make fromLen smaller and toLen bigger.
|
||||
if (orgType == TSDB_DATA_TYPE_VARBINARY && fromType != orgType) {
|
||||
fromLen = fromLen / TSDB_NCHAR_SIZE;
|
||||
}
|
||||
if (orgType == TSDB_DATA_TYPE_NCHAR && toType != orgType) {
|
||||
toLen = toLen * TSDB_NCHAR_SIZE;
|
||||
}
|
||||
resLen = TMAX(orgLen, orgLen + orgLen / fromLen * (toLen - fromLen));
|
||||
pFunc->node.resType = (SDataType){.bytes = resLen, .type = orgType};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateRepeat(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para0Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if (para0Type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
(!IS_STR_DATA_TYPE(para0Type) && !IS_NULL_TYPE(para0Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 1))->type;
|
||||
if (!IS_INTEGER_TYPE(para1Type) && !IS_NULL_TYPE(para1Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
int32_t orgLen = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->bytes;
|
||||
int32_t count = TMAX((int32_t)((SValueNode*)nodesListGetNode(pFunc->pParameterList, 1))->datum.i, 1);
|
||||
|
||||
int32_t resLen = orgLen * count;
|
||||
pFunc->node.resType = (SDataType){.bytes = resLen, .type = type};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// The number of parameters has been limited by the syntax definition
|
||||
|
||||
|
@ -2180,7 +2404,7 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
|||
|
||||
// add database precision as param
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec);
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2251,7 +2475,7 @@ static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int
|
|||
|
||||
// add database precision as param
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec);
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2325,7 +2549,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
|
|||
|
||||
// add database precision as param
|
||||
|
||||
code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec);
|
||||
code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2375,7 +2599,7 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
|||
}
|
||||
}
|
||||
|
||||
int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec);
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2384,6 +2608,91 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateWeekday(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if ((!IS_STR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) &&
|
||||
!IS_TIMESTAMP_TYPE(para1Type) && !IS_NULL_TYPE(para1Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
// add database precision as param
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
pFunc->node.resType =
|
||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateWeek(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList) && 2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if ((!IS_STR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) &&
|
||||
!IS_TIMESTAMP_TYPE(para1Type)) && !IS_NULL_TYPE(para1Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
if (2 == LIST_LENGTH(pFunc->pParameterList)) {
|
||||
uint8_t para2Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 1))->type;
|
||||
if (!IS_INTEGER_TYPE(para2Type) && !IS_NULL_TYPE(para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
if (IS_INTEGER_TYPE(para2Type)) {
|
||||
SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1);
|
||||
if (pValue->datum.i < 0 || pValue->datum.i > 7) {
|
||||
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add database precision as param
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
pFunc->node.resType =
|
||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateWeekofyear(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type;
|
||||
if ((!IS_STR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) &&
|
||||
!IS_TIMESTAMP_TYPE(para1Type)) && !IS_NULL_TYPE(para1Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
// add database precision as param
|
||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||
|
||||
int32_t code = addUint8Param(&pFunc->pParameterList, dbPrec);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
pFunc->node.resType =
|
||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
|
@ -2623,47 +2932,47 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.type = FUNCTION_TYPE_STDDEV,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = getStddevFuncEnv,
|
||||
.initFunc = stddevFunctionSetup,
|
||||
.processFunc = stddevFunction,
|
||||
.sprocessFunc = stddevScalarFunction,
|
||||
.getEnvFunc = getStdFuncEnv,
|
||||
.initFunc = stdFunctionSetup,
|
||||
.processFunc = stdFunction,
|
||||
.sprocessFunc = stdScalarFunction,
|
||||
.finalizeFunc = stddevFinalize,
|
||||
#ifdef BUILD_NO_CALL
|
||||
.invertFunc = stddevInvertFunction,
|
||||
.invertFunc = stdInvertFunction,
|
||||
#endif
|
||||
.combineFunc = stddevCombine,
|
||||
.pPartialFunc = "_stddev_partial",
|
||||
.pStateFunc = "_stddev_state",
|
||||
.combineFunc = stdCombine,
|
||||
.pPartialFunc = "_std_partial",
|
||||
.pStateFunc = "_std_state",
|
||||
.pMergeFunc = "_stddev_merge"
|
||||
},
|
||||
{
|
||||
.name = "_stddev_partial",
|
||||
.type = FUNCTION_TYPE_STDDEV_PARTIAL,
|
||||
.name = "_std_partial",
|
||||
.type = FUNCTION_TYPE_STD_PARTIAL,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateStddevPartial,
|
||||
.getEnvFunc = getStddevFuncEnv,
|
||||
.initFunc = stddevFunctionSetup,
|
||||
.processFunc = stddevFunction,
|
||||
.finalizeFunc = stddevPartialFinalize,
|
||||
.translateFunc = translateStdPartial,
|
||||
.getEnvFunc = getStdFuncEnv,
|
||||
.initFunc = stdFunctionSetup,
|
||||
.processFunc = stdFunction,
|
||||
.finalizeFunc = stdPartialFinalize,
|
||||
#ifdef BUILD_NO_CALL
|
||||
.invertFunc = stddevInvertFunction,
|
||||
.invertFunc = stdInvertFunction,
|
||||
#endif
|
||||
.combineFunc = stddevCombine,
|
||||
.combineFunc = stdCombine,
|
||||
},
|
||||
{
|
||||
.name = "_stddev_merge",
|
||||
.type = FUNCTION_TYPE_STDDEV_MERGE,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateStddevMerge,
|
||||
.getEnvFunc = getStddevFuncEnv,
|
||||
.initFunc = stddevFunctionSetup,
|
||||
.processFunc = stddevFunctionMerge,
|
||||
.translateFunc = translateStdMerge,
|
||||
.getEnvFunc = getStdFuncEnv,
|
||||
.initFunc = stdFunctionSetup,
|
||||
.processFunc = stdFunctionMerge,
|
||||
.finalizeFunc = stddevFinalize,
|
||||
#ifdef BUILD_NO_CALL
|
||||
.invertFunc = stddevInvertFunction,
|
||||
.invertFunc = stdInvertFunction,
|
||||
#endif
|
||||
.combineFunc = stddevCombine,
|
||||
.pPartialFunc = "_stddev_state_merge",
|
||||
.combineFunc = stdCombine,
|
||||
.pPartialFunc = "_std_state_merge",
|
||||
.pMergeFunc = "_stddev_merge",
|
||||
},
|
||||
{
|
||||
|
@ -3409,7 +3718,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "round",
|
||||
.type = FUNCTION_TYPE_ROUND,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.translateFunc = translateRound,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = roundFunction,
|
||||
|
@ -3489,7 +3798,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "char_length",
|
||||
.type = FUNCTION_TYPE_CHAR_LENGTH,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateLength,
|
||||
.translateFunc = translateCharLength,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = charLengthFunction,
|
||||
|
@ -3998,26 +4307,26 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_stddev_state",
|
||||
.type = FUNCTION_TYPE_STDDEV_STATE,
|
||||
.name = "_std_state",
|
||||
.type = FUNCTION_TYPE_STD_STATE,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC,
|
||||
.translateFunc = translateStddevState,
|
||||
.getEnvFunc = getStddevFuncEnv,
|
||||
.initFunc = stddevFunctionSetup,
|
||||
.processFunc = stddevFunction,
|
||||
.finalizeFunc = stddevPartialFinalize,
|
||||
.pPartialFunc = "_stddev_partial",
|
||||
.pMergeFunc = "_stddev_state_merge",
|
||||
.translateFunc = translateStdState,
|
||||
.getEnvFunc = getStdFuncEnv,
|
||||
.initFunc = stdFunctionSetup,
|
||||
.processFunc = stdFunction,
|
||||
.finalizeFunc = stdPartialFinalize,
|
||||
.pPartialFunc = "_std_partial",
|
||||
.pMergeFunc = "_std_state_merge",
|
||||
},
|
||||
{
|
||||
.name = "_stddev_state_merge",
|
||||
.type = FUNCTION_TYPE_STDDEV_STATE_MERGE,
|
||||
.name = "_std_state_merge",
|
||||
.type = FUNCTION_TYPE_STD_STATE_MERGE,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC,
|
||||
.translateFunc = translateStddevStateMerge,
|
||||
.getEnvFunc = getStddevFuncEnv,
|
||||
.initFunc = stddevFunctionSetup,
|
||||
.processFunc = stddevFunctionMerge,
|
||||
.finalizeFunc = stddevPartialFinalize,
|
||||
.translateFunc = translateStdStateMerge,
|
||||
.getEnvFunc = getStdFuncEnv,
|
||||
.initFunc = stdFunctionSetup,
|
||||
.processFunc = stdFunctionMerge,
|
||||
.finalizeFunc = stdPartialFinalize,
|
||||
},
|
||||
{
|
||||
.name = "_avg_state",
|
||||
|
@ -4152,6 +4461,268 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.processFunc = groupConstValueFunction,
|
||||
.finalizeFunc = groupConstValueFinalize,
|
||||
},
|
||||
{
|
||||
.name = "stddev_pop",
|
||||
.type = FUNCTION_TYPE_STDDEV,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = getStdFuncEnv,
|
||||
.initFunc = stdFunctionSetup,
|
||||
.processFunc = stdFunction,
|
||||
.sprocessFunc = stdScalarFunction,
|
||||
.finalizeFunc = stddevFinalize,
|
||||
#ifdef BUILD_NO_CALL
|
||||
.invertFunc = stdInvertFunction,
|
||||
#endif
|
||||
.combineFunc = stdCombine,
|
||||
.pPartialFunc = "_std_partial",
|
||||
.pStateFunc = "_std_state",
|
||||
.pMergeFunc = "_stddev_merge"
|
||||
},
|
||||
{
|
||||
.name = "var_pop",
|
||||
.type = FUNCTION_TYPE_STDVAR,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = getStdFuncEnv,
|
||||
.initFunc = stdFunctionSetup,
|
||||
.processFunc = stdFunction,
|
||||
.sprocessFunc = stdScalarFunction,
|
||||
.finalizeFunc = stdvarFinalize,
|
||||
#ifdef BUILD_NO_CALL
|
||||
.invertFunc = stdInvertFunction,
|
||||
#endif
|
||||
.combineFunc = stdCombine,
|
||||
.pPartialFunc = "_std_partial",
|
||||
.pStateFunc = "_std_state",
|
||||
.pMergeFunc = "_stdvar_merge"
|
||||
},
|
||||
{
|
||||
.name = "_stdvar_merge",
|
||||
.type = FUNCTION_TYPE_STDVAR_MERGE,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateStdMerge,
|
||||
.getEnvFunc = getStdFuncEnv,
|
||||
.initFunc = stdFunctionSetup,
|
||||
.processFunc = stdFunctionMerge,
|
||||
.finalizeFunc = stdvarFinalize,
|
||||
#ifdef BUILD_NO_CALL
|
||||
.invertFunc = stdInvertFunction,
|
||||
#endif
|
||||
.combineFunc = stdCombine,
|
||||
.pPartialFunc = "_std_state_merge",
|
||||
.pMergeFunc = "_stdvar_merge",
|
||||
},
|
||||
{
|
||||
.name = "pi",
|
||||
.type = FUNCTION_TYPE_PI,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translatePi,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = piFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "exp",
|
||||
.type = FUNCTION_TYPE_EXP,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = expFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "ln",
|
||||
.type = FUNCTION_TYPE_LN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = lnFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "mod",
|
||||
.type = FUNCTION_TYPE_MOD,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateIn2NumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = modFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "sign",
|
||||
.type = FUNCTION_TYPE_SIGN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = signFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "degrees",
|
||||
.type = FUNCTION_TYPE_DEGREES,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = degreesFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "radians",
|
||||
.type = FUNCTION_TYPE_RADIANS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = radiansFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "truncate",
|
||||
.type = FUNCTION_TYPE_TRUNCATE,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateTrunc,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = truncFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "trunc",
|
||||
.type = FUNCTION_TYPE_TRUNCATE,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateTrunc,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = truncFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "substring",
|
||||
.type = FUNCTION_TYPE_SUBSTR,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateSubstr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = substrFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "substring_index",
|
||||
.type = FUNCTION_TYPE_SUBSTR_IDX,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateSubstrIdx,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = substrIdxFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "char",
|
||||
.type = FUNCTION_TYPE_CHAR,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateChar,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = charFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "ascii",
|
||||
.type = FUNCTION_TYPE_ASCII,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateAscii,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = asciiFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "position",
|
||||
.type = FUNCTION_TYPE_POSITION,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translatePosition,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = positionFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "trim",
|
||||
.type = FUNCTION_TYPE_TRIM,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateTrim,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = trimFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "replace",
|
||||
.type = FUNCTION_TYPE_REPLACE,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateReplace,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = replaceFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "repeat",
|
||||
.type = FUNCTION_TYPE_REPEAT,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateRepeat,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = repeatFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "weekday",
|
||||
.type = FUNCTION_TYPE_WEEKDAY,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateWeekday,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = weekdayFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "dayofweek",
|
||||
.type = FUNCTION_TYPE_DAYOFWEEK,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateWeekday,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = dayofweekFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "week",
|
||||
.type = FUNCTION_TYPE_WEEK,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateWeek,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = weekFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "weekofyear",
|
||||
.type = FUNCTION_TYPE_WEEKOFYEAR,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateWeekofyear,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = weekofyearFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ typedef struct STopBotRes {
|
|||
STopBotResItem* pItems;
|
||||
} STopBotRes;
|
||||
|
||||
typedef struct SStddevRes {
|
||||
typedef struct SStdRes {
|
||||
double result;
|
||||
int64_t count;
|
||||
union {
|
||||
|
@ -77,7 +77,7 @@ typedef struct SStddevRes {
|
|||
uint64_t usum;
|
||||
};
|
||||
int16_t type;
|
||||
} SStddevRes;
|
||||
} SStdRes;
|
||||
|
||||
typedef struct SLeastSQRInfo {
|
||||
double matrix[2][3];
|
||||
|
@ -1300,14 +1300,14 @@ int32_t maxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
|||
return minMaxCombine(pDestCtx, pSourceCtx, 0);
|
||||
}
|
||||
|
||||
int32_t getStddevInfoSize() { return (int32_t)sizeof(SStddevRes); }
|
||||
int32_t getStdInfoSize() { return (int32_t)sizeof(SStdRes); }
|
||||
|
||||
bool getStddevFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||
pEnv->calcMemSize = sizeof(SStddevRes);
|
||||
bool getStdFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||
pEnv->calcMemSize = sizeof(SStdRes);
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t stddevFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
|
||||
int32_t stdFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
|
||||
if (pResultInfo->initialized) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1315,20 +1315,20 @@ int32_t stddevFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultIn
|
|||
return TSDB_CODE_FUNC_SETUP_ERROR;
|
||||
}
|
||||
|
||||
SStddevRes* pRes = GET_ROWCELL_INTERBUF(pResultInfo);
|
||||
(void)memset(pRes, 0, sizeof(SStddevRes));
|
||||
SStdRes* pRes = GET_ROWCELL_INTERBUF(pResultInfo);
|
||||
(void)memset(pRes, 0, sizeof(SStdRes));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
||||
int32_t stdFunction(SqlFunctionCtx* pCtx) {
|
||||
int32_t numOfElem = 0;
|
||||
|
||||
// Only the pre-computing information loaded and actual data does not loaded
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
int32_t type = pInput->pData[0]->info.type;
|
||||
|
||||
SStddevRes* pStddevRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
pStddevRes->type = type;
|
||||
SStdRes* pStdRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
pStdRes->type = type;
|
||||
|
||||
// computing based on the true data block
|
||||
SColumnInfoData* pCol = pInput->pData[0];
|
||||
|
@ -1350,9 +1350,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->isum += plist[i];
|
||||
pStddevRes->quadraticISum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->isum += plist[i];
|
||||
pStdRes->quadraticISum += plist[i] * plist[i];
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1366,9 +1366,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->isum += plist[i];
|
||||
pStddevRes->quadraticISum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->isum += plist[i];
|
||||
pStdRes->quadraticISum += plist[i] * plist[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1381,9 +1381,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->isum += plist[i];
|
||||
pStddevRes->quadraticISum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->isum += plist[i];
|
||||
pStdRes->quadraticISum += plist[i] * plist[i];
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1397,9 +1397,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->isum += plist[i];
|
||||
pStddevRes->quadraticISum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->isum += plist[i];
|
||||
pStdRes->quadraticISum += plist[i] * plist[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1412,9 +1412,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->usum += plist[i];
|
||||
pStddevRes->quadraticUSum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->usum += plist[i];
|
||||
pStdRes->quadraticUSum += plist[i] * plist[i];
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1428,9 +1428,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->usum += plist[i];
|
||||
pStddevRes->quadraticUSum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->usum += plist[i];
|
||||
pStdRes->quadraticUSum += plist[i] * plist[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1443,9 +1443,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->usum += plist[i];
|
||||
pStddevRes->quadraticUSum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->usum += plist[i];
|
||||
pStdRes->quadraticUSum += plist[i] * plist[i];
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1459,9 +1459,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->usum += plist[i];
|
||||
pStddevRes->quadraticUSum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->usum += plist[i];
|
||||
pStdRes->quadraticUSum += plist[i] * plist[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1474,9 +1474,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->dsum += plist[i];
|
||||
pStddevRes->quadraticDSum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->dsum += plist[i];
|
||||
pStdRes->quadraticDSum += plist[i] * plist[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1489,9 +1489,9 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
numOfElem += 1;
|
||||
pStddevRes->count += 1;
|
||||
pStddevRes->dsum += plist[i];
|
||||
pStddevRes->quadraticDSum += plist[i] * plist[i];
|
||||
pStdRes->count += 1;
|
||||
pStdRes->dsum += plist[i];
|
||||
pStdRes->quadraticDSum += plist[i] * plist[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1506,7 +1506,7 @@ _stddev_over:
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void stddevTransferInfo(SStddevRes* pInput, SStddevRes* pOutput) {
|
||||
static void stdTransferInfo(SStdRes* pInput, SStdRes* pOutput) {
|
||||
if (IS_NULL_TYPE(pInput->type)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1525,7 +1525,7 @@ static void stddevTransferInfo(SStddevRes* pInput, SStddevRes* pOutput) {
|
|||
pOutput->count += pInput->count;
|
||||
}
|
||||
|
||||
int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||
int32_t stdFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
SColumnInfoData* pCol = pInput->pData[0];
|
||||
|
||||
|
@ -1538,13 +1538,13 @@ int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) {
|
|||
return TSDB_CODE_FUNC_FUNTION_PARA_TYPE;
|
||||
}
|
||||
|
||||
SStddevRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
SStdRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pCol, i)) continue;
|
||||
char* data = colDataGetData(pCol, i);
|
||||
SStddevRes* pInputInfo = (SStddevRes*)varDataVal(data);
|
||||
stddevTransferInfo(pInputInfo, pInfo);
|
||||
SStdRes* pInputInfo = (SStdRes*)varDataVal(data);
|
||||
stdTransferInfo(pInputInfo, pInfo);
|
||||
}
|
||||
|
||||
SET_VAL(GET_RES_INFO(pCtx), 1, 1);
|
||||
|
@ -1552,14 +1552,14 @@ int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
#ifdef BUILD_NO_CALL
|
||||
int32_t stddevInvertFunction(SqlFunctionCtx* pCtx) {
|
||||
int32_t stdInvertFunction(SqlFunctionCtx* pCtx) {
|
||||
int32_t numOfElem = 0;
|
||||
|
||||
// Only the pre-computing information loaded and actual data does not loaded
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
int32_t type = pInput->pData[0]->info.type;
|
||||
|
||||
SStddevRes* pStddevRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
SStdRes* pStdRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
|
||||
// computing based on the true data block
|
||||
SColumnInfoData* pCol = pInput->pData[0];
|
||||
|
@ -1569,43 +1569,43 @@ int32_t stddevInvertFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->isum, int8_t);
|
||||
LIST_STDDEV_SUB_N(pStdRes->isum, int8_t);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->isum, int16_t);
|
||||
LIST_STDDEV_SUB_N(pStdRes->isum, int16_t);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_INT: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->isum, int32_t);
|
||||
LIST_STDDEV_SUB_N(pStdRes->isum, int32_t);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_BIGINT: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->isum, int64_t);
|
||||
LIST_STDDEV_SUB_N(pStdRes->isum, int64_t);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->isum, uint8_t);
|
||||
LIST_STDDEV_SUB_N(pStdRes->isum, uint8_t);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->isum, uint16_t);
|
||||
LIST_STDDEV_SUB_N(pStdRes->isum, uint16_t);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UINT: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->isum, uint32_t);
|
||||
LIST_STDDEV_SUB_N(pStdRes->isum, uint32_t);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->isum, uint64_t);
|
||||
LIST_STDDEV_SUB_N(pStdRes->isum, uint64_t);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->dsum, float);
|
||||
LIST_STDDEV_SUB_N(pStdRes->dsum, float);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
LIST_STDDEV_SUB_N(pStddevRes->dsum, double);
|
||||
LIST_STDDEV_SUB_N(pStdRes->dsum, double);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1620,7 +1620,7 @@ int32_t stddevInvertFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
SStddevRes* pStddevRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
SStdRes* pStddevRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
int32_t type = pStddevRes->type;
|
||||
double avg;
|
||||
|
||||
|
@ -1648,10 +1648,40 @@ int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
return functionFinalize(pCtx, pBlock);
|
||||
}
|
||||
|
||||
int32_t stddevPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||
int32_t stdvarFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
SStdRes* pStdvarRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
int32_t type = pStdvarRes->type;
|
||||
double avg;
|
||||
|
||||
if (pStdvarRes->count == 0) {
|
||||
GET_RES_INFO(pCtx)->numOfRes = 0;
|
||||
return functionFinalize(pCtx, pBlock);
|
||||
}
|
||||
|
||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||
avg = pStdvarRes->isum / ((double)pStdvarRes->count);
|
||||
pStdvarRes->result = fabs(pStdvarRes->quadraticISum / ((double)pStdvarRes->count) - avg * avg);
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||
avg = pStdvarRes->usum / ((double)pStdvarRes->count);
|
||||
pStdvarRes->result = fabs(pStdvarRes->quadraticUSum / ((double)pStdvarRes->count) - avg * avg);
|
||||
} else {
|
||||
avg = pStdvarRes->dsum / ((double)pStdvarRes->count);
|
||||
pStdvarRes->result = fabs(pStdvarRes->quadraticDSum / ((double)pStdvarRes->count) - avg * avg);
|
||||
}
|
||||
|
||||
// check for overflow
|
||||
if (isinf(pStdvarRes->result) || isnan(pStdvarRes->result)) {
|
||||
GET_RES_INFO(pCtx)->numOfRes = 0;
|
||||
}
|
||||
|
||||
return functionFinalize(pCtx, pBlock);
|
||||
}
|
||||
|
||||
int32_t stdPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||
SStddevRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
int32_t resultBytes = getStddevInfoSize();
|
||||
SStdRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||
int32_t resultBytes = getStdInfoSize();
|
||||
char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char));
|
||||
|
||||
if (NULL == res) {
|
||||
|
@ -1673,15 +1703,15 @@ int32_t stddevPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||
int32_t stdCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
||||
SStddevRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);
|
||||
SStdRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);
|
||||
|
||||
SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx);
|
||||
SStddevRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo);
|
||||
SStdRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo);
|
||||
int16_t type = pDBuf->type == TSDB_DATA_TYPE_NULL ? pSBuf->type : pDBuf->type;
|
||||
|
||||
stddevTransferInfo(pSBuf, pDBuf);
|
||||
stdTransferInfo(pSBuf, pDBuf);
|
||||
|
||||
pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes);
|
||||
pDResInfo->isNullRes &= pSResInfo->isNullRes;
|
||||
|
|
|
@ -4254,6 +4254,7 @@ static const char* jkFunctionHasPk = "HasPk";
|
|||
static const char* jkFunctionPkBytes = "PkBytes";
|
||||
static const char* jkFunctionIsMergeFunc = "IsMergeFunc";
|
||||
static const char* jkFunctionMergeFuncOf = "MergeFuncOf";
|
||||
static const char* jkFunctionTrimType = "TrimType";
|
||||
|
||||
static int32_t functionNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SFunctionNode* pNode = (const SFunctionNode*)pObj;
|
||||
|
@ -4286,7 +4287,9 @@ static int32_t functionNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkFunctionMergeFuncOf, pNode->originalFuncId);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkFunctionTrimType, pNode->trimType);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -4321,6 +4324,9 @@ static int32_t jsonToFunctionNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkFunctionMergeFuncOf, &pNode->originalFuncId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
tjsonGetNumberValue(pJson, jkFunctionTrimType, pNode->trimType, code);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -1112,6 +1112,7 @@ enum {
|
|||
FUNCTION_NODE_PK_BYTES,
|
||||
FUNCTION_CODE_IS_MERGE_FUNC,
|
||||
FUNCTION_CODE_MERGE_FUNC_OF,
|
||||
FUNCTION_CODE_TRIM_TYPE,
|
||||
};
|
||||
|
||||
static int32_t functionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||
|
@ -1145,6 +1146,9 @@ static int32_t functionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeI32(pEncoder, FUNCTION_CODE_MERGE_FUNC_OF, pNode->originalFuncId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeEnum(pEncoder, FUNCTION_CODE_TRIM_TYPE, pNode->trimType);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -1186,6 +1190,9 @@ static int32_t msgToFunctionNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
case FUNCTION_CODE_MERGE_FUNC_OF:
|
||||
code = tlvDecodeI32(pTlv, &pNode->originalFuncId);
|
||||
break;
|
||||
case FUNCTION_CODE_TRIM_TYPE:
|
||||
code = tlvDecodeEnum(pTlv, &pNode->trimType, sizeof(pNode->trimType));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -136,6 +136,11 @@ SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft,
|
|||
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList);
|
||||
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt);
|
||||
SNode* createPositionFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SNode* pExpr2);
|
||||
SNode* createTrimFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, ETrimType type);
|
||||
SNode* createTrimFunctionNodeExt(SAstCreateContext* pCxt, SNode* pExpr, SNode* pExpr2, ETrimType type);
|
||||
SNode* createSubstrFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SNode* pExpr2);
|
||||
SNode* createSubstrFunctionNodeExt(SAstCreateContext* pCxt, SNode* pExpr, SNode* pExpr2, SNode* pExpr3);
|
||||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
|
||||
SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2);
|
||||
SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTableName, SToken* pTableAlias);
|
||||
|
|
|
@ -1183,19 +1183,46 @@ pseudo_column(A) ::= IROWTS(B).
|
|||
pseudo_column(A) ::= ISFILLED(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= QTAGS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
|
||||
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::=
|
||||
CAST(B) NK_LP expr_or_subquery(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
CAST(B) NK_LP expr_or_subquery(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
function_expression(A) ::=
|
||||
CAST(B) NK_LP expr_or_subquery(C) AS type_name_default_len(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
|
||||
function_expression(A) ::= literal_func(B). { A = B; }
|
||||
CAST(B) NK_LP expr_or_subquery(C) AS type_name_default_len(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
function_expression(A) ::=
|
||||
POSITION(B) NK_LP expr_or_subquery(C) IN expr_or_subquery(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createPositionFunctionNode(pCxt, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D))); }
|
||||
function_expression(A) ::=
|
||||
TRIM(B) NK_LP expr_or_subquery(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createTrimFunctionNode(pCxt, releaseRawExprNode(pCxt, C), TRIM_TYPE_BOTH)); }
|
||||
function_expression(A) ::=
|
||||
TRIM(B) NK_LP trim_specification_type(C) FROM expr_or_subquery(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createTrimFunctionNode(pCxt, releaseRawExprNode(pCxt, D), C)); }
|
||||
function_expression(A) ::=
|
||||
TRIM(B) NK_LP expr_or_subquery(C) FROM expr_or_subquery(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createTrimFunctionNodeExt(pCxt, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), TRIM_TYPE_BOTH)); }
|
||||
function_expression(A) ::=
|
||||
TRIM(B) NK_LP trim_specification_type(C) expr_or_subquery(D) FROM expr_or_subquery(E) NK_RP(F). { A = createRawExprNodeExt(pCxt, &B, &F, createTrimFunctionNodeExt(pCxt, releaseRawExprNode(pCxt, D), releaseRawExprNode(pCxt, E), C)); }
|
||||
function_expression(A) ::=
|
||||
substr_func(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::=
|
||||
substr_func(B) NK_LP expr_or_subquery(C) FROM expr_or_subquery(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createSubstrFunctionNode(pCxt, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D))); }
|
||||
function_expression(A) ::=
|
||||
substr_func(B) NK_LP expr_or_subquery(C) FROM expr_or_subquery(D) FOR expr_or_subquery(E) NK_RP(F). { A = createRawExprNodeExt(pCxt, &B, &F, createSubstrFunctionNodeExt(pCxt, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), releaseRawExprNode(pCxt, E))); }
|
||||
function_expression(A) ::= REPLACE(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= literal_func(B). { A = B; }
|
||||
|
||||
literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
|
||||
literal_func(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
literal_func(A) ::= TODAY(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
|
||||
%type substr_func { SToken }
|
||||
%destructor substr_func { }
|
||||
substr_func(A) ::= SUBSTR(B). { A = B; }
|
||||
substr_func(A) ::= SUBSTRING(B). { A = B; }
|
||||
|
||||
%type trim_specification_type ETrimType
|
||||
%destructor trim_specification_type { }
|
||||
trim_specification_type(A) ::= BOTH. { A = TRIM_TYPE_BOTH; }
|
||||
trim_specification_type(A) ::= TRAILING. { A = TRIM_TYPE_TRAILING; }
|
||||
trim_specification_type(A) ::= LEADING. { A = TRIM_TYPE_LEADING; }
|
||||
|
||||
%type noarg_func { SToken }
|
||||
%destructor noarg_func { }
|
||||
noarg_func(A) ::= NOW(B). { A = B; }
|
||||
|
@ -1207,6 +1234,7 @@ noarg_func(A) ::= SERVER_VERSION(B).
|
|||
noarg_func(A) ::= SERVER_STATUS(B). { A = B; }
|
||||
noarg_func(A) ::= CURRENT_USER(B). { A = B; }
|
||||
noarg_func(A) ::= USER(B). { A = B; }
|
||||
noarg_func(A) ::= PI(B). { A = B; }
|
||||
|
||||
%type star_func { SToken }
|
||||
%destructor star_func { }
|
||||
|
|
|
@ -997,6 +997,73 @@ SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType d
|
|||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createPositionFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SNode* pExpr2) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SFunctionNode* func = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "position");
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr2);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createTrimFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, ETrimType type) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SFunctionNode* func = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "trim");
|
||||
func->trimType = type;
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createTrimFunctionNodeExt(SAstCreateContext* pCxt, SNode* pExpr, SNode* pExpr2, ETrimType type) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SFunctionNode* func = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "trim");
|
||||
func->trimType = type;
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr2);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createSubstrFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SNode* pExpr2) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SFunctionNode* func = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "substr");
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr2);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createSubstrFunctionNodeExt(SAstCreateContext* pCxt, SNode* pExpr, SNode* pExpr2, SNode* pExpr3) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SFunctionNode* func = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&func);
|
||||
CHECK_MAKE_NODE(func);
|
||||
strcpy(func->functionName, "substr");
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr2);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
pCxt->errCode = nodesListMakeAppend(&func->pParameterList, pExpr3);
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SNodeListNode* list = NULL;
|
||||
|
|
|
@ -2238,6 +2238,8 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt
|
|||
if (pStmt->insertType != TSDB_QUERY_TYPE_FILE_INSERT) {
|
||||
return buildSyntaxErrMsg(&pCxt->msg, "keyword VALUES or FILE is exclusive", NULL);
|
||||
}
|
||||
} else {
|
||||
return buildInvalidOperationMsg(&pCxt->msg, tstrerror(code));
|
||||
}
|
||||
|
||||
// just record pTableCxt whose data come from file
|
||||
|
|
|
@ -52,6 +52,7 @@ static SKeyword keywordTable[] = {
|
|||
{"BNODE", TK_BNODE},
|
||||
{"BNODES", TK_BNODES},
|
||||
{"BOOL", TK_BOOL},
|
||||
{"BOTH", TK_BOTH},
|
||||
{"BUFFER", TK_BUFFER},
|
||||
{"BUFSIZE", TK_BUFSIZE},
|
||||
{"BY", TK_BY},
|
||||
|
@ -111,6 +112,7 @@ static SKeyword keywordTable[] = {
|
|||
{"FLOAT", TK_FLOAT},
|
||||
{"FLUSH", TK_FLUSH},
|
||||
{"FROM", TK_FROM},
|
||||
{"FOR", TK_FOR},
|
||||
{"FORCE", TK_FORCE},
|
||||
{"FULL", TK_FULL},
|
||||
{"FUNCTION", TK_FUNCTION},
|
||||
|
@ -148,6 +150,7 @@ static SKeyword keywordTable[] = {
|
|||
{"LAST", TK_LAST},
|
||||
{"LAST_ROW", TK_LAST_ROW},
|
||||
{"LEADER", TK_LEADER},
|
||||
{"LEADING", TK_LEADING},
|
||||
{"LEFT", TK_LEFT},
|
||||
{"LICENCES", TK_LICENCES},
|
||||
{"LIKE", TK_LIKE},
|
||||
|
@ -191,6 +194,7 @@ static SKeyword keywordTable[] = {
|
|||
{"PARTITION_FIRST", TK_PARTITION_FIRST},
|
||||
{"PASS", TK_PASS},
|
||||
{"PORT", TK_PORT},
|
||||
{"POSITION", TK_POSITION},
|
||||
{"PPS", TK_PPS},
|
||||
{"PRIMARY", TK_PRIMARY},
|
||||
{"PRECISION", TK_PRECISION},
|
||||
|
@ -201,6 +205,7 @@ static SKeyword keywordTable[] = {
|
|||
{"QTIME", TK_QTIME},
|
||||
{"QUERIES", TK_QUERIES},
|
||||
{"QUERY", TK_QUERY},
|
||||
{"PI", TK_PI},
|
||||
{"RANGE", TK_RANGE},
|
||||
{"RATIO", TK_RATIO},
|
||||
{"PAUSE", TK_PAUSE},
|
||||
|
@ -250,6 +255,8 @@ static SKeyword keywordTable[] = {
|
|||
{"STT_TRIGGER", TK_STT_TRIGGER},
|
||||
{"SUBSCRIBE", TK_SUBSCRIBE},
|
||||
{"SUBSCRIPTIONS", TK_SUBSCRIPTIONS},
|
||||
{"SUBSTR", TK_SUBSTR},
|
||||
{"SUBSTRING", TK_SUBSTRING},
|
||||
{"SUBTABLE", TK_SUBTABLE},
|
||||
{"SYSINFO", TK_SYSINFO},
|
||||
{"SYSTEM", TK_SYSTEM},
|
||||
|
@ -268,6 +275,7 @@ static SKeyword keywordTable[] = {
|
|||
{"TODAY", TK_TODAY},
|
||||
{"TOPIC", TK_TOPIC},
|
||||
{"TOPICS", TK_TOPICS},
|
||||
{"TRAILING", TK_TRAILING},
|
||||
{"TRANSACTION", TK_TRANSACTION},
|
||||
{"TRANSACTIONS", TK_TRANSACTIONS},
|
||||
{"TRIGGER", TK_TRIGGER},
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -778,11 +778,13 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) {
|
|||
sql = NULL;
|
||||
if (code) {
|
||||
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
||||
qDestroyTask(pTaskInfo);
|
||||
QW_ERR_JRET(code);
|
||||
}
|
||||
|
||||
if (NULL == sinkHandle || NULL == pTaskInfo) {
|
||||
QW_TASK_ELOG("create task result error, taskHandle:%p, sinkHandle:%p", pTaskInfo, sinkHandle);
|
||||
qDestroyTask(pTaskInfo);
|
||||
QW_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
|
@ -1277,11 +1279,13 @@ int32_t qwProcessDelete(QW_FPARAMS_DEF, SQWMsg *qwMsg, SDeleteRes *pRes) {
|
|||
|
||||
if (code) {
|
||||
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
||||
qDestroyTask(pTaskInfo);
|
||||
QW_ERR_JRET(code);
|
||||
}
|
||||
|
||||
if (NULL == sinkHandle || NULL == pTaskInfo) {
|
||||
QW_TASK_ELOG("create task result error, taskHandle:%p, sinkHandle:%p", pTaskInfo, sinkHandle);
|
||||
qDestroyTask(pTaskInfo);
|
||||
QW_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue