Merge branch 'main' into merge/mainto3.0
|
@ -2,7 +2,7 @@
|
|||
# taosadapter
|
||||
ExternalProject_Add(taosadapter
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||
GIT_TAG 3.0
|
||||
GIT_TAG main
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 3.0
|
||||
GIT_TAG main
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taosws-rs
|
||||
ExternalProject_Add(taosws-rs
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
|
||||
GIT_TAG 3.0
|
||||
GIT_TAG main
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -166,6 +166,12 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
|||
|
||||

|
||||
|
||||
### 8. 创建完成
|
||||
### 8. 异常处理策略
|
||||
|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
<Contributing />
|
||||
|
||||
### 9. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 MQTT 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -196,12 +196,16 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
|||
|
||||
### 8. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||

|
||||
<AdvancedOptions/>
|
||||
|
||||

|
||||
### 9. 异常处理策略
|
||||
|
||||
### 9. 创建完成
|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
<Contributing />
|
||||
|
||||
### 10. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 Kafka 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -75,9 +75,9 @@ InfluxDB 是一种流行的开源时间序列数据库,它针对处理大量
|
|||
|
||||
### 6. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||

|
||||

|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
<AdvancedOptions/>
|
||||
|
||||
### 7. 创建完成
|
||||
|
|
@ -58,9 +58,9 @@ OpenTSDB 是一个架构在 HBase 系统之上的实时监控信息收集和展
|
|||
|
||||
### 5. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||

|
||||

|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
<AdvancedOptions/>
|
||||
|
||||
### 6. 创建完成
|
||||
|
|
@ -107,13 +107,25 @@ sidebar_label: "CSV"
|
|||
|
||||

|
||||
|
||||
### 5. 创建完成
|
||||
### 5. 配置高级选项
|
||||
|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
<AdvancedOptions/>
|
||||
|
||||
### 6. 异常处理策略
|
||||
|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
<Contributing />
|
||||
|
||||
### 7. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 CSV 到 TDengine 的数据同步任务,回到数据写入任务列表页面,可查看任务执行情况,也可以进行任务的“启动/停止”操作与“查看/编辑/删除/复制”操作。
|
||||
|
||||

|
||||
|
||||
### 6. 查看运行指标
|
||||
### 8. 查看运行指标
|
||||
|
||||
点击 **查看** 按钮,查看任务的运行指标,同时也可以查看任务中所有文件的处理情况。
|
||||
|
|
@ -134,6 +134,12 @@ split 提取器,seperator 填写分割符 `,`, number 填写 2。
|
|||
|
||||

|
||||
|
||||
### 7. 创建完成
|
||||
### 7. 异常处理策略
|
||||
|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
<Contributing />
|
||||
|
||||
### 8. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建任务。提交任务后,回到**数据写入**页面可以查看任务状态。
|
|
@ -98,14 +98,16 @@ MySQL 是最流行的关系型数据库之一。很多系统都曾经或正在
|
|||
|
||||
### 8. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
||||
<AdvancedOptions/>
|
||||
|
||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
||||
### 9. 异常处理策略
|
||||
|
||||

|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
### 9. 创建完成
|
||||
<Contributing />
|
||||
|
||||
### 10. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 MySQL 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -99,14 +99,16 @@ TDengine 可以高效地从 PostgreSQL 读取数据并将其写入 TDengine,
|
|||
|
||||
### 8. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
||||
<AdvancedOptions/>
|
||||
|
||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
||||
### 9. 异常处理策略
|
||||
|
||||

|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
### 9. 创建完成
|
||||
<Contributing />
|
||||
|
||||
### 10. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 PostgreSQL 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -91,14 +91,16 @@ TDengine 可以高效地从 Oracle 读取数据并将其写入 TDengine,以实
|
|||
|
||||
### 7. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
||||
<AdvancedOptions/>
|
||||
|
||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
||||
### 8. 异常处理策略
|
||||
|
||||

|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
### 8. 创建完成
|
||||
<Contributing />
|
||||
|
||||
### 9. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 Oracle 到 TDengine 的数据同步任务,回到**数据源列表****页面可查看任务执行情况。
|
|
@ -105,14 +105,16 @@ Microsoft SQL Server 是最流行的关系型数据库之一。很多系统都
|
|||
|
||||
### 8. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
||||
<AdvancedOptions/>
|
||||
|
||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
||||
### 9. 异常处理策略
|
||||
|
||||

|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
### 9. 创建完成
|
||||
<Contributing />
|
||||
|
||||
### 10. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 Microsoft SQL Server 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -122,14 +122,16 @@ MongoDB 是一个介于关系型数据库与非关系型数据库之间的产品
|
|||
|
||||
### 8. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
||||
<AdvancedOptions/>
|
||||
|
||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
||||
### 9. 异常处理策略
|
||||
|
||||

|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
### 9. 创建完成
|
||||
<Contributing />
|
||||
|
||||
### 10. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 MongoDB 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -0,0 +1,7 @@
|
|||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
|
||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
||||
|
||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
||||
|
||||

|
|
@ -0,0 +1,23 @@
|
|||
异常处理策略区域是对数据异常时的处理策略进行配置,默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
|
||||

|
||||
|
||||
各异常项说明及相应可选处理策略如下:
|
||||
|
||||
> 通用处理策略说明:
|
||||
> 归档:将异常数据写入归档文件(默认路径为 `${data_dir}/tasks/_id/.datetime`),不写入目标库
|
||||
> 丢弃:将异常数据忽略,不写入目标库
|
||||
> 报错:任务报错
|
||||
|
||||
- **主键时间戳溢出** 检查数据中第一列时间戳是否在正确的时间范围内(now - keep1, now + 100y),可选处理策略:归档、丢弃、报错
|
||||
- **主键时间戳空** 检查数据中第一列时间戳是否为空,可选处理策略:归档、丢弃、报错、使用当前时间
|
||||
> 使用当前时间:使用当前时间填充到空的时间戳字段中
|
||||
- **表名长度溢出** 检查子表表名的长度是否超出限制(最大 192 字符),可选处理策略:归档、丢弃、报错、截断、截断且归档
|
||||
> 截断:截取原始表名的前 192 个字符作为新的表名
|
||||
> 截断且归档:截取原始表名的前 192 个字符作为新的表名,并且将此行记录写入归档文件
|
||||
- **表名非法字符** 检查子表表名中是否包含特殊字符(符号 `.` 等),可选处理策略:归档、丢弃、报错、非法字符替换为指定字符串
|
||||
> 非法字符替换为指定字符串:将原始表名中的特殊字符替换为后方输入框中的指定字符串,例如 `a.b` 替换为 `a_b`
|
||||
- **表名模板变量空值** 检查子表表名模板中的变量是否为空,可选处理策略:丢弃、留空、变量替换为指定字符串
|
||||
> 留空:变量位置不做任何特殊处理,例如 `a_{x}` 转换为 `a_`
|
||||
> 变量替换为指定字符串:变量位置使用后方输入框中的指定字符串,例如 `a_{x}` 转换为 `a_b`
|
||||
- **列名长度溢出** 检查列名的长度是否超出限制(最大 64 字符),可选处理策略:归档、丢弃、报错
|
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 97 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 31 KiB |
|
@ -145,3 +145,47 @@ toasX 的配置文件(默认 /etc/taos/taosx.toml) 中与 monitor 相关的配
|
|||
#### 限制
|
||||
|
||||
只有在以 server 模式运行 taosX 时,与监控相关的配置才生效。
|
||||
|
||||
## explorer 集成监控面板
|
||||
|
||||
explorer 支持集成已有的 grafana dashboard。
|
||||
|
||||
### 配置 grafana
|
||||
|
||||
编辑 grafana.ini, 修改以下配置项。配置 root_url, 可能对现有的 grafana 使用习惯有所影响,为了集成到 explorer 是需要如此配置的, 方便通过 explorer 做服务代理。
|
||||
|
||||
``` toml
|
||||
[server]
|
||||
# If you use reverse proxy and sub path specify full url (with sub path)
|
||||
root_url = http://ip:3000/grafana
|
||||
# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
|
||||
serve_from_sub_path = true
|
||||
|
||||
[security]
|
||||
# set to true if you want to allow browsers to render Grafana in a <frame>, <iframe>, <embed> or <object>. default is false.
|
||||
allow_embedding = true
|
||||
```
|
||||
|
||||
### 配置 Explorer
|
||||
|
||||
修改 explorer.toml, 其中 dashboard 配置的 url 中的 ip, 应该配置为可以通过 explorer 服务器能够访问到的 grafana 服务的内网地址。
|
||||
|
||||
``` toml
|
||||
[grafana]
|
||||
# The token of the Grafana server, which is used to access the Grafana server.
|
||||
token = ""
|
||||
|
||||
# The URL of the Grafana dashboard, which is used to display the monitoring data of the TDengine cluster.
|
||||
# You can configure multiple Grafana dashboards.
|
||||
[grafana.dashboards]
|
||||
TDengine3 = "http://ip:3000/d/000000001/tdengine3?theme=light&kiosk=tv"
|
||||
taosX = "http://ip:3000/d/000000002/taosx?theme=light&kiosk=tv"
|
||||
```
|
||||
|
||||
如下图(grafana V-8.5.27),获取 api key, 请注意添加只读权限的 apikey, 否则有安全风险。
|
||||
|
||||

|
||||
|
||||
如下图(grafana V-8.5.27),获取 dashboard url, 获取的 url 请额外加上参数:theme=light&kiosk=tv.
|
||||
|
||||

|
||||
|
|
|
@ -35,119 +35,67 @@ taosdump -i /file/path -h localhost -P 6030
|
|||
|
||||
# 2. 基于 TDengine Enterprise 进行数据备份恢复
|
||||
|
||||
## 2.1. 概念
|
||||
## 2.1. 概述
|
||||
|
||||
基于 TDengine 的数据订阅功能,TDengine Enterprise 实现了数据的增量备份和恢复。用户可以通过 taosExplorer 对 TDengine
|
||||
集群进行备份和恢复。
|
||||
|
||||
TDengine Enterprise 的备份和恢复功能包括以下几个概念:
|
||||
|
||||
1. 备份对象:用户可以对一个数据库,或者一个超级表进行备份。
|
||||
2. 备份计划:用户可以为某个备份对象创建一个备份计划。备份计划从指定的时间点开始,周期性的执行一次备份任务,并生成一组备份文件。
|
||||
3. 备份点:每执行一次备份任务,生成一组备份文件,它们对应一个时间点,称为**备份点**。第一个备份点称为**初始备份点**。
|
||||
4. 备份文件:多个备份点,组成备份计划的备份文件。
|
||||
5. 恢复任务:用户可以选择备份计划的某个备份点,创建一个恢复任务。恢复任务会从初始备份点开始,逐个应用备份点,恢复到指定的备份点。
|
||||
1. 增量数据备份:基于 TDengine 的数据订阅功能,将**备份对象**的所有数据变更(包括:新增、修改、删除、元数据变更等)记录下来,生成备份文件。
|
||||
2. 数据恢复:使用增量数据备份生成的备份文件,将**备份对象**恢复到指定的时间点。
|
||||
3. 备份对象:用户备份的对象,可以是一个**数据库**,也可以是一个**超级表**。
|
||||
4. 备份计划:用户为备份对象创建一个周期性执行的备份任务。备份计划从指定的时间点开始,以**备份周期**为间隔,周期性地执行备份任务。备份任务每次生成一个**备份点**。
|
||||
5. 备份点:每次执行备份任务,生成一组备份文件,它们对应一个时间点,称为**备份点**。第一个备份点称为**初始备份点**。
|
||||
6. 恢复任务:用户选择备份计划的某个备份点,创建一个恢复任务。恢复任务从**初始备份点**开始,逐个回放**备份文件**中的数据变更,直到指定的备份点结束。
|
||||
|
||||

|
||||
|
||||
以上面的图为例:
|
||||
以上图为例:
|
||||
|
||||
1. 用户创建了一个备份计划,从 2024-08-27 00:00:00 开始,每隔 1 天执行一次备份任务。
|
||||
2. 在 2024-08-27 00:00:00 执行了第一次备份任务,生成了一个备份点。
|
||||
3. 之后,每隔 1 天执行一次备份任务,生成了多个备份点,组成了备份文件。
|
||||
4. 用户可以选择某个备份点,创建一个恢复任务,恢复到指定的备份点。
|
||||
1. 用户创建了一个**备份计划**,从 2024-08-27 00:00:00 开始,每隔 1 天执行一次**备份任务**。
|
||||
2. 在 2024-08-27 00:00:00 执行了第一次备份任务,生成了一个**初始备份点**。
|
||||
3. 之后,每隔 1 天执行一次备份任务,生成了多个**备份点**。
|
||||
4. 用户可以选择某个**备份点**,创建一个**恢复任务**。
|
||||
5. 恢复任务会从初始备份点开始,逐个应用备份点,恢复到指定的备份点。
|
||||
|
||||
## 2.2. 备份计划
|
||||
## 2.2. 数据备份
|
||||
|
||||
### 2.1.1. 创建
|
||||
|
||||
1. 通过浏览器访问 taosExplorer 服务,访问地址通常为 TDengine 集群所在 IP 地址的端口 6060,如 http://localhost:6060。
|
||||
2. 在 taosExplorer 服务页面中,进入“系统管理 - 备份”页面,点击“创建备份计划”按钮。
|
||||
|
||||

|
||||
|
||||
3. 在弹出的“创建备份计划”表单中,填写备份计划的相关信息。
|
||||
|
||||

|
||||
通过浏览器访问 taosExplorer 服务,访问地址通常为 TDengine 集群所在 IP 地址的端口 6060,如 http://localhost:6060。 在
|
||||
taosExplorer 服务页面中,进入“系统管理 - 备份”页面,在“备份计划”标签页下,点击“创建备份计划”,填写备份计划的相关信息。
|
||||
|
||||
需要填写的信息包括:
|
||||
|
||||
* 数据库:需要备份的数据库名称。一个备份计划只能备份一个数据库/超级表。
|
||||
* 超级表:需要备份的超级表名称。如果不填写,则备份整个数据库。
|
||||
* 下次执行时间:首次执行备份任务的日期时间。
|
||||
* 备份周期:备份点之间的时间间隔。注意:备份周期必须大于数据库的 WAL_RETENTION_PERIOD 参数值。
|
||||
* 错误重试次数:对于可通过重试解决的错误,系统会按照此次数进行重试。
|
||||
* 错误重试间隔:每次重试之间的时间间隔。
|
||||
* 目录:存储备份文件的目录。
|
||||
* 备份文件大小:备份文件的大小限制。当备份文件大小达到此限制时,会自动创建新的备份文件。
|
||||
* 文件压缩等级:备份文件的压缩等级。支持:最快速度、最佳压缩比、兼具速度和压缩比。
|
||||
1. 数据库:需要备份的数据库名称。一个备份计划只能备份一个数据库/超级表。
|
||||
2. 超级表:需要备份的超级表名称。如果不填写,则备份整个数据库。
|
||||
3. 下次执行时间:首次执行备份任务的日期时间。
|
||||
4. 备份周期:备份点之间的时间间隔。注意:备份周期必须大于数据库的 WAL_RETENTION_PERIOD 参数值。
|
||||
5. 错误重试次数:对于可通过重试解决的错误,系统会按照此次数进行重试。
|
||||
6. 错误重试间隔:每次重试之间的时间间隔。
|
||||
7. 目录:存储备份文件的目录。
|
||||
8. 备份文件大小:备份文件的大小限制。当备份文件大小达到此限制时,会自动创建新的备份文件。
|
||||
9. 文件压缩等级:备份文件的压缩等级。支持:最快速度、最佳压缩比、兼具速度和压缩比。
|
||||
|
||||
创建成功后,备份计划会开始按照配置的参数运行。
|
||||
创建成功后,备份计划会开始按照配置的参数运行。在“备份计划”下的列表中,可以查看已创建的备份计划。
|
||||
|
||||
### 2.1.2. 查看
|
||||
备份计划支持以下操作:
|
||||
|
||||
在“备份计划”下的列表中,可以查看已创建的备份计划。
|
||||
1. 查看:显示备份计划的详细信息。
|
||||
2. 修改:修改备份计划的配置。修改备份计划的配置后,当前运行的备份任务会先停止,然后按照新的配置重新运行。
|
||||
3. 复制:以选中的备份计划为模版,创建新的备份计划。除了数据库和超级表需要用户选择以外,其他配置项和被复制的计划相同。
|
||||
4. 删除:删除备份计划。删除备份计划时,可以选择是否删除关联的备份文件。
|
||||
5. 指标:查看备份计划的统计指标。
|
||||
6. 查看备份点:查看和备份计划关联的所有备份点。
|
||||
|
||||

|
||||
## 2.3. 备份文件
|
||||
|
||||
点击“操作”中的“查看”按钮,可以查看备份计划的详细信息。
|
||||
在“备份文件”列表中,可以查看备份文件的详细信息。
|
||||
|
||||

|
||||
## 2.4. 数据恢复
|
||||
|
||||
### 2.1.3. 修改
|
||||
在“备份文件”列表中,选择一个备份点,可以创建一个恢复任务,数据库恢复到指定的时间。
|
||||
|
||||
点击“操作”中的“修改”按钮,可以修改备份计划的配置。
|
||||
|
||||

|
||||
|
||||
修改备份计划的配置后,当前运行的备份任务会先停止,然后按照新的配置重新运行。
|
||||
|
||||
### 2.1.4. 复制
|
||||
|
||||
点击“操作”中的“复制”按钮,可以复制备份计划。
|
||||
|
||||

|
||||
|
||||
除了数据库和超级表被置为空外,其他配置项和被复制的计划相同。用户点击“确认”后,创建一个新的备份计划。
|
||||
|
||||
### 2.1.5. 删除
|
||||
|
||||
在操作中点击关闭按钮,可以停止当前备份计划。点击“操作”中的“删除”按钮,可以删除备份计划。
|
||||
|
||||

|
||||
|
||||
删除备份计划时,可以选择,是否删除关联的备份文件。
|
||||
|
||||
## 2.2. 备份文件
|
||||
|
||||
### 2.2.1. 查看
|
||||
|
||||
在备份计划列表中,选择要一个备份计划。在“备份文件”列中,点击“查看”按钮。可以查看和备份计划的所有备份点。
|
||||
|
||||

|
||||
|
||||
在备份文件列表中,可以查看备份文件的详细信息。
|
||||
|
||||

|
||||
|
||||
## 2.3. 恢复任务
|
||||
|
||||
### 2.3.1. 创建
|
||||
|
||||
在备份文件列表中,点击“操作”中的“恢复”按钮,可以创建一个恢复任务。
|
||||
|
||||

|
||||
|
||||
在弹出的对话框中,选择使用哪个备份点开始恢复,默认为最早的备份点。点击“确定”后,创建恢复任务,并跳转至“恢复任务”列表。
|
||||
|
||||
### 2.3.2. 查看
|
||||
|
||||
在“恢复任务”列表中,可以查看已创建的恢复任务。
|
||||
|
||||

|
||||
|
||||
恢复任务可以终止。点击“操作”中的开关,可以终止当前恢复任务。
|
||||
在“恢复任务”列表中,可以查看已创建的恢复任务。恢复任务可以终止。
|
||||
|
||||
# 3. 常见错误排查
|
||||
|
||||
|
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 94 KiB |
Before Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 106 KiB |
Before Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 119 KiB |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 109 KiB |
|
@ -182,7 +182,7 @@ void tColDataClear(SColData *pColData);
|
|||
void tColDataDeepClear(SColData *pColData);
|
||||
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal);
|
||||
int32_t tColDataUpdateValue(SColData *pColData, SColVal *pColVal, bool forward);
|
||||
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
|
||||
int32_t tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
|
||||
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal);
|
||||
int32_t tColDataCopy(SColData *pColDataFrom, SColData *pColData, xMallocFn xMalloc, void *arg);
|
||||
void tColDataArrGetRowKey(SColData *aColData, int32_t nColData, int32_t iRow, SRowKey *key);
|
||||
|
|
|
@ -293,6 +293,7 @@ extern int32_t tsMaxStreamBackendCache;
|
|||
extern int32_t tsPQSortMemThreshold;
|
||||
extern int32_t tsResolveFQDNRetryTime;
|
||||
extern bool tsStreamCoverage;
|
||||
extern int8_t tsS3EpNum;
|
||||
|
||||
extern bool tsExperimental;
|
||||
// #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||
|
|
|
@ -237,18 +237,20 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR
|
|||
(void)memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes);
|
||||
} else {
|
||||
int32_t dataLen = varDataTLen(pData);
|
||||
if (meta->type == TSDB_DATA_TYPE_JSON) {
|
||||
if (*pData == TSDB_DATA_TYPE_NULL) {
|
||||
dataLen = 0;
|
||||
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||
dataLen = varDataTLen(pData + sizeof(char));
|
||||
} else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||
dataLen = sizeof(int64_t);
|
||||
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||
dataLen = sizeof(char);
|
||||
}
|
||||
dataLen += sizeof(char);
|
||||
}
|
||||
// This is a piece of code to help users implement udf. It is only called during testing.
|
||||
// Currently, the json type is not supported and will not be called.
|
||||
// if (meta->type == TSDB_DATA_TYPE_JSON) {
|
||||
// if (*pData == TSDB_DATA_TYPE_NULL) {
|
||||
// dataLen = 0;
|
||||
// } else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||
// dataLen = varDataTLen(pData + sizeof(char));
|
||||
// } else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||
// dataLen = sizeof(int64_t);
|
||||
// } else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||
// dataLen = sizeof(char);
|
||||
// }
|
||||
// dataLen += sizeof(char);
|
||||
// }
|
||||
|
||||
if (data->varLenCol.payloadAllocLen < data->varLenCol.payloadLen + dataLen) {
|
||||
uint32_t newSize = data->varLenCol.payloadAllocLen;
|
||||
|
|
|
@ -848,6 +848,7 @@ static int stmtSetDbName2(TAOS_STMT2* stmt, const char* dbName) {
|
|||
STMT_DLOG("start to set dbName: %s", dbName);
|
||||
|
||||
pStmt->db = taosStrdup(dbName);
|
||||
(void)strdequote(pStmt->db);
|
||||
STMT_ERR_RET(stmtCreateRequest(pStmt));
|
||||
|
||||
// The SQL statement specifies a database name, overriding the previously specified database
|
||||
|
|
|
@ -276,6 +276,7 @@ TEST(testCase, smlParseCols_Test) {
|
|||
info->dataFormat = false;
|
||||
SSmlLineInfo elements = {0};
|
||||
info->msgBuf = msgBuf;
|
||||
ASSERT_EQ(smlInitHandle(NULL), TSDB_CODE_INVALID_PARA);
|
||||
|
||||
const char *data =
|
||||
"st,t=1 cb\\=in=\"pass\\,it "
|
||||
|
|
|
@ -11141,6 +11141,7 @@ void tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
|||
}
|
||||
|
||||
void tOffsetDestroy(void *param) {
|
||||
if (param == NULL) return;
|
||||
STqOffsetVal *pVal = (STqOffsetVal *)param;
|
||||
if (IS_VAR_DATA_TYPE(pVal->primaryKey.type)) {
|
||||
taosMemoryFreeClear(pVal->primaryKey.pData);
|
||||
|
@ -11148,6 +11149,7 @@ void tOffsetDestroy(void *param) {
|
|||
}
|
||||
|
||||
void tDeleteSTqOffset(void *param) {
|
||||
if (param == NULL) return;
|
||||
STqOffset *pVal = (STqOffset *)param;
|
||||
tOffsetDestroy(&pVal->val);
|
||||
}
|
||||
|
|
|
@ -2671,8 +2671,13 @@ static void (*tColDataGetValueImpl[])(SColData *pColData, int32_t iVal, SColVal
|
|||
tColDataGetValue6, // HAS_VALUE | HAS_NULL
|
||||
tColDataGetValue7 // HAS_VALUE | HAS_NULL | HAS_NONE
|
||||
};
|
||||
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal) {
|
||||
int32_t tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal) {
|
||||
if (iVal < 0 || iVal >= pColData->nVal ||
|
||||
(pColData->flag <= 0 || pColData->flag >= sizeof(tColDataGetValueImpl)/POINTER_BYTES)){
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
tColDataGetValueImpl[pColData->flag](pColData, iVal, pColVal);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal) {
|
||||
|
@ -3436,7 +3441,10 @@ static int32_t tColDataCopyRowAppend(SColData *aFromColData, int32_t iFromRow, S
|
|||
|
||||
for (int32_t i = 0; i < nColData; i++) {
|
||||
SColVal cv = {0};
|
||||
tColDataGetValue(&aFromColData[i], iFromRow, &cv);
|
||||
code = tColDataGetValue(&aFromColData[i], iFromRow, &cv);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
code = tColDataAppendValue(&aToColData[i], &cv);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
|
@ -3575,7 +3583,10 @@ static int32_t tColDataMerge(SArray **colArr) {
|
|||
SColData *dstCol = taosArrayGet(dst, j);
|
||||
|
||||
SColVal cv;
|
||||
tColDataGetValue(srcCol, i, &cv);
|
||||
code = tColDataGetValue(srcCol, i, &cv);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _exit;
|
||||
}
|
||||
code = tColDataAppendValue(dstCol, &cv);
|
||||
if (code) {
|
||||
goto _exit;
|
||||
|
@ -3588,7 +3599,10 @@ static int32_t tColDataMerge(SArray **colArr) {
|
|||
SColData *dstCol = taosArrayGet(dst, j);
|
||||
|
||||
SColVal cv;
|
||||
tColDataGetValue(srcCol, i, &cv);
|
||||
code = tColDataGetValue(srcCol, i, &cv);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _exit;
|
||||
}
|
||||
code = tColDataUpdateValue(dstCol, &cv, true);
|
||||
if (code) {
|
||||
goto _exit;
|
||||
|
|
|
@ -449,6 +449,20 @@ static void checkTSRow(const char **data, STSRow *row, STSchema *pTSchema) {
|
|||
checkSColVal(data[i], &colVal, pCol->type);
|
||||
}
|
||||
}
|
||||
#ifndef WINDOWS
|
||||
TEST(testCase, tColDataGetValue) {
|
||||
SColData pColData = {0};
|
||||
SColVal pColVal = {0};
|
||||
ASSERT_NE(tColDataGetValue(&pColData, 0, &pColVal),0);
|
||||
|
||||
pColData = {.flag = 8};
|
||||
pColVal = {0};
|
||||
ASSERT_NE(tColDataGetValue(&pColData, 0, &pColVal),0);
|
||||
|
||||
pColData = {.nVal = 1, .flag = 8};
|
||||
ASSERT_NE(tColDataGetValue(&pColData, 0, &pColVal),0);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(testCase, AllNormTest) {
|
||||
int16_t nCols = 14;
|
||||
|
|
|
@ -129,7 +129,7 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_USER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_DNODE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_MNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_MNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -348,6 +348,7 @@ static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pC
|
|||
req.compactId = compactId;
|
||||
req.vgId = pVgroup->vgId;
|
||||
req.dnodeId = dnodeid;
|
||||
terrno = 0;
|
||||
|
||||
mInfo("vgId:%d, build compact vnode config req", pVgroup->vgId);
|
||||
int32_t contLen = tSerializeSVKillCompactReq(NULL, 0, &req);
|
||||
|
@ -367,8 +368,10 @@ static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pC
|
|||
pHead->contLen = htonl(contLen);
|
||||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
|
||||
if ((contLen = tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req)) < 0) {
|
||||
terrno = contLen;
|
||||
mTrace("vgId:%d, build compact vnode config req, contLen:%d", pVgroup->vgId, contLen);
|
||||
int32_t ret = 0;
|
||||
if ((ret = tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req)) < 0) {
|
||||
terrno = ret;
|
||||
return NULL;
|
||||
}
|
||||
*pContLen = contLen;
|
||||
|
@ -401,6 +404,8 @@ static int32_t mndAddKillCompactAction(SMnode *pMnode, STrans *pTrans, SVgObj *p
|
|||
action.contLen = contLen;
|
||||
action.msgType = TDMT_VND_KILL_COMPACT;
|
||||
|
||||
mTrace("trans:%d, kill compact msg len:%d", pTrans->id, contLen);
|
||||
|
||||
if ((code = mndTransAppendRedoAction(pTrans, &action)) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
TAOS_RETURN(code);
|
||||
|
|
|
@ -160,7 +160,7 @@ int32_t metaAlterSuperTable(SMeta* pMeta, int64_t version, SVCreateStbRe
|
|||
int32_t metaDropSuperTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
||||
int32_t metaCreateTable2(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq, STableMetaRsp** ppRsp);
|
||||
int32_t metaDropTable2(SMeta* pMeta, int64_t version, SVDropTbReq* pReq);
|
||||
int32_t metaTrimTables(SMeta* pMeta);
|
||||
int32_t metaTrimTables(SMeta* pMeta, int64_t version);
|
||||
int32_t metaDropMultipleTables(SMeta* pMeta, int64_t version, SArray* tbUids);
|
||||
int metaTtlFindExpired(SMeta* pMeta, int64_t timePointMs, SArray* tbUids, int32_t ttlDropMaxCount);
|
||||
int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq, STableMetaRsp* pMetaRsp);
|
||||
|
|
|
@ -1645,7 +1645,6 @@ static int32_t metaHandleSuperTableUpdate(SMeta *pMeta, const SMetaEntry *pEntry
|
|||
metaFetchEntryFree(&pOldEntry);
|
||||
return code;
|
||||
}
|
||||
// TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pEntry->uid, uids));
|
||||
TAOS_CHECK_RETURN(tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type));
|
||||
} else if (deltaCol == -1) {
|
||||
int16_t cid = -1;
|
||||
|
@ -1667,7 +1666,6 @@ static int32_t metaHandleSuperTableUpdate(SMeta *pMeta, const SMetaEntry *pEntry
|
|||
metaFetchEntryFree(&pOldEntry);
|
||||
return code;
|
||||
}
|
||||
// TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pEntry->uid, uids));
|
||||
TAOS_CHECK_RETURN(tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,7 +325,6 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
|||
ctx->suidInfo = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
if (ctx->suidInfo == NULL) {
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
;
|
||||
}
|
||||
taosHashSetFreeFp(ctx->suidInfo, destroySTableInfoForChildTable);
|
||||
|
||||
|
|
|
@ -151,11 +151,8 @@ void tqClose(STQ* pTq) {
|
|||
taosHashCleanup(pTq->pOffset);
|
||||
taosMemoryFree(pTq->path);
|
||||
tqMetaClose(pTq);
|
||||
|
||||
int32_t vgId = pTq->pStreamMeta->vgId;
|
||||
qDebug("vgId:%d end to close tq", pTq->pStreamMeta != NULL ? pTq->pStreamMeta->vgId : -1);
|
||||
streamMetaClose(pTq->pStreamMeta);
|
||||
|
||||
qDebug("vgId:%d end to close tq", vgId);
|
||||
taosMemoryFree(pTq);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,36 +17,41 @@
|
|||
#include "tq.h"
|
||||
|
||||
int32_t tqBuildFName(char** data, const char* path, char* name) {
|
||||
if (data == NULL || path == NULL || name == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
char* fname = NULL;
|
||||
TSDB_CHECK_NULL(data, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(path, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(name, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
int32_t len = strlen(path) + strlen(name) + 2;
|
||||
char* fname = taosMemoryCalloc(1, len);
|
||||
if(fname == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
int32_t code = tsnprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
||||
if (code < 0){
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosMemoryFree(fname);
|
||||
return code;
|
||||
}
|
||||
fname = taosMemoryCalloc(1, len);
|
||||
TSDB_CHECK_NULL(fname, code, lino, END, terrno);
|
||||
(void)tsnprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
||||
|
||||
*data = fname;
|
||||
return TDB_CODE_SUCCESS;
|
||||
fname = NULL;
|
||||
|
||||
END:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
taosMemoryFree(fname);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name) {
|
||||
if (pTq == NULL || name == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = TDB_CODE_SUCCESS;
|
||||
void* pMemBuf = NULL;
|
||||
int32_t code = TDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
void* pMemBuf = NULL;
|
||||
TdFilePtr pFile = NULL;
|
||||
STqOffset *pOffset = NULL;
|
||||
void *pIter = NULL;
|
||||
|
||||
TdFilePtr pFile = taosOpenFile(name, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TDB_CODE_SUCCESS;
|
||||
goto END;
|
||||
}
|
||||
TSDB_CHECK_NULL(pTq, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(name, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
|
||||
pFile = taosOpenFile(name, TD_FILE_READ);
|
||||
TSDB_CHECK_NULL(pFile, code, lino, END, TDB_CODE_SUCCESS);
|
||||
|
||||
int64_t ret = 0;
|
||||
int32_t size = 0;
|
||||
|
@ -60,48 +65,41 @@ int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name) {
|
|||
}
|
||||
total += INT_BYTES;
|
||||
size = htonl(size);
|
||||
if (size <= 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto END;
|
||||
}
|
||||
pMemBuf = taosMemoryCalloc(1, size);
|
||||
if (pMemBuf == NULL) {
|
||||
code = terrno;
|
||||
goto END;
|
||||
}
|
||||
TSDB_CHECK_CONDITION(size > 0, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
|
||||
if (taosReadFile(pFile, pMemBuf, size) != size) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto END;
|
||||
}
|
||||
pMemBuf = taosMemoryCalloc(1, size);
|
||||
TSDB_CHECK_NULL(pMemBuf, code, lino, END, terrno);
|
||||
TSDB_CHECK_CONDITION(taosReadFile(pFile, pMemBuf, size) == size, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
|
||||
total += size;
|
||||
STqOffset offset = {0};
|
||||
TQ_ERR_GO_TO_END(tqMetaDecodeOffsetInfo(&offset, pMemBuf, size));
|
||||
code = taosHashPut(pTq->pOffset, offset.subKey, strlen(offset.subKey), &offset, sizeof(STqOffset));
|
||||
if (code != TDB_CODE_SUCCESS) {
|
||||
tDeleteSTqOffset(&offset);
|
||||
goto END;
|
||||
}
|
||||
code = tqMetaDecodeOffsetInfo(&offset, pMemBuf, size);
|
||||
TSDB_CHECK_CODE(code, lino, END);
|
||||
pOffset = &offset;
|
||||
code = taosHashPut(pTq->pOffset, pOffset->subKey, strlen(pOffset->subKey), pOffset, sizeof(STqOffset));
|
||||
TSDB_CHECK_CODE(code, lino, END);
|
||||
pOffset = NULL;
|
||||
|
||||
tqInfo("tq: offset restore from file to tdb, size:%d, hash size:%d subkey:%s", total, taosHashGetSize(pTq->pOffset), offset.subKey);
|
||||
taosMemoryFree(pMemBuf);
|
||||
pMemBuf = NULL;
|
||||
}
|
||||
|
||||
void *pIter = NULL;
|
||||
while ((pIter = taosHashIterate(pTq->pOffset, pIter))) {
|
||||
STqOffset* pOffset = (STqOffset*)pIter;
|
||||
code = tqMetaSaveOffset(pTq, pOffset);
|
||||
if(code != 0){
|
||||
taosHashCancelIterate(pTq->pOffset, pIter);
|
||||
goto END;
|
||||
}
|
||||
STqOffset* offset = (STqOffset*)pIter;
|
||||
code = tqMetaSaveOffset(pTq, offset);
|
||||
TSDB_CHECK_CODE(code, lino, END);
|
||||
}
|
||||
|
||||
END:
|
||||
taosCloseFile(&pFile);
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
(void)taosCloseFile(&pFile);
|
||||
taosMemoryFree(pMemBuf);
|
||||
|
||||
tDeleteSTqOffset(pOffset);
|
||||
taosHashCancelIterate(pTq->pOffset, pIter);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -796,7 +796,8 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
sourceIdx++;
|
||||
} else if (pCol->cid == pColData->info.colId) {
|
||||
for (int32_t i = 0; i < pCol->nVal; i++) {
|
||||
tColDataGetValue(pCol, i, &colVal);
|
||||
code = tColDataGetValue(pCol, i, &colVal);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
code = doSetVal(pColData, i, &colVal);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
|
@ -937,7 +938,7 @@ static int32_t tqProcessColData(STqReader* pReader, SSubmitTbData* pSubmitTbData
|
|||
pCol = taosArrayGet(pCols, j);
|
||||
TQ_NULL_GO_TO_END(pCol);
|
||||
SColVal colVal = {0};
|
||||
tColDataGetValue(pCol, i, &colVal);
|
||||
TQ_ERR_GO_TO_END(tColDataGetValue(pCol, i, &colVal));
|
||||
PROCESS_VAL
|
||||
}
|
||||
|
||||
|
@ -961,7 +962,7 @@ static int32_t tqProcessColData(STqReader* pReader, SSubmitTbData* pSubmitTbData
|
|||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
|
||||
TQ_NULL_GO_TO_END(pColData);
|
||||
SColVal colVal = {0};
|
||||
tColDataGetValue(pCol, i, &colVal);
|
||||
TQ_ERR_GO_TO_END(tColDataGetValue(pCol, i, &colVal));
|
||||
SET_DATA
|
||||
}
|
||||
|
||||
|
|
|
@ -27,18 +27,16 @@ struct STqSnapReader {
|
|||
};
|
||||
|
||||
int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, int8_t type, STqSnapReader** ppReader) {
|
||||
if (pTq == NULL || ppReader == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
STqSnapReader* pReader = NULL;
|
||||
TSDB_CHECK_NULL(pTq, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(ppReader, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
|
||||
// alloc
|
||||
pReader = (STqSnapReader*)taosMemoryCalloc(1, sizeof(STqSnapReader));
|
||||
if (pReader == NULL) {
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_NULL(pReader, code, lino, end, terrno);
|
||||
|
||||
pReader->pTq = pTq;
|
||||
pReader->sver = sver;
|
||||
pReader->ever = ever;
|
||||
|
@ -54,28 +52,21 @@ int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, int8_t type, STqS
|
|||
pTb = pTq->pOffsetStore;
|
||||
} else {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _err;
|
||||
goto end;
|
||||
}
|
||||
code = tdbTbcOpen(pTb, &pReader->pCur, NULL);
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
code = tdbTbcMoveToFirst(pReader->pCur);
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
tqInfo("vgId:%d, vnode tq snapshot reader opene success", TD_VID(pTq->pVnode));
|
||||
*ppReader = pReader;
|
||||
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d, vnode tq snapshot reader open failed since %s", __func__, lino, tstrerror(code));
|
||||
taosMemoryFreeClear(pReader);
|
||||
}
|
||||
|
||||
tqInfo("vgId:%d, vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
||||
|
||||
*ppReader = pReader;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -84,45 +75,37 @@ void tqSnapReaderClose(STqSnapReader** ppReader) {
|
|||
return;
|
||||
}
|
||||
tdbTbcClose((*ppReader)->pCur);
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
taosMemoryFreeClear(*ppReader);
|
||||
}
|
||||
|
||||
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
||||
if (pReader == NULL || ppData == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
void* pKey = NULL;
|
||||
void* pVal = NULL;
|
||||
int32_t kLen = 0;
|
||||
int32_t vLen = 0;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
void* pKey = NULL;
|
||||
void* pVal = NULL;
|
||||
int32_t kLen = 0;
|
||||
int32_t vLen = 0;
|
||||
TSDB_CHECK_NULL(pReader, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(ppData, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
|
||||
if (tdbTbcNext(pReader->pCur, &pKey, &kLen, &pVal, &vLen)) {
|
||||
goto _exit;
|
||||
}
|
||||
code = tdbTbcNext(pReader->pCur, &pKey, &kLen, &pVal, &vLen);
|
||||
TSDB_CHECK_CONDITION(code == 0, code, lino, end, TDB_CODE_SUCCESS);
|
||||
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + vLen);
|
||||
if (*ppData == NULL) {
|
||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_NULL(*ppData, code, lino, end, terrno);
|
||||
|
||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
||||
pHdr->type = pReader->type;
|
||||
pHdr->size = vLen;
|
||||
(void)memcpy(pHdr->data, pVal, vLen);
|
||||
tqInfo("vgId:%d, vnode tq snapshot read data, vLen:%d", TD_VID(pReader->pTq->pVnode), vLen);
|
||||
|
||||
_exit:
|
||||
end:
|
||||
if (code != 0) {
|
||||
tqError("%s failed at %d, vnode tq snapshot read data failed since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
tqInfo("vgId:%d, vnode snapshot tq read data, vLen:%d", TD_VID(pReader->pTq->pVnode), vLen);
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
tqError("vgId:%d, vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -135,135 +118,148 @@ struct STqSnapWriter {
|
|||
};
|
||||
|
||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||
if (pTq == NULL || ppWriter == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
STqSnapWriter* pWriter = NULL;
|
||||
|
||||
TSDB_CHECK_NULL(pTq, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(ppWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
|
||||
// alloc
|
||||
pWriter = (STqSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||
if (pWriter == NULL) {
|
||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
;
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_NULL(pWriter, code, lino, end, terrno);
|
||||
pWriter->pTq = pTq;
|
||||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
code = tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0);
|
||||
if (code < 0) {
|
||||
taosMemoryFree(pWriter);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
tqInfo("vgId:%d, tq snapshot writer opene success", TD_VID(pTq->pVnode));
|
||||
*ppWriter = pWriter;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppWriter = NULL;
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d tq snapshot writer open failed since %s", __func__, lino, tstrerror(code));
|
||||
taosMemoryFreeClear(pWriter);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||
if (ppWriter == NULL || *ppWriter == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
STqSnapWriter* pWriter = *ppWriter;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
STqSnapWriter* pWriter = NULL;
|
||||
|
||||
TSDB_CHECK_NULL(ppWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(*ppWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
pWriter = *ppWriter;
|
||||
|
||||
if (rollback) {
|
||||
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
} else {
|
||||
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
code = tdbPostCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
}
|
||||
tqInfo("vgId:%d, tq snapshot writer close success", TD_VID(pWriter->pTq->pVnode));
|
||||
taosMemoryFreeClear(*ppWriter);
|
||||
|
||||
taosMemoryFree(pWriter);
|
||||
*ppWriter = NULL;
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, tq snapshot writer close failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d, tq snapshot writer close failed since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapHandleWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
if (pWriter == NULL || pData == NULL || nData < sizeof(SSnapDataHdr)) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
static int32_t tqWriteCheck(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData){
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
TSDB_CHECK_NULL(pWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(pData, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_CONDITION(nData >= sizeof(SSnapDataHdr), code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d failed since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
int32_t code = 0;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
return code;
|
||||
}
|
||||
int32_t tqSnapHandleWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SDecoder decoder = {0};
|
||||
SDecoder* pDecoder = &decoder;
|
||||
STqHandle handle = {0};
|
||||
code = tqWriteCheck(pWriter, pData, nData);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
STQ* pTq = pWriter->pTq;
|
||||
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||
code = tDecodeSTqHandle(pDecoder, &handle);
|
||||
if (code) goto end;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
taosWLockLatch(&pTq->lock);
|
||||
code = tqMetaSaveInfo(pTq, pTq->pExecStore, handle.subKey, strlen(handle.subKey), pData + sizeof(SSnapDataHdr),
|
||||
nData - sizeof(SSnapDataHdr));
|
||||
taosWUnLockLatch(&pTq->lock);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
tqInfo("vgId:%d, vnode tq snapshot write success", TD_VID(pTq->pVnode));
|
||||
|
||||
end:
|
||||
tDecoderClear(pDecoder);
|
||||
tqDestroyTqHandle(&handle);
|
||||
tqInfo("vgId:%d, vnode snapshot tq write result:%d", TD_VID(pTq->pVnode), code);
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d, vnode tq snapshot write failed since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapCheckInfoWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
if (pWriter == NULL || pData == NULL || nData < sizeof(SSnapDataHdr)) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
|
||||
code = tqWriteCheck(pWriter, pData, nData);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
STQ* pTq = pWriter->pTq;
|
||||
STqCheckInfo info = {0};
|
||||
code = tqMetaDecodeCheckInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||
if (code != 0) {
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
code = tqMetaSaveInfo(pTq, pTq->pCheckStore, &info.topic, strlen(info.topic), pData + sizeof(SSnapDataHdr),
|
||||
nData - sizeof(SSnapDataHdr));
|
||||
tDeleteSTqCheckInfo(&info);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
tqInfo("vgId:%d, vnode tq check info write success", TD_VID(pTq->pVnode));
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, vnode check info tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d, vnode tq check info write failed since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapOffsetWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
if (pWriter == NULL || pData == NULL || nData < sizeof(SSnapDataHdr)) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
code = tqWriteCheck(pWriter, pData, nData);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
STQ* pTq = pWriter->pTq;
|
||||
STqOffset info = {0};
|
||||
code = tqMetaDecodeOffsetInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||
if (code != 0) {
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
code = tqMetaSaveInfo(pTq, pTq->pOffsetStore, info.subKey, strlen(info.subKey), pData + sizeof(SSnapDataHdr),
|
||||
nData - sizeof(SSnapDataHdr));
|
||||
tDeleteSTqOffset(&info);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
tqInfo("vgId:%d, vnode tq offset write success", TD_VID(pTq->pVnode));
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, vnode check info tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d, vnode tq offset write failed since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -1715,7 +1715,7 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo
|
|||
uint8_t colType = tColDataGetBitValue(pColData, tRow.iRow);
|
||||
if (colType == 2) {
|
||||
SColVal colVal = COL_VAL_NONE(pColData->cid, pColData->type);
|
||||
tColDataGetValue(pColData, tRow.iRow, &colVal);
|
||||
TAOS_CHECK_GOTO(tColDataGetValue(pColData, tRow.iRow, &colVal), &lino, _exit);
|
||||
|
||||
SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST, .tsdbRowKey = tsdbRowKey, .colVal = colVal};
|
||||
if (!taosArrayPush(ctxArray, &updateCtx)) {
|
||||
|
|
|
@ -123,7 +123,8 @@ static int32_t tColRowGetPriamyKeyDeepCopy(SBlockData* pBlock, int32_t irow, int
|
|||
|
||||
pColData = &pBlock->aColData[slotId];
|
||||
|
||||
tColDataGetValue(pColData, irow, &cv);
|
||||
code = tColDataGetValue(pColData, irow, &cv);
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pKey->numOfPKs = 1;
|
||||
pKey->pks[0].type = cv.value.type;
|
||||
|
@ -1603,7 +1604,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, SRowKey* pLastPro
|
|||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
} else { // varchar/nchar type
|
||||
for (int32_t j = pDumpInfo->rowIndex; rowIndex < dumpedRows; j += step) {
|
||||
tColDataGetValue(pData, j, &cv);
|
||||
code = tColDataGetValue(pData, j, &cv);
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
code = doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo);
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
@ -5282,7 +5284,8 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S
|
|||
|
||||
SColumnInfoData* pCol = TARRAY_GET_ELEM(pResBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
if (pData->cid == pSupInfo->colId[i]) {
|
||||
tColDataGetValue(pData, rowIndex, &cv);
|
||||
code = tColDataGetValue(pData, rowIndex, &cv);
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
code = doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo);
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
j += 1;
|
||||
|
@ -5791,7 +5794,6 @@ int32_t tsdbReaderSuspend2(STsdbReader* pReader) {
|
|||
|
||||
// make sure only release once
|
||||
void* p = pReader->pReadSnap;
|
||||
TSDB_CHECK_NULL(p, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
||||
if ((p == atomic_val_compare_exchange_ptr((void**)&pReader->pReadSnap, p, NULL)) && (p != NULL)) {
|
||||
tsdbUntakeReadSnap2(pReader, p, false);
|
||||
pReader->pReadSnap = NULL;
|
||||
|
|
|
@ -622,7 +622,9 @@ void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *
|
|||
SColData *pColData = tBlockDataGetColData(pRow->pBlockData, pTColumn->colId);
|
||||
|
||||
if (pColData) {
|
||||
tColDataGetValue(pColData, pRow->iRow, pColVal);
|
||||
if (tColDataGetValue(pColData, pRow->iRow, pColVal) != 0){
|
||||
tsdbError("failed to tColDataGetValue");
|
||||
}
|
||||
} else {
|
||||
*pColVal = COL_VAL_NONE(pTColumn->colId, pTColumn->type);
|
||||
}
|
||||
|
@ -645,7 +647,9 @@ void tColRowGetPrimaryKey(SBlockData *pBlock, int32_t irow, SRowKey *key) {
|
|||
SColData *pColData = &pBlock->aColData[i];
|
||||
if (pColData->cflag & COL_IS_KEY) {
|
||||
SColVal cv;
|
||||
tColDataGetValue(pColData, irow, &cv);
|
||||
if (tColDataGetValue(pColData, irow, &cv) != 0){
|
||||
break;
|
||||
}
|
||||
key->pks[key->numOfPKs] = cv.value;
|
||||
key->numOfPKs++;
|
||||
} else {
|
||||
|
@ -719,7 +723,9 @@ SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
|
|||
}
|
||||
|
||||
if (pIter->iColData <= pIter->pRow->pBlockData->nColData) {
|
||||
tColDataGetValue(&pIter->pRow->pBlockData->aColData[pIter->iColData - 1], pIter->pRow->iRow, &pIter->cv);
|
||||
if (tColDataGetValue(&pIter->pRow->pBlockData->aColData[pIter->iColData - 1], pIter->pRow->iRow, &pIter->cv) != 0){
|
||||
return NULL;
|
||||
}
|
||||
++pIter->iColData;
|
||||
return &pIter->cv;
|
||||
} else {
|
||||
|
@ -1251,7 +1257,8 @@ static int32_t tBlockDataUpsertBlockRow(SBlockData *pBlockData, SBlockData *pBlo
|
|||
cv = COL_VAL_NONE(pColDataTo->cid, pColDataTo->type);
|
||||
if (flag == 0 && (code = tColDataAppendValue(pColDataTo, &cv))) goto _exit;
|
||||
} else {
|
||||
tColDataGetValue(pColDataFrom, iRow, &cv);
|
||||
code = tColDataGetValue(pColDataFrom, iRow, &cv);
|
||||
if (code) goto _exit;
|
||||
|
||||
if (flag) {
|
||||
code = tColDataUpdateValue(pColDataTo, &cv, flag > 0);
|
||||
|
|
|
@ -243,7 +243,7 @@ int32_t vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
code = TSDB_CODE_VND_HASH_MISMATCH;
|
||||
goto _exit;
|
||||
} else if (mer1.me.type == TSDB_CHILD_TABLE) {
|
||||
metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_LOCK);
|
||||
metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_NOLOCK);
|
||||
if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit;
|
||||
|
||||
tstrncpy(cfgRsp.stbName, mer2.me.name, TSDB_TABLE_NAME_LEN);
|
||||
|
@ -279,7 +279,8 @@ int32_t vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
}
|
||||
} else {
|
||||
vError("vnodeGetTableCfg get invalid table type:%d", mer1.me.type);
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
cfgRsp.numOfTags = schemaTag.nCols;
|
||||
|
|
|
@ -607,9 +607,9 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg
|
|||
}
|
||||
|
||||
vDebug("vgId:%d, start to process write request %s, index:%" PRId64 ", applied:%" PRId64 ", state.applyTerm:%" PRId64
|
||||
", conn.applyTerm:%" PRId64,
|
||||
", conn.applyTerm:%" PRId64 ", contLen:%d",
|
||||
TD_VID(pVnode), TMSG_INFO(pMsg->msgType), ver, pVnode->state.applied, pVnode->state.applyTerm,
|
||||
pMsg->info.conn.applyTerm);
|
||||
pMsg->info.conn.applyTerm, pMsg->contLen);
|
||||
|
||||
if (!(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm)) {
|
||||
return terrno = TSDB_CODE_INTERNAL_ERROR;
|
||||
|
@ -843,7 +843,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
SReadHandle handle = {.vnode = pVnode, .pMsgCb = &pVnode->msgCb, .pWorkerCb = pInfo->workerCb};
|
||||
initStorageAPI(&handle.api);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
bool redirected = false;
|
||||
bool redirected = false;
|
||||
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_SCH_QUERY:
|
||||
|
@ -2145,7 +2145,7 @@ static int32_t vnodeConsolidateAlterHashRange(SVnode *pVnode, int64_t ver) {
|
|||
pVnode->config.hashBegin, pVnode->config.hashEnd, ver);
|
||||
|
||||
// TODO: trim meta of tables from TDB per hash range [pVnode->config.hashBegin, pVnode->config.hashEnd]
|
||||
code = metaTrimTables(pVnode->pMeta);
|
||||
code = metaTrimTables(pVnode->pMeta, ver);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
MESSAGE(STATUS "vnode unit test")
|
||||
MESSAGE(STATUS "tq unit test")
|
||||
|
||||
# GoogleTest requires at least C++11
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||
|
||||
# add_executable(tqTest "")
|
||||
# target_sources(tqTest
|
||||
# PRIVATE
|
||||
# "tqMetaTest.cpp"
|
||||
# )
|
||||
# target_include_directories(tqTest
|
||||
# PUBLIC
|
||||
# "${TD_SOURCE_DIR}/include/server/vnode/tq"
|
||||
# "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
# )
|
||||
IF(NOT TD_WINDOWS)
|
||||
add_executable(tqTest tqTest.cpp)
|
||||
target_include_directories(tqTest
|
||||
PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
)
|
||||
|
||||
# target_link_libraries(tqTest
|
||||
# tq
|
||||
# gtest_main
|
||||
# )
|
||||
# enable_testing()
|
||||
# add_test(
|
||||
# NAME tq_test
|
||||
# COMMAND tqTest
|
||||
# )
|
||||
TARGET_LINK_LIBRARIES(
|
||||
tqTest
|
||||
PUBLIC os util common vnode gtest_main
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(
|
||||
NAME tq_test
|
||||
COMMAND tqTest
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# ADD_EXECUTABLE(tsdbSmaTest tsdbSmaTest.cpp)
|
||||
# TARGET_LINK_LIBRARIES(
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <vnodeInt.h>
|
||||
|
||||
#include <taoserror.h>
|
||||
#include <tglobal.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <tmsg.h>
|
||||
#include <vnodeInt.h>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
|
||||
SDmNotifyHandle dmNotifyHdl = {.state = 0};
|
||||
|
||||
#include "tq.h"
|
||||
int main(int argc, char **argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
void tqWriteOffset() {
|
||||
TdFilePtr pFile = taosOpenFile(TQ_OFFSET_NAME, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||
|
||||
STqOffset offset = {.val = {.type = TMQ_OFFSET__LOG, .version = 8923}};
|
||||
strcpy(offset.subKey, "testtest");
|
||||
int32_t bodyLen;
|
||||
int32_t code;
|
||||
tEncodeSize(tEncodeSTqOffset, &offset, bodyLen, code);
|
||||
int32_t totLen = INT_BYTES + bodyLen;
|
||||
void* buf = taosMemoryCalloc(1, totLen);
|
||||
void* abuf = POINTER_SHIFT(buf, INT_BYTES);
|
||||
|
||||
*(int32_t*)buf = htonl(bodyLen);
|
||||
SEncoder encoder;
|
||||
tEncoderInit(&encoder, (uint8_t*)abuf, bodyLen);
|
||||
tEncodeSTqOffset(&encoder, &offset);
|
||||
taosWriteFile(pFile, buf, totLen);
|
||||
|
||||
taosMemoryFree(buf);
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
}
|
||||
|
||||
TEST(testCase, tqOffsetTest) {
|
||||
STQ* pTq = (STQ*)taosMemoryCalloc(1, sizeof(STQ));
|
||||
pTq->path = taosStrdup("./");
|
||||
|
||||
pTq->pOffset = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_ENTRY_LOCK);
|
||||
taosHashSetFreeFp(pTq->pOffset, (FDelete)tDeleteSTqOffset);
|
||||
|
||||
tdbOpen(pTq->path, 16 * 1024, 1, &pTq->pMetaDB, 0, 0, NULL);
|
||||
tdbTbOpen("tq.offset.db", -1, -1, NULL, pTq->pMetaDB, &pTq->pOffsetStore, 0);
|
||||
|
||||
tqWriteOffset();
|
||||
tqOffsetRestoreFromFile(pTq, TQ_OFFSET_NAME);
|
||||
taosRemoveFile(TQ_OFFSET_NAME);
|
||||
tqClose(pTq);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
|
@ -11,6 +11,6 @@ target_link_libraries(
|
|||
PRIVATE os util transport qcom nodes
|
||||
)
|
||||
|
||||
#if(${BUILD_TEST})
|
||||
# ADD_SUBDIRECTORY(test)
|
||||
#endif(${BUILD_TEST})
|
||||
if(${BUILD_TEST} AND NOT ${TD_WINDOWS})
|
||||
ADD_SUBDIRECTORY(test)
|
||||
endif()
|
||||
|
|
|
@ -424,6 +424,7 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
|
|||
CTG_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t ctgGetTbTag(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pRes) {
|
||||
SVgroupInfo vgroupInfo = {0};
|
||||
STableCfg* pCfg = NULL;
|
||||
|
@ -474,6 +475,7 @@ _return:
|
|||
|
||||
CTG_RET(code);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pVgList) {
|
||||
STableMeta* tbMeta = NULL;
|
||||
|
@ -1695,6 +1697,7 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t catalogGetTableTag(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
|
@ -1709,6 +1712,7 @@ _return:
|
|||
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** pCfg) {
|
||||
CTG_API_ENTER();
|
||||
|
@ -1845,7 +1849,7 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
int32_t catalogAsyncUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
|
@ -1860,6 +1864,7 @@ _return:
|
|||
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t catalogGetViewMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pViewName, STableMeta** pTableMeta) {
|
||||
CTG_API_ENTER();
|
||||
|
@ -1981,10 +1986,19 @@ void catalogDestroy(void) {
|
|||
}
|
||||
|
||||
if (gCtgMgmt.cacheTimer) {
|
||||
if (taosTmrStop(gCtgMgmt.cacheTimer)) {
|
||||
qTrace("stop catalog cache timer may failed");
|
||||
if (!taosTmrStop(gCtgMgmt.cacheTimer)) {
|
||||
/*
|
||||
qDebug("catalog cacheTimer %" PRIuPTR " not stopped", (uintptr_t)gCtgMgmt.cacheTimer);
|
||||
|
||||
while (!taosTmrIsStopped(&gCtgMgmt.cacheTimer)) {
|
||||
taosMsleep(1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
qDebug("catalog cacheTimer %" PRIuPTR " is stopped", (uintptr_t)gCtgMgmt.cacheTimer);
|
||||
gCtgMgmt.cacheTimer = NULL;
|
||||
|
||||
taosTmrCleanUp(gCtgMgmt.timer);
|
||||
gCtgMgmt.timer = NULL;
|
||||
}
|
||||
|
|
|
@ -480,6 +480,8 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) {
|
|||
|
||||
dbCache = (SCtgDBCache *)pIter;
|
||||
|
||||
CTG_LOCK(CTG_READ, &dbCache->dbLock);
|
||||
|
||||
dbFName = taosHashGetKey(pIter, &len);
|
||||
|
||||
int32_t metaNum = dbCache->tbCache ? taosHashGetSize(dbCache->tbCache) : 0;
|
||||
|
@ -509,6 +511,8 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) {
|
|||
hashMethod, hashPrefix, hashSuffix, vgNum);
|
||||
|
||||
if (dbCache->vgCache.vgInfo) {
|
||||
CTG_LOCK(CTG_READ, &dbCache->vgCache.vgLock);
|
||||
|
||||
int32_t i = 0;
|
||||
void *pVgIter = taosHashIterate(dbCache->vgCache.vgInfo->vgHash, NULL);
|
||||
while (pVgIter) {
|
||||
|
@ -524,6 +528,8 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) {
|
|||
|
||||
pVgIter = taosHashIterate(dbCache->vgCache.vgInfo->vgHash, pVgIter);
|
||||
}
|
||||
|
||||
CTG_UNLOCK(CTG_READ, &dbCache->vgCache.vgLock);
|
||||
}
|
||||
|
||||
if (dbCache->cfgCache.cfgInfo) {
|
||||
|
@ -544,6 +550,8 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) {
|
|||
pCfg->schemaless, pCfg->sstTrigger);
|
||||
}
|
||||
|
||||
CTG_UNLOCK(CTG_READ, &dbCache->dbLock);
|
||||
|
||||
++i;
|
||||
pIter = taosHashIterate(dbHash, pIter);
|
||||
}
|
||||
|
|
|
@ -149,12 +149,13 @@ void ctgTestInitLogFile() {
|
|||
return;
|
||||
}
|
||||
|
||||
const char *defaultLogFileNamePrefix = "taoslog";
|
||||
const char *defaultLogFileNamePrefix = "catalogTest";
|
||||
const int32_t maxLogFileNum = 10;
|
||||
|
||||
tsAsyncLog = 0;
|
||||
qDebugFlag = 159;
|
||||
tmrDebugFlag = 159;
|
||||
tsNumOfLogLines = 1000000000;
|
||||
TAOS_STRCPY(tsLogDir, TD_LOG_DIR_PATH);
|
||||
|
||||
(void)ctgdEnableDebug("api", true);
|
||||
|
@ -1839,7 +1840,7 @@ TEST(tableMeta, updateStbMeta) {
|
|||
while (true) {
|
||||
uint64_t n = 0;
|
||||
ASSERT(0 == ctgdGetStatNum("runtime.numOfOpDequeue", (void *)&n));
|
||||
if (n != 3) {
|
||||
if (n < 3) {
|
||||
taosMsleep(50);
|
||||
} else {
|
||||
break;
|
||||
|
@ -2992,6 +2993,7 @@ TEST(apiTest, catalogGetTableIndex_test) {
|
|||
catalogDestroy();
|
||||
}
|
||||
|
||||
|
||||
TEST(apiTest, catalogGetDBCfg_test) {
|
||||
struct SCatalog *pCtg = NULL;
|
||||
SRequestConnInfo connInfo = {0};
|
||||
|
|
|
@ -83,6 +83,8 @@ int32_t hInnerJoinDo(struct SOperatorInfo* pOperator) {
|
|||
return code;
|
||||
}
|
||||
|
||||
#ifdef HASH_JOIN_FULL
|
||||
|
||||
int32_t hLeftJoinHandleSeqRowRemains(struct SOperatorInfo* pOperator, SHJoinOperatorInfo* pJoin, bool* loopCont) {
|
||||
bool allFetched = false;
|
||||
SHJoinCtx* pCtx = &pJoin->ctx;
|
||||
|
@ -346,4 +348,5 @@ int32_t hLeftJoinDo(struct SOperatorInfo* pOperator) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ int32_t hJoinSetImplFp(SHJoinOperatorInfo* pJoin) {
|
|||
case JOIN_TYPE_RIGHT: {
|
||||
switch (pJoin->subType) {
|
||||
case JOIN_STYPE_OUTER:
|
||||
pJoin->joinFp = hLeftJoinDo;
|
||||
//pJoin->joinFp = hLeftJoinDo; TOOPEN
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -44,3 +44,15 @@ TARGET_INCLUDE_DIRECTORIES(
|
|||
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(execUtilTests execUtilTests.cpp)
|
||||
TARGET_LINK_LIBRARIES(
|
||||
execUtilTests
|
||||
PRIVATE os util common executor gtest_main qcom function planner scalar nodes vnode
|
||||
)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(
|
||||
execUtilTests
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
)
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "executil.h"
|
||||
|
||||
TEST(execUtilTest, resRowTest) {
|
||||
SDiskbasedBuf *pBuf = nullptr;
|
||||
int32_t pageSize = 32;
|
||||
int32_t numPages = 3;
|
||||
int32_t code = createDiskbasedBuf(&pBuf, pageSize, pageSize * numPages, "test_buf", "/");
|
||||
EXPECT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
std::vector<void *> pages(numPages);
|
||||
std::vector<int32_t> pageIds(numPages);
|
||||
for (int32_t i = 0; i < numPages; ++i) {
|
||||
pages[i] = getNewBufPage(pBuf, &pageIds[i]);
|
||||
EXPECT_NE(pages[i], nullptr);
|
||||
EXPECT_EQ(pageIds[i], i);
|
||||
}
|
||||
|
||||
EXPECT_EQ(getNewBufPage(pBuf, nullptr), nullptr);
|
||||
|
||||
SResultRowPosition pos;
|
||||
pos.offset = 0;
|
||||
for (int32_t i = 0; i < numPages; ++i) {
|
||||
pos.pageId = pageIds[i];
|
||||
bool forUpdate = i & 0x1;
|
||||
SResultRow *row = getResultRowByPos(pBuf, &pos, forUpdate);
|
||||
EXPECT_EQ((void *)row, pages[i]);
|
||||
}
|
||||
|
||||
pos.pageId = numPages + 1;
|
||||
EXPECT_EQ(getResultRowByPos(pBuf, &pos, true), nullptr);
|
||||
|
||||
destroyDiskbasedBuf(pBuf);
|
||||
}
|
|
@ -41,6 +41,7 @@
|
|||
#include "tvariant.h"
|
||||
#include "stub.h"
|
||||
#include "querytask.h"
|
||||
#include "hashjoin.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
@ -3766,6 +3767,21 @@ TEST(leftWinJoin, noCondProjectionTest) {
|
|||
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
TEST(functionsTest, branch) {
|
||||
struct SOperatorInfo op = {0};
|
||||
SHJoinOperatorInfo join;
|
||||
SBufRowInfo bufrow = {0};
|
||||
SSDataBlock blk = {0};
|
||||
|
||||
op.info = &join;
|
||||
memset(&join, 0, sizeof(join));
|
||||
join.ctx.pBuildRow = &bufrow;
|
||||
blk.info.rows = 1;
|
||||
join.finBlk = &blk;
|
||||
hInnerJoinDo(&op);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
|
|
@ -142,6 +142,50 @@ target_link_libraries(
|
|||
udf2_dup PUBLIC os ${LINK_JEMALLOC}
|
||||
)
|
||||
|
||||
set(TARGET_NAMES
|
||||
change_udf_normal
|
||||
change_udf_no_init
|
||||
change_udf_no_process
|
||||
change_udf_no_destroy
|
||||
change_udf_init_failed
|
||||
change_udf_process_failed
|
||||
change_udf_destory_failed
|
||||
)
|
||||
|
||||
set(COMPILE_DEFINITIONS
|
||||
CHANGE_UDF_NORMAL
|
||||
CHANGE_UDF_NO_INIT
|
||||
CHANGE_UDF_NO_PROCESS
|
||||
CHANGE_UDF_NO_DESTROY
|
||||
CHANGE_UDF_INIT_FAILED
|
||||
CHANGE_UDF_PROCESS_FAILED
|
||||
CHANGE_UDF_DESTORY_FAILED
|
||||
)
|
||||
|
||||
foreach(index RANGE 0 6)
|
||||
list(GET TARGET_NAMES ${index} target_name)
|
||||
list(GET COMPILE_DEFINITIONS ${index} compile_def)
|
||||
|
||||
add_library(${target_name} STATIC MODULE test/change_udf.c)
|
||||
target_include_directories(
|
||||
${target_name}
|
||||
PUBLIC
|
||||
"${TD_SOURCE_DIR}/include/libs/function"
|
||||
"${TD_SOURCE_DIR}/include/util"
|
||||
"${TD_SOURCE_DIR}/include/common"
|
||||
"${TD_SOURCE_DIR}/include/client"
|
||||
"${TD_SOURCE_DIR}/include/os"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_compile_definitions(${target_name} PRIVATE ${compile_def})
|
||||
IF(TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||
ADD_DEPENDENCIES(${target_name} jemalloc)
|
||||
ENDIF()
|
||||
target_link_libraries(
|
||||
${target_name} PUBLIC os ${LINK_JEMALLOC}
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
|
||||
add_executable(udfd src/udfd.c)
|
||||
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef LINUX
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "taosudf.h"
|
||||
|
||||
// rename function name
|
||||
#ifdef CHANGE_UDF_NORMAL
|
||||
#define UDFNAME change_udf_normal
|
||||
#define UDFNAMEINIT change_udf_normal_init
|
||||
#define UDFNAMEDESTROY change_udf_normal_destroy
|
||||
#elif defined(CHANGE_UDF_NO_INIT)
|
||||
#define UDFNAME change_udf_no_init
|
||||
#define UDFNAMEINIT change_udf_no_init_init
|
||||
#define UDFNAMEDESTROY change_udf_no_init_destroy
|
||||
#elif defined(CHANGE_UDF_NO_PROCESS)
|
||||
#define UDFNAME change_udf_no_process
|
||||
#define UDFNAMEINIT change_udf_no_process_init
|
||||
#define UDFNAMEDESTROY change_udf_no_process_destroy
|
||||
#elif defined(CHANGE_UDF_NO_DESTROY)
|
||||
#define UDFNAME change_udf_no_destroy
|
||||
#define UDFNAMEINIT change_udf_no_destroy_init
|
||||
#define UDFNAMEDESTROY change_udf_no_destroy_destroy
|
||||
#elif defined(CHANGE_UDF_INIT_FAILED)
|
||||
#define UDFNAME change_udf_init_failed
|
||||
#define UDFNAMEINIT change_udf_init_failed_init
|
||||
#define UDFNAMEDESTROY change_udf_init_failed_destroy
|
||||
#elif defined(CHANGE_UDF_PROCESS_FAILED)
|
||||
#define UDFNAME change_udf_process_failed
|
||||
#define UDFNAMEINIT change_udf_process_failed_init
|
||||
#define UDFNAMEDESTROY change_udf_process_failed_destroy
|
||||
#elif defined(CHANGE_UDF_DESTORY_FAILED)
|
||||
#define UDFNAME change_udf_destory_failed
|
||||
#define UDFNAMEINIT change_udf_destory_failed_init
|
||||
#define UDFNAMEDESTROY change_udf_destory_failed_destroy
|
||||
#else
|
||||
#define UDFNAME change_udf_normal
|
||||
#define UDFNAMEINIT change_udf_normal_init
|
||||
#define UDFNAMEDESTROY change_udf_normal_destroy
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CHANGE_UDF_NO_INIT
|
||||
#else
|
||||
DLL_EXPORT int32_t UDFNAMEINIT() {
|
||||
#ifdef CHANGE_UDF_INIT_FAILED
|
||||
return -1;
|
||||
#else
|
||||
return 0;
|
||||
#endif // ifdef CHANGE_UDF_INIT_FAILED
|
||||
}
|
||||
#endif // ifdef CHANGE_UDF_NO_INIT
|
||||
|
||||
#ifdef CHANGE_UDF_NO_DESTROY
|
||||
#else
|
||||
DLL_EXPORT int32_t UDFNAMEDESTROY() {
|
||||
#ifdef CHANGE_UDF_DESTORY_FAILED
|
||||
return -1;
|
||||
#else
|
||||
return 0;
|
||||
#endif // ifdef CHANGE_UDF_DESTORY_FAILED
|
||||
}
|
||||
#endif // ifdef CHANGE_UDF_NO_DESTROY
|
||||
|
||||
#ifdef CHANGE_UDF_NO_PROCESS
|
||||
#else
|
||||
DLL_EXPORT int32_t UDFNAME(SUdfDataBlock *block, SUdfColumn *resultCol) {
|
||||
#ifdef CHANGE_UDF_PROCESS_FAILED
|
||||
return -1;
|
||||
#else
|
||||
int32_t code = 0;
|
||||
SUdfColumnData *resultData = &resultCol->colData;
|
||||
for (int32_t i = 0; i < block->numOfRows; ++i) {
|
||||
int j = 0;
|
||||
for (; j < block->numOfCols; ++j) {
|
||||
if (udfColDataIsNull(block->udfCols[j], i)) {
|
||||
code = udfColDataSetNull(resultCol, i);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == block->numOfCols) {
|
||||
int32_t luckyNum = 1;
|
||||
code = udfColDataSet(resultCol, i, (char *)&luckyNum, false);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
// to simulate actual processing delay by udf
|
||||
#ifdef LINUX
|
||||
usleep(1 * 1000); // usleep takes sleep time in us (1 millionth of a second)
|
||||
#endif // ifdef LINUX
|
||||
#ifdef WINDOWS
|
||||
Sleep(1);
|
||||
#endif // ifdef WINDOWS
|
||||
resultData->numOfRows = block->numOfRows;
|
||||
return 0;
|
||||
#endif // ifdef CHANGE_UDF_PROCESS_FAILED
|
||||
}
|
||||
#endif // ifdef CHANGE_UDF_NO_PROCESS
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************************************************************/
|
||||
// udf revert functions
|
||||
/********************************************************************************************************************/
|
||||
DLL_EXPORT int32_t udf_reverse_init() { return 0; }
|
||||
|
||||
DLL_EXPORT int32_t udf_reverse_destroy() { return 0; }
|
||||
|
||||
static void reverse_data(char* data, size_t len) {
|
||||
size_t i, j;
|
||||
char temp;
|
||||
for (i = 0, j = len - 1; i < j; i++, j--) {
|
||||
temp = data[i];
|
||||
data[i] = data[j];
|
||||
data[j] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
DLL_EXPORT int32_t udf_reverse(SUdfDataBlock *block, SUdfColumn *resultCol) {
|
||||
int32_t code = 0;
|
||||
SUdfColumnData *resultData = &resultCol->colData;
|
||||
for (int32_t i = 0; i < block->numOfRows; ++i) {
|
||||
int j = 0;
|
||||
for (; j < block->numOfCols; ++j) {
|
||||
if (udfColDataIsNull(block->udfCols[j], i)) {
|
||||
code = udfColDataSetNull(resultCol, i);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
int32_t oldLen = udfColDataGetDataLen(block->udfCols[j], i);
|
||||
char *pOldData = udfColDataGetData(block->udfCols[j], i);
|
||||
|
||||
|
||||
char *buff = malloc(sizeof(VarDataLenT) + oldLen);
|
||||
if (buff == NULL) {
|
||||
return -1;
|
||||
}
|
||||
((VarDataLenT *)buff)[0] = (VarDataLenT)oldLen;
|
||||
memcpy(buff, pOldData, oldLen + sizeof(VarDataLenT));
|
||||
reverse_data(buff + sizeof(VarDataLenT), oldLen);
|
||||
code = udfColDataSet(resultCol, i, buff, false);
|
||||
if (code != 0) {
|
||||
free(buff);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// to simulate actual processing delay by udf
|
||||
#ifdef LINUX
|
||||
usleep(1 * 1000); // usleep takes sleep time in us (1 millionth of a second)
|
||||
#endif
|
||||
#ifdef WINDOWS
|
||||
Sleep(1);
|
||||
#endif
|
||||
resultData->numOfRows = block->numOfRows;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -128,6 +128,86 @@ TEST(NodesTest, sort) {
|
|||
nodesDestroyList(l);
|
||||
}
|
||||
|
||||
TEST(NodesTest, match) {
|
||||
SNode* pOperator = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOperator);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
SOperatorNode* pOp = (SOperatorNode*)pOperator;
|
||||
SOperatorNode* pLeft = NULL;
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pLeft));
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, &pLeft->pLeft));
|
||||
((SValueNode*)(pLeft->pLeft))->literal = taosStrdup("10");
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, &pLeft->pRight));
|
||||
((SValueNode*)(pLeft->pRight))->literal = taosStrdup("5");
|
||||
pOp->pLeft = (SNode*)pLeft;
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, &pOp->pRight));
|
||||
((SValueNode*)(pOp->pRight))->literal = taosStrdup("3");
|
||||
pOp->opType = OP_TYPE_GREATER_THAN;
|
||||
|
||||
SNode* pOperatorClone = NULL;
|
||||
code = nodesCloneNode(pOperator, &pOperatorClone);
|
||||
ASSERT_TRUE(nodesMatchNode(pOperator, pOperatorClone));
|
||||
|
||||
SNode* pValue = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pValue);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
((SValueNode*)pValue)->literal = taosStrdup("10");
|
||||
ASSERT_FALSE(nodesMatchNode(pOperator, pValue));
|
||||
|
||||
SNode* pValueClone = NULL;
|
||||
code = nodesCloneNode(pValue, &pValueClone);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(nodesMatchNode(pValue, pValueClone));
|
||||
nodesDestroyNode(pValue);
|
||||
nodesDestroyNode(pValueClone);
|
||||
|
||||
SNode* pColumn = NULL, *pColumnClone = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN, &pColumn);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
strcpy(((SColumnNode*)pColumn)->colName, "column");
|
||||
strcpy(((SColumnNode*)pColumn)->tableName, "table");
|
||||
strcpy(((SColumnNode*)pColumn)->dbName, "db");
|
||||
strcpy(((SColumnNode*)pColumn)->node.aliasName, "column");
|
||||
ASSERT_FALSE(nodesMatchNode(pOperator, pColumn));
|
||||
code = nodesCloneNode(pColumn, &pColumnClone);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(nodesMatchNode(pColumn, pColumnClone));
|
||||
nodesDestroyNode(pColumn);
|
||||
nodesDestroyNode(pColumnClone);
|
||||
|
||||
SNode* pFunction = NULL, *pFunctionClone = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunction);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
((SFunctionNode*)pFunction)->funcId = 1;
|
||||
strcpy(((SFunctionNode*)pFunction)->functionName, "now");
|
||||
ASSERT_FALSE(nodesMatchNode(pOperator, pFunction));
|
||||
code = nodesCloneNode(pFunction, &pFunctionClone);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(nodesMatchNode(pFunction, pFunctionClone));
|
||||
nodesDestroyNode(pFunctionClone);
|
||||
nodesDestroyNode(pFunction);
|
||||
|
||||
SNode* pLogicCondition = NULL, *pLogicConditionClone = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCondition);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
((SLogicConditionNode*)pLogicCondition)->condType = LOGIC_COND_TYPE_AND;
|
||||
((SLogicConditionNode*)pLogicCondition)->pParameterList = NULL;
|
||||
code = nodesMakeList(&((SLogicConditionNode*)pLogicCondition)->pParameterList);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = nodesListAppend((SNodeList*)((SLogicConditionNode*)pLogicCondition)->pParameterList, pOperator);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = nodesListAppend(((SLogicConditionNode*)pLogicCondition)->pParameterList, pOperatorClone);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
code = nodesCloneNode(pLogicCondition, &pLogicConditionClone);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(nodesMatchNode(pLogicCondition, pLogicConditionClone));
|
||||
ASSERT_FALSE(nodesMatchNode(pLogicCondition, pFunctionClone));
|
||||
|
||||
nodesDestroyNode(pLogicCondition);
|
||||
nodesDestroyNode(pLogicConditionClone);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
|
@ -20,40 +20,32 @@
|
|||
|
||||
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
|
||||
int32_t msgBufLen) {
|
||||
SMsgBuf msg = {.buf = msgBuf, .len = msgBufLen};
|
||||
SToken sToken;
|
||||
int32_t code = 0;
|
||||
char* tbName = NULL;
|
||||
SMsgBuf msg = {.buf = msgBuf, .len = msgBufLen};
|
||||
SToken sToken = {0};
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
|
||||
NEXT_TOKEN(pTableName, sToken);
|
||||
|
||||
if (sToken.n == 0) {
|
||||
return buildInvalidOperationMsg(&msg, "empty table name");
|
||||
}
|
||||
|
||||
TSDB_CHECK_CONDITION(sToken.n != 0, code, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
code = insCreateSName(pName, &sToken, acctId, dbName, &msg);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
NEXT_TOKEN(pTableName, sToken);
|
||||
TSDB_CHECK_CONDITION(sToken.n <= 0, code, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
|
||||
if (sToken.n > 0) {
|
||||
return buildInvalidOperationMsg(&msg, "table name format is wrong");
|
||||
end:
|
||||
if (code != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSchema* pSchema, bool isTag) {
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool));
|
||||
if (NULL == pUseCols) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
TSDB_CHECK_NULL(pUseCols, code, lino, end, terrno);
|
||||
pBoundInfo->numOfBound = 0;
|
||||
int16_t lastColIdx = -1; // last column found
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(cols); ++i) {
|
||||
SSmlKv* kv = taosArrayGet(cols, i);
|
||||
|
@ -65,16 +57,9 @@ static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSche
|
|||
index = insFindCol(&sToken, 0, t, pSchema);
|
||||
}
|
||||
|
||||
if (index < 0) {
|
||||
uError("smlBoundColumnData. index:%d", index);
|
||||
code = TSDB_CODE_SML_INVALID_DATA;
|
||||
goto end;
|
||||
}
|
||||
if (pUseCols[index]) {
|
||||
uError("smlBoundColumnData. already set. index:%d", index);
|
||||
code = TSDB_CODE_SML_INVALID_DATA;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CONDITION(index >= 0, code, lino, end, TSDB_CODE_SML_INVALID_DATA);
|
||||
TSDB_CHECK_CONDITION(!pUseCols[index], code, lino, end, TSDB_CODE_SML_INVALID_DATA);
|
||||
|
||||
lastColIdx = index;
|
||||
pUseCols[index] = true;
|
||||
pBoundInfo->pColIndex[pBoundInfo->numOfBound] = index;
|
||||
|
@ -82,11 +67,30 @@ static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSche
|
|||
}
|
||||
|
||||
end:
|
||||
if (code != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
taosMemoryFree(pUseCols);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t smlMbsToUcs4(const char* mbs, size_t mbsLen, void** result, int32_t* resultLen, int32_t maxLen, void* charsetCxt){
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
void* pUcs4 = NULL;
|
||||
int32_t lino = 0;
|
||||
pUcs4 = taosMemoryCalloc(1, maxLen);
|
||||
TSDB_CHECK_NULL(pUcs4, code, lino, end, terrno);
|
||||
TSDB_CHECK_CONDITION(taosMbsToUcs4(mbs, mbsLen, (TdUcs4*)pUcs4, maxLen, resultLen, charsetCxt), code, lino, end, terrno);
|
||||
*result = pUcs4;
|
||||
pUcs4 = NULL;
|
||||
|
||||
end:
|
||||
if (code != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
taosMemoryFree(pUcs4);
|
||||
return code;
|
||||
}
|
||||
/**
|
||||
* @brief No json tag for schemaless
|
||||
*
|
||||
|
@ -99,75 +103,39 @@ end:
|
|||
*/
|
||||
static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchema, STag** ppTag, SArray** tagName,
|
||||
SMsgBuf* msg, void* charsetCxt) {
|
||||
SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal));
|
||||
if (!pTagArray) {
|
||||
return terrno;
|
||||
}
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal));
|
||||
TSDB_CHECK_NULL(pTagArray, code, lino, end, terrno);
|
||||
*tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||
if (!*tagName) {
|
||||
return terrno;
|
||||
}
|
||||
TSDB_CHECK_NULL(*tagName, code, lino, end, terrno);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
for (int i = 0; i < tags->numOfBound; ++i) {
|
||||
SSchema* pTagSchema = &pSchema[tags->pColIndex[i]];
|
||||
SSmlKv* kv = taosArrayGet(cols, i);
|
||||
if (kv == NULL){
|
||||
code = terrno;
|
||||
uError("SML smlBuildTagRow error kv is null");
|
||||
goto end;
|
||||
}
|
||||
if (kv->keyLen != strlen(pTagSchema->name) || memcmp(kv->key, pTagSchema->name, kv->keyLen) != 0 ||
|
||||
kv->type != pTagSchema->type) {
|
||||
code = TSDB_CODE_SML_INVALID_DATA;
|
||||
uError("SML smlBuildTagRow error col not same %s", pTagSchema->name);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (taosArrayPush(*tagName, pTagSchema->name) == NULL){
|
||||
code = terrno;
|
||||
uError("SML smlBuildTagRow error push tag name");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(kv, code, lino, end, terrno);
|
||||
bool cond = (kv->keyLen == strlen(pTagSchema->name) && memcmp(kv->key, pTagSchema->name, kv->keyLen) == 0 && kv->type == pTagSchema->type);
|
||||
TSDB_CHECK_CONDITION(cond, code, lino, end, TSDB_CODE_SML_INVALID_DATA);
|
||||
TSDB_CHECK_NULL(taosArrayPush(*tagName, pTagSchema->name), code, lino, end, terrno);
|
||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||
// strcpy(val.colName, pTagSchema->name);
|
||||
if (pTagSchema->type == TSDB_DATA_TYPE_BINARY || pTagSchema->type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
pTagSchema->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
val.pData = (uint8_t*)kv->value;
|
||||
val.nData = kv->length;
|
||||
} else if (pTagSchema->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t output = 0;
|
||||
void* p = taosMemoryCalloc(1, kv->length * TSDB_NCHAR_SIZE);
|
||||
if (p == NULL) {
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)(p), kv->length * TSDB_NCHAR_SIZE, &output, charsetCxt)) {
|
||||
if (terrno == TAOS_SYSTEM_ERROR(E2BIG)) {
|
||||
taosMemoryFree(p);
|
||||
code = generateSyntaxErrMsg(msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pTagSchema->name);
|
||||
goto end;
|
||||
}
|
||||
char buf[512] = {0};
|
||||
(void)snprintf(buf, tListLen(buf), " taosMbsToUcs4 error:%s", strerror(terrno));
|
||||
taosMemoryFree(p);
|
||||
code = buildSyntaxErrMsg(msg, buf, kv->value);
|
||||
goto end;
|
||||
}
|
||||
val.pData = p;
|
||||
val.nData = output;
|
||||
code = smlMbsToUcs4(kv->value, kv->length, (void**)&val.pData, (int32_t*)&val.nData, kv->length * TSDB_NCHAR_SIZE, charsetCxt);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
} else {
|
||||
(void)memcpy(&val.i64, &(kv->value), kv->length);
|
||||
}
|
||||
if (taosArrayPush(pTagArray, &val) == NULL){
|
||||
code = terrno;
|
||||
uError("SML smlBuildTagRow error push tag array");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(taosArrayPush(pTagArray, &val), code, lino, end, terrno);
|
||||
}
|
||||
|
||||
code = tTagNew(pTagArray, 1, false, ppTag);
|
||||
|
||||
end:
|
||||
if (code != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) {
|
||||
STagVal* p = (STagVal*)taosArrayGet(pTagArray, i);
|
||||
if (p->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
|
@ -179,18 +147,20 @@ end:
|
|||
}
|
||||
|
||||
int32_t smlInitTableDataCtx(SQuery* query, STableMeta* pTableMeta, STableDataCxt** cxt) {
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SVCreateTbReq* pCreateTbReq = NULL;
|
||||
int ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
||||
ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
||||
sizeof(pTableMeta->uid), pTableMeta, &pCreateTbReq, cxt, false, false);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
ret = initTableColSubmitData(*cxt);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
end:
|
||||
if (ret != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void clearColValArraySml(SArray* pCols) {
|
||||
|
@ -207,78 +177,51 @@ void clearColValArraySml(SArray* pCols) {
|
|||
}
|
||||
|
||||
int32_t smlBuildRow(STableDataCxt* pTableCxt) {
|
||||
SRow** pRow = taosArrayReserve(pTableCxt->pData->aRowP, 1);
|
||||
if (pRow == NULL){
|
||||
return terrno;
|
||||
}
|
||||
int ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
||||
if (TSDB_CODE_SUCCESS != ret) {
|
||||
return ret;
|
||||
}
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SRow** pRow = taosArrayReserve(pTableCxt->pData->aRowP, 1);
|
||||
TSDB_CHECK_NULL(pRow, ret, lino, end, terrno);
|
||||
ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
SRowKey key;
|
||||
tRowGetKey(*pRow, &key);
|
||||
insCheckTableDataOrder(pTableCxt, &key);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
end:
|
||||
if (ret != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32_t index, void* charsetCxt) {
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SSchema* pColSchema = schema + index;
|
||||
SColVal* pVal = taosArrayGet(pTableCxt->pValues, index);
|
||||
if (pVal == NULL) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
TSDB_CHECK_NULL(pVal, ret, lino, end, TSDB_CODE_SUCCESS);
|
||||
SSmlKv* kv = (SSmlKv*)data;
|
||||
if (kv->keyLen != strlen(pColSchema->name) || memcmp(kv->key, pColSchema->name, kv->keyLen) != 0 ||
|
||||
kv->type != pColSchema->type) {
|
||||
ret = TSDB_CODE_SML_INVALID_DATA;
|
||||
char* tmp = taosMemoryCalloc(kv->keyLen + 1, 1);
|
||||
if (tmp) {
|
||||
(void)memcpy(tmp, kv->key, kv->keyLen);
|
||||
uInfo("SML data(name:%s type:%s) is not same like the db data(name:%s type:%s)", tmp, tDataTypes[kv->type].name,
|
||||
pColSchema->name, tDataTypes[pColSchema->type].name);
|
||||
taosMemoryFree(tmp);
|
||||
} else {
|
||||
uError("SML smlBuildCol out of memory");
|
||||
ret = terrno;
|
||||
}
|
||||
TSDB_CHECK_NULL(tmp, ret, lino, end, terrno);
|
||||
(void)memcpy(tmp, kv->key, kv->keyLen);
|
||||
uInfo("SML data(name:%s type:%s) is not same like the db data(name:%s type:%s)", tmp, tDataTypes[kv->type].name,
|
||||
pColSchema->name, tDataTypes[pColSchema->type].name);
|
||||
taosMemoryFree(tmp);
|
||||
goto end;
|
||||
}
|
||||
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = 0;
|
||||
int64_t size = pColSchema->bytes - VARSTR_HEADER_SIZE;
|
||||
if (size <= 0) {
|
||||
ret = TSDB_CODE_SML_INVALID_DATA;
|
||||
goto end;
|
||||
}
|
||||
char* pUcs4 = taosMemoryCalloc(1, size);
|
||||
if (NULL == pUcs4) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, size, &len, charsetCxt)) {
|
||||
if (terrno == TAOS_SYSTEM_ERROR(E2BIG)) {
|
||||
taosMemoryFree(pUcs4);
|
||||
ret = TSDB_CODE_PAR_VALUE_TOO_LONG;
|
||||
goto end;
|
||||
}
|
||||
taosMemoryFree(pUcs4);
|
||||
ret = TSDB_CODE_TSC_INVALID_VALUE;
|
||||
goto end;
|
||||
}
|
||||
pVal->value.pData = pUcs4;
|
||||
pVal->value.nData = len;
|
||||
ret = smlMbsToUcs4(kv->value, kv->length, (void**)&pVal->value.pData, &pVal->value.nData, pColSchema->bytes - VARSTR_HEADER_SIZE, charsetCxt);
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
} else if (kv->type == TSDB_DATA_TYPE_BINARY) {
|
||||
pVal->value.nData = kv->length;
|
||||
pVal->value.pData = (uint8_t*)kv->value;
|
||||
} else if (kv->type == TSDB_DATA_TYPE_GEOMETRY || kv->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||
pVal->value.nData = kv->length;
|
||||
pVal->value.pData = taosMemoryMalloc(kv->length);
|
||||
if (!pVal->value.pData) {
|
||||
ret = terrno;
|
||||
uError("SML smlBuildCol malloc failed %s:%d, err: %s", __func__, __LINE__, tstrerror(ret));
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pVal->value.pData, ret, lino, end, terrno);
|
||||
|
||||
(void)memcpy(pVal->value.pData, (uint8_t*)kv->value, kv->length);
|
||||
} else {
|
||||
(void)memcpy(&pVal->value.val, &(kv->value), kv->length);
|
||||
|
@ -286,12 +229,17 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32
|
|||
pVal->flag = CV_FLAG_VALUE;
|
||||
|
||||
end:
|
||||
if (ret != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSchema, SArray* cols,
|
||||
STableMeta* pTableMeta, char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl,
|
||||
char* msgBuf, int32_t msgBufLen, void* charsetCxt) {
|
||||
int32_t lino = 0;
|
||||
int32_t ret = 0;
|
||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||
|
||||
SSchema* pTagsSchema = getTableTagSchema(pTableMeta);
|
||||
|
@ -299,50 +247,32 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
|||
SVCreateTbReq* pCreateTblReq = NULL;
|
||||
SArray* tagName = NULL;
|
||||
|
||||
int ret = insInitBoundColsInfo(getNumOfTags(pTableMeta), &bindTags);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "init bound cols error");
|
||||
goto end;
|
||||
}
|
||||
ret = insInitBoundColsInfo(getNumOfTags(pTableMeta), &bindTags);
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
ret = smlBoundColumnData(tags, &bindTags, pTagsSchema, true);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "bound tags error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
STag* pTag = NULL;
|
||||
|
||||
ret = smlBuildTagRow(tags, &bindTags, pTagsSchema, &pTag, &tagName, &pBuf, charsetCxt);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
||||
if (NULL == pCreateTblReq) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pCreateTblReq, ret, lino, end, terrno);
|
||||
|
||||
ret = insBuildCreateTbReq(pCreateTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName,
|
||||
pTableMeta->tableInfo.numOfTags, ttl);
|
||||
if (TSDB_CODE_SUCCESS != ret) {
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
pCreateTblReq->ctb.stbName = taosMemoryCalloc(1, sTableNameLen + 1);
|
||||
if (pCreateTblReq->ctb.stbName == NULL){
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pCreateTblReq->ctb.stbName, ret, lino, end, terrno);
|
||||
|
||||
(void)memcpy(pCreateTblReq->ctb.stbName, sTableName, sTableNameLen);
|
||||
|
||||
if (dataFormat) {
|
||||
STableDataCxt** pTableCxt = (STableDataCxt**)taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj,
|
||||
&pTableMeta->uid, sizeof(pTableMeta->uid));
|
||||
if (NULL == pTableCxt) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "dataformat true. get tableDataCtx error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pTableCxt, ret, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
(*pTableCxt)->pData->flags |= SUBMIT_REQ_AUTO_CREATE_TABLE;
|
||||
(*pTableCxt)->pData->pCreateTbReq = pCreateTblReq;
|
||||
(*pTableCxt)->pMeta->uid = pTableMeta->uid;
|
||||
|
@ -354,86 +284,47 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
|||
STableDataCxt* pTableCxt = NULL;
|
||||
ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
||||
sizeof(pTableMeta->uid), pTableMeta, &pCreateTblReq, &pTableCxt, false, false);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "insGetTableDataCxt error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
SSchema* pSchema = getTableColumnSchema(pTableMeta);
|
||||
ret = smlBoundColumnData(colsSchema, &pTableCxt->boundColsInfo, pSchema, false);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "bound cols error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
ret = initTableColSubmitData(pTableCxt);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "initTableColSubmitData error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
int32_t rowNum = taosArrayGetSize(cols);
|
||||
if (rowNum <= 0) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "cols size <= 0");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CONDITION(rowNum > 0, ret, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
|
||||
for (int32_t r = 0; r < rowNum; ++r) {
|
||||
void* rowData = taosArrayGetP(cols, r);
|
||||
if (rowData == NULL) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(rowData, ret, lino, end, terrno);
|
||||
|
||||
// 1. set the parsed value from sql string
|
||||
for (int c = 0; c < pTableCxt->boundColsInfo.numOfBound; ++c) {
|
||||
SSchema* pColSchema = &pSchema[pTableCxt->boundColsInfo.pColIndex[c]];
|
||||
SColVal* pVal = taosArrayGet(pTableCxt->pValues, pTableCxt->boundColsInfo.pColIndex[c]);
|
||||
if (pVal == NULL) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pVal, ret, lino, end, terrno);
|
||||
void** p = taosHashGet(rowData, pColSchema->name, strlen(pColSchema->name));
|
||||
if (p == NULL) {
|
||||
continue;
|
||||
}
|
||||
SSmlKv* kv = *(SSmlKv**)p;
|
||||
if (kv->type != pColSchema->type) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "kv type not equal to col type");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CONDITION(kv->type == pColSchema->type, ret, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
|
||||
if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
kv->i = convertTimePrecision(kv->i, TSDB_TIME_PRECISION_NANO, pTableMeta->tableInfo.precision);
|
||||
}
|
||||
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = 0;
|
||||
char* pUcs4 = taosMemoryCalloc(1, pColSchema->bytes - VARSTR_HEADER_SIZE);
|
||||
if (NULL == pUcs4) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, pColSchema->bytes - VARSTR_HEADER_SIZE, &len, charsetCxt)) {
|
||||
if (terrno == TAOS_SYSTEM_ERROR(E2BIG)) {
|
||||
uError("sml bind taosMbsToUcs4 error, kv length:%d, bytes:%d, kv->value:%s", (int)kv->length,
|
||||
pColSchema->bytes, kv->value);
|
||||
(void)buildInvalidOperationMsg(&pBuf, "value too long");
|
||||
ret = TSDB_CODE_PAR_VALUE_TOO_LONG;
|
||||
goto end;
|
||||
}
|
||||
ret = buildInvalidOperationMsg(&pBuf, strerror(terrno));
|
||||
goto end;
|
||||
}
|
||||
pVal->value.pData = pUcs4;
|
||||
pVal->value.nData = len;
|
||||
ret = smlMbsToUcs4(kv->value, kv->length, (void**)&pVal->value.pData, (int32_t*)&pVal->value.nData, pColSchema->bytes - VARSTR_HEADER_SIZE, charsetCxt);
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
} else if (kv->type == TSDB_DATA_TYPE_BINARY) {
|
||||
pVal->value.nData = kv->length;
|
||||
pVal->value.pData = (uint8_t*)kv->value;
|
||||
} else if (kv->type == TSDB_DATA_TYPE_GEOMETRY || kv->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||
pVal->value.nData = kv->length;
|
||||
pVal->value.pData = taosMemoryMalloc(kv->length);
|
||||
if (NULL == pVal->value.pData) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pVal->value.pData, ret, lino, end, terrno);
|
||||
(void)memcpy(pVal->value.pData, (uint8_t*)kv->value, kv->length);
|
||||
} else {
|
||||
(void)memcpy(&pVal->value.val, &(kv->value), kv->length);
|
||||
|
@ -442,22 +333,20 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
|||
}
|
||||
|
||||
SRow** pRow = taosArrayReserve(pTableCxt->pData->aRowP, 1);
|
||||
if (NULL == pRow) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pRow, ret, lino, end, terrno);
|
||||
ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
||||
if (TSDB_CODE_SUCCESS != ret) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "tRowBuild error");
|
||||
goto end;
|
||||
}
|
||||
SRowKey key;
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
SRowKey key = {0};
|
||||
tRowGetKey(*pRow, &key);
|
||||
insCheckTableDataOrder(pTableCxt, &key);
|
||||
clearColValArraySml(pTableCxt->pValues);
|
||||
}
|
||||
|
||||
end:
|
||||
if (ret != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||
ret = buildInvalidOperationMsg(&pBuf, tstrerror(ret));
|
||||
}
|
||||
insDestroyBoundColInfo(&bindTags);
|
||||
tdDestroySVCreateTbReq(pCreateTblReq);
|
||||
taosMemoryFree(pCreateTblReq);
|
||||
|
@ -466,29 +355,22 @@ end:
|
|||
}
|
||||
|
||||
int32_t smlInitHandle(SQuery** query) {
|
||||
*query = NULL;
|
||||
int32_t lino = 0;
|
||||
int32_t code = 0;
|
||||
SQuery* pQuery = NULL;
|
||||
SVnodeModifyOpStmt* stmt = NULL;
|
||||
TSDB_CHECK_NULL(query, code, lino, end, TSDB_CODE_INVALID_PARA);
|
||||
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (code != 0) {
|
||||
uError("SML create pQuery error");
|
||||
goto END;
|
||||
}
|
||||
*query = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->haveResultSet = false;
|
||||
pQuery->msgType = TDMT_VND_SUBMIT;
|
||||
code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&stmt);
|
||||
if (code != 0) {
|
||||
uError("SML create SVnodeModifyOpStmt error");
|
||||
goto END;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
stmt->pTableBlockHashObj = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
if (stmt->pTableBlockHashObj == NULL){
|
||||
uError("SML create pTableBlockHashObj error");
|
||||
code = terrno;
|
||||
goto END;
|
||||
}
|
||||
TSDB_CHECK_NULL(stmt->pTableBlockHashObj, code, lino, end, terrno);
|
||||
stmt->freeHashFunc = insDestroyTableDataCxtHashMap;
|
||||
stmt->freeArrayFunc = insDestroyVgroupDataCxtList;
|
||||
|
||||
|
@ -496,24 +378,28 @@ int32_t smlInitHandle(SQuery** query) {
|
|||
*query = pQuery;
|
||||
return code;
|
||||
|
||||
END:
|
||||
end:
|
||||
if (code != 0) {
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
nodesDestroyNode((SNode*)stmt);
|
||||
qDestroyQuery(pQuery);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash) {
|
||||
int32_t lino = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)(handle)->pRoot;
|
||||
// merge according to vgId
|
||||
int32_t code = insMergeTableDataCxt(pStmt->pTableBlockHashObj, &pStmt->pVgDataBlocks, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("insMergeTableDataCxt failed");
|
||||
return code;
|
||||
}
|
||||
code = insMergeTableDataCxt(pStmt->pTableBlockHashObj, &pStmt->pVgDataBlocks, true);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
code = insBuildVgDataBlocks(pVgHash, pStmt->pVgDataBlocks, &pStmt->pDataBlocks, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("insBuildVgDataBlocks failed");
|
||||
return code;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
end:
|
||||
if (code != 0) {
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -1841,6 +1841,9 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt*
|
|||
}
|
||||
|
||||
if (TK_NK_QUESTION == pToken->type) {
|
||||
if (!pCxt->pComCxt->isStmtBind && i != 0) {
|
||||
return buildInvalidOperationMsg(&pCxt->msg, "not support mixed bind and non-bind values");
|
||||
}
|
||||
pCxt->isStmtBind = true;
|
||||
pStmt->usingTableProcessing = true;
|
||||
if (pCols->pColIndex[i] == tbnameIdx) {
|
||||
|
@ -1874,6 +1877,9 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt*
|
|||
return buildInvalidOperationMsg(&pCxt->msg, "not expected numOfBound");
|
||||
}
|
||||
} else {
|
||||
if (pCxt->pComCxt->isStmtBind) {
|
||||
return buildInvalidOperationMsg(&pCxt->msg, "not support mixed bind and non-bind values");
|
||||
}
|
||||
if (pCols->pColIndex[i] < numOfCols) {
|
||||
const SSchema* pSchema = &pSchemas[pCols->pColIndex[i]];
|
||||
SColVal* pVal = taosArrayGet(pStbRowsCxt->aColVals, pCols->pColIndex[i]);
|
||||
|
|
|
@ -6060,11 +6060,22 @@ static int32_t stbJoinOptCreateTagScanNode(SLogicNode* pJoin, SNodeList** ppList
|
|||
}
|
||||
|
||||
SNode* pNode = NULL;
|
||||
SName* pPrev = NULL;
|
||||
FOREACH(pNode, pList) {
|
||||
code = stbJoinOptRewriteToTagScan(pJoin, pNode);
|
||||
if (code) {
|
||||
break;
|
||||
}
|
||||
|
||||
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||
if (pScan->pVgroupList && 1 == pScan->pVgroupList->numOfVgroups) {
|
||||
if (NULL == pPrev || 0 == strcmp(pPrev->dbname, pScan->tableName.dbname)) {
|
||||
pPrev = &pScan->tableName;
|
||||
continue;
|
||||
}
|
||||
|
||||
pScan->needSplit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -6156,6 +6167,7 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
|
|||
}
|
||||
|
||||
int32_t i = 0;
|
||||
SName* pPrev = NULL;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pList) {
|
||||
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||
|
@ -6173,6 +6185,16 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
|
|||
*(srcScan + i++) = pScan->pVgroupList->numOfVgroups <= 1;
|
||||
|
||||
pScan->scanType = SCAN_TYPE_TABLE;
|
||||
|
||||
if (pScan->pVgroupList && 1 == pScan->pVgroupList->numOfVgroups) {
|
||||
if (NULL == pPrev || 0 == strcmp(pPrev->dbname, pScan->tableName.dbname)) {
|
||||
pPrev = &pScan->tableName;
|
||||
continue;
|
||||
}
|
||||
|
||||
pScan->needSplit = true;
|
||||
*(srcScan + i - 1) = false;
|
||||
}
|
||||
}
|
||||
|
||||
*ppList = pList;
|
||||
|
|
|
@ -55,16 +55,10 @@ int32_t validateQueryPlanNode(SValidatePlanContext* pCxt, SQueryPlan* pPlan) {
|
|||
SNode* pSubNode = NULL;
|
||||
SNodeListNode* pSubplans = (SNodeListNode*)pNode;
|
||||
FOREACH(pSubNode, pSubplans->pNodeList) {
|
||||
if (QUERY_NODE_PHYSICAL_SUBPLAN != nodeType(pNode)) {
|
||||
code = TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
code = doValidatePhysiNode(pCxt, pSubNode);
|
||||
if (code) {
|
||||
break;
|
||||
}
|
||||
if (code) break;
|
||||
}
|
||||
if (code) break;
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -142,24 +136,7 @@ int32_t validateQueryPlan(SPlanContext* pCxt, SQueryPlan* pPlan) {
|
|||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pPlan->pSubplans) {
|
||||
if (QUERY_NODE_NODE_LIST != nodeType(pNode)) {
|
||||
code = TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
SNode* pSubNode = NULL;
|
||||
SNodeListNode* pSubplans = (SNodeListNode*)pNode;
|
||||
FOREACH(pSubNode, pSubplans->pNodeList) {
|
||||
code = doValidatePhysiNode(&cxt, pSubNode);
|
||||
if (code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
code = validateQueryPlanNode(&cxt, pPlan);
|
||||
|
||||
destoryValidatePlanContext(&cxt);
|
||||
return code;
|
||||
|
|
|
@ -161,6 +161,10 @@ int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
|
|||
int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan) { return nodesStringToNode(pStr, (SNode**)pSubplan); }
|
||||
|
||||
int32_t qSubPlanToMsg(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
|
||||
if (NULL == pSubplan) {
|
||||
return terrno = TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType && NULL == pSubplan->pNode) {
|
||||
SDataInserterNode* insert = (SDataInserterNode*)pSubplan->pDataSink;
|
||||
*pLen = insert->size;
|
||||
|
|
|
@ -137,6 +137,8 @@ static void processTaskQueue(SQueueInfo *pInfo, SSchedMsg *pSchedMsg) {
|
|||
}
|
||||
|
||||
int32_t initTaskQueue() {
|
||||
memset(&taskQueue, 0, sizeof(taskQueue));
|
||||
|
||||
taskQueue.wrokrerPool.name = "taskWorkPool";
|
||||
taskQueue.wrokrerPool.min = tsNumOfTaskQueueThreads;
|
||||
taskQueue.wrokrerPool.max = tsNumOfTaskQueueThreads;
|
||||
|
|
|
@ -477,6 +477,8 @@ extern SQueryMgmt gQueryMgmt;
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#if 0
|
||||
#define QW_UNLOCK(type, _lock) \
|
||||
do { \
|
||||
if (QW_READ == (type)) { \
|
||||
|
@ -505,6 +507,16 @@ extern SQueryMgmt gQueryMgmt;
|
|||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define QW_UNLOCK(type, _lock) \
|
||||
do { \
|
||||
if (QW_READ == (type)) { \
|
||||
taosRUnLockLatch(_lock); \
|
||||
} else { \
|
||||
taosWUnLockLatch(_lock); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
extern SQWorkerMgmt gQwMgmt;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "qwInt.h"
|
||||
#include "qworker.h"
|
||||
|
||||
#if 0
|
||||
void qwSetConcurrentTaskNumCb(int32_t taskNum) {
|
||||
int32_t finTaskNum = TMIN(taskNum, tsNumOfQueryThreads * QW_DEFAULT_THREAD_TASK_NUM);
|
||||
|
||||
|
@ -33,6 +34,7 @@ void qwIncConcurrentTaskNumCb(void) {
|
|||
|
||||
//TODO
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t qwInitJobInfo(QW_FPARAMS_DEF, SQWJobInfo* pJob) {
|
||||
pJob->pSessions= taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||
|
|
|
@ -2985,279 +2985,93 @@ static int32_t doScalarFunction2(SScalarParam *pInput, int32_t inputNum, SScalar
|
|||
bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1])));
|
||||
|
||||
int32_t numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows);
|
||||
if (pInput[0].numOfRows == pInput[1].numOfRows) {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInputData[0], i) || colDataIsNull_s(pInputData[1], i) || hasNullType) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
double in2;
|
||||
GET_TYPED_DATA(in2, double, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInputData[1], i));
|
||||
switch (GET_PARAM_TYPE(&pInput[0])) {
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double *in = (double *)pInputData[0]->pData;
|
||||
double *out = (double *)pOutputData->pData;
|
||||
double result = d1(in[i], in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
} else {
|
||||
out[i] = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float *in = (float *)pInputData[0]->pData;
|
||||
float *out = (float *)pOutputData->pData;
|
||||
float result = f1(in[i], (float)in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
} else {
|
||||
out[i] = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t *in = (int8_t *)pInputData[0]->pData;
|
||||
int8_t *out = (int8_t *)pOutputData->pData;
|
||||
int8_t result = (int8_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
int16_t *in = (int16_t *)pInputData[0]->pData;
|
||||
int16_t *out = (int16_t *)pOutputData->pData;
|
||||
int16_t result = (int16_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_INT: {
|
||||
int32_t *in = (int32_t *)pInputData[0]->pData;
|
||||
int32_t *out = (int32_t *)pOutputData->pData;
|
||||
int32_t result = (int32_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_BIGINT: {
|
||||
int64_t *in = (int64_t *)pInputData[0]->pData;
|
||||
int64_t *out = (int64_t *)pOutputData->pData;
|
||||
int64_t result = (int64_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
uint8_t *in = (uint8_t *)pInputData[0]->pData;
|
||||
uint8_t *out = (uint8_t *)pOutputData->pData;
|
||||
uint8_t result = (uint8_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
uint16_t *in = (uint16_t *)pInputData[0]->pData;
|
||||
uint16_t *out = (uint16_t *)pOutputData->pData;
|
||||
uint16_t result = (uint16_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UINT: {
|
||||
uint32_t *in = (uint32_t *)pInputData[0]->pData;
|
||||
uint32_t *out = (uint32_t *)pOutputData->pData;
|
||||
uint32_t result = (uint32_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
uint64_t *in = (uint64_t *)pInputData[0]->pData;
|
||||
uint64_t *out = (uint64_t *)pOutputData->pData;
|
||||
uint64_t result = (uint64_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
int32_t colIdx1 = (pInput[0].numOfRows == 1) ? 0 : i;
|
||||
int32_t colIdx2 = (pInput[1].numOfRows == 1) ? 0 : i;
|
||||
if (colDataIsNull_s(pInputData[0], colIdx1) || colDataIsNull_s(pInputData[1], colIdx2) || hasNullType) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
} else if (pInput[0].numOfRows == 1) { // left operand is constant
|
||||
if (colDataIsNull_s(pInputData[0], 0) || hasNullType) {
|
||||
colDataSetNNULL(pOutputData, 0, pInput[1].numOfRows);
|
||||
} else {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInputData[1], i)) {
|
||||
double in2;
|
||||
GET_TYPED_DATA(in2, double, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInputData[1], colIdx2));
|
||||
switch (GET_PARAM_TYPE(&pInput[0])) {
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double *in = (double *)pInputData[0]->pData;
|
||||
double *out = (double *)pOutputData->pData;
|
||||
double result = d1(in[colIdx1], in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
double in2;
|
||||
GET_TYPED_DATA(in2, double, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInputData[1], i));
|
||||
switch (GET_PARAM_TYPE(&pInput[0])) {
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double *in = (double *)pInputData[0]->pData;
|
||||
double *out = (double *)pOutputData->pData;
|
||||
double result = d1(in[0], in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
} else {
|
||||
out[i] = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float *in = (float *)pInputData[0]->pData;
|
||||
float *out = (float *)pOutputData->pData;
|
||||
float result = f1(in[0], (float)in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
} else {
|
||||
out[i] = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t *in = (int8_t *)pInputData[0]->pData;
|
||||
int8_t *out = (int8_t *)pOutputData->pData;
|
||||
int8_t result = (int8_t)d1((double)in[0], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
int16_t *in = (int16_t *)pInputData[0]->pData;
|
||||
int16_t *out = (int16_t *)pOutputData->pData;
|
||||
int16_t result = (int16_t)d1((double)in[0], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_INT: {
|
||||
int32_t *in = (int32_t *)pInputData[0]->pData;
|
||||
int32_t *out = (int32_t *)pOutputData->pData;
|
||||
int32_t result = (int32_t)d1((double)in[0], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_BIGINT: {
|
||||
int64_t *in = (int64_t *)pInputData[0]->pData;
|
||||
int64_t *out = (int64_t *)pOutputData->pData;
|
||||
int64_t result = (int64_t)d1((double)in[0], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
uint8_t *in = (uint8_t *)pInputData[0]->pData;
|
||||
uint8_t *out = (uint8_t *)pOutputData->pData;
|
||||
uint8_t result = (uint8_t)d1((double)in[0], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
uint16_t *in = (uint16_t *)pInputData[0]->pData;
|
||||
uint16_t *out = (uint16_t *)pOutputData->pData;
|
||||
uint16_t result = (uint16_t)d1((double)in[0], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UINT: {
|
||||
uint32_t *in = (uint32_t *)pInputData[0]->pData;
|
||||
uint32_t *out = (uint32_t *)pOutputData->pData;
|
||||
uint32_t result = (uint32_t)d1((double)in[0], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
uint64_t *in = (uint64_t *)pInputData[0]->pData;
|
||||
uint64_t *out = (uint64_t *)pOutputData->pData;
|
||||
uint64_t result = (uint64_t)d1((double)in[0], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
out[i] = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (pInput[1].numOfRows == 1) {
|
||||
if (colDataIsNull_s(pInputData[1], 0) || hasNullType) {
|
||||
colDataSetNNULL(pOutputData, 0, pInput[0].numOfRows);
|
||||
} else {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInputData[0], i)) {
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float *in = (float *)pInputData[0]->pData;
|
||||
float *out = (float *)pOutputData->pData;
|
||||
float result = f1(in[colIdx1], (float)in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
continue;
|
||||
}
|
||||
double in2;
|
||||
GET_TYPED_DATA(in2, double, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInputData[1], 0));
|
||||
switch (GET_PARAM_TYPE(&pInput[0])) {
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double *in = (double *)pInputData[0]->pData;
|
||||
double *out = (double *)pOutputData->pData;
|
||||
double result = d1(in[i], in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
} else {
|
||||
out[i] = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float *in = (float *)pInputData[0]->pData;
|
||||
float *out = (float *)pOutputData->pData;
|
||||
float result = f1(in[i], in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
colDataSetNULL(pOutputData, i);
|
||||
} else {
|
||||
out[i] = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t *in = (int8_t *)pInputData[0]->pData;
|
||||
int8_t *out = (int8_t *)pOutputData->pData;
|
||||
int8_t result = (int8_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
int16_t *in = (int16_t *)pInputData[0]->pData;
|
||||
int16_t *out = (int16_t *)pOutputData->pData;
|
||||
int16_t result = (int16_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_INT: {
|
||||
int32_t *in = (int32_t *)pInputData[0]->pData;
|
||||
int32_t *out = (int32_t *)pOutputData->pData;
|
||||
int32_t result = (int32_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_BIGINT: {
|
||||
int64_t *in = (int64_t *)pInputData[0]->pData;
|
||||
int64_t *out = (int64_t *)pOutputData->pData;
|
||||
int64_t result = (int64_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
uint8_t *in = (uint8_t *)pInputData[0]->pData;
|
||||
uint8_t *out = (uint8_t *)pOutputData->pData;
|
||||
uint8_t result = (uint8_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
uint16_t *in = (uint16_t *)pInputData[0]->pData;
|
||||
uint16_t *out = (uint16_t *)pOutputData->pData;
|
||||
uint16_t result = (uint16_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UINT: {
|
||||
uint32_t *in = (uint32_t *)pInputData[0]->pData;
|
||||
uint32_t *out = (uint32_t *)pOutputData->pData;
|
||||
uint32_t result = (uint32_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
uint64_t *in = (uint64_t *)pInputData[0]->pData;
|
||||
uint64_t *out = (uint64_t *)pOutputData->pData;
|
||||
uint64_t result = (uint64_t)d1((double)in[i], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
out[i] = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t *in = (int8_t *)pInputData[0]->pData;
|
||||
int8_t *out = (int8_t *)pOutputData->pData;
|
||||
int8_t result = (int8_t)d1((double)in[colIdx1], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
int16_t *in = (int16_t *)pInputData[0]->pData;
|
||||
int16_t *out = (int16_t *)pOutputData->pData;
|
||||
int16_t result = (int16_t)d1((double)in[colIdx1], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_INT: {
|
||||
int32_t *in = (int32_t *)pInputData[0]->pData;
|
||||
int32_t *out = (int32_t *)pOutputData->pData;
|
||||
int32_t result = (int32_t)d1((double)in[colIdx1], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_BIGINT: {
|
||||
int64_t *in = (int64_t *)pInputData[0]->pData;
|
||||
int64_t *out = (int64_t *)pOutputData->pData;
|
||||
int64_t result = (int64_t)d1((double)in[colIdx1], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
uint8_t *in = (uint8_t *)pInputData[0]->pData;
|
||||
uint8_t *out = (uint8_t *)pOutputData->pData;
|
||||
uint8_t result = (uint8_t)d1((double)in[colIdx1], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
uint16_t *in = (uint16_t *)pInputData[0]->pData;
|
||||
uint16_t *out = (uint16_t *)pOutputData->pData;
|
||||
uint16_t result = (uint16_t)d1((double)in[colIdx1], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UINT: {
|
||||
uint32_t *in = (uint32_t *)pInputData[0]->pData;
|
||||
uint32_t *out = (uint32_t *)pOutputData->pData;
|
||||
uint32_t result = (uint32_t)d1((double)in[colIdx1], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
uint64_t *in = (uint64_t *)pInputData[0]->pData;
|
||||
uint64_t *out = (uint64_t *)pOutputData->pData;
|
||||
uint64_t result = (uint64_t)d1((double)in[colIdx1], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,19 +121,6 @@ _return:
|
|||
SCL_RET(code);
|
||||
}
|
||||
|
||||
int32_t convertBinaryToDouble(const void *inData, void *outData) {
|
||||
char *tmp = taosMemoryCalloc(1, varDataTLen(inData));
|
||||
if (tmp == NULL) {
|
||||
*((double *)outData) = 0.;
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(tmp, varDataVal(inData), varDataLen(inData));
|
||||
double ret = taosStr2Double(tmp, NULL);
|
||||
taosMemoryFree(tmp);
|
||||
*((double *)outData) = ret;
|
||||
SCL_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
typedef int32_t (*_getBigintValue_fn_t)(void *src, int32_t index, int64_t *res);
|
||||
|
||||
int32_t getVectorBigintValue_TINYINT(void *src, int32_t index, int64_t *res) {
|
||||
|
@ -1129,17 +1116,11 @@ int32_t vectorConvertCols(SScalarParam *pLeft, SScalarParam *pRight, SScalarPara
|
|||
}
|
||||
|
||||
if (type != GET_PARAM_TYPE(param1)) {
|
||||
code = vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
SCL_ERR_RET(vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows));
|
||||
}
|
||||
|
||||
if (type != GET_PARAM_TYPE(param2)) {
|
||||
code = vectorConvertSingleCol(param2, paramOut2, type, startIndex, numOfRows);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
SCL_ERR_RET(vectorConvertSingleCol(param2, paramOut2, type, startIndex, numOfRows));
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1208,22 +1189,16 @@ static int32_t vectorMathTsAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData
|
|||
static int32_t vectorConvertVarToDouble(SScalarParam *pInput, int32_t *converted, SColumnInfoData **pOutputCol) {
|
||||
SScalarParam output = {0};
|
||||
SColumnInfoData *pCol = pInput->columnData;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
*pOutputCol = NULL;
|
||||
if (IS_VAR_DATA_TYPE(pCol->info.type) && pCol->info.type != TSDB_DATA_TYPE_JSON && pCol->info.type != TSDB_DATA_TYPE_VARBINARY) {
|
||||
int32_t code = vectorConvertSingleCol(pInput, &output, TSDB_DATA_TYPE_DOUBLE, -1, -1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
*pOutputCol = NULL;
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
|
||||
SCL_ERR_RET(vectorConvertSingleCol(pInput, &output, TSDB_DATA_TYPE_DOUBLE, -1, -1));
|
||||
*converted = VECTOR_DO_CONVERT;
|
||||
|
||||
*pOutputCol = output.columnData;
|
||||
SCL_RET(code);
|
||||
}
|
||||
|
||||
*converted = VECTOR_UN_CONVERT;
|
||||
|
||||
*pOutputCol = pInput->columnData;
|
||||
SCL_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -1616,68 +1591,25 @@ int32_t vectorMathRemainder(SScalarParam *pLeft, SScalarParam *pRight, SScalarPa
|
|||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (IS_NULL) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
double lx = 0;
|
||||
double rx = 0;
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, i, &lx));
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, i, &rx));
|
||||
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
*output = lx - ((int64_t)(lx / rx)) * rx;
|
||||
int32_t numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
for (; i < numOfRows && i >= 0; i += step, output += 1) {
|
||||
int32_t leftidx = pLeft->numOfRows == 1 ? 0 : i;
|
||||
int32_t rightidx = pRight->numOfRows == 1 ? 0 : i;
|
||||
if (IS_HELPER_NULL(pLeftCol, leftidx) || IS_HELPER_NULL(pRightCol, rightidx)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
|
||||
double lx = 0;
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, 0, &lx));
|
||||
if (IS_HELPER_NULL(pLeftCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataSetNNULL(pOutputCol, 0, pRight->numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) {
|
||||
if (IS_HELPER_NULL(pRightCol, i)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
double rx = 0;
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, i, &rx));
|
||||
if (isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
*output = lx - ((int64_t)(lx / rx)) * rx;
|
||||
}
|
||||
}
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
double rx = 0;
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, 0, &rx));
|
||||
if (IS_HELPER_NULL(pRightCol, 0) || FLT_EQUAL(rx, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataSetNNULL(pOutputCol, 0, pLeft->numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
double lx = 0;
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, i, &lx));
|
||||
if (isnan(lx) || isinf(lx)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
*output = lx - ((int64_t)(lx / rx)) * rx;
|
||||
}
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, leftidx, &lx));
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, rightidx, &rx));
|
||||
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
*output = lx - ((int64_t)(lx / rx)) * rx;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
@ -1739,33 +1671,6 @@ int32_t vectorAssign(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pO
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t vectorBitAndHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
|
||||
int32_t numOfRows, int32_t step, int32_t i) {
|
||||
_getBigintValue_fn_t getVectorBigintValueFnLeft;
|
||||
_getBigintValue_fn_t getVectorBigintValueFnRight;
|
||||
SCL_ERR_RET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
|
||||
SCL_ERR_RET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
||||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
|
||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataSetNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
int64_t leftRes = 0;
|
||||
int64_t rightRes = 0;
|
||||
SCL_ERR_RET(getVectorBigintValueFnLeft(LEFT_COL, i, &leftRes));
|
||||
SCL_ERR_RET(getVectorBigintValueFnRight(RIGHT_COL, 0, &rightRes));
|
||||
*output = leftRes & rightRes;
|
||||
}
|
||||
}
|
||||
SCL_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t vectorBitAnd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) {
|
||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
||||
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
|
@ -1786,22 +1691,19 @@ int32_t vectorBitAnd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pO
|
|||
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
||||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (IS_NULL) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
int64_t leftRes = 0;
|
||||
int64_t rightRes = 0;
|
||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, i, &leftRes));
|
||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, i, &rightRes));
|
||||
*output = leftRes & rightRes;
|
||||
int32_t numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
for (; i < numOfRows && i >= 0; i += step, output += 1) {
|
||||
int32_t leftidx = pLeft->numOfRows == 1 ? 0 : i;
|
||||
int32_t rightidx = pRight->numOfRows == 1 ? 0 : i;
|
||||
if (IS_HELPER_NULL(pRightCol, rightidx) || IS_HELPER_NULL(pLeftCol, leftidx)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
SCL_ERR_JRET(vectorBitAndHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i));
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
SCL_ERR_JRET(vectorBitAndHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i));
|
||||
int64_t leftRes = 0;
|
||||
int64_t rightRes = 0;
|
||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, leftidx, &leftRes));
|
||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, rightidx, &rightRes));
|
||||
*output = leftRes & rightRes;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
@ -1810,33 +1712,6 @@ _return:
|
|||
SCL_RET(code);
|
||||
}
|
||||
|
||||
static int32_t vectorBitOrHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
|
||||
int32_t numOfRows, int32_t step, int32_t i) {
|
||||
_getBigintValue_fn_t getVectorBigintValueFnLeft;
|
||||
_getBigintValue_fn_t getVectorBigintValueFnRight;
|
||||
SCL_ERR_RET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
|
||||
SCL_ERR_RET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
||||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
|
||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataSetNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
int64_t rx = 0;
|
||||
SCL_ERR_RET(getVectorBigintValueFnRight(RIGHT_COL, 0, &rx));
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
int64_t lx = 0;
|
||||
SCL_ERR_RET(getVectorBigintValueFnLeft(LEFT_COL, i, &lx));
|
||||
*output = lx | rx;
|
||||
}
|
||||
}
|
||||
SCL_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) {
|
||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
||||
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
|
@ -1857,22 +1732,20 @@ int32_t vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOu
|
|||
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
||||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (IS_NULL) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
int64_t leftRes = 0;
|
||||
int64_t rightRes = 0;
|
||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, i, &leftRes));
|
||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, i, &rightRes));
|
||||
*output = leftRes | rightRes;
|
||||
int32_t numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
for (; i < numOfRows && i >= 0; i += step, output += 1) {
|
||||
int32_t leftidx = pLeft->numOfRows == 1 ? 0 : i;
|
||||
int32_t rightidx = pRight->numOfRows == 1 ? 0 : i;
|
||||
if (IS_HELPER_NULL(pRightCol, leftidx) || IS_HELPER_NULL(pLeftCol, rightidx)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
SCL_ERR_JRET(vectorBitOrHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i));
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
SCL_ERR_JRET(vectorBitOrHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i));
|
||||
|
||||
int64_t leftRes = 0;
|
||||
int64_t rightRes = 0;
|
||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, leftidx, &leftRes));
|
||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, rightidx, &rightRes));
|
||||
*output = leftRes | rightRes;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
|
|
@ -391,6 +391,26 @@ TEST(constantTest, bigint_add_bigint) {
|
|||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
TEST(constantTest, ubigint_add_ubigint) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_UBIGINT, &scltLeftV);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_UBIGINT, &scltRightV);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_UBIGINT, pLeft, pRight);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
code = scalarCalculateConstants(opNode, &res);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||
SValueNode *v = (SValueNode *)res;
|
||||
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_UBIGINT);
|
||||
ASSERT_FLOAT_EQ(v->datum.d, (scltLeftV + scltRightV));
|
||||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
TEST(constantTest, double_sub_bigint) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -431,6 +451,66 @@ TEST(constantTest, tinyint_and_smallint) {
|
|||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
TEST(constantTest, utinyint_and_usmallint) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_UTINYINT, &scltLeftV);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_USMALLINT, &scltRightV);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
code = scalarCalculateConstants(opNode, &res);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||
SValueNode *v = (SValueNode *)res;
|
||||
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT);
|
||||
ASSERT_EQ(v->datum.i, (int64_t)scltLeftV & (int64_t)scltRightV);
|
||||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
TEST(constantTest, uint_and_usmallint) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_UINT, &scltLeftV);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_USMALLINT, &scltRightV);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
code = scalarCalculateConstants(opNode, &res);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||
SValueNode *v = (SValueNode *)res;
|
||||
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT);
|
||||
ASSERT_EQ(v->datum.i, (int64_t)scltLeftV & (int64_t)scltRightV);
|
||||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
TEST(constantTest, ubigint_and_uint) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_UBIGINT, &scltLeftV);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_UINT, &scltRightV);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
code = scalarCalculateConstants(opNode, &res);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||
SValueNode *v = (SValueNode *)res;
|
||||
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT);
|
||||
ASSERT_EQ(v->datum.i, (int64_t)scltLeftV & (int64_t)scltRightV);
|
||||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
TEST(constantTest, bigint_or_double) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -494,6 +574,53 @@ TEST(constantTest, int_greater_double) {
|
|||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
TEST(constantTest, binary_greater_equal_varbinary) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
char binaryStr[64] = {0};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
(void)sprintf(&binaryStr[2], "%d", scltRightV);
|
||||
varDataSetLen(binaryStr, strlen(&binaryStr[2]));
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_VARBINARY, binaryStr);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, binaryStr);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
code = scalarCalculateConstants(opNode, &res);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||
SValueNode *v = (SValueNode *)res;
|
||||
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL);
|
||||
ASSERT_EQ(v->datum.b, scltLeftV < scltRightVd);
|
||||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
TEST(constantTest, binary_equal_geo) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
char geoRawStr[64] = "POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))";
|
||||
char geoStr[64] = {0};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
(void)sprintf(&geoStr[2], "%s", geoRawStr);
|
||||
varDataSetLen(geoStr, strlen(&geoStr[2]));
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_GEOMETRY, geoStr);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, geoStr);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
code = scltMakeOpNode(&opNode, OP_TYPE_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
code = scalarCalculateConstants(opNode, &res);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||
SValueNode *v = (SValueNode *)res;
|
||||
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL);
|
||||
ASSERT_EQ(v->datum.b, scltLeftV < scltRightVd);
|
||||
nodesDestroyNode(res);
|
||||
}
|
||||
|
||||
TEST(constantTest, int_greater_equal_binary) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
char binaryStr[64] = {0};
|
||||
|
|
|
@ -149,11 +149,11 @@ typedef struct SSchedulerMgmt {
|
|||
bool exit;
|
||||
int32_t jobRef;
|
||||
int32_t jobNum;
|
||||
SSchStat stat;
|
||||
void *timer;
|
||||
SRWLatch hbLock;
|
||||
SHashObj *hbConnections;
|
||||
void *queryMgmt;
|
||||
SSchStat stat;
|
||||
} SSchedulerMgmt;
|
||||
|
||||
typedef struct SSchCallbackParamHeader {
|
||||
|
|
|
@ -50,11 +50,6 @@ int32_t schChkJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) {
|
|||
int32_t taskNum = taosArrayGetSize(pJob->dataSrcTasks);
|
||||
for (int32_t i = 0; i < taskNum; ++i) {
|
||||
SSchTask *pTask = *(SSchTask **)taosArrayGet(pJob->dataSrcTasks, i);
|
||||
if (NULL == pTask) {
|
||||
SCH_JOB_DLOG("fail to get the %dth task", i);
|
||||
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
sum += pTask->plan->execNodeStat.tableNum;
|
||||
}
|
||||
|
||||
|
|
|
@ -531,8 +531,8 @@ int32_t schHandleNotifyCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
|||
qDebug("QID:0x%" PRIx64 ",SID:0x%" PRIx64 ",CID:0x%" PRIx64 ",TID:0x%" PRIx64 " task notify rsp received, code:0x%x",
|
||||
pParam->queryId, pParam->seriousId, pParam->clientId, pParam->taskId, code);
|
||||
if (pMsg) {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFreeClear(pMsg->pData);
|
||||
taosMemoryFreeClear(pMsg->pEpSet);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -545,8 +545,8 @@ int32_t schHandleLinkBrokenCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
|||
qDebug("handle %p is broken", pMsg->handle);
|
||||
|
||||
if (head->isHbParam) {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFreeClear(pMsg->pData);
|
||||
taosMemoryFreeClear(pMsg->pEpSet);
|
||||
|
||||
SSchHbCallbackParam *hbParam = (SSchHbCallbackParam *)param;
|
||||
SSchTrans trans = {.pTrans = hbParam->pTrans, .pHandle = NULL, .pHandleId = 0};
|
||||
|
@ -1293,6 +1293,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
}
|
||||
break;
|
||||
}
|
||||
/*
|
||||
case TDMT_SCH_QUERY_HEARTBEAT: {
|
||||
SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &rpcCtx));
|
||||
|
||||
|
@ -1320,6 +1321,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
persistHandle = true;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
case TDMT_SCH_TASK_NOTIFY: {
|
||||
ETaskNotifyType* pType = param;
|
||||
STaskNotifyReq qMsg;
|
||||
|
|
|
@ -189,7 +189,6 @@ int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode)
|
|||
}
|
||||
|
||||
pTask->failedExecId = pTask->execId;
|
||||
pTask->failedSeriousId = pTask->seriousId;
|
||||
|
||||
int8_t jobStatus = 0;
|
||||
if (schJobNeedToStop(pJob, &jobStatus)) {
|
||||
|
@ -274,18 +273,18 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
|||
if (taskDone < pTask->level->taskNum) {
|
||||
SCH_TASK_DLOG("wait all tasks, done:%d, all:%d", taskDone, pTask->level->taskNum);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else if (taskDone > pTask->level->taskNum) {
|
||||
SCH_TASK_ELOG("taskDone number invalid, done:%d, total:%d", taskDone, pTask->level->taskNum);
|
||||
}
|
||||
|
||||
SCH_TASK_DLOG("taskDone number reach level task number, done:%d, total:%d", taskDone, pTask->level->taskNum);
|
||||
|
||||
if (pTask->level->taskFailed > 0) {
|
||||
SCH_RET(schHandleJobFailure(pJob, pJob->errCode));
|
||||
} else {
|
||||
SCH_RET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_PART_SUCC, NULL));
|
||||
}
|
||||
} else {
|
||||
pJob->resNode = pTask->succeedAddr;
|
||||
|
||||
SCH_RET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_PART_SUCC, NULL));
|
||||
}
|
||||
|
||||
pJob->resNode = pTask->succeedAddr;
|
||||
|
||||
pJob->fetchTask = pTask;
|
||||
|
||||
|
@ -438,7 +437,7 @@ void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) {
|
|||
pTask->waitRetry = true;
|
||||
|
||||
if (pTask->delayTimer) {
|
||||
taosTmrStop(pTask->delayTimer);
|
||||
UNUSED(taosTmrStop(pTask->delayTimer));
|
||||
}
|
||||
|
||||
schDropTaskOnExecNode(pJob, pTask);
|
||||
|
@ -452,6 +451,8 @@ void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) {
|
|||
TAOS_MEMSET(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr));
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -593,17 +594,18 @@ _return:
|
|||
|
||||
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code));
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) {
|
||||
int32_t code = taosHashPut(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
||||
if (0 != code) {
|
||||
if (HASH_NODE_EXIST(code)) {
|
||||
SCH_TASK_DLOG("task already in execTask list, code:%x", code);
|
||||
SCH_TASK_DLOG("task already in execTask list, code:0x%x", code);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SCH_TASK_ELOG("taosHashPut task to execTask list failed, errno:0x%x", errno);
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_TASK_ELOG("taosHashPut task to execTask list failed, code:0x%x", code);
|
||||
SCH_ERR_RET(code);
|
||||
}
|
||||
|
||||
SCH_TASK_DLOG("task added to execTask list, numOfTasks:%d", taosHashGetSize(pJob->execTasks));
|
||||
|
@ -759,7 +761,7 @@ int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
|||
(void)atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||
|
||||
if (pTask->delayTimer) {
|
||||
taosTmrStop(pTask->delayTimer);
|
||||
UNUSED(taosTmrStop(pTask->delayTimer));
|
||||
}
|
||||
|
||||
(void)schRemoveTaskFromExecList(pJob, pTask); // ignore error
|
||||
|
@ -798,11 +800,6 @@ int32_t schSetAddrsFromNodeList(SSchJob *pJob, SSchTask *pTask) {
|
|||
|
||||
for (int32_t i = 0; i < nodeNum; ++i) {
|
||||
SQueryNodeLoad *nload = taosArrayGet(pJob->nodeList, i);
|
||||
if (NULL == nload) {
|
||||
SCH_TASK_ELOG("fail to get the %dth node in nodeList, nodeNum:%d", i, nodeNum);
|
||||
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
SQueryNodeAddr *naddr = &nload->addr;
|
||||
|
||||
if (NULL == taosArrayPush(pTask->candidateAddrs, naddr)) {
|
||||
|
@ -869,6 +866,7 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (NULL == pTask->candidateAddrs || 1 != taosArrayGetSize(pTask->candidateAddrs)) {
|
||||
|
@ -900,6 +898,7 @@ _return:
|
|||
|
||||
return code;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask) {
|
||||
int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs);
|
||||
|
@ -1376,6 +1375,7 @@ int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level) {
|
|||
|
||||
for (int32_t i = 0; i < level->taskNum; ++i) {
|
||||
SSchTask *pTask = taosArrayGet(level->subTasks, i);
|
||||
pTask->failedSeriousId = pJob->seriousId - 1;
|
||||
pTask->seriousId = pJob->seriousId;
|
||||
|
||||
SCH_TASK_DLOG("task seriousId set to 0x%" PRIx64, pTask->seriousId);
|
||||
|
|
|
@ -57,6 +57,22 @@ namespace {
|
|||
extern "C" int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, uint64_t sId, int32_t execId, SDataBuf *pMsg,
|
||||
int32_t rspCode);
|
||||
extern "C" int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t rspCode);
|
||||
extern "C" int32_t schHandleNotifyCallback(void *param, SDataBuf *pMsg, int32_t code);
|
||||
extern "C" int32_t schHandleLinkBrokenCallback(void *param, SDataBuf *pMsg, int32_t code);
|
||||
extern "C" int32_t schRescheduleTask(SSchJob *pJob, SSchTask *pTask);
|
||||
extern "C" int32_t schValidateRspMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType);
|
||||
//extern "C" int32_t schProcessFetchRsp(SSchJob *pJob, SSchTask *pTask, char *msg, int32_t rspCode);
|
||||
extern "C" int32_t schProcessResponseMsg(SSchJob *pJob, SSchTask *pTask, SDataBuf *pMsg, int32_t rspCode);
|
||||
extern "C" void schInitTaskRetryTimes(SSchJob *pJob, SSchTask *pTask, SSchLevel *pLevel);
|
||||
extern "C" int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask);
|
||||
extern "C" int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execId);
|
||||
extern "C" int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask);
|
||||
extern "C" int32_t schSetAddrsFromNodeList(SSchJob *pJob, SSchTask *pTask);
|
||||
extern "C" int32_t schNotifyTaskOnExecNode(SSchJob *pJob, SSchTask *pTask, ETaskNotifyType type);
|
||||
extern "C" int32_t schLaunchRemoteTask(SSchJob *pJob, SSchTask *pTask);
|
||||
extern "C" int32_t schLaunchTaskImpl(void *param);
|
||||
extern "C" void schHandleTimerEvent(void *param, void *tmrId);
|
||||
|
||||
|
||||
int64_t insertJobRefId = 0;
|
||||
int64_t queryJobRefId = 0;
|
||||
|
@ -316,7 +332,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) {
|
|||
|
||||
scanPlan->execNode.nodeId = 1 + i;
|
||||
scanPlan->execNode.epSet.inUse = 0;
|
||||
scanPlan->execNodeStat.tableNum = taosRand() % 30;
|
||||
scanPlan->execNodeStat.tableNum = taosRand() % 100;
|
||||
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep0", 6030);
|
||||
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep1", 6030);
|
||||
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep2", 6030);
|
||||
|
@ -982,8 +998,159 @@ TEST(queryTest, normalCase) {
|
|||
schedulerFreeJob(&job, 0);
|
||||
|
||||
(void)taosThreadJoin(thread1, NULL);
|
||||
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
TEST(queryTest, rescheduleCase) {
|
||||
void *mockPointer = (void *)0x1;
|
||||
char *clusterId = "cluster1";
|
||||
char *dbname = "1.db1";
|
||||
char *tablename = "table1";
|
||||
SVgroupInfo vgInfo = {0};
|
||||
int64_t job = 0;
|
||||
SQueryPlan *dag = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN, (SNode**)&dag);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad));
|
||||
|
||||
SQueryNodeLoad load = {0};
|
||||
load.addr.epSet.numOfEps = 1;
|
||||
TAOS_STRCPY(load.addr.epSet.eps[0].fqdn, "qnode0.ep");
|
||||
load.addr.epSet.eps[0].port = 6031;
|
||||
assert(taosArrayPush(qnodeList, &load) != NULL);
|
||||
|
||||
TAOS_STRCPY(load.addr.epSet.eps[0].fqdn, "qnode1.ep");
|
||||
assert(taosArrayPush(qnodeList, &load) != NULL);
|
||||
|
||||
code = schedulerInit();
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
schtBuildQueryDag(dag);
|
||||
|
||||
schtSetPlanToString();
|
||||
schtSetExecNode();
|
||||
schtSetAsyncSendMsgToServer();
|
||||
|
||||
int32_t queryDone = 0;
|
||||
|
||||
SRequestConnInfo conn = {0};
|
||||
conn.pTrans = mockPointer;
|
||||
SSchedulerReq req = {0};
|
||||
req.pConn = &conn;
|
||||
req.pNodeList = qnodeList;
|
||||
req.pDag = dag;
|
||||
req.sql = "select * from tb";
|
||||
req.execFp = schtQueryCb;
|
||||
req.cbParam = &queryDone;
|
||||
|
||||
code = schedulerExecJob(&req, &job);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SSchJob *pJob = NULL;
|
||||
code = schAcquireJob(job, &pJob);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
schedulerEnableReSchedule(true);
|
||||
|
||||
void *pIter = taosHashIterate(pJob->execTasks, NULL);
|
||||
while (pIter) {
|
||||
SSchTask *task = *(SSchTask **)pIter;
|
||||
task->timeoutUsec = -1;
|
||||
|
||||
code = schRescheduleTask(pJob, task);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
task->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC;
|
||||
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pJob->execTasks, NULL);
|
||||
while (pIter) {
|
||||
SSchTask *task = *(SSchTask **)pIter;
|
||||
|
||||
SDataBuf msg = {0};
|
||||
void *rmsg = NULL;
|
||||
assert(0 == schtBuildQueryRspMsg(&msg.len, &rmsg));
|
||||
msg.msgType = TDMT_SCH_QUERY_RSP;
|
||||
msg.pData = rmsg;
|
||||
|
||||
code = schHandleResponseMsg(pJob, task, task->seriousId, task->execId, &msg, 0);
|
||||
|
||||
ASSERT_EQ(code, 0);
|
||||
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||
}
|
||||
|
||||
|
||||
pIter = taosHashIterate(pJob->execTasks, NULL);
|
||||
while (pIter) {
|
||||
SSchTask *task = *(SSchTask **)pIter;
|
||||
task->timeoutUsec = -1;
|
||||
|
||||
code = schRescheduleTask(pJob, task);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
task->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC;
|
||||
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pJob->execTasks, NULL);
|
||||
while (pIter) {
|
||||
SSchTask *task = *(SSchTask **)pIter;
|
||||
if (JOB_TASK_STATUS_EXEC == task->status) {
|
||||
SDataBuf msg = {0};
|
||||
void *rmsg = NULL;
|
||||
assert(0 == schtBuildQueryRspMsg(&msg.len, &rmsg));
|
||||
msg.msgType = TDMT_SCH_QUERY_RSP;
|
||||
msg.pData = rmsg;
|
||||
|
||||
code = schHandleResponseMsg(pJob, task, task->seriousId, task->execId, &msg, 0);
|
||||
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (queryDone) {
|
||||
break;
|
||||
}
|
||||
|
||||
taosUsleep(10000);
|
||||
}
|
||||
|
||||
TdThreadAttr thattr;
|
||||
assert(0 == taosThreadAttrInit(&thattr));
|
||||
|
||||
TdThread thread1;
|
||||
assert(0 == taosThreadCreate(&(thread1), &thattr, schtCreateFetchRspThread, &job));
|
||||
|
||||
void *data = NULL;
|
||||
req.syncReq = true;
|
||||
req.pFetchRes = &data;
|
||||
|
||||
code = schedulerFetchRows(job, &req);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
SRetrieveTableRsp *pRsp = (SRetrieveTableRsp *)data;
|
||||
ASSERT_EQ(pRsp->completed, 1);
|
||||
ASSERT_EQ(pRsp->numOfRows, 10);
|
||||
taosMemoryFreeClear(data);
|
||||
|
||||
(void)schReleaseJob(job);
|
||||
|
||||
schedulerDestroy();
|
||||
|
||||
schedulerFreeJob(&job, 0);
|
||||
|
||||
(void)taosThreadJoin(thread1, NULL);
|
||||
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
|
||||
TEST(queryTest, readyFirstCase) {
|
||||
void *mockPointer = (void *)0x1;
|
||||
char *clusterId = "cluster1";
|
||||
|
@ -1097,6 +1264,7 @@ TEST(queryTest, readyFirstCase) {
|
|||
schedulerFreeJob(&job, 0);
|
||||
|
||||
(void)taosThreadJoin(thread1, NULL);
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
TEST(queryTest, flowCtrlCase) {
|
||||
|
@ -1196,6 +1364,9 @@ TEST(queryTest, flowCtrlCase) {
|
|||
schedulerFreeJob(&job, 0);
|
||||
|
||||
(void)taosThreadJoin(thread1, NULL);
|
||||
schMgmt.jobRef = -1;
|
||||
|
||||
cleanupTaskQueue();
|
||||
}
|
||||
|
||||
TEST(insertTest, normalCase) {
|
||||
|
@ -1260,6 +1431,7 @@ TEST(insertTest, normalCase) {
|
|||
schedulerDestroy();
|
||||
|
||||
(void)taosThreadJoin(thread1, NULL);
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
TEST(multiThread, forceFree) {
|
||||
|
@ -1282,9 +1454,11 @@ TEST(multiThread, forceFree) {
|
|||
|
||||
schtTestStop = true;
|
||||
// taosSsleep(3);
|
||||
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
TEST(otherTest, otherCase) {
|
||||
TEST(otherTest, function) {
|
||||
// excpet test
|
||||
(void)schReleaseJob(0);
|
||||
schFreeRpcCtx(NULL);
|
||||
|
@ -1293,6 +1467,296 @@ TEST(otherTest, otherCase) {
|
|||
ASSERT_EQ(schDumpEpSet(NULL, &ep), TSDB_CODE_SUCCESS);
|
||||
ASSERT_EQ(strcmp(schGetOpStr(SCH_OP_NULL), "NULL"), 0);
|
||||
ASSERT_EQ(strcmp(schGetOpStr((SCH_OP_TYPE)100), "UNKNOWN"), 0);
|
||||
|
||||
SSchTaskCallbackParam param = {0};
|
||||
SDataBuf dataBuf = {0};
|
||||
dataBuf.pData = taosMemoryMalloc(1);
|
||||
dataBuf.pEpSet = (SEpSet*)taosMemoryMalloc(sizeof(*dataBuf.pEpSet));
|
||||
ASSERT_EQ(schHandleNotifyCallback(¶m, &dataBuf, TSDB_CODE_SUCCESS), TSDB_CODE_SUCCESS);
|
||||
|
||||
SSchCallbackParamHeader param2 = {0};
|
||||
dataBuf.pData = taosMemoryMalloc(1);
|
||||
dataBuf.pEpSet = (SEpSet*)taosMemoryMalloc(sizeof(*dataBuf.pEpSet));
|
||||
schHandleLinkBrokenCallback(¶m2, &dataBuf, TSDB_CODE_SUCCESS);
|
||||
param2.isHbParam = true;
|
||||
dataBuf.pData = taosMemoryMalloc(1);
|
||||
dataBuf.pEpSet = (SEpSet*)taosMemoryMalloc(sizeof(*dataBuf.pEpSet));
|
||||
schHandleLinkBrokenCallback(¶m2, &dataBuf, TSDB_CODE_SUCCESS);
|
||||
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
TEST(otherTest, branch) {
|
||||
SSchJob job = {0};
|
||||
SSchTask task = {0};
|
||||
memset(&schMgmt, 0, sizeof(schMgmt));
|
||||
|
||||
schValidateRspMsgType(&job, &task, TDMT_SCH_MERGE_FETCH_RSP);
|
||||
|
||||
task.lastMsgType = TDMT_SCH_MERGE_FETCH_RSP - 1;
|
||||
schValidateRspMsgType(&job, &task, TDMT_SCH_MERGE_FETCH_RSP);
|
||||
|
||||
schValidateRspMsgType(&job, &task, 0);
|
||||
|
||||
schValidateRspMsgType(&job, &task, TDMT_SCH_QUERY_RSP);
|
||||
|
||||
task.lastMsgType = TDMT_SCH_QUERY_RSP - 1;
|
||||
schValidateRspMsgType(&job, &task, TDMT_SCH_QUERY_RSP);
|
||||
|
||||
schProcessFetchRsp(&job, &task, NULL, -1);
|
||||
schProcessFetchRsp(&job, &task, NULL, 0);
|
||||
|
||||
job.fetchRes = (void*)0x1;
|
||||
schProcessFetchRsp(&job, &task, (char*)taosMemoryMalloc(0), 0);
|
||||
job.fetchRes = NULL;
|
||||
|
||||
SDataBuf databuf = {0};
|
||||
databuf.msgType = TDMT_VND_ALTER_TABLE_RSP;
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
databuf.msgType = TDMT_VND_SUBMIT_RSP;
|
||||
databuf.pData = taosMemoryMalloc(0);
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
databuf.msgType = TDMT_VND_DELETE_RSP;
|
||||
databuf.pData = taosMemoryMalloc(0);
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
databuf.msgType = TDMT_SCH_QUERY_RSP;
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
databuf.msgType = TDMT_SCH_QUERY_RSP;
|
||||
databuf.pData = taosMemoryMalloc(0);
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
|
||||
databuf.msgType = TDMT_SCH_EXPLAIN_RSP;
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
databuf.msgType = TDMT_SCH_EXPLAIN_RSP;
|
||||
databuf.pData = taosMemoryMalloc(0);
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
job.status = 0;
|
||||
|
||||
job.attr.explainMode = EXPLAIN_MODE_ANALYZE;
|
||||
databuf.msgType = TDMT_SCH_EXPLAIN_RSP;
|
||||
databuf.pData = taosMemoryMalloc(0);
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
job.fetchRes = (void*)0x1;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
job.fetchRes = NULL;
|
||||
|
||||
job.attr.explainMode = EXPLAIN_MODE_ANALYZE;
|
||||
databuf.msgType = TDMT_SCH_EXPLAIN_RSP;
|
||||
databuf.pData = taosMemoryMalloc(0);
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
databuf.msgType = TDMT_SCH_DROP_TASK_RSP;
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
databuf.msgType = TDMT_SCH_LINK_BROKEN;
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
databuf.msgType = 0;
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||
|
||||
databuf.pData = taosMemoryMalloc(0);
|
||||
schHandleHbCallback(NULL, &databuf, 0);
|
||||
|
||||
__async_send_cb_fn_t fp = NULL;
|
||||
schGetCallbackFp(TDMT_SCH_TASK_NOTIFY, &fp);
|
||||
schGetCallbackFp(0, &fp);
|
||||
|
||||
SQueryNodeEpId ep = {0};
|
||||
schBuildAndSendHbMsg(&ep, NULL);
|
||||
|
||||
schBuildAndSendMsg(&job, &task, NULL, 0, NULL);
|
||||
|
||||
SSchLevel level = {0};
|
||||
SSubplan subplan;
|
||||
memset(&subplan, 0, sizeof(subplan));
|
||||
job.attr.queryJob = true;
|
||||
schMgmt.cfg.schPolicy = SCH_ALL;
|
||||
task.plan = &subplan;
|
||||
schInitTaskRetryTimes(&job, &task, &level);
|
||||
job.attr.queryJob = false;
|
||||
memset(&schMgmt.cfg, 0, sizeof(schMgmt.cfg));
|
||||
memset(&level, 0, sizeof(level));
|
||||
|
||||
schRecordTaskSucceedNode(&job, &task);
|
||||
|
||||
schDropTaskExecNode(&job, &task, NULL, 0);
|
||||
|
||||
task.execNodes = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
schDropTaskExecNode(&job, &task, NULL, 0);
|
||||
|
||||
int32_t execId = 0;
|
||||
task.execId = 1;
|
||||
(void)taosHashPut(task.execNodes, &execId, sizeof(execId), &execId, sizeof(execId));
|
||||
schDropTaskExecNode(&job, &task, NULL, execId);
|
||||
task.execId = 0;
|
||||
taosHashCleanup(task.execNodes);
|
||||
task.execNodes = NULL;
|
||||
|
||||
job.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessOnTaskFailure(&job, &task, 0);
|
||||
job.status = 0;
|
||||
|
||||
task.status = JOB_TASK_STATUS_FAIL;
|
||||
schProcessOnTaskFailure(&job, &task, 0);
|
||||
task.status = 0;
|
||||
|
||||
task.level = &level;
|
||||
schProcessOnTaskFailure(&job, &task, TSDB_CODE_SCH_TIMEOUT_ERROR);
|
||||
memset(&level, 0, sizeof(level));
|
||||
task.level = NULL;
|
||||
|
||||
subplan.subplanType = SUBPLAN_TYPE_SCAN;
|
||||
task.plan = &subplan;
|
||||
SEpSet epset = {0};
|
||||
epset.numOfEps = 127;
|
||||
schChkUpdateRedirectCtx(&job, &task, &epset, 0);
|
||||
|
||||
schChkUpdateRedirectCtx(&job, &task, NULL, 0);
|
||||
task.plan = NULL;
|
||||
|
||||
schPushTaskToExecList(&job, &task);
|
||||
|
||||
job.execTasks = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK);
|
||||
taosHashPut(job.execTasks, &task.taskId, sizeof(task.taskId), &task, POINTER_BYTES);
|
||||
schPushTaskToExecList(&job, &task);
|
||||
taosHashCleanup(job.execTasks);
|
||||
job.execTasks = NULL;
|
||||
|
||||
bool needRetry = false;
|
||||
task.timeoutUsec = SCH_MAX_TASK_TIMEOUT_USEC / 2 + 1;
|
||||
task.retryTimes = 0;
|
||||
task.maxRetryTimes = 0;
|
||||
schTaskCheckSetRetry(&job, &task, TSDB_CODE_SCH_TIMEOUT_ERROR, &needRetry);
|
||||
|
||||
task.execId = 0;
|
||||
task.retryTimes = 0;
|
||||
task.maxRetryTimes = 100;
|
||||
task.maxExecTimes = 1;
|
||||
schTaskCheckSetRetry(&job, &task, TSDB_CODE_SCH_TIMEOUT_ERROR, &needRetry);
|
||||
|
||||
|
||||
task.execId = 0;
|
||||
task.retryTimes = 0;
|
||||
task.maxRetryTimes = 100;
|
||||
task.maxExecTimes = 100;
|
||||
task.lastMsgType = TDMT_SCH_LINK_BROKEN;
|
||||
schTaskCheckSetRetry(&job, &task, TSDB_CODE_SCH_TIMEOUT_ERROR, &needRetry);
|
||||
|
||||
schSetAddrsFromNodeList(&job, &task);
|
||||
|
||||
schSwitchTaskCandidateAddr(&job, &task);
|
||||
|
||||
|
||||
task.candidateAddrs = taosArrayInit(SCHEDULE_DEFAULT_MAX_NODE_NUM, sizeof(SQueryNodeAddr));
|
||||
SQueryNodeAddr addr = {0};
|
||||
taosArrayPush(task.candidateAddrs, &addr);
|
||||
taosArrayPush(task.candidateAddrs, &addr);
|
||||
schMgmt.cfg.schPolicy = SCH_LOAD_SEQ;
|
||||
task.candidateIdx = 1;
|
||||
schSwitchTaskCandidateAddr(&job, &task);
|
||||
|
||||
schMgmt.cfg.schPolicy = SCH_RANDOM;
|
||||
schSwitchTaskCandidateAddr(&job, &task);
|
||||
taosArrayDestroy(task.candidateAddrs);
|
||||
task.candidateAddrs = NULL;
|
||||
memset(&schMgmt.cfg, 0, sizeof(schMgmt.cfg));
|
||||
task.candidateIdx = 0;
|
||||
|
||||
schDropTaskOnExecNode(&job, &task);
|
||||
|
||||
schNotifyTaskOnExecNode(&job, &task, TASK_NOTIFY_FINISHED);
|
||||
|
||||
schLaunchRemoteTask(&job, &task);
|
||||
|
||||
SSchTaskCtx* pCtx = (SSchTaskCtx*)taosMemoryCalloc(1, sizeof(SSchTaskCtx));
|
||||
pCtx->jobRid = -1;
|
||||
schLaunchTaskImpl((void*)pCtx);
|
||||
|
||||
task.plan = &subplan;
|
||||
subplan.subplanType = SUBPLAN_TYPE_SCAN;
|
||||
job.attr.needFlowCtrl = true;
|
||||
level.taskNum = 1000;
|
||||
task.level = &level;
|
||||
schLaunchTask(&job, &task);
|
||||
task.plan = NULL;
|
||||
task.level = NULL;
|
||||
job.attr.needFlowCtrl = false;
|
||||
|
||||
SSchTimerParam param = {0};
|
||||
param.rId = -1;
|
||||
schHandleTimerEvent(¶m, NULL);
|
||||
|
||||
job.execTasks = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK);
|
||||
task.delayExecMs = 1;
|
||||
schMgmt.timer = NULL;
|
||||
schDelayLaunchTask(&job, &task);
|
||||
task.delayExecMs = 0;
|
||||
taosHashCleanup(job.execTasks);
|
||||
job.execTasks = NULL;
|
||||
|
||||
job.fetchRes = (void*)0x1;
|
||||
schLaunchFetchTask(&job);
|
||||
job.fetchRes = NULL;
|
||||
|
||||
job.fetchTask = &task;
|
||||
job.attr.localExec = true;
|
||||
job.attr.queryJob = true;
|
||||
subplan.subplanType = SUBPLAN_TYPE_MERGE;
|
||||
task.plan = &subplan;
|
||||
void* p = taosMemoryCalloc(1, 1024);
|
||||
schMgmt.queryMgmt = p;
|
||||
schLaunchFetchTask(&job);
|
||||
memset(&job, 0, sizeof(job));
|
||||
memset(&subplan, 0, sizeof(subplan));
|
||||
task.plan = NULL;
|
||||
taosMemoryFreeClear(schMgmt.queryMgmt);
|
||||
|
||||
// flow ctrl
|
||||
|
||||
job.flowCtrl = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||
SEp sep = {0};
|
||||
SSchFlowControl nctrl = {0};
|
||||
nctrl.taskList = taosArrayInit(1, POINTER_BYTES);
|
||||
taosHashPut(job.flowCtrl, &sep, sizeof(SEp), &nctrl, sizeof(nctrl));
|
||||
schFreeFlowCtrl(&job);
|
||||
|
||||
|
||||
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
|
||||
void schtReset() {
|
||||
insertJobRefId = 0;
|
||||
queryJobRefId = 0;
|
||||
|
||||
schtJobDone = false;
|
||||
schtMergeTemplateId = 0x4;
|
||||
schtFetchTaskId = 0;
|
||||
schtQueryId = 1;
|
||||
|
||||
schtTestStop = false;
|
||||
schtTestDeadLoop = false;
|
||||
schtTestMTRunSec = 1;
|
||||
schtTestPrintNum = 1000;
|
||||
schtStartFetch = 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
@ -1302,7 +1766,17 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
taosSeedRand(taosGetTimestampSec());
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
int code = 0;
|
||||
for (int32_t i = 0; i < 10; ++i) {
|
||||
schtReset();
|
||||
code = RUN_ALL_TESTS();
|
||||
if (code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -252,6 +252,8 @@ void chkptFailedByRetrieveReqToSource(SStreamTask* pTask, int64_t checkpointId);
|
|||
|
||||
int32_t uploadCheckpointData(SStreamTask* pTask, int64_t checkpointId, int64_t dbRefId, ECHECKPOINT_BACKUP_TYPE type);
|
||||
int32_t chkptTriggerRecvMonitorHelper(SStreamTask* pTask, void* param, SArray** ppNotSendList);
|
||||
int32_t downloadCheckpointByNameS3(const char* id, const char* fname, const char* dstName);
|
||||
int32_t uploadCheckpointToS3(const char* id, const char* path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ static int32_t streamTaskUploadCheckpoint(const char* id, const char* path, int6
|
|||
#ifdef BUILD_NO_CALL
|
||||
static int32_t deleteCheckpoint(const char* id);
|
||||
#endif
|
||||
static int32_t downloadCheckpointByNameS3(const char* id, const char* fname, const char* dstName);
|
||||
static int32_t continueDispatchCheckpointTriggerBlock(SStreamDataBlock* pBlock, SStreamTask* pTask);
|
||||
static int32_t appendCheckpointIntoInputQ(SStreamTask* pTask, int32_t checkpointType, int64_t checkpointId,
|
||||
int32_t transId, int32_t srcTaskId);
|
||||
|
@ -1355,7 +1354,7 @@ void streamTaskSetTriggerDispatchConfirmed(SStreamTask* pTask, int32_t vgId) {
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t uploadCheckpointToS3(const char* id, const char* path) {
|
||||
int32_t uploadCheckpointToS3(const char* id, const char* path) {
|
||||
int32_t code = 0;
|
||||
int32_t nBytes = 0;
|
||||
/*
|
||||
|
|