enh:[TS-5441] cost too long in tmq write meta data by cache meta and vg info
This commit is contained in:
commit
61531e7339
|
@ -138,3 +138,24 @@ tags
|
|||
*CMakeCache*
|
||||
*CMakeFiles*
|
||||
.history/
|
||||
*.txt
|
||||
*.tcl
|
||||
*.pc
|
||||
contrib/geos
|
||||
contrib/libuv
|
||||
contrib/pcre2
|
||||
contrib/zlib
|
||||
deps_tmp_CMakeLists.txt.in
|
||||
*.a
|
||||
*.ctest
|
||||
pcre2-config
|
||||
pcre2_test.sh
|
||||
pcre2_grep_test.sh
|
||||
pcre2_chartables.c
|
||||
geos-config
|
||||
config.h
|
||||
pcre2.h
|
||||
zconf.h
|
||||
version.h
|
||||
geos_c.h
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# stub
|
||||
ExternalProject_Add(stub
|
||||
GIT_REPOSITORY https://github.com/coolxv/cpp-stub.git
|
||||
GIT_TAG 5e903b8e
|
||||
GIT_TAG 3137465194014d66a8402941e80d2bccc6346f51
|
||||
GIT_SUBMODULES "src"
|
||||
SOURCE_DIR "${TD_CONTRIB_DIR}/cpp-stub"
|
||||
BINARY_DIR "${TD_CONTRIB_DIR}/cpp-stub/src"
|
||||
|
|
|
@ -347,14 +347,18 @@ curl -X DELETE http://localhost:8083/connectors/TDengineSourceConnector
|
|||
以下配置项对 TDengine Sink Connector 和 TDengine Source Connector 均适用。
|
||||
|
||||
1. `name`: connector 名称。
|
||||
2. `connector.class`: connector 的完整类名, 如: com.taosdata.kafka.connect.sink.TDengineSinkConnector。
|
||||
3. `tasks.max`: 最大任务数, 默认 1。
|
||||
4. `topics`: 需要同步的 topic 列表, 多个用逗号分隔, 如 `topic1,topic2`。
|
||||
5. `connection.url`: TDengine JDBC 连接字符串, 如 `jdbc:TAOS://127.0.0.1:6030`。
|
||||
6. `connection.user`: TDengine 用户名, 默认 root。
|
||||
7. `connection.password` :TDengine 用户密码, 默认 taosdata。
|
||||
8. `connection.attempts` :最大尝试连接次数。默认 3。
|
||||
9. `connection.backoff.ms` : 创建连接失败重试时间隔时间,单位为 ms。 默认 5000。
|
||||
1. `connector.class`: connector 的完整类名, 如: com.taosdata.kafka.connect.sink.TDengineSinkConnector。
|
||||
1. `tasks.max`: 最大任务数, 默认 1。
|
||||
1. `topics`: 需要同步的 topic 列表, 多个用逗号分隔, 如 `topic1,topic2`。
|
||||
1. `connection.url`: TDengine JDBC 连接字符串, 如 `jdbc:TAOS://127.0.0.1:6030`。
|
||||
1. `connection.user`: TDengine 用户名, 默认 root。
|
||||
1. `connection.password` :TDengine 用户密码, 默认 taosdata。
|
||||
1. `connection.attempts` :最大尝试连接次数。默认 3。
|
||||
1. `connection.backoff.ms` : 创建连接失败重试时间隔时间,单位为 ms。 默认 5000。
|
||||
1. `data.precision`: 使用 InfluxDB 行协议格式时,时间戳的精度。可选值为:
|
||||
1. ms : 表示毫秒
|
||||
1. us : 表示微秒
|
||||
1. ns : 表示纳秒
|
||||
|
||||
### TDengine Sink Connector 特有的配置
|
||||
|
||||
|
@ -367,30 +371,22 @@ curl -X DELETE http://localhost:8083/connectors/TDengineSourceConnector
|
|||
1. line :代表 InfluxDB 行协议格式
|
||||
2. json : 代表 OpenTSDB JSON 格式
|
||||
3. telnet :代表 OpenTSDB Telnet 行协议格式
|
||||
7. `data.precision`: 使用 InfluxDB 行协议格式时,时间戳的精度。可选值为:
|
||||
1. ms : 表示毫秒
|
||||
2. us : 表示微秒
|
||||
3. ns : 表示纳秒。
|
||||
|
||||
### TDengine Source Connector 特有的配置
|
||||
|
||||
1. `connection.database`: 源数据库名称,无缺省值。
|
||||
2. `topic.prefix`: 数据导入 kafka 时使用的 topic 名称的前缀。默认为空字符串 ""。
|
||||
3. `timestamp.initial`: 数据同步起始时间。格式为'yyyy-MM-dd HH:mm:ss',若未指定则从指定 DB 中最早的一条记录开始。
|
||||
4. `poll.interval.ms`: 检查是否有新建或删除的表的时间间隔,单位为 ms。默认为 1000。
|
||||
5. `fetch.max.rows` : 检索数据库时最大检索条数。 默认为 100。
|
||||
6. `query.interval.ms`: 从 TDengine 一次读取数据的时间跨度,需要根据表中的数据特征合理配置,避免一次查询的数据量过大或过小;在具体的环境中建议通过测试设置一个较优值,默认值为 0,即获取到当前最新时间的所有数据。
|
||||
7. `out.format` : 结果集输出格式。`line` 表示输出格式为 InfluxDB Line 协议格式,`json` 表示输出格式是 json。默认为 line。
|
||||
8. `data.precision`: 使用 InfluxDB 行协议格式时,时间戳的精度。可选值为:
|
||||
1. ms : 表示毫秒,
|
||||
2. us : 表示微秒
|
||||
3. ns : 表示纳秒。
|
||||
9. `topic.per.stable`: 如果设置为 true,表示一个超级表对应一个 Kafka topic,topic的命名规则 `<topic.prefix><topic.delimiter><connection.database><topic.delimiter><stable.name>`;如果设置为 false,则指定的 DB 中的所有数据进入一个 Kafka topic,topic 的命名规则为 `<topic.prefix><topic.delimiter><connection.database>`
|
||||
10. `topic.ignore.db`: topic 命名规则是否包含 database 名称,true 表示规则为 `<topic.prefix><topic.delimiter><stable.name>`,false 表示规则为 `<topic.prefix><topic.delimiter><connection.database><topic.delimiter><stable.name>`,默认 false。此配置项在 `topic.per.stable` 设置为 false 时不生效。
|
||||
11. `topic.delimiter`: topic 名称分割符,默认为 `-`。
|
||||
12. `read.method`: 从 TDengine 读取数据方式,query 或是 subscription。默认为 subscription。
|
||||
13. `subscription.group.id`: 指定 TDengine 数据订阅的组 id,当 `read.method` 为 subscription 时,此项为必填项。
|
||||
14. `subscription.from`: 指定 TDengine 数据订阅起始位置,latest 或是 earliest。默认为 latest。
|
||||
1. `topic.prefix`: 数据导入 kafka 时使用的 topic 名称的前缀。默认为空字符串 ""。
|
||||
1. `timestamp.initial`: 数据同步起始时间。格式为'yyyy-MM-dd HH:mm:ss',若未指定则从指定 DB 中最早的一条记录开始。
|
||||
1. `poll.interval.ms`: 检查是否有新建或删除的表的时间间隔,单位为 ms。默认为 1000。
|
||||
1. `fetch.max.rows` : 检索数据库时最大检索条数。 默认为 100。
|
||||
1. `query.interval.ms`: 从 TDengine 一次读取数据的时间跨度,需要根据表中的数据特征合理配置,避免一次查询的数据量过大或过小;在具体的环境中建议通过测试设置一个较优值,默认值为 0,即获取到当前最新时间的所有数据。
|
||||
1. `out.format` : 结果集输出格式。`line` 表示输出格式为 InfluxDB Line 协议格式,`json` 表示输出格式是 json。默认为 line。
|
||||
1. `topic.per.stable`: 如果设置为 true,表示一个超级表对应一个 Kafka topic,topic的命名规则 `<topic.prefix><topic.delimiter><connection.database><topic.delimiter><stable.name>`;如果设置为 false,则指定的 DB 中的所有数据进入一个 Kafka topic,topic 的命名规则为 `<topic.prefix><topic.delimiter><connection.database>`
|
||||
1. `topic.ignore.db`: topic 命名规则是否包含 database 名称,true 表示规则为 `<topic.prefix><topic.delimiter><stable.name>`,false 表示规则为 `<topic.prefix><topic.delimiter><connection.database><topic.delimiter><stable.name>`,默认 false。此配置项在 `topic.per.stable` 设置为 false 时不生效。
|
||||
1. `topic.delimiter`: topic 名称分割符,默认为 `-`。
|
||||
1. `read.method`: 从 TDengine 读取数据方式,query 或是 subscription。默认为 subscription。
|
||||
1. `subscription.group.id`: 指定 TDengine 数据订阅的组 id,当 `read.method` 为 subscription 时,此项为必填项。
|
||||
1. `subscription.from`: 指定 TDengine 数据订阅起始位置,latest 或是 earliest。默认为 latest。
|
||||
|
||||
## 其他说明
|
||||
|
||||
|
|
|
@ -79,6 +79,18 @@ CREATE TABLE [IF NOT EXISTS] tb_name1 USING stb_name TAGS (tag_value1, ...) [IF
|
|||
|
||||
批量建表方式要求数据表必须以超级表为模板。 在不超出 SQL 语句长度限制的前提下,单条语句中的建表数量建议控制在 1000 ~ 3000 之间,将会获得比较理想的建表速度。
|
||||
|
||||
### 使用 CSV 批量创建子表
|
||||
|
||||
```sql
|
||||
CREATE TABLE [IF NOT EXISTS] USING [db_name.]stb_name (field1_name [, field2_name] ....) FILE csv_file_path;
|
||||
```
|
||||
|
||||
**参数说明**
|
||||
|
||||
1. FILE 语法表示数据来自于 CSV 文件(英文逗号分隔、英文单引号括住每个值),CSV 文件无需表头。CSV 文件中应仅包含 table name 与 tag 值。如需插入数据,请参考数据写入章节。
|
||||
2. 为指定的 stb_name 创建子表,该超级表必须已经存在。
|
||||
3. field_name 列表顺序与 CSV 文件各列内容顺序一致。列表中不允许出现重复项,且必须包含 `tbname`,可包含零个或多个超级表中已定义的标签列。未包含在列表中的标签值将被设置为 NULL。
|
||||
|
||||
## 修改普通表
|
||||
|
||||
```sql
|
||||
|
|
|
@ -1458,7 +1458,7 @@ WEEKDAY(expr)
|
|||
**适用于**: 表和超级表。
|
||||
|
||||
**使用说明**:
|
||||
- 返回值 0 代表周日,1 代表周一 ... 6 代表周六。
|
||||
- 返回值 0 代表周一,1 代表周二 ... 6 代表周日。
|
||||
- 若 `expr` 为 NULL,返回 NULL。
|
||||
- 输入时间戳的精度由所查询表的精度确定, 若未指定表, 则精度为毫秒.
|
||||
|
||||
|
|
|
@ -30,6 +30,16 @@ SHOW CLUSTER ALIVE;
|
|||
|
||||
查询当前集群的状态是否可用,返回值: 0:不可用 1:完全可用 2:部分可用(集群中部分节点下线,但其它节点仍可以正常使用)
|
||||
|
||||
## SHOW CLUSTER MACHINES
|
||||
|
||||
```sql
|
||||
SHOW CLUSTER MACHINES; // 从 TDengine 3.2.3.0 版本开始支持
|
||||
```
|
||||
|
||||
显示集群的机器码等信息。
|
||||
|
||||
注:企业版独有
|
||||
|
||||
## SHOW CONNECTIONS
|
||||
|
||||
```sql
|
||||
|
@ -99,6 +109,7 @@ SHOW FUNCTIONS;
|
|||
```sql
|
||||
SHOW LICENCES;
|
||||
SHOW GRANTS;
|
||||
SHOW GRANTS FULL; // 从 TDengine 3.2.3.0 版本开始支持
|
||||
```
|
||||
|
||||
显示企业版许可授权的信息。
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
---
|
||||
title: 3.3.3.0 版本说明
|
||||
sidebar_label: 3.3.3.0
|
||||
description: 3.3.3.0 版本说明
|
||||
---
|
||||
### 新特性/优化
|
||||
1. 增加函数支持:pi、truncate/tunc、exp、ln、mod、rand、sign、degress、radians、char、ascii、position、trim、replace、repeat、substring、substr、substring_index、week、weekday、weekofyear、dayofweek、stddev_pop、var_pop
|
||||
2. 多级存储支持微软对象存储 Azure Blob [企业版]
|
||||
3. 支持 MongoDB 数据源 [企业版]
|
||||
4. TDengine支持macOS企业版客户端 [企业版]
|
||||
5. taosX日志默认不写入syslog [企业版]
|
||||
6. 服务端记录所有慢查询信息到log库
|
||||
7. show cluster machines 查询结果中添加服务端版本号
|
||||
8. 删除保留关键字LEVEL/ENCODE/COMPRESS, 可以作为列名/表名/数据库名等使用
|
||||
9. 禁止动态修改临时目录
|
||||
10. round 函数:支持四舍五入的精度
|
||||
11. timediff 函数:返回时间戳 expr1 - expr2 的结果,支持负数结果,并近似到时间单位 time_unit 指定的精度
|
||||
12. max/min 函数:支持字符串作为输入参数,当输入参数为字符串类型时,返回最大字符串值
|
||||
13. 提升了 taosX 数据同步的性能 [企业版]
|
||||
14. 统一慢查询和普通日志的保存策略
|
||||
15. 优化订阅功能中offset文件过大且加载过慢的问题
|
||||
16. 升级 JDBC driver 至 3.2.5
|
||||
17. Kafka connector 提交改为同步方式
|
||||
18. 新增参数:表查询不存在时是否报异常
|
||||
19. 扩大 tsma 的 interval 的最大窗口到 1 年
|
||||
20. 支持从 CSV 文件批量建表
|
||||
### 修复问题
|
||||
1. 服务器重启后 mqtt 写入任务未自动重新启动 [企业版]
|
||||
2. 修复windows上agent和PI connector连接错误导致任务终止的问题 [企业版]
|
||||
3. 重启taosadapter后,mqtt 任务异常,无法同步数据 [企业版]
|
||||
4. Explorer 上 mqtt 写入任务状态不正确 [企业版]
|
||||
5. 重启 taosx 后,运行中的任务没有被重新调度 [企业版]
|
||||
6. 对于 taosx 的 MongoDB DataIn 任务,优化了日志的输出信息 [企业版]
|
||||
7. 修复在 local.toml 文件为空时备份失败的问题 [企业版]
|
||||
8. taosx replica 任务在网络断开恢复后数据同步异常的问题 [企业版]
|
||||
9. 修复3.1版本同步到3.3版本meta数据不同步问题 [企业版]
|
||||
10. taosadapter 异常重启后, mqtt任务无法自动恢复的问题[企业版]
|
||||
11. Kafka DataIn 任务状态正常,但任务停止消费数据 [企业版]
|
||||
12. 修复 last + interval 查询导致 crash 的问题
|
||||
13. 在数据写入时热更stt_trigger导致taosd崩溃
|
||||
14. 修改root密码后taoskeeper反复重启
|
||||
15. 云服务中服务重启后流计算无法继续
|
||||
16. tsdb加载缓存导致taosd死锁
|
||||
17. 查询时fill值指定为0报错
|
||||
18. last_row 查询结果与预期不符
|
||||
19. 用户指定 information_schema 库登录时导致 taosd 崩溃
|
||||
20. group by 语句支持位置参数和别名语法
|
||||
21. 元数据克隆函数对象错误导致 crash
|
||||
22. 缓存更新时数据填充的游标错误导致的 taosd 异常退出
|
||||
23. STDDEV 函数计算结果随机不正确的问题
|
||||
24. 多级存储以及加密场景下无法添加离线节点
|
||||
25. taos CLI 无法输入大于20字节长度的密码
|
||||
26. 拼接 sql 写入报错: int data overflow
|
||||
27. 大量查询并发场景下元数据的一致性
|
||||
28. 尝试解决手动点击停止按钮,任务无法停止的问题
|
||||
29. 解决了列或者标签中包含逗号或引号时导出 CSV 文件错误的问题
|
||||
30. 多线程并发的对同一张子表进行 describe 导致 crash
|
||||
31. 数据浏览器的查询结果未按照配置的时区展示的问题
|
||||
32. 创建 websocket 连接时 taosadapter 内存泄漏的问题
|
||||
33. 社区版无法在 redhat 操作系统正常启动
|
||||
34. 无效断言在两个 stt 分别位于数据块时间轴分布空洞场景引发的 crash
|
||||
35. S3 长时间拉取数据会失败的问题
|
||||
36. 使用结果集函数判断时间线的有序性
|
||||
37. 解决超级表投影查询慢的问题
|
||||
38. 修复: 多节点环境,事务返回码与事务状态不一致导致事务堆积
|
||||
39. 修复:在stt_trigger = 1时,delete数据之后重新出现的错误
|
||||
40. 节点恢复阶段taosd内存占用过高导致OOM
|
||||
41. limit过小时的判断错误
|
||||
42. AVEVA historian 数据源连通性及获取示例数据功能
|
||||
43. taosd 服务无法正常停止的问题
|
||||
44. last 函数查询全空列导致 crash
|
||||
45. 查询 cid 不在当前版本的 schema 时触发 assert 导致 coredump
|
||||
46. 写入消息体过大时 OOM 的问题,增加 syncLogBufferMemoryAllowed 参数控制
|
||||
47. timezone 设置为 UTC 且数据包含“1970”时,查询报错
|
||||
48. 取消mnode节点的消息同步的等待超时
|
||||
49. 集群节点异常恢复后,集群授权状态失效
|
||||
50. 查询空指针问题
|
||||
51. 在restore vnode时,将vgroup暂时设置成单副本
|
||||
52. 可以使用SQL保留字作为列名创建超级表,也可以使用SQL保留字作为标签名
|
||||
53. 高并发查询期间内存持续增长的问题
|
||||
54. 流计算在checkpoint处理过程中,由于断言失败导致的crash
|
||||
55. 修复了 3.3.2.8.0820 版本中可以查询到 information_schema 中不存在的表perf_queries问题
|
||||
56. 节点恢复阶段taosd内存占用过高导致OOM
|
||||
57. 修复在schema变更情况下,通过taosx导入数据时,taosd出现crash的问题
|
||||
58. 可能的内存泄漏
|
||||
59. 客户端内存泄漏
|
||||
60. 开源用户修改stt_trigger值升级后无法修改其他数据库选项
|
||||
61. NOT IN (NULL) 查询结果不正确
|
||||
62. taos shell和taosBenchmark不能成功连接云服务实例
|
|
@ -3,5 +3,5 @@ title: 版本说明
|
|||
sidebar_label: 版本说明
|
||||
description: 各版本版本说明
|
||||
---
|
||||
|
||||
[3.3.3.0](./3.3.3.0)
|
||||
[3.3.2.0](./3.3.2.0)
|
||||
|
|
|
@ -251,6 +251,7 @@ DLL_EXPORT int64_t taos_affected_rows64(TAOS_RES *res);
|
|||
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||
DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
||||
DLL_EXPORT int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
||||
DLL_EXPORT void taos_stop_query(TAOS_RES *res);
|
||||
DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col);
|
||||
DLL_EXPORT int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows);
|
||||
|
|
|
@ -89,32 +89,6 @@ typedef struct {
|
|||
int32_t exprIdx;
|
||||
} STupleKey;
|
||||
|
||||
typedef struct STuplePos {
|
||||
union {
|
||||
struct {
|
||||
int32_t pageId;
|
||||
int32_t offset;
|
||||
};
|
||||
SWinKey streamTupleKey;
|
||||
};
|
||||
} STuplePos;
|
||||
|
||||
typedef struct SFirstLastRes {
|
||||
bool hasResult;
|
||||
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
||||
// this attribute is required
|
||||
bool isNull;
|
||||
int32_t bytes;
|
||||
int64_t ts;
|
||||
char* pkData;
|
||||
int32_t pkBytes;
|
||||
int8_t pkType;
|
||||
STuplePos pos;
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
char buf[];
|
||||
} SFirstLastRes;
|
||||
|
||||
static inline int STupleKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
||||
STupleKey* pTuple1 = (STupleKey*)pKey1;
|
||||
STupleKey* pTuple2 = (STupleKey*)pKey2;
|
||||
|
|
|
@ -277,7 +277,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** pReq, const SSDataBlock* pData
|
|||
|
||||
bool alreadyAddGroupId(char* ctbName, int64_t groupId);
|
||||
bool isAutoTableName(char* ctbName);
|
||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId);
|
||||
int32_t buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId, size_t cap);
|
||||
int32_t buildCtbNameByGroupId(const char* stbName, uint64_t groupId, char** pName);
|
||||
int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf);
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
|
|||
: 1000000000;
|
||||
time_t t = taosTime(NULL);
|
||||
struct tm tm;
|
||||
(void) taosLocalTime(&t, &tm, NULL);
|
||||
(void) taosLocalTime(&t, &tm, NULL, 0);
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 0;
|
||||
|
|
|
@ -69,335 +69,341 @@
|
|||
#define TK_NK_DOT 51
|
||||
#define TK_WITH 52
|
||||
#define TK_ENCRYPT_KEY 53
|
||||
#define TK_DNODE 54
|
||||
#define TK_PORT 55
|
||||
#define TK_DNODES 56
|
||||
#define TK_RESTORE 57
|
||||
#define TK_NK_IPTOKEN 58
|
||||
#define TK_FORCE 59
|
||||
#define TK_UNSAFE 60
|
||||
#define TK_CLUSTER 61
|
||||
#define TK_LOCAL 62
|
||||
#define TK_QNODE 63
|
||||
#define TK_BNODE 64
|
||||
#define TK_SNODE 65
|
||||
#define TK_MNODE 66
|
||||
#define TK_VNODE 67
|
||||
#define TK_DATABASE 68
|
||||
#define TK_USE 69
|
||||
#define TK_FLUSH 70
|
||||
#define TK_TRIM 71
|
||||
#define TK_S3MIGRATE 72
|
||||
#define TK_COMPACT 73
|
||||
#define TK_IF 74
|
||||
#define TK_NOT 75
|
||||
#define TK_EXISTS 76
|
||||
#define TK_BUFFER 77
|
||||
#define TK_CACHEMODEL 78
|
||||
#define TK_CACHESIZE 79
|
||||
#define TK_COMP 80
|
||||
#define TK_DURATION 81
|
||||
#define TK_NK_VARIABLE 82
|
||||
#define TK_MAXROWS 83
|
||||
#define TK_MINROWS 84
|
||||
#define TK_KEEP 85
|
||||
#define TK_PAGES 86
|
||||
#define TK_PAGESIZE 87
|
||||
#define TK_TSDB_PAGESIZE 88
|
||||
#define TK_PRECISION 89
|
||||
#define TK_REPLICA 90
|
||||
#define TK_VGROUPS 91
|
||||
#define TK_SINGLE_STABLE 92
|
||||
#define TK_RETENTIONS 93
|
||||
#define TK_SCHEMALESS 94
|
||||
#define TK_WAL_LEVEL 95
|
||||
#define TK_WAL_FSYNC_PERIOD 96
|
||||
#define TK_WAL_RETENTION_PERIOD 97
|
||||
#define TK_WAL_RETENTION_SIZE 98
|
||||
#define TK_WAL_ROLL_PERIOD 99
|
||||
#define TK_WAL_SEGMENT_SIZE 100
|
||||
#define TK_STT_TRIGGER 101
|
||||
#define TK_TABLE_PREFIX 102
|
||||
#define TK_TABLE_SUFFIX 103
|
||||
#define TK_S3_CHUNKSIZE 104
|
||||
#define TK_S3_KEEPLOCAL 105
|
||||
#define TK_S3_COMPACT 106
|
||||
#define TK_KEEP_TIME_OFFSET 107
|
||||
#define TK_ENCRYPT_ALGORITHM 108
|
||||
#define TK_NK_COLON 109
|
||||
#define TK_BWLIMIT 110
|
||||
#define TK_START 111
|
||||
#define TK_TIMESTAMP 112
|
||||
#define TK_END 113
|
||||
#define TK_TABLE 114
|
||||
#define TK_NK_LP 115
|
||||
#define TK_NK_RP 116
|
||||
#define TK_USING 117
|
||||
#define TK_FILE 118
|
||||
#define TK_STABLE 119
|
||||
#define TK_COLUMN 120
|
||||
#define TK_MODIFY 121
|
||||
#define TK_RENAME 122
|
||||
#define TK_TAG 123
|
||||
#define TK_SET 124
|
||||
#define TK_NK_EQ 125
|
||||
#define TK_TAGS 126
|
||||
#define TK_BOOL 127
|
||||
#define TK_TINYINT 128
|
||||
#define TK_SMALLINT 129
|
||||
#define TK_INT 130
|
||||
#define TK_INTEGER 131
|
||||
#define TK_BIGINT 132
|
||||
#define TK_FLOAT 133
|
||||
#define TK_DOUBLE 134
|
||||
#define TK_BINARY 135
|
||||
#define TK_NCHAR 136
|
||||
#define TK_UNSIGNED 137
|
||||
#define TK_JSON 138
|
||||
#define TK_VARCHAR 139
|
||||
#define TK_MEDIUMBLOB 140
|
||||
#define TK_BLOB 141
|
||||
#define TK_VARBINARY 142
|
||||
#define TK_GEOMETRY 143
|
||||
#define TK_DECIMAL 144
|
||||
#define TK_COMMENT 145
|
||||
#define TK_MAX_DELAY 146
|
||||
#define TK_WATERMARK 147
|
||||
#define TK_ROLLUP 148
|
||||
#define TK_TTL 149
|
||||
#define TK_SMA 150
|
||||
#define TK_DELETE_MARK 151
|
||||
#define TK_FIRST 152
|
||||
#define TK_LAST 153
|
||||
#define TK_SHOW 154
|
||||
#define TK_FULL 155
|
||||
#define TK_PRIVILEGES 156
|
||||
#define TK_DATABASES 157
|
||||
#define TK_TABLES 158
|
||||
#define TK_STABLES 159
|
||||
#define TK_MNODES 160
|
||||
#define TK_QNODES 161
|
||||
#define TK_ARBGROUPS 162
|
||||
#define TK_FUNCTIONS 163
|
||||
#define TK_INDEXES 164
|
||||
#define TK_ACCOUNTS 165
|
||||
#define TK_APPS 166
|
||||
#define TK_CONNECTIONS 167
|
||||
#define TK_LICENCES 168
|
||||
#define TK_GRANTS 169
|
||||
#define TK_LOGS 170
|
||||
#define TK_MACHINES 171
|
||||
#define TK_ENCRYPTIONS 172
|
||||
#define TK_QUERIES 173
|
||||
#define TK_SCORES 174
|
||||
#define TK_TOPICS 175
|
||||
#define TK_VARIABLES 176
|
||||
#define TK_BNODES 177
|
||||
#define TK_SNODES 178
|
||||
#define TK_TRANSACTIONS 179
|
||||
#define TK_DISTRIBUTED 180
|
||||
#define TK_CONSUMERS 181
|
||||
#define TK_SUBSCRIPTIONS 182
|
||||
#define TK_VNODES 183
|
||||
#define TK_ALIVE 184
|
||||
#define TK_VIEWS 185
|
||||
#define TK_VIEW 186
|
||||
#define TK_COMPACTS 187
|
||||
#define TK_NORMAL 188
|
||||
#define TK_CHILD 189
|
||||
#define TK_LIKE 190
|
||||
#define TK_TBNAME 191
|
||||
#define TK_QTAGS 192
|
||||
#define TK_AS 193
|
||||
#define TK_SYSTEM 194
|
||||
#define TK_TSMA 195
|
||||
#define TK_INTERVAL 196
|
||||
#define TK_RECURSIVE 197
|
||||
#define TK_TSMAS 198
|
||||
#define TK_FUNCTION 199
|
||||
#define TK_INDEX 200
|
||||
#define TK_COUNT 201
|
||||
#define TK_LAST_ROW 202
|
||||
#define TK_META 203
|
||||
#define TK_ONLY 204
|
||||
#define TK_TOPIC 205
|
||||
#define TK_CONSUMER 206
|
||||
#define TK_GROUP 207
|
||||
#define TK_DESC 208
|
||||
#define TK_DESCRIBE 209
|
||||
#define TK_RESET 210
|
||||
#define TK_QUERY 211
|
||||
#define TK_CACHE 212
|
||||
#define TK_EXPLAIN 213
|
||||
#define TK_ANALYZE 214
|
||||
#define TK_VERBOSE 215
|
||||
#define TK_NK_BOOL 216
|
||||
#define TK_RATIO 217
|
||||
#define TK_NK_FLOAT 218
|
||||
#define TK_OUTPUTTYPE 219
|
||||
#define TK_AGGREGATE 220
|
||||
#define TK_BUFSIZE 221
|
||||
#define TK_LANGUAGE 222
|
||||
#define TK_REPLACE 223
|
||||
#define TK_STREAM 224
|
||||
#define TK_INTO 225
|
||||
#define TK_PAUSE 226
|
||||
#define TK_RESUME 227
|
||||
#define TK_PRIMARY 228
|
||||
#define TK_KEY 229
|
||||
#define TK_TRIGGER 230
|
||||
#define TK_AT_ONCE 231
|
||||
#define TK_WINDOW_CLOSE 232
|
||||
#define TK_IGNORE 233
|
||||
#define TK_EXPIRED 234
|
||||
#define TK_FILL_HISTORY 235
|
||||
#define TK_UPDATE 236
|
||||
#define TK_SUBTABLE 237
|
||||
#define TK_UNTREATED 238
|
||||
#define TK_KILL 239
|
||||
#define TK_CONNECTION 240
|
||||
#define TK_TRANSACTION 241
|
||||
#define TK_BALANCE 242
|
||||
#define TK_VGROUP 243
|
||||
#define TK_LEADER 244
|
||||
#define TK_MERGE 245
|
||||
#define TK_REDISTRIBUTE 246
|
||||
#define TK_SPLIT 247
|
||||
#define TK_DELETE 248
|
||||
#define TK_INSERT 249
|
||||
#define TK_NK_BIN 250
|
||||
#define TK_NK_HEX 251
|
||||
#define TK_NULL 252
|
||||
#define TK_NK_QUESTION 253
|
||||
#define TK_NK_ALIAS 254
|
||||
#define TK_NK_ARROW 255
|
||||
#define TK_ROWTS 256
|
||||
#define TK_QSTART 257
|
||||
#define TK_QEND 258
|
||||
#define TK_QDURATION 259
|
||||
#define TK_WSTART 260
|
||||
#define TK_WEND 261
|
||||
#define TK_WDURATION 262
|
||||
#define TK_IROWTS 263
|
||||
#define TK_ISFILLED 264
|
||||
#define TK_CAST 265
|
||||
#define TK_POSITION 266
|
||||
#define TK_IN 267
|
||||
#define TK_FOR 268
|
||||
#define TK_NOW 269
|
||||
#define TK_TODAY 270
|
||||
#define TK_RAND 271
|
||||
#define TK_SUBSTR 272
|
||||
#define TK_SUBSTRING 273
|
||||
#define TK_BOTH 274
|
||||
#define TK_TRAILING 275
|
||||
#define TK_LEADING 276
|
||||
#define TK_TIMEZONE 277
|
||||
#define TK_CLIENT_VERSION 278
|
||||
#define TK_SERVER_VERSION 279
|
||||
#define TK_SERVER_STATUS 280
|
||||
#define TK_CURRENT_USER 281
|
||||
#define TK_PI 282
|
||||
#define TK_CASE 283
|
||||
#define TK_WHEN 284
|
||||
#define TK_THEN 285
|
||||
#define TK_ELSE 286
|
||||
#define TK_BETWEEN 287
|
||||
#define TK_IS 288
|
||||
#define TK_NK_LT 289
|
||||
#define TK_NK_GT 290
|
||||
#define TK_NK_LE 291
|
||||
#define TK_NK_GE 292
|
||||
#define TK_NK_NE 293
|
||||
#define TK_MATCH 294
|
||||
#define TK_NMATCH 295
|
||||
#define TK_CONTAINS 296
|
||||
#define TK_JOIN 297
|
||||
#define TK_INNER 298
|
||||
#define TK_LEFT 299
|
||||
#define TK_RIGHT 300
|
||||
#define TK_OUTER 301
|
||||
#define TK_SEMI 302
|
||||
#define TK_ANTI 303
|
||||
#define TK_ASOF 304
|
||||
#define TK_WINDOW 305
|
||||
#define TK_WINDOW_OFFSET 306
|
||||
#define TK_JLIMIT 307
|
||||
#define TK_SELECT 308
|
||||
#define TK_NK_HINT 309
|
||||
#define TK_DISTINCT 310
|
||||
#define TK_WHERE 311
|
||||
#define TK_PARTITION 312
|
||||
#define TK_BY 313
|
||||
#define TK_SESSION 314
|
||||
#define TK_STATE_WINDOW 315
|
||||
#define TK_EVENT_WINDOW 316
|
||||
#define TK_COUNT_WINDOW 317
|
||||
#define TK_SLIDING 318
|
||||
#define TK_FILL 319
|
||||
#define TK_VALUE 320
|
||||
#define TK_VALUE_F 321
|
||||
#define TK_NONE 322
|
||||
#define TK_PREV 323
|
||||
#define TK_NULL_F 324
|
||||
#define TK_LINEAR 325
|
||||
#define TK_NEXT 326
|
||||
#define TK_HAVING 327
|
||||
#define TK_RANGE 328
|
||||
#define TK_EVERY 329
|
||||
#define TK_ORDER 330
|
||||
#define TK_SLIMIT 331
|
||||
#define TK_SOFFSET 332
|
||||
#define TK_LIMIT 333
|
||||
#define TK_OFFSET 334
|
||||
#define TK_ASC 335
|
||||
#define TK_NULLS 336
|
||||
#define TK_ABORT 337
|
||||
#define TK_AFTER 338
|
||||
#define TK_ATTACH 339
|
||||
#define TK_BEFORE 340
|
||||
#define TK_BEGIN 341
|
||||
#define TK_BITAND 342
|
||||
#define TK_BITNOT 343
|
||||
#define TK_BITOR 344
|
||||
#define TK_BLOCKS 345
|
||||
#define TK_CHANGE 346
|
||||
#define TK_COMMA 347
|
||||
#define TK_CONCAT 348
|
||||
#define TK_CONFLICT 349
|
||||
#define TK_COPY 350
|
||||
#define TK_DEFERRED 351
|
||||
#define TK_DELIMITERS 352
|
||||
#define TK_DETACH 353
|
||||
#define TK_DIVIDE 354
|
||||
#define TK_DOT 355
|
||||
#define TK_EACH 356
|
||||
#define TK_FAIL 357
|
||||
#define TK_GLOB 358
|
||||
#define TK_ID 359
|
||||
#define TK_IMMEDIATE 360
|
||||
#define TK_IMPORT 361
|
||||
#define TK_INITIALLY 362
|
||||
#define TK_INSTEAD 363
|
||||
#define TK_ISNULL 364
|
||||
#define TK_MODULES 365
|
||||
#define TK_NK_BITNOT 366
|
||||
#define TK_NK_SEMI 367
|
||||
#define TK_NOTNULL 368
|
||||
#define TK_OF 369
|
||||
#define TK_PLUS 370
|
||||
#define TK_PRIVILEGE 371
|
||||
#define TK_RAISE 372
|
||||
#define TK_RESTRICT 373
|
||||
#define TK_ROW 374
|
||||
#define TK_STAR 375
|
||||
#define TK_STATEMENT 376
|
||||
#define TK_STRICT 377
|
||||
#define TK_STRING 378
|
||||
#define TK_TIMES 379
|
||||
#define TK_VALUES 380
|
||||
#define TK_VARIABLE 381
|
||||
#define TK_WAL 382
|
||||
#define TK_ANODE 54
|
||||
#define TK_UPDATE 55
|
||||
#define TK_ANODES 56
|
||||
#define TK_DNODE 57
|
||||
#define TK_PORT 58
|
||||
#define TK_DNODES 59
|
||||
#define TK_RESTORE 60
|
||||
#define TK_NK_IPTOKEN 61
|
||||
#define TK_FORCE 62
|
||||
#define TK_UNSAFE 63
|
||||
#define TK_CLUSTER 64
|
||||
#define TK_LOCAL 65
|
||||
#define TK_QNODE 66
|
||||
#define TK_BNODE 67
|
||||
#define TK_SNODE 68
|
||||
#define TK_MNODE 69
|
||||
#define TK_VNODE 70
|
||||
#define TK_DATABASE 71
|
||||
#define TK_USE 72
|
||||
#define TK_FLUSH 73
|
||||
#define TK_TRIM 74
|
||||
#define TK_S3MIGRATE 75
|
||||
#define TK_COMPACT 76
|
||||
#define TK_IF 77
|
||||
#define TK_NOT 78
|
||||
#define TK_EXISTS 79
|
||||
#define TK_BUFFER 80
|
||||
#define TK_CACHEMODEL 81
|
||||
#define TK_CACHESIZE 82
|
||||
#define TK_COMP 83
|
||||
#define TK_DURATION 84
|
||||
#define TK_NK_VARIABLE 85
|
||||
#define TK_MAXROWS 86
|
||||
#define TK_MINROWS 87
|
||||
#define TK_KEEP 88
|
||||
#define TK_PAGES 89
|
||||
#define TK_PAGESIZE 90
|
||||
#define TK_TSDB_PAGESIZE 91
|
||||
#define TK_PRECISION 92
|
||||
#define TK_REPLICA 93
|
||||
#define TK_VGROUPS 94
|
||||
#define TK_SINGLE_STABLE 95
|
||||
#define TK_RETENTIONS 96
|
||||
#define TK_SCHEMALESS 97
|
||||
#define TK_WAL_LEVEL 98
|
||||
#define TK_WAL_FSYNC_PERIOD 99
|
||||
#define TK_WAL_RETENTION_PERIOD 100
|
||||
#define TK_WAL_RETENTION_SIZE 101
|
||||
#define TK_WAL_ROLL_PERIOD 102
|
||||
#define TK_WAL_SEGMENT_SIZE 103
|
||||
#define TK_STT_TRIGGER 104
|
||||
#define TK_TABLE_PREFIX 105
|
||||
#define TK_TABLE_SUFFIX 106
|
||||
#define TK_S3_CHUNKSIZE 107
|
||||
#define TK_S3_KEEPLOCAL 108
|
||||
#define TK_S3_COMPACT 109
|
||||
#define TK_KEEP_TIME_OFFSET 110
|
||||
#define TK_ENCRYPT_ALGORITHM 111
|
||||
#define TK_NK_COLON 112
|
||||
#define TK_BWLIMIT 113
|
||||
#define TK_START 114
|
||||
#define TK_TIMESTAMP 115
|
||||
#define TK_END 116
|
||||
#define TK_TABLE 117
|
||||
#define TK_NK_LP 118
|
||||
#define TK_NK_RP 119
|
||||
#define TK_USING 120
|
||||
#define TK_FILE 121
|
||||
#define TK_STABLE 122
|
||||
#define TK_COLUMN 123
|
||||
#define TK_MODIFY 124
|
||||
#define TK_RENAME 125
|
||||
#define TK_TAG 126
|
||||
#define TK_SET 127
|
||||
#define TK_NK_EQ 128
|
||||
#define TK_TAGS 129
|
||||
#define TK_BOOL 130
|
||||
#define TK_TINYINT 131
|
||||
#define TK_SMALLINT 132
|
||||
#define TK_INT 133
|
||||
#define TK_INTEGER 134
|
||||
#define TK_BIGINT 135
|
||||
#define TK_FLOAT 136
|
||||
#define TK_DOUBLE 137
|
||||
#define TK_BINARY 138
|
||||
#define TK_NCHAR 139
|
||||
#define TK_UNSIGNED 140
|
||||
#define TK_JSON 141
|
||||
#define TK_VARCHAR 142
|
||||
#define TK_MEDIUMBLOB 143
|
||||
#define TK_BLOB 144
|
||||
#define TK_VARBINARY 145
|
||||
#define TK_GEOMETRY 146
|
||||
#define TK_DECIMAL 147
|
||||
#define TK_COMMENT 148
|
||||
#define TK_MAX_DELAY 149
|
||||
#define TK_WATERMARK 150
|
||||
#define TK_ROLLUP 151
|
||||
#define TK_TTL 152
|
||||
#define TK_SMA 153
|
||||
#define TK_DELETE_MARK 154
|
||||
#define TK_FIRST 155
|
||||
#define TK_LAST 156
|
||||
#define TK_SHOW 157
|
||||
#define TK_FULL 158
|
||||
#define TK_PRIVILEGES 159
|
||||
#define TK_DATABASES 160
|
||||
#define TK_TABLES 161
|
||||
#define TK_STABLES 162
|
||||
#define TK_MNODES 163
|
||||
#define TK_QNODES 164
|
||||
#define TK_ARBGROUPS 165
|
||||
#define TK_FUNCTIONS 166
|
||||
#define TK_INDEXES 167
|
||||
#define TK_ACCOUNTS 168
|
||||
#define TK_APPS 169
|
||||
#define TK_CONNECTIONS 170
|
||||
#define TK_LICENCES 171
|
||||
#define TK_GRANTS 172
|
||||
#define TK_LOGS 173
|
||||
#define TK_MACHINES 174
|
||||
#define TK_ENCRYPTIONS 175
|
||||
#define TK_QUERIES 176
|
||||
#define TK_SCORES 177
|
||||
#define TK_TOPICS 178
|
||||
#define TK_VARIABLES 179
|
||||
#define TK_BNODES 180
|
||||
#define TK_SNODES 181
|
||||
#define TK_TRANSACTIONS 182
|
||||
#define TK_DISTRIBUTED 183
|
||||
#define TK_CONSUMERS 184
|
||||
#define TK_SUBSCRIPTIONS 185
|
||||
#define TK_VNODES 186
|
||||
#define TK_ALIVE 187
|
||||
#define TK_VIEWS 188
|
||||
#define TK_VIEW 189
|
||||
#define TK_COMPACTS 190
|
||||
#define TK_NORMAL 191
|
||||
#define TK_CHILD 192
|
||||
#define TK_LIKE 193
|
||||
#define TK_TBNAME 194
|
||||
#define TK_QTAGS 195
|
||||
#define TK_AS 196
|
||||
#define TK_SYSTEM 197
|
||||
#define TK_TSMA 198
|
||||
#define TK_INTERVAL 199
|
||||
#define TK_RECURSIVE 200
|
||||
#define TK_TSMAS 201
|
||||
#define TK_FUNCTION 202
|
||||
#define TK_INDEX 203
|
||||
#define TK_COUNT 204
|
||||
#define TK_LAST_ROW 205
|
||||
#define TK_META 206
|
||||
#define TK_ONLY 207
|
||||
#define TK_TOPIC 208
|
||||
#define TK_CONSUMER 209
|
||||
#define TK_GROUP 210
|
||||
#define TK_DESC 211
|
||||
#define TK_DESCRIBE 212
|
||||
#define TK_RESET 213
|
||||
#define TK_QUERY 214
|
||||
#define TK_CACHE 215
|
||||
#define TK_EXPLAIN 216
|
||||
#define TK_ANALYZE 217
|
||||
#define TK_VERBOSE 218
|
||||
#define TK_NK_BOOL 219
|
||||
#define TK_RATIO 220
|
||||
#define TK_NK_FLOAT 221
|
||||
#define TK_OUTPUTTYPE 222
|
||||
#define TK_AGGREGATE 223
|
||||
#define TK_BUFSIZE 224
|
||||
#define TK_LANGUAGE 225
|
||||
#define TK_REPLACE 226
|
||||
#define TK_STREAM 227
|
||||
#define TK_INTO 228
|
||||
#define TK_PAUSE 229
|
||||
#define TK_RESUME 230
|
||||
#define TK_PRIMARY 231
|
||||
#define TK_KEY 232
|
||||
#define TK_TRIGGER 233
|
||||
#define TK_AT_ONCE 234
|
||||
#define TK_WINDOW_CLOSE 235
|
||||
#define TK_IGNORE 236
|
||||
#define TK_EXPIRED 237
|
||||
#define TK_FILL_HISTORY 238
|
||||
#define TK_SUBTABLE 239
|
||||
#define TK_UNTREATED 240
|
||||
#define TK_KILL 241
|
||||
#define TK_CONNECTION 242
|
||||
#define TK_TRANSACTION 243
|
||||
#define TK_BALANCE 244
|
||||
#define TK_VGROUP 245
|
||||
#define TK_LEADER 246
|
||||
#define TK_MERGE 247
|
||||
#define TK_REDISTRIBUTE 248
|
||||
#define TK_SPLIT 249
|
||||
#define TK_DELETE 250
|
||||
#define TK_INSERT 251
|
||||
#define TK_NK_BIN 252
|
||||
#define TK_NK_HEX 253
|
||||
#define TK_NULL 254
|
||||
#define TK_NK_QUESTION 255
|
||||
#define TK_NK_ALIAS 256
|
||||
#define TK_NK_ARROW 257
|
||||
#define TK_ROWTS 258
|
||||
#define TK_QSTART 259
|
||||
#define TK_QEND 260
|
||||
#define TK_QDURATION 261
|
||||
#define TK_WSTART 262
|
||||
#define TK_WEND 263
|
||||
#define TK_WDURATION 264
|
||||
#define TK_IROWTS 265
|
||||
#define TK_ISFILLED 266
|
||||
#define TK_FLOW 267
|
||||
#define TK_FHIGH 268
|
||||
#define TK_FROWTS 269
|
||||
#define TK_CAST 270
|
||||
#define TK_POSITION 271
|
||||
#define TK_IN 272
|
||||
#define TK_FOR 273
|
||||
#define TK_NOW 274
|
||||
#define TK_TODAY 275
|
||||
#define TK_RAND 276
|
||||
#define TK_SUBSTR 277
|
||||
#define TK_SUBSTRING 278
|
||||
#define TK_BOTH 279
|
||||
#define TK_TRAILING 280
|
||||
#define TK_LEADING 281
|
||||
#define TK_TIMEZONE 282
|
||||
#define TK_CLIENT_VERSION 283
|
||||
#define TK_SERVER_VERSION 284
|
||||
#define TK_SERVER_STATUS 285
|
||||
#define TK_CURRENT_USER 286
|
||||
#define TK_PI 287
|
||||
#define TK_CASE 288
|
||||
#define TK_WHEN 289
|
||||
#define TK_THEN 290
|
||||
#define TK_ELSE 291
|
||||
#define TK_BETWEEN 292
|
||||
#define TK_IS 293
|
||||
#define TK_NK_LT 294
|
||||
#define TK_NK_GT 295
|
||||
#define TK_NK_LE 296
|
||||
#define TK_NK_GE 297
|
||||
#define TK_NK_NE 298
|
||||
#define TK_MATCH 299
|
||||
#define TK_NMATCH 300
|
||||
#define TK_CONTAINS 301
|
||||
#define TK_JOIN 302
|
||||
#define TK_INNER 303
|
||||
#define TK_LEFT 304
|
||||
#define TK_RIGHT 305
|
||||
#define TK_OUTER 306
|
||||
#define TK_SEMI 307
|
||||
#define TK_ANTI 308
|
||||
#define TK_ASOF 309
|
||||
#define TK_WINDOW 310
|
||||
#define TK_WINDOW_OFFSET 311
|
||||
#define TK_JLIMIT 312
|
||||
#define TK_SELECT 313
|
||||
#define TK_NK_HINT 314
|
||||
#define TK_DISTINCT 315
|
||||
#define TK_WHERE 316
|
||||
#define TK_PARTITION 317
|
||||
#define TK_BY 318
|
||||
#define TK_SESSION 319
|
||||
#define TK_STATE_WINDOW 320
|
||||
#define TK_EVENT_WINDOW 321
|
||||
#define TK_COUNT_WINDOW 322
|
||||
#define TK_ANOMALY_WINDOW 323
|
||||
#define TK_SLIDING 324
|
||||
#define TK_FILL 325
|
||||
#define TK_VALUE 326
|
||||
#define TK_VALUE_F 327
|
||||
#define TK_NONE 328
|
||||
#define TK_PREV 329
|
||||
#define TK_NULL_F 330
|
||||
#define TK_LINEAR 331
|
||||
#define TK_NEXT 332
|
||||
#define TK_HAVING 333
|
||||
#define TK_RANGE 334
|
||||
#define TK_EVERY 335
|
||||
#define TK_ORDER 336
|
||||
#define TK_SLIMIT 337
|
||||
#define TK_SOFFSET 338
|
||||
#define TK_LIMIT 339
|
||||
#define TK_OFFSET 340
|
||||
#define TK_ASC 341
|
||||
#define TK_NULLS 342
|
||||
#define TK_ABORT 343
|
||||
#define TK_AFTER 344
|
||||
#define TK_ATTACH 345
|
||||
#define TK_BEFORE 346
|
||||
#define TK_BEGIN 347
|
||||
#define TK_BITAND 348
|
||||
#define TK_BITNOT 349
|
||||
#define TK_BITOR 350
|
||||
#define TK_BLOCKS 351
|
||||
#define TK_CHANGE 352
|
||||
#define TK_COMMA 353
|
||||
#define TK_CONCAT 354
|
||||
#define TK_CONFLICT 355
|
||||
#define TK_COPY 356
|
||||
#define TK_DEFERRED 357
|
||||
#define TK_DELIMITERS 358
|
||||
#define TK_DETACH 359
|
||||
#define TK_DIVIDE 360
|
||||
#define TK_DOT 361
|
||||
#define TK_EACH 362
|
||||
#define TK_FAIL 363
|
||||
#define TK_GLOB 364
|
||||
#define TK_ID 365
|
||||
#define TK_IMMEDIATE 366
|
||||
#define TK_IMPORT 367
|
||||
#define TK_INITIALLY 368
|
||||
#define TK_INSTEAD 369
|
||||
#define TK_ISNULL 370
|
||||
#define TK_MODULES 371
|
||||
#define TK_NK_BITNOT 372
|
||||
#define TK_NK_SEMI 373
|
||||
#define TK_NOTNULL 374
|
||||
#define TK_OF 375
|
||||
#define TK_PLUS 376
|
||||
#define TK_PRIVILEGE 377
|
||||
#define TK_RAISE 378
|
||||
#define TK_RESTRICT 379
|
||||
#define TK_ROW 380
|
||||
#define TK_STAR 381
|
||||
#define TK_STATEMENT 382
|
||||
#define TK_STRICT 383
|
||||
#define TK_STRING 384
|
||||
#define TK_TIMES 385
|
||||
#define TK_VALUES 386
|
||||
#define TK_VARIABLE 387
|
||||
#define TK_WAL 388
|
||||
|
||||
#define TK_NK_SPACE 600
|
||||
#define TK_NK_COMMENT 601
|
||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
// variant, each number/string/field_id has a corresponding struct during parsing sql
|
||||
// **NOTE**: if you want to change this struct, please consider the backward compatibility of function top and bottom.
|
||||
typedef struct SVariant {
|
||||
uint32_t nType;
|
||||
int32_t nLen; // only used for string, for number, it is useless
|
||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
|||
#include "tcommon.h"
|
||||
#include "tsimplehash.h"
|
||||
#include "tvariant.h"
|
||||
#include "functionResInfo.h"
|
||||
|
||||
struct SqlFunctionCtx;
|
||||
struct SResultRowEntryInfo;
|
||||
|
@ -85,14 +86,7 @@ enum {
|
|||
PRE_SCAN = 0x2u, // pre-scan belongs to the main scan and occurs before main scan
|
||||
};
|
||||
|
||||
typedef struct SPoint1 {
|
||||
int64_t key;
|
||||
union {
|
||||
double val;
|
||||
char *ptr;
|
||||
};
|
||||
} SPoint1;
|
||||
|
||||
struct SPoint1;
|
||||
struct SqlFunctionCtx;
|
||||
struct SResultRowEntryInfo;
|
||||
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_FUNCTIONRESINFO_H
|
||||
#define TDENGINE_FUNCTIONRESINFO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "tcommon.h"
|
||||
|
||||
typedef struct STuplePos {
|
||||
union {
|
||||
struct {
|
||||
int32_t pageId;
|
||||
int32_t offset;
|
||||
};
|
||||
SWinKey streamTupleKey;
|
||||
};
|
||||
} STuplePos;
|
||||
|
||||
typedef struct SCentroid {
|
||||
double mean;
|
||||
int64_t weight;
|
||||
} SCentroid;
|
||||
|
||||
typedef struct SPt {
|
||||
double value;
|
||||
int64_t weight;
|
||||
} SPt;
|
||||
|
||||
typedef struct TDigest {
|
||||
double compression;
|
||||
int32_t threshold;
|
||||
int64_t size;
|
||||
|
||||
int64_t total_weight;
|
||||
double min;
|
||||
double max;
|
||||
|
||||
int32_t num_buffered_pts;
|
||||
SPt *buffered_pts;
|
||||
|
||||
int32_t num_centroids;
|
||||
SCentroid *centroids;
|
||||
} TDigest;
|
||||
|
||||
typedef struct SFirstLastRes {
|
||||
bool hasResult;
|
||||
// used for last_row function only, isNullRes in SResultRowEntry can not be passed to downstream.So,
|
||||
// this attribute is required
|
||||
bool isNull;
|
||||
int32_t bytes;
|
||||
int64_t ts;
|
||||
char* pkData;
|
||||
int32_t pkBytes;
|
||||
int8_t pkType;
|
||||
STuplePos pos;
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
char buf[];
|
||||
} SFirstLastRes;
|
||||
|
||||
typedef struct SPoint1 {
|
||||
int64_t key;
|
||||
union {
|
||||
double val;
|
||||
char *ptr;
|
||||
};
|
||||
} SPoint1;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TDENGINE_FUNCTIONRESINFO_H
|
|
@ -320,7 +320,7 @@ typedef struct SAlterDnodeStmt {
|
|||
|
||||
typedef struct {
|
||||
ENodeType type;
|
||||
char url[TSDB_ANAL_ANODE_URL_LEN];
|
||||
char url[TSDB_ANAL_ANODE_URL_LEN + 3];
|
||||
} SCreateAnodeStmt;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -247,9 +247,12 @@ void syslog(int unused, const char *format, ...);
|
|||
#define TD_DIRSEP_CHAR '/'
|
||||
#endif
|
||||
|
||||
#define TD_FQDN_LEN 128
|
||||
#define TD_LOCALE_LEN 64
|
||||
#define TD_CHARSET_LEN 64
|
||||
#define TD_TIMEZONE_LEN 96
|
||||
#define TD_TIME_STR_LEN 128
|
||||
#define TD_IP_LEN 64
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -85,7 +85,6 @@ typedef int32_t SOCKET;
|
|||
#else
|
||||
#define TAOS_EPOLL_WAIT_TIME 500
|
||||
typedef int32_t SOCKET;
|
||||
typedef SOCKET EpollFd;
|
||||
#define EpollClose(pollFd) taosCloseSocket(pollFd)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -59,12 +59,13 @@ typedef enum { M2C = 0, C2M } ConvType;
|
|||
|
||||
#endif
|
||||
|
||||
#define tstrncpy(dst, src, size) \
|
||||
do { \
|
||||
#define tstrncpy(dst, src, size) \
|
||||
do { \
|
||||
(void)strncpy((dst), (src), (size)); \
|
||||
(dst)[(size)-1] = 0; \
|
||||
(dst)[(size) - 1] = 0; \
|
||||
} while (0)
|
||||
|
||||
int64_t tsnprintf(char *dst, int64_t size, const char *format, ...);
|
||||
#define TAOS_STRCPY(_dst, _src) ((void)strcpy(_dst, _src))
|
||||
#define TAOS_STRNCPY(_dst, _src, _size) ((void)strncpy(_dst, _src, _size))
|
||||
#define TAOS_STRCAT(_dst, _src) ((void)strcat(_dst, _src))
|
||||
|
@ -87,7 +88,7 @@ bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs
|
|||
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||
int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
bool taosValidateEncodec(const char *encodec);
|
||||
int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len);
|
||||
int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len, int32_t bufSize);
|
||||
int32_t taosHexDecode(const char *src, char *dst, int32_t len);
|
||||
|
||||
int32_t taosWcharWidth(TdWchar wchar);
|
||||
|
|
|
@ -52,7 +52,8 @@ int32_t taosGetCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes);
|
|||
void taosSetDefaultCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes);
|
||||
|
||||
void taosKillSystem();
|
||||
int32_t taosGetSystemUUID(char *uid, int32_t uidlen);
|
||||
int32_t taosGetSystemUUIDLimit36(char *uid, int32_t uidlen);
|
||||
int32_t taosGetSystemUUIDLen(char *uid, int32_t uidlen);
|
||||
char *taosGetCmdlineByPID(int32_t pid);
|
||||
void taosSetCoreDump(bool enable);
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ static FORCE_INLINE int64_t taosGetMonoTimestampMs() {
|
|||
}
|
||||
|
||||
char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm);
|
||||
struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf);
|
||||
struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf, int32_t bufSize);
|
||||
struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst);
|
||||
time_t taosTime(time_t *t);
|
||||
time_t taosMktime(struct tm *timep);
|
||||
|
|
|
@ -482,9 +482,10 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_MND_ANODE_TOO_LONG_URL TAOS_DEF_ERROR_CODE(0, 0x0432)
|
||||
#define TSDB_CODE_MND_ANODE_INVALID_PROTOCOL TAOS_DEF_ERROR_CODE(0, 0x0433)
|
||||
#define TSDB_CODE_MND_ANODE_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0434)
|
||||
#define TSDB_CODE_MND_ANODE_TOO_MANY_ALGO TAOS_DEF_ERROR_CODE(0, 0x0435)
|
||||
#define TSDB_CODE_MND_ANODE_TOO_LONG_ALGO_NAME TAOS_DEF_ERROR_CODE(0, 0x0436)
|
||||
#define TSDB_CODE_MND_ANODE_TOO_MANY_ALGO_TYPE TAOS_DEF_ERROR_CODE(0, 0x0437)
|
||||
#define TSDB_CODE_MND_ANODE_INVALID_ALGO_TYPE TAOS_DEF_ERROR_CODE(0, 0x0435)
|
||||
#define TSDB_CODE_MND_ANODE_TOO_MANY_ALGO TAOS_DEF_ERROR_CODE(0, 0x0436)
|
||||
#define TSDB_CODE_MND_ANODE_TOO_LONG_ALGO_NAME TAOS_DEF_ERROR_CODE(0, 0x0437)
|
||||
#define TSDB_CODE_MND_ANODE_TOO_MANY_ALGO_TYPE TAOS_DEF_ERROR_CODE(0, 0x0438)
|
||||
|
||||
// analysis
|
||||
#define TSDB_CODE_ANAL_URL_RSP_IS_NULL TAOS_DEF_ERROR_CODE(0, 0x0440)
|
||||
|
|
|
@ -284,7 +284,7 @@ typedef enum ELogicConditionType {
|
|||
|
||||
#define TSDB_CLUSTER_ID_LEN 40
|
||||
#define TSDB_MACHINE_ID_LEN 24
|
||||
#define TSDB_FQDN_LEN 128
|
||||
#define TSDB_FQDN_LEN TD_FQDN_LEN
|
||||
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
|
||||
#define TSDB_IPv4ADDR_LEN 16
|
||||
#define TSDB_FILENAME_LEN 128
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#define TDIGEST_H
|
||||
|
||||
#include "os.h"
|
||||
#include "libs/function/functionResInfo.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327950288 /* pi */
|
||||
|
@ -37,32 +38,6 @@
|
|||
#define TDIGEST_SIZE(compression) \
|
||||
(sizeof(TDigest) + sizeof(SCentroid) * GET_CENTROID(compression) + sizeof(SPt) * GET_THRESHOLD(compression))
|
||||
|
||||
typedef struct SCentroid {
|
||||
double mean;
|
||||
int64_t weight;
|
||||
} SCentroid;
|
||||
|
||||
typedef struct SPt {
|
||||
double value;
|
||||
int64_t weight;
|
||||
} SPt;
|
||||
|
||||
typedef struct TDigest {
|
||||
double compression;
|
||||
int32_t threshold;
|
||||
int64_t size;
|
||||
|
||||
int64_t total_weight;
|
||||
double min;
|
||||
double max;
|
||||
|
||||
int32_t num_buffered_pts;
|
||||
SPt *buffered_pts;
|
||||
|
||||
int32_t num_centroids;
|
||||
SCentroid *centroids;
|
||||
} TDigest;
|
||||
|
||||
TDigest *tdigestNewFrom(void *pBuf, int32_t compression);
|
||||
int32_t tdigestAdd(TDigest *t, double x, int64_t w);
|
||||
int32_t tdigestMerge(TDigest *t1, TDigest *t2);
|
||||
|
|
|
@ -71,6 +71,7 @@ int32_t tjsonGetObjectValueString(const SJson* pJson, char** pStringValue);
|
|||
void tjsonGetObjectValueBigInt(const SJson* pJson, int64_t* pVal);
|
||||
void tjsonGetObjectValueDouble(const SJson* pJson, double* pVal);
|
||||
int32_t tjsonGetStringValue(const SJson* pJson, const char* pName, char* pVal);
|
||||
int32_t tjsonGetStringValue2(const SJson* pJson, const char* pName, char* pVal, int32_t maxLen);
|
||||
int32_t tjsonDupStringValue(const SJson* pJson, const char* pName, char** pVal);
|
||||
int32_t tjsonGetBigIntValue(const SJson* pJson, const char* pName, int64_t* pVal);
|
||||
int32_t tjsonGetIntValue(const SJson* pJson, const char* pName, int32_t* pVal);
|
||||
|
|
|
@ -48,3 +48,6 @@ int64_t tGenIdPI64(void);
|
|||
* @return
|
||||
*/
|
||||
int64_t tGenQid64(int8_t dnodeId);
|
||||
|
||||
int32_t taosGetSystemUUIDU32(uint32_t *uuid);
|
||||
int32_t taosGetSystemUUIDU64(uint64_t *uuid);
|
||||
|
|
|
@ -114,10 +114,10 @@ static void concatStrings(SArray *list, char *buf, int size) {
|
|||
db = dot + 1;
|
||||
}
|
||||
if (i != 0) {
|
||||
(void)strcat(buf, ",");
|
||||
(void)strncat(buf, ",", size - 1 - len);
|
||||
len += 1;
|
||||
}
|
||||
int ret = snprintf(buf + len, size - len, "%s", db);
|
||||
int ret = tsnprintf(buf + len, size - len, "%s", db);
|
||||
if (ret < 0) {
|
||||
tscError("snprintf failed, buf:%s, ret:%d", buf, ret);
|
||||
break;
|
||||
|
@ -1094,18 +1094,14 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
* @return
|
||||
*/
|
||||
uint64_t generateRequestId() {
|
||||
static uint64_t hashId = 0;
|
||||
static uint32_t requestSerialId = 0;
|
||||
static uint32_t hashId = 0;
|
||||
static int32_t requestSerialId = 0;
|
||||
|
||||
if (hashId == 0) {
|
||||
char uid[64] = {0};
|
||||
int32_t code = taosGetSystemUUID(uid, tListLen(uid));
|
||||
int32_t code = taosGetSystemUUIDU32(&hashId);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tscError("Failed to get the system uid to generated request id, reason:%s. use ip address instead",
|
||||
tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
||||
|
||||
} else {
|
||||
hashId = MurmurHash3_32(uid, strlen(uid));
|
||||
tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1117,7 +1113,7 @@ uint64_t generateRequestId() {
|
|||
uint32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
||||
if (val >= 0xFFFF) atomic_store_32(&requestSerialId, 0);
|
||||
|
||||
id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
|
||||
id = (((uint64_t)(hashId & 0x0FFF)) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
|
||||
if (id) {
|
||||
break;
|
||||
}
|
||||
|
@ -1132,27 +1128,27 @@ static setConfRet taos_set_config_imp(const char *config){
|
|||
static bool setConfFlag = false;
|
||||
if (setConfFlag) {
|
||||
ret.retCode = SET_CONF_RET_ERR_ONLY_ONCE;
|
||||
strcpy(ret.retMsg, "configuration can only set once");
|
||||
tstrncpy(ret.retMsg, "configuration can only set once", RET_MSG_LENGTH);
|
||||
return ret;
|
||||
}
|
||||
taosInitGlobalCfg();
|
||||
cJSON *root = cJSON_Parse(config);
|
||||
if (root == NULL){
|
||||
ret.retCode = SET_CONF_RET_ERR_JSON_PARSE;
|
||||
strcpy(ret.retMsg, "parse json error");
|
||||
tstrncpy(ret.retMsg, "parse json error", RET_MSG_LENGTH);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int size = cJSON_GetArraySize(root);
|
||||
if(!cJSON_IsObject(root) || size == 0) {
|
||||
ret.retCode = SET_CONF_RET_ERR_JSON_INVALID;
|
||||
strcpy(ret.retMsg, "json content is invalid, must be not empty object");
|
||||
tstrncpy(ret.retMsg, "json content is invalid, must be not empty object", RET_MSG_LENGTH);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(size >= 1000) {
|
||||
ret.retCode = SET_CONF_RET_ERR_TOO_LONG;
|
||||
strcpy(ret.retMsg, "json object size is too long");
|
||||
tstrncpy(ret.retMsg, "json object size is too long", RET_MSG_LENGTH);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1160,7 +1156,7 @@ static setConfRet taos_set_config_imp(const char *config){
|
|||
cJSON *item = cJSON_GetArrayItem(root, i);
|
||||
if(!item) {
|
||||
ret.retCode = SET_CONF_RET_ERR_INNER;
|
||||
strcpy(ret.retMsg, "inner error");
|
||||
tstrncpy(ret.retMsg, "inner error", RET_MSG_LENGTH);
|
||||
return ret;
|
||||
}
|
||||
if(!taosReadConfigOption(item->string, item->valuestring, NULL, NULL, TAOS_CFG_CSTATUS_OPTION, TSDB_CFG_CTYPE_B_CLIENT)){
|
||||
|
|
|
@ -772,7 +772,7 @@ static int32_t hbGetUserAuthInfo(SClientHbKey *connKey, SHbParam *param, SClient
|
|||
SUserAuthVersion *qUserAuth =
|
||||
(SUserAuthVersion *)taosMemoryRealloc(pKv->value, (userNum + 1) * sizeof(SUserAuthVersion));
|
||||
if (qUserAuth) {
|
||||
(void)strncpy((qUserAuth + userNum)->user, pTscObj->user, TSDB_USER_LEN);
|
||||
tstrncpy((qUserAuth + userNum)->user, pTscObj->user, TSDB_USER_LEN);
|
||||
(qUserAuth + userNum)->version = htonl(-1); // force get userAuthInfo
|
||||
pKv->value = qUserAuth;
|
||||
pKv->valueLen += sizeof(SUserAuthVersion);
|
||||
|
|
|
@ -1921,19 +1921,19 @@ TAOS* taos_connect_auth(const char* ip, const char* user, const char* auth, cons
|
|||
return NULL;
|
||||
}
|
||||
|
||||
TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen,
|
||||
const char* db, int dbLen, uint16_t port) {
|
||||
char ipStr[TSDB_EP_LEN] = {0};
|
||||
char dbStr[TSDB_DB_NAME_LEN] = {0};
|
||||
char userStr[TSDB_USER_LEN] = {0};
|
||||
char passStr[TSDB_PASSWORD_LEN] = {0};
|
||||
|
||||
(void)strncpy(ipStr, ip, TMIN(TSDB_EP_LEN - 1, ipLen));
|
||||
(void)strncpy(userStr, user, TMIN(TSDB_USER_LEN - 1, userLen));
|
||||
(void)strncpy(passStr, pass, TMIN(TSDB_PASSWORD_LEN - 1, passLen));
|
||||
(void)strncpy(dbStr, db, TMIN(TSDB_DB_NAME_LEN - 1, dbLen));
|
||||
return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
||||
}
|
||||
//TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen,
|
||||
// const char* db, int dbLen, uint16_t port) {
|
||||
// char ipStr[TSDB_EP_LEN] = {0};
|
||||
// char dbStr[TSDB_DB_NAME_LEN] = {0};
|
||||
// char userStr[TSDB_USER_LEN] = {0};
|
||||
// char passStr[TSDB_PASSWORD_LEN] = {0};
|
||||
//
|
||||
// tstrncpy(ipStr, ip, TMIN(TSDB_EP_LEN - 1, ipLen));
|
||||
// tstrncpy(userStr, user, TMIN(TSDB_USER_LEN - 1, userLen));
|
||||
// tstrncpy(passStr, pass, TMIN(TSDB_PASSWORD_LEN - 1, passLen));
|
||||
// tstrncpy(dbStr, db, TMIN(TSDB_DB_NAME_LEN - 1, dbLen));
|
||||
// return taos_connect(ipStr, userStr, passStr, dbStr, port);
|
||||
//}
|
||||
|
||||
void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
|
||||
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
||||
|
@ -2275,7 +2275,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
|||
char* jsonInnerData = data + CHAR_BYTES;
|
||||
char dst[TSDB_MAX_JSON_TAG_LEN] = {0};
|
||||
if (jsonInnerType == TSDB_DATA_TYPE_NULL) {
|
||||
(void)sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L);
|
||||
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%s", TSDB_DATA_NULL_STR_L);
|
||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||
} else if (tTagIsJson(data)) {
|
||||
char* jsonString = NULL;
|
||||
|
@ -2298,10 +2298,10 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
|||
*(char*)POINTER_SHIFT(varDataVal(dst), length + CHAR_BYTES) = '\"';
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_DOUBLE) {
|
||||
double jsonVd = *(double*)(jsonInnerData);
|
||||
(void)sprintf(varDataVal(dst), "%.9lf", jsonVd);
|
||||
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%.9lf", jsonVd);
|
||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_BOOL) {
|
||||
(void)sprintf(varDataVal(dst), "%s", (*((char*)jsonInnerData) == 1) ? "true" : "false");
|
||||
(void)snprintf(varDataVal(dst), TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE, "%s", (*((char*)jsonInnerData) == 1) ? "true" : "false");
|
||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||
} else {
|
||||
tscError("doConvertJson error: invalid type:%d", jsonInnerType);
|
||||
|
@ -2658,8 +2658,8 @@ int32_t appendTbToReq(SHashObj* pHash, int32_t pos1, int32_t len1, int32_t pos2,
|
|||
return -1;
|
||||
}
|
||||
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
(void)sprintf(dbFName, "%d.%.*s", acctId, dbLen, dbName);
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
(void)snprintf(dbFName, TSDB_DB_FNAME_LEN, "%d.%.*s", acctId, dbLen, dbName);
|
||||
|
||||
STablesReq* pDb = taosHashGet(pHash, dbFName, strlen(dbFName));
|
||||
if (pDb) {
|
||||
|
@ -2672,7 +2672,7 @@ int32_t appendTbToReq(SHashObj* pHash, int32_t pos1, int32_t len1, int32_t pos2,
|
|||
if (NULL == db.pTables) {
|
||||
return terrno;
|
||||
}
|
||||
(void)strcpy(db.dbFName, dbFName);
|
||||
tstrncpy(db.dbFName, dbFName, TSDB_DB_FNAME_LEN);
|
||||
if (NULL == taosArrayPush(db.pTables, &name)) {
|
||||
return terrno;
|
||||
}
|
||||
|
|
|
@ -1083,14 +1083,14 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_stmtErrorMsgIm
|
|||
TAOS *tscon = (TAOS *)con;
|
||||
if (tscon == NULL) {
|
||||
jniError("jobj:%p, connection already closed", jobj);
|
||||
(void)sprintf(errMsg, "jobj:%p, connection already closed", jobj);
|
||||
(void)snprintf(errMsg, sizeof(errMsg), "jobj:%p, connection already closed", jobj);
|
||||
return (*env)->NewStringUTF(env, errMsg);
|
||||
}
|
||||
|
||||
TAOS_STMT *pStmt = (TAOS_STMT *)stmt;
|
||||
if (pStmt == NULL) {
|
||||
jniError("jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||
(void)sprintf(errMsg, "jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||
(void)snprintf(errMsg, sizeof(errMsg), "jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||
return (*env)->NewStringUTF(env, errMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -482,71 +482,75 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
}
|
||||
|
||||
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
||||
return taos_print_row_with_size(str, INT32_MAX, row, fields, num_fields);
|
||||
}
|
||||
int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields){
|
||||
int32_t len = 0;
|
||||
for (int i = 0; i < num_fields; ++i) {
|
||||
if (i > 0) {
|
||||
if (i > 0 && len < size - 1) {
|
||||
str[len++] = ' ';
|
||||
}
|
||||
|
||||
if (row[i] == NULL) {
|
||||
len += sprintf(str + len, "%s", TSDB_DATA_NULL_STR);
|
||||
len += snprintf(str + len, size - len, "%s", TSDB_DATA_NULL_STR);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (fields[i].type) {
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
len += sprintf(str + len, "%d", *((int8_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%d", *((int8_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
len += sprintf(str + len, "%u", *((uint8_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%u", *((uint8_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
len += sprintf(str + len, "%d", *((int16_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%d", *((int16_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
len += sprintf(str + len, "%u", *((uint16_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%u", *((uint16_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
len += sprintf(str + len, "%d", *((int32_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%d", *((int32_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
len += sprintf(str + len, "%u", *((uint32_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%u", *((uint32_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%" PRId64, *((int64_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
len += sprintf(str + len, "%" PRIu64, *((uint64_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%" PRIu64, *((uint64_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float fv = 0;
|
||||
fv = GET_FLOAT_VAL(row[i]);
|
||||
len += sprintf(str + len, "%f", fv);
|
||||
len += snprintf(str + len, size - len, "%f", fv);
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double dv = 0;
|
||||
dv = GET_DOUBLE_VAL(row[i]);
|
||||
len += sprintf(str + len, "%lf", dv);
|
||||
len += snprintf(str + len, size - len, "%lf", dv);
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_VARBINARY: {
|
||||
void *data = NULL;
|
||||
uint32_t size = 0;
|
||||
uint32_t tmp = 0;
|
||||
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
||||
if (taosAscii2Hex(row[i], charLen, &data, &size) < 0) {
|
||||
if (taosAscii2Hex(row[i], charLen, &data, &tmp) < 0) {
|
||||
break;
|
||||
}
|
||||
(void)memcpy(str + len, data, size);
|
||||
len += size;
|
||||
uint32_t copyLen = TMIN(size - len - 1, tmp);
|
||||
(void)memcpy(str + len, data, copyLen);
|
||||
len += copyLen;
|
||||
taosMemoryFree(data);
|
||||
} break;
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
|
@ -566,21 +570,28 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
|||
}
|
||||
}
|
||||
|
||||
(void)memcpy(str + len, row[i], charLen);
|
||||
len += charLen;
|
||||
uint32_t copyLen = TMIN(size - len - 1, charLen);
|
||||
(void)memcpy(str + len, row[i], copyLen);
|
||||
len += copyLen;
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%" PRId64, *((int64_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
len += sprintf(str + len, "%d", *((int8_t *)row[i]));
|
||||
len += snprintf(str + len, size - len, "%d", *((int8_t *)row[i]));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (len >= size - 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (len < size){
|
||||
str[len] = 0;
|
||||
}
|
||||
str[len] = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -945,7 +956,7 @@ int taos_get_current_db(TAOS *taos, char *database, int len, int *required) {
|
|||
if (required) *required = strlen(pTscObj->db) + 1;
|
||||
TSC_ERR_JRET(TSDB_CODE_INVALID_PARA);
|
||||
} else {
|
||||
(void)strcpy(database, pTscObj->db);
|
||||
tstrncpy(database, pTscObj->db, len);
|
||||
code = 0;
|
||||
}
|
||||
_return:
|
||||
|
|
|
@ -21,7 +21,7 @@ char tmpSlowLogPath[PATH_MAX] = {0};
|
|||
TdThread monitorThread;
|
||||
|
||||
static int32_t getSlowLogTmpDir(char* tmpPath, int32_t size) {
|
||||
int ret = snprintf(tmpPath, size, "%s/tdengine_slow_log/", tsTempDir);
|
||||
int ret = tsnprintf(tmpPath, size, "%s/tdengine_slow_log/", tsTempDir);
|
||||
if (ret < 0) {
|
||||
tscError("failed to get tmp path ret:%d", ret);
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
|
@ -183,7 +183,7 @@ FAILED:
|
|||
|
||||
static void generateClusterReport(taos_collector_registry_t* registry, void* pTransporter, SEpSet* epSet) {
|
||||
char ts[50] = {0};
|
||||
(void)sprintf(ts, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
||||
(void)snprintf(ts, sizeof(ts), "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
||||
char* pCont = (char*)taos_collector_registry_bridge_new(registry, ts, "%" PRId64, NULL);
|
||||
if (NULL == pCont) {
|
||||
tscError("generateClusterReport failed, get null content.");
|
||||
|
@ -401,7 +401,7 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
|||
return;
|
||||
}
|
||||
pClient->lastCheckTime = taosGetMonoTimestampMs();
|
||||
(void)strcpy(pClient->path, path);
|
||||
tstrncpy(pClient->path, path, PATH_MAX);
|
||||
pClient->offset = 0;
|
||||
pClient->pFile = pFile;
|
||||
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0) {
|
||||
|
@ -458,7 +458,7 @@ static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) {
|
|||
return NULL;
|
||||
}
|
||||
char* buf = pCont;
|
||||
(void)strcat(buf++, "[");
|
||||
(void)strncat(buf++, "[", totalSize - 1);
|
||||
int64_t readSize = taosReadFile(pFile, buf, totalSize - 4); // 4 reserved for []
|
||||
if (readSize <= 0) {
|
||||
if (readSize < 0) {
|
||||
|
|
|
@ -924,7 +924,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
for (int32_t i = 0; i < req.schemaRow.nCols; i++) {
|
||||
SSchema* pSchema = req.schemaRow.pSchema + i;
|
||||
SFieldWithOptions field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes};
|
||||
(void)strcpy(field.name, pSchema->name);
|
||||
tstrncpy(field.name, pSchema->name, TSDB_COL_NAME_LEN);
|
||||
|
||||
if (createDefaultCompress) {
|
||||
field.compress = createDefaultColCmprByType(pSchema->type);
|
||||
|
@ -939,7 +939,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
for (int32_t i = 0; i < req.schemaTag.nCols; i++) {
|
||||
SSchema* pSchema = req.schemaTag.pSchema + i;
|
||||
SField field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes};
|
||||
(void)strcpy(field.name, pSchema->name);
|
||||
tstrncpy(field.name, pSchema->name, TSDB_COL_NAME_LEN);
|
||||
RAW_NULL_CHECK(taosArrayPush(pReq.pTags, &field));
|
||||
}
|
||||
|
||||
|
@ -1242,7 +1242,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
if (pTableBatch == NULL) {
|
||||
SVgroupCreateTableBatch tBatch = {0};
|
||||
tBatch.info = pInfo;
|
||||
(void)strcpy(tBatch.dbName, pRequest->pDb);
|
||||
tstrncpy(tBatch.dbName, pRequest->pDb, TSDB_DB_NAME_LEN);
|
||||
|
||||
tBatch.req.pArray = taosArrayInit(4, sizeof(struct SVCreateTbReq));
|
||||
RAW_NULL_CHECK(tBatch.req.pArray);
|
||||
|
|
|
@ -137,7 +137,7 @@ void smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const char *msg2
|
|||
}
|
||||
(void)memset(pBuf->buf, 0, pBuf->len);
|
||||
if (msg1) {
|
||||
(void)strncat(pBuf->buf, msg1, pBuf->len);
|
||||
(void)strncat(pBuf->buf, msg1, pBuf->len - 1);
|
||||
}
|
||||
int32_t left = pBuf->len - strlen(pBuf->buf);
|
||||
if (left > 2 && msg2) {
|
||||
|
@ -515,9 +515,9 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName, char *tbnam
|
|||
if (tag == NULL) {
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
(void)strncat(childTableName, tag->value, tag->length);
|
||||
(void)strncat(childTableName, tag->value, TMIN(tag->length, TSDB_TABLE_NAME_LEN - 1 - strlen(childTableName)));
|
||||
if (i != taosArrayGetSize(tags) - 1) {
|
||||
(void)strcat(childTableName, tsSmlAutoChildTableNameDelimiter);
|
||||
(void)strncat(childTableName, tsSmlAutoChildTableNameDelimiter, TSDB_TABLE_NAME_LEN - 1 - strlen(childTableName));
|
||||
}
|
||||
}
|
||||
if (tsSmlDot2Underline) {
|
||||
|
@ -538,8 +538,7 @@ static int32_t smlParseTableName(SArray *tags, char *childTableName, char *tbnam
|
|||
// handle child table name
|
||||
if (childTableNameLen == tag->keyLen && strncmp(tag->key, tbnameKey, tag->keyLen) == 0) {
|
||||
(void)memset(childTableName, 0, TSDB_TABLE_NAME_LEN);
|
||||
(void)strncpy(childTableName, tag->value,
|
||||
(tag->length < TSDB_TABLE_NAME_LEN ? tag->length : TSDB_TABLE_NAME_LEN));
|
||||
tstrncpy(childTableName, tag->value, TMIN(TSDB_TABLE_NAME_LEN, tag->length + 1));
|
||||
if (tsSmlDot2Underline) {
|
||||
smlStrReplace(childTableName, strlen(childTableName));
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags,
|
|||
}
|
||||
|
||||
(void)memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
|
||||
(void)strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
||||
tstrncpy(pStmt->bInfo.tbFName, tbFName, TSDB_TABLE_FNAME_LEN);
|
||||
pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
|
||||
|
||||
pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
||||
|
@ -1018,13 +1018,13 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
|||
STMT_ERR_RET(stmtGetFromCache(pStmt));
|
||||
|
||||
if (pStmt->bInfo.needParse) {
|
||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
||||
tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
|
||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||
|
||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||
}
|
||||
} else {
|
||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
||||
tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
|
||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||
pStmt->exec.pRequest->requestId++;
|
||||
pStmt->bInfo.needParse = false;
|
||||
|
@ -1172,7 +1172,7 @@ int32_t stmtAppendTablePostHandle(STscStmt* pStmt, SStmtQNode* param) {
|
|||
}
|
||||
|
||||
if (0 == pStmt->sql.siInfo.firstName[0]) {
|
||||
(void)strcpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName);
|
||||
tstrncpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
|
||||
param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
|
||||
|
@ -1313,7 +1313,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
|||
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
||||
|
||||
param->restoreTbCols = false;
|
||||
(void)strcpy(param->tblData.tbName, pStmt->bInfo.tbName);
|
||||
tstrncpy(param->tblData.tbName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
|
||||
int64_t startUs3 = taosGetTimestampUs();
|
||||
|
|
|
@ -187,7 +187,7 @@ static int32_t stmtUpdateBindInfo(TAOS_STMT2* stmt, STableMeta* pTableMeta, void
|
|||
}
|
||||
|
||||
(void)memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName));
|
||||
(void)strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
||||
tstrncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName));
|
||||
pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
|
||||
|
||||
pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
||||
|
@ -961,13 +961,13 @@ int stmtSetTbName2(TAOS_STMT2* stmt, const char* tbName) {
|
|||
STMT_ERR_RET(stmtGetFromCache(pStmt));
|
||||
|
||||
if (pStmt->bInfo.needParse) {
|
||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
||||
tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
|
||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||
|
||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||
}
|
||||
} else {
|
||||
(void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1);
|
||||
tstrncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName));
|
||||
pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0;
|
||||
pStmt->exec.pRequest->requestId++;
|
||||
pStmt->bInfo.needParse = false;
|
||||
|
@ -1113,7 +1113,7 @@ static int32_t stmtAppendTablePostHandle(STscStmt2* pStmt, SStmtQNode* param) {
|
|||
}
|
||||
|
||||
if (0 == pStmt->sql.siInfo.firstName[0]) {
|
||||
(void)strcpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName);
|
||||
tstrncpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
|
||||
param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash;
|
||||
|
@ -1200,22 +1200,6 @@ static int stmtAddBatch2(TAOS_STMT2* stmt) {
|
|||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
int64_t startUs2 = taosGetTimestampUs();
|
||||
pStmt->stat.addBatchUs += startUs2 - startUs;
|
||||
|
||||
pStmt->sql.siInfo.tableColsReady = false;
|
||||
|
||||
SStmtQNode* param = NULL;
|
||||
STMT_ERR_RET(stmtAllocQNodeFromBuf(&pStmt->sql.siInfo.tbBuf, (void**)¶m));
|
||||
param->restoreTbCols = true;
|
||||
param->next = NULL;
|
||||
|
||||
stmtEnqueue(pStmt, param);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
STMT_ERR_RET(stmtCacheBlock(pStmt));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1367,7 +1351,7 @@ int stmtBindBatch2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* bind, int32_t colIdx) {
|
|||
// param->tblData.aCol = taosArrayInit(20, POINTER_BYTES);
|
||||
|
||||
param->restoreTbCols = false;
|
||||
(void)strcpy(param->tblData.tbName, pStmt->bInfo.tbName);
|
||||
tstrncpy(param->tblData.tbName, pStmt->bInfo.tbName, TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
|
||||
int64_t startUs3 = taosGetTimestampUs();
|
||||
|
@ -1627,6 +1611,22 @@ int stmtExec2(TAOS_STMT2* stmt, int* affected_rows) {
|
|||
|
||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
||||
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
int64_t startUs2 = taosGetTimestampUs();
|
||||
pStmt->stat.addBatchUs += startUs2 - startUs;
|
||||
|
||||
pStmt->sql.siInfo.tableColsReady = false;
|
||||
|
||||
SStmtQNode* param = NULL;
|
||||
STMT_ERR_RET(stmtAllocQNodeFromBuf(&pStmt->sql.siInfo.tbBuf, (void**)¶m));
|
||||
param->restoreTbCols = true;
|
||||
param->next = NULL;
|
||||
|
||||
stmtEnqueue(pStmt, param);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (STMT_TYPE_QUERY != pStmt->sql.type) {
|
||||
if (pStmt->sql.stbInterlaceMode) {
|
||||
int64_t startTs = taosGetTimestampUs();
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
|
||||
#define SET_ERROR_MSG_TMQ(MSG) \
|
||||
if (errstr != NULL) (void)snprintf(errstr, errstrLen, MSG);
|
||||
if (errstr != NULL && errstrLen > 0) (void)snprintf(errstr, errstrLen, MSG);
|
||||
|
||||
#define PROCESS_POLL_RSP(FUNC,DATA) \
|
||||
SDecoder decoder = {0}; \
|
||||
|
@ -994,7 +994,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
if (data == NULL) {
|
||||
continue;
|
||||
}
|
||||
(void)strcpy(data->topicName, pTopic->topicName);
|
||||
tstrncpy(data->topicName, pTopic->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||
data->offsetRows = taosArrayInit(numOfVgroups, sizeof(OffsetRows));
|
||||
if (data->offsetRows == NULL) {
|
||||
continue;
|
||||
|
@ -1127,7 +1127,7 @@ static void initClientTopicFromRsp(SMqClientTopic* pTopic, SMqSubTopicEp* pTopic
|
|||
if (pVgEp == NULL) {
|
||||
continue;
|
||||
}
|
||||
(void)sprintf(vgKey, "%s:%d", pTopic->topicName, pVgEp->vgId);
|
||||
(void)snprintf(vgKey, sizeof(vgKey), "%s:%d", pTopic->topicName, pVgEp->vgId);
|
||||
SVgroupSaveInfo* pInfo = taosHashGet(pVgOffsetHashMap, vgKey, strlen(vgKey));
|
||||
|
||||
STqOffsetVal offsetNew = {0};
|
||||
|
@ -1188,7 +1188,7 @@ static void buildNewTopicList(tmq_t* tmq, SArray* newTopics, const SMqAskEpRsp*
|
|||
continue;
|
||||
}
|
||||
char vgKey[TSDB_TOPIC_FNAME_LEN + 22] = {0};
|
||||
(void)sprintf(vgKey, "%s:%d", pTopicCur->topicName, pVgCur->vgId);
|
||||
(void)snprintf(vgKey, sizeof(vgKey), "%s:%d", pTopicCur->topicName, pVgCur->vgId);
|
||||
|
||||
char buf[TSDB_OFFSET_LEN] = {0};
|
||||
tFormatOffset(buf, TSDB_OFFSET_LEN, &pVgCur->offsetInfo.endOffset);
|
||||
|
@ -1994,7 +1994,7 @@ END:
|
|||
if (pRspWrapper) {
|
||||
pRspWrapper->code = code;
|
||||
pRspWrapper->pollRsp.vgId = vgId;
|
||||
(void)strcpy(pRspWrapper->pollRsp.topicName, pParam->topicName);
|
||||
tstrncpy(pRspWrapper->pollRsp.topicName, pParam->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||
code = taosWriteQitem(tmq->mqueue, pRspWrapper);
|
||||
if (code != 0) {
|
||||
tmqFreeRspWrapper(pRspWrapper);
|
||||
|
@ -2158,7 +2158,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
|
|||
}
|
||||
|
||||
pParam->refId = pTmq->refId;
|
||||
(void)strcpy(pParam->topicName, pTopic->topicName);
|
||||
tstrncpy(pParam->topicName, pTopic->topicName, TSDB_TOPIC_FNAME_LEN);
|
||||
pParam->vgId = pVg->vgId;
|
||||
pParam->requestId = req.reqId;
|
||||
|
||||
|
|
|
@ -47,10 +47,6 @@ target_link_libraries(
|
|||
INTERFACE api
|
||||
)
|
||||
|
||||
if(${BUILD_WITH_ANALYSIS})
|
||||
add_definitions(-DUSE_ANAL)
|
||||
endif()
|
||||
|
||||
if(${BUILD_S3})
|
||||
|
||||
if(${BUILD_WITH_S3})
|
||||
|
|
|
@ -260,19 +260,19 @@ static void responseCompleteCallback(S3Status status, const S3ErrorDetails *erro
|
|||
const int elen = sizeof(cbd->err_msg);
|
||||
if (error) {
|
||||
if (error->message && elen - len > 0) {
|
||||
len += snprintf(&(cbd->err_msg[len]), elen - len, " Message: %s\n", error->message);
|
||||
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " Message: %s\n", error->message);
|
||||
}
|
||||
if (error->resource && elen - len > 0) {
|
||||
len += snprintf(&(cbd->err_msg[len]), elen - len, " Resource: %s\n", error->resource);
|
||||
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " Resource: %s\n", error->resource);
|
||||
}
|
||||
if (error->furtherDetails && elen - len > 0) {
|
||||
len += snprintf(&(cbd->err_msg[len]), elen - len, " Further Details: %s\n", error->furtherDetails);
|
||||
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " Further Details: %s\n", error->furtherDetails);
|
||||
}
|
||||
if (error->extraDetailsCount && elen - len > 0) {
|
||||
len += snprintf(&(cbd->err_msg[len]), elen - len, "%s", " Extra Details:\n");
|
||||
len += tsnprintf(&(cbd->err_msg[len]), elen - len, "%s", " Extra Details:\n");
|
||||
for (int i = 0; i < error->extraDetailsCount; i++) {
|
||||
if (elen - len > 0) {
|
||||
len += snprintf(&(cbd->err_msg[len]), elen - len, " %s: %s\n", error->extraDetails[i].name,
|
||||
len += tsnprintf(&(cbd->err_msg[len]), elen - len, " %s: %s\n", error->extraDetails[i].name,
|
||||
error->extraDetails[i].value);
|
||||
}
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ upload:
|
|||
if (!manager.etags[i]) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(EIO), &lino, _exit);
|
||||
}
|
||||
n = snprintf(buf, sizeof(buf),
|
||||
n = tsnprintf(buf, sizeof(buf),
|
||||
"<Part><PartNumber>%d</PartNumber>"
|
||||
"<ETag>%s</ETag></Part>",
|
||||
i + 1, manager.etags[i]);
|
||||
|
@ -919,7 +919,7 @@ upload:
|
|||
char buf[256];
|
||||
int n;
|
||||
for (int i = 0; i < cp.part_num; ++i) {
|
||||
n = snprintf(buf, sizeof(buf),
|
||||
n = tsnprintf(buf, sizeof(buf),
|
||||
"<Part><PartNumber>%d</PartNumber>"
|
||||
"<ETag>%s</ETag></Part>",
|
||||
// i + 1, manager.etags[i]);
|
||||
|
|
|
@ -2446,9 +2446,11 @@ _error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
||||
static int32_t formatTimestamp(char* buf, size_t cap, int64_t val, int precision) {
|
||||
time_t tt;
|
||||
int32_t ms = 0;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||
tt = (time_t)(val / 1000000000);
|
||||
ms = val % 1000000000;
|
||||
|
@ -2460,14 +2462,6 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
|||
ms = val % 1000;
|
||||
}
|
||||
|
||||
/* comment out as it make testcases like select_with_tags.sim fail.
|
||||
but in windows, this may cause the call to localtime crash if tt < 0,
|
||||
need to find a better solution.
|
||||
if (tt < 0) {
|
||||
tt = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
if (tt <= 0 && ms < 0) {
|
||||
tt--;
|
||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||
|
@ -2479,28 +2473,44 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
|||
}
|
||||
}
|
||||
struct tm ptm = {0};
|
||||
if (taosLocalTime(&tt, &ptm, buf) == NULL) {
|
||||
return buf;
|
||||
if (taosLocalTime(&tt, &ptm, buf, cap) == NULL) {
|
||||
code = TSDB_CODE_INTERNAL_ERROR;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm);
|
||||
size_t pos = strftime(buf, cap, "%Y-%m-%d %H:%M:%S", &ptm);
|
||||
if (pos == 0) {
|
||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
int32_t nwritten = 0;
|
||||
if (precision == TSDB_TIME_PRECISION_NANO) {
|
||||
sprintf(buf + pos, ".%09d", ms);
|
||||
nwritten = snprintf(buf + pos, cap - pos, ".%09d", ms);
|
||||
} else if (precision == TSDB_TIME_PRECISION_MICRO) {
|
||||
sprintf(buf + pos, ".%06d", ms);
|
||||
nwritten = snprintf(buf + pos, cap - pos, ".%06d", ms);
|
||||
} else {
|
||||
sprintf(buf + pos, ".%03d", ms);
|
||||
nwritten = snprintf(buf + pos, cap - pos, ".%03d", ms);
|
||||
}
|
||||
|
||||
return buf;
|
||||
if (nwritten >= cap - pos) {
|
||||
code = TSDB_CODE_OUT_OF_BUFFER;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
_end:
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
// for debug
|
||||
int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf, const char* taskIdStr) {
|
||||
int32_t lino = 0;
|
||||
int32_t size = 2048 * 1024;
|
||||
int32_t code = 0;
|
||||
char* dumpBuf = NULL;
|
||||
char pBuf[128] = {0};
|
||||
char pBuf[TD_TIME_STR_LEN] = {0};
|
||||
int32_t rows = pDataBlock->info.rows;
|
||||
int32_t len = 0;
|
||||
|
||||
|
@ -2510,7 +2520,7 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
}
|
||||
|
||||
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
len += snprintf(dumpBuf + len, size - len,
|
||||
len += tsnprintf(dumpBuf + len, size - len,
|
||||
"%s===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%" PRId64 "|rows:%" PRId64
|
||||
"|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n",
|
||||
taskIdStr, flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId,
|
||||
|
@ -2521,7 +2531,7 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
}
|
||||
|
||||
for (int32_t j = 0; j < rows; j++) {
|
||||
len += snprintf(dumpBuf + len, size - len, "%s|", flag);
|
||||
len += tsnprintf(dumpBuf + len, size - len, "%s|", flag);
|
||||
if (len >= size - 1) {
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -2530,11 +2540,12 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||
if (pColInfoData == NULL) {
|
||||
code = terrno;
|
||||
lino = __LINE__;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (colDataIsNull(pColInfoData, rows, j, NULL) || !pColInfoData->pData) {
|
||||
len += snprintf(dumpBuf + len, size - len, " %15s |", "NULL");
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15s |", "NULL");
|
||||
if (len >= size - 1) goto _exit;
|
||||
continue;
|
||||
}
|
||||
|
@ -2543,52 +2554,55 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
switch (pColInfoData->info.type) {
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
memset(pBuf, 0, sizeof(pBuf));
|
||||
(void)formatTimestamp(pBuf, *(uint64_t*)var, pColInfoData->info.precision);
|
||||
len += snprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
||||
code = formatTimestamp(pBuf, sizeof(pBuf), *(uint64_t*)var, pColInfoData->info.precision);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
TAOS_UNUSED(tsnprintf(pBuf, sizeof(pBuf), "NaN"));
|
||||
}
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %25s |", pBuf);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int8_t*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(int8_t*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint8_t*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(uint8_t*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int16_t*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(int16_t*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(uint16_t*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(uint16_t*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(int32_t*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15u |", *(uint32_t*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15u |", *(uint32_t*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15" PRId64 " |", *(int64_t*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15" PRId64 " |", *(int64_t*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15" PRIu64 " |", *(uint64_t*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15" PRIu64 " |", *(uint64_t*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15f |", *(float*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15f |", *(float*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15f |", *(double*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15f |", *(double*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(bool*)var);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15d |", *(bool*)var);
|
||||
if (len >= size - 1) goto _exit;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
|
@ -2599,7 +2613,7 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData));
|
||||
dataSize = TMIN(dataSize, 50);
|
||||
memcpy(pBuf, varDataVal(pData), dataSize);
|
||||
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||
if (len >= size - 1) goto _exit;
|
||||
} break;
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
|
@ -2609,24 +2623,25 @@ int32_t dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf
|
|||
code = taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf);
|
||||
if (code < 0) {
|
||||
uError("func %s failed to convert to ucs charset since %s", __func__, tstrerror(code));
|
||||
lino = __LINE__;
|
||||
goto _exit;
|
||||
}
|
||||
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||
len += tsnprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||
if (len >= size - 1) goto _exit;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
len += snprintf(dumpBuf + len, size - len, "%d\n", j);
|
||||
len += tsnprintf(dumpBuf + len, size - len, "%d\n", j);
|
||||
if (len >= size - 1) goto _exit;
|
||||
}
|
||||
len += snprintf(dumpBuf + len, size - len, "%s |end\n", flag);
|
||||
len += tsnprintf(dumpBuf + len, size - len, "%s |end\n", flag);
|
||||
|
||||
_exit:
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
*pDataBuf = dumpBuf;
|
||||
dumpBuf = NULL;
|
||||
} else {
|
||||
uError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
uError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
if (dumpBuf) {
|
||||
taosMemoryFree(dumpBuf);
|
||||
}
|
||||
|
@ -2857,27 +2872,98 @@ _end:
|
|||
return code;
|
||||
}
|
||||
|
||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId) {
|
||||
char tmp[TSDB_TABLE_NAME_LEN] = {0};
|
||||
if (stbName == NULL){
|
||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%"PRIu64, groupId);
|
||||
}else{
|
||||
// Construct the child table name in the form of <ctbName>_<stbName>_<groupId> and store it in `ctbName`.
|
||||
// If the name length exceeds TSDB_TABLE_NAME_LEN, first convert <stbName>_<groupId> to an MD5 value and then
|
||||
// concatenate. If the length is still too long, convert <ctbName> to an MD5 value as well.
|
||||
int32_t buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId, size_t cap) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
char tmp[TSDB_TABLE_NAME_LEN] = {0};
|
||||
char* suffix = tmp;
|
||||
size_t suffixCap = sizeof(tmp);
|
||||
size_t suffixLen = 0;
|
||||
size_t prefixLen = 0;
|
||||
T_MD5_CTX context;
|
||||
|
||||
if (ctbName == NULL || cap < TSDB_TABLE_NAME_LEN) {
|
||||
code = TSDB_CODE_INTERNAL_ERROR;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
prefixLen = strlen(ctbName);
|
||||
|
||||
if (stbName == NULL) {
|
||||
suffixLen = snprintf(suffix, suffixCap, "%" PRIu64, groupId);
|
||||
if (suffixLen >= suffixCap) {
|
||||
code = TSDB_CODE_INTERNAL_ERROR;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
} else {
|
||||
int32_t i = strlen(stbName) - 1;
|
||||
for(; i >= 0; i--){
|
||||
if (stbName[i] == '.'){
|
||||
for (; i >= 0; i--) {
|
||||
if (stbName[i] == '.') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%s_%"PRIu64, stbName + i + 1, groupId);
|
||||
}
|
||||
|
||||
ctbName[TSDB_TABLE_NAME_LEN - strlen(tmp) - 1] = 0; // put stbname + groupId to the end
|
||||
(void)strcat(ctbName, tmp);
|
||||
for(int i = 0; i < strlen(ctbName); i++){
|
||||
if(ctbName[i] == '.'){
|
||||
ctbName[i] = '_';
|
||||
suffixLen = snprintf(suffix, suffixCap, "%s_%" PRIu64, stbName + i + 1, groupId);
|
||||
if (suffixLen >= suffixCap) {
|
||||
suffixCap = suffixLen + 1;
|
||||
suffix = taosMemoryMalloc(suffixCap);
|
||||
TSDB_CHECK_NULL(suffix, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
suffixLen = snprintf(suffix, suffixCap, "%s_%" PRIu64, stbName + i + 1, groupId);
|
||||
if (suffixLen >= suffixCap) {
|
||||
code = TSDB_CODE_INTERNAL_ERROR;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prefixLen + suffixLen + 1 >= TSDB_TABLE_NAME_LEN) {
|
||||
// If the name length exceeeds the limit, convert the suffix to MD5 value.
|
||||
tMD5Init(&context);
|
||||
tMD5Update(&context, (uint8_t*)suffix, suffixLen);
|
||||
tMD5Final(&context);
|
||||
suffixLen = snprintf(suffix, suffixCap, "%016" PRIx64 "%016" PRIx64, *(uint64_t*)context.digest,
|
||||
*(uint64_t*)(context.digest + 8));
|
||||
if (suffixLen >= suffixCap) {
|
||||
code = TSDB_CODE_INTERNAL_ERROR;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
}
|
||||
|
||||
if (prefixLen + suffixLen + 1 >= TSDB_TABLE_NAME_LEN) {
|
||||
// If the name is still too long, convert the ctbName to MD5 value.
|
||||
tMD5Init(&context);
|
||||
tMD5Update(&context, (uint8_t*)ctbName, prefixLen);
|
||||
tMD5Final(&context);
|
||||
prefixLen = snprintf(ctbName, cap, "t_%016" PRIx64 "%016" PRIx64, *(uint64_t*)context.digest,
|
||||
*(uint64_t*)(context.digest + 8));
|
||||
if (prefixLen >= cap) {
|
||||
code = TSDB_CODE_INTERNAL_ERROR;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
}
|
||||
|
||||
if (prefixLen + suffixLen + 1 >= TSDB_TABLE_NAME_LEN) {
|
||||
code = TSDB_CODE_INTERNAL_ERROR;
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
ctbName[prefixLen] = '_';
|
||||
tstrncpy(&ctbName[prefixLen + 1], suffix, cap - prefixLen - 1);
|
||||
|
||||
for (char* p = ctbName; *p; ++p) {
|
||||
if (*p == '.') *p = '_';
|
||||
}
|
||||
|
||||
_end:
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
if (suffix != tmp) {
|
||||
taosMemoryFree(suffix);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
// auto stream subtable name starts with 't_', followed by the first segment of MD5 digest for group vals.
|
||||
|
|
|
@ -1725,6 +1725,7 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *
|
|||
TAOS_CHECK_RETURN(cfgInit(&pCfg));
|
||||
|
||||
TAOS_CHECK_GOTO(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_NONE), NULL, _exit);
|
||||
TAOS_CHECK_GOTO(cfgAddInt32(pCfg, "debugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER), NULL, _exit);
|
||||
TAOS_CHECK_GOTO(cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER) ,NULL, _exit);
|
||||
|
||||
if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != 0) {
|
||||
|
|
|
@ -33,7 +33,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
|
|||
}
|
||||
struct tm tm;
|
||||
time_t t = (time_t)start;
|
||||
taosLocalTime(&t, &tm);
|
||||
taosLocalTime(&t, &tm, NULL, 0);
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_hour = 0;
|
||||
|
@ -103,7 +103,7 @@ int32_t tNameExtractFullName(const SName* name, char* dst) {
|
|||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
int32_t len = snprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
|
||||
int32_t len = tsnprintf(dst, TSDB_DB_FNAME_LEN, "%d.%s", name->acctId, name->dbname);
|
||||
|
||||
size_t tnameLen = strlen(name->tname);
|
||||
if (tnameLen > 0) {
|
||||
|
|
|
@ -693,7 +693,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
|||
|
||||
struct tm tm;
|
||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||
struct tm* ptm = taosLocalTime(&tt, &tm, NULL);
|
||||
struct tm* ptm = taosLocalTime(&tt, &tm, NULL, 0);
|
||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth;
|
||||
tm.tm_year = mon / 12;
|
||||
tm.tm_mon = mon % 12;
|
||||
|
@ -754,11 +754,11 @@ int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interva
|
|||
|
||||
struct tm tm;
|
||||
time_t t = (time_t)skey;
|
||||
struct tm* ptm = taosLocalTime(&t, &tm, NULL);
|
||||
struct tm* ptm = taosLocalTime(&t, &tm, NULL, 0);
|
||||
int32_t smon = tm.tm_year * 12 + tm.tm_mon;
|
||||
|
||||
t = (time_t)ekey;
|
||||
ptm = taosLocalTime(&t, &tm, NULL);
|
||||
ptm = taosLocalTime(&t, &tm, NULL, 0);
|
||||
int32_t emon = tm.tm_year * 12 + tm.tm_mon;
|
||||
|
||||
if (unit == 'y') {
|
||||
|
@ -782,7 +782,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
|
|||
start /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
|
||||
struct tm tm;
|
||||
time_t tt = (time_t)start;
|
||||
struct tm* ptm = taosLocalTime(&tt, &tm, NULL);
|
||||
struct tm* ptm = taosLocalTime(&tt, &tm, NULL, 0);
|
||||
tm.tm_sec = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_hour = 0;
|
||||
|
@ -911,13 +911,13 @@ int64_t taosTimeGetIntervalEnd(int64_t intervalStart, const SInterval* pInterval
|
|||
// 2020-07-03 17:48:42
|
||||
// and the parameter can also be a variable.
|
||||
const char* fmtts(int64_t ts) {
|
||||
static char buf[96] = {0};
|
||||
static char buf[TD_TIME_STR_LEN] = {0};
|
||||
size_t pos = 0;
|
||||
struct tm tm;
|
||||
|
||||
if (ts > -62135625943 && ts < 32503651200) {
|
||||
time_t t = (time_t)ts;
|
||||
if (taosLocalTime(&t, &tm, buf) == NULL) {
|
||||
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
|
||||
return buf;
|
||||
}
|
||||
pos += strftime(buf + pos, sizeof(buf), "s=%Y-%m-%d %H:%M:%S", &tm);
|
||||
|
@ -925,7 +925,7 @@ const char* fmtts(int64_t ts) {
|
|||
|
||||
if (ts > -62135625943000 && ts < 32503651200000) {
|
||||
time_t t = (time_t)(ts / 1000);
|
||||
if (taosLocalTime(&t, &tm, buf) == NULL) {
|
||||
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
|
||||
return buf;
|
||||
}
|
||||
if (pos > 0) {
|
||||
|
@ -939,7 +939,7 @@ const char* fmtts(int64_t ts) {
|
|||
|
||||
{
|
||||
time_t t = (time_t)(ts / 1000000);
|
||||
if (taosLocalTime(&t, &tm, buf) == NULL) {
|
||||
if (taosLocalTime(&t, &tm, buf, sizeof(buf)) == NULL) {
|
||||
return buf;
|
||||
}
|
||||
if (pos > 0) {
|
||||
|
@ -993,11 +993,11 @@ int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precisio
|
|||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
if (NULL == taosLocalTime(", &ptm, buf)) {
|
||||
if (NULL == taosLocalTime(", &ptm, buf, bufLen)) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm);
|
||||
length += snprintf(ts + length, fractionLen, format, mod);
|
||||
length += tsnprintf(ts + length, fractionLen, format, mod);
|
||||
length += (int32_t)strftime(ts + length, 40 - length, "%z", &ptm);
|
||||
|
||||
tstrncpy(buf, ts, bufLen);
|
||||
|
@ -1007,7 +1007,7 @@ int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precisio
|
|||
int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm) {
|
||||
tm->fsec = ts % TICK_PER_SECOND[precision] * (TICK_PER_SECOND[TSDB_TIME_PRECISION_NANO] / TICK_PER_SECOND[precision]);
|
||||
time_t t = ts / TICK_PER_SECOND[precision];
|
||||
if (NULL == taosLocalTime(&t, &tm->tm, NULL)) {
|
||||
if (NULL == taosLocalTime(&t, &tm->tm, NULL, 0)) {
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -480,7 +480,7 @@ TEST(testCase, StreamAllNormTest) {
|
|||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(NULL, ctbName, groupId);
|
||||
buildCtbNameAddGroupId(NULL, ctbName, groupId, sizeof(ctbName));
|
||||
|
||||
ASSERT_STREQ("_12345", ctbName);
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ TEST(testCase, StreamWithStbName) {
|
|||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName));
|
||||
|
||||
ASSERT_STREQ("_stb_12345", ctbName);
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ TEST(testCase, StreamWithoutDotInStbName) {
|
|||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName));
|
||||
|
||||
ASSERT_STREQ("_table_12345", ctbName);
|
||||
}
|
||||
|
@ -510,11 +510,59 @@ TEST(testCase, StreamWithoutDotInStbName2) {
|
|||
char ctbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
uint64_t groupId = 12345;
|
||||
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId);
|
||||
buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName));
|
||||
|
||||
ASSERT_STREQ("__12345", ctbName);
|
||||
}
|
||||
|
||||
TEST(testCase, StreamWithLongStbName) {
|
||||
char ctbName[TSDB_TABLE_NAME_LEN];
|
||||
char expectName[TSDB_TABLE_NAME_LEN];
|
||||
char *stbName = "a_simle_stb_name";
|
||||
uint64_t groupId = UINT64_MAX;
|
||||
|
||||
// test basic function
|
||||
strcpy(ctbName, "a_simple_ctb_name");
|
||||
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||
EXPECT_STREQ(ctbName, "a_simple_ctb_name_a_simle_stb_name_18446744073709551615");
|
||||
|
||||
// test null stbName
|
||||
strcpy(ctbName, "a_simple_ctb_name");
|
||||
stbName = NULL;
|
||||
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||
EXPECT_STREQ(ctbName, "a_simple_ctb_name_18446744073709551615");
|
||||
|
||||
// test buffer capcity check
|
||||
EXPECT_EQ(buildCtbNameAddGroupId(stbName, NULL, groupId, sizeof(ctbName)), TSDB_CODE_INTERNAL_ERROR);
|
||||
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName) - 1), TSDB_CODE_INTERNAL_ERROR);
|
||||
|
||||
// test md5 conversion of stbName with groupid
|
||||
for (int32_t i = 0; i < 159; ++i) ctbName[i] = 'A';
|
||||
ctbName[159] = '\0';
|
||||
stbName = taosStrdup(ctbName);
|
||||
snprintf(expectName, TSDB_TABLE_NAME_LEN, "%s_d85f0d87946d76eeedd7b7b78b7492a2", ctbName);
|
||||
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||
EXPECT_STREQ(ctbName, expectName);
|
||||
|
||||
// test md5 conversion of all parts
|
||||
for (int32_t i = 0; i < 190; ++i) ctbName[i] = 'A';
|
||||
ctbName[190] = '\0';
|
||||
tstrncpy(expectName, "t_d38a8b2df999bef0082ffc80a59a9cd7_d85f0d87946d76eeedd7b7b78b7492a2", TSDB_TABLE_NAME_LEN);
|
||||
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||
EXPECT_STREQ(ctbName, expectName);
|
||||
|
||||
// test larger stbName
|
||||
taosMemoryFree(stbName);
|
||||
for (int32_t i = 0; i < 190; ++i) ctbName[i] = 'A';
|
||||
ctbName[190] = '\0';
|
||||
stbName = taosStrdup(ctbName);
|
||||
tstrncpy(expectName, "t_d38a8b2df999bef0082ffc80a59a9cd7_9c99cc7c52073b63fb750af402d9b84b", TSDB_TABLE_NAME_LEN);
|
||||
EXPECT_EQ(buildCtbNameAddGroupId(stbName, ctbName, groupId, sizeof(ctbName)), TSDB_CODE_SUCCESS);
|
||||
EXPECT_STREQ(ctbName, expectName);
|
||||
|
||||
taosMemoryFree(stbName);
|
||||
}
|
||||
|
||||
#if 1
|
||||
TEST(testCase, NoneTest) {
|
||||
const static int nCols = 14;
|
||||
|
@ -570,4 +618,4 @@ for (int r = 0; r < nRows; ++r) {
|
|||
taosArrayDestroy(pArray);
|
||||
taosMemoryFree(pTSchema);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -280,9 +280,9 @@ static void dmPrintArgs(int32_t argc, char const *argv[]) {
|
|||
taosGetCwd(path, sizeof(path));
|
||||
|
||||
char args[1024] = {0};
|
||||
int32_t arglen = snprintf(args, sizeof(args), "%s", argv[0]);
|
||||
int32_t arglen = tsnprintf(args, sizeof(args), "%s", argv[0]);
|
||||
for (int32_t i = 1; i < argc; ++i) {
|
||||
arglen = arglen + snprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
|
||||
arglen = arglen + tsnprintf(args + arglen, sizeof(args) - arglen, " %s", argv[i]);
|
||||
}
|
||||
|
||||
dInfo("startup path:%s args:%s", path, args);
|
||||
|
|
|
@ -461,12 +461,12 @@ void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
|
|||
|
||||
void dmEpSetToStr(char *buf, int32_t len, SEpSet *epSet) {
|
||||
int32_t n = 0;
|
||||
n += snprintf(buf + n, len - n, "%s", "{");
|
||||
n += tsnprintf(buf + n, len - n, "%s", "{");
|
||||
for (int i = 0; i < epSet->numOfEps; i++) {
|
||||
n += snprintf(buf + n, len - n, "%s:%d%s", epSet->eps[i].fqdn, epSet->eps[i].port,
|
||||
n += tsnprintf(buf + n, len - n, "%s:%d%s", epSet->eps[i].fqdn, epSet->eps[i].port,
|
||||
(i + 1 < epSet->numOfEps ? ", " : ""));
|
||||
}
|
||||
n += snprintf(buf + n, len - n, "%s", "}");
|
||||
n += tsnprintf(buf + n, len - n, "%s", "}");
|
||||
}
|
||||
|
||||
static FORCE_INLINE void dmSwapEps(SEp *epLhs, SEp *epRhs) {
|
||||
|
|
|
@ -14,6 +14,10 @@ IF (TD_ENTERPRISE)
|
|||
ELSEIF(${BUILD_WITH_COS})
|
||||
add_definitions(-DUSE_COS)
|
||||
ENDIF()
|
||||
|
||||
IF(${BUILD_WITH_ANALYSIS})
|
||||
add_definitions(-DUSE_ANAL)
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
|
||||
add_library(mnode STATIC ${MNODE_SRC})
|
||||
|
|
|
@ -43,7 +43,7 @@ static void mndCancelGetNextAnode(SMnode *pMnode, void *pIter);
|
|||
static int32_t mndRetrieveAnodesFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
static void mndCancelGetNextAnodeFull(SMnode *pMnode, void *pIter);
|
||||
static int32_t mndGetAnodeAlgoList(const char *url, SAnodeObj *pObj);
|
||||
static int32_t mndGetAnodeStatus(SAnodeObj *pObj, char *status);
|
||||
static int32_t mndGetAnodeStatus(SAnodeObj *pObj, char *status, int32_t statusLen);
|
||||
|
||||
int32_t mndInitAnode(SMnode *pMnode) {
|
||||
SSdbTable table = {
|
||||
|
@ -603,7 +603,7 @@ static int32_t mndRetrieveAnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
if (code != 0) goto _end;
|
||||
|
||||
status[0] = 0;
|
||||
if (mndGetAnodeStatus(pObj, status) == 0) {
|
||||
if (mndGetAnodeStatus(pObj, status, 64) == 0) {
|
||||
STR_TO_VARSTR(buf, status);
|
||||
} else {
|
||||
STR_TO_VARSTR(buf, "offline");
|
||||
|
@ -698,7 +698,7 @@ static int32_t mndDecodeAlgoList(SJson *pJson, SAnodeObj *pObj) {
|
|||
code = tjsonGetDoubleValue(pJson, "protocol", &tmp);
|
||||
if (code < 0) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||
protocol = (int32_t)(tmp * 1000);
|
||||
if (protocol != 100) return TSDB_CODE_MND_ANODE_INVALID_PROTOCOL;
|
||||
if (protocol != 100 && protocol != 1000) return TSDB_CODE_MND_ANODE_INVALID_PROTOCOL;
|
||||
|
||||
code = tjsonGetDoubleValue(pJson, "version", &tmp);
|
||||
pObj->version = (int32_t)(tmp * 1000);
|
||||
|
@ -722,10 +722,10 @@ static int32_t mndDecodeAlgoList(SJson *pJson, SAnodeObj *pObj) {
|
|||
SJson *detail = tjsonGetArrayItem(details, d);
|
||||
if (detail == NULL) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||
|
||||
code = tjsonGetStringValue(detail, "type", buf);
|
||||
code = tjsonGetStringValue2(detail, "type", buf, sizeof(buf));
|
||||
if (code < 0) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||
EAnalAlgoType type = taosAnalAlgoInt(buf);
|
||||
if (type < 0 || type >= ANAL_ALGO_TYPE_END) continue;
|
||||
if (type < 0 || type >= ANAL_ALGO_TYPE_END) return TSDB_CODE_MND_ANODE_INVALID_ALGO_TYPE;
|
||||
|
||||
SJson *algos = tjsonGetObjectItem(detail, "algo");
|
||||
if (algos == NULL) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||
|
@ -734,13 +734,12 @@ static int32_t mndDecodeAlgoList(SJson *pJson, SAnodeObj *pObj) {
|
|||
SJson *algo = tjsonGetArrayItem(algos, a);
|
||||
if (algo == NULL) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||
|
||||
code = tjsonGetStringValue(algo, "name", buf);
|
||||
if (code < 0) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||
code = tjsonGetStringValue2(algo, "name", buf, sizeof(buf));
|
||||
if (code < 0) return TSDB_CODE_MND_ANODE_TOO_LONG_ALGO_NAME;
|
||||
|
||||
SAnodeAlgo algoObj = {0};
|
||||
algoObj.nameLen = strlen(buf) + 1;
|
||||
if (algoObj.nameLen > TSDB_ANAL_ALGO_NAME_LEN) return TSDB_CODE_MND_ANODE_TOO_LONG_ALGO_NAME;
|
||||
if (algoObj.nameLen <= 1) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (algoObj.nameLen <= 1) return TSDB_CODE_INVALID_JSON_FORMAT;
|
||||
algoObj.name = taosMemoryCalloc(algoObj.nameLen, 1);
|
||||
tstrncpy(algoObj.name, buf, algoObj.nameLen);
|
||||
|
||||
|
@ -764,7 +763,7 @@ static int32_t mndGetAnodeAlgoList(const char *url, SAnodeObj *pObj) {
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t mndGetAnodeStatus(SAnodeObj *pObj, char *status) {
|
||||
static int32_t mndGetAnodeStatus(SAnodeObj *pObj, char *status, int32_t statusLen) {
|
||||
int32_t code = 0;
|
||||
int32_t protocol = 0;
|
||||
double tmp = 0;
|
||||
|
@ -780,12 +779,12 @@ static int32_t mndGetAnodeStatus(SAnodeObj *pObj, char *status) {
|
|||
goto _OVER;
|
||||
}
|
||||
protocol = (int32_t)(tmp * 1000);
|
||||
if (protocol != 100) {
|
||||
if (protocol != 100 && protocol != 1000) {
|
||||
code = TSDB_CODE_MND_ANODE_INVALID_PROTOCOL;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = tjsonGetStringValue(pJson, "status", status);
|
||||
code = tjsonGetStringValue2(pJson, "status", status, statusLen);
|
||||
if (code < 0) {
|
||||
code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||
goto _OVER;
|
||||
|
@ -835,7 +834,7 @@ static int32_t mndProcessAnalAlgoReq(SRpcMsg *pReq) {
|
|||
|
||||
for (int32_t a = 0; a < taosArrayGetSize(algos); ++a) {
|
||||
SAnodeAlgo *algo = taosArrayGet(algos, a);
|
||||
nameLen = 1 + snprintf(name, sizeof(name) - 1, "%d:%s", url.type, algo->name);
|
||||
nameLen = 1 + tsnprintf(name, sizeof(name) - 1, "%d:%s", url.type, algo->name);
|
||||
|
||||
SAnalUrl *pOldUrl = taosHashAcquire(rsp.hash, name, nameLen);
|
||||
if (pOldUrl == NULL || (pOldUrl != NULL && pOldUrl->anode < url.anode)) {
|
||||
|
@ -852,7 +851,7 @@ static int32_t mndProcessAnalAlgoReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
url.urlLen = 1 + snprintf(url.url, TSDB_ANAL_ANODE_URL_LEN + TSDB_ANAL_ALGO_TYPE_LEN, "%s/%s", pAnode->url,
|
||||
url.urlLen = 1 + tsnprintf(url.url, TSDB_ANAL_ANODE_URL_LEN + TSDB_ANAL_ALGO_TYPE_LEN, "%s/%s", pAnode->url,
|
||||
taosAnalAlgoUrlStr(url.type));
|
||||
if (taosHashPut(rsp.hash, name, nameLen, &url, sizeof(SAnalUrl)) != 0) {
|
||||
taosMemoryFree(url.url);
|
||||
|
|
|
@ -445,7 +445,7 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
|||
|
||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId);
|
||||
if (pDnode == NULL) {
|
||||
mError("dnodeId:%d, timer failed to send arb-hb request, failed find dnode", dnodeId);
|
||||
mError("dnodeId:%d, timer failed to acquire dnode", dnodeId);
|
||||
taosArrayDestroy(hbMembers);
|
||||
continue;
|
||||
}
|
||||
|
@ -453,7 +453,10 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) {
|
|||
int64_t mndTerm = mndGetTerm(pMnode);
|
||||
|
||||
if (mndIsDnodeOnline(pDnode, nowMs)) {
|
||||
TAOS_CHECK_RETURN(mndSendArbHeartBeatReq(pDnode, arbToken, mndTerm, hbMembers));
|
||||
int32_t sendCode = mndSendArbHeartBeatReq(pDnode, arbToken, mndTerm, hbMembers);
|
||||
if (TSDB_CODE_SUCCESS != sendCode) {
|
||||
mError("dnodeId:%d, timer failed to send arb-hb request", dnodeId);
|
||||
}
|
||||
}
|
||||
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
|
|
|
@ -241,7 +241,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
|
|||
clusterObj.createdTime = taosGetTimestampMs();
|
||||
clusterObj.updateTime = clusterObj.createdTime;
|
||||
|
||||
int32_t code = taosGetSystemUUID(clusterObj.name, TSDB_CLUSTER_ID_LEN);
|
||||
int32_t code = taosGetSystemUUIDLen(clusterObj.name, TSDB_CLUSTER_ID_LEN);
|
||||
if (code != 0) {
|
||||
(void)strcpy(clusterObj.name, "tdengine3.0");
|
||||
mError("failed to get name from system, set to default val %s", clusterObj.name);
|
||||
|
|
|
@ -640,10 +640,10 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
|
|||
rpcMsg.pCont = pHead;
|
||||
|
||||
char detail[1024] = {0};
|
||||
int32_t len = snprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d",
|
||||
int32_t len = tsnprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d",
|
||||
TMSG_INFO(TDMT_VND_QUERY_COMPACT_PROGRESS), epSet.numOfEps, epSet.inUse);
|
||||
for (int32_t i = 0; i < epSet.numOfEps; ++i) {
|
||||
len += snprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||
len += tsnprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port);
|
||||
}
|
||||
|
||||
mDebug("compact:%d, send update progress msg to %s", pDetail->compactId, detail);
|
||||
|
|
|
@ -167,7 +167,7 @@ static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRs
|
|||
}
|
||||
STopicPrivilege *data = taosArrayReserve(rsp->topicPrivileges, 1);
|
||||
MND_TMQ_NULL_CHECK(data);
|
||||
(void)strcpy(data->topic, topic);
|
||||
tstrncpy(data->topic, topic, TSDB_TOPIC_FNAME_LEN);
|
||||
if (mndCheckTopicPrivilege(pMnode, user, MND_OPER_SUBSCRIBE, pTopic) != 0 ||
|
||||
grantCheckExpire(TSDB_GRANT_SUBSCRIPTION) < 0) {
|
||||
data->noPrivilege = 1;
|
||||
|
@ -279,7 +279,7 @@ static int32_t addEpSetInfo(SMnode *pMnode, SMqConsumerObj *pConsumer, int32_t e
|
|||
taosRLockLatch(&pSub->lock);
|
||||
|
||||
SMqSubTopicEp topicEp = {0};
|
||||
(void)strcpy(topicEp.topic, topic);
|
||||
tstrncpy(topicEp.topic, topic, TSDB_TOPIC_FNAME_LEN);
|
||||
|
||||
// 2.1 fetch topic schema
|
||||
SMqTopicObj *pTopic = NULL;
|
||||
|
@ -911,7 +911,7 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
|||
|
||||
// consumer id
|
||||
char consumerIdHex[TSDB_CONSUMER_ID_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)sprintf(varDataVal(consumerIdHex), "0x%" PRIx64, pConsumer->consumerId);
|
||||
(void)snprintf(varDataVal(consumerIdHex), TSDB_CONSUMER_ID_LEN, "0x%" PRIx64, pConsumer->consumerId);
|
||||
varDataSetLen(consumerIdHex, strlen(varDataVal(consumerIdHex)));
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -994,7 +994,7 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
|
|||
|
||||
parasStr = taosMemoryCalloc(1, pShow->pMeta->pSchemas[cols].bytes);
|
||||
MND_TMQ_NULL_CHECK(parasStr);
|
||||
(void)sprintf(varDataVal(parasStr), "tbname:%d,commit:%d,interval:%dms,reset:%s", pConsumer->withTbName,
|
||||
(void)snprintf(varDataVal(parasStr), pShow->pMeta->pSchemas[cols].bytes - VARSTR_HEADER_SIZE, "tbname:%d,commit:%d,interval:%dms,reset:%s", pConsumer->withTbName,
|
||||
pConsumer->autoCommit, pConsumer->autoCommitInterval, buf);
|
||||
varDataSetLen(parasStr, strlen(varDataVal(parasStr)));
|
||||
|
||||
|
|
|
@ -575,6 +575,8 @@ static int32_t mndOpenSdb(SMnode *pMnode) {
|
|||
code = sdbReadFile(pMnode->pSdb);
|
||||
}
|
||||
|
||||
mInfo("vgId:1, mnode sdb is opened, with applied index:%" PRId64, pMnode->pSdb->commitIndex);
|
||||
|
||||
atomic_store_64(&pMnode->applied, pMnode->pSdb->commitIndex);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
|
|||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
char connStr[255] = {0};
|
||||
int32_t len = snprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app);
|
||||
int32_t len = tsnprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app);
|
||||
uint32_t connId = mndGenerateUid(connStr, len);
|
||||
if (startTime == 0) startTime = taosGetTimestampMs();
|
||||
|
||||
|
|
|
@ -1231,7 +1231,7 @@ static int32_t mndGetSma(SMnode *pMnode, SUserIndexReq *indexReq, SUserIndexRsp
|
|||
SNode *node = NULL;
|
||||
FOREACH(node, pList) {
|
||||
SFunctionNode *pFunc = (SFunctionNode *)node;
|
||||
extOffset += snprintf(rsp->indexExts + extOffset, sizeof(rsp->indexExts) - extOffset - 1, "%s%s",
|
||||
extOffset += tsnprintf(rsp->indexExts + extOffset, sizeof(rsp->indexExts) - extOffset - 1, "%s%s",
|
||||
(extOffset ? "," : ""), pFunc->functionName);
|
||||
}
|
||||
|
||||
|
@ -2221,10 +2221,10 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
int32_t len = 0;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (!IS_CALENDAR_TIME_DURATION(pSma->intervalUnit)) {
|
||||
len = snprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval,
|
||||
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval,
|
||||
getPrecisionUnit(pSrcDb->cfg.precision));
|
||||
} else {
|
||||
len = snprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, pSma->intervalUnit);
|
||||
len = tsnprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, pSma->intervalUnit);
|
||||
}
|
||||
varDataSetLen(interval, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -2235,7 +2235,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// create sql
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
len = snprintf(buf + VARSTR_HEADER_SIZE, TSDB_MAX_SAVED_SQL_LEN, "%s", pSma->sql);
|
||||
len = tsnprintf(buf + VARSTR_HEADER_SIZE, TSDB_MAX_SAVED_SQL_LEN, "%s", pSma->sql);
|
||||
varDataSetLen(buf, TMIN(len, TSDB_MAX_SAVED_SQL_LEN));
|
||||
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
}
|
||||
|
|
|
@ -187,12 +187,12 @@ static void mndSplitSubscribeKey(const char *key, char *topic, char *cgroup, boo
|
|||
(void)memcpy(cgroup, key, i);
|
||||
cgroup[i] = 0;
|
||||
if (fullName) {
|
||||
(void)strcpy(topic, &key[i + 1]);
|
||||
tstrncpy(topic, &key[i + 1], TSDB_TOPIC_FNAME_LEN);
|
||||
} else {
|
||||
while (key[i] != '.') {
|
||||
i++;
|
||||
}
|
||||
(void)strcpy(topic, &key[i + 1]);
|
||||
tstrncpy(topic, &key[i + 1], TSDB_CGROUP_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1361,7 +1361,7 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons
|
|||
|
||||
// consumer id
|
||||
char consumerIdHex[TSDB_CONSUMER_ID_LEN] = {0};
|
||||
(void)sprintf(varDataVal(consumerIdHex), "0x%" PRIx64, consumerId);
|
||||
(void)snprintf(varDataVal(consumerIdHex), TSDB_CONSUMER_ID_LEN - VARSTR_HEADER_SIZE, "0x%" PRIx64, consumerId);
|
||||
varDataSetLen(consumerIdHex, strlen(varDataVal(consumerIdHex)));
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -1398,7 +1398,8 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons
|
|||
// vg id
|
||||
char buf[TSDB_OFFSET_LEN * 2 + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)tFormatOffset(varDataVal(buf), TSDB_OFFSET_LEN, &data->offset);
|
||||
(void)sprintf(varDataVal(buf) + strlen(varDataVal(buf)), "/%" PRId64, data->ever);
|
||||
(void)snprintf(varDataVal(buf) + strlen(varDataVal(buf)),
|
||||
sizeof(buf) - VARSTR_HEADER_SIZE - strlen(varDataVal(buf)), "/%" PRId64, data->ever);
|
||||
varDataSetLen(buf, strlen(varDataVal(buf)));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
MND_TMQ_NULL_CHECK(pColInfo);
|
||||
|
|
|
@ -637,7 +637,7 @@ void mndSyncStop(SMnode *pMnode) {
|
|||
|
||||
(void)taosThreadMutexLock(&pMgmt->lock);
|
||||
if (pMgmt->transId != 0) {
|
||||
mInfo("vgId:1, is stopped and post sem, trans:%d", pMgmt->transId);
|
||||
mInfo("vgId:1, trans:%d, is stopped and post sem", pMgmt->transId);
|
||||
pMgmt->transId = 0;
|
||||
pMgmt->transSec = 0;
|
||||
pMgmt->errCode = TSDB_CODE_APP_IS_STOPPING;
|
||||
|
|
|
@ -589,6 +589,7 @@ STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId) {
|
|||
|
||||
void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
if (pTrans != NULL) mInfo("vgId:1, trans:%d, release transaction", pTrans->id);
|
||||
sdbRelease(pSdb, pTrans);
|
||||
}
|
||||
|
||||
|
@ -1131,10 +1132,11 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
if (!sendRsp) {
|
||||
return;
|
||||
} else {
|
||||
mInfo("trans:%d, send rsp, stage:%s failedTimes:%d code:0x%x", pTrans->id, mndTransStr(pTrans->stage),
|
||||
pTrans->failedTimes, code);
|
||||
mInfo("vgId:1, trans:%d, start to send rsp, stage:%s failedTimes:%d code:0x%x", pTrans->id,
|
||||
mndTransStr(pTrans->stage), pTrans->failedTimes, code);
|
||||
}
|
||||
|
||||
mInfo("vgId:1, trans:%d, start to lock rpc array", pTrans->id);
|
||||
taosWLockLatch(&pTrans->lockRpcArray);
|
||||
int32_t size = taosArrayGetSize(pTrans->pRpcArray);
|
||||
if (size <= 0) {
|
||||
|
@ -1155,8 +1157,8 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
if (i != 0 && code == 0) {
|
||||
code = TSDB_CODE_MNODE_NOT_FOUND;
|
||||
}
|
||||
mInfo("trans:%d, client:%d send rsp, code:0x%x stage:%s app:%p", pTrans->id, i, code, mndTransStr(pTrans->stage),
|
||||
pInfo->ahandle);
|
||||
mInfo("vgId:1, trans:%d, client:%d start to send rsp, code:0x%x stage:%s app:%p", pTrans->id, i, code,
|
||||
mndTransStr(pTrans->stage), pInfo->ahandle);
|
||||
|
||||
SRpcMsg rspMsg = {.code = code, .info = *pInfo};
|
||||
|
||||
|
@ -1199,6 +1201,9 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
}
|
||||
|
||||
tmsgSendRsp(&rspMsg);
|
||||
|
||||
mInfo("vgId:1, trans:%d, client:%d send rsp finished, code:0x%x stage:%s app:%p", pTrans->id, i, code,
|
||||
mndTransStr(pTrans->stage), pInfo->ahandle);
|
||||
}
|
||||
}
|
||||
taosArrayClear(pTrans->pRpcArray);
|
||||
|
@ -1338,10 +1343,10 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
|
|||
memcpy(rpcMsg.pCont, pAction->pCont, pAction->contLen);
|
||||
|
||||
char detail[1024] = {0};
|
||||
int32_t len = snprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d", TMSG_INFO(pAction->msgType),
|
||||
int32_t len = tsnprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d", TMSG_INFO(pAction->msgType),
|
||||
pAction->epSet.numOfEps, pAction->epSet.inUse);
|
||||
for (int32_t i = 0; i < pAction->epSet.numOfEps; ++i) {
|
||||
len += snprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, pAction->epSet.eps[i].fqdn,
|
||||
len += tsnprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, pAction->epSet.eps[i].fqdn,
|
||||
pAction->epSet.eps[i].port);
|
||||
}
|
||||
|
||||
|
@ -2019,14 +2024,14 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
|
||||
char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char detail[TSDB_TRANS_ERROR_LEN + 1] = {0};
|
||||
int32_t len = snprintf(detail, sizeof(detail), "action:%d code:0x%x(%s) ", pTrans->lastAction,
|
||||
int32_t len = tsnprintf(detail, sizeof(detail), "action:%d code:0x%x(%s) ", pTrans->lastAction,
|
||||
pTrans->lastErrorNo & 0xFFFF, tstrerror(pTrans->lastErrorNo));
|
||||
SEpSet epset = pTrans->lastEpset;
|
||||
if (epset.numOfEps > 0) {
|
||||
len += snprintf(detail + len, sizeof(detail) - len, "msgType:%s numOfEps:%d inUse:%d ",
|
||||
len += tsnprintf(detail + len, sizeof(detail) - len, "msgType:%s numOfEps:%d inUse:%d ",
|
||||
TMSG_INFO(pTrans->lastMsgType), epset.numOfEps, epset.inUse);
|
||||
for (int32_t i = 0; i < pTrans->lastEpset.numOfEps; ++i) {
|
||||
len += snprintf(detail + len, sizeof(detail) - len, "ep:%d-%s:%u ", i, epset.eps[i].fqdn, epset.eps[i].port);
|
||||
len += tsnprintf(detail + len, sizeof(detail) - len, "ep:%d-%s:%u ", i, epset.eps[i].fqdn, epset.eps[i].port);
|
||||
}
|
||||
}
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
|
|
@ -168,11 +168,10 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
|
|||
}
|
||||
|
||||
void sdbSetApplyInfo(SSdb *pSdb, int64_t index, int64_t term, int64_t config) {
|
||||
#if 1
|
||||
mTrace("mnode apply info changed from index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " to index:%" PRId64
|
||||
" term:%" PRId64 " config:%" PRId64,
|
||||
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, index, term, config);
|
||||
#endif
|
||||
mInfo("vgId:1, mnode apply info changed from index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " to index:%" PRId64
|
||||
" term:%" PRId64 " config:%" PRId64,
|
||||
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, index, term, config);
|
||||
|
||||
pSdb->applyIndex = index;
|
||||
pSdb->applyTerm = term;
|
||||
pSdb->applyConfig = config;
|
||||
|
|
|
@ -207,6 +207,8 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
return terrno;
|
||||
}
|
||||
|
||||
mInfo("vgId:1, write sdb file with sdb applyIndex:%" PRId64 " term:%" PRId64 " config:%" PRId64, pSdb->applyIndex,
|
||||
pSdb->applyTerm, pSdb->applyConfig);
|
||||
if (taosWriteFile(pFile, &pSdb->applyIndex, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
return terrno;
|
||||
}
|
||||
|
@ -607,6 +609,9 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) {
|
|||
}
|
||||
if (code != 0) {
|
||||
mError("failed to write sdb file since %s", tstrerror(code));
|
||||
} else {
|
||||
mInfo("write sdb file success, apply index:%" PRId64 " term:%" PRId64 " config:%" PRId64, pSdb->applyIndex,
|
||||
pSdb->applyTerm, pSdb->applyConfig);
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pSdb->filelock);
|
||||
return code;
|
||||
|
|
|
@ -42,6 +42,7 @@ void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc) {
|
|||
// remove attached object such as trans
|
||||
SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type];
|
||||
if (deleteFp != NULL) {
|
||||
mInfo("vgId:1, deleteFp:%p, type:%s", deleteFp, sdbTableName(pRow->type));
|
||||
(void)(*deleteFp)(pSdb, pRow->pObj, callFunc);
|
||||
}
|
||||
|
||||
|
|
|
@ -3133,7 +3133,12 @@ static void colCompressDebug(SHashObj *pColCmprObj) {
|
|||
int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) {
|
||||
int rc = 0;
|
||||
|
||||
SHashObj *pColCmprObj = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
||||
SHashObj *pColCmprObj = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
||||
if (pColCmprObj == NULL) {
|
||||
pColCmprObj = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
void *pData = NULL;
|
||||
int nData = 0;
|
||||
SMetaEntry e = {0};
|
||||
|
|
|
@ -22,7 +22,7 @@ int32_t tqBuildFName(char** data, const char* path, char* name) {
|
|||
if(fname == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
int32_t code = snprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
||||
int32_t code = tsnprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
||||
if (code < 0){
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosMemoryFree(fname);
|
||||
|
|
|
@ -562,9 +562,18 @@ int32_t tqMaskBlock(SSchemaWrapper* pDst, SSDataBlock* pBlock, const SSchemaWrap
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t buildResSDataBlock(SSDataBlock* pBlock, SSchemaWrapper* pSchema, const SArray* pColIdList) {
|
||||
static int32_t buildResSDataBlock(STqReader* pReader, SSchemaWrapper* pSchema, const SArray* pColIdList) {
|
||||
SSDataBlock* pBlock = pReader->pResBlock;
|
||||
if (blockDataGetNumOfCols(pBlock) > 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
blockDataDestroy(pBlock);
|
||||
int32_t code = createDataBlock(&pReader->pResBlock);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
pBlock = pReader->pResBlock;
|
||||
|
||||
pBlock->info.id.uid = pReader->cachedSchemaUid;
|
||||
pBlock->info.version = pReader->msg.ver;
|
||||
}
|
||||
|
||||
int32_t numOfCols = taosArrayGetSize(pColIdList);
|
||||
|
@ -678,10 +687,10 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char*
|
|||
vgId, suid, uid, sversion, pReader->pSchemaWrapper->version);
|
||||
return TSDB_CODE_TQ_INTERNAL_ERROR;
|
||||
}
|
||||
if (blockDataGetNumOfCols(pBlock) == 0) {
|
||||
code = buildResSDataBlock(pReader->pResBlock, pReader->pSchemaWrapper, pReader->pColIdList);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
code = buildResSDataBlock(pReader, pReader->pSchemaWrapper, pReader->pColIdList);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
pBlock = pReader->pResBlock;
|
||||
*pRes = pBlock;
|
||||
}
|
||||
|
||||
int32_t numOfRows = 0;
|
||||
|
|
|
@ -73,14 +73,19 @@ int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* p
|
|||
}
|
||||
|
||||
if (varTbName != NULL && varTbName != (void*)-1) {
|
||||
name = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN);
|
||||
size_t cap = TMAX(TSDB_TABLE_NAME_LEN, varDataLen(varTbName) + 1);
|
||||
name = taosMemoryMalloc(cap);
|
||||
if (name == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
memcpy(name, varDataVal(varTbName), varDataLen(varTbName));
|
||||
name[varDataLen(varTbName)] = '\0';
|
||||
if (newSubTableRule && !isAutoTableName(name) && !alreadyAddGroupId(name, groupId) && groupId != 0 && stbFullName) {
|
||||
buildCtbNameAddGroupId(stbFullName, name, groupId);
|
||||
int32_t code = buildCtbNameAddGroupId(stbFullName, name, groupId, cap);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
} else if (stbFullName) {
|
||||
int32_t code = buildCtbNameByGroupId(stbFullName, groupId, &name);
|
||||
|
@ -107,7 +112,7 @@ int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* p
|
|||
groupId, name, skey, ekey);
|
||||
|
||||
SSingleDeleteReq req = {.startTs = skey, .endTs = ekey};
|
||||
strncpy(req.tbname, name, TSDB_TABLE_NAME_LEN - 1);
|
||||
tstrncpy(req.tbname, name, TSDB_TABLE_NAME_LEN);
|
||||
void* p = taosArrayPush(deleteReq->deleteReqs, &req);
|
||||
if (p == NULL) {
|
||||
return terrno;
|
||||
|
@ -235,8 +240,11 @@ int32_t setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock*
|
|||
return terrno;
|
||||
}
|
||||
|
||||
strcpy(pCreateTableReq->name, pDataBlock->info.parTbName);
|
||||
buildCtbNameAddGroupId(stbFullName, pCreateTableReq->name, gid);
|
||||
tstrncpy(pCreateTableReq->name, pDataBlock->info.parTbName, TSDB_TABLE_NAME_LEN);
|
||||
int32_t code = buildCtbNameAddGroupId(stbFullName, pCreateTableReq->name, gid, TSDB_TABLE_NAME_LEN);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
// tqDebug("gen name from:%s", pDataBlock->info.parTbName);
|
||||
} else {
|
||||
pCreateTableReq->name = taosStrdup(pDataBlock->info.parTbName);
|
||||
|
@ -852,9 +860,12 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat
|
|||
!alreadyAddGroupId(dstTableName, groupId) && groupId != 0) {
|
||||
tqDebug("s-task:%s append groupId:%" PRId64 " for generated dstTable:%s", id, groupId, dstTableName);
|
||||
if (pTask->ver == SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
||||
buildCtbNameAddGroupId(NULL, dstTableName, groupId);
|
||||
code = buildCtbNameAddGroupId(NULL, dstTableName, groupId, sizeof(pDataBlock->info.parTbName));
|
||||
} else if (pTask->ver > SSTREAM_TASK_SUBTABLE_CHANGED_VER && stbFullName) {
|
||||
buildCtbNameAddGroupId(stbFullName, dstTableName, groupId);
|
||||
code = buildCtbNameAddGroupId(stbFullName, dstTableName, groupId, sizeof(pDataBlock->info.parTbName));
|
||||
}
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1250,4 +1261,4 @@ int32_t doBuildAndSendDeleteMsg(SVnode* pVnode, char* stbFullName, SSDataBlock*
|
|||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1767,10 +1767,14 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
|||
SLastCol *pLastCol = h ? (SLastCol *)taosLRUCacheValue(pCache, h) : NULL;
|
||||
if (h && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) {
|
||||
SLastCol lastCol = *pLastCol;
|
||||
TAOS_CHECK_GOTO(tsdbCacheReallocSLastCol(&lastCol, NULL), NULL, _exit);
|
||||
if (TSDB_CODE_SUCCESS != (code = tsdbCacheReallocSLastCol(&lastCol, NULL))) {
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||
}
|
||||
|
||||
if (taosArrayPush(pLastArray, &lastCol) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
} else {
|
||||
|
@ -1780,28 +1784,33 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
|||
|
||||
if (taosArrayPush(pLastArray, &noneCol) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (!remainCols) {
|
||||
if ((remainCols = taosArrayInit(numKeys, sizeof(SIdxKey))) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
if (!ignoreFromRocks) {
|
||||
if ((ignoreFromRocks = taosArrayInit(numKeys, sizeof(bool))) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
if (taosArrayPush(remainCols, &(SIdxKey){i, key}) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
bool ignoreRocks = pLastCol ? (pLastCol->cacheStatus == TSDB_LAST_CACHE_NO_CACHE) : false;
|
||||
if (taosArrayPush(ignoreFromRocks, &ignoreRocks) == NULL) {
|
||||
code = terrno;
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
@ -1822,6 +1831,7 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
|||
SLastCol lastCol = *pLastCol;
|
||||
code = tsdbCacheReallocSLastCol(&lastCol, NULL);
|
||||
if (code) {
|
||||
tsdbLRUCacheRelease(pCache, h, false);
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -3600,4 +3610,4 @@ void tsdbCacheSetPageS3(SLRUCache *pCache, STsdbFD *pFD, int64_t pgno, uint8_t *
|
|||
(void)taosThreadMutexUnlock(&pFD->pTsdb->pgMutex);
|
||||
|
||||
tsdbCacheRelease(pFD->pTsdb->pgCache, handle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "functionMgt.h"
|
||||
#include "functionResInfo.h"
|
||||
#include "taoserror.h"
|
||||
#include "tarray.h"
|
||||
#include "tcommon.h"
|
||||
|
|
|
@ -433,6 +433,21 @@ static int32_t tsdbFSCreateFileObjHash(STFileSystem *fs, STFileHash *hash) {
|
|||
if (fset->farr[i] != NULL) {
|
||||
code = tsdbFSAddEntryToFileObjHash(hash, fset->farr[i]->fname);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if (TSDB_FTYPE_DATA == i && fset->farr[i]->f->lcn > 0) {
|
||||
STFileObj *fobj = fset->farr[i];
|
||||
int32_t lcn = fobj->f->lcn;
|
||||
char lcn_name[TSDB_FILENAME_LEN];
|
||||
|
||||
snprintf(lcn_name, TSDB_FQDN_LEN, "%s", fobj->fname);
|
||||
char *dot = strrchr(lcn_name, '.');
|
||||
if (dot) {
|
||||
snprintf(dot + 1, TSDB_FQDN_LEN - (dot + 1 - lcn_name), "%d.data", lcn);
|
||||
|
||||
code = tsdbFSAddEntryToFileObjHash(hash, lcn_name);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -535,9 +550,7 @@ static int32_t tsdbFSDoSanAndFix(STFileSystem *fs) {
|
|||
for (const STfsFile *file = NULL; (file = tfsReaddir(dir)) != NULL;) {
|
||||
if (taosIsDir(file->aname)) continue;
|
||||
|
||||
if (tsdbFSGetFileObjHashEntry(&fobjHash, file->aname) == NULL &&
|
||||
strncmp(file->aname + strlen(file->aname) - 3, ".cp", 3) &&
|
||||
strncmp(file->aname + strlen(file->aname) - 5, ".data", 5)) {
|
||||
if (tsdbFSGetFileObjHashEntry(&fobjHash, file->aname) == NULL) {
|
||||
tsdbRemoveFile(file->aname);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,11 @@ static int32_t tsdbFSetWriteTableDataBegin(SFSetWriter *writer, const TABLEID *t
|
|||
code = tsdbUpdateSkmTb(writer->config->tsdb, writer->ctx->tbid, writer->skmTb);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if (writer->pColCmprObj != NULL) {
|
||||
taosHashCleanup(writer->pColCmprObj);
|
||||
writer->pColCmprObj = NULL;
|
||||
}
|
||||
code = metaGetColCmpr(writer->config->tsdb->pVnode->pMeta, tbid->suid ? tbid->suid : tbid->uid, &writer->pColCmprObj);
|
||||
// TODO: TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
writer->blockDataIdx = 0;
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(writer->blockData); i++) {
|
||||
|
@ -127,6 +130,8 @@ _exit:
|
|||
TSDB_ERROR_LOG(TD_VID(writer->config->tsdb->pVnode), lino, code);
|
||||
}
|
||||
taosHashCleanup(writer->pColCmprObj);
|
||||
writer->pColCmprObj = NULL;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -2916,7 +2916,7 @@ int32_t ctgHandleGetTbTSMARsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf
|
|||
|
||||
if (META_TYPE_BOTH_TABLE == pOut->metaType) {
|
||||
// rewrite tsma fetch table with it's super table name
|
||||
(void)sprintf(pFetch->tsmaSourceTbName.tname, "%s", pOut->tbName);
|
||||
(void)snprintf(pFetch->tsmaSourceTbName.tname, sizeof(pFetch->tsmaSourceTbName.tname), "%s", pOut->tbName);
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgGetTbTSMAFromMnode(pCtg, pConn, &pFetch->tsmaSourceTbName, NULL, tReq, TDMT_MND_GET_TABLE_TSMA));
|
||||
|
|
|
@ -176,22 +176,22 @@ int32_t ctgdLaunchAsyncCall(SCatalog *pCtg, SRequestConnInfo *pConn, uint64_t re
|
|||
taosArrayPush(req.pTableMeta, &name);
|
||||
taosArrayPush(req.pTableHash, &name);
|
||||
|
||||
strcpy(dbFName, "1.db1");
|
||||
tstrncpy(dbFName, "1.db1", sizeof(dbFName));
|
||||
taosArrayPush(req.pDbVgroup, dbFName);
|
||||
taosArrayPush(req.pDbCfg, dbFName);
|
||||
taosArrayPush(req.pDbInfo, dbFName);
|
||||
strcpy(dbFName, "1.db2");
|
||||
tstrncpy(dbFName, "1.db2", sizeof(dbFName));
|
||||
taosArrayPush(req.pDbVgroup, dbFName);
|
||||
taosArrayPush(req.pDbCfg, dbFName);
|
||||
taosArrayPush(req.pDbInfo, dbFName);
|
||||
|
||||
strcpy(funcName, "udf1");
|
||||
tstrncpy(funcName, "udf1", sizeof(funcName));
|
||||
taosArrayPush(req.pUdf, funcName);
|
||||
strcpy(funcName, "udf2");
|
||||
tstrncpy(funcName, "udf2", sizeof(funcName));
|
||||
taosArrayPush(req.pUdf, funcName);
|
||||
|
||||
strcpy(user.user, "root");
|
||||
strcpy(user.dbFName, "1.db1");
|
||||
tstrncpy(user.user, "root", sizeof(user.user));
|
||||
tstrncpy(user.dbFName, "1.db1", sizeof(user.dbFName));
|
||||
user.type = AUTH_TYPE_READ;
|
||||
taosArrayPush(req.pUser, &user);
|
||||
user.type = AUTH_TYPE_WRITE;
|
||||
|
@ -199,8 +199,8 @@ int32_t ctgdLaunchAsyncCall(SCatalog *pCtg, SRequestConnInfo *pConn, uint64_t re
|
|||
user.type = AUTH_TYPE_OTHER;
|
||||
taosArrayPush(req.pUser, &user);
|
||||
|
||||
strcpy(user.user, "user1");
|
||||
strcpy(user.dbFName, "1.db2");
|
||||
tstrncpy(user.user, "user1", sizeof(user.user));
|
||||
tstrncpy(user.dbFName, "1.db2", sizeof(user.dbFName));
|
||||
user.type = AUTH_TYPE_READ;
|
||||
taosArrayPush(req.pUser, &user);
|
||||
user.type = AUTH_TYPE_WRITE;
|
||||
|
@ -335,7 +335,7 @@ int32_t ctgdHandleDbgCommand(char *command) {
|
|||
CTG_RET(TSDB_CODE_INVALID_PARA);
|
||||
}
|
||||
|
||||
bool enable = atoi(param);
|
||||
bool enable = taosStr2Int32(param, NULL, 10);
|
||||
|
||||
int32_t code = ctgdEnableDebug(option, enable);
|
||||
|
||||
|
|
|
@ -1303,7 +1303,7 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
|||
int32_t msgLen = 0;
|
||||
int32_t reqType = TDMT_MND_TABLE_META;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
(void)sprintf(tbFName, "%s.%s", dbFName, tbName);
|
||||
(void)snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, tbName);
|
||||
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont;
|
||||
|
||||
ctgDebug("try to get table meta from mnode, tbFName:%s", tbFName);
|
||||
|
@ -1369,7 +1369,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
|
|||
(void)tNameGetFullDbName(pTableName, dbFName);
|
||||
int32_t reqType = (pTask && pTask->type == CTG_TASK_GET_TB_NAME ? TDMT_VND_TABLE_NAME : TDMT_VND_TABLE_META);
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
(void)sprintf(tbFName, "%s.%s", dbFName, pTableName->tname);
|
||||
(void)snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, pTableName->tname);
|
||||
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont;
|
||||
|
||||
SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse];
|
||||
|
|
|
@ -1386,7 +1386,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SEpSet* pMgmgEpSet, SCtgTaskR
|
|||
}
|
||||
|
||||
char tbFullName[TSDB_TABLE_FNAME_LEN];
|
||||
(void)sprintf(tbFullName, "%s.", dbFName);
|
||||
(void)snprintf(tbFullName, sizeof(tbFullName), "%s.", dbFName);
|
||||
int32_t offset = strlen(tbFullName);
|
||||
SName* pName = NULL;
|
||||
int32_t tbNameLen = 0;
|
||||
|
@ -2070,7 +2070,7 @@ int32_t ctgChkSetTbAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
|
|||
continue;
|
||||
}
|
||||
|
||||
(void)sprintf(tbFName, "%s.%s", dbFName, stbName);
|
||||
(void)snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, stbName);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -303,13 +303,13 @@ static int32_t buildRetension(SArray* pRetension, char** ppRetentions) {
|
|||
int64_t v1 = getValOfDiffPrecision(p->freqUnit, p->freq);
|
||||
int64_t v2 = getValOfDiffPrecision(p->keepUnit, p->keep);
|
||||
if (i == 0) {
|
||||
len += snprintf(p1 + len, lMaxLen - len, "-:%" PRId64 "%c", v2, p->keepUnit);
|
||||
len += tsnprintf(p1 + len, lMaxLen - len, "-:%" PRId64 "%c", v2, p->keepUnit);
|
||||
} else {
|
||||
len += snprintf(p1 + len, lMaxLen - len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit);
|
||||
len += tsnprintf(p1 + len, lMaxLen - len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit);
|
||||
}
|
||||
|
||||
if (i < size - 1) {
|
||||
len += snprintf(p1 + len, lMaxLen - len, ",");
|
||||
len += tsnprintf(p1 + len, lMaxLen - len, ",");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,12 +352,12 @@ int32_t formatDurationOrKeep(char* buffer, int64_t bufSize, int32_t timeInMinute
|
|||
int32_t len = 0;
|
||||
if (timeInMinutes % 1440 == 0) {
|
||||
int32_t days = timeInMinutes / 1440;
|
||||
len = snprintf(buffer, bufSize, "%dd", days);
|
||||
len = tsnprintf(buffer, bufSize, "%dd", days);
|
||||
} else if (timeInMinutes % 60 == 0) {
|
||||
int32_t hours = timeInMinutes / 60;
|
||||
len = snprintf(buffer, bufSize, "%dh", hours);
|
||||
len = tsnprintf(buffer, bufSize, "%dh", hours);
|
||||
} else {
|
||||
len = snprintf(buffer, bufSize, "%dm", timeInMinutes);
|
||||
len = tsnprintf(buffer, bufSize, "%dm", timeInMinutes);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
@ -410,9 +410,9 @@ static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName,
|
|||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), pCfg->daysToKeep2);
|
||||
|
||||
if (IS_SYS_DBNAME(dbName)) {
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE DATABASE `%s`", dbName);
|
||||
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE DATABASE `%s`", dbName);
|
||||
} else {
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
"CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %s "
|
||||
"WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %s,%s,%s PAGES %d PAGESIZE %d "
|
||||
"PRECISION '%s' REPLICA %d "
|
||||
|
@ -430,7 +430,7 @@ static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName,
|
|||
pCfg->s3KeepLocal, pCfg->s3Compact);
|
||||
|
||||
if (pRetentions) {
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, " RETENTIONS %s", pRetentions);
|
||||
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, " RETENTIONS %s", pRetentions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -510,28 +510,29 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
#define LTYPE_LEN (32 + 60) // 60 byte for compress info
|
||||
char type[LTYPE_LEN];
|
||||
snprintf(type, LTYPE_LEN, "%s", tDataTypes[pSchema->type].name);
|
||||
int typeLen = strlen(type);
|
||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type ||
|
||||
TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
} else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) {
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), "(%d)",
|
||||
typeLen += snprintf(type + typeLen, LTYPE_LEN - typeLen, "(%d)",
|
||||
(int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
}
|
||||
|
||||
if (useCompress(pCfg->tableType) && pCfg->pSchemaExt) {
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), " ENCODE \'%s\'",
|
||||
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " ENCODE \'%s\'",
|
||||
columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), " COMPRESS \'%s\'",
|
||||
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " COMPRESS \'%s\'",
|
||||
columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||
snprintf(type + strlen(type), LTYPE_LEN - strlen(type), " LEVEL \'%s\'",
|
||||
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " LEVEL \'%s\'",
|
||||
columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress)));
|
||||
}
|
||||
if (!(pSchema->flags & COL_IS_KEY)) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s",
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s",
|
||||
((i > 0) ? ", " : ""), pSchema->name, type);
|
||||
} else {
|
||||
char* pk = "PRIMARY KEY";
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s %s",
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s %s",
|
||||
((i > 0) ? ", " : ""), pSchema->name, type, pk);
|
||||
}
|
||||
}
|
||||
|
@ -550,7 +551,7 @@ void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
(int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
}
|
||||
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, sizeof(type) - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s",
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, sizeof(type) - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s",
|
||||
((i > 0) ? ", " : ""), pSchema->name, type);
|
||||
}
|
||||
}
|
||||
|
@ -558,7 +559,7 @@ void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
void appendTagNameFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
||||
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"%s`%s`", ((i > 0) ? ", " : ""), pSchema->name);
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +581,7 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
qError("failed to parse tag to json, pJson is NULL");
|
||||
return terrno;
|
||||
}
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"%s", pJson);
|
||||
taosMemoryFree(pJson);
|
||||
|
||||
|
@ -594,12 +595,12 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
||||
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
||||
if (i > 0) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
", ");
|
||||
}
|
||||
|
||||
if (j >= valueNum) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"NULL");
|
||||
continue;
|
||||
}
|
||||
|
@ -629,7 +630,7 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
*len += tlen;
|
||||
j++;
|
||||
} else {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"NULL");
|
||||
}
|
||||
}
|
||||
|
@ -641,38 +642,38 @@ _exit:
|
|||
|
||||
void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg* pCfg) {
|
||||
if (pCfg->commentLen > 0) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" COMMENT '%s'", pCfg->pComment);
|
||||
} else if (0 == pCfg->commentLen) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" COMMENT ''");
|
||||
}
|
||||
|
||||
if (NULL != pDbCfg->pRetensions && pCfg->watermark1 > 0) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" WATERMARK %" PRId64 "a", pCfg->watermark1);
|
||||
if (pCfg->watermark2 > 0) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
", %" PRId64 "a", pCfg->watermark2);
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL != pDbCfg->pRetensions && pCfg->delay1 > 0) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" MAX_DELAY %" PRId64 "a", pCfg->delay1);
|
||||
if (pCfg->delay2 > 0) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
", %" PRId64 "a", pCfg->delay2);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t funcNum = taosArrayGetSize(pCfg->pFuncs);
|
||||
if (NULL != pDbCfg->pRetensions && funcNum > 0) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" ROLLUP(");
|
||||
for (int32_t i = 0; i < funcNum; ++i) {
|
||||
char* pFunc = taosArrayGet(pCfg->pFuncs, i);
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
"%s%s", ((i > 0) ? ", " : ""), pFunc);
|
||||
}
|
||||
*len +=
|
||||
|
@ -680,7 +681,7 @@ void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg*
|
|||
}
|
||||
|
||||
if (pCfg->ttl > 0) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" TTL %d", pCfg->ttl);
|
||||
}
|
||||
|
||||
|
@ -694,23 +695,23 @@ void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg*
|
|||
|
||||
if (nSma < pCfg->numOfColumns && nSma > 0) {
|
||||
bool smaOn = false;
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||
" SMA(");
|
||||
for (int32_t i = 0; i < pCfg->numOfColumns; ++i) {
|
||||
if (IS_BSMA_ON(pCfg->pSchemas + i)) {
|
||||
if (smaOn) {
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len,
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len,
|
||||
SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), ",`%s`",
|
||||
(pCfg->pSchemas + i)->name);
|
||||
} else {
|
||||
smaOn = true;
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len,
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len,
|
||||
SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "`%s`",
|
||||
(pCfg->pSchemas + i)->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
*len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, ")");
|
||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -734,20 +735,20 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p
|
|||
int32_t len = 0;
|
||||
|
||||
if (TSDB_SUPER_TABLE == pCfg->tableType) {
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
"CREATE STABLE `%s` (", tbName);
|
||||
appendColumnFields(buf2, &len, pCfg);
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len),
|
||||
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len),
|
||||
") TAGS (");
|
||||
appendTagFields(buf2, &len, pCfg);
|
||||
len +=
|
||||
snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len), ")");
|
||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||
} else if (TSDB_CHILD_TABLE == pCfg->tableType) {
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
"CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName);
|
||||
appendTagNameFields(buf2, &len, pCfg);
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len),
|
||||
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len),
|
||||
") TAGS (");
|
||||
code = appendTagValues(buf2, &len, pCfg);
|
||||
TAOS_CHECK_ERRNO(code);
|
||||
|
@ -755,7 +756,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p
|
|||
snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len), ")");
|
||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||
} else {
|
||||
len += snprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
|
||||
"CREATE TABLE `%s` (", tbName);
|
||||
appendColumnFields(buf2, &len, pCfg);
|
||||
len +=
|
||||
|
|
|
@ -5,6 +5,10 @@ if(${TD_DARWIN})
|
|||
target_compile_options(executor PRIVATE -Wno-error=deprecated-non-prototype)
|
||||
endif(${TD_DARWIN})
|
||||
|
||||
IF(${BUILD_WITH_ANALYSIS})
|
||||
add_definitions(-DUSE_ANAL)
|
||||
ENDIF()
|
||||
|
||||
target_link_libraries(executor
|
||||
PRIVATE os util common function parser planner qcom scalar nodes index wal tdb geometry
|
||||
)
|
||||
|
|
|
@ -1641,13 +1641,17 @@ int32_t getTableListInfo(const SExecTaskInfo* pTaskInfo, SArray** pList) {
|
|||
|
||||
int32_t qStreamOperatorReleaseState(qTaskInfo_t tInfo) {
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tInfo;
|
||||
pTaskInfo->pRoot->fpSet.releaseStreamStateFn(pTaskInfo->pRoot);
|
||||
if (pTaskInfo->pRoot->fpSet.releaseStreamStateFn != NULL) {
|
||||
pTaskInfo->pRoot->fpSet.releaseStreamStateFn(pTaskInfo->pRoot);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t qStreamOperatorReloadState(qTaskInfo_t tInfo) {
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tInfo;
|
||||
pTaskInfo->pRoot->fpSet.reloadStreamStateFn(pTaskInfo->pRoot);
|
||||
if (pTaskInfo->pRoot->fpSet.reloadStreamStateFn != NULL) {
|
||||
pTaskInfo->pRoot->fpSet.reloadStreamStateFn(pTaskInfo->pRoot);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,14 +78,15 @@ static void logGroupCacheExecInfo(SGroupCacheOperatorInfo* pGrpCacheOperator) {
|
|||
if (pGrpCacheOperator->downstreamNum <= 0 || NULL == pGrpCacheOperator->execInfo.pDownstreamBlkNum) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* buf = taosMemoryMalloc(pGrpCacheOperator->downstreamNum * 32 + 100);
|
||||
|
||||
int32_t bufSize = pGrpCacheOperator->downstreamNum * 32 + 100;
|
||||
char* buf = taosMemoryMalloc(bufSize);
|
||||
if (NULL == buf) {
|
||||
return;
|
||||
}
|
||||
int32_t offset = sprintf(buf, "groupCache exec info, downstreamBlkNum:");
|
||||
int32_t offset = snprintf(buf, bufSize, "groupCache exec info, downstreamBlkNum:");
|
||||
for (int32_t i = 0; i < pGrpCacheOperator->downstreamNum; ++i) {
|
||||
offset += sprintf(buf + offset, " %" PRId64 , pGrpCacheOperator->execInfo.pDownstreamBlkNum[i]);
|
||||
offset += snprintf(buf + offset, bufSize, " %" PRId64 , pGrpCacheOperator->execInfo.pDownstreamBlkNum[i]);
|
||||
}
|
||||
qDebug("%s", buf);
|
||||
taosMemoryFree(buf);
|
||||
|
@ -234,7 +235,7 @@ static int32_t acquireFdFromFileCtx(SGcFileCacheCtx* pFileCtx, int32_t fileId, S
|
|||
|
||||
SGroupCacheFileInfo* pTmp = taosHashGet(pFileCtx->pCacheFile, &fileId, sizeof(fileId));
|
||||
if (NULL == pTmp) {
|
||||
(void)sprintf(&pFileCtx->baseFilename[pFileCtx->baseNameLen], "_%d", fileId);
|
||||
(void)snprintf(&pFileCtx->baseFilename[pFileCtx->baseNameLen], sizeof(pFileCtx->baseFilename) - pFileCtx->baseNameLen, "_%d", fileId);
|
||||
|
||||
SGroupCacheFileInfo newFile = {0};
|
||||
if (taosHashPut(pFileCtx->pCacheFile, &fileId, sizeof(fileId), &newFile, sizeof(newFile))) {
|
||||
|
@ -439,7 +440,7 @@ static FORCE_INLINE void chkRemoveVgroupCurrFile(SGcFileCacheCtx* pFileCtx, int3
|
|||
|
||||
#if 0
|
||||
/* debug only */
|
||||
sprintf(&pFileCtx->baseFilename[pFileCtx->baseNameLen], "_%d", pFileCtx->fileId);
|
||||
snprintf(&pFileCtx->baseFilename[pFileCtx->baseNameLen], sizeof(pFileCtx->baseFilename) - pFileCtx->baseNameLen, "_%d", pFileCtx->fileId);
|
||||
taosRemoveFile(pFileCtx->baseFilename);
|
||||
/* debug only */
|
||||
#endif
|
||||
|
@ -813,7 +814,7 @@ static int32_t addFileRefTableNum(SGcFileCacheCtx* pFileCtx, int32_t fileId, int
|
|||
|
||||
SGroupCacheFileInfo* pTmp = taosHashGet(pFileCtx->pCacheFile, &fileId, sizeof(fileId));
|
||||
if (NULL == pTmp) {
|
||||
(void)sprintf(&pFileCtx->baseFilename[pFileCtx->baseNameLen], "_%u", fileId);
|
||||
(void)snprintf(&pFileCtx->baseFilename[pFileCtx->baseNameLen], sizeof(pFileCtx->baseFilename) - pFileCtx->baseNameLen, "_%u", fileId);
|
||||
|
||||
SGroupCacheFileInfo newFile = {0};
|
||||
newFile.groupNum = 1;
|
||||
|
@ -1377,7 +1378,7 @@ static void freeRemoveGroupCacheData(void* p) {
|
|||
|
||||
#if 0
|
||||
/* debug only */
|
||||
sprintf(&pFileCtx->baseFilename[pFileCtx->baseNameLen], "_%d", pGroup->fileId);
|
||||
snprintf(&pFileCtx->baseFilename[pFileCtx->baseNameLen], sizeof(pFileCtx->baseFilename) - pFileCtx->baseNameLen, "_%d", pGroup->fileId);
|
||||
taosRemoveFile(pFileCtx->baseFilename);
|
||||
/* debug only */
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#define STREAM_SESSION_OP_CHECKPOINT_NAME "StreamSessionOperator_Checkpoint"
|
||||
#define STREAM_STATE_OP_CHECKPOINT_NAME "StreamStateOperator_Checkpoint"
|
||||
|
||||
#define MAX_STREAM_HISTORY_RESULT 20000000
|
||||
#define MAX_STREAM_HISTORY_RESULT 20000000
|
||||
|
||||
typedef struct SStateWindowInfo {
|
||||
SResultWindowInfo winInfo;
|
||||
|
@ -449,7 +449,7 @@ void destroyFlusedPos(void* pRes) {
|
|||
}
|
||||
|
||||
void destroyFlusedppPos(void* ppRes) {
|
||||
void *pRes = *(void **)ppRes;
|
||||
void* pRes = *(void**)ppRes;
|
||||
destroyFlusedPos(pRes);
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) {
|
|||
}
|
||||
taosArrayDestroy(pInfo->pMidPullDatas);
|
||||
|
||||
if (pInfo->pState !=NULL && pInfo->pState->dump == 1) {
|
||||
if (pInfo->pState != NULL && pInfo->pState->dump == 1) {
|
||||
taosMemoryFreeClear(pInfo->pState->pTdbState->pOwner);
|
||||
taosMemoryFreeClear(pInfo->pState->pTdbState);
|
||||
}
|
||||
|
@ -548,7 +548,8 @@ void reloadFromDownStream(SOperatorInfo* downstream, SStreamIntervalOperatorInfo
|
|||
|
||||
bool hasSrcPrimaryKeyCol(SSteamOpBasicInfo* pInfo) { return pInfo->primaryPkIndex != -1; }
|
||||
|
||||
int32_t initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SStreamIntervalOperatorInfo* pInfo, struct SSteamOpBasicInfo* pBasic) {
|
||||
int32_t initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SStreamIntervalOperatorInfo* pInfo,
|
||||
struct SSteamOpBasicInfo* pBasic) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SStateStore* pAPI = &downstream->pTaskInfo->storageAPI.stateStore;
|
||||
|
@ -1028,7 +1029,7 @@ static int32_t getNextQualifiedFinalWindow(SInterval* pInterval, STimeWindow* pN
|
|||
}
|
||||
|
||||
static int32_t doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, uint64_t groupId,
|
||||
SSHashObj* pUpdatedMap, SSHashObj* pDeletedMap) {
|
||||
SSHashObj* pUpdatedMap, SSHashObj* pDeletedMap) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperator->info;
|
||||
|
@ -1661,7 +1662,7 @@ static int32_t doStreamFinalIntervalAggNext(SOperatorInfo* pOperator, SSDataBloc
|
|||
pInfo->binfo.pRes->info.type = pBlock->info.type;
|
||||
} else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT ||
|
||||
pBlock->info.type == STREAM_CLEAR) {
|
||||
SArray* delWins = taosArrayInit(8, sizeof(SWinKey));
|
||||
SArray* delWins = taosArrayInit(8, sizeof(SWinKey));
|
||||
QUERY_CHECK_NULL(delWins, code, lino, _end, terrno);
|
||||
SHashObj* finalMap = IS_FINAL_INTERVAL_OP(pOperator) ? pInfo->pFinalPullDataMap : NULL;
|
||||
code = doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap, finalMap);
|
||||
|
@ -1897,9 +1898,8 @@ _end:
|
|||
}
|
||||
}
|
||||
|
||||
int32_t createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode,
|
||||
SExecTaskInfo* pTaskInfo, int32_t numOfChild,
|
||||
SReadHandle* pHandle, SOperatorInfo** pOptrInfo) {
|
||||
int32_t createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo,
|
||||
int32_t numOfChild, SReadHandle* pHandle, SOperatorInfo** pOptrInfo) {
|
||||
QRY_PARAM_CHECK(pOptrInfo);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -1959,8 +1959,8 @@ int32_t createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiN
|
|||
|
||||
pAPI->stateStore.streamStateSetNumber(pInfo->pState, -1, pInfo->primaryTsIndex);
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = NULL;
|
||||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = NULL;
|
||||
code = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &pExprInfo, &numOfCols);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
|
@ -2042,11 +2042,13 @@ int32_t createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiN
|
|||
pOperator->info = pInfo;
|
||||
|
||||
if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL) {
|
||||
pOperator->fpSet = createOperatorFpSet(NULL, doStreamMidIntervalAggNext, NULL, destroyStreamFinalIntervalOperatorInfo,
|
||||
optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(NULL, doStreamMidIntervalAggNext, NULL, destroyStreamFinalIntervalOperatorInfo,
|
||||
optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
||||
} else {
|
||||
pOperator->fpSet = createOperatorFpSet(NULL, doStreamFinalIntervalAggNext, NULL, destroyStreamFinalIntervalOperatorInfo,
|
||||
optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(NULL, doStreamFinalIntervalAggNext, NULL, destroyStreamFinalIntervalOperatorInfo,
|
||||
optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
||||
}
|
||||
setOperatorStreamStateFn(pOperator, streamIntervalReleaseState, streamIntervalReloadState);
|
||||
if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL ||
|
||||
|
@ -2220,10 +2222,10 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, SExprSupp* pExpSup, in
|
|||
*(pSup->pState) = *pState;
|
||||
pSup->stateStore.streamStateSetNumber(pSup->pState, -1, tsIndex);
|
||||
int32_t funResSize = getMaxFunResSize(pExpSup, numOfOutput);
|
||||
pSup->pState->pFileState = NULL;
|
||||
code = pSup->stateStore.streamFileStateInit(
|
||||
tsStreamBufferSize, sizeof(SSessionKey), pSup->resultRowSize, funResSize, sesionTs, pSup->pState,
|
||||
pTwAggSup->deleteMark, taskIdStr, pHandle->checkpointId, STREAM_STATE_BUFF_SORT, &pSup->pState->pFileState);
|
||||
pSup->pState->pFileState = NULL;
|
||||
code = pSup->stateStore.streamFileStateInit(tsStreamBufferSize, sizeof(SSessionKey), pSup->resultRowSize, funResSize,
|
||||
sesionTs, pSup->pState, pTwAggSup->deleteMark, taskIdStr,
|
||||
pHandle->checkpointId, STREAM_STATE_BUFF_SORT, &pSup->pState->pFileState);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||
|
@ -3309,8 +3311,8 @@ int32_t doStreamSessionDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOpe
|
|||
QUERY_CHECK_CONDITION((winCode == TSDB_CODE_SUCCESS), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
|
||||
|
||||
buf = decodeSResultWindowInfo(buf, &winfo, pInfo->streamAggSup.resultRowSize);
|
||||
code =
|
||||
tSimpleHashPut(pInfo->streamAggSup.pResultRows, &winfo.sessionWin, sizeof(SSessionKey), &winfo, sizeof(SResultWindowInfo));
|
||||
code = tSimpleHashPut(pInfo->streamAggSup.pResultRows, &winfo.sessionWin, sizeof(SSessionKey), &winfo,
|
||||
sizeof(SResultWindowInfo));
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
|
@ -3772,8 +3774,8 @@ _end:
|
|||
}
|
||||
}
|
||||
|
||||
int32_t createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode,
|
||||
SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, SOperatorInfo** pOptrInfo) {
|
||||
int32_t createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo,
|
||||
SReadHandle* pHandle, SOperatorInfo** pOptrInfo) {
|
||||
QRY_PARAM_CHECK(pOptrInfo);
|
||||
|
||||
SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode;
|
||||
|
@ -3802,12 +3804,12 @@ int32_t createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode
|
|||
}
|
||||
}
|
||||
SExprSupp* pExpSup = &pOperator->exprSupp;
|
||||
|
||||
|
||||
SSDataBlock* pResBlock = createDataBlockFromDescNode(pPhyNode->pOutputDataBlockDesc);
|
||||
QUERY_CHECK_NULL(pResBlock, code, lino, _error, terrno);
|
||||
pInfo->binfo.pRes = pResBlock;
|
||||
|
||||
SExprInfo* pExprInfo = NULL;
|
||||
SExprInfo* pExprInfo = NULL;
|
||||
code = createExprInfo(pSessionNode->window.pFuncs, NULL, &pExprInfo, &numOfCols);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
|
@ -3886,8 +3888,9 @@ int32_t createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode
|
|||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
}
|
||||
}
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamSessionAggNext, NULL, destroyStreamSessionAggOperatorInfo,
|
||||
optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(optrDummyOpenFn, doStreamSessionAggNext, NULL, destroyStreamSessionAggOperatorInfo,
|
||||
optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
||||
setOperatorStreamStateFn(pOperator, streamSessionReleaseState, streamSessionReloadState);
|
||||
|
||||
if (downstream) {
|
||||
|
@ -4102,8 +4105,8 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
int32_t createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode,
|
||||
SExecTaskInfo* pTaskInfo, int32_t numOfChild,
|
||||
SReadHandle* pHandle, SOperatorInfo** pOptrInfo) {
|
||||
SExecTaskInfo* pTaskInfo, int32_t numOfChild, SReadHandle* pHandle,
|
||||
SOperatorInfo** pOptrInfo) {
|
||||
QRY_PARAM_CHECK(pOptrInfo);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -4111,7 +4114,7 @@ int32_t createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
|||
SOperatorInfo* pOperator = NULL;
|
||||
code = createStreamSessionAggOperatorInfo(downstream, pPhyNode, pTaskInfo, pHandle, &pOperator);
|
||||
if (pOperator == NULL || code != 0) {
|
||||
downstream = NULL;
|
||||
downstream = NULL;
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
}
|
||||
|
||||
|
@ -4618,8 +4621,8 @@ int32_t doStreamStateDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOpera
|
|||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
buf = decodeSResultWindowInfo(buf, &winfo, pInfo->streamAggSup.resultRowSize);
|
||||
code =
|
||||
tSimpleHashPut(pInfo->streamAggSup.pResultRows, &winfo.sessionWin, sizeof(SSessionKey), &winfo, sizeof(SResultWindowInfo));
|
||||
code = tSimpleHashPut(pInfo->streamAggSup.pResultRows, &winfo.sessionWin, sizeof(SSessionKey), &winfo,
|
||||
sizeof(SResultWindowInfo));
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
|
@ -4846,7 +4849,7 @@ void streamStateReleaseState(SOperatorInfo* pOperator) {
|
|||
int32_t resSize = winSize + sizeof(TSKEY);
|
||||
char* pBuff = taosMemoryCalloc(1, resSize);
|
||||
if (!pBuff) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
memcpy(pBuff, pInfo->historyWins->pData, winSize);
|
||||
memcpy(pBuff + winSize, &pInfo->twAggSup.maxTs, sizeof(TSKEY));
|
||||
|
@ -4944,7 +4947,7 @@ void streamStateReloadState(SOperatorInfo* pOperator) {
|
|||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
}
|
||||
taosMemoryFree(pBuf);
|
||||
taosMemoryFreeClear(pBuf);
|
||||
|
||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||
if (downstream->fpSet.reloadStreamStateFn) {
|
||||
|
@ -4953,6 +4956,7 @@ void streamStateReloadState(SOperatorInfo* pOperator) {
|
|||
reloadAggSupFromDownStream(downstream, &pInfo->streamAggSup);
|
||||
|
||||
_end:
|
||||
taosMemoryFreeClear(pBuf);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s. task:%s", __func__, lino, tstrerror(code), GET_TASKID(pTaskInfo));
|
||||
}
|
||||
|
@ -5001,9 +5005,9 @@ int32_t createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode*
|
|||
QUERY_CHECK_NULL(pResBlock, code, lino, _error, terrno);
|
||||
pInfo->binfo.pRes = pResBlock;
|
||||
|
||||
SExprSupp* pExpSup = &pOperator->exprSupp;
|
||||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = NULL;
|
||||
SExprSupp* pExpSup = &pOperator->exprSupp;
|
||||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = NULL;
|
||||
code = createExprInfo(pStateNode->window.pFuncs, NULL, &pExprInfo, &numOfCols);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
|
@ -5335,7 +5339,7 @@ int32_t createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode*
|
|||
*(pInfo->pState) = *(pTaskInfo->streamInfo.pState);
|
||||
pAPI->stateStore.streamStateSetNumber(pInfo->pState, -1, pInfo->primaryTsIndex);
|
||||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
SExprInfo* pExprInfo = NULL;
|
||||
code = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &pExprInfo, &numOfCols);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
@ -5383,7 +5387,8 @@ int32_t createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode*
|
|||
pInfo->pState->pFileState = NULL;
|
||||
code = pTaskInfo->storageAPI.stateStore.streamFileStateInit(
|
||||
tsStreamBufferSize, sizeof(SWinKey), pInfo->aggSup.resultRowSize, funResSize, compareTs, pInfo->pState,
|
||||
pInfo->twAggSup.deleteMark, GET_TASKID(pTaskInfo), pHandle->checkpointId, STREAM_STATE_BUFF_HASH, &pInfo->pState->pFileState);
|
||||
pInfo->twAggSup.deleteMark, GET_TASKID(pTaskInfo), pHandle->checkpointId, STREAM_STATE_BUFF_HASH,
|
||||
&pInfo->pState->pFileState);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
pInfo->pOperator = pOperator;
|
||||
|
@ -5397,7 +5402,7 @@ int32_t createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode*
|
|||
pInfo->recvGetAll = false;
|
||||
|
||||
code = createSpecialDataBlock(STREAM_CHECKPOINT, &pInfo->pCheckpointRes);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||
pInfo->pDeletedMap = tSimpleHashInit(4096, hashFn);
|
||||
|
|
|
@ -22,29 +22,7 @@ extern "C" {
|
|||
|
||||
#include "function.h"
|
||||
#include "functionMgt.h"
|
||||
|
||||
typedef struct SSumRes {
|
||||
union {
|
||||
int64_t isum;
|
||||
uint64_t usum;
|
||||
double dsum;
|
||||
};
|
||||
int16_t type;
|
||||
int64_t prevTs;
|
||||
bool isPrevTsSet;
|
||||
bool overflow; // if overflow is true, dsum to be used for any type;
|
||||
} SSumRes;
|
||||
|
||||
typedef struct SMinmaxResInfo {
|
||||
bool assign; // assign the first value or not
|
||||
int64_t v;
|
||||
char *str;
|
||||
STuplePos tuplePos;
|
||||
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
int16_t type;
|
||||
} SMinmaxResInfo;
|
||||
#include "functionResInfoInt.h"
|
||||
|
||||
int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems);
|
||||
|
||||
|
|
|
@ -0,0 +1,366 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_FUNCTIONRESINFOINT_H
|
||||
#define TDENGINE_FUNCTIONRESINFOINT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "thistogram.h"
|
||||
#include "tdigest.h"
|
||||
#include "functionResInfo.h"
|
||||
#include "tpercentile.h"
|
||||
|
||||
#define USE_ARRAYLIST
|
||||
|
||||
#define HLL_BUCKET_BITS 14 // The bits of the bucket
|
||||
#define HLL_DATA_BITS (64 - HLL_BUCKET_BITS)
|
||||
#define HLL_BUCKETS (1 << HLL_BUCKET_BITS)
|
||||
#define HLL_BUCKET_MASK (HLL_BUCKETS - 1)
|
||||
#define HLL_ALPHA_INF 0.721347520444481703680 // constant for 0.5/ln(2)
|
||||
|
||||
typedef struct SSumRes {
|
||||
union {
|
||||
int64_t isum;
|
||||
uint64_t usum;
|
||||
double dsum;
|
||||
};
|
||||
int16_t type;
|
||||
int64_t prevTs;
|
||||
bool isPrevTsSet;
|
||||
bool overflow; // if overflow is true, dsum to be used for any type;
|
||||
} SSumRes;
|
||||
|
||||
typedef struct SMinmaxResInfo {
|
||||
bool assign; // assign the first value or not
|
||||
int64_t v;
|
||||
char *str;
|
||||
STuplePos tuplePos;
|
||||
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
int16_t type;
|
||||
} SMinmaxResInfo;
|
||||
|
||||
typedef struct SStdRes {
|
||||
double result;
|
||||
int64_t count;
|
||||
union {
|
||||
double quadraticDSum;
|
||||
int64_t quadraticISum;
|
||||
uint64_t quadraticUSum;
|
||||
};
|
||||
union {
|
||||
double dsum;
|
||||
int64_t isum;
|
||||
uint64_t usum;
|
||||
};
|
||||
int16_t type;
|
||||
} SStdRes;
|
||||
|
||||
typedef struct SHistBin {
|
||||
double val;
|
||||
int64_t num;
|
||||
|
||||
#if !defined(USE_ARRAYLIST)
|
||||
double delta;
|
||||
int32_t index; // index in min-heap list
|
||||
#endif
|
||||
} SHistBin;
|
||||
|
||||
typedef struct SHistogramInfo {
|
||||
int64_t numOfElems;
|
||||
int32_t numOfEntries;
|
||||
int32_t maxEntries;
|
||||
double min;
|
||||
double max;
|
||||
#if defined(USE_ARRAYLIST)
|
||||
SHistBin* elems;
|
||||
#else
|
||||
tSkipList* pList;
|
||||
SMultiwayMergeTreeInfo* pLoserTree;
|
||||
int32_t maxIndex;
|
||||
bool ordered;
|
||||
#endif
|
||||
} SHistogramInfo;
|
||||
|
||||
typedef struct SAPercentileInfo {
|
||||
double result;
|
||||
double percent;
|
||||
int8_t algo;
|
||||
SHistogramInfo* pHisto;
|
||||
TDigest* pTDigest;
|
||||
} SAPercentileInfo;
|
||||
|
||||
typedef struct SSpreadInfo {
|
||||
double result;
|
||||
bool hasResult;
|
||||
double min;
|
||||
double max;
|
||||
} SSpreadInfo;
|
||||
|
||||
typedef struct SHLLFuncInfo {
|
||||
uint64_t result;
|
||||
uint64_t totalCount;
|
||||
uint8_t buckets[HLL_BUCKETS];
|
||||
} SHLLInfo;
|
||||
|
||||
typedef struct SGroupKeyInfo {
|
||||
bool hasResult;
|
||||
bool isNull;
|
||||
char data[];
|
||||
} SGroupKeyInfo;
|
||||
|
||||
typedef struct SAvgRes {
|
||||
double result;
|
||||
SSumRes sum;
|
||||
int64_t count;
|
||||
int16_t type; // store the original input type, used in merge function
|
||||
} SAvgRes;
|
||||
|
||||
|
||||
// structs above are used in stream
|
||||
|
||||
#define HISTOGRAM_MAX_BINS_NUM 1000
|
||||
#define MAVG_MAX_POINTS_NUM 1000
|
||||
#define TAIL_MAX_POINTS_NUM 100
|
||||
#define TAIL_MAX_OFFSET 100
|
||||
|
||||
typedef struct STopBotResItem {
|
||||
SVariant v;
|
||||
uint64_t uid; // it is a table uid, used to extract tag data during building of the final result for the tag data
|
||||
STuplePos tuplePos; // tuple data of this chosen row
|
||||
} STopBotResItem;
|
||||
|
||||
typedef struct STopBotRes {
|
||||
int32_t maxSize;
|
||||
int16_t type;
|
||||
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
|
||||
STopBotResItem* pItems;
|
||||
} STopBotRes;
|
||||
|
||||
typedef struct SLeastSQRInfo {
|
||||
double matrix[2][3];
|
||||
double startVal;
|
||||
double stepVal;
|
||||
int64_t num;
|
||||
} SLeastSQRInfo;
|
||||
|
||||
typedef struct MinMaxEntry {
|
||||
union {
|
||||
double dMinVal;
|
||||
// double i64MinVal;
|
||||
uint64_t u64MinVal;
|
||||
};
|
||||
union {
|
||||
double dMaxVal;
|
||||
// double i64MaxVal;
|
||||
int64_t u64MaxVal;
|
||||
};
|
||||
} MinMaxEntry;
|
||||
|
||||
typedef struct {
|
||||
int32_t size;
|
||||
int32_t pageId;
|
||||
SFilePage *data;
|
||||
} SSlotInfo;
|
||||
|
||||
typedef struct tMemBucketSlot {
|
||||
SSlotInfo info;
|
||||
MinMaxEntry range;
|
||||
} tMemBucketSlot;
|
||||
|
||||
struct tMemBucket;
|
||||
typedef int32_t (*__perc_hash_func_t)(struct tMemBucket *pBucket, const void *value, int32_t *index);
|
||||
|
||||
typedef struct tMemBucket {
|
||||
int16_t numOfSlots;
|
||||
int16_t type;
|
||||
int32_t bytes;
|
||||
int32_t total;
|
||||
int32_t elemPerPage; // number of elements for each object
|
||||
int32_t maxCapacity; // maximum allowed number of elements that can be sort directly to get the result
|
||||
int32_t bufPageSize; // disk page size
|
||||
MinMaxEntry range; // value range
|
||||
int32_t times; // count that has been checked for deciding the correct data value buckets.
|
||||
__compar_fn_t comparFn;
|
||||
tMemBucketSlot *pSlots;
|
||||
SDiskbasedBuf *pBuffer;
|
||||
__perc_hash_func_t hashFunc;
|
||||
SHashObj *groupPagesMap; // disk page map for different groups;
|
||||
} tMemBucket;
|
||||
|
||||
typedef struct SPercentileInfo {
|
||||
double result;
|
||||
tMemBucket* pMemBucket;
|
||||
int32_t stage;
|
||||
double minval;
|
||||
double maxval;
|
||||
int64_t numOfElems;
|
||||
} SPercentileInfo;
|
||||
|
||||
typedef struct SDiffInfo {
|
||||
bool hasPrev;
|
||||
bool isFirstRow;
|
||||
int8_t ignoreOption; // replace the ignore with case when
|
||||
union {
|
||||
int64_t i64;
|
||||
double d64;
|
||||
} prev;
|
||||
|
||||
int64_t prevTs;
|
||||
} SDiffInfo;
|
||||
|
||||
typedef struct SElapsedInfo {
|
||||
double result;
|
||||
TSKEY min;
|
||||
TSKEY max;
|
||||
int64_t timeUnit;
|
||||
} SElapsedInfo;
|
||||
|
||||
typedef struct STwaInfo {
|
||||
double dOutput;
|
||||
int64_t numOfElems;
|
||||
SPoint1 p;
|
||||
STimeWindow win;
|
||||
} STwaInfo;
|
||||
|
||||
typedef struct SHistoFuncBin {
|
||||
double lower;
|
||||
double upper;
|
||||
int64_t count;
|
||||
double percentage;
|
||||
} SHistoFuncBin;
|
||||
|
||||
typedef struct SHistoFuncInfo {
|
||||
int32_t numOfBins;
|
||||
int32_t totalCount;
|
||||
bool normalized;
|
||||
SHistoFuncBin bins[];
|
||||
} SHistoFuncInfo;
|
||||
|
||||
typedef struct SStateInfo {
|
||||
union {
|
||||
int64_t count;
|
||||
int64_t durationStart;
|
||||
};
|
||||
int64_t prevTs;
|
||||
bool isPrevTsSet;
|
||||
} SStateInfo;
|
||||
|
||||
typedef struct SMavgInfo {
|
||||
int32_t pos;
|
||||
double sum;
|
||||
int64_t prevTs;
|
||||
bool isPrevTsSet;
|
||||
int32_t numOfPoints;
|
||||
bool pointsMeet;
|
||||
double points[];
|
||||
} SMavgInfo;
|
||||
|
||||
typedef struct SSampleInfo {
|
||||
int32_t samples;
|
||||
int32_t totalPoints;
|
||||
int32_t numSampled;
|
||||
uint8_t colType;
|
||||
uint16_t colBytes;
|
||||
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
|
||||
char* data;
|
||||
STuplePos* tuplePos;
|
||||
} SSampleInfo;
|
||||
|
||||
typedef struct STailItem {
|
||||
int64_t timestamp;
|
||||
bool isNull;
|
||||
char data[];
|
||||
} STailItem;
|
||||
|
||||
typedef struct STailInfo {
|
||||
int32_t numOfPoints;
|
||||
int32_t numAdded;
|
||||
int32_t offset;
|
||||
uint8_t colType;
|
||||
uint16_t colBytes;
|
||||
STailItem** pItems;
|
||||
} STailInfo;
|
||||
|
||||
typedef struct SUniqueItem {
|
||||
int64_t timestamp;
|
||||
bool isNull;
|
||||
char data[];
|
||||
} SUniqueItem;
|
||||
|
||||
typedef struct SUniqueInfo {
|
||||
int32_t numOfPoints;
|
||||
uint8_t colType;
|
||||
uint16_t colBytes;
|
||||
bool hasNull; // null is not hashable, handle separately
|
||||
SHashObj* pHash;
|
||||
char pItems[];
|
||||
} SUniqueInfo;
|
||||
|
||||
typedef struct SModeItem {
|
||||
int64_t count;
|
||||
STuplePos dataPos;
|
||||
STuplePos tuplePos;
|
||||
} SModeItem;
|
||||
|
||||
typedef struct SModeInfo {
|
||||
uint8_t colType;
|
||||
uint16_t colBytes;
|
||||
SHashObj* pHash;
|
||||
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
|
||||
char* buf; // serialize data buffer
|
||||
} SModeInfo;
|
||||
|
||||
typedef struct SDerivInfo {
|
||||
double prevValue; // previous value
|
||||
TSKEY prevTs; // previous timestamp
|
||||
bool ignoreNegative; // ignore the negative value
|
||||
int64_t tsWindow; // time window for derivative
|
||||
bool valueSet; // the value has been set already
|
||||
} SDerivInfo;
|
||||
|
||||
typedef struct SRateInfo {
|
||||
double firstValue;
|
||||
TSKEY firstKey;
|
||||
double lastValue;
|
||||
TSKEY lastKey;
|
||||
int8_t hasResult; // flag to denote has value
|
||||
|
||||
char* firstPk;
|
||||
char* lastPk;
|
||||
int8_t pkType;
|
||||
int32_t pkBytes;
|
||||
char pkData[];
|
||||
} SRateInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TDENGINE_FUNCTIONRESINFOINT_H
|
|
@ -16,6 +16,8 @@
|
|||
#ifndef TDENGINE_HISTOGRAM_H
|
||||
#define TDENGINE_HISTOGRAM_H
|
||||
|
||||
#include "functionResInfoInt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -24,51 +26,28 @@ extern "C" {
|
|||
|
||||
#define MAX_HISTOGRAM_BIN 500
|
||||
|
||||
typedef struct SHistBin {
|
||||
double val;
|
||||
int64_t num;
|
||||
|
||||
#if !defined(USE_ARRAYLIST)
|
||||
double delta;
|
||||
int32_t index; // index in min-heap list
|
||||
#endif
|
||||
} SHistBin;
|
||||
|
||||
typedef struct SHeapEntry {
|
||||
void* pData;
|
||||
double val;
|
||||
} SHeapEntry;
|
||||
|
||||
typedef struct SHistogramInfo {
|
||||
int64_t numOfElems;
|
||||
int32_t numOfEntries;
|
||||
int32_t maxEntries;
|
||||
double min;
|
||||
double max;
|
||||
#if defined(USE_ARRAYLIST)
|
||||
SHistBin* elems;
|
||||
#else
|
||||
tSkipList* pList;
|
||||
SMultiwayMergeTreeInfo* pLoserTree;
|
||||
int32_t maxIndex;
|
||||
bool ordered;
|
||||
#endif
|
||||
} SHistogramInfo;
|
||||
struct SHistogramInfo;
|
||||
struct SHistBin;
|
||||
|
||||
int32_t tHistogramCreate(int32_t numOfEntries, SHistogramInfo** pHisto);
|
||||
SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins);
|
||||
int32_t tHistogramCreate(int32_t numOfEntries, struct SHistogramInfo** pHisto);
|
||||
struct SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins);
|
||||
|
||||
int32_t tHistogramAdd(SHistogramInfo** pHisto, double val);
|
||||
int32_t tHistogramSum(SHistogramInfo* pHisto, double v, int64_t *res);
|
||||
int32_t tHistogramAdd(struct SHistogramInfo** pHisto, double val);
|
||||
int32_t tHistogramSum(struct SHistogramInfo* pHisto, double v, int64_t *res);
|
||||
|
||||
int32_t tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num, double** pVal);
|
||||
int32_t tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2, int32_t numOfEntries,
|
||||
SHistogramInfo** pResHistogram);
|
||||
void tHistogramDestroy(SHistogramInfo** pHisto);
|
||||
int32_t tHistogramUniform(struct SHistogramInfo* pHisto, double* ratio, int32_t num, double** pVal);
|
||||
int32_t tHistogramMerge(struct SHistogramInfo* pHisto1, struct SHistogramInfo* pHisto2, int32_t numOfEntries,
|
||||
struct SHistogramInfo** pResHistogram);
|
||||
void tHistogramDestroy(struct SHistogramInfo** pHisto);
|
||||
|
||||
void tHistogramPrint(SHistogramInfo* pHisto);
|
||||
void tHistogramPrint(struct SHistogramInfo* pHisto);
|
||||
|
||||
int32_t histoBinarySearch(SHistBin* pEntry, int32_t len, double val);
|
||||
int32_t histoBinarySearch(struct SHistBin* pEntry, int32_t len, double val);
|
||||
|
||||
SHeapEntry* tHeapCreate(int32_t numOfEntries);
|
||||
void tHeapSort(SHeapEntry* pEntry, int32_t len);
|
||||
|
|
|
@ -21,59 +21,18 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "tpagedbuf.h"
|
||||
|
||||
typedef struct MinMaxEntry {
|
||||
union {
|
||||
double dMinVal;
|
||||
// double i64MinVal;
|
||||
uint64_t u64MinVal;
|
||||
};
|
||||
union {
|
||||
double dMaxVal;
|
||||
// double i64MaxVal;
|
||||
int64_t u64MaxVal;
|
||||
};
|
||||
} MinMaxEntry;
|
||||
|
||||
typedef struct {
|
||||
int32_t size;
|
||||
int32_t pageId;
|
||||
SFilePage *data;
|
||||
} SSlotInfo;
|
||||
|
||||
typedef struct tMemBucketSlot {
|
||||
SSlotInfo info;
|
||||
MinMaxEntry range;
|
||||
} tMemBucketSlot;
|
||||
#include "functionResInfoInt.h"
|
||||
|
||||
struct tMemBucket;
|
||||
typedef int32_t (*__perc_hash_func_t)(struct tMemBucket *pBucket, const void *value, int32_t *index);
|
||||
|
||||
typedef struct tMemBucket {
|
||||
int16_t numOfSlots;
|
||||
int16_t type;
|
||||
int32_t bytes;
|
||||
int32_t total;
|
||||
int32_t elemPerPage; // number of elements for each object
|
||||
int32_t maxCapacity; // maximum allowed number of elements that can be sort directly to get the result
|
||||
int32_t bufPageSize; // disk page size
|
||||
MinMaxEntry range; // value range
|
||||
int32_t times; // count that has been checked for deciding the correct data value buckets.
|
||||
__compar_fn_t comparFn;
|
||||
tMemBucketSlot *pSlots;
|
||||
SDiskbasedBuf *pBuffer;
|
||||
__perc_hash_func_t hashFunc;
|
||||
SHashObj *groupPagesMap; // disk page map for different groups;
|
||||
} tMemBucket;
|
||||
|
||||
int32_t tMemBucketCreate(int32_t nElemSize, int16_t dataType, double minval, double maxval, bool hasWindowOrGroup,
|
||||
tMemBucket **pBucket);
|
||||
struct tMemBucket **pBucket);
|
||||
|
||||
void tMemBucketDestroy(tMemBucket **pBucket);
|
||||
void tMemBucketDestroy(struct tMemBucket **pBucket);
|
||||
|
||||
int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size);
|
||||
int32_t tMemBucketPut(struct tMemBucket *pBucket, const void *data, size_t size);
|
||||
|
||||
int32_t getPercentile(tMemBucket *pMemBucket, double percent, double *result);
|
||||
int32_t getPercentile(struct tMemBucket *pMemBucket, double percent, double *result);
|
||||
|
||||
#endif // TDENGINE_TPERCENTILE_H
|
||||
|
||||
|
|
|
@ -209,10 +209,10 @@ static int32_t countTrailingSpaces(const SValueNode* pVal, bool isLtrim) {
|
|||
}
|
||||
|
||||
static int32_t addTimezoneParam(SNodeList* pList) {
|
||||
char buf[6] = {0};
|
||||
char buf[TD_TIME_STR_LEN] = {0};
|
||||
time_t t = taosTime(NULL);
|
||||
struct tm tmInfo;
|
||||
if (taosLocalTime(&t, &tmInfo, buf) != NULL) {
|
||||
if (taosLocalTime(&t, &tmInfo, buf, sizeof(buf)) != NULL) {
|
||||
(void)strftime(buf, sizeof(buf), "%z", &tmInfo);
|
||||
}
|
||||
int32_t len = (int32_t)strlen(buf);
|
||||
|
@ -4839,6 +4839,48 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.sprocessFunc = randFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "forecast",
|
||||
.type = FUNCTION_TYPE_FORECAST,
|
||||
.classification = FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC |
|
||||
FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC | FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_PRIMARY_KEY_FUNC,
|
||||
.translateFunc = translateForecast,
|
||||
.getEnvFunc = getSelectivityFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = NULL,
|
||||
.finalizeFunc = NULL,
|
||||
.estimateReturnRowsFunc = forecastEstReturnRows,
|
||||
},
|
||||
{
|
||||
.name = "_frowts",
|
||||
.type = FUNCTION_TYPE_FORECAST_ROWTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_FORECAST_PC_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_flow",
|
||||
.type = FUNCTION_TYPE_FORECAST_LOW,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_FORECAST_PC_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||
.translateFunc = translateForecastConf,
|
||||
.getEnvFunc = getForecastConfEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_fhigh",
|
||||
.type = FUNCTION_TYPE_FORECAST_HIGH,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_FORECAST_PC_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||
.translateFunc = translateForecastConf,
|
||||
.getEnvFunc = getForecastConfEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "builtinsimpl.h"
|
||||
#include "cJSON.h"
|
||||
#include "function.h"
|
||||
#include "functionResInfoInt.h"
|
||||
#include "query.h"
|
||||
#include "querynodes.h"
|
||||
#include "tanal.h"
|
||||
|
@ -27,82 +28,12 @@
|
|||
#include "thistogram.h"
|
||||
#include "tpercentile.h"
|
||||
|
||||
#define HISTOGRAM_MAX_BINS_NUM 1000
|
||||
#define MAVG_MAX_POINTS_NUM 1000
|
||||
#define TAIL_MAX_POINTS_NUM 100
|
||||
#define TAIL_MAX_OFFSET 100
|
||||
|
||||
#define HLL_BUCKET_BITS 14 // The bits of the bucket
|
||||
#define HLL_DATA_BITS (64 - HLL_BUCKET_BITS)
|
||||
#define HLL_BUCKETS (1 << HLL_BUCKET_BITS)
|
||||
#define HLL_BUCKET_MASK (HLL_BUCKETS - 1)
|
||||
#define HLL_ALPHA_INF 0.721347520444481703680 // constant for 0.5/ln(2)
|
||||
|
||||
// typedef struct SMinmaxResInfo {
|
||||
// bool assign; // assign the first value or not
|
||||
// int64_t v;
|
||||
// STuplePos tuplePos;
|
||||
//
|
||||
// STuplePos nullTuplePos;
|
||||
// bool nullTupleSaved;
|
||||
// int16_t type;
|
||||
// } SMinmaxResInfo;
|
||||
|
||||
typedef struct STopBotResItem {
|
||||
SVariant v;
|
||||
uint64_t uid; // it is a table uid, used to extract tag data during building of the final result for the tag data
|
||||
STuplePos tuplePos; // tuple data of this chosen row
|
||||
} STopBotResItem;
|
||||
|
||||
typedef struct STopBotRes {
|
||||
int32_t maxSize;
|
||||
int16_t type;
|
||||
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
|
||||
STopBotResItem* pItems;
|
||||
} STopBotRes;
|
||||
|
||||
typedef struct SStdRes {
|
||||
double result;
|
||||
int64_t count;
|
||||
union {
|
||||
double quadraticDSum;
|
||||
int64_t quadraticISum;
|
||||
uint64_t quadraticUSum;
|
||||
};
|
||||
union {
|
||||
double dsum;
|
||||
int64_t isum;
|
||||
uint64_t usum;
|
||||
};
|
||||
int16_t type;
|
||||
} SStdRes;
|
||||
|
||||
typedef struct SLeastSQRInfo {
|
||||
double matrix[2][3];
|
||||
double startVal;
|
||||
double stepVal;
|
||||
int64_t num;
|
||||
} SLeastSQRInfo;
|
||||
|
||||
typedef struct SPercentileInfo {
|
||||
double result;
|
||||
tMemBucket* pMemBucket;
|
||||
int32_t stage;
|
||||
double minval;
|
||||
double maxval;
|
||||
int64_t numOfElems;
|
||||
} SPercentileInfo;
|
||||
|
||||
typedef struct SAPercentileInfo {
|
||||
double result;
|
||||
double percent;
|
||||
int8_t algo;
|
||||
SHistogramInfo* pHisto;
|
||||
TDigest* pTDigest;
|
||||
} SAPercentileInfo;
|
||||
bool ignoreNegative(int8_t ignoreOption){
|
||||
return (ignoreOption & 0x1) == 0x1;
|
||||
}
|
||||
bool ignoreNull(int8_t ignoreOption){
|
||||
return (ignoreOption & 0x2) == 0x2;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
APERCT_ALGO_UNKNOWN = 0,
|
||||
|
@ -110,76 +41,8 @@ typedef enum {
|
|||
APERCT_ALGO_TDIGEST,
|
||||
} EAPerctAlgoType;
|
||||
|
||||
typedef struct SDiffInfo {
|
||||
bool hasPrev;
|
||||
bool isFirstRow;
|
||||
int8_t ignoreOption; // replace the ignore with case when
|
||||
union {
|
||||
int64_t i64;
|
||||
double d64;
|
||||
} prev;
|
||||
|
||||
int64_t prevTs;
|
||||
} SDiffInfo;
|
||||
|
||||
bool ignoreNegative(int8_t ignoreOption){
|
||||
return (ignoreOption & 0x1) == 0x1;
|
||||
}
|
||||
bool ignoreNull(int8_t ignoreOption){
|
||||
return (ignoreOption & 0x2) == 0x2;
|
||||
}
|
||||
typedef struct SSpreadInfo {
|
||||
double result;
|
||||
bool hasResult;
|
||||
double min;
|
||||
double max;
|
||||
} SSpreadInfo;
|
||||
|
||||
typedef struct SElapsedInfo {
|
||||
double result;
|
||||
TSKEY min;
|
||||
TSKEY max;
|
||||
int64_t timeUnit;
|
||||
} SElapsedInfo;
|
||||
|
||||
typedef struct STwaInfo {
|
||||
double dOutput;
|
||||
int64_t numOfElems;
|
||||
SPoint1 p;
|
||||
STimeWindow win;
|
||||
} STwaInfo;
|
||||
|
||||
typedef struct SHistoFuncBin {
|
||||
double lower;
|
||||
double upper;
|
||||
int64_t count;
|
||||
double percentage;
|
||||
} SHistoFuncBin;
|
||||
|
||||
typedef struct SHistoFuncInfo {
|
||||
int32_t numOfBins;
|
||||
int32_t totalCount;
|
||||
bool normalized;
|
||||
SHistoFuncBin bins[];
|
||||
} SHistoFuncInfo;
|
||||
|
||||
typedef enum { UNKNOWN_BIN = 0, USER_INPUT_BIN, LINEAR_BIN, LOG_BIN } EHistoBinType;
|
||||
|
||||
typedef struct SHLLFuncInfo {
|
||||
uint64_t result;
|
||||
uint64_t totalCount;
|
||||
uint8_t buckets[HLL_BUCKETS];
|
||||
} SHLLInfo;
|
||||
|
||||
typedef struct SStateInfo {
|
||||
union {
|
||||
int64_t count;
|
||||
int64_t durationStart;
|
||||
};
|
||||
int64_t prevTs;
|
||||
bool isPrevTsSet;
|
||||
} SStateInfo;
|
||||
|
||||
typedef enum {
|
||||
STATE_OPER_INVALID = 0,
|
||||
STATE_OPER_LT,
|
||||
|
@ -190,105 +53,6 @@ typedef enum {
|
|||
STATE_OPER_EQ,
|
||||
} EStateOperType;
|
||||
|
||||
typedef struct SMavgInfo {
|
||||
int32_t pos;
|
||||
double sum;
|
||||
int64_t prevTs;
|
||||
bool isPrevTsSet;
|
||||
int32_t numOfPoints;
|
||||
bool pointsMeet;
|
||||
double points[];
|
||||
} SMavgInfo;
|
||||
|
||||
typedef struct SSampleInfo {
|
||||
int32_t samples;
|
||||
int32_t totalPoints;
|
||||
int32_t numSampled;
|
||||
uint8_t colType;
|
||||
uint16_t colBytes;
|
||||
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
|
||||
char* data;
|
||||
STuplePos* tuplePos;
|
||||
} SSampleInfo;
|
||||
|
||||
typedef struct STailItem {
|
||||
int64_t timestamp;
|
||||
bool isNull;
|
||||
char data[];
|
||||
} STailItem;
|
||||
|
||||
typedef struct STailInfo {
|
||||
int32_t numOfPoints;
|
||||
int32_t numAdded;
|
||||
int32_t offset;
|
||||
uint8_t colType;
|
||||
uint16_t colBytes;
|
||||
STailItem** pItems;
|
||||
} STailInfo;
|
||||
|
||||
typedef struct SUniqueItem {
|
||||
int64_t timestamp;
|
||||
bool isNull;
|
||||
char data[];
|
||||
} SUniqueItem;
|
||||
|
||||
typedef struct SUniqueInfo {
|
||||
int32_t numOfPoints;
|
||||
uint8_t colType;
|
||||
uint16_t colBytes;
|
||||
bool hasNull; // null is not hashable, handle separately
|
||||
SHashObj* pHash;
|
||||
char pItems[];
|
||||
} SUniqueInfo;
|
||||
|
||||
typedef struct SModeItem {
|
||||
int64_t count;
|
||||
STuplePos dataPos;
|
||||
STuplePos tuplePos;
|
||||
} SModeItem;
|
||||
|
||||
typedef struct SModeInfo {
|
||||
uint8_t colType;
|
||||
uint16_t colBytes;
|
||||
SHashObj* pHash;
|
||||
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
|
||||
char* buf; // serialize data buffer
|
||||
} SModeInfo;
|
||||
|
||||
typedef struct SDerivInfo {
|
||||
double prevValue; // previous value
|
||||
TSKEY prevTs; // previous timestamp
|
||||
bool ignoreNegative; // ignore the negative value
|
||||
int64_t tsWindow; // time window for derivative
|
||||
bool valueSet; // the value has been set already
|
||||
} SDerivInfo;
|
||||
|
||||
typedef struct SRateInfo {
|
||||
double firstValue;
|
||||
TSKEY firstKey;
|
||||
double lastValue;
|
||||
TSKEY lastKey;
|
||||
int8_t hasResult; // flag to denote has value
|
||||
|
||||
char* firstPk;
|
||||
char* lastPk;
|
||||
int8_t pkType;
|
||||
int32_t pkBytes;
|
||||
char pkData[];
|
||||
} SRateInfo;
|
||||
|
||||
typedef struct SGroupKeyInfo {
|
||||
bool hasResult;
|
||||
bool isNull;
|
||||
char data[];
|
||||
} SGroupKeyInfo;
|
||||
|
||||
#define SET_VAL(_info, numOfElem, res) \
|
||||
do { \
|
||||
if ((numOfElem) <= 0) { \
|
||||
|
@ -1949,11 +1713,11 @@ int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
char buf[LEASTSQUARES_BUFF_LENGTH] = {0};
|
||||
char slopBuf[64] = {0};
|
||||
char interceptBuf[64] = {0};
|
||||
int n = snprintf(slopBuf, 64, "%.6lf", param02);
|
||||
int n = tsnprintf(slopBuf, 64, "%.6lf", param02);
|
||||
if (n > LEASTSQUARES_DOUBLE_ITEM_LENGTH) {
|
||||
(void)snprintf(slopBuf, 64, "%." DOUBLE_PRECISION_DIGITS, param02);
|
||||
}
|
||||
n = snprintf(interceptBuf, 64, "%.6lf", param12);
|
||||
n = tsnprintf(interceptBuf, 64, "%.6lf", param12);
|
||||
if (n > LEASTSQUARES_DOUBLE_ITEM_LENGTH) {
|
||||
(void)snprintf(interceptBuf, 64, "%." DOUBLE_PRECISION_DIGITS, param12);
|
||||
}
|
||||
|
@ -2145,9 +1909,9 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
}
|
||||
|
||||
if (i == pCtx->numOfParams - 1) {
|
||||
len += snprintf(varDataVal(buf) + len, sizeof(buf) - VARSTR_HEADER_SIZE - len, "%.6lf]", ppInfo->result);
|
||||
len += tsnprintf(varDataVal(buf) + len, sizeof(buf) - VARSTR_HEADER_SIZE - len, "%.6lf]", ppInfo->result);
|
||||
} else {
|
||||
len += snprintf(varDataVal(buf) + len, sizeof(buf) - VARSTR_HEADER_SIZE - len, "%.6lf, ", ppInfo->result);
|
||||
len += tsnprintf(varDataVal(buf) + len, sizeof(buf) - VARSTR_HEADER_SIZE - len, "%.6lf, ", ppInfo->result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,13 +92,6 @@
|
|||
out->sum.usum += val; \
|
||||
}
|
||||
|
||||
typedef struct SAvgRes {
|
||||
double result;
|
||||
SSumRes sum;
|
||||
int64_t count;
|
||||
int16_t type; // store the original input type, used in merge function
|
||||
} SAvgRes;
|
||||
|
||||
static void floatVectorSumAVX(const float* plist, int32_t numOfRows, SAvgRes* pRes) {
|
||||
const int32_t bitWidth = 256;
|
||||
|
||||
|
|
|
@ -446,7 +446,8 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod
|
|||
(*pPartialFunc)->hasOriginalFunc = true;
|
||||
(*pPartialFunc)->originalFuncId = pSrcFunc->hasOriginalFunc ? pSrcFunc->originalFuncId : pSrcFunc->funcId;
|
||||
char name[TSDB_FUNC_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_POINTER_PRINT_BYTES + 1] = {0};
|
||||
int32_t len = snprintf(name, sizeof(name), "%s.%p", (*pPartialFunc)->functionName, pSrcFunc);
|
||||
|
||||
int32_t len = tsnprintf(name, sizeof(name), "%s.%p", (*pPartialFunc)->functionName, pSrcFunc);
|
||||
if (taosHashBinary(name, len) < 0) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
|||
|
||||
char udfdPathLdLib[1024] = {0};
|
||||
size_t udfdLdLibPathLen = strlen(tsUdfdLdLibPath);
|
||||
tstrncpy(udfdPathLdLib, tsUdfdLdLibPath, sizeof(udfdPathLdLib) < sizeof(tsUdfdLdLibPath) ? sizeof(udfdPathLdLib) : sizeof(tsUdfdLdLibPath));
|
||||
tstrncpy(udfdPathLdLib, tsUdfdLdLibPath, sizeof(udfdPathLdLib));
|
||||
|
||||
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
||||
tstrncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
||||
|
|
|
@ -368,6 +368,13 @@ static int32_t countWindowNodeCopy(const SCountWindowNode* pSrc, SCountWindowNod
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t anomalyWindowNodeCopy(const SAnomalyWindowNode* pSrc, SAnomalyWindowNode* pDst) {
|
||||
CLONE_NODE_FIELD(pCol);
|
||||
CLONE_NODE_FIELD(pExpr);
|
||||
COPY_CHAR_ARRAY_FIELD(anomalyOpt);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) {
|
||||
CLONE_NODE_FIELD_EX(pCol, SColumnNode*);
|
||||
CLONE_NODE_FIELD_EX(pGap, SValueNode*);
|
||||
|
@ -622,6 +629,8 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p
|
|||
COPY_SCALAR_FIELD(windowAlgo);
|
||||
COPY_SCALAR_FIELD(windowCount);
|
||||
COPY_SCALAR_FIELD(windowSliding);
|
||||
CLONE_NODE_FIELD(pAnomalyExpr);
|
||||
COPY_CHAR_ARRAY_FIELD(anomalyOpt);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -674,6 +683,12 @@ static int32_t logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFunc
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t logicForecastFuncCopy(const SForecastFuncLogicNode* pSrc, SForecastFuncLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t logicGroupCacheCopy(const SGroupCacheLogicNode* pSrc, SGroupCacheLogicNode* pDst) {
|
||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||
COPY_SCALAR_FIELD(grpColsMayBeNull);
|
||||
|
@ -937,6 +952,9 @@ int32_t nodesCloneNode(const SNode* pNode, SNode** ppNode) {
|
|||
case QUERY_NODE_COUNT_WINDOW:
|
||||
code = countWindowNodeCopy((const SCountWindowNode*)pNode, (SCountWindowNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_ANOMALY_WINDOW:
|
||||
code = anomalyWindowNodeCopy((const SAnomalyWindowNode*)pNode, (SAnomalyWindowNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_SESSION_WINDOW:
|
||||
code = sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst);
|
||||
break;
|
||||
|
@ -1021,6 +1039,9 @@ int32_t nodesCloneNode(const SNode* pNode, SNode** ppNode) {
|
|||
case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC:
|
||||
code = logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC:
|
||||
code = logicForecastFuncCopy((const SForecastFuncLogicNode*)pNode, (SForecastFuncLogicNode*)pDst);
|
||||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_GROUP_CACHE:
|
||||
code = logicGroupCacheCopy((const SGroupCacheLogicNode*)pNode, (SGroupCacheLogicNode*)pDst);
|
||||
break;
|
||||
|
|
|
@ -97,6 +97,8 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "WindowOffset";
|
||||
case QUERY_NODE_COUNT_WINDOW:
|
||||
return "CountWindow";
|
||||
case QUERY_NODE_ANOMALY_WINDOW:
|
||||
return "AnomalyWindow";
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return "SetOperator";
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -153,6 +155,12 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "CreateQnodeStmt";
|
||||
case QUERY_NODE_DROP_QNODE_STMT:
|
||||
return "DropQnodeStmt";
|
||||
case QUERY_NODE_CREATE_ANODE_STMT:
|
||||
return "CreateAnodeStmt";
|
||||
case QUERY_NODE_DROP_ANODE_STMT:
|
||||
return "DropAnodeStmt";
|
||||
case QUERY_NODE_UPDATE_ANODE_STMT:
|
||||
return "UpdateAnodeStmt";
|
||||
case QUERY_NODE_CREATE_SNODE_STMT:
|
||||
return "CreateSnodeStmt";
|
||||
case QUERY_NODE_DROP_SNODE_STMT:
|
||||
|
@ -213,6 +221,10 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "ShowModulesStmt";
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
return "ShowQnodesStmt";
|
||||
case QUERY_NODE_SHOW_ANODES_STMT:
|
||||
return "ShowAnodesStmt";
|
||||
case QUERY_NODE_SHOW_ANODES_FULL_STMT:
|
||||
return "ShowAnodesFullStmt";
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
return "ShowSnodesStmt";
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
|
@ -328,6 +340,8 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "LogicIndefRowsFunc";
|
||||
case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC:
|
||||
return "LogicInterpFunc";
|
||||
case QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC:
|
||||
return "LogicForecastFunc";
|
||||
case QUERY_NODE_LOGIC_PLAN_GROUP_CACHE:
|
||||
return "LogicGroupCache";
|
||||
case QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL:
|
||||
|
@ -362,6 +376,10 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "PhysiMergeCountWindow";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT:
|
||||
return "PhysiStreamCountWindow";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY:
|
||||
return "PhysiMergeAnomalyWindow";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_ANOMALY:
|
||||
return "PhysiStreamAnomalyWindow";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
|
||||
return "PhysiProject";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
|
||||
|
@ -413,6 +431,8 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "PhysiIndefRowsFunc";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
|
||||
return "PhysiInterpFunc";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC:
|
||||
return "PhysiForecastFunc";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
return "PhysiDispatch";
|
||||
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
||||
|
@ -1260,6 +1280,30 @@ static int32_t jsonToLogicInterpFuncNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkForecastFuncLogicPlanFuncs = "Funcs";
|
||||
|
||||
static int32_t logicForecastFuncNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SForecastFuncLogicNode* pNode = (const SForecastFuncLogicNode*)pObj;
|
||||
|
||||
int32_t code = logicPlanNodeToJson(pObj, pJson);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkForecastFuncLogicPlanFuncs, pNode->pFuncs);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToLogicForecastFuncNode(const SJson* pJson, void* pObj) {
|
||||
SForecastFuncLogicNode* pNode = (SForecastFuncLogicNode*)pObj;
|
||||
|
||||
int32_t code = jsonToLogicPlanNode(pJson, pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkForecastFuncLogicPlanFuncs, &pNode->pFuncs);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkGroupCacheLogicPlanGrpColsMayBeNull = "GroupColsMayBeNull";
|
||||
static const char* jkGroupCacheLogicPlanGroupByUid = "GroupByUid";
|
||||
static const char* jkGroupCacheLogicPlanGlobalGroup = "GlobalGroup";
|
||||
|
@ -3011,6 +3055,36 @@ static int32_t jsonToPhysiCountWindowNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkAnomalyWindowPhysiPlanAnomalyKey = "AnomalyKey";
|
||||
static const char* jkAnomalyWindowPhysiPlanAnomalyOption = "AnomalyOpt";
|
||||
|
||||
static int32_t physiAnomalyWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SAnomalyWindowPhysiNode* pNode = (const SAnomalyWindowPhysiNode*)pObj;
|
||||
|
||||
int32_t code = physiWindowNodeToJson(pObj, pJson);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkAnomalyWindowPhysiPlanAnomalyKey, nodeToJson, pNode->pAnomalyKey);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddStringToObject(pJson, jkAnomalyWindowPhysiPlanAnomalyOption, pNode->anomalyOpt);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToPhysiAnomalyWindowNode(const SJson* pJson, void* pObj) {
|
||||
SAnomalyWindowPhysiNode* pNode = (SAnomalyWindowPhysiNode*)pObj;
|
||||
|
||||
int32_t code = jsonToPhysiWindowNode(pJson, pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkAnomalyWindowPhysiPlanAnomalyKey, &pNode->pAnomalyKey);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetStringValue(pJson, jkAnomalyWindowPhysiPlanAnomalyOption, pNode->anomalyOpt);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkPartitionPhysiPlanExprs = "Exprs";
|
||||
static const char* jkPartitionPhysiPlanPartitionKeys = "PartitionKeys";
|
||||
static const char* jkPartitionPhysiPlanTargets = "Targets";
|
||||
|
@ -3198,6 +3272,37 @@ static int32_t jsonToPhysiInterpFuncNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkForecastFuncPhysiPlanExprs = "Exprs";
|
||||
static const char* jkForecastFuncPhysiPlanFuncs = "Funcs";
|
||||
|
||||
static int32_t physiForecastFuncNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SForecastFuncPhysiNode* pNode = (const SForecastFuncPhysiNode*)pObj;
|
||||
|
||||
int32_t code = physicPlanNodeToJson(pObj, pJson);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkForecastFuncPhysiPlanExprs, pNode->pExprs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkForecastFuncPhysiPlanFuncs, pNode->pFuncs);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToPhysiForecastFuncNode(const SJson* pJson, void* pObj) {
|
||||
SForecastFuncPhysiNode* pNode = (SForecastFuncPhysiNode*)pObj;
|
||||
|
||||
int32_t code = jsonToPhysicPlanNode(pJson, pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkForecastFuncPhysiPlanExprs, &pNode->pExprs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkForecastFuncPhysiPlanFuncs, &pNode->pFuncs);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkDataSinkInputDataBlockDesc = "InputDataBlockDesc";
|
||||
|
||||
static int32_t physicDataSinkNodeToJson(const void* pObj, SJson* pJson) {
|
||||
|
@ -3953,9 +4058,10 @@ static int32_t datumToJson(const void* pObj, SJson* pJson) {
|
|||
break;
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
// cJSON only support utf-8 encoding. Convert memory content to hex string.
|
||||
char* buf = taosMemoryCalloc(varDataLen(pNode->datum.p) * 2 + 1, sizeof(char));
|
||||
int32_t bufSize = varDataLen(pNode->datum.p) * 2 + 1;
|
||||
char* buf = taosMemoryCalloc(bufSize, sizeof(char));
|
||||
if (!buf) return terrno;
|
||||
code = taosHexEncode(varDataVal(pNode->datum.p), buf, varDataLen(pNode->datum.p));
|
||||
code = taosHexEncode(varDataVal(pNode->datum.p), buf, varDataLen(pNode->datum.p), bufSize);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(buf);
|
||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
|
@ -3971,9 +4077,10 @@ static int32_t datumToJson(const void* pObj, SJson* pJson) {
|
|||
break;
|
||||
case TSDB_DATA_TYPE_JSON: {
|
||||
int32_t len = getJsonValueLen(pNode->datum.p);
|
||||
char* buf = taosMemoryCalloc(len * 2 + 1, sizeof(char));
|
||||
int32_t bufSize = len * 2 + 1;
|
||||
char* buf = taosMemoryCalloc(bufSize, sizeof(char));
|
||||
if (!buf) return terrno;
|
||||
code = taosHexEncode(pNode->datum.p, buf, len);
|
||||
code = taosHexEncode(pNode->datum.p, buf, len, bufSize);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(buf);
|
||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
|
@ -4763,6 +4870,36 @@ static int32_t jsonToCountWindowNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkAnomalyWindowTsPrimaryKey = "AnomalyTsPrimaryKey";
|
||||
static const char* jkAnomalyWindowExpr = "AnomalyWindowExpr";
|
||||
static const char* jkAnomalyWindowOption = "AnomalyWindowOpt";
|
||||
|
||||
static int32_t anomalyWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SAnomalyWindowNode* pNode = (const SAnomalyWindowNode*)pObj;
|
||||
|
||||
int32_t code = tjsonAddObject(pJson, jkAnomalyWindowTsPrimaryKey, nodeToJson, pNode->pCol);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkAnomalyWindowExpr, nodeToJson, pNode->pExpr);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddStringToObject(pJson, jkAnomalyWindowOption, pNode->anomalyOpt);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToAnomalyWindowNode(const SJson* pJson, void* pObj) {
|
||||
SAnomalyWindowNode* pNode = (SAnomalyWindowNode*)pObj;
|
||||
|
||||
int32_t code = jsonToNodeObject(pJson, jkAnomalyWindowTsPrimaryKey, &pNode->pCol);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkAnomalyWindowExpr, (SNode**)&pNode->pExpr);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetStringValue(pJson, jkAnomalyWindowOption, pNode->anomalyOpt);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkIntervalWindowInterval = "Interval";
|
||||
static const char* jkIntervalWindowOffset = "Offset";
|
||||
static const char* jkIntervalWindowSliding = "Sliding";
|
||||
|
@ -6449,6 +6586,39 @@ static int32_t dropQnodeStmtToJson(const void* pObj, SJson* pJson) { return drop
|
|||
|
||||
static int32_t jsonToDropQnodeStmt(const SJson* pJson, void* pObj) { return jsonToDropComponentNodeStmt(pJson, pObj); }
|
||||
|
||||
static const char* jkCreateAnodeStmtUrl = "Url";
|
||||
static const char* jkUpdateDropANodeStmtId = "AnodeId";
|
||||
|
||||
static int32_t createAnodeStmtToJson(const void* pObj, SJson* pJson) {
|
||||
const SCreateAnodeStmt* pNode = (const SCreateAnodeStmt*)pObj;
|
||||
return tjsonAddStringToObject(pJson, jkCreateAnodeStmtUrl, pNode->url);
|
||||
}
|
||||
|
||||
static int32_t jsonToCreateAnodeStmt(const SJson* pJson, void* pObj) {
|
||||
SCreateAnodeStmt* pNode = (SCreateAnodeStmt*)pObj;
|
||||
return tjsonGetStringValue(pJson, jkCreateAnodeStmtUrl, pNode->url);
|
||||
}
|
||||
|
||||
static int32_t updateAnodeStmtToJson(const void* pObj, SJson* pJson) {
|
||||
const SUpdateAnodeStmt* pNode = (const SUpdateAnodeStmt*)pObj;
|
||||
return tjsonAddIntegerToObject(pJson, jkUpdateDropANodeStmtId, pNode->anodeId);
|
||||
}
|
||||
|
||||
static int32_t jsonToUpdateAnodeStmt(const SJson* pJson, void* pObj) {
|
||||
SUpdateAnodeStmt* pNode = (SUpdateAnodeStmt*)pObj;
|
||||
return tjsonGetIntValue(pJson, jkUpdateDropANodeStmtId, &pNode->anodeId);
|
||||
}
|
||||
|
||||
static int32_t dropAnodeStmtToJson(const void* pObj, SJson* pJson) {
|
||||
const SDropAnodeStmt* pNode = (const SDropAnodeStmt*)pObj;
|
||||
return tjsonAddIntegerToObject(pJson, jkUpdateDropANodeStmtId, pNode->anodeId);
|
||||
}
|
||||
|
||||
static int32_t jsonToDropAnodeStmt(const SJson* pJson, void* pObj) {
|
||||
SDropAnodeStmt* pNode = (SDropAnodeStmt*)pObj;
|
||||
return tjsonGetIntValue(pJson, jkUpdateDropANodeStmtId, &pNode->anodeId);
|
||||
}
|
||||
|
||||
static int32_t createSnodeStmtToJson(const void* pObj, SJson* pJson) {
|
||||
return createComponentNodeStmtToJson(pObj, pJson);
|
||||
}
|
||||
|
@ -7014,6 +7184,14 @@ static int32_t showQnodesStmtToJson(const void* pObj, SJson* pJson) { return sho
|
|||
|
||||
static int32_t jsonToShowQnodesStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||
|
||||
static int32_t showAnodesStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
||||
|
||||
static int32_t jsonToShowAnodesStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||
|
||||
static int32_t showAnodesFullStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
||||
|
||||
static int32_t jsonToShowAnodesFullStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||
|
||||
static int32_t showArbGroupsStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); }
|
||||
|
||||
static int32_t jsonToShowArbGroupsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); }
|
||||
|
@ -7550,6 +7728,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
return windowOffsetNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_COUNT_WINDOW:
|
||||
return countWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_ANOMALY_WINDOW:
|
||||
return anomalyWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return setOperatorToJson(pObj, pJson);
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -7602,6 +7782,12 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
return createQnodeStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_DROP_QNODE_STMT:
|
||||
return dropQnodeStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_CREATE_ANODE_STMT:
|
||||
return createAnodeStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_DROP_ANODE_STMT:
|
||||
return dropAnodeStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_UPDATE_ANODE_STMT:
|
||||
return updateAnodeStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_CREATE_SNODE_STMT:
|
||||
return createSnodeStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_DROP_SNODE_STMT:
|
||||
|
@ -7652,6 +7838,10 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
return showMnodesStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
return showQnodesStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_SHOW_ANODES_STMT:
|
||||
return showAnodesStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_SHOW_ANODES_FULL_STMT:
|
||||
return showAnodesFullStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
|
||||
return showArbGroupsStmtToJson(pObj, pJson);
|
||||
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||
|
@ -7741,6 +7931,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
return logicIndefRowsFuncNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC:
|
||||
return logicInterpFuncNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC:
|
||||
return logicForecastFuncNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_LOGIC_PLAN_GROUP_CACHE:
|
||||
return logicGroupCacheNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL:
|
||||
|
@ -7801,6 +7993,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT:
|
||||
return physiCountWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY:
|
||||
return physiAnomalyWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
return physiPartitionNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION:
|
||||
|
@ -7809,6 +8003,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
return physiIndefRowsFuncNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
|
||||
return physiInterpFuncNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC:
|
||||
return physiForecastFuncNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
return physiDispatchNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
||||
|
@ -7900,6 +8096,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
return jsonToWindowOffsetNode(pJson, pObj);
|
||||
case QUERY_NODE_COUNT_WINDOW:
|
||||
return jsonToCountWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_ANOMALY_WINDOW:
|
||||
return jsonToAnomalyWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return jsonToSetOperator(pJson, pObj);
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -8002,6 +8200,10 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
return jsonToShowMnodesStmt(pJson, pObj);
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
return jsonToShowQnodesStmt(pJson, pObj);
|
||||
case QUERY_NODE_SHOW_ANODES_STMT:
|
||||
return jsonToShowAnodesStmt(pJson, pObj);
|
||||
case QUERY_NODE_SHOW_ANODES_FULL_STMT:
|
||||
return jsonToShowAnodesFullStmt(pJson, pObj);
|
||||
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
|
||||
return jsonToShowArbGroupsStmt(pJson, pObj);
|
||||
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||
|
@ -8099,6 +8301,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
return jsonToLogicIndefRowsFuncNode(pJson, pObj);
|
||||
case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC:
|
||||
return jsonToLogicInterpFuncNode(pJson, pObj);
|
||||
case QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC:
|
||||
return jsonToLogicForecastFuncNode(pJson, pObj);
|
||||
case QUERY_NODE_LOGIC_PLAN_GROUP_CACHE:
|
||||
return jsonToLogicGroupCacheNode(pJson, pObj);
|
||||
case QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL:
|
||||
|
@ -8159,6 +8363,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT:
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT:
|
||||
return jsonToPhysiCountWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY:
|
||||
return jsonToPhysiAnomalyWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
return jsonToPhysiPartitionNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION:
|
||||
|
@ -8167,6 +8373,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
return jsonToPhysiIndefRowsFuncNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
|
||||
return jsonToPhysiInterpFuncNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC:
|
||||
return jsonToPhysiForecastFuncNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
return jsonToPhysiDispatchNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT:
|
||||
|
|
|
@ -3539,6 +3539,46 @@ static int32_t msgToPhysiCountWindowNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
enum { PHY_ANOMALY_CODE_WINDOW = 1, PHY_ANOMALY_CODE_KEY, PHY_ANOMALY_CODE_WINDOW_OPTION };
|
||||
|
||||
static int32_t physiAnomalyWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||
const SAnomalyWindowPhysiNode* pNode = (const SAnomalyWindowPhysiNode*)pObj;
|
||||
|
||||
int32_t code = tlvEncodeObj(pEncoder, PHY_ANOMALY_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, PHY_ANOMALY_CODE_KEY, nodeToMsg, pNode->pAnomalyKey);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeCStr(pEncoder, PHY_ANOMALY_CODE_WINDOW_OPTION, pNode->anomalyOpt);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t msgToPhysiAnomalyWindowNode(STlvDecoder* pDecoder, void* pObj) {
|
||||
SAnomalyWindowPhysiNode* pNode = (SAnomalyWindowPhysiNode*)pObj;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
STlv* pTlv = NULL;
|
||||
tlvForEach(pDecoder, pTlv, code) {
|
||||
switch (pTlv->type) {
|
||||
case PHY_ANOMALY_CODE_WINDOW:
|
||||
code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
|
||||
break;
|
||||
case PHY_ANOMALY_CODE_KEY:
|
||||
code = msgToNodeFromTlv(pTlv, (void**)&pNode->pAnomalyKey);
|
||||
break;
|
||||
case PHY_ANOMALY_CODE_WINDOW_OPTION:
|
||||
code = tlvDecodeCStr(pTlv, pNode->anomalyOpt, sizeof(pNode->anomalyOpt));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
enum {
|
||||
PHY_PARTITION_CODE_BASE_NODE = 1,
|
||||
PHY_PARTITION_CODE_EXPR,
|
||||
|
@ -3770,6 +3810,50 @@ static int32_t msgToPhysiInterpFuncNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
enum {
|
||||
PHY_FORECAST_FUNC_CODE_BASE_NODE = 1,
|
||||
PHY_FORECAST_FUNC_CODE_EXPR,
|
||||
PHY_FORECAST_FUNC_CODE_FUNCS,
|
||||
};
|
||||
|
||||
static int32_t physiForecastFuncNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||
const SForecastFuncPhysiNode* pNode = (const SForecastFuncPhysiNode*)pObj;
|
||||
|
||||
int32_t code = tlvEncodeObj(pEncoder, PHY_FORECAST_FUNC_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, PHY_FORECAST_FUNC_CODE_EXPR, nodeListToMsg, pNode->pExprs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, PHY_FORECAST_FUNC_CODE_FUNCS, nodeListToMsg, pNode->pFuncs);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t msgToPhysiForecastFuncNode(STlvDecoder* pDecoder, void* pObj) {
|
||||
SForecastFuncPhysiNode* pNode = (SForecastFuncPhysiNode*)pObj;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
STlv* pTlv = NULL;
|
||||
tlvForEach(pDecoder, pTlv, code) {
|
||||
switch (pTlv->type) {
|
||||
case PHY_FORECAST_FUNC_CODE_BASE_NODE:
|
||||
code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
|
||||
break;
|
||||
case PHY_FORECAST_FUNC_CODE_EXPR:
|
||||
code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
|
||||
break;
|
||||
case PHY_FORECAST_FUNC_CODE_FUNCS:
|
||||
code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFuncs);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
enum { PHY_DATA_SINK_CODE_INPUT_DESC = 1 };
|
||||
|
||||
static int32_t physicDataSinkNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||
|
@ -4536,6 +4620,9 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
|||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT:
|
||||
code = physiCountWindowNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY:
|
||||
code = physiAnomalyWindowNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
code = physiPartitionNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
|
@ -4548,6 +4635,9 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
|||
case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
|
||||
code = physiInterpFuncNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC:
|
||||
code = physiForecastFuncNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
code = physiDispatchNodeToMsg(pObj, pEncoder);
|
||||
break;
|
||||
|
@ -4698,6 +4788,9 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT:
|
||||
code = msgToPhysiCountWindowNode(pDecoder, pObj);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY:
|
||||
code = msgToPhysiAnomalyWindowNode(pDecoder, pObj);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
code = msgToPhysiPartitionNode(pDecoder, pObj);
|
||||
break;
|
||||
|
@ -4710,6 +4803,9 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
|
||||
code = msgToPhysiInterpFuncNode(pDecoder, pObj);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC:
|
||||
code = msgToPhysiForecastFuncNode(pDecoder, pObj);
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
code = msgToPhysiDispatchNode(pDecoder, pObj);
|
||||
break;
|
||||
|
|
|
@ -110,19 +110,19 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
|||
case QUERY_NODE_COLUMN: {
|
||||
SColumnNode *colNode = (SColumnNode *)pNode;
|
||||
if (colNode->dbName[0]) {
|
||||
*len += snprintf(buf + *len, bufSize - *len, "`%s`.", colNode->dbName);
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "`%s`.", colNode->dbName);
|
||||
}
|
||||
|
||||
if (colNode->tableAlias[0]) {
|
||||
*len += snprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableAlias);
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableAlias);
|
||||
} else if (colNode->tableName[0]) {
|
||||
*len += snprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableName);
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableName);
|
||||
}
|
||||
|
||||
if (colNode->tableAlias[0]) {
|
||||
*len += snprintf(buf + *len, bufSize - *len, "`%s`", colNode->node.userAlias);
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "`%s`", colNode->node.userAlias);
|
||||
} else {
|
||||
*len += snprintf(buf + *len, bufSize - *len, "%s", colNode->node.userAlias);
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "%s", colNode->node.userAlias);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -137,9 +137,9 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
|||
|
||||
int32_t tlen = strlen(t);
|
||||
if (tlen > 32) {
|
||||
*len += snprintf(buf + *len, bufSize - *len, "%.*s...%s", 32, t, t + tlen - 1);
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "%.*s...%s", 32, t, t + tlen - 1);
|
||||
} else {
|
||||
*len += snprintf(buf + *len, bufSize - *len, "%s", t);
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "%s", t);
|
||||
}
|
||||
taosMemoryFree(t);
|
||||
|
||||
|
@ -147,18 +147,18 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
|||
}
|
||||
case QUERY_NODE_OPERATOR: {
|
||||
SOperatorNode *pOpNode = (SOperatorNode *)pNode;
|
||||
*len += snprintf(buf + *len, bufSize - *len, "(");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "(");
|
||||
if (pOpNode->pLeft) {
|
||||
NODES_ERR_RET(nodesNodeToSQL(pOpNode->pLeft, buf, bufSize, len));
|
||||
}
|
||||
|
||||
*len += snprintf(buf + *len, bufSize - *len, " %s ", operatorTypeStr(pOpNode->opType));
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, " %s ", operatorTypeStr(pOpNode->opType));
|
||||
|
||||
if (pOpNode->pRight) {
|
||||
NODES_ERR_RET(nodesNodeToSQL(pOpNode->pRight, buf, bufSize, len));
|
||||
}
|
||||
|
||||
*len += snprintf(buf + *len, bufSize - *len, ")");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, ")");
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -167,17 +167,17 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
|||
SNode *node = NULL;
|
||||
bool first = true;
|
||||
|
||||
*len += snprintf(buf + *len, bufSize - *len, "(");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "(");
|
||||
|
||||
FOREACH(node, pLogicNode->pParameterList) {
|
||||
if (!first) {
|
||||
*len += snprintf(buf + *len, bufSize - *len, " %s ", logicConditionTypeStr(pLogicNode->condType));
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, " %s ", logicConditionTypeStr(pLogicNode->condType));
|
||||
}
|
||||
NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len));
|
||||
first = false;
|
||||
}
|
||||
|
||||
*len += snprintf(buf + *len, bufSize - *len, ")");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, ")");
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -186,17 +186,17 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
|||
SNode *node = NULL;
|
||||
bool first = true;
|
||||
|
||||
*len += snprintf(buf + *len, bufSize - *len, "%s(", pFuncNode->functionName);
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "%s(", pFuncNode->functionName);
|
||||
|
||||
FOREACH(node, pFuncNode->pParameterList) {
|
||||
if (!first) {
|
||||
*len += snprintf(buf + *len, bufSize - *len, ", ");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, ", ");
|
||||
}
|
||||
NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len));
|
||||
first = false;
|
||||
}
|
||||
|
||||
*len += snprintf(buf + *len, bufSize - *len, ")");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, ")");
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -206,13 +206,13 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
|||
bool first = true;
|
||||
int32_t num = 0;
|
||||
|
||||
*len += snprintf(buf + *len, bufSize - *len, "(");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "(");
|
||||
|
||||
FOREACH(node, pListNode->pNodeList) {
|
||||
if (!first) {
|
||||
*len += snprintf(buf + *len, bufSize - *len, ", ");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, ", ");
|
||||
if (++num >= 10) {
|
||||
*len += snprintf(buf + *len, bufSize - *len, "...");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, "...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
|||
first = false;
|
||||
}
|
||||
|
||||
*len += snprintf(buf + *len, bufSize - *len, ")");
|
||||
*len += tsnprintf(buf + *len, bufSize - *len, ")");
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -181,6 +181,14 @@ static EDealRes dispatchExpr(SNode* pNode, ETraversalOrder order, FNodeWalker wa
|
|||
res = walkExpr(pEvent->pCol, order, walker, pContext);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_ANOMALY_WINDOW: {
|
||||
SAnomalyWindowNode* pAnomaly = (SAnomalyWindowNode*)pNode;
|
||||
res = walkExpr(pAnomaly->pExpr, order, walker, pContext);
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = walkExpr(pAnomaly->pCol, order, walker, pContext);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -392,6 +400,14 @@ static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
|
|||
res = rewriteExpr(&pEvent->pCol, order, rewriter, pContext);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_ANOMALY_WINDOW: {
|
||||
SAnomalyWindowNode* pAnomaly = (SAnomalyWindowNode*)pNode;
|
||||
res = rewriteExpr(&pAnomaly->pExpr, order, rewriter, pContext);
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = rewriteExpr(&pAnomaly->pCol, order, rewriter, pContext);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -419,6 +419,8 @@ int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut) {
|
|||
code = makeNode(type, sizeof(SEventWindowNode), &pNode); break;
|
||||
case QUERY_NODE_COUNT_WINDOW:
|
||||
code = makeNode(type, sizeof(SCountWindowNode), &pNode); break;
|
||||
case QUERY_NODE_ANOMALY_WINDOW:
|
||||
code = makeNode(type, sizeof(SAnomalyWindowNode), &pNode); break;
|
||||
case QUERY_NODE_HINT:
|
||||
code = makeNode(type, sizeof(SHintNode), &pNode); break;
|
||||
case QUERY_NODE_VIEW:
|
||||
|
@ -474,6 +476,12 @@ int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut) {
|
|||
code = makeNode(type, sizeof(SDropDnodeStmt), &pNode); break;
|
||||
case QUERY_NODE_ALTER_DNODE_STMT:
|
||||
code = makeNode(type, sizeof(SAlterDnodeStmt), &pNode); break;
|
||||
case QUERY_NODE_CREATE_ANODE_STMT:
|
||||
code = makeNode(type, sizeof(SCreateAnodeStmt), &pNode); break;
|
||||
case QUERY_NODE_DROP_ANODE_STMT:
|
||||
code = makeNode(type, sizeof(SDropAnodeStmt), &pNode); break;
|
||||
case QUERY_NODE_UPDATE_ANODE_STMT:
|
||||
code = makeNode(type, sizeof(SUpdateAnodeStmt), &pNode); break;
|
||||
case QUERY_NODE_CREATE_INDEX_STMT:
|
||||
code = makeNode(type, sizeof(SCreateIndexStmt), &pNode); break;
|
||||
case QUERY_NODE_DROP_INDEX_STMT:
|
||||
|
@ -540,6 +548,8 @@ int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut) {
|
|||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
case QUERY_NODE_SHOW_ANODES_STMT:
|
||||
case QUERY_NODE_SHOW_ANODES_FULL_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
|
||||
|
@ -647,6 +657,8 @@ int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut) {
|
|||
code = makeNode(type, sizeof(SIndefRowsFuncLogicNode), &pNode); break;
|
||||
case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC:
|
||||
code = makeNode(type, sizeof(SInterpFuncLogicNode), &pNode); break;
|
||||
case QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC:
|
||||
code = makeNode(type, sizeof(SForecastFuncLogicNode), &pNode); break;
|
||||
case QUERY_NODE_LOGIC_PLAN_GROUP_CACHE:
|
||||
code = makeNode(type, sizeof(SGroupCacheLogicNode), &pNode); break;
|
||||
case QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL:
|
||||
|
@ -722,6 +734,8 @@ int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut) {
|
|||
code = makeNode(type, sizeof(SStreamEventWinodwPhysiNode), &pNode); break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT:
|
||||
code = makeNode(type, sizeof(SCountWinodwPhysiNode), &pNode); break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY:
|
||||
code = makeNode(type, sizeof(SAnomalyWindowPhysiNode), &pNode); break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT:
|
||||
code = makeNode(type, sizeof(SStreamCountWinodwPhysiNode), &pNode); break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||
|
@ -732,6 +746,8 @@ int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut) {
|
|||
code = makeNode(type, sizeof(SIndefRowsFuncPhysiNode), &pNode); break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
|
||||
code = makeNode(type, sizeof(SInterpFuncLogicNode), &pNode); break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC:
|
||||
code = makeNode(type, sizeof(SForecastFuncLogicNode), &pNode); break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
code = makeNode(type, sizeof(SDataDispatcherNode), &pNode); break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
||||
|
@ -1019,6 +1035,11 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
nodesDestroyNode(pEvent->pCol);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_ANOMALY_WINDOW: {
|
||||
SAnomalyWindowNode* pAnomaly = (SAnomalyWindowNode*)pNode;
|
||||
nodesDestroyNode(pAnomaly->pCol);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_HINT: {
|
||||
SHintNode* pHint = (SHintNode*)pNode;
|
||||
destroyHintValue(pHint->option, pHint->value);
|
||||
|
@ -1167,6 +1188,9 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
case QUERY_NODE_CREATE_DNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_DROP_DNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_ALTER_DNODE_STMT: // no pointer field
|
||||
case QUERY_NODE_CREATE_ANODE_STMT: // no pointer field
|
||||
case QUERY_NODE_UPDATE_ANODE_STMT: // no pointer field
|
||||
case QUERY_NODE_DROP_ANODE_STMT: // no pointer field
|
||||
break;
|
||||
case QUERY_NODE_CREATE_INDEX_STMT: {
|
||||
SCreateIndexStmt* pStmt = (SCreateIndexStmt*)pNode;
|
||||
|
@ -1252,6 +1276,8 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
case QUERY_NODE_SHOW_ANODES_STMT:
|
||||
case QUERY_NODE_SHOW_ANODES_FULL_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
|
||||
|
@ -1500,6 +1526,12 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
nodesDestroyNode(pLogicNode->pTimeSeries);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_LOGIC_PLAN_FORECAST_FUNC: {
|
||||
SForecastFuncLogicNode* pLogicNode = (SForecastFuncLogicNode*)pNode;
|
||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||
nodesDestroyList(pLogicNode->pFuncs);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_LOGIC_PLAN_GROUP_CACHE: {
|
||||
SGroupCacheLogicNode* pLogicNode = (SGroupCacheLogicNode*)pNode;
|
||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||
|
@ -1663,6 +1695,11 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
destroyWinodwPhysiNode((SWindowPhysiNode*)pPhyNode);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_MERGE_ANOMALY: {
|
||||
SAnomalyWindowPhysiNode* pPhyNode = (SAnomalyWindowPhysiNode*)pNode;
|
||||
destroyWinodwPhysiNode((SWindowPhysiNode*)pPhyNode);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_PARTITION: {
|
||||
destroyPartitionPhysiNode((SPartitionPhysiNode*)pNode);
|
||||
break;
|
||||
|
@ -1690,6 +1727,13 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
nodesDestroyNode(pPhyNode->pTimeSeries);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_FORECAST_FUNC: {
|
||||
SForecastFuncPhysiNode* pPhyNode = (SForecastFuncPhysiNode*)pNode;
|
||||
destroyPhysiNode((SPhysiNode*)pPhyNode);
|
||||
nodesDestroyList(pPhyNode->pExprs);
|
||||
nodesDestroyList(pPhyNode->pFuncs);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||
destroyDataSinkNode((SDataSinkNode*)pNode);
|
||||
break;
|
||||
|
@ -2265,9 +2309,9 @@ static EDealRes doCollect(SCollectColumnsCxt* pCxt, SColumnNode* pCol, SNode* pN
|
|||
char name[TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN];
|
||||
int32_t len = 0;
|
||||
if ('\0' == pCol->tableAlias[0]) {
|
||||
len = snprintf(name, sizeof(name), "%s", pCol->colName);
|
||||
len = tsnprintf(name, sizeof(name), "%s", pCol->colName);
|
||||
} else {
|
||||
len = snprintf(name, sizeof(name), "%s.%s", pCol->tableAlias, pCol->colName);
|
||||
len = tsnprintf(name, sizeof(name), "%s.%s", pCol->tableAlias, pCol->colName);
|
||||
}
|
||||
if (pCol->projRefIdx > 0) {
|
||||
len = taosHashBinary(name, strlen(name));
|
||||
|
|
|
@ -157,6 +157,12 @@ with_clause_opt(A) ::= WITH search_condition(B).
|
|||
/************************************************ create encrypt_key *********************************************/
|
||||
cmd ::= CREATE ENCRYPT_KEY NK_STRING(A). { pCxt->pRootNode = createEncryptKeyStmt(pCxt, &A); }
|
||||
|
||||
/************************************************ create drop update anode ***************************************/
|
||||
cmd ::= CREATE ANODE NK_STRING(A). { pCxt->pRootNode = createCreateAnodeStmt(pCxt, &A); }
|
||||
cmd ::= UPDATE ANODE NK_INTEGER(A). { pCxt->pRootNode = createUpdateAnodeStmt(pCxt, &A, false); }
|
||||
cmd ::= UPDATE ALL ANODES. { pCxt->pRootNode = createUpdateAnodeStmt(pCxt, NULL, true); }
|
||||
cmd ::= DROP ANODE NK_INTEGER(A). { pCxt->pRootNode = createDropAnodeStmt(pCxt, &A); }
|
||||
|
||||
/************************************************ create/drop/alter/restore dnode *********************************************/
|
||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
||||
cmd ::= CREATE DNODE dnode_endpoint(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
||||
|
@ -524,6 +530,8 @@ cmd ::= SHOW db_name_cond_opt(A) VGROUPS.
|
|||
cmd ::= SHOW MNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); }
|
||||
//cmd ::= SHOW MODULES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); }
|
||||
cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); }
|
||||
cmd ::= SHOW ANODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ANODES_STMT); }
|
||||
cmd ::= SHOW ANODES FULL. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ANODES_FULL_STMT); }
|
||||
cmd ::= SHOW ARBGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ARBGROUPS_STMT); }
|
||||
cmd ::= SHOW FUNCTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); }
|
||||
cmd ::= SHOW INDEXES FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, B, A, OP_TYPE_EQUAL); }
|
||||
|
@ -1187,6 +1195,9 @@ pseudo_column(A) ::= WDURATION(B).
|
|||
pseudo_column(A) ::= IROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= ISFILLED(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= QTAGS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= FLOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= FHIGH(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
pseudo_column(A) ::= FROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
|
||||
|
||||
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
|
@ -1505,6 +1516,10 @@ twindow_clause_opt(A) ::=
|
|||
COUNT_WINDOW NK_LP NK_INTEGER(B) NK_RP. { A = createCountWindowNode(pCxt, &B, &B); }
|
||||
twindow_clause_opt(A) ::=
|
||||
COUNT_WINDOW NK_LP NK_INTEGER(B) NK_COMMA NK_INTEGER(C) NK_RP. { A = createCountWindowNode(pCxt, &B, &C); }
|
||||
twindow_clause_opt(A) ::=
|
||||
ANOMALY_WINDOW NK_LP expr_or_subquery(B) NK_RP. { A = createAnomalyWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL); }
|
||||
twindow_clause_opt(A) ::=
|
||||
ANOMALY_WINDOW NK_LP expr_or_subquery(B) NK_COMMA NK_STRING(C) NK_RP. { A = createAnomalyWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
||||
|
||||
sliding_opt(A) ::= . { A = NULL; }
|
||||
sliding_opt(A) ::= SLIDING NK_LP interval_sliding_duration_literal(B) NK_RP. { A = releaseRawExprNode(pCxt, B); }
|
||||
|
|
|
@ -555,6 +555,22 @@ static int32_t collectMetaKeyFromShowSnodes(SCollectMetaKeyCxt* pCxt, SShowStmt*
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowAnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
if (pCxt->pParseCxt->enableSysInfo) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ANODES,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowAnodesFull(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
if (pCxt->pParseCxt->enableSysInfo) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ANODES_FULL,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowBnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
if (pCxt->pParseCxt->enableSysInfo) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_BNODES,
|
||||
|
@ -983,6 +999,10 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
|
|||
return collectMetaKeyFromShowQnodes(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
return collectMetaKeyFromShowSnodes(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_ANODES_STMT:
|
||||
return collectMetaKeyFromShowAnodes(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_ANODES_FULL_STMT:
|
||||
return collectMetaKeyFromShowAnodesFull(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
return collectMetaKeyFromShowBnodes(pCxt, (SShowStmt*)pStmt);
|
||||
case QUERY_NODE_SHOW_ARBGROUPS_STMT:
|
||||
|
|
|
@ -358,6 +358,8 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
|
|||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
case QUERY_NODE_SHOW_ANODES_STMT:
|
||||
case QUERY_NODE_SHOW_ANODES_FULL_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_CLUSTER_STMT:
|
||||
|
|
|
@ -38,6 +38,9 @@ static SKeyword keywordTable[] = {
|
|||
{"ANALYZE", TK_ANALYZE},
|
||||
{"AND", TK_AND},
|
||||
{"ANTI", TK_ANTI},
|
||||
{"ANODE", TK_ANODE},
|
||||
{"ANODES", TK_ANODES},
|
||||
{"ANOMALY_WINDOW", TK_ANOMALY_WINDOW},
|
||||
// {"ANY", TK_ANY},
|
||||
{"APPS", TK_APPS},
|
||||
{"AS", TK_AS},
|
||||
|
@ -332,6 +335,9 @@ static SKeyword keywordTable[] = {
|
|||
{"_WDURATION", TK_WDURATION},
|
||||
{"_WEND", TK_WEND},
|
||||
{"_WSTART", TK_WSTART},
|
||||
{"_FLOW", TK_FLOW},
|
||||
{"_FHIGH", TK_FHIGH},
|
||||
{"_FROWTS", TK_FROWTS},
|
||||
{"ALIVE", TK_ALIVE},
|
||||
{"VARBINARY", TK_VARBINARY},
|
||||
{"S3_CHUNKSIZE", TK_S3_CHUNKSIZE},
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "parUtil.h"
|
||||
#include "scalar.h"
|
||||
#include "systable.h"
|
||||
#include "tanal.h"
|
||||
#include "tcol.h"
|
||||
#include "tglobal.h"
|
||||
#include "ttime.h"
|
||||
|
@ -348,6 +349,20 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
|||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_ANODES_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_ANODES,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_ANODES_FULL_STMT,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_ANODES_FULL,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
|
@ -1035,6 +1050,14 @@ static bool isInterpPseudoColumnFunc(const SNode* pNode) {
|
|||
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsInterpPseudoColumnFunc(((SFunctionNode*)pNode)->funcId));
|
||||
}
|
||||
|
||||
static bool isForecastFunc(const SNode* pNode) {
|
||||
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsForecastFunc(((SFunctionNode*)pNode)->funcId));
|
||||
}
|
||||
|
||||
static bool isForecastPseudoColumnFunc(const SNode* pNode) {
|
||||
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsForecastPseudoColumnFunc(((SFunctionNode*)pNode)->funcId));
|
||||
}
|
||||
|
||||
#ifdef BUILD_NO_CALL
|
||||
static bool isTimelineFunc(const SNode* pNode) {
|
||||
return (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsTimelineFunc(((SFunctionNode*)pNode)->funcId));
|
||||
|
@ -1237,7 +1260,7 @@ bool isPrimaryKeyImpl(SNode* pExpr) {
|
|||
FUNCTION_TYPE_LAST_ROW == pFunc->funcType || FUNCTION_TYPE_TIMETRUNCATE == pFunc->funcType) {
|
||||
return isPrimaryKeyImpl(nodesListGetNode(pFunc->pParameterList, 0));
|
||||
} else if (FUNCTION_TYPE_WSTART == pFunc->funcType || FUNCTION_TYPE_WEND == pFunc->funcType ||
|
||||
FUNCTION_TYPE_IROWTS == pFunc->funcType) {
|
||||
FUNCTION_TYPE_IROWTS == pFunc->funcType || FUNCTION_TYPE_FORECAST_ROWTS == pFunc->funcType) {
|
||||
return true;
|
||||
}
|
||||
} else if (QUERY_NODE_OPERATOR == nodeType(pExpr)) {
|
||||
|
@ -2250,7 +2273,7 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
|||
|
||||
static EDealRes haveVectorFunction(SNode* pNode, void* pContext) {
|
||||
if (isAggFunc(pNode) || isIndefiniteRowsFunc(pNode) || isWindowPseudoColumnFunc(pNode) ||
|
||||
isInterpPseudoColumnFunc(pNode)) {
|
||||
isInterpPseudoColumnFunc(pNode) || isForecastPseudoColumnFunc(pNode)) {
|
||||
*((bool*)pContext) = true;
|
||||
return DEAL_RES_END;
|
||||
}
|
||||
|
@ -2553,6 +2576,72 @@ static int32_t translateInterpPseudoColumnFunc(STranslateContext* pCxt, SNode**
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateForecastFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||
if (!fmIsForecastFunc(pFunc->funcId)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (!isSelectStmt(pCxt->pCurrStmt) || SQL_CLAUSE_SELECT != pCxt->currClause) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
}
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
||||
SNode* pTable = pSelect->pFromTable;
|
||||
|
||||
if (pSelect->hasAggFuncs || pSelect->hasMultiRowsFunc || pSelect->hasIndefiniteRowsFunc) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
}
|
||||
|
||||
if (pSelect->hasForecastFunc &&
|
||||
(FUNC_RETURN_ROWS_INDEFINITE == pSelect->returnRows || pSelect->returnRows != fmGetFuncReturnRows(pFunc))) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
|
||||
"%s ignoring null value options cannot be used when applying to multiple columns",
|
||||
pFunc->functionName);
|
||||
}
|
||||
|
||||
if (NULL != pSelect->pWindow || NULL != pSelect->pGroupByList) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
|
||||
"%s function is not supported in window query or group query", pFunc->functionName);
|
||||
}
|
||||
if (hasInvalidFuncNesting(pFunc->pParameterList)) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AGG_FUNC_NESTING);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateForecastPseudoColumnFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRewriteToColumn) {
|
||||
SFunctionNode* pFunc = (SFunctionNode*)(*ppNode);
|
||||
if (!fmIsForecastPseudoColumnFunc(pFunc->funcId)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (!isSelectStmt(pCxt->pCurrStmt)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
|
||||
"%s must be used in select statements", pFunc->functionName);
|
||||
}
|
||||
if (pCxt->currClause == SQL_CLAUSE_WHERE) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_INTERP_CLAUSE,
|
||||
"%s is not allowed in where clause", pFunc->functionName);
|
||||
}
|
||||
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
||||
SNode* pNode = NULL;
|
||||
bool bFound = false;
|
||||
FOREACH(pNode, pSelect->pProjectionList) {
|
||||
if (nodeType(pNode) == QUERY_NODE_FUNCTION && strcasecmp(((SFunctionNode*)pNode)->functionName, "forecast") == 0) {
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bFound) {
|
||||
*pRewriteToColumn = true;
|
||||
int32_t code = replacePsedudoColumnFuncWithColumn(pCxt, ppNode);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
(void)translateColumn(pCxt, (SColumnNode**)ppNode);
|
||||
return pCxt->errCode;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTimelineFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||
if (!fmIsTimelineFunc(pFunc->funcId)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -2738,6 +2827,8 @@ static void setFuncClassification(STranslateContext* pCxt, SFunctionNode* pFunc)
|
|||
pSelect->returnRows = fmGetFuncReturnRows(pFunc);
|
||||
} else if (fmIsInterpFunc(pFunc->funcId)) {
|
||||
pSelect->returnRows = fmGetFuncReturnRows(pFunc);
|
||||
} else if (fmIsForecastFunc(pFunc->funcId)) {
|
||||
pSelect->returnRows = fmGetFuncReturnRows(pFunc);
|
||||
}
|
||||
if (fmIsProcessByRowFunc(pFunc->funcId)) {
|
||||
pSelect->lastProcessByRowFuncId = pFunc->funcId;
|
||||
|
@ -2755,6 +2846,9 @@ static void setFuncClassification(STranslateContext* pCxt, SFunctionNode* pFunc)
|
|||
pSelect->hasInterpFunc = pSelect->hasInterpFunc ? true : (FUNCTION_TYPE_INTERP == pFunc->funcType);
|
||||
pSelect->hasInterpPseudoColFunc =
|
||||
pSelect->hasInterpPseudoColFunc ? true : fmIsInterpPseudoColumnFunc(pFunc->funcId);
|
||||
pSelect->hasForecastFunc = pSelect->hasForecastFunc ? true : (FUNCTION_TYPE_FORECAST == pFunc->funcType);
|
||||
pSelect->hasForecastPseudoColFunc =
|
||||
pSelect->hasForecastPseudoColFunc ? true : fmIsForecastPseudoColumnFunc(pFunc->funcId);
|
||||
pSelect->hasLastRowFunc = pSelect->hasLastRowFunc ? true : (FUNCTION_TYPE_LAST_ROW == pFunc->funcType);
|
||||
pSelect->hasLastFunc = pSelect->hasLastFunc ? true : (FUNCTION_TYPE_LAST == pFunc->funcType);
|
||||
pSelect->hasTimeLineFunc = pSelect->hasTimeLineFunc ? true : fmIsTimelineFunc(pFunc->funcId);
|
||||
|
@ -2840,7 +2934,7 @@ static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
|
|||
|
||||
static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) {
|
||||
char userConn[TSDB_USER_LEN + 1 + TSDB_FQDN_LEN] = {0}; // format 'user@host'
|
||||
int32_t len = snprintf(userConn, sizeof(userConn), "%s@", pCxt->pParseCxt->pUser);
|
||||
int32_t len = tsnprintf(userConn, sizeof(userConn), "%s@", pCxt->pParseCxt->pUser);
|
||||
if (TSDB_CODE_SUCCESS != taosGetFqdn(userConn + len)) {
|
||||
return terrno;
|
||||
}
|
||||
|
@ -2946,6 +3040,9 @@ static int32_t translateScanPseudoColumnFunc(STranslateContext* pCxt, SNode** pp
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (0 == LIST_LENGTH(pFunc->pParameterList)) {
|
||||
if (pFunc->funcType == FUNCTION_TYPE_FORECAST_LOW || pFunc->funcType == FUNCTION_TYPE_FORECAST_HIGH) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (!isSelectStmt(pCxt->pCurrStmt) || NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TBNAME);
|
||||
}
|
||||
|
@ -3016,6 +3113,16 @@ static int32_t translateNormalFunction(STranslateContext* pCxt, SNode** ppNode)
|
|||
return code;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateForecastFunc(pCxt, pFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
bool bRewriteToColumn = false;
|
||||
code = translateForecastPseudoColumnFunc(pCxt, ppNode, &bRewriteToColumn);
|
||||
if (bRewriteToColumn) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateTimelineFunc(pCxt, pFunc);
|
||||
}
|
||||
|
@ -3759,7 +3866,8 @@ static int32_t resetSelectFuncNumWithoutDup(SSelectStmt* pSelect) {
|
|||
|
||||
static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (NULL != pSelect->pGroupByList || NULL != pSelect->pWindow || isWindowJoinStmt(pSelect) ||
|
||||
(!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc && !pSelect->hasInterpFunc)) {
|
||||
(!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc && !pSelect->hasInterpFunc &&
|
||||
!pSelect->hasForecastFunc)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (!pSelect->onlyHasKeepOrderFunc) {
|
||||
|
@ -3781,8 +3889,8 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
|
|||
}
|
||||
|
||||
static int32_t checkWinJoinAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (!isWindowJoinStmt(pSelect) ||
|
||||
(!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc && !pSelect->hasInterpFunc)) {
|
||||
if (!isWindowJoinStmt(pSelect) || (!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc &&
|
||||
!pSelect->hasInterpFunc && !pSelect->hasForecastFunc)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (!pSelect->onlyHasKeepOrderFunc) {
|
||||
|
@ -4126,7 +4234,7 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo
|
|||
SVgroupInfo vgInfo = {0};
|
||||
bool exists = false;
|
||||
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
|
||||
int32_t len = snprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name,
|
||||
int32_t len = tsnprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name,
|
||||
pRealTable->table.tableName);
|
||||
len = taosCreateMD5Hash(buf, len);
|
||||
strncpy(tsmaTargetTbName.tname, buf, MD5_OUTPUT_LEN);
|
||||
|
@ -4935,18 +5043,18 @@ static int32_t createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr, SNo
|
|||
strcpy(pFunc->node.userAlias, pCol->colName);
|
||||
strcpy(pFunc->node.aliasName, pCol->colName);
|
||||
} else {
|
||||
len = snprintf(buf, sizeof(buf) - 1, "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName);
|
||||
len = tsnprintf(buf, sizeof(buf) - 1, "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName);
|
||||
(void)taosHashBinary(buf, len);
|
||||
strncpy(pFunc->node.aliasName, buf, TSDB_COL_NAME_LEN - 1);
|
||||
len = snprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pCol->colName);
|
||||
len = tsnprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pCol->colName);
|
||||
// note: userAlias could be truncated here
|
||||
strncpy(pFunc->node.userAlias, buf, TSDB_COL_NAME_LEN - 1);
|
||||
}
|
||||
} else {
|
||||
len = snprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pExpr->aliasName);
|
||||
len = tsnprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pExpr->aliasName);
|
||||
(void)taosHashBinary(buf, len);
|
||||
strncpy(pFunc->node.aliasName, buf, TSDB_COL_NAME_LEN - 1);
|
||||
len = snprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pExpr->userAlias);
|
||||
len = tsnprintf(buf, sizeof(buf) - 1, "%s(%s)", pSrcFunc->functionName, pExpr->userAlias);
|
||||
// note: userAlias could be truncated here
|
||||
strncpy(pFunc->node.userAlias, buf, TSDB_COL_NAME_LEN - 1);
|
||||
}
|
||||
|
@ -5795,6 +5903,40 @@ static int32_t translateCountWindow(STranslateContext* pCxt, SSelectStmt* pSelec
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t checkAnomalyExpr(STranslateContext* pCxt, SNode* pNode) {
|
||||
int32_t type = ((SExprNode*)pNode)->resType.type;
|
||||
if (!IS_MATHABLE_TYPE(type)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ANOMALY_WIN_TYPE,
|
||||
"ANOMALY_WINDOW only support mathable column");
|
||||
}
|
||||
|
||||
if (QUERY_NODE_COLUMN == nodeType(pNode) && COLUMN_TYPE_TAG == ((SColumnNode*)pNode)->colType) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ANOMALY_WIN_COL,
|
||||
"ANOMALY_WINDOW not support on tag column");
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateAnomalyWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) &&
|
||||
!isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TIMELINE_QUERY,
|
||||
"ANOMALY_WINDOW requires valid time series input");
|
||||
}
|
||||
|
||||
SAnomalyWindowNode* pAnomaly = (SAnomalyWindowNode*)pSelect->pWindow;
|
||||
int32_t code = checkAnomalyExpr(pCxt, pAnomaly->pExpr);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (!taosAnalGetOptStr(pAnomaly->anomalyOpt, "algo", NULL, 0) != 0) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ANOMALY_WIN_OPT,
|
||||
"ANOMALY_WINDOW option should include algo field");
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateSpecificWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
switch (nodeType(pSelect->pWindow)) {
|
||||
case QUERY_NODE_STATE_WINDOW:
|
||||
|
@ -5807,6 +5949,8 @@ static int32_t translateSpecificWindow(STranslateContext* pCxt, SSelectStmt* pSe
|
|||
return translateEventWindow(pCxt, pSelect);
|
||||
case QUERY_NODE_COUNT_WINDOW:
|
||||
return translateCountWindow(pCxt, pSelect);
|
||||
case QUERY_NODE_ANOMALY_WINDOW:
|
||||
return translateAnomalyWindow(pCxt, pSelect);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -6043,6 +6187,26 @@ static int32_t translateInterp(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateForecast(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (!pSelect->hasForecastFunc) {
|
||||
if (pSelect->hasForecastPseudoColFunc) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
|
||||
"Has Forecast pseudo column(s) but missing forcast function");
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if ((NULL != pSelect->pFromTable) && (QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable))) {
|
||||
SJoinTableNode* pJoinTable = (SJoinTableNode*)pSelect->pFromTable;
|
||||
if (IS_WINDOW_JOIN(pJoinTable->subType)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FORECAST_CLAUSE,
|
||||
"Forecast not supported to be used in WINDOW join");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t removeConstantValueFromList(SNodeList** pList) {
|
||||
SNode* pNode = NULL;
|
||||
WHERE_EACH(pNode, *pList) {
|
||||
|
@ -6402,7 +6566,7 @@ static int32_t replaceToChildTableQuery(STranslateContext* pCxt, SEqCondTbNameTa
|
|||
STableTSMAInfo* pTsma = taosArrayGetP(pRealTable->pTsmas, i);
|
||||
SName tsmaTargetTbName = {0};
|
||||
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
|
||||
int32_t len = snprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name,
|
||||
int32_t len = tsnprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name,
|
||||
pRealTable->table.tableName);
|
||||
len = taosCreateMD5Hash(buf, len);
|
||||
strncpy(tsmaTargetTbName.tname, buf, MD5_OUTPUT_LEN);
|
||||
|
@ -6884,6 +7048,9 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateInterp(pCxt, pSelect);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateForecast(pCxt, pSelect);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = appendTsForImplicitTsFunc(pCxt, pSelect);
|
||||
}
|
||||
|
@ -7895,6 +8062,19 @@ static int32_t fillCmdSql(STranslateContext* pCxt, int16_t msgType, void* pReq)
|
|||
break;
|
||||
}
|
||||
|
||||
case TDMT_MND_CREATE_ANODE: {
|
||||
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SMCreateAnodeReq, pReq);
|
||||
break;
|
||||
}
|
||||
case TDMT_MND_DROP_ANODE: {
|
||||
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SMDropAnodeReq, pReq);
|
||||
break;
|
||||
}
|
||||
case TDMT_MND_UPDATE_ANODE: {
|
||||
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SMUpdateAnodeReq, pReq);
|
||||
break;
|
||||
}
|
||||
|
||||
case TDMT_MND_CREATE_MNODE: {
|
||||
FILL_CMD_SQL(sql, sqlLen, pCmdReq, SMCreateMnodeReq, pReq);
|
||||
break;
|
||||
|
@ -8724,7 +8904,7 @@ static int32_t makeIntervalVal(SRetention* pRetension, int8_t precision, SNode**
|
|||
return code;
|
||||
}
|
||||
char buf[20] = {0};
|
||||
int32_t len = snprintf(buf, sizeof(buf), "%" PRId64 "%c", timeVal, pRetension->freqUnit);
|
||||
int32_t len = tsnprintf(buf, sizeof(buf), "%" PRId64 "%c", timeVal, pRetension->freqUnit);
|
||||
pVal->literal = taosStrndup(buf, len);
|
||||
if (NULL == pVal->literal) {
|
||||
nodesDestroyNode((SNode*)pVal);
|
||||
|
@ -9398,6 +9578,43 @@ static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt)
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateCreateAnode(STranslateContext* pCxt, SCreateAnodeStmt* pStmt) {
|
||||
SMCreateAnodeReq createReq = {0};
|
||||
createReq.urlLen = strlen(pStmt->url) + 1;
|
||||
if (createReq.urlLen > TSDB_ANAL_ANODE_URL_LEN) {
|
||||
return TSDB_CODE_MND_ANODE_TOO_LONG_URL;
|
||||
}
|
||||
|
||||
createReq.url = taosMemoryCalloc(createReq.urlLen, 1);
|
||||
if (createReq.url == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
tstrncpy(createReq.url, pStmt->url, createReq.urlLen);
|
||||
|
||||
int32_t code = buildCmdMsg(pCxt, TDMT_MND_CREATE_ANODE, (FSerializeFunc)tSerializeSMCreateAnodeReq, &createReq);
|
||||
tFreeSMCreateAnodeReq(&createReq);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateDropAnode(STranslateContext* pCxt, SDropAnodeStmt* pStmt) {
|
||||
SMDropAnodeReq dropReq = {0};
|
||||
dropReq.anodeId = pStmt->anodeId;
|
||||
|
||||
int32_t code = buildCmdMsg(pCxt, TDMT_MND_DROP_ANODE, (FSerializeFunc)tSerializeSMDropAnodeReq, &dropReq);
|
||||
tFreeSMDropAnodeReq(&dropReq);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateUpdateAnode(STranslateContext* pCxt, SUpdateAnodeStmt* pStmt) {
|
||||
SMUpdateAnodeReq updateReq = {0};
|
||||
updateReq.anodeId = pStmt->anodeId;
|
||||
|
||||
int32_t code = buildCmdMsg(pCxt, TDMT_MND_UPDATE_ANODE, (FSerializeFunc)tSerializeSMUpdateAnodeReq, &updateReq);
|
||||
tFreeSMUpdateAnodeReq(&updateReq);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* pStmt) {
|
||||
SCreateDnodeReq createReq = {0};
|
||||
strcpy(createReq.fqdn, pStmt->fqdn);
|
||||
|
@ -9820,7 +10037,7 @@ static int32_t translateDropComponentNode(STranslateContext* pCxt, SDropComponen
|
|||
}
|
||||
|
||||
static int32_t checkTopicQuery(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (pSelect->hasAggFuncs || pSelect->hasInterpFunc || pSelect->hasIndefiniteRowsFunc) {
|
||||
if (pSelect->hasAggFuncs || pSelect->hasForecastFunc || pSelect->hasInterpFunc || pSelect->hasIndefiniteRowsFunc) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TOPIC_QUERY);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -10186,7 +10403,8 @@ static int32_t translateKillTransaction(STranslateContext* pCxt, SKillStmt* pStm
|
|||
|
||||
static bool crossTableWithoutAggOper(SSelectStmt* pSelect) {
|
||||
return NULL == pSelect->pWindow && !pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc &&
|
||||
!pSelect->hasInterpFunc && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
||||
!pSelect->hasInterpFunc && !pSelect->hasForecastFunc &&
|
||||
TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType &&
|
||||
!hasTbnameFunction(pSelect->pPartitionByList);
|
||||
}
|
||||
|
||||
|
@ -10603,6 +10821,11 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
|
|||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported Group by");
|
||||
}
|
||||
|
||||
if (NULL == pSelect->pWindow && pSelect->hasAggFuncs) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
|
||||
"Non window query only support scalar function, aggregate function is not allowed");
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -12389,6 +12612,15 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
|||
case QUERY_NODE_ALTER_DNODE_STMT:
|
||||
code = translateAlterDnode(pCxt, (SAlterDnodeStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_ANODE_STMT:
|
||||
code = translateCreateAnode(pCxt, (SCreateAnodeStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_DROP_ANODE_STMT:
|
||||
code = translateDropAnode(pCxt, (SDropAnodeStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_UPDATE_ANODE_STMT:
|
||||
code = translateUpdateAnode(pCxt, (SUpdateAnodeStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_INDEX_STMT:
|
||||
code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode);
|
||||
break;
|
||||
|
@ -15749,6 +15981,8 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
case QUERY_NODE_SHOW_ANODES_STMT:
|
||||
case QUERY_NODE_SHOW_ANODES_FULL_STMT:
|
||||
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
|
|
|
@ -989,13 +989,13 @@ static int32_t reserveTableReqInCacheImpl(const char* pTbFName, int32_t len, SHa
|
|||
|
||||
static int32_t reserveTableReqInCache(int32_t acctId, const char* pDb, const char* pTable, SHashObj** pTables) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
int32_t len = snprintf(fullName, sizeof(fullName), "%d.%s.%s", acctId, pDb, pTable);
|
||||
int32_t len = tsnprintf(fullName, sizeof(fullName), "%d.%s.%s", acctId, pDb, pTable);
|
||||
return reserveTableReqInCacheImpl(fullName, len, pTables);
|
||||
}
|
||||
|
||||
static int32_t reserveTableReqInDbCacheImpl(int32_t acctId, const char* pDb, const char* pTable, SHashObj* pDbs) {
|
||||
SParseTablesMetaReq req = {0};
|
||||
int32_t len = snprintf(req.dbFName, sizeof(req.dbFName), "%d.%s", acctId, pDb);
|
||||
int32_t len = tsnprintf(req.dbFName, sizeof(req.dbFName), "%d.%s", acctId, pDb);
|
||||
int32_t code = reserveTableReqInCache(acctId, pDb, pTable, &req.pTables);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = taosHashPut(pDbs, req.dbFName, len, &req, sizeof(SParseTablesMetaReq));
|
||||
|
@ -1011,7 +1011,7 @@ static int32_t reserveTableReqInDbCache(int32_t acctId, const char* pDb, const c
|
|||
}
|
||||
}
|
||||
char fullName[TSDB_DB_FNAME_LEN];
|
||||
int32_t len = snprintf(fullName, sizeof(fullName), "%d.%s", acctId, pDb);
|
||||
int32_t len = tsnprintf(fullName, sizeof(fullName), "%d.%s", acctId, pDb);
|
||||
SParseTablesMetaReq* pReq = taosHashGet(*pDbs, fullName, len);
|
||||
if (NULL == pReq) {
|
||||
return reserveTableReqInDbCacheImpl(acctId, pDb, pTable, *pDbs);
|
||||
|
@ -1111,7 +1111,7 @@ static int32_t reserveDbReqInCache(int32_t acctId, const char* pDb, SHashObj** p
|
|||
}
|
||||
}
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
int32_t len = snprintf(fullName, sizeof(fullName), "%d.%s", acctId, pDb);
|
||||
int32_t len = tsnprintf(fullName, sizeof(fullName), "%d.%s", acctId, pDb);
|
||||
return taosHashPut(*pDbs, fullName, len, &nullPointer, POINTER_BYTES);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue