Merge remote-tracking branch 'origin/3.0' into feature/3.0_wxy

This commit is contained in:
Xiaoyu Wang 2022-07-29 20:41:39 +08:00
commit 31126d5390
105 changed files with 2282 additions and 2049 deletions

View File

@ -443,7 +443,7 @@ pipeline {
}
}
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
/*catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
timeout(time: 15, unit: 'MINUTES'){
script {
sh '''
@ -455,7 +455,7 @@ pipeline {
'''
}
}
}
}*/
}
}
}

View File

@ -47,15 +47,21 @@ IF(${TD_WINDOWS})
)
option(
BUILD_TEST
"If build unit tests using googletest"
ON
)
BUILD_TEST
"If build unit tests using googletest"
ON
)
option(
TDENGINE_3
"TDengine 3.x"
ON
TDENGINE_3
"TDengine 3.x for taos-tools"
ON
)
option(
BUILD_CRASHDUMP
"If build crashdump on Windows"
ON
)
ELSEIF (TD_DARWIN_64)

View File

@ -0,0 +1,12 @@
# crashdump
ExternalProject_Add(crashdump
GIT_REPOSITORY https://github.com/Arnavion/crashdump.git
GIT_TAG master
SOURCE_DIR "${TD_CONTRIB_DIR}/crashdump"
BINARY_DIR "${TD_CONTRIB_DIR}/crashdump"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

View File

@ -120,6 +120,11 @@ if(${BUILD_WITH_NURAFT})
cat("${TD_SUPPORT_DIR}/nuraft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
endif(${BUILD_WITH_NURAFT})
# crashdump
if(${BUILD_CRASHDUMP})
cat("${TD_SUPPORT_DIR}/crashdump_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
endif(${BUILD_CRASHDUMP})
# addr2line
if(${BUILD_ADDR2LINE})
if(NOT ${TD_WINDOWS})
@ -257,6 +262,16 @@ if(${BUILD_PTHREAD})
target_link_libraries(pthread INTERFACE libpthreadVC3)
endif()
# crashdump
if(${BUILD_CRASHDUMP})
add_executable(dumper "crashdump/dumper/dumper.c")
target_link_libraries(dumper User32.lib dbghelp.lib)
file(READ "crashdump/crasher/crasher.c" CRASHDUMP_CONTENT)
string(REPLACE "main(" "main_crashdump(" CRASHDUMP_CONTENT "${CRASHDUMP_CONTENT}")
file(WRITE "crashdump/crasher/crasher.c" "${CRASHDUMP_CONTENT}")
add_library(crashdump STATIC "crashdump/crasher/crasher.c")
endif()
# iconv
if(${BUILD_WITH_ICONV})
add_library(iconv STATIC iconv/win_iconv.c)

View File

@ -23,7 +23,7 @@ A single line of text is used in OpenTSDB line protocol to represent one row of
- `metric` will be used as the STable name.
- `timestamp` is the timestamp of current row of data. The time precision will be determined automatically based on the length of the timestamp. Second and millisecond time precision are supported.
- `value` is a metric which must be a numeric value, the corresponding column name is "value".
- `value` is a metric which must be a numeric value, the corresponding column name is "_value".
- The last part is the tag set separated by spaces, all tags will be converted to nchar type automatically.
For example:
@ -74,7 +74,7 @@ taos> show STables;
Query OK, 2 row(s) in set (0.002544s)
taos> select tbname, * from `meters.current`;
tbname | ts | value | groupid | location |
tbname | _ts | _value | groupid | location |
==================================================================================================================================
t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LoSangeles |
t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LoSangeles |

View File

@ -91,7 +91,7 @@ taos> show STables;
Query OK, 2 row(s) in set (0.001954s)
taos> select * from `meters.current`;
ts | value | groupid | location |
_ts | _value | groupid | location |
===================================================================================================================
2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco |
2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco |

View File

@ -23,7 +23,7 @@ OpenTSDB 行协议同样采用一行字符串来表示一行数据。OpenTSDB
- metric 将作为超级表名。
- timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度
- value 度量值,必须为一个数值。对应的列名是 “value”。
- value 度量值,必须为一个数值。对应的列名是 “_value”。
- 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 nchar 数据类型;
例如:
@ -74,7 +74,7 @@ taos> show stables;
Query OK, 2 row(s) in set (0.002544s)
taos> select tbname, * from `meters.current`;
tbname | ts | value | groupid | location |
tbname | _ts | _value | groupid | location |
==================================================================================================================================
t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LosAngeles |
t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LosAngeles |

View File

@ -91,7 +91,7 @@ taos> show stables;
Query OK, 2 row(s) in set (0.001954s)
taos> select * from `meters.current`;
ts | value | groupid | location |
_ts | _value | groupid | location |
===================================================================================================================
2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco |
2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco |

View File

@ -1,6 +1,6 @@
---
title: 配置参数
description: 'TDengine 客户端和服务配置列表'
description: "TDengine 客户端和服务配置列表"
---
## 为服务端指定配置文件
@ -21,8 +21,6 @@ taosd -C
TDengine 系统的前台交互客户端应用程序为 taos以及应用驱动它可以与 taosd 共享同一个配置文件 taos.cfg也可以使用单独指定配置文件。运行 taos 时,使用参数-c 指定配置文件目录,如 taos -c /home/cfg表示使用/home/cfg/目录下的 taos.cfg 配置文件中的参数,缺省目录是/etc/taos。更多 taos 的使用方法请见帮助信息 `taos --help`
**2.0.10.0 之后版本支持命令行以下参数显示当前客户端参数的配置**
```bash
taos -C
```
@ -47,19 +45,19 @@ taos --dump-config
### firstEp
| 属性 | 说明 |
| -------- | --------------------------------------------------------------- |
| 适用范围 | 服务端和客户端均适用 |
| 属性 | 说明 |
| -------- | -------------------------------------------------------------- |
| 适用范围 | 服务端和客户端均适用 |
| 含义 | taosd 或者 taos 启动时,主动连接的集群中首个 dnode 的 endpoint |
| 缺省值 | localhost:6030 |
| 缺省值 | localhost:6030 |
### secondEp
| 属性 | 说明 |
| -------- | -------------------------------------------------------------------------------------- |
| 适用范围 | 服务端和客户端均适用 |
| 属性 | 说明 |
| -------- | ------------------------------------------------------------------------------------- |
| 适用范围 | 服务端和客户端均适用 |
| 含义 | taosd 或者 taos 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint |
| 缺省值 | 无 |
| 缺省值 | 无 |
### fqdn
@ -77,7 +75,6 @@ taos --dump-config
| 适用范围 | 仅服务端适用 |
| 含义 | taosd 启动后,对外服务的端口号 |
| 缺省值 | 6030 |
| 补充说明 | RESTful 服务在 2.4.0.0 之前(不含)由 taosd 提供,默认端口为 6041; 在 2.4.0.0 及后续版本由 taosAdapter默认端口为 6041 |
:::note
确保集群中所有主机在端口 6030 上的 TCP 协议能够互通。(详细的端口情况请参见下表)
@ -87,8 +84,8 @@ taos --dump-config
| TCP | 6030 | 客户端与服务端之间通讯,多节点集群的节点间通讯。 | 由配置文件设置 serverPort 决定。 |
| TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 |
| TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 |
| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化2.3.0.1+以上版本)。 |
| UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化2.3.0.1+以上版本)。 |
| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化|
| UDP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化 |
| TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | |
### maxShellConns
@ -104,28 +101,28 @@ taos --dump-config
### monitor
| 属性 | 说明 |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | 服务器内部的系统监控开关。监控主要负责收集物理节点的负载状况,包括 CPU、内存、硬盘、网络带宽的监控记录监控信息将通过 HTTP 协议发送给由 `monitorFqdn``monitorProt` 指定的 TaosKeeper 监控服务 |
| 取值范围 | 0关闭监控服务 1激活监控服务。 |
| 缺省值 | 1 |
| 取值范围 | 0关闭监控服务 1激活监控服务。 |
| 缺省值 | 1 |
### monitorFqdn
| 属性 | 说明 |
| -------- | -------------------------------------------- |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | -------------------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | TaosKeeper 监控服务的 FQDN |
| 缺省值 | 无 |
| 缺省值 | 无 |
### monitorPort
| 属性 | 说明 |
| -------- | -------------------------------------------- |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | --------------------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | TaosKeeper 监控服务的端口号 |
| 缺省值 | 6043 |
| 缺省值 | 6043 |
### monitorInterval
@ -134,10 +131,9 @@ taos --dump-config
| 适用范围 | 仅服务端适用 |
| 含义 | 监控数据库记录系统参数CPU/内存)的时间间隔 |
| 单位 | 秒 |
| 取值范围 | 1-200000 |
| 取值范围 | 1-200000 |
| 缺省值 | 30 |
### telemetryReporting
| 属性 | 说明 |
@ -149,25 +145,43 @@ taos --dump-config
## 查询相关
### queryBufferSize
### queryPolicy
| 属性 | 说明 |
| -------- | ----------------------------- |
| 适用范围 | 仅客户端适用 |
| 含义 | 查询语句的执行策略 |
| 单位 | 无 |
| 缺省值 | 1 |
| 补充说明 | 1: 只使用 vnode不使用 qnode |
2: 没有扫描算子的子任务在 qnode 执行,带扫描算子的子任务在 vnode 执行
3: vnode 只运行扫描算子,其余算子均在 qnode 执行 |
### querySmaOptimize
| 属性 | 说明 |
| -------- | -------------------- |
| 适用范围 | 仅客户端适用 |
| 含义 | sma index 的优化策略 |
| 单位 | 无 |
| 缺省值 | 0 |
| 补充说明 |
0: 表示不使用 sma index永远从原始数据进行查询
1: 表示使用 sma index对符合的语句直接从预计算的结果进行查询 |
| 属性 | 说明 |
| -------- | ------------------------------------------------------------------------------------------------------------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | 为所有并发查询占用保留的内存大小。 |
| 单位 | MB |
| 缺省值 | 无 |
| 补充说明 | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。<br/>2.0.15 以前的版本中,此参数的单位是字节) |
### maxNumOfDistinctRes
| 属性 | 说明 |
| -------- | -------------------------------- |
| -------- | -------------------------------- | --- |
| 适用范围 | 仅服务端适用 |
| 含义 | 允许返回的 distinct 结果最大行数 |
| 取值范围 | 默认值为 10 万,最大值 1 亿 |
| 缺省值 | 10 万 |
| 补充说明 | 2.3 版本新增。 | |
## 区域相关
@ -306,12 +320,12 @@ charset 的有效值是 UTF-8。
### supportVnodes
| 属性 | 说明 |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | dnode 支持的最大 vnode 数目 |
| 取值范围 | 0-4096 |
| 缺省值 | 256 |
| 属性 | 说明 |
| -------- | --------------------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | dnode 支持的最大 vnode 数目 |
| 取值范围 | 0-4096 |
| 缺省值 | 256 |
## 时间相关
@ -366,7 +380,6 @@ charset 的有效值是 UTF-8。
| 单位 | bytes |
| 取值范围 | 0: 对所有查询结果均进行压缩 >0: 查询结果中任意列大小超过该值的消息才进行压缩 -1: 不压缩 |
| 缺省值 | -1 |
| 补充说明 | 2.3.0.0 版本新增。 |
## 日志相关
@ -464,7 +477,7 @@ charset 的有效值是 UTF-8。
| 属性 | 说明 |
| -------- | -------------------- |
| 适用范围 | 服务端和客户端均适用 |
| 含义 | query 模块的日志开关 |
| 含义 | query 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | |
@ -481,7 +494,7 @@ charset 的有效值是 UTF-8。
| 属性 | 说明 |
| -------- | -------------------- |
| 适用范围 | 仅服务端适用 |
| 适用范围 | 仅服务端适用 |
| 含义 | dnode 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | 135 |
@ -490,28 +503,28 @@ charset 的有效值是 UTF-8。
| 属性 | 说明 |
| -------- | -------------------- |
| 适用范围 | 仅服务端适用 |
| 适用范围 | 仅服务端适用 |
| 含义 | vnode 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | |
### mDebugFlag
| 属性 | 说明 |
| -------- | ------------------ |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | -------------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | mnode 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | 135 |
| 取值范围 | 同上 |
| 缺省值 | 135 |
### wDebugFlag
| 属性 | 说明 |
| -------- | -------------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | wal 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | 135 |
| 属性 | 说明 |
| -------- | ------------------ |
| 适用范围 | 仅服务端适用 |
| 含义 | wal 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | 135 |
### sDebugFlag
@ -533,57 +546,86 @@ charset 的有效值是 UTF-8。
### tqDebugFlag
| 属性 | 说明 |
| -------- | ------------------- |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | ----------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | tq 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | |
| 取值范围 | 同上 |
| 缺省值 | |
### fsDebugFlag
| 属性 | 说明 |
| -------- | ------------------- |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | ----------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | fs 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | |
| 取值范围 | 同上 |
| 缺省值 | |
### udfDebugFlag
| 属性 | 说明 |
| -------- | ---------------------- |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | ------------------ |
| 适用范围 | 仅服务端适用 |
| 含义 | UDF 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | |
| 取值范围 | 同上 |
| 缺省值 | |
### smaDebugFlag
| 属性 | 说明 |
| -------- | ---------------------- |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | ------------------ |
| 适用范围 | 仅服务端适用 |
| 含义 | sma 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | |
| 取值范围 | 同上 |
| 缺省值 | |
### idxDebugFlag
| 属性 | 说明 |
| -------- | ---------------------- |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | -------------------- |
| 适用范围 | 仅服务端适用 |
| 含义 | index 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | |
| 取值范围 | 同上 |
| 缺省值 | |
### tdbDebugFlag
| 属性 | 说明 |
| -------- | ---------------------- |
| 适用范围 | 仅服务端适用 |
| 属性 | 说明 |
| -------- | ------------------ |
| 适用范围 | 仅服务端适用 |
| 含义 | tdb 模块的日志开关 |
| 取值范围 | 同上 |
| 缺省值 | |
| 取值范围 | 同上 |
| 缺省值 | |
## Schemaless 相关
### smlChildTableName
| 属性 | 说明 |
| -------- | ------------------------- |
| 适用范围 | 仅客户端适用 |
| 含义 | schemaless 自定义的子表名 |
| 类型 | 字符串 |
| 缺省值 | 无 |
### smlTagName
| 属性 | 说明 |
| -------- | ------------------------------------ |
| 适用范围 | 仅客户端适用 |
| 含义 | schemaless tag 为空时默认的 tag 名字 |
| 类型 | 字符串 |
| 缺省值 | _tag_null |
### smlDataFormat
| 属性 | 说明 |
| -------- | ----------------------------- |
| 适用范围 | 仅客户端适用 |
| 含义 | schemaless 列数据是否顺序一致 |
| 值域 | 0不一致1: 一致 |
| 缺省值 | 1 |
## 其他
@ -596,3 +638,12 @@ charset 的有效值是 UTF-8。
| 取值范围 | 01是 |
| 缺省值 | 1 |
| 补充说明 | 不同的启动方式,生成 core 文件的目录如下1、systemctl start taosd 启动:生成的 core 在根目录下 <br/> 2、手动启动就在 taosd 执行目录下。 |
### udf
| 属性 | 说明 |
| -------- | ------------------ |
| 适用范围 | 仅服务端适用 |
| 含义 | 是否启动 udf 服务 |
| 取值范围 | 0: 不启动1启动 |
| 缺省值 | 1 |

View File

@ -5,7 +5,7 @@ title: 整体架构
## 集群与基本逻辑单元
TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起,就按照分布式高可靠架构进行设计,是支持水平扩展的,这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时,通过节点虚拟化并辅以自动化负载均衡技术TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。
TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起就按照分布式高可靠架构进行设计是支持水平扩展的这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时通过节点虚拟化并辅以负载均衡技术TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。
### 主要逻辑单元
@ -19,45 +19,43 @@ TDengine 分布式架构的逻辑结构图如下:
**物理节点pnode** pnode 是一独立运行、拥有自己的计算、存储和网络能力的计算机,可以是安装有 OS 的物理机、虚拟机或 Docker 容器。物理节点由其配置的 FQDNFully Qualified Domain Name来标识。TDengine 完全依赖 FQDN 来进行网络通讯,如果不了解 FQDN请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。
**数据节点dnode** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点vnode零或者至多一个逻辑的管理节点mnode。dnode 在系统中的唯一标识由实例的 End PointEP决定。EP 是 dnode 所在物理节点的 FQDNFully Qualified Domain Name和系统所配置的网络端口号Port的组合。通过配置不同的端口一个物理节点一台物理机、虚拟机或容器可以运行多个实例或有多个数据节点。
**数据节点dnode** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点vnode零或者至多一个逻辑的管理节点mnode零或者至多一个逻辑的弹性计算节点qnode零或者至多一个逻辑的流计算节点snode。dnode 在系统中的唯一标识由实例的 End PointEP决定。EP 是 dnode 所在物理节点的 FQDNFully Qualified Domain Name和系统所配置的网络端口号Port的组合。通过配置不同的端口一个物理节点一台物理机、虚拟机或容器可以运行多个实例或有多个数据节点。
**虚拟节点vnode** 为更好的支持数据分片、负载均衡防止数据过热或倾斜数据节点被虚拟化成多个虚拟节点vnode图中 V2V3V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。
**虚拟节点vnode** 为更好的支持数据分片、负载均衡防止数据过热或倾斜数据节点被虚拟化成多个虚拟节点vnode图中 V2V3V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一个新 DB 时,系统会创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。
**管理节点mnode** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M。同时管理节点也负责元数据包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个mnode它们自动构建成为一个虚拟管理节点组图中 M0M1M2。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步,任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。
**管理节点mnode** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M。同时管理节点也负责元数据包括用户、数据库、超级表等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个mnode它们自动构建成为一个虚拟管理节点组图中 M1M2M3。mnode 支持多副本,采用 RAFT 一致性协议,保证系统的高可用与高可靠,任何数据更新操作只能在 Leader 上进行。mnode 集群的第一个节点在集群部署时自动完成,其他节点的创建与删除由用户通过 SQL 命令完成。每个 dnode 上至多有一个 mnode由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。
**虚拟节点组VGroup** 不同数据节点上的 vnode 可以组成一个虚拟节点组vgroup来保证系统的高可靠。虚拟节点组内采取 master/slave 的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 IDVGroup ID。如果两个虚拟节点的 VGroup ID 相同说明他们属于同一个组数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的容许只有一个也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用
**弹性计算节点qnode** 一个虚拟的逻辑单元,运行查询计算任务,也包括基于系统表来实现的 show 命令(图中 Q。集群中可配置多个 qnode在整个集群内部共享使用图中 Q1Q2Q3。qnode 不与具体的 DB 绑定,即一个 qnode 可以同时执行多个 DB 的查询任务。每个 dnode 上至多有一个 qnode由所属的数据节点的 EP 来唯一标识。客户端通过与 mnode 交互,获取可用的 qnode 列表,当没有可用的 qnode 时,计算任务在 vnode 中执行
**Taosc** taosc 是 TDengine 给应用提供的驱动程序driver负责处理应用与集群的接口交互提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,为支持全分布式的 RESTful 接口taosc 在 TDengine 集群的每个 dnode 上都有一运行实例。
**流计算节点snode** 一个虚拟的逻辑单元,只运行流计算任务(图中 S。集群中可配置多个 snode在整个集群内部共享使用图中 S1S2S3。snode 不与具体的 stream 绑定,即一个 snode 可以同时执行多个 stream 的计算任务。每个 dnode 上至多有一个 snode由所属的数据节点的 EP 来唯一标识。由 mnode 调度可用的 snode 完成流计算任务,当没有可用的 snode 时,流计算任务在 vnode 中执行。
**虚拟节点组VGroup** 不同数据节点上的 vnode 可以组成一个虚拟节点组vgroup采用 RAFT 一致性协议,保证系统的高可用与高可靠。写操作只能在 leader vnode 上进行,系统采用异步复制的方式将数据同步到 follower vnode这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 IDVGroup ID。如果两个虚拟节点的 VGroup ID 相同说明他们属于同一个组数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的容许只有一个也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。
**Taosc** taosc 是 TDengine 给应用提供的驱动程序driver负责处理应用与集群的接口交互提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言这个模块是在应用所处的物理节点上运行。同时taosc 也可以与 taosAdapter 交互,支持全分布式的 RESTful 接口。
### 节点之间的通讯
**通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP/UDP 进行的。因为考虑到物联网场景,数据写入的包一般不大,因此 TDengine 除采用 TCP 做传输之外,还采用 UDP 方式,因为 UDP 更加高效而且不受连接数的限制。TDengine 实现了自己的超时、重传、确认等机制,以确保 UDP 的可靠传输。对于数据量不到 15K 的数据包,采取 UDP 的方式进行传输,超过 15K 的,或者是查询类的操作,自动采取 TCP 的方式进行传输。同时TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用 TCP 方式进行数据传输。
**通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP 进行的。TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。
**FQDN 配置:**一个数据节点有一个或多个 FQDN可以在系统配置文件 taos.cfg 通过参数“fqdn”进行指定如果没有指定系统将自动获取计算机的 hostname 作为其 FQDN。如果节点没有配置 FQDN可以直接将该节点的配置参数 fqdn 设置为它的 IP 地址。但不建议使用 IP因为 IP 地址可变,一旦变化,将让集群无法正常工作。一个数据节点的 EPEnd Point由 FQDN + Port 组成。采用 FQDN需要保证 DNS 服务正常工作,或者在节点以及应用所在的节点配置好 hosts 文件。另外,这个参数值的长度需要控制在 96 个字符以内。
**端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,对集群内部通讯的端口是 serverPort+5。为支持多线程高效的处理 UDP 数据,每个对内和对外的 UDP 连接,都需要占用 5 个连续的端口。
- 集群内数据节点之间的数据复制操作占用一个 TCP 端口,是 serverPort+10。
- 集群数据节点对外提供 RESTful 服务占用一个 TCP 端口,是 serverPort+11。
- 集群内数据节点与 Arbitrator 节点之间通讯占用一个 TCP 端口,是 serverPort+12。
因此一个数据节点总的端口范围为 serverPort 到 serverPort+12总共 13 个 TCP/UDP 端口。确保集群中所有主机在端口 6030-6042 上的 TCP/UDP 协议能够互通。详细的端口情况请参见 [TDengine 2.0 端口说明](/train-faq/faq#port)
**端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,默认为 6030。
**集群对外连接:**TDengine 集群可以容纳单个、多个甚至几千个数据节点。应用只需要向集群中任何一个数据节点发起连接即可,连接需要提供的网络参数是一数据节点的 End PointFQDN 加配置的端口号)。通过命令行 CLI 启动应用 taos 时,可以通过选项-h 来指定数据节点的 FQDN-P 来指定其配置的端口号,如果端口不配置,将采用 TDengine 的系统配置参数 serverPort。
**集群内部通讯:**各个数据节点之间通过 TCP/UDP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步:
**集群内部通讯:**各个数据节点之间通过 TCP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步:
1. 检查 mnodeEpSet.json 文件是否存在,如果不存在或不能正常打开获得 mnode EP 信息,进入第二步;
1. 检查 dnode.json 文件是否存在,如果不存在或不能正常打开获得 mnode EP 信息,进入第二步;
2. 检查系统配置文件 taos.cfg获取节点配置参数 firstEp、secondEp这两个参数指定的节点可以是不带 mnode 的普通节点,这样的话,节点被连接时会尝试重定向到 mnode 节点),如果不存在或者 taos.cfg 里没有这两个配置参数,或无效,进入第三步;
3. 将自己的 EP 设为 mnode EP并独立运行起来。
获取 mnode EP 列表后,数据节点发起连接,如果连接成功,则成功加入进工作的集群,如果不成功,则尝试 mnode EP 列表中的下一个。如果都尝试了,但连接都仍然失败,则休眠几秒后,再进行尝试。
**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢这是系统自动决定的,无需任何人工干预。原则如下:一个数据节点启动时,会检查自己的 End Point并与获取的 mnode EP List 进行比对,如果在其中,该数据节点认为自己应该启动 mnode 模块,成为 mnode。如果自己的 EP 不在 mnode EP List 里,则不启动 mnode 模块。在系统的运行过程中由于负载均衡、宕机等原因mnode 有可能迁移至新的 dnode但一切都是透明的无需人工干预配置参数的修改是 mnode 自己根据资源做出的决定
**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢在集群部署时,第一个数据节点自动成为管理节点。集群中的其他管理节点的创建与删除,由用户通过 SQL 语句完成
**新数据节点的加入:**系统有了一个数据节点后,就已经成为一个工作的系统。添加新的节点进集群时,有两个步骤,第一步:使用 TDengine CLI 连接到现有工作的数据节点然后用命令“CREATE DNODE”将新的数据节点的 End Point 添加进去;第二步:在新的数据节点的系统配置参数文件 taos.cfg 里,将 firstEpsecondEp 参数设置为现有集群中任意两个数据节点的 EP 即可。具体添加的详细步骤请见详细的用户手册。这样就把集群一步一步的建立起来。
**重定向:**无论是 dnode 还是 taosc最先都是要发起与 mnode 的连接,但 mnode 是系统自动创建并维护的,因此对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode则将 mnode EP List 回复给对方taosc 或新启动的 dnode 收到这个 list就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。
**重定向:**无论是 dnode 还是 taosc最先都是要发起与 mnode 的连接,由于 mnode 是可以动态调整的,所以对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode则将 mnode EP List 回复给对方taosc 或新启动的 dnode 收到这个 list就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。
### 一个典型的消息流程
@ -68,15 +66,17 @@ TDengine 分布式架构的逻辑结构图如下:
<center> 图 2 TDengine 典型的操作流程 </center>
1. 应用通过 JDBC 或其他 API 接口发起插入数据的请求。
2. taosc 会检查缓存,看是否保存有该表的 meta data。如果有直接到第 4 步。如果没有taosc 将向 mnode 发出 get meta-data 请求。
3. mnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema而且还有该表所属的 vgroup 信息vnode ID 以及所在的 dnode 的 End Point如果副本数为 N就有 N 组 End Point。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnodetaosc 将向下一个 mnode 发出请求。
4. taosc 向 master vnode 发起插入请求。
5. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应taosc 会认为该节点已经离线。这种情况下如果被插入的数据库有多个副本taosc 将向 vgroup 里下一个 vnode 发出插入请求。
6. taosc 通知 APP写入成功。
2. taosc 会检查缓存,看是否保存有该表所在数据库的 vgroup-info 信息。如果有,直接到第 4 步。如果没有taosc 将向 mnode 发出 get vgroup-info 请求。
3. mnode 将该表所在数据库的 vgroup-info 返回给 taosc。Vgroup-info 包含数据库的 vgroup 分布信息vnode ID 以及所在的 dnode 的 End Point如果副本数为 N就有 N 组 End Point还包含每个 vgroup 中存储数据表的 hash 范围。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnodetaosc 将向下一个 mnode 发出请求。
4. taosc 会继续检查缓存,看是否保存有该表的 meta-data。如果有直接到第 6 步。如果没有taosc 将向 vnode 发出 get meta-data 请求。
5. vnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema。
6. taosc 向 leader vnode 发起插入请求。
7. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应taosc 会认为该节点已经离线。这种情况下如果被插入的数据库有多个副本taosc 将向 vgroup 里下一个 vnode 发出插入请求。
8. taosc 通知 APP写入成功。
对于第二和第三步taosc 启动时,并不知道 mnode 的 End Point因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。
对于第二步taosc 启动时,并不知道 mnode 的 End Point因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。
对于第四和第五步没有缓存的情况下taosc 无法知道虚拟节点组里谁是 master就假设第一个 vnodeID 就是 master向它发出请求。如果接收到请求的 vnode 并不是 master它会在回复中告知谁是 master这样 taosc 就向建议的 master vnode 发出请求。一旦得到插入成功的回复taosc 会缓存 master 节点的信息。
对于第四和第六步没有缓存的情况下taosc 无法知道虚拟节点组里谁是 leader就假设第一个 vnodeID 就是 leader向它发出请求。如果接收到请求的 vnode 并不是 leader它会在回复中告知谁是 leader这样 taosc 就向建议的 leader vnode 发出请求。一旦得到插入成功的回复taosc 会缓存 leader 节点的信息。
上述是插入数据的流程查询、计算的流程也完全一致。taosc 把这些复杂的流程全部封装屏蔽了,对于应用来说无感知也无需任何特别处理。
@ -89,13 +89,13 @@ TDengine 分布式架构的逻辑结构图如下:
TDengine 存储的数据包括采集的时序数据以及库、表相关的元数据、标签数据等,这些数据具体分为三部分:
- 时序数据:存放于 vnode 里,由 data、head 和 last 三个文件组成,数据量大,查询量取决于应用场景。容许乱序写入,但暂时不支持删除操作,并且仅在 update 参数设置为 1 时允许更新操作。通过采用一个采集点一张表的模型,一个时间段的数据是连续存储,对单张表的写入是简单的追加操作,一次读,可以读到多条记录,这样保证对单个采集点的插入和查询操作,性能达到最优。
- 标签数据:存放于 vnode 里的 meta 文件,支持增删改查四个标准操作。数据量不大,有 N 张表,就有 N 条记录,因此可以全内存存储。如果标签过滤操作很多,查询将十分频繁,因此 TDengine 支持多核多线程并发查询。只要计算资源足够,即使有数千万张表,过滤结果能毫秒级返回
- 元数据:存放于 mnode 里包含系统节点、用户、DB、Table Schema 等信息,支持增删改查四个标准操作。这部分数据的量不大,可以全内存保存,而且由于客户端有缓存,查询量也不大。因此目前的设计虽是集中式存储管理,但不会构成性能瓶颈。
- 数据表元数据:包含标签信息和 Table Schema 信息,存放于 vnode 里的 meta 文件,支持增删改查四个标准操作。数据量很大,有 N 张表,就有 N 条记录,因此采用 LRU 存储支持标签数据的索引。TDengine 支持多核多线程并发查询。只要计算内存足够,元数据全内存存储,千万级别规模的标签数据过滤结果能毫秒级返回。在内存资源不足的情况下,仍然可以支持数千万张表的快速查询
- 数据库元数据:存放于 mnode 里包含系统节点、用户、DB、STable Schema 等信息,支持增删改查四个标准操作。这部分数据的量不大,可以全内存保存,而且由于客户端有缓存,查询量也不大。因此目前的设计虽是集中式存储管理,但不会构成性能瓶颈。
与典型的 NoSQL 存储模型相比TDengine 将标签数据与时序数据完全分离存储,它具有两大优势:
- 能够极大地降低标签数据存储的冗余度:一般的 NoSQL 数据库或时序数据库,采用的 K-V 存储,其中的 Key 包含时间戳、设备 ID、各种标签。每条记录都带有这些重复的内容浪费存储空间。而且如果应用要在历史数据上增加、修改或删除标签需要遍历数据重写一遍操作成本极其昂贵。
- 能够实现极为高效的多表之间的聚合查询:做多表之间聚合查询时,先把符合标签过滤条件的表查找出来,然后再查找这些表相应的数据块,这样大幅减少要扫描的数据集,从而大幅提高查询效率。而且标签数据采用全内存的结构进行管理和维护,千万级别规模的标签数据查询可以在毫秒级别返回。
- 能够实现极为高效的多表之间的聚合查询:做多表之间聚合查询时,先把符合标签过滤条件的表查找出来,然后再查找这些表相应的数据块,这样大幅减少要扫描的数据集,从而大幅提高查询效率。
### 数据分片
@ -103,11 +103,11 @@ TDengine 存储的数据包括采集的时序数据以及库、表相关的元
vnode虚拟数据节点负责为采集的时序数据提供写入、查询和计算功能。为便于负载均衡、数据恢复、支持异构环境TDengine 将一个数据节点根据其计算和存储资源切分为多个 vnode。这些 vnode 的管理是 TDengine 自动完成的,对应用完全透明。
对于单独一个数据采集点,无论其数据量多大,一个 vnode或 vgroup如果副本数大于 1有足够的计算资源和存储资源来处理如果每秒生成一条 16 字节的记录,一年产生的原始数据不到 0.5G),因此 TDengine 将一张表(一个数据采集点)的所有数据都存放在一个 vnode 里,而不会让同一个采集点的数据分布到两个或多个 dnode 上。而且一个 vnode 可存储多个数据采集点(表)的数据,一个 vnode 可容纳的表的数目的上限为一百万。设计上,一个 vnode 里所有的表都属于同一个 DB。一个数据节点上,除非特殊配置,一个 DB 拥有的 vnode 数目不会超过系统核的数目。
对于单独一个数据采集点,无论其数据量多大,一个 vnode或 vgroup如果副本数大于 1有足够的计算资源和存储资源来处理如果每秒生成一条 16 字节的记录,一年产生的原始数据不到 0.5G),因此 TDengine 将一张表(一个数据采集点)的所有数据都存放在一个 vnode 里,而不会让同一个采集点的数据分布到两个或多个 dnode 上。而且一个 vnode 可存储多个数据采集点(表)的数据,一个 vnode 可容纳的表的数目的上限为一百万。设计上,一个 vnode 里所有的表都属于同一个 DB。
创建 DB 时,系统并不会马上分配资源。但当创建一张表时,系统将看是否有已经分配的 vnode且该 vnode 是否有空余的表空间,如果有,立即在该有空位的 vnode 创建表。如果没有,系统将从集群中,根据当前的负载情况,在一个 dnode 上创建一新的 vnode然后创建表。如果 DB 有多个副本,系统不是只创建一个 vnode而是一个 vgroup虚拟数据节点组。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。
TDengine 3.0 采用 hash 一致性算法,确定每张数据表所在的 vnode。创建 DB 时,系统会立刻分配指定数目的 vnode并确定每个 vnode 所负责的数据表范围。当创建一张表时,系统根据数据表名计算出所在的 vnodeID立即在该 vnode 创建表。如果 DB 有多个副本,系统不是只创建一个 vnode而是一个 vgroup虚拟数据节点组。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。
每张表的 meta data包含 schema标签等也存放于 vnode 里,而不是集中存放于 mnode实际上这是对 Meta 数据的分片,这样便于高效并行的进行标签过滤操作。
每张表的 meta data包含 schema标签等也存放于 vnode 里,而不是集中存放于 mnode实际上这是对 meta 数据的分片,这样便于高效并行的进行标签过滤操作。
### 数据分区
@ -117,77 +117,68 @@ TDengine 除 vnode 分片之外,还对时序数据按照时间段进行分区
### 负载均衡
每个 dnode 都定时向 mnode虚拟管理节点报告其状态包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中对外服务继续进行数据插入、查询和计算操作都不受影响。
每个 dnode 都定时向 mnode虚拟管理节点报告其状态包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中对外服务继续进行数据插入、查询和计算操作都不受影响。负载均衡的触发时间,由用户指定。
如果 mnode 一段时间没有收到 dnode 的状态报告mnode 会认为这个 dnode 已经离线。如果离线时间超过一定时长(时长由配置参数 offlineThreshold 决定),该 dnode 将被 mnode 强制剔除出集群。该 dnode 上的 vnodes 如果副本数大于 1系统将自动在其他 dnode 上创建新的副本,以保证数据的副本数。如果该 dnode 上还有 mnode而且 mnode 的副本数大于 1系统也将自动在其他 dnode 上创建新的 mnode以保证 mnode 的副本数。
当新的数据节点被添加进集群,因为新的计算和存储被添加进来,系统也将自动启动负载均衡流程。
负载均衡过程无需任何人工干预,应用也无需重启,将自动连接新的节点,完全透明。
当新的数据节点被添加进集群,因为新的计算和存储被添加进来,用户需要手动触发负载均衡流程,使得系统在最优的情况下运行。
**提示:负载均衡由参数 balance 控制,决定开启/关闭自动负载均衡。**
## 数据写入与复制流程
如果一个数据库有 N 个副本,那一个虚拟节点组就有 N 个虚拟节点,但是只有一个是 master其他都是 slave。当应用将新的记录写入系统时只有 master vnode 能接受写的请求。如果 slave vnode 收到写的请求,系统将通知 taosc 需要重新定向。
如果一个数据库有 N 个副本,那一个虚拟节点组就有 N 个虚拟节点,但是只有一个是 leader其他都是 follower。当应用将新的记录写入系统时只有 leader vnode 能接受写的请求。如果 follower vnode 收到写的请求,系统将通知 taosc 需要重新定向。
### Master Vnode 写入流程
### Leader Vnode 写入流程
Master Vnode 遵循下面的写入流程:
Leader Vnode 遵循下面的写入流程:
![TDengine Database Master写入流程](./write_master.webp)
![TDengine Database Leader写入流程](./write_leader.webp)
<center> 图 3 TDengine Master 写入流程 </center>
<center> 图 3 TDengine Leader 写入流程 </center>
1. master vnode 收到应用的数据插入请求,验证 OK进入下一步
2. 如果系统配置参数 walLevel 大于 0vnode 将该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2而且 fsync 设置为 0TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失;
3. 如果有多个副本vnode 将把数据包转发给同一虚拟节点组内的 slave vnodes该转发包带有数据的版本号version
4. 写入内存,并将记录加入到 skip list
5. master vnode 返回确认信息给应用,表示写入成功;
6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用
1. leader vnode 收到应用的数据插入请求,验证 OK进入下一步
2. vnode 将该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2而且 fsync 设置为 0TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失;
3. 如果有多个副本vnode 将把数据包转发给同一虚拟节点组内的 follower vnodes该转发包带有数据的版本号version
4. 写入内存,并将记录加入到 skip list。但如果未达成一致,会触发回滚操作
5. leader vnode 返回确认信息给应用,表示写入成功;
6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用
### Slave Vnode 写入流程
### Follower Vnode 写入流程
对于 slave vnode写入流程是
对于 follower vnode写入流程是
![TDengine Database Slave 写入流程](./write_slave.webp)
![TDengine Database Follower 写入流程](./write_follower.webp)
<center> 图 4 TDengine Slave 写入流程 </center>
<center> 图 4 TDengine Follower 写入流程 </center>
1. slave vnode 收到 Master vnode 转发了的数据插入请求。检查 last version 是否与 master 一致,如果一致,进入下一步。如果不一致,需要进入同步状态
2. 如果系统配置参数 walLevel 大于 0vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2而且 fsync 设置为 0TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。
1. follower vnode 收到 leader vnode 转发了的数据插入请求
2. vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2而且 fsync 设置为 0TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。
3. 写入内存,更新内存中的 skip list。
master vnode 相比slave vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。
leader vnode 相比follower vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。
### 主从选择
Vnode 会保持一个数据版本号version对内存数据进行持久化存储时对该版本号也进行持久化存储。每个数据更新操作无论是采集的时序数据还是元数据这个版本号将增加 1。
一个 vnode 启动时,角色(master、slave)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status其中包括 version 和自己的角色。通过 status 的交换,系统进入选主流程,规则如下:
一个 vnode 启动时,角色(leader、follower)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status按照标准的 raft 一致性算法完成选主。
1. 如果只有一个副本,该副本永远就是 master
2. 所有副本都在线时,版本最高的被选为 master
3. 在线的虚拟节点数过半,而且有虚拟节点是 slave 的话,该虚拟节点自动成为 master
4. 对于 2 和 3如果多个虚拟节点满足成为 master 的要求,那么虚拟节点组的节点列表里,最前面的选为 master
更多的关于数据复制的流程,请见[《TDengine 2.0 数据复制模块设计》](/tdinternal/replica/)。
更多的关于数据复制的流程,请见[《TDengine 3.0 数据复制模块设计》](/tdinternal/replica/)。
### 同步复制
对于数据一致性要求更高的场景,异步数据复制无法满足要求,因为有极小的概率丢失数据,因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 quorum。如果 quorum 大于 1它表示每次 master 转发给副本时,需要等待 quorum-1 个回复确认,才能通知应用,数据在 slave 已经写入成功。如果在一定的时间内,得不到 quorum-1 个回复确认master vnode 将返回错误给应用。
对于数据一致性要求更高的场景,异步数据复制提供的最终一致性无法满足要求。因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 strict。如果 strict 等于 1它表示每次 leader 转发给副本时,需要等待半数以上副本达成一致后,才能通知应用,数据在 follower 已经写入成功。如果在一定的时间内得不到半数以上副本的确认leader vnode 将返回错误给应用。
采用同步复制,系统的性能会有所下降,而且 latency 会增加。因为元数据要强一致mnode 之间的数据同步缺省就是采用的同步复制。
## 缓存与持久化
### 缓存
### 时序数据缓存
TDengine 采用时间驱动缓存管理策略First-In-First-OutFIFO又称为写驱动的缓存管理机制。这种策略有别于读驱动的数据缓存模式Least-Recent-UsedLRU直接将最近写入的数据保存在系统的缓存中。当缓存达到临界值的时候将最早的数据批量写入磁盘。一般意义上来说对于物联网数据的使用用户最为关心的是刚产生的数据即当前状态。TDengine 充分利用这一特性,将最近到达的(当前状态)数据保存在缓存中。
TDengine 通过查询函数向用户提供毫秒级的数据获取能力。直接将最近到达的数据保存在缓存中,可以更加快速地响应用户针对最近一条或一批数据的查询分析,整体上提供更快的数据库查询响应能力。从这个意义上来说,**可通过设置合适的配置参数将 TDengine 作为数据缓存来使用,而不需要再部署 Redis 或其他额外的缓存系统**可有效地简化系统架构降低运维的成本。需要注意的是TDengine 重启以后系统的缓存将被清空,之前缓存的数据均会被批量写入磁盘,缓存的数据将不会像专门的 key-value 缓存系统再将之前缓存的数据重新加载到缓存中。
每个 vnode 有自己独立的内存,而且由多个固定大小的内存块组成,不同 vnode 之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个 vnode 维护有自己的 skip list便于迅速查找。当三分之一以上的内存块写满时启动落盘操作而且后续写的操作在新的内存块进行。这样一个 vnode 里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个 vnode 的内存块的个数由配置参数 blocks 决定,内存块的大小由配置参数 cache 决定。
每个 vnode 有自己独立的内存,而且由多个固定大小的内存块组成,不同 vnode 之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个 vnode 维护有自己的 skip list便于迅速查找。当三分之一以上的内存块写满时启动落盘操作而且后续写的操作在新的内存块进行。这样一个 vnode 里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个 vnode 的内存大小由配置参数 buffer 决定。
### 持久化存储

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@ -89,7 +89,6 @@ extern uint16_t tsTelemPort;
// query buffer management
extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing
extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node
extern bool tsRetrieveBlockingModel; // retrieve threads will be blocked
// query client
extern int32_t tsQueryPolicy;

View File

@ -96,6 +96,7 @@ typedef struct SScanLogicNode {
bool groupSort;
int8_t cacheLastMode;
bool hasNormalCols; // neither tag column nor primary key tag column
bool sortPrimaryKey;
} SScanLogicNode;
typedef struct SJoinLogicNode {
@ -204,6 +205,7 @@ typedef struct SWindowLogicNode {
int8_t igExpired;
EWindowAlgorithm windowAlgo;
EOrder inputTsOrder;
EOrder outputTsOrder;
} SWindowLogicNode;
typedef struct SFillLogicNode {
@ -212,6 +214,7 @@ typedef struct SFillLogicNode {
SNode* pWStartTs;
SNode* pValues; // SNodeListNode
STimeWindow timeRange;
EOrder inputTsOrder;
} SFillLogicNode;
typedef struct SSortLogicNode {
@ -410,6 +413,8 @@ typedef struct SWinodwPhysiNode {
int8_t triggerType;
int64_t watermark;
int8_t igExpired;
EOrder inputTsOrder;
EOrder outputTsOrder;
} SWinodwPhysiNode;
typedef struct SIntervalPhysiNode {
@ -434,6 +439,7 @@ typedef struct SFillPhysiNode {
SNode* pValues; // SNodeListNode
SNodeList* pTargets;
STimeWindow timeRange;
EOrder inputTsOrder;
} SFillPhysiNode;
typedef struct SMultiTableIntervalPhysiNode {

View File

@ -555,6 +555,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F)
#define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x2660)
#define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661)
#define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662)
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
//planner

View File

@ -1,6 +1,7 @@
@echo off
goto %1
:needAdmin
mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close)&goto :eof
mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close)&& echo To start/stop TDengine with administrator privileges: sc start/stop taosd &goto :eof
:hasAdmin
cp -f C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32
cp -f C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32
sc query "taosd" >nul || sc create "taosd" binPath= "C:\\TDengine\\taosd.exe --win_service" start= DEMAND

View File

@ -20,11 +20,6 @@ target_link_libraries(
)
if(TD_WINDOWS)
set_target_properties(taos
PROPERTIES
LINK_FLAGS
/DEF:${CMAKE_CURRENT_SOURCE_DIR}/src/taos.def
)
INCLUDE_DIRECTORIES(jni/windows)
INCLUDE_DIRECTORIES(jni/windows/win32)
INCLUDE_DIRECTORIES(jni/windows/win32/bridge)

View File

@ -225,9 +225,9 @@ typedef struct SRequestObj {
SArray* targetTableList;
SQueryExecMetric metric;
SRequestSendRecvBody body;
bool syncQuery; // todo refactor: async query object
bool stableQuery; // todo refactor
bool validateOnly; // todo refactor
bool syncQuery; // todo refactor: async query object
bool stableQuery; // todo refactor
bool validateOnly; // todo refactor
bool killed;
uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog
uint32_t retry;

View File

@ -353,6 +353,7 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
desc.subDesc = NULL;
desc.subPlanNum = 0;
}
ASSERT(desc.subPlanNum == taosArrayGetSize(desc.subDesc));
} else {
desc.subDesc = NULL;
}

View File

@ -591,7 +591,7 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray
return code;
}
void freeVgList(void *list) {
void freeVgList(void* list) {
SArray* pList = *(SArray**)list;
taosArrayDestroy(pList);
}
@ -1278,8 +1278,8 @@ int32_t doProcessMsgFromServer(void* param) {
char tbuf[40] = {0};
TRACE_TO_STR(trace, tbuf);
tscDebug("processMsgFromServer handle %p, message: %s, code: %s, gtid: %s", pMsg->info.handle, TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code),
tbuf);
tscDebug("processMsgFromServer handle %p, message: %s, code: %s, gtid: %s", pMsg->info.handle,
TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), tbuf);
if (pSendInfo->requestObjRefId != 0) {
SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId);
@ -2114,7 +2114,7 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) {
return NULL;
}
TAOS_RES* pRes = execQuery(connId, sql, sqlLen, validateOnly);
TAOS_RES* pRes = execQuery(*(int64_t*)taos, sql, sqlLen, validateOnly);
return pRes;
#endif
}

View File

@ -1,81 +0,0 @@
taos_cleanup
taos_options
taos_set_config
taos_init
taos_connect
taos_connect_l
taos_connect_auth
taos_close
taos_data_type
taos_stmt_init
taos_stmt_prepare
taos_stmt_set_tbname_tags
taos_stmt_set_tbname
taos_stmt_set_sub_tbname
taos_stmt_is_insert
taos_stmt_num_params
taos_stmt_get_param
taos_stmt_bind_param
taos_stmt_bind_param_batch
taos_stmt_bind_single_param_batch
taos_stmt_add_batch
taos_stmt_execute
taos_stmt_use_result
taos_stmt_close
taos_stmt_errstr
taos_stmt_affected_rows
taos_stmt_affected_rows_once
taos_query
taos_query_l
taos_fetch_row
taos_result_precision
taos_free_result
taos_field_count
taos_num_fields
taos_affected_rows
taos_fetch_fields
taos_select_db
taos_print_row
taos_stop_query
taos_is_null
taos_is_update_query
taos_fetch_block
taos_fetch_block_s
taos_fetch_raw_block
taos_get_column_data_offset
taos_validate_sql
taos_reset_current_db
taos_fetch_lengths
taos_result_block
taos_get_server_info
taos_get_client_info
taos_errstr
taos_errno
taos_query_a
taos_fetch_rows_a
taos_subscribe
taos_consume
taos_unsubscribe
taos_load_table_info
taos_schemaless_insert
tmq_list_new
tmq_list_append
tmq_list_destroy
tmq_list_get_size
tmq_list_to_c_array
tmq_consumer_new
tmq_err2str
tmq_subscribe
tmq_unsubscribe
tmq_subscription
tmq_consumer_poll
tmq_consumer_close
tmq_commit
tmq_conf_new
tmq_conf_set
tmq_conf_destroy
tmq_conf_set_offset_commit_cb
tmq_get_topic_name
tmq_get_vgroup_id
tmq_create_stream
taos_check_server_status

View File

@ -124,9 +124,6 @@ int32_t tsMinIntervalTime = 1;
int32_t tsQueryBufferSize = -1;
int64_t tsQueryBufferSizeBytes = -1;
// in retrieve blocking model, the retrieve threads will wait for the completion of the query processing.
bool tsRetrieveBlockingModel = false;
// tsdb config
// For backward compatibility
bool tsdbForceKeepFile = false;
@ -296,6 +293,7 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
if (cfgAddInt32(pCfg, "smaDebugFlag", smaDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "idxDebugFlag", idxDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "tdbDebugFlag", tdbDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "metaDebugFlag", metaDebugFlag, 0, 255, 0) != 0) return -1;
return 0;
}
@ -362,7 +360,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, 0) != 0) return -1;
if (cfgAddBool(pCfg, "retrieveBlockingModel", tsRetrieveBlockingModel, 0) != 0) return -1;
if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1;
@ -476,6 +473,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) {
smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32;
idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32;
tdbDebugFlag = cfgGetItem(pCfg, "tdbDebugFlag")->i32;
metaDebugFlag = cfgGetItem(pCfg, "metaDebugFlag")->i32;
}
static int32_t taosSetClientCfg(SConfig *pCfg) {
@ -547,7 +545,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32;
tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32;
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval;
tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval;
tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
@ -832,9 +829,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
break;
}
case 'r': {
if (strcasecmp("retrieveBlockingModel", name) == 0) {
tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval;
} else if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) {
if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) {
tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64;
} else if (strcasecmp("rpcDebugFlag", name) == 0) {
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
@ -1100,12 +1095,12 @@ void taosCfgDynamicOptions(const char *option, const char *value) {
const char *options[] = {
"dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag",
"tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag",
"tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag",
"tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag",
};
int32_t *optionVars[] = {
&dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag,
&tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tdbDebugFlag,
&tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag,
&tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, &metaDebugFlag,
};
int32_t optionSize = tListLen(options);
@ -1152,5 +1147,6 @@ void taosSetAllDebugFlag(int32_t flag) {
taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag);
taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag);
taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag);
taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag);
uInfo("all debug flag are set to %d", flag);
}

View File

@ -305,6 +305,8 @@ static int32_t tDeserializeSClientHbReq(SDecoder *pDecoder, SClientHbReq *pReq)
taosArrayPush(desc.subDesc, &sDesc);
}
}
ASSERT(desc.subPlanNum == taosArrayGetSize(desc.subDesc));
taosArrayPush(pReq->query->queryDesc, &desc);
}

View File

@ -27,6 +27,9 @@
#define DM_VERSION "Print program version."
#define DM_EMAIL "<support@taosdata.com>"
static struct {
#ifdef WINDOWS
bool winServiceMode;
#endif
bool dumpConfig;
bool generateGrant;
bool printAuth;
@ -93,6 +96,10 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
global.dumpConfig = true;
} else if (strcmp(argv[i], "-V") == 0) {
global.printVersion = true;
#ifdef WINDOWS
} else if (strcmp(argv[i], "--win_service") == 0) {
global.winServiceMode = true;
#endif
} else if (strcmp(argv[i], "-e") == 0) {
global.envCmd[cmdEnvIndex] = argv[++i];
cmdEnvIndex++;
@ -169,6 +176,18 @@ int main(int argc, char const *argv[]) {
return -1;
}
#ifdef WINDOWS
int mainWindows(int argc,char** argv);
if (global.winServiceMode) {
stratWindowsService(mainWindows);
} else {
return mainWindows(argc, argv);
}
return 0;
}
int mainWindows(int argc,char** argv) {
#endif
if (global.generateGrant) {
dmGenerateGrant();
taosCleanupArgs();

View File

@ -788,9 +788,9 @@ _OVER:
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node;
const char *options[] = {
"debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag",
"tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag",
"tdbDebugFlag", "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag",
"debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag",
"tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", "tmrDebugFlag",
"uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag",
};
int32_t optionSize = tListLen(options);

View File

@ -145,6 +145,8 @@ int32_t metaSnapWriterOpen(SMeta* pMeta, int64_t sver, int64_t ever, SMetaSnapWr
pWriter->sver = sver;
pWriter->ever = ever;
metaBegin(pMeta);
*ppWriter = pWriter;
return code;

View File

@ -175,7 +175,7 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST
cacheRow = (STSRow *)taosLRUCacheValue(pCache, h);
if (row->ts >= cacheRow->ts) {
if (row->ts == cacheRow->ts) {
STSRow *mergedRow;
STSRow *mergedRow = NULL;
SRowMerger merger = {0};
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1);

View File

@ -374,11 +374,12 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid
p = taosArrayInsert(pMemTable->aTbData, idx, &pTbData);
taosWUnLockLatch(&pMemTable->latch);
tsdbDebug("vgId:%d add table data %p at idx:%d", TD_VID(pMemTable->pTsdb->pVnode), pTbData, idx);
if (p == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
_exit:
*ppTbData = pTbData;
return code;

View File

@ -694,8 +694,8 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
if (pWriter->bDataW.nRow < pWriter->maxRow * 4 / 5) continue;
_write_block:
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdx, &pWriter->blockW,
pWriter->cmprAlg);
code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
&pWriter->blockW, pWriter->cmprAlg);
if (code) goto _err;
code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock);
@ -756,7 +756,7 @@ static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, TABLEID id) {
if (pWriter->iBlockIdx < taosArrayGetSize(pWriter->aBlockIdx)) {
ASSERT(pWriter->pDataFReader);
SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlock);
SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx);
int32_t c = tTABLEIDCmprFn(pBlockIdx, &id);
ASSERT(c >= 0);
@ -833,7 +833,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) {
}
_exit:
tsdbError("vgId:%d vnode snapshot tsdb writer data end", TD_VID(pTsdb->pVnode));
tsdbInfo("vgId:%d vnode snapshot tsdb writer data end", TD_VID(pTsdb->pVnode));
return code;
_err:

View File

@ -288,7 +288,7 @@ int vnodeCommit(SVnode *pVnode) {
// apply the commit (TODO)
walEndSnapshot(pVnode->pWal);
vInfo("vgId:%d, commit over", TD_VID(pVnode));
vInfo("vgId:%d, commit end", TD_VID(pVnode));
return 0;
}

View File

@ -180,6 +180,7 @@ struct SVSnapWriter {
SVnode *pVnode;
int64_t sver;
int64_t ever;
int64_t commitID;
int64_t index;
// meta
SMetaSnapWriter *pMetaSnapWriter;
@ -201,7 +202,16 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
pWriter->sver = sver;
pWriter->ever = ever;
vInfo("vgId:%d vnode snapshot writer opened", TD_VID(pVnode));
// commit it
code = vnodeCommit(pVnode);
if (code) goto _err;
// inc commit ID
pVnode->state.commitID++;
pWriter->commitID = pVnode->state.commitID;
vInfo("vgId:%d vnode snapshot writer opened, sver:%" PRId64 " ever:%" PRId64 " commit id:%" PRId64, TD_VID(pVnode),
sver, ever, pWriter->commitID);
*ppWriter = pWriter;
return code;
@ -244,6 +254,8 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
code = vnodeCommitInfo(dir, &info);
if (code) goto _err;
vnodeBegin(pVnode);
} else {
ASSERT(0);
}

View File

@ -19,6 +19,8 @@
#ifdef __cplusplus
extern "C" {
#endif
// clang-format off
#include "nodes.h"
#include "plannodes.h"
#include "ttime.h"
@ -77,6 +79,8 @@ extern "C" {
#define EXPLAIN_EXECINFO_FORMAT "cost=%.3f..%.3f rows=%" PRIu64
#define EXPLAIN_MODE_FORMAT "mode=%s"
#define EXPLAIN_STRING_TYPE_FORMAT "%s"
#define EXPLAIN_INPUT_ORDER_FORMAT "input_order=%s"
#define EXPLAIN_OUTPUT_ORDER_TYPE_FORMAT "output_order=%s"
#define COMMAND_RESET_LOG "resetLog"
#define COMMAND_SCHEDULE_POLICY "schedulePolicy"
@ -122,7 +126,7 @@ typedef struct SExplainCtx {
SHashObj *groupHash; // Hash<SExplainGroup>
} SExplainCtx;
#define EXPLAIN_ORDER_STRING(_order) ((TSDB_ORDER_ASC == _order) ? "Ascending" : "Descending")
#define EXPLAIN_ORDER_STRING(_order) ((ORDER_ASC == _order) ? "asc" : "desc")
#define EXPLAIN_JOIN_STRING(_type) ((JOIN_TYPE_INNER == _type) ? "Inner join" : "Join")
#define INVERAL_TIME_FROM_PRECISION_TO_UNIT(_t, _u, _p) (((_u) == 'n' || (_u) == 'y') ? (_t) : (convertTimeFromPrecisionToUnit(_t, _p, _u)))

View File

@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// clang-format off
#include "commandInt.h"
#include "plannodes.h"
#include "query.h"
@ -849,6 +850,10 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
EXPLAIN_ROW_APPEND(EXPLAIN_FUNCTIONS_FORMAT, pIntNode->window.pFuncs->length);
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->totalRowSize);
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
EXPLAIN_ROW_APPEND(EXPLAIN_INPUT_ORDER_FORMAT, EXPLAIN_ORDER_STRING(pIntNode->window.inputTsOrder));
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
EXPLAIN_ROW_APPEND(EXPLAIN_OUTPUT_ORDER_TYPE_FORMAT, EXPLAIN_ORDER_STRING(pIntNode->window.outputTsOrder));
EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT);
EXPLAIN_ROW_END();
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level));
@ -1154,7 +1159,9 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_MERGE_KEYS_FORMAT);
for (int32_t i = 0; i < LIST_LENGTH(pMergeNode->pMergeKeys); ++i) {
SOrderByExprNode *ptn = (SOrderByExprNode *)nodesListGetNode(pMergeNode->pMergeKeys, i);
EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr));
EXPLAIN_ROW_APPEND(EXPLAIN_STRING_TYPE_FORMAT, nodesGetNameFromColumnNode(ptn->pExpr));
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
EXPLAIN_ROW_APPEND(EXPLAIN_STRING_TYPE_FORMAT, EXPLAIN_ORDER_STRING(ptn->order));
}
EXPLAIN_ROW_END();
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));

View File

@ -523,7 +523,8 @@ typedef struct SIntervalAggOperatorInfo {
STimeWindow win; // query time range
bool timeWindowInterpo; // interpolation needed or not
SArray* pInterpCols; // interpolation columns
int32_t order; // current SSDataBlock scan order
int32_t resultTsOrder; // result timestamp order
int32_t inputOrder; // input data ts order
EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
STimeWindowAggSupp twAggSup;
bool invertible;
@ -533,8 +534,7 @@ typedef struct SIntervalAggOperatorInfo {
SArray* pDelWins; // SWinRes
int32_t delIndex;
SSDataBlock* pDelRes;
SNode *pCondition;
SNode* pCondition;
} SIntervalAggOperatorInfo;
typedef struct SMergeAlignedIntervalAggOperatorInfo {
@ -804,7 +804,7 @@ typedef struct STagFilterOperatorInfo {
typedef struct SJoinOperatorInfo {
SSDataBlock *pRes;
int32_t joinType;
int32_t inputTsOrder;
int32_t inputOrder;
SSDataBlock *pLeft;
int32_t leftPos;

View File

@ -74,9 +74,9 @@ void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataB
struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const struct SNodeListNode* val);
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t slotId,
const char* id);
int32_t order, const char* id);
void* taosDestroyFillInfo(struct SFillInfo *pFillInfo);
int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity);

View File

@ -251,15 +251,29 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
}
}
bool assignUid = false;
if (LIST_LENGTH(pScanInfo->pGroupTags) > 0) {
SNode* p = nodesListGetNode(pScanInfo->pGroupTags, 0);
if (p->type == QUERY_NODE_FUNCTION) {
// partition by tbname/group by tbname
assignUid = (strcmp(((struct SFunctionNode*)p)->functionName, "tbname") == 0);
}
}
for (int32_t i = 0; i < taosArrayGetSize(qa); ++i) {
uint64_t* uid = taosArrayGet(qa, i);
STableKeyInfo keyInfo = {.uid = *uid, .groupId = 0};
if (bufLen > 0) {
code = getGroupIdFromTagsVal(pScanInfo->readHandle.meta, keyInfo.uid, pScanInfo->pGroupTags, keyBuf,
&keyInfo.groupId);
if (code != TSDB_CODE_SUCCESS) {
return code;
if (assignUid) {
keyInfo.groupId = keyInfo.uid;
} else {
code = getGroupIdFromTagsVal(pScanInfo->readHandle.meta, keyInfo.uid, pScanInfo->pGroupTags, keyBuf,
&keyInfo.groupId);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
}
}

View File

@ -3586,15 +3586,14 @@ void doDestroyExchangeOperatorInfo(void* param) {
}
static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, SNodeListNode* pValNode,
STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType) {
STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType, int32_t order) {
SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, pValNode);
STimeWindow w = getAlignQueryTimeWindow(pInterval, pInterval->precision, win.skey);
w = getFirstQualifiedTimeWindow(win.skey, &w, pInterval, TSDB_ORDER_ASC);
int32_t order = TSDB_ORDER_ASC;
pInfo->pFillInfo =
taosCreateFillInfo(order, w.skey, 0, capacity, numOfCols, pInterval, fillType, pColInfo, pInfo->primaryTsCol, id);
taosCreateFillInfo(w.skey, 0, capacity, numOfCols, pInterval, fillType, pColInfo, pInfo->primaryTsCol, order, id);
pInfo->win = win;
pInfo->p = taosMemoryCalloc(numOfCols, POINTER_BYTES);
@ -3624,6 +3623,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
? &((SMergeAlignedIntervalAggOperatorInfo*)downstream->info)->intervalAggOperatorInfo->interval
: &((SIntervalAggOperatorInfo*)downstream->info)->interval;
int32_t order = (pPhyFillNode->inputTsOrder == ORDER_ASC)? TSDB_ORDER_ASC:TSDB_ORDER_DESC;
int32_t type = convertFillType(pPhyFillNode->mode);
SResultInfo* pResultInfo = &pOperator->resultInfo;
@ -3635,7 +3635,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
&numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
int32_t code = initFillInfo(pInfo, pExprInfo, num, (SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange,
pResultInfo->capacity, pTaskInfo->id.str, pInterval, type);
pResultInfo->capacity, pTaskInfo->id.str, pInterval, type, order);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}

View File

@ -77,11 +77,11 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
pInfo->pCondAfterMerge = NULL;
}
pInfo->inputTsOrder = TSDB_ORDER_ASC;
pInfo->inputOrder = TSDB_ORDER_ASC;
if (pJoinNode->inputTsOrder == ORDER_ASC) {
pInfo->inputTsOrder = TSDB_ORDER_ASC;
pInfo->inputOrder = TSDB_ORDER_ASC;
} else if (pJoinNode->inputTsOrder == ORDER_DESC) {
pInfo->inputTsOrder = TSDB_ORDER_DESC;
pInfo->inputOrder = TSDB_ORDER_DESC;
}
pOperator->fpSet =
@ -312,7 +312,7 @@ static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes)
int32_t nrows = pRes->info.rows;
bool asc = (pJoinInfo->inputTsOrder == TSDB_ORDER_ASC) ? true : false;
bool asc = (pJoinInfo->inputOrder == TSDB_ORDER_ASC) ? true : false;
while (1) {
int64_t leftTs = 0;

View File

@ -66,7 +66,7 @@ static void setNullRow(SSDataBlock* pBlock, int64_t ts, int32_t rowIndex) {
static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
static void doSetUserSpecifiedValue(SColumnInfoData* pDst, SVariant* pVar, int32_t rowIndex, int64_t currentKey) {
static void doSetUserSpecifiedValue(SColumnInfoData* pDst, SVariant* pVar, int32_t rowIndex, int64_t currentKey) {
if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) {
float v = 0;
GET_TYPED_DATA(v, float, pVar->nType, &pVar->i);
@ -184,7 +184,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
continue;
}
SVariant* pVar = &pFillInfo->pFillCol[i].fillVal;
SVariant* pVar = &pFillInfo->pFillCol[i].fillVal;
SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, i);
doSetUserSpecifiedValue(pDst, pVar, index, pFillInfo->currentKey);
}
@ -298,7 +298,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
SColumnInfoData* pSrc = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId);
char* src = colDataGetData(pSrc, pFillInfo->index);
if (/*i == 0 || (*/!colDataIsNull_s(pSrc, pFillInfo->index)) {
if (/*i == 0 || (*/ !colDataIsNull_s(pSrc, pFillInfo->index)) {
bool isNull = colDataIsNull_s(pSrc, pFillInfo->index);
colDataAppend(pDst, index, src, isNull);
saveColData(pFillInfo->prev, i, src, isNull);
@ -313,7 +313,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
bool isNull = colDataIsNull_s(pSrc, pFillInfo->index);
colDataAppend(pDst, index, src, isNull);
saveColData(pFillInfo->prev, i, src, isNull); // todo:
saveColData(pFillInfo->prev, i, src, isNull); // todo:
} else if (pFillInfo->type == TSDB_FILL_NULL) {
colDataAppendNULL(pDst, index);
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
@ -433,9 +433,9 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
return pFillInfo->numOfRows - pFillInfo->index;
}
struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t primaryTsSlotId,
const char* id) {
struct SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol,
int32_t primaryTsSlotId, int32_t order, const char* id) {
if (fillType == TSDB_FILL_NONE) {
return NULL;
}
@ -446,10 +446,9 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
return NULL;
}
pFillInfo->tsSlotId = primaryTsSlotId;
taosResetFillInfo(pFillInfo, skey);
pFillInfo->order = order;
pFillInfo->tsSlotId = primaryTsSlotId;
taosResetFillInfo(pFillInfo, skey);
switch (fillType) {
case FILL_MODE_NONE:
@ -535,6 +534,14 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) {
return NULL;
}
void taosFillSetDataOrderInfo(SFillInfo* pFillInfo, int32_t order) {
if (pFillInfo == NULL || (order != TSDB_ORDER_ASC && order != TSDB_ORDER_DESC)) {
return;
}
pFillInfo->order = order;
}
void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey) {
if (pFillInfo->type == TSDB_FILL_NONE) {
return;
@ -581,7 +588,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
int64_t numOfRes = -1;
if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set.
TSKEY lastKey = tsList[pFillInfo->numOfRows - 1];
TSKEY lastKey = (TSDB_ORDER_ASC == pFillInfo->order ? tsList[pFillInfo->numOfRows - 1] : tsList[0]);
numOfRes = taosTimeCountInterval(lastKey, pFillInfo->currentKey, pFillInfo->interval.sliding,
pFillInfo->interval.slidingUnit, pFillInfo->interval.precision);
numOfRes += 1;
@ -626,9 +633,9 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t ca
}
qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%" PRId64 "-%" PRId64 ", currentKey:%" PRId64
", current : % d, total : % d, %s", pFillInfo,
pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey,
pFillInfo->numOfCurrent, pFillInfo->numOfTotal, pFillInfo->id);
", current : % d, total : % d, %s",
pFillInfo, pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey,
pFillInfo->numOfCurrent, pFillInfo->numOfTotal, pFillInfo->id);
return numOfRes;
}

View File

@ -362,7 +362,7 @@ static void setNotInterpoWindowKey(SqlFunctionCtx* pCtx, int32_t numOfOutput, in
static bool setTimeWindowInterpolationStartTs(SIntervalAggOperatorInfo* pInfo, int32_t pos, SSDataBlock* pBlock,
const TSKEY* tsCols, STimeWindow* win, SExprSupp* pSup) {
bool ascQuery = (pInfo->order == TSDB_ORDER_ASC);
bool ascQuery = (pInfo->inputOrder == TSDB_ORDER_ASC);
TSKEY curTs = tsCols[pos];
@ -392,7 +392,7 @@ static bool setTimeWindowInterpolationStartTs(SIntervalAggOperatorInfo* pInfo, i
static bool setTimeWindowInterpolationEndTs(SIntervalAggOperatorInfo* pInfo, SExprSupp* pSup, int32_t endRowIndex,
SArray* pDataBlock, const TSKEY* tsCols, TSKEY blockEkey,
STimeWindow* win) {
int32_t order = pInfo->order;
int32_t order = pInfo->inputOrder;
TSKEY actualEndKey = tsCols[endRowIndex];
TSKEY key = (order == TSDB_ORDER_ASC) ? win->ekey : win->skey;
@ -550,7 +550,7 @@ static void doWindowBorderInterpolation(SIntervalAggOperatorInfo* pInfo, SSDataB
if (!done) {
int32_t endRowIndex = startPos + forwardRows - 1;
TSKEY endKey = (pInfo->order == TSDB_ORDER_ASC) ? pBlock->info.window.ekey : pBlock->info.window.skey;
TSKEY endKey = (pInfo->inputOrder == TSDB_ORDER_ASC) ? pBlock->info.window.ekey : pBlock->info.window.skey;
bool interp = setTimeWindowInterpolationEndTs(pInfo, pSup, endRowIndex, pBlock->pDataBlock, tsCols, endKey, win);
if (interp) {
setResultRowInterpo(pResult, RESULT_ROW_END_INTERP);
@ -639,7 +639,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
setNotInterpoWindowKey(pSup->pCtx, numOfExprs, RESULT_ROW_START_INTERP);
doApplyFunctions(pTaskInfo, pSup->pCtx, &w, &pInfo->twAggSup.timeWindowData, startPos, 0, tsCols, pBlock->info.rows,
numOfExprs, pInfo->order);
numOfExprs, pInfo->inputOrder);
if (isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) {
closeResultRow(pr);
@ -924,11 +924,11 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
int32_t numOfOutput = pSup->numOfExprs;
int64_t* tsCols = extractTsCol(pBlock, pInfo);
uint64_t tableGroupId = pBlock->info.groupId;
bool ascScan = (pInfo->order == TSDB_ORDER_ASC);
bool ascScan = (pInfo->inputOrder == TSDB_ORDER_ASC);
TSKEY ts = getStartTsKey(&pBlock->info.window, tsCols);
SResultRow* pResult = NULL;
STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->order);
STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->inputOrder);
int32_t ret = TSDB_CODE_SUCCESS;
if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) &&
inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) {
@ -946,7 +946,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
TSKEY ekey = ascScan ? win.ekey : win.skey;
int32_t forwardRows =
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order);
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder);
ASSERT(forwardRows > 0);
// prev time window not interpolation yet.
@ -969,7 +969,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) {
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true);
doApplyFunctions(pTaskInfo, pSup->pCtx, &win, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols,
pBlock->info.rows, numOfOutput, pInfo->order);
pBlock->info.rows, numOfOutput, pInfo->inputOrder);
}
doCloseWindow(pResultRowInfo, pInfo, pResult);
@ -977,14 +977,14 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
STimeWindow nextWin = win;
while (1) {
int32_t prevEndPos = forwardRows - 1 + startPos;
startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, pInfo->order);
startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, pInfo->inputOrder);
if (startPos < 0) {
break;
}
if (pInfo->ignoreExpiredData && isCloseWindow(&nextWin, &pInfo->twAggSup)) {
ekey = ascScan ? nextWin.ekey : nextWin.skey;
forwardRows =
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order);
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder);
continue;
}
@ -1002,14 +1002,14 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
ekey = ascScan ? nextWin.ekey : nextWin.skey;
forwardRows =
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->order);
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder);
// window start(end) key interpolation
doWindowBorderInterpolation(pInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pSup);
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true);
doApplyFunctions(pTaskInfo, pSup->pCtx, &nextWin, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols,
pBlock->info.rows, numOfOutput, pInfo->order);
pBlock->info.rows, numOfOutput, pInfo->inputOrder);
doCloseWindow(pResultRowInfo, pInfo, pResult);
}
@ -1082,7 +1082,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
break;
}
getTableScanInfo(pOperator, &pInfo->order, &scanFlag);
getTableScanInfo(pOperator, &pInfo->inputOrder, &scanFlag);
if (pInfo->scalarSupp.pExprInfo != NULL) {
SExprSupp* pExprSup = &pInfo->scalarSupp;
@ -1090,13 +1090,13 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
}
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, scanFlag, true);
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->inputOrder, scanFlag, true);
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag, NULL);
}
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, pInfo->order);
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, pInfo->resultTsOrder);
OPTR_SET_OPENED(pOperator);
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
@ -1249,7 +1249,6 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
}
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
pOperator->status = OP_RES_TO_RETURN;
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, TSDB_ORDER_ASC);
@ -1550,7 +1549,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
SIntervalAggOperatorInfo* pInfo = pOperator->info;
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
pInfo->order = TSDB_ORDER_ASC;
pInfo->inputOrder = TSDB_ORDER_ASC;
SExprSupp* pSup = &pOperator->exprSupp;
if (pOperator->status == OP_EXEC_DONE) {
@ -1610,7 +1609,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
// The timewindow that overlaps the timestamps of the input pBlock need to be recalculated and return to the
// caller. Note that all the time window are not close till now.
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, MAIN_SCAN, true);
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->inputOrder, MAIN_SCAN, true);
if (pInfo->invertible) {
setInverFunction(pSup->pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.type);
}
@ -1790,7 +1789,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
}
pInfo->win = pTaskInfo->window;
pInfo->order = TSDB_ORDER_ASC;
pInfo->inputOrder = (pPhyNode->window.inputTsOrder == ORDER_ASC)? TSDB_ORDER_ASC:TSDB_ORDER_DESC;
pInfo->resultTsOrder = (pPhyNode->window.outputTsOrder == ORDER_ASC)? TSDB_ORDER_ASC:TSDB_ORDER_DESC;
pInfo->interval = *pInterval;
pInfo->execModel = pTaskInfo->execModel;
pInfo->twAggSup = *pTwAggSupp;
@ -1807,7 +1807,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
}
pInfo->primaryTsIndex = primaryTsSlotId;
SExprSupp* pSup = &pOperator->exprSupp;
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
@ -1879,7 +1878,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
goto _error;
}
pInfo->order = TSDB_ORDER_ASC;
pInfo->inputOrder = TSDB_ORDER_ASC;
pInfo->interval = *pInterval;
pInfo->execModel = OPTR_EXEC_MODEL_STREAM;
pInfo->win = pTaskInfo->window;
@ -3098,6 +3097,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT);
pInfo->delIndex = 0;
pInfo->pDelWins = taosArrayInit(4, sizeof(SWinRes));
pInfo->pRecycledPages = taosArrayInit(4, sizeof(int32_t));
pOperator->operatorType = pPhyNode->type;
pOperator->blocking = true;
@ -3140,6 +3140,26 @@ void destroyStreamAggSupporter(SStreamAggSupporter* pSup) {
blockDataDestroy(pSup->pScanBlock);
}
void destroyStateWinInfo(void* ptr) {
if (ptr == NULL) {
return;
}
SStateWindowInfo* pWin = (SStateWindowInfo*) ptr;
taosMemoryFreeClear(pWin->stateKey.pData);
}
void destroyStateStreamAggSupporter(SStreamAggSupporter* pSup) {
taosMemoryFreeClear(pSup->pKeyBuf);
void** pIte = NULL;
while ((pIte = taosHashIterate(pSup->pResultRows, pIte)) != NULL) {
SArray* pWins = (SArray*)(*pIte);
taosArrayDestroyEx(pWins, (FDelete)destroyStateWinInfo);
}
taosHashCleanup(pSup->pResultRows);
destroyDiskbasedBuf(pSup->pResultBuf);
blockDataDestroy(pSup->pScanBlock);
}
void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) {
SStreamSessionAggOperatorInfo* pInfo = (SStreamSessionAggOperatorInfo*)param;
cleanupBasicInfo(&pInfo->binfo);
@ -3607,12 +3627,17 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
}
}
void deleteWindow(SArray* pWinInfos, int32_t index) {
void deleteWindow(SArray* pWinInfos, int32_t index, FDelete fp) {
ASSERT(index >= 0 && index < taosArrayGetSize(pWinInfos));
if (fp) {
void* ptr = taosArrayGet(pWinInfos, index);
fp(ptr);
}
taosArrayRemove(pWinInfos, index);
}
static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, int64_t gap, SArray* result) {
static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, int64_t gap,
SArray* result, FDelete fp) {
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
TSKEY* startDatas = (TSKEY*)pStartTsCol->pData;
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
@ -3626,7 +3651,7 @@ static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc
if (!pCurWin) {
break;
}
deleteWindow(pAggSup->pCurWins, winIndex);
deleteWindow(pAggSup->pCurWins, winIndex, fp);
if (result) {
taosArrayPush(result, pCurWin);
}
@ -3751,7 +3776,7 @@ SResultWindowInfo* getResWinForSession(void* pData) { return (SResultWindowInfo*
SResultWindowInfo* getResWinForState(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; }
int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArray* pClosed, __get_win_info_ fn,
bool delete) {
bool delete, FDelete fp) {
// Todo(liuyao) save window to tdb
void** pIte = NULL;
size_t keyLen = 0;
@ -3773,7 +3798,7 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra
pSeWin->isOutput = true;
}
if (delete) {
deleteWindow(pWins, i);
deleteWindow(pWins, i, fp);
i--;
size = taosArrayGetSize(pWins);
}
@ -3786,13 +3811,13 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra
return TSDB_CODE_SUCCESS;
}
static void closeChildSessionWindow(SArray* pChildren, TSKEY maxTs, bool delete) {
static void closeChildSessionWindow(SArray* pChildren, TSKEY maxTs, bool delete, FDelete fp) {
int32_t size = taosArrayGetSize(pChildren);
for (int32_t i = 0; i < size; i++) {
SOperatorInfo* pChildOp = taosArrayGetP(pChildren, i);
SStreamSessionAggOperatorInfo* pChInfo = pChildOp->info;
pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, maxTs);
closeSessionWindow(pChInfo->streamAggSup.pResultRows, &pChInfo->twAggSup, NULL, getResWinForSession, delete);
closeSessionWindow(pChInfo->streamAggSup.pResultRows, &pChInfo->twAggSup, NULL, getResWinForSession, delete, fp);
}
}
@ -3870,13 +3895,13 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
} else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) {
SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo));
// gap must be 0
doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins);
doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins, NULL);
if (IS_FINAL_OP(pInfo)) {
int32_t childIndex = getChildIndex(pBlock);
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex);
SStreamSessionAggOperatorInfo* pChildInfo = pChildOp->info;
// gap must be 0
doDeleteTimeWindows(&pChildInfo->streamAggSup, pBlock, 0, NULL);
doDeleteTimeWindows(&pChildInfo->streamAggSup, pBlock, 0, NULL, NULL);
rebuildTimeWindow(pInfo, pWins, pBlock->info.groupId, pOperator->exprSupp.numOfExprs, pOperator);
}
copyDeleteWindowInfo(pWins, pInfo->pStDeleted);
@ -3918,8 +3943,8 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
pOperator->status = OP_RES_TO_RETURN;
closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForSession,
pInfo->ignoreExpiredData);
closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData);
pInfo->ignoreExpiredData, NULL);
closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData, NULL);
copyUpdateResult(pStUpdated, pUpdated);
taosHashCleanup(pStUpdated);
@ -4014,7 +4039,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
break;
} else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) {
// gap must be 0
doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, NULL);
doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, NULL, NULL);
copyDataBlock(pInfo->pDelRes, pBlock);
pInfo->pDelRes->info.type = STREAM_DELETE_RESULT;
break;
@ -4120,7 +4145,7 @@ _error:
void destroyStreamStateOperatorInfo(void* param, int32_t numOfOutput) {
SStreamStateAggOperatorInfo* pInfo = (SStreamStateAggOperatorInfo*)param;
cleanupBasicInfo(&pInfo->binfo);
destroyStreamAggSupporter(&pInfo->streamAggSup);
destroyStateStreamAggSupporter(&pInfo->streamAggSup);
cleanupGroupResInfo(&pInfo->groupResInfo);
if (pInfo->pChildren != NULL) {
int32_t size = taosArrayGetSize(pInfo->pChildren);
@ -4132,6 +4157,10 @@ void destroyStreamStateOperatorInfo(void* param, int32_t numOfOutput) {
taosMemoryFreeClear(pChInfo);
}
}
colDataDestroy(&pInfo->twAggSup.timeWindowData);
blockDataDestroy(pInfo->pDelRes);
taosHashCleanup(pInfo->pSeDeleted);
destroySqlFunctionCtx(pInfo->pDummyCtx, 0);
taosMemoryFreeClear(param);
}
@ -4314,7 +4343,7 @@ static void doClearStateWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc
pSeDeleted);
ASSERT(isTsInWindow(pCurWin, tsCol[i]) || isEqualStateKey(pCurWin, pKeyData));
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
deleteWindow(pAggSup->pCurWins, winIndex);
deleteWindow(pAggSup->pCurWins, winIndex, destroyStateWinInfo);
}
}
@ -4357,7 +4386,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey,
&pSDataBlock->info.groupId);
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
deleteWindow(pAggSup->pCurWins, winIndex);
deleteWindow(pAggSup->pCurWins, winIndex, destroyStateWinInfo);
continue;
}
code = doOneStateWindowAgg(pInfo, pSDataBlock, &pCurWin->winInfo, &pResult, i, winRows, numOfOutput, pOperator);
@ -4415,7 +4444,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
continue;
} else if (pBlock->info.type == STREAM_DELETE_DATA) {
SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo));
doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins);
doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins, destroyStateWinInfo);
copyDeleteWindowInfo(pWins, pInfo->pSeDeleted);
taosArrayDestroy(pWins);
continue;
@ -4437,8 +4466,8 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
pOperator->status = OP_RES_TO_RETURN;
closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForState,
pInfo->ignoreExpiredData);
closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData);
pInfo->ignoreExpiredData, destroyStateWinInfo);
// closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData, destroyStateWinInfo);
copyUpdateResult(pSeUpdated, pUpdated);
taosHashCleanup(pSeUpdated);
@ -4564,7 +4593,7 @@ static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, ui
SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
SExprSupp* pSup = &pOperatorInfo->exprSupp;
bool ascScan = (iaInfo->order == TSDB_ORDER_ASC);
bool ascScan = (iaInfo->inputOrder == TSDB_ORDER_ASC);
SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &wstartTs, TSDB_KEYSIZE, tableGroupId);
SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf,
@ -4618,7 +4647,7 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
} else {
updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true);
doApplyFunctions(pTaskInfo, pSup->pCtx, &currWin, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos,
tsCols, pBlock->info.rows, numOfOutput, iaInfo->order);
tsCols, pBlock->info.rows, numOfOutput, iaInfo->inputOrder);
outputMergeAlignedIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs);
@ -4637,7 +4666,7 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
}
updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true);
doApplyFunctions(pTaskInfo, pSup->pCtx, &currWin, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos,
tsCols, pBlock->info.rows, numOfOutput, iaInfo->order);
tsCols, pBlock->info.rows, numOfOutput, iaInfo->inputOrder);
outputMergeAlignedIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs);
}
@ -4682,8 +4711,8 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
break;
}
getTableScanInfo(pOperator, &iaInfo->order, &scanFlag);
setInputDataBlock(pOperator, pSup->pCtx, pBlock, iaInfo->order, scanFlag, true);
getTableScanInfo(pOperator, &iaInfo->inputOrder, &scanFlag);
setInputDataBlock(pOperator, pSup->pCtx, pBlock, iaInfo->inputOrder, scanFlag, true);
doMergeAlignedIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes);
doFilter(miaInfo->pCondition, pRes, NULL);
if (pRes->info.rows >= pOperator->resultInfo.capacity) {
@ -4724,7 +4753,7 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
miaInfo->pCondition = pCondition;
iaInfo->win = pTaskInfo->window;
iaInfo->order = TSDB_ORDER_ASC;
iaInfo->inputOrder = TSDB_ORDER_ASC;
iaInfo->interval = *pInterval;
iaInfo->execModel = pTaskInfo->execModel;
iaInfo->primaryTsIndex = primaryTsSlotId;
@ -4806,7 +4835,7 @@ static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t table
SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info;
SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo;
SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
bool ascScan = (iaInfo->order == TSDB_ORDER_ASC);
bool ascScan = (iaInfo->inputOrder == TSDB_ORDER_ASC);
SExprSupp* pExprSup = &pOperatorInfo->exprSupp;
SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &win->skey, TSDB_KEYSIZE, tableGroupId);
@ -4824,7 +4853,7 @@ static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t t
SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info;
SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo;
SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
bool ascScan = (iaInfo->order == TSDB_ORDER_ASC);
bool ascScan = (iaInfo->inputOrder == TSDB_ORDER_ASC);
SExprSupp* pExprSup = &pOperatorInfo->exprSupp;
SGroupTimeWindow groupTimeWindow = {.groupId = tableGroupId, .window = *newWin};
@ -4860,12 +4889,12 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
int32_t numOfOutput = pExprSup->numOfExprs;
int64_t* tsCols = extractTsCol(pBlock, iaInfo);
uint64_t tableGroupId = pBlock->info.groupId;
bool ascScan = (iaInfo->order == TSDB_ORDER_ASC);
bool ascScan = (iaInfo->inputOrder == TSDB_ORDER_ASC);
TSKEY blockStartTs = getStartTsKey(&pBlock->info.window, tsCols);
SResultRow* pResult = NULL;
STimeWindow win =
getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval, iaInfo->order);
getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval, iaInfo->inputOrder);
int32_t ret =
setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx,
@ -4876,7 +4905,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
TSKEY ekey = ascScan ? win.ekey : win.skey;
int32_t forwardRows =
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->order);
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->inputOrder);
ASSERT(forwardRows > 0);
// prev time window not interpolation yet.
@ -4897,7 +4926,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &win, true);
doApplyFunctions(pTaskInfo, pExprSup->pCtx, &win, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols,
pBlock->info.rows, numOfOutput, iaInfo->order);
pBlock->info.rows, numOfOutput, iaInfo->inputOrder);
doCloseWindow(pResultRowInfo, iaInfo, pResult);
// output previous interval results after this interval (&win) is closed
@ -4906,7 +4935,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
STimeWindow nextWin = win;
while (1) {
int32_t prevEndPos = forwardRows - 1 + startPos;
startPos = getNextQualifiedWindow(&iaInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, iaInfo->order);
startPos = getNextQualifiedWindow(&iaInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, iaInfo->inputOrder);
if (startPos < 0) {
break;
}
@ -4921,14 +4950,14 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
ekey = ascScan ? nextWin.ekey : nextWin.skey;
forwardRows =
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->order);
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->inputOrder);
// window start(end) key interpolation
doWindowBorderInterpolation(iaInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pExprSup);
updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &nextWin, true);
doApplyFunctions(pTaskInfo, pExprSup->pCtx, &nextWin, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows,
tsCols, pBlock->info.rows, numOfOutput, iaInfo->order);
tsCols, pBlock->info.rows, numOfOutput, iaInfo->inputOrder);
doCloseWindow(pResultRowInfo, iaInfo, pResult);
// output previous interval results after this interval (&nextWin) is closed
@ -4982,8 +5011,8 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) {
break;
}
getTableScanInfo(pOperator, &iaInfo->order, &scanFlag);
setInputDataBlock(pOperator, pExpSupp->pCtx, pBlock, iaInfo->order, scanFlag, true);
getTableScanInfo(pOperator, &iaInfo->inputOrder, &scanFlag);
setInputDataBlock(pOperator, pExpSupp->pCtx, pBlock, iaInfo->inputOrder, scanFlag, true);
doMergeIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes);
if (pRes->info.rows >= pOperator->resultInfo.threshold) {
@ -5025,9 +5054,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI
miaInfo->groupIntervals = tdListNew(sizeof(SGroupTimeWindow));
SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo;
iaInfo->win = pTaskInfo->window;
iaInfo->order = TSDB_ORDER_ASC;
iaInfo->inputOrder = TSDB_ORDER_ASC;
iaInfo->interval = *pInterval;
iaInfo->execModel = pTaskInfo->execModel;

View File

@ -2083,7 +2083,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.name = "apercentile",
.type = FUNCTION_TYPE_APERCENTILE,
.classification = FUNC_MGT_AGG_FUNC,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC,
.translateFunc = translateApercentile,
.getEnvFunc = getApercentileFuncEnv,
.initFunc = apercentileFunctionSetup,
@ -2098,7 +2098,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
},
{
.name = "_apercentile_partial",
.type = FUNCTION_TYPE_APERCENTILE_PARTIAL,
.type = FUNCTION_TYPE_APERCENTILE_PARTIAL | FUNC_MGT_TIMELINE_FUNC,
.classification = FUNC_MGT_AGG_FUNC,
.translateFunc = translateApercentilePartial,
.getEnvFunc = getApercentileFuncEnv,
@ -2111,7 +2111,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.name = "_apercentile_merge",
.type = FUNCTION_TYPE_APERCENTILE_MERGE,
.classification = FUNC_MGT_AGG_FUNC,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC,
.translateFunc = translateApercentileMerge,
.getEnvFunc = getApercentileFuncEnv,
.initFunc = apercentileFunctionSetup,
@ -2374,7 +2374,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.name = "histogram",
.type = FUNCTION_TYPE_HISTOGRAM,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC,
.translateFunc = translateHistogram,
.getEnvFunc = getHistogramFuncEnv,
.initFunc = histogramFunctionSetup,
@ -2389,7 +2389,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.name = "_histogram_partial",
.type = FUNCTION_TYPE_HISTOGRAM_PARTIAL,
.classification = FUNC_MGT_AGG_FUNC,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC,
.translateFunc = translateHistogramPartial,
.getEnvFunc = getHistogramFuncEnv,
.initFunc = histogramFunctionSetup,
@ -2401,7 +2401,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.name = "_histogram_merge",
.type = FUNCTION_TYPE_HISTOGRAM_MERGE,
.classification = FUNC_MGT_AGG_FUNC,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_MULTI_ROWS_FUNC | FUNC_MGT_FORBID_FILL_FUNC,
.translateFunc = translateHistogramMerge,
.getEnvFunc = getHistogramFuncEnv,
.initFunc = functionSetup,

View File

@ -443,6 +443,7 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p
COPY_SCALAR_FIELD(igExpired);
COPY_SCALAR_FIELD(windowAlgo);
COPY_SCALAR_FIELD(inputTsOrder);
COPY_SCALAR_FIELD(outputTsOrder);
return TSDB_CODE_SUCCESS;
}
@ -452,6 +453,7 @@ static int32_t logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) {
CLONE_NODE_FIELD(pWStartTs);
CLONE_NODE_FIELD(pValues);
COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow));
COPY_SCALAR_FIELD(inputTsOrder);
return TSDB_CODE_SUCCESS;
}

View File

@ -1936,6 +1936,8 @@ static const char* jkWindowPhysiPlanTsEnd = "TsEnd";
static const char* jkWindowPhysiPlanTriggerType = "TriggerType";
static const char* jkWindowPhysiPlanWatermark = "Watermark";
static const char* jkWindowPhysiPlanIgnoreExpired = "IgnoreExpired";
static const char* jkWindowPhysiPlanInputTsOrder = "inputTsOrder";
static const char* jkWindowPhysiPlanOutputTsOrder = "outputTsOrder";
static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
const SWinodwPhysiNode* pNode = (const SWinodwPhysiNode*)pObj;
@ -1962,6 +1964,12 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanIgnoreExpired, pNode->igExpired);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanInputTsOrder, pNode->inputTsOrder);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkWindowPhysiPlanOutputTsOrder, pNode->outputTsOrder);
}
return code;
}
@ -1991,6 +1999,12 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetTinyIntValue(pJson, jkWindowPhysiPlanIgnoreExpired, &pNode->igExpired);
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkWindowPhysiPlanInputTsOrder, pNode->inputTsOrder, code);
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkWindowPhysiPlanOutputTsOrder, pNode->outputTsOrder, code);
}
return code;
}
@ -2053,6 +2067,7 @@ static const char* jkFillPhysiPlanValues = "Values";
static const char* jkFillPhysiPlanTargets = "Targets";
static const char* jkFillPhysiPlanStartTime = "StartTime";
static const char* jkFillPhysiPlanEndTime = "EndTime";
static const char* jkFillPhysiPlanInputTsOrder = "inputTsOrder";
static int32_t physiFillNodeToJson(const void* pObj, SJson* pJson) {
const SFillPhysiNode* pNode = (const SFillPhysiNode*)pObj;
@ -2076,6 +2091,9 @@ static int32_t physiFillNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkFillPhysiPlanEndTime, pNode->timeRange.ekey);
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkFillPhysiPlanInputTsOrder, pNode->inputTsOrder);
}
return code;
}
@ -2103,6 +2121,9 @@ static int32_t jsonToPhysiFillNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBigIntValue(pJson, jkFillPhysiPlanEndTime, &pNode->timeRange.ekey);
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkFillPhysiPlanInputTsOrder, pNode->inputTsOrder, code);
}
return code;
}

View File

@ -34,6 +34,7 @@ typedef struct STranslateContext {
SMsgBuf msgBuf;
SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode*
int32_t currLevel;
int32_t levelNo;
ESqlClause currClause;
SNode* pCurrStmt;
SCmdMsgInfo* pCmdMsg;
@ -354,6 +355,7 @@ static int32_t initTranslateContext(SParseContext* pParseCxt, SParseMetaCache* p
pCxt->msgBuf.len = pParseCxt->msgLen;
pCxt->pNsLevel = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES);
pCxt->currLevel = 0;
pCxt->levelNo = 0;
pCxt->currClause = 0;
pCxt->pMetaCache = pMetaCache;
pCxt->pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
@ -1871,7 +1873,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name),
&(pRealTable->pMeta));
if (TSDB_CODE_SUCCESS != code) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pRealTable->table.tableName);
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
}
code = setTableVgroupList(pCxt, &name, pRealTable);
if (TSDB_CODE_SUCCESS == code) {
@ -4977,13 +4979,14 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
}
static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
++(pCxt->currLevel);
ESqlClause currClause = pCxt->currClause;
SNode* pCurrStmt = pCxt->pCurrStmt;
int32_t currLevel = pCxt->currLevel;
pCxt->currLevel = ++(pCxt->levelNo);
int32_t code = translateQuery(pCxt, pNode);
--(pCxt->currLevel);
pCxt->currClause = currClause;
pCxt->pCurrStmt = pCurrStmt;
pCxt->currLevel = currLevel;
return code;
}

View File

@ -31,6 +31,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return "Invalid column name: %s";
case TSDB_CODE_PAR_TABLE_NOT_EXIST:
return "Table does not exist: %s";
case TSDB_CODE_PAR_GET_META_ERROR:
return "Fail to get table info, error: %s";
case TSDB_CODE_PAR_AMBIGUOUS_COLUMN:
return "Column ambiguously defined: %s";
case TSDB_CODE_PAR_WRONG_VALUE_TYPE:

View File

@ -341,11 +341,12 @@ TEST_F(ParserSelectTest, semanticCheck) {
run("SELECT t1.c1, t1.cc1 FROM t1", TSDB_CODE_PAR_INVALID_COLUMN);
// TSDB_CODE_PAR_GET_META_ERROR
run("SELECT * FROM t10", TSDB_CODE_PAR_GET_META_ERROR);
run("SELECT * FROM test.t10", TSDB_CODE_PAR_GET_META_ERROR);
// TSDB_CODE_PAR_TABLE_NOT_EXIST
run("SELECT * FROM t10", TSDB_CODE_PAR_TABLE_NOT_EXIST);
run("SELECT * FROM test.t10", TSDB_CODE_PAR_TABLE_NOT_EXIST);
run("SELECT t2.c1 FROM t1", TSDB_CODE_PAR_TABLE_NOT_EXIST);
// TSDB_CODE_PAR_AMBIGUOUS_COLUMN

View File

@ -632,6 +632,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
pWindow->igExpired = pCxt->pPlanCxt->igExpired;
}
pWindow->inputTsOrder = ORDER_ASC;
pWindow->outputTsOrder = ORDER_ASC;
int32_t code = nodesCollectFuncs(pSelect, SQL_CLAUSE_WINDOW, fmIsWindowClauseFunc, &pWindow->pFuncs);
if (TSDB_CODE_SUCCESS == code) {
@ -764,6 +765,7 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
pFill->node.groupAction = GROUP_ACTION_KEEP;
pFill->node.requireDataOrder = DATA_ORDER_LEVEL_IN_GROUP;
pFill->node.resultDataOrder = DATA_ORDER_LEVEL_IN_GROUP;
pFill->inputTsOrder = ORDER_ASC;
int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_WINDOW, NULL, COLLECT_COL_TYPE_ALL, &pFill->node.pTargets);
if (TSDB_CODE_SUCCESS == code && NULL == pFill->node.pTargets) {
@ -1229,6 +1231,7 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
// set columns to scan
if (TSDB_CODE_SUCCESS == code) {
pScan->scanType = SCAN_TYPE_TABLE;
pScan->scanRange = pDelete->timeRange;
pScan->pScanCols = nodesCloneList(((SFunctionNode*)pDelete->pCountFunc)->pParameterList);
if (NULL == pScan->pScanCols) {
code = TSDB_CODE_OUT_OF_MEMORY;

View File

@ -38,10 +38,13 @@ typedef struct SOptimizeRule {
FOptimize optimizeFunc;
} SOptimizeRule;
typedef enum EScanOrder { SCAN_ORDER_ASC = 1, SCAN_ORDER_DESC, SCAN_ORDER_BOTH } EScanOrder;
typedef struct SOsdInfo {
SScanLogicNode* pScan;
SNodeList* pSdrFuncs;
SNodeList* pDsoFuncs;
EScanOrder scanOrder;
} SOsdInfo;
typedef struct SCpdIsMultiTableCondCxt {
@ -97,6 +100,27 @@ static EDealRes optRebuildTbanme(SNode** pNode, void* pContext) {
return DEAL_RES_CONTINUE;
}
static void optSetParentOrder(SLogicNode* pNode, EOrder order) {
if (NULL == pNode) {
return;
}
switch (nodeType(pNode)) {
case QUERY_NODE_LOGIC_PLAN_WINDOW:
((SWindowLogicNode*)pNode)->inputTsOrder = order;
// window has a sorting function, and the operator behind it uses its output order
return;
case QUERY_NODE_LOGIC_PLAN_JOIN:
((SJoinLogicNode*)pNode)->inputTsOrder = order;
break;
case QUERY_NODE_LOGIC_PLAN_FILL:
((SFillLogicNode*)pNode)->inputTsOrder = order;
break;
default:
break;
}
optSetParentOrder(pNode->pParent, order);
}
EDealRes scanPathOptHaveNormalColImpl(SNode* pNode, void* pContext) {
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
// *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType);
@ -179,16 +203,18 @@ static int32_t scanPathOptGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSd
SNodeList* pAllFuncs = scanPathOptGetAllFuncs(pScan->node.pParent);
SNodeList* pTmpSdrFuncs = NULL;
SNodeList* pTmpDsoFuncs = NULL;
SNode* pFunc = NULL;
SNode* pNode = NULL;
bool otherFunc = false;
FOREACH(pFunc, pAllFuncs) {
int32_t code = TSDB_CODE_SUCCESS;
if (scanPathOptNeedOptimizeDataRequire((SFunctionNode*)pFunc)) {
code = nodesListMakeStrictAppend(&pTmpSdrFuncs, nodesCloneNode(pFunc));
} else if (scanPathOptNeedDynOptimize((SFunctionNode*)pFunc)) {
code = nodesListMakeStrictAppend(&pTmpDsoFuncs, nodesCloneNode(pFunc));
FOREACH(pNode, pAllFuncs) {
SFunctionNode* pFunc = (SFunctionNode*)pNode;
int32_t code = TSDB_CODE_SUCCESS;
if (scanPathOptNeedOptimizeDataRequire(pFunc)) {
code = nodesListMakeStrictAppend(&pTmpSdrFuncs, nodesCloneNode(pNode));
} else if (scanPathOptNeedDynOptimize(pFunc)) {
code = nodesListMakeStrictAppend(&pTmpDsoFuncs, nodesCloneNode(pNode));
} else {
otherFunc = true;
break;
}
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyList(pTmpSdrFuncs);
@ -206,12 +232,46 @@ static int32_t scanPathOptGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSd
return TSDB_CODE_SUCCESS;
}
static int32_t scanPathOptGetScanOrder(SScanLogicNode* pScan, EScanOrder* pScanOrder) {
SNodeList* pAllFuncs = scanPathOptGetAllFuncs(pScan->node.pParent);
SNode* pNode = NULL;
bool hasFirst = false;
bool hasLast = false;
bool otherFunc = false;
FOREACH(pNode, pAllFuncs) {
SFunctionNode* pFunc = (SFunctionNode*)pNode;
if (FUNCTION_TYPE_FIRST == pFunc->funcType) {
hasFirst = true;
} else if (FUNCTION_TYPE_LAST == pFunc->funcType) {
hasLast = true;
} else if (FUNCTION_TYPE_SELECT_VALUE != pFunc->funcType) {
otherFunc = true;
}
}
if (hasFirst && hasLast && !otherFunc) {
*pScanOrder = SCAN_ORDER_BOTH;
} else if (hasLast) {
*pScanOrder = SCAN_ORDER_DESC;
} else {
*pScanOrder = SCAN_ORDER_ASC;
}
return TSDB_CODE_SUCCESS;
}
static int32_t scanPathOptSetOsdInfo(SOsdInfo* pInfo) {
int32_t code = scanPathOptGetRelatedFuncs(pInfo->pScan, &pInfo->pSdrFuncs, &pInfo->pDsoFuncs);
if (TSDB_CODE_SUCCESS == code) {
code = scanPathOptGetScanOrder(pInfo->pScan, &pInfo->scanOrder);
}
return code;
}
static int32_t scanPathOptMatch(SOptimizeContext* pCxt, SLogicNode* pLogicNode, SOsdInfo* pInfo) {
pInfo->pScan = (SScanLogicNode*)optFindPossibleNode(pLogicNode, scanPathOptMayBeOptimized);
if (NULL == pInfo->pScan) {
return TSDB_CODE_SUCCESS;
}
return scanPathOptGetRelatedFuncs(pInfo->pScan, &pInfo->pSdrFuncs, &pInfo->pDsoFuncs);
return scanPathOptSetOsdInfo(pInfo);
}
static EFuncDataRequired scanPathOptPromoteDataRequired(EFuncDataRequired l, EFuncDataRequired r) {
@ -258,15 +318,42 @@ static void scanPathOptSetScanWin(SScanLogicNode* pScan) {
}
}
static void scanPathOptSetScanOrder(EScanOrder scanOrder, SScanLogicNode* pScan) {
if (pScan->sortPrimaryKey || pScan->scanSeq[0] > 1 || pScan->scanSeq[1] > 1) {
return;
}
switch (scanOrder) {
case SCAN_ORDER_ASC:
pScan->scanSeq[0] = 1;
pScan->scanSeq[1] = 0;
optSetParentOrder(pScan->node.pParent, ORDER_ASC);
break;
case SCAN_ORDER_DESC:
pScan->scanSeq[0] = 0;
pScan->scanSeq[1] = 1;
optSetParentOrder(pScan->node.pParent, ORDER_DESC);
break;
case SCAN_ORDER_BOTH:
pScan->scanSeq[0] = 1;
pScan->scanSeq[1] = 1;
break;
default:
break;
}
}
static int32_t scanPathOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) {
SOsdInfo info = {0};
SOsdInfo info = {.scanOrder = SCAN_ORDER_ASC};
int32_t code = scanPathOptMatch(pCxt, pLogicSubplan->pNode, &info);
if (TSDB_CODE_SUCCESS == code && info.pScan) {
scanPathOptSetScanWin((SScanLogicNode*)info.pScan);
scanPathOptSetScanWin(info.pScan);
scanPathOptSetScanOrder(info.scanOrder, info.pScan);
}
if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) {
info.pScan->dataRequired = scanPathOptGetDataRequired(info.pSdrFuncs);
info.pScan->pDynamicScanFuncs = info.pDsoFuncs;
}
if (TSDB_CODE_SUCCESS == code && info.pScan) {
OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_SCAN_PATH);
pCxt->optimized = true;
}
@ -987,12 +1074,13 @@ static bool sortPriKeyOptMayBeOptimized(SLogicNode* pNode) {
}
SSortLogicNode* pSort = (SSortLogicNode*)pNode;
if (pSort->groupSort || !sortPriKeyOptIsPriKeyOrderBy(pSort->pSortKeys) || 1 != LIST_LENGTH(pSort->node.pChildren)) {
return TSDB_CODE_SUCCESS;
return false;
}
return true;
}
static int32_t sortPriKeyOptGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeList** pScanNodes) {
static int32_t sortPriKeyOptGetSequencingNodesImpl(SLogicNode* pNode, bool* pNotOptimize,
SNodeList** pSequencingNodes) {
switch (nodeType(pNode)) {
case QUERY_NODE_LOGIC_PLAN_SCAN: {
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
@ -1000,17 +1088,19 @@ static int32_t sortPriKeyOptGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimi
*pNotOptimize = true;
return TSDB_CODE_SUCCESS;
}
return nodesListMakeAppend(pScanNodes, (SNode*)pNode);
return nodesListMakeAppend(pSequencingNodes, (SNode*)pNode);
}
case QUERY_NODE_LOGIC_PLAN_JOIN: {
int32_t code =
sortPriKeyOptGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes);
int32_t code = sortPriKeyOptGetSequencingNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0),
pNotOptimize, pSequencingNodes);
if (TSDB_CODE_SUCCESS == code) {
code =
sortPriKeyOptGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 1), pNotOptimize, pScanNodes);
code = sortPriKeyOptGetSequencingNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 1), pNotOptimize,
pSequencingNodes);
}
return code;
}
case QUERY_NODE_LOGIC_PLAN_WINDOW:
return nodesListMakeAppend(pSequencingNodes, (SNode*)pNode);
case QUERY_NODE_LOGIC_PLAN_AGG:
case QUERY_NODE_LOGIC_PLAN_PARTITION:
*pNotOptimize = true;
@ -1024,14 +1114,15 @@ static int32_t sortPriKeyOptGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimi
return TSDB_CODE_SUCCESS;
}
return sortPriKeyOptGetScanNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize, pScanNodes);
return sortPriKeyOptGetSequencingNodesImpl((SLogicNode*)nodesListGetNode(pNode->pChildren, 0), pNotOptimize,
pSequencingNodes);
}
static int32_t sortPriKeyOptGetScanNodes(SLogicNode* pNode, SNodeList** pScanNodes) {
static int32_t sortPriKeyOptGetSequencingNodes(SLogicNode* pNode, SNodeList** pSequencingNodes) {
bool notOptimize = false;
int32_t code = sortPriKeyOptGetScanNodesImpl(pNode, &notOptimize, pScanNodes);
int32_t code = sortPriKeyOptGetSequencingNodesImpl(pNode, &notOptimize, pSequencingNodes);
if (TSDB_CODE_SUCCESS != code || notOptimize) {
nodesClearList(*pScanNodes);
nodesClearList(*pSequencingNodes);
}
return code;
}
@ -1040,33 +1131,26 @@ static EOrder sortPriKeyOptGetPriKeyOrder(SSortLogicNode* pSort) {
return ((SOrderByExprNode*)nodesListGetNode(pSort->pSortKeys, 0))->order;
}
static void sortPriKeyOptSetParentOrder(SLogicNode* pNode, EOrder order) {
if (NULL == pNode) {
return;
}
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode)) {
((SWindowLogicNode*)pNode)->inputTsOrder = order;
} else if (QUERY_NODE_LOGIC_PLAN_JOIN == nodeType(pNode)) {
((SJoinLogicNode*)pNode)->inputTsOrder = order;
}
sortPriKeyOptSetParentOrder(pNode->pParent, order);
}
static int32_t sortPriKeyOptApply(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SSortLogicNode* pSort,
SNodeList* pScanNodes) {
SNodeList* pSequencingNodes) {
EOrder order = sortPriKeyOptGetPriKeyOrder(pSort);
SNode* pScanNode = NULL;
FOREACH(pScanNode, pScanNodes) {
SScanLogicNode* pScan = (SScanLogicNode*)pScanNode;
if (ORDER_DESC == order && pScan->scanSeq[0] > 0) {
TSWAP(pScan->scanSeq[0], pScan->scanSeq[1]);
SNode* pSequencingNode = NULL;
FOREACH(pSequencingNode, pSequencingNodes) {
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pSequencingNode)) {
SScanLogicNode* pScan = (SScanLogicNode*)pSequencingNode;
if ((ORDER_DESC == order && pScan->scanSeq[0] > 0) || (ORDER_ASC == order && pScan->scanSeq[1] > 0)) {
TSWAP(pScan->scanSeq[0], pScan->scanSeq[1]);
}
if (TSDB_SUPER_TABLE == pScan->tableType) {
pScan->scanType = SCAN_TYPE_TABLE_MERGE;
pScan->node.resultDataOrder = DATA_ORDER_LEVEL_GLOBAL;
pScan->node.requireDataOrder = DATA_ORDER_LEVEL_GLOBAL;
}
pScan->sortPrimaryKey = true;
} else if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pSequencingNode)) {
((SWindowLogicNode*)pSequencingNode)->outputTsOrder = order;
}
if (TSDB_SUPER_TABLE == pScan->tableType) {
pScan->scanType = SCAN_TYPE_TABLE_MERGE;
pScan->node.resultDataOrder = DATA_ORDER_LEVEL_GLOBAL;
pScan->node.requireDataOrder = DATA_ORDER_LEVEL_GLOBAL;
}
sortPriKeyOptSetParentOrder(pScan->node.pParent, order);
optSetParentOrder(((SLogicNode*)pSequencingNode)->pParent, order);
}
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0);
@ -1083,12 +1167,13 @@ static int32_t sortPriKeyOptApply(SOptimizeContext* pCxt, SLogicSubplan* pLogicS
}
static int32_t sortPrimaryKeyOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SSortLogicNode* pSort) {
SNodeList* pScanNodes = NULL;
int32_t code = sortPriKeyOptGetScanNodes((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0), &pScanNodes);
if (TSDB_CODE_SUCCESS == code && NULL != pScanNodes) {
code = sortPriKeyOptApply(pCxt, pLogicSubplan, pSort, pScanNodes);
SNodeList* pSequencingNodes = NULL;
int32_t code =
sortPriKeyOptGetSequencingNodes((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0), &pSequencingNodes);
if (TSDB_CODE_SUCCESS == code && NULL != pSequencingNodes) {
code = sortPriKeyOptApply(pCxt, pLogicSubplan, pSort, pSequencingNodes);
}
nodesClearList(pScanNodes);
nodesClearList(pSequencingNodes);
return code;
}

View File

@ -1089,6 +1089,8 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
pWindow->triggerType = pWindowLogicNode->triggerType;
pWindow->watermark = pWindowLogicNode->watermark;
pWindow->igExpired = pWindowLogicNode->igExpired;
pWindow->inputTsOrder = pWindowLogicNode->inputTsOrder;
pWindow->outputTsOrder = pWindowLogicNode->outputTsOrder;
SNodeList* pPrecalcExprs = NULL;
SNodeList* pFuncs = NULL;
@ -1363,6 +1365,7 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
pFill->mode = pFillNode->mode;
pFill->timeRange = pFillNode->timeRange;
pFill->inputTsOrder = pFillNode->inputTsOrder;
SDataBlockDescNode* pChildTupe = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc);
int32_t code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pFillNode->node.pTargets, &pFill->pTargets);

View File

@ -492,7 +492,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo
((SWindowLogicNode*)pInfo->pSplitNode)->windowAlgo = INTERVAL_ALGO_MERGE;
SNodeList* pMergeKeys = NULL;
code = stbSplCreateMergeKeysByPrimaryKey(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk,
((SWindowLogicNode*)pInfo->pSplitNode)->inputTsOrder, &pMergeKeys);
((SWindowLogicNode*)pInfo->pSplitNode)->outputTsOrder, &pMergeKeys);
if (TSDB_CODE_SUCCESS == code) {
code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, pMergeKeys, pPartWindow, true);
}

View File

@ -30,6 +30,11 @@ TEST_F(PlanOptimizeTest, scanPath) {
run("SELECT COUNT(CAST(c1 AS BIGINT)) FROM t1");
run("SELECT PERCENTILE(c1, 40), COUNT(*) FROM t1");
run("SELECT LAST(c1) FROM t1");
run("SELECT LAST(c1) FROM t1 WHERE ts BETWEEN '2022-7-29 11:10:10' AND '2022-7-30 11:10:10' INTERVAL(10S) "
"FILL(LINEAR)");
}
TEST_F(PlanOptimizeTest, pushDownCondition) {
@ -57,7 +62,15 @@ TEST_F(PlanOptimizeTest, sortPrimaryKey) {
run("SELECT c1 FROM t1 ORDER BY ts DESC");
run("SELECT c1 FROM st1 ORDER BY ts DESC");
run("SELECT COUNT(*) FROM t1 INTERVAL(10S) ORDER BY _WSTART DESC");
run("SELECT FIRST(c1) FROM t1 WHERE ts BETWEEN '2022-7-29 11:10:10' AND '2022-7-30 11:10:10' INTERVAL(10S) "
"FILL(LINEAR) ORDER BY _WSTART DESC");
run("SELECT LAST(c1) FROM t1 WHERE ts BETWEEN '2022-7-29 11:10:10' AND '2022-7-30 11:10:10' INTERVAL(10S) "
"FILL(LINEAR) ORDER BY _WSTART");
}
TEST_F(PlanOptimizeTest, PartitionTags) {

View File

@ -916,7 +916,7 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq
qDebug("job not initialized or not executable job, refId:0x%" PRIx64, pJob->refId);
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
}
break;
return TSDB_CODE_SUCCESS;
default:
SCH_JOB_ELOG("unknown operation type %d", type);
SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR);

View File

@ -513,7 +513,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
msgSendInfo->paramFreeFp = taosMemoryFree;
msgSendInfo->paramFreeFp = taosMemoryFree;
SCH_ERR_JRET(schMakeCallbackParam(pJob, pTask, msgType, isHb, trans, &msgSendInfo->param));
SCH_ERR_JRET(schGetCallbackFp(msgType, &msgSendInfo->fp));
@ -541,7 +541,7 @@ _return:
}
taosMemoryFree(msg);
SCH_RET(code);
}
@ -681,7 +681,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
param->pTrans = pJob->conn.pTrans;
pMsgSendInfo->param = param;
pMsgSendInfo->paramFreeFp = taosMemoryFree;
pMsgSendInfo->paramFreeFp = taosMemoryFree;
pMsgSendInfo->fp = fp;
SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo};
@ -801,7 +801,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) {
pDst->param = NULL;
SCH_ERR_JRET(schCloneCallbackParam(pSrc->param, (SSchCallbackParamHeader **)&pDst->param));
pDst->paramFreeFp = taosMemoryFree;
pDst->paramFreeFp = taosMemoryFree;
*dst = pDst;
@ -1094,14 +1094,29 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
break;
}
#if 1
SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)};
schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL));
msg = NULL;
SCH_ERR_JRET(code);
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) {
SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId));
}
#else
if (TDMT_VND_SUBMIT != msgType) {
SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)};
schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL));
msg = NULL;
SCH_ERR_JRET(code);
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) {
SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId));
}
} else {
SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask));
}
#endif
return TSDB_CODE_SUCCESS;

View File

@ -41,7 +41,7 @@ target_link_libraries(
)
if(TD_WINDOWS)
target_link_libraries(
os PUBLIC ws2_32 iconv msvcregex wcwidth winmm
os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump
)
elseif(TD_DARWIN_64)
target_link_libraries(

View File

@ -91,6 +91,7 @@ LONG WINAPI FlCrashDump(PEXCEPTION_POINTERS ep) {
return EXCEPTION_CONTINUE_SEARCH;
}
LONG WINAPI exceptionHandler(LPEXCEPTION_POINTERS exception);
#elif defined(_TD_DARWIN_64)
@ -841,7 +842,8 @@ char *taosGetCmdlineByPID(int pid) {
void taosSetCoreDump(bool enable) {
#ifdef WINDOWS
SetUnhandledExceptionFilter(&FlCrashDump);
// SetUnhandledExceptionFilter(exceptionHandler);
// SetUnhandledExceptionFilter(&FlCrashDump);
#elif defined(_TD_DARWIN_64)
#else
if (!enable) return;

View File

@ -18,6 +18,63 @@
#include "os.h"
#if defined(WINDOWS)
typedef void (*MainWindows)(int argc,char** argv);
MainWindows mainWindowsFunc = NULL;
SERVICE_STATUS ServiceStatus;
SERVICE_STATUS_HANDLE hServiceStatusHandle;
void WINAPI windowsServiceCtrlHandle(DWORD request) {
switch (request) {
case SERVICE_CONTROL_STOP:
case SERVICE_CONTROL_SHUTDOWN:
raise(SIGINT);
ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
DWORD nError = GetLastError();
printf("failed to send stopped status to windows service: %d",nError);
}
break;
default:
return;
}
}
void WINAPI mainWindowsService(int argc,char** argv) {
int ret = 0;
ServiceStatus.dwServiceType = SERVICE_WIN32;
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
ServiceStatus.dwServiceSpecificExitCode = 0;
hServiceStatusHandle = RegisterServiceCtrlHandler("taosd", &windowsServiceCtrlHandle);
if (hServiceStatusHandle == 0) {
DWORD nError = GetLastError();
printf("failed to register windows service ctrl handler: %d",nError);
}
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
if (SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
DWORD nError = GetLastError();
printf("failed to send running status to windows service: %d",nError);
}
if (mainWindowsFunc != NULL) mainWindowsFunc(argc, argv);
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
DWORD nError = GetLastError();
printf("failed to send stopped status to windows service: %d",nError);
}
}
void stratWindowsService(MainWindows mainWindows) {
mainWindowsFunc = mainWindows;
SERVICE_TABLE_ENTRY ServiceTable[2];
ServiceTable[0].lpServiceName = "taosd";
ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)mainWindowsService;
ServiceTable[1].lpServiceName = NULL;
ServiceTable[1].lpServiceProc = NULL;
StartServiceCtrlDispatcher(ServiceTable);
}
#elif defined(_TD_DARWIN_64)
#else
#include <dlfcn.h>

View File

@ -559,6 +559,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN, "Not valid function
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE, "Only support single table")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_SMA_INDEX, "Invalid sma index")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_SELECTED_EXPR, "Invalid SELECTed expression")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GET_META_ERROR, "Fail to get table info")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error")
//planner

View File

@ -82,7 +82,7 @@ int64_t tsNumOfTraceLogs = 0;
// log
int32_t dDebugFlag = 135;
int32_t vDebugFlag = 135;
int32_t mDebugFlag = 131;
int32_t mDebugFlag = 135;
int32_t cDebugFlag = 131;
int32_t jniDebugFlag = 131;
int32_t tmrDebugFlag = 131;

View File

@ -489,7 +489,7 @@ class TDDnode:
onlyKillOnceWindows = 0
while(processID):
if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'):
killCmd = "kill -4 %s > /dev/null 2>&1" % processID
killCmd = "kill -INT %s > /dev/null 2>&1" % processID
os.system(killCmd)
onlyKillOnceWindows = 1
time.sleep(1)
@ -503,7 +503,7 @@ class TDDnode:
time.sleep(2)
self.running = 0
tdLog.debug("dnode:%d is stopped by kill -4" % (self.index))
tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index))
def stoptaosd(self):
@ -527,7 +527,7 @@ class TDDnode:
onlyKillOnceWindows = 0
while(processID):
if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'):
killCmd = "kill -4 %s > /dev/null 2>&1" % processID
killCmd = "kill -INT %s > /dev/null 2>&1" % processID
os.system(killCmd)
onlyKillOnceWindows = 1
time.sleep(1)
@ -537,7 +537,7 @@ class TDDnode:
time.sleep(2)
self.running = 0
tdLog.debug("dnode:%d is stopped by kill -4" % (self.index))
tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index))
def forcestop(self):
if (not self.remoteIP == ""):

View File

@ -89,15 +89,22 @@
./test.sh -f tsim/parser/alter_column.sim
./test.sh -f tsim/parser/alter_stable.sim
./test.sh -f tsim/parser/alter.sim
# TD-17661 ./test.sh -f tsim/parser/alter1.sim
# TD-17959 ./test.sh -f tsim/parser/alter1.sim
./test.sh -f tsim/parser/auto_create_tb_drop_tb.sim
./test.sh -f tsim/parser/auto_create_tb.sim
./test.sh -f tsim/parser/between_and.sim
./test.sh -f tsim/parser/binary_escapeCharacter.sim
# TD-17738 ./test.sh -f tsim/parser/col_arithmetic_operation.sim
# TD-17661 ./test.sh -f tsim/parser/columnValue.sim
./test.sh -f tsim/parser/col_arithmetic_operation.sim
./test.sh -f tsim/parser/columnValue_bigint.sim
./test.sh -f tsim/parser/columnValue_bool.sim
./test.sh -f tsim/parser/columnValue_double.sim
./test.sh -f tsim/parser/columnValue_float.sim
./test.sh -f tsim/parser/columnValue_int.sim
./test.sh -f tsim/parser/columnValue_smallint.sim
./test.sh -f tsim/parser/columnValue_tinyint.sim
./test.sh -f tsim/parser/columnValue_unsign.sim
./test.sh -f tsim/parser/commit.sim
# TD-17661 ./test.sh -f tsim/parser/condition.sim
./test.sh -f tsim/parser/condition.sim
./test.sh -f tsim/parser/constCol.sim
#./test.sh -f tsim/parser/create_db.sim
./test.sh -f tsim/parser/create_mt.sim
@ -145,7 +152,7 @@
./test.sh -f tsim/parser/select_across_vnodes.sim
./test.sh -f tsim/parser/select_distinct_tag.sim
./test.sh -f tsim/parser/select_from_cache_disk.sim
# TD-17832 ./test.sh -f tsim/parser/select_with_tags.sim
./test.sh -f tsim/parser/select_with_tags.sim
./test.sh -f tsim/parser/selectResNum.sim
./test.sh -f tsim/parser/set_tag_vals.sim
./test.sh -f tsim/parser/single_row_in_tb.sim
@ -154,15 +161,15 @@
./test.sh -f tsim/parser/slimit.sim
./test.sh -f tsim/parser/slimit1.sim
./test.sh -f tsim/parser/stableOp.sim
# TD-17661 ./test.sh -f tsim/parser/tags_dynamically_specifiy.sim
# TD-17661 ./test.sh -f tsim/parser/tags_filter.sim
./test.sh -f tsim/parser/tags_dynamically_specifiy.sim
./test.sh -f tsim/parser/tags_filter.sim
./test.sh -f tsim/parser/tbnameIn.sim
./test.sh -f tsim/parser/timestamp.sim
./test.sh -f tsim/parser/top_groupby.sim
./test.sh -f tsim/parser/topbot.sim
./test.sh -f tsim/parser/union.sim
# TD-17704 ./test.sh -f tsim/parser/union_sysinfo.sim
# TD-17661 ./test.sh -f tsim/parser/where.sim
./test.sh -f tsim/parser/union_sysinfo.sim
./test.sh -f tsim/parser/where.sim
# ---- query ----
./test.sh -f tsim/query/charScalarFunction.sim
@ -422,18 +429,18 @@
./test.sh -f tsim/tag/bool_binary.sim
./test.sh -f tsim/tag/bool_int.sim
./test.sh -f tsim/tag/bool.sim
# TD-17661 ./test.sh -f tsim/tag/change.sim
# TD-17407 ./test.sh -f tsim/tag/change.sim
./test.sh -f tsim/tag/column.sim
./test.sh -f tsim/tag/commit.sim
# TD-17661 ./test.sh -f tsim/tag/create.sim
# TD-17661 ./test.sh -f tsim/tag/delete.sim
# TD-17661 ./test.sh -f tsim/tag/double.sim
# TD-17661 ./test.sh -f tsim/tag/filter.sim
# TD-17407 ./test.sh -f tsim/tag/create.sim
# TD-17407 ./test.sh -f tsim/tag/delete.sim
# TD-17407 ./test.sh -f tsim/tag/double.sim
./test.sh -f tsim/tag/filter.sim
# TD-17407 ./test.sh -f tsim/tag/float.sim
./test.sh -f tsim/tag/int_binary.sim
./test.sh -f tsim/tag/int_float.sim
./test.sh -f tsim/tag/int.sim
# TD-17661 ./test.sh -f tsim/tag/set.sim
# TD-17959 ./test.sh -f tsim/tag/set.sim
./test.sh -f tsim/tag/smallint.sim
./test.sh -f tsim/tag/tinyint.sim

View File

@ -24,14 +24,20 @@ sql alter dnode 1 'fsDebugFlag 131'
sql alter dnode 1 'udfDebugFlag 131'
sql alter dnode 1 'smaDebugFlag 131'
sql alter dnode 1 'idxDebugFlag 131'
sql alter dnode 1 'tdbDebugFlag 131'
sql alter dnode 1 'tmrDebugFlag 131'
sql alter dnode 1 'uDebugFlag 131'
sql alter dnode 1 'smaDebugFlag 131'
sql alter dnode 1 'rpcDebugFlag 131'
sql alter dnode 1 'qDebugFlag 131'
sql alter dnode 1 'metaDebugFlag 131'
sql_error alter dnode 2 'wDebugFlag 135'
sql_error alter dnode 2 'tmrDebugFlag 135'
sql_error alter dnode 1 'monDebugFlag 131'
sql_error alter dnode 1 'cqDebugFlag 131'
sql_error alter dnode 1 'httpDebugFlag 131'
sql_error alter dnode 1 'mqttDebugFlag 131'
print ======== step3
sql_error alter $hostname1 debugFlag 135

View File

@ -103,7 +103,7 @@ endi
print ================== change a tag value
sql alter table car1 set tag carid=10
sql select carId, carmodel from car1
sql select distinct carId, carmodel from car1
if $rows != 1 then
return -1
endi

View File

@ -131,20 +131,5 @@ sql_error select max(c1-c2) from $tb
#========================================regression test cases====================================
print =====================> td-1764
sql select sum(c1)/count(*), sum(c1) as b, count(*) as b from $stb interval(1y)
if $rows != 1 then
return -1
endi
if $data00 != @18-01-01 00:00:00.000@ then
return -1
endi
if $data01 != 2.250000000 then
return -1
endi
if $data02 != 225000 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -511,24 +511,21 @@ if $rows != 1 then
endi
# slimit/soffset not support for normal table query. [d.11]===============================================================
sql select sum(c1) from $stb slimit 1 soffset 19;
if $rows != 0 then
return -1
endi
sql_error select sum(c1) from $stb slimit 1 soffset 19;
sql select sum(c1) from $stb interval(1s) group by tbname slimit 1 soffset 1
sql select sum(c1) from ca_stb0 interval(1s) group by tbname slimit 2 soffset 4 limit 10 offset 1
sql select sum(c1) from ca_stb0 partition by tbname interval(1s) slimit 1 soffset 1
sql select sum(c1) from ca_stb0 partition by tbname interval(1s) slimit 2 soffset 4 limit 10 offset 1
# fill [d.12]===============================================================
sql_error select first(c1)-last(c1), sum(c3)*count(c3), spread(c5 ) % count(*) from $stb interval(1s) fill(prev);
sql_error select first(c1) from $stb fill(value, 20);
sql_error select first(c1)-last(c1), sum(c3)*count(c3), spread(c5 ) % count(*) from ca_stb0 interval(1s) fill(prev);
sql_error select first(c1) from ca_stb0 fill(value, 20);
# constant column. [d.13]===============================================================
# column value filter [d.14]===============================================================
# tag filter. [d.15]===============================================================
sql select sum(c2)+99 from $stb where t1=12;
sql select sum(c2)+99 from ca_stb0 where t1=12;
# multi-field output [d.16]===============================================================
sql select count(*), sum(c1)*avg(c2), avg(c3)*count(c3), sum(c3), sum(c4), first(c7), last(c8), first(c9), first(c7), last(c8) from $tb
@ -548,15 +545,12 @@ if $data90 != 9.500000000 then
endi
# interval query [d.17]===============================================================
sql select avg(c2)*count(c2), sum(c3)-first(c3), last(c4)+9 from $stb interval(1s)
sql select avg(c2)*count(c2), sum(c3)-first(c3), last(c4)+9 from ca_stb0 interval(1s)
if $rows != 10000 then
return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
sql_error select first(c7)- last(c1) from $tb interval(2y)
sql select first(c7)- last(c1) from $tb interval(2y)
# aggregation query [d.18]===============================================================
# all cases in this part are aggregation query test.

View File

@ -1,22 +0,0 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
run tsim/parser/columnValue_bool.sim
run tsim/parser/columnValue_tinyint.sim
run tsim/parser/columnValue_smallint.sim
run tsim/parser/columnValue_int.sim
run tsim/parser/columnValue_bigint.sim
run tsim/parser/columnValue_float.sim
run tsim/parser/columnValue_double.sim
run tsim/parser/columnValue_unsign.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -1,5 +1,12 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database if not exists db
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
@ -10,78 +17,64 @@ sql create table mt_bigint (ts timestamp, c bigint) tags (tagname bigint)
## case 00: static create table for test tag values
sql create table st_bigint_0 using mt_bigint tags (NULL)
sql select tagname from st_bigint_0
if $data00 != NULL then
sql show tags from st_bigint_0
if $data05 != NULL then
return -1
endi
sql create table st_bigint_1 using mt_bigint tags (NULL)
sql select tagname from st_bigint_1
if $data00 != NULL then
return -1
endi
sql create table st_bigint_2 using mt_bigint tags ('NULL')
sql select tagname from st_bigint_2
if $data00 != NULL then
return -1
endi
sql create table st_bigint_3 using mt_bigint tags ('NULL')
sql select tagname from st_bigint_3
if $data00 != NULL then
return -1
endi
sql create table st_bigint_4 using mt_bigint tags ("NULL")
sql select tagname from st_bigint_4
if $data00 != NULL then
return -1
endi
sql create table st_bigint_5 using mt_bigint tags ("NULL")
sql select tagname from st_bigint_5
if $data00 != NULL then
sql show tags from st_bigint_1
if $data05 != NULL then
return -1
endi
sql_error create table st_bigint_2 using mt_bigint tags ('NULL')
sql_error create table st_bigint_3 using mt_bigint tags ('NULL')
sql_error create table st_bigint_4 using mt_bigint tags ("NULL")
sql_error create table st_bigint_5 using mt_bigint tags ("NULL")
sql create table st_bigint_6 using mt_bigint tags (-9223372036854775807)
sql select tagname from st_bigint_6
if $data00 != -9223372036854775807 then
sql show tags from st_bigint_6
if $data05 != -9223372036854775807 then
return -1
endi
sql create table st_bigint_7 using mt_bigint tags (9223372036854775807)
sql select tagname from st_bigint_7
if $data00 != 9223372036854775807 then
sql show tags from st_bigint_7
if $data05 != 9223372036854775807 then
return -1
endi
sql create table st_bigint_8 using mt_bigint tags (37)
sql select tagname from st_bigint_8
if $data00 != 37 then
sql show tags from st_bigint_8
if $data05 != 37 then
return -1
endi
sql create table st_bigint_9 using mt_bigint tags (-100)
sql select tagname from st_bigint_9
if $data00 != -100 then
sql show tags from st_bigint_9
if $data05 != -100 then
return -1
endi
sql create table st_bigint_10 using mt_bigint tags (+113)
sql select tagname from st_bigint_10
if $data00 != 113 then
sql show tags from st_bigint_10
if $data05 != 113 then
return -1
endi
sql create table st_bigint_11 using mt_bigint tags ('-100')
sql select tagname from st_bigint_11
if $data00 != -100 then
sql show tags from st_bigint_11
if $data05 != -100 then
return -1
endi
sql create table st_bigint_12 using mt_bigint tags ("+78")
sql select tagname from st_bigint_12
if $data00 != 78 then
sql show tags from st_bigint_12
if $data05 != 78 then
return -1
endi
sql create table st_bigint_13 using mt_bigint tags (+0078)
sql select tagname from st_bigint_13
if $data00 != 78 then
sql show tags from st_bigint_13
if $data05 != 78 then
return -1
endi
sql create table st_bigint_14 using mt_bigint tags (-00078)
sql select tagname from st_bigint_14
if $data00 != -78 then
sql show tags from st_bigint_14
if $data05 != -78 then
return -1
endi
@ -102,38 +95,7 @@ endi
if $data01 != NULL then
return -1
endi
sql insert into st_bigint_2 values (now, 'NULL')
sql select * from st_bigint_2
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_bigint_3 values (now, 'NULL')
sql select * from st_bigint_3
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_bigint_4 values (now, "NULL")
sql select * from st_bigint_4
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_bigint_5 values (now, "NULL")
sql select * from st_bigint_5
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_bigint_6 values (now, 9223372036854775807)
sql select * from st_bigint_6
if $rows != 1 then
@ -211,8 +173,8 @@ endi
## case 02: dynamic create table for test tag values
sql insert into st_bigint_16 using mt_bigint tags (NULL) values (now, NULL)
sql select tagname from st_bigint_16
if $data00 != NULL then
sql show tags from st_bigint_16
if $data05 != NULL then
return -1
endi
sql select * from st_bigint_16
@ -221,8 +183,8 @@ if $data01 != NULL then
endi
sql insert into st_bigint_17 using mt_bigint tags (NULL) values (now, NULL)
sql select tagname from st_bigint_17
if $data00 != NULL then
sql show tags from st_bigint_17
if $data05 != NULL then
return -1
endi
sql select * from st_bigint_17
@ -230,8 +192,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bigint_18 using mt_bigint tags ('NULL') values (now, 'NULL')
sql select tagname from st_bigint_18
if $data00 != NULL then
sql show tags from st_bigint_18
if $data05 != NULL then
return -1
endi
sql select * from st_bigint_18
@ -239,8 +201,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bigint_19 using mt_bigint tags ('NULL') values (now, 'NULL')
sql select tagname from st_bigint_19
if $data00 != NULL then
sql show tags from st_bigint_19
if $data05 != NULL then
return -1
endi
sql select * from st_bigint_19
@ -248,8 +210,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bigint_20 using mt_bigint tags ("NULL") values (now, "NULL")
sql select tagname from st_bigint_20
if $data00 != NULL then
sql show tags from st_bigint_20
if $data05 != NULL then
return -1
endi
sql select * from st_bigint_20
@ -257,8 +219,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bigint_21 using mt_bigint tags ("NULL") values (now, "NULL")
sql select tagname from st_bigint_21
if $data00 != NULL then
sql show tags from st_bigint_21
if $data05 != NULL then
return -1
endi
sql select * from st_bigint_21
@ -266,8 +228,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bigint_22 using mt_bigint tags (9223372036854775807) values (now, 9223372036854775807)
sql select tagname from st_bigint_22
if $data00 != 9223372036854775807 then
sql show tags from st_bigint_22
if $data05 != 9223372036854775807 then
return -1
endi
sql select * from st_bigint_22
@ -275,8 +237,8 @@ if $data01 != 9223372036854775807 then
return -1
endi
sql insert into st_bigint_23 using mt_bigint tags (-9223372036854775807) values (now, -9223372036854775807)
sql select tagname from st_bigint_23
if $data00 != -9223372036854775807 then
sql show tags from st_bigint_23
if $data05 != -9223372036854775807 then
return -1
endi
sql select * from st_bigint_23
@ -284,8 +246,8 @@ if $data01 != -9223372036854775807 then
return -1
endi
sql insert into st_bigint_24 using mt_bigint tags (10) values (now, 10)
sql select tagname from st_bigint_24
if $data00 != 10 then
sql show tags from st_bigint_24
if $data05 != 10 then
return -1
endi
sql select * from st_bigint_24
@ -293,8 +255,8 @@ if $data01 != 10 then
return -1
endi
sql insert into st_bigint_25 using mt_bigint tags ("-0") values (now, "-0")
sql select tagname from st_bigint_25
if $data00 != 0 then
sql show tags from st_bigint_25
if $data05 != 0 then
return -1
endi
sql select * from st_bigint_25
@ -302,8 +264,8 @@ if $data01 != 0 then
return -1
endi
sql insert into st_bigint_26 using mt_bigint tags ('123') values (now, '123')
sql select tagname from st_bigint_26
if $data00 != 123 then
sql show tags from st_bigint_26
if $data05 != 123 then
return -1
endi
sql select * from st_bigint_26
@ -311,8 +273,8 @@ if $data01 != 123 then
return -1
endi
sql insert into st_bigint_27 using mt_bigint tags (+056) values (now, +00056)
sql select tagname from st_bigint_27
if $data00 != 56 then
sql show tags from st_bigint_27
if $data05 != 56 then
return -1
endi
sql select * from st_bigint_27
@ -320,8 +282,8 @@ if $data01 != 56 then
return -1
endi
sql insert into st_bigint_28 using mt_bigint tags (-056) values (now, -0056)
sql select tagname from st_bigint_28
if $data00 != -56 then
sql show tags from st_bigint_28
if $data05 != -56 then
return -1
endi
sql select * from st_bigint_28
@ -331,50 +293,50 @@ endi
### case 03: alter tag values
#sql alter table st_bigint_0 set tag tagname=9223372036854775807
#sql select tagname from st_bigint_0
#if $data00 != 9223372036854775807 then
#sql show tags from st_bigint_0
#if $data05 != 9223372036854775807 then
# return -1
#endi
#sql alter table st_bigint_0 set tag tagname=-9223372036854775807
#sql select tagname from st_bigint_0
#if $data00 != -9223372036854775807 then
#sql show tags from st_bigint_0
#if $data05 != -9223372036854775807 then
# return -1
#endi
#sql alter table st_bigint_0 set tag tagname=+100
#sql select tagname from st_bigint_0
#if $data00 != 100 then
#sql show tags from st_bigint_0
#if $data05 != 100 then
# return -1
#endi
#sql alter table st_bigint_0 set tag tagname=-33
#sql select tagname from st_bigint_0
#if $data00 != -33 then
#sql show tags from st_bigint_0
#if $data05 != -33 then
# return -1
#endi
#sql alter table st_bigint_0 set tag tagname='+98'
#sql select tagname from st_bigint_0
#if $data00 != 98 then
#sql show tags from st_bigint_0
#if $data05 != 98 then
# return -1
#endi
#sql alter table st_bigint_0 set tag tagname='-076'
#sql select tagname from st_bigint_0
#if $data00 != -76 then
#sql show tags from st_bigint_0
#if $data05 != -76 then
# return -1
#endi
#sql alter table st_bigint_0 set tag tagname=+0012
#sql select tagname from st_bigint_0
#if $data00 != 12 then
#sql show tags from st_bigint_0
#if $data05 != 12 then
# return -1
#endi
#sql alter table st_bigint_0 set tag tagname=-00063
#sql select tagname from st_bigint_0
#if $data00 != -63 then
#sql show tags from st_bigint_0
#if $data05 != -63 then
# return -1
#endi
## case 04: illegal input
################## when overflow, auto set max
sql_error create table st_bigint_e0 using mt_bigint tags (9223372036854775808)
sql_error create table st_bigint_e0_1 using mt_bigint tags (-9223372036854775808)
sql create table st_bigint_e0_1 using mt_bigint tags (-9223372036854775808)
sql_error create table st_bigint_e0_2 using mt_bigint tags (92233720368547758080)
sql_error create table st_bigint_e0_3 using mt_bigint tags (-9223372036854775809)
#sql_error create table st_bigint_e0 using mt_bigint tags (12.80) truncate integer part
@ -384,7 +346,7 @@ sql_error create table st_bigint_e0 using mt_bigint tags ("123abc")
sql_error create table st_bigint_e0 using mt_bigint tags (abc)
sql_error create table st_bigint_e0 using mt_bigint tags ("abc")
sql_error create table st_bigint_e0 using mt_bigint tags (" ")
sql_error create table st_bigint_e0 using mt_bigint tags ('')
sql create table st_bigint_e0_error using mt_bigint tags ('')
sql create table st_bigint_e0 using mt_bigint tags (123)
sql create table st_bigint_e1 using mt_bigint tags (123)
@ -401,9 +363,9 @@ sql create table st_bigint_e11 using mt_bigint tags (123)
sql create table st_bigint_e12 using mt_bigint tags (123)
sql_error insert into st_bigint_e0 values (now, 9223372036854775808)
sql_error insert into st_bigint_e1 values (now, -9223372036854775808)
sql insert into st_bigint_e1 values (now, -9223372036854775808)
sql_error insert into st_bigint_e2 values (now, 9223372036854775809)
sql_error insert into st_bigint_e3 values (now, -9223372036854775808)
sql insert into st_bigint_e3 values (now, -9223372036854775808)
#sql_error insert into st_bigint_e4 values (now, 922337203.6854775808)
#sql_error insert into st_bigint_e5 values (now, -922337203685477580.9)
sql_error insert into st_bigint_e6 values (now, 123abc)
@ -411,10 +373,10 @@ sql_error insert into st_bigint_e7 values (now, "123abc")
sql_error insert into st_bigint_e9 values (now, abc)
sql_error insert into st_bigint_e10 values (now, "abc")
sql_error insert into st_bigint_e11 values (now, " ")
sql_error insert into st_bigint_e12 values (now, '')
sql insert into st_bigint_e12 values (now, '')
sql_error insert into st_bigint_e13 using mt_bigint tags (033) values (now, 9223372036854775808)
sql_error insert into st_bigint_e14 using mt_bigint tags (033) values (now, -9223372036854775808)
sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, -9223372036854775808)
sql_error insert into st_bigint_e15 using mt_bigint tags (033) values (now, 9223372036854775818)
sql_error insert into st_bigint_e16 using mt_bigint tags (033) values (now, -9923372036854775808)
#sql_error insert into st_bigint_e17 using mt_bigint tags (033) values (now, 92233720368547758.08)
@ -424,10 +386,10 @@ sql_error insert into st_bigint_e20 using mt_bigint tags (033) values (now, "123
sql_error insert into st_bigint_e22 using mt_bigint tags (033) values (now, abc)
sql_error insert into st_bigint_e23 using mt_bigint tags (033) values (now, "abc")
sql_error insert into st_bigint_e24 using mt_bigint tags (033) values (now, " ")
sql_error insert into st_bigint_e25 using mt_bigint tags (033) values (now, '')
sql insert into st_bigint_e25 using mt_bigint tags (033) values (now, '')
sql_error insert into st_bigint_e13_0 using mt_bigint tags (9223372036854775808) values (now, -033)
sql_error insert into st_bigint_e14_0 using mt_bigint tags (-9223372036854775808) values (now, -033)
sql insert into st_bigint_e14_0 using mt_bigint tags (-9223372036854775808) values (now, -033)
sql_error insert into st_bigint_e15_0 using mt_bigint tags (9223372036854775809) values (now, -033)
sql_error insert into st_bigint_e16_0 using mt_bigint tags (-9223372036854775898) values (now, -033)
#sql_error insert into st_bigint_e17 using mt_bigint tags (12.80) values (now, -033)
@ -437,7 +399,7 @@ sql_error insert into st_bigint_e20 using mt_bigint tags ("123abc") values (now,
sql_error insert into st_bigint_e22 using mt_bigint tags (abc) values (now, -033)
sql_error insert into st_bigint_e23 using mt_bigint tags ("abc") values (now, -033)
sql_error insert into st_bigint_e24 using mt_bigint tags (" ") values (now, -033)
sql_error insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033)
sql insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033)
sql insert into st_bigint_e13 using mt_bigint tags (033) values (now, 00062)
sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, 00062)

View File

@ -1,5 +1,12 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database if not exists db
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
@ -10,110 +17,110 @@ sql create table mt_bool (ts timestamp, c bool) tags (tagname bool)
## case 00: static create table for test tag values
sql create table st_bool_0 using mt_bool tags (NULL)
sql select tagname from st_bool_0
if $data00 != NULL then
print ==1== expect: NULL, actually: $data00
sql show tags from st_bool_0
if $data05 != NULL then
print ==1== expect: NULL, actually: $data05
return -1
endi
sql create table st_bool_1 using mt_bool tags (NULL)
sql select tagname from st_bool_1
if $data00 != NULL then
print ==2== expect: NULL, actually: $data00
sql show tags from st_bool_1
if $data05 != NULL then
print ==2== expect: NULL, actually: $data05
return -1
endi
sql create table st_bool_2 using mt_bool tags ('NULL')
sql select tagname from st_bool_2
if $data00 != NULL then
print ==3== expect: NULL, actually: $data00
sql show tags from st_bool_2
if $data05 != false then
print ==3== expect: false, actually: $data05
return -1
endi
sql create table st_bool_3 using mt_bool tags ('NULL')
sql select tagname from st_bool_3
if $data00 != NULL then
print ==4== expect: NULL, actually: $data00
sql show tags from st_bool_3
if $data05 != false then
print ==4== expect: false, actually: $data05
return -1
endi
sql create table st_bool_4 using mt_bool tags ("NULL")
sql select tagname from st_bool_4
if $data00 != NULL then
print ==5== expect: NULL, actually: $data00
sql show tags from st_bool_4
if $data05 != false then
print ==5== expect: false, actually: $data05
return -1
endi
sql create table st_bool_5 using mt_bool tags ("NULL")
sql select tagname from st_bool_5
if $data00 != NULL then
print ==6== expect: NULL, actually: $data00
sql show tags from st_bool_5
if $data05 != false then
print ==6== expect: false, actually: $data05
return -1
endi
sql create table st_bool_6 using mt_bool tags ("true")
sql select tagname from st_bool_6
if $data00 != 1 then
print ==7== expect: 1, actually: $data00
sql show tags from st_bool_6
if $data05 != true then
print ==7== expect: 1, actually: $data05
return -1
endi
sql create table st_bool_7 using mt_bool tags ('true')
sql select tagname from st_bool_7
if $data00 != 1 then
print ==8== expect: 1, actually: $data00
sql show tags from st_bool_7
if $data05 != true then
print ==8== expect: 1, actually: $data05
return -1
endi
sql create table st_bool_8 using mt_bool tags (true)
sql select tagname from st_bool_8
if $data00 != 1 then
print ==9== expect: 1, actually: $data00
sql show tags from st_bool_8
if $data05 != true then
print ==9== expect: 1, actually: $data05
return -1
endi
sql create table st_bool_9 using mt_bool tags ("false")
sql select tagname from st_bool_9
if $data00 != 0 then
print ==10== expect: 0, actually: $data00
sql show tags from st_bool_9
if $data05 != false then
print ==10== expect: 0, actually: $data05
return -1
endi
sql create table st_bool_10 using mt_bool tags ('false')
sql select tagname from st_bool_10
if $data00 != 0 then
print ==11== expect: 0, actually: $data00
sql show tags from st_bool_10
if $data05 != false then
print ==11== expect: 0, actually: $data05
return -1
endi
sql create table st_bool_11 using mt_bool tags (false)
sql select tagname from st_bool_11
if $data00 != 0 then
print ==12== expect: 0, actually: $data00
sql show tags from st_bool_11
if $data05 != false then
print ==12== expect: 0, actually: $data05
return -1
endi
sql create table st_bool_12 using mt_bool tags (0)
sql select tagname from st_bool_12
if $data00 != 0 then
print ==13== expect: 0, actually: $data00
sql show tags from st_bool_12
if $data05 != false then
print ==13== expect: 0, actually: $data05
return -1
endi
sql create table st_bool_13 using mt_bool tags (1)
sql select tagname from st_bool_13
if $data00 != 1 then
print ==14== expect: 1, actually: $data00
sql show tags from st_bool_13
if $data05 != true then
print ==14== expect: 1, actually: $data05
return -1
endi
sql create table st_bool_14 using mt_bool tags (6.9)
sql select tagname from st_bool_14
if $data00 != 1 then
print ==15== expect: 1, actually: $data00
sql show tags from st_bool_14
if $data05 != true then
print ==15== expect: 1, actually: $data05
return -1
endi
sql create table st_bool_15 using mt_bool tags (-3)
sql select tagname from st_bool_15
if $data00 != 1 then
sql show tags from st_bool_15
if $data05 != true then
print ==16== expect: 1, actually: $data00
return -1
endi
sql create table st_bool_15_0 using mt_bool tags (+300)
sql select tagname from st_bool_15_0
if $data00 != 1 then
sql show tags from st_bool_15_0
if $data05 != true then
print ==16== expect: 1, actually: $data00
return -1
endi
sql create table st_bool_15_1 using mt_bool tags (-8.03)
sql select tagname from st_bool_15_1
if $data00 != 1 then
sql show tags from st_bool_15_1
if $data05 != true then
print ==16== expect: 1, actually: $data00
return -1
endi
@ -284,8 +291,8 @@ endi
## case 02: dynamic create table for test tag values
sql insert into st_bool_16 using mt_bool tags (NULL) values (now, NULL)
sql select tagname from st_bool_16
if $data00 != NULL then
sql show tags from st_bool_16
if $data05 != NULL then
print ==33== expect: NULL, actually: $data00
return -1
endi
@ -296,8 +303,8 @@ if $data01 != NULL then
endi
sql insert into st_bool_17 using mt_bool tags (NULL) values (now, NULL)
sql select tagname from st_bool_17
if $data00 != NULL then
sql show tags from st_bool_17
if $data05 != NULL then
print ==35== expect: NULL, actually: $data00
return -1
endi
@ -307,8 +314,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bool_18 using mt_bool tags ('NULL') values (now, 'NULL')
sql select tagname from st_bool_18
if $data00 != NULL then
sql show tags from st_bool_18
if $data05 != NULL then
print ==37== expect: NULL, actually: $data00
return -1
endi
@ -318,8 +325,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bool_19 using mt_bool tags ('NULL') values (now, 'NULL')
sql select tagname from st_bool_19
if $data00 != NULL then
sql show tags from st_bool_19
if $data05 != NULL then
print ==39== expect: NULL, actually: $data00
return -1
endi
@ -329,8 +336,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bool_20 using mt_bool tags ("NULL") values (now, "NULL")
sql select tagname from st_bool_20
if $data00 != NULL then
sql show tags from st_bool_20
if $data05 != NULL then
print ==41== expect: NULL, actually: $data00
return -1
endi
@ -340,8 +347,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bool_21 using mt_bool tags ("NULL") values (now, "NULL")
sql select tagname from st_bool_21
if $data00 != NULL then
sql show tags from st_bool_21
if $data05 != NULL then
print ==43== expect: NULL, actually: $data00
return -1
endi
@ -351,8 +358,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_bool_22 using mt_bool tags ("true") values (now, "true")
sql select tagname from st_bool_22
if $data00 != 1 then
sql show tags from st_bool_22
if $data05 != true then
print ==45== expect: 1, actually: $data00
return -1
endi
@ -362,8 +369,8 @@ if $data01 != 1 then
return -1
endi
sql insert into st_bool_23 using mt_bool tags ('true') values (now, 'true')
sql select tagname from st_bool_23
if $data00 != 1 then
sql show tags from st_bool_23
if $data05 != true then
print ==47== expect: 1, actually: $data00
return -1
endi
@ -373,8 +380,8 @@ if $data01 != 1 then
return -1
endi
sql insert into st_bool_24 using mt_bool tags (true) values (now, true)
sql select tagname from st_bool_24
if $data00 != 1 then
sql show tags from st_bool_24
if $data05 != true then
print ==49== expect: 1, actually: $data00
return -1
endi
@ -384,8 +391,8 @@ if $data01 != 1 then
return -1
endi
sql insert into st_bool_25 using mt_bool tags ("false") values (now, "false")
sql select tagname from st_bool_25
if $data00 != 0 then
sql show tags from st_bool_25
if $data05 != false then
print ==51== expect: 0, actually: $data00
return -1
endi
@ -395,8 +402,8 @@ if $data01 != 0 then
return -1
endi
sql insert into st_bool_26 using mt_bool tags ('false') values (now, 'false')
sql select tagname from st_bool_26
if $data00 != 0 then
sql show tags from st_bool_26
if $data05 != false then
print ==53== expect: 0, actually: $data00
return -1
endi
@ -406,8 +413,8 @@ if $data01 != 0 then
return -1
endi
sql insert into st_bool_27 using mt_bool tags (false) values (now, false)
sql select tagname from st_bool_27
if $data00 != 0 then
sql show tags from st_bool_27
if $data05 != false then
print ==55== expect: 0, actually: $data00
return -1
endi
@ -417,8 +424,8 @@ if $data01 != 0 then
return -1
endi
sql insert into st_bool_28 using mt_bool tags (0) values (now, 0)
sql select tagname from st_bool_28
if $data00 != 0 then
sql show tags from st_bool_28
if $data05 != false then
print ==57== expect: 0, actually: $data00
return -1
endi
@ -428,8 +435,8 @@ if $data01 != 0 then
return -1
endi
sql insert into st_bool_29 using mt_bool tags (1) values (now, 1)
sql select tagname from st_bool_29
if $data00 != 1 then
sql show tags from st_bool_29
if $data05 != true then
print ==59== expect: 1, actually: $data00
return -1
endi
@ -439,8 +446,8 @@ if $data01 != 1 then
return -1
endi
sql insert into st_bool_30 using mt_bool tags (6.9) values (now, 6.9)
sql select tagname from st_bool_30
if $data00 != 1 then
sql show tags from st_bool_30
if $data05 != true then
print ==61== expect: 1, actually: $data00
return -1
endi
@ -450,8 +457,8 @@ if $data01 != 1 then
return -1
endi
sql insert into st_bool_31 using mt_bool tags (-3) values (now, -3)
sql select tagname from st_bool_31
if $data00 != 1 then
sql show tags from st_bool_31
if $data05 != true then
print ==63== expect: 1, actually: $data00
return -1
endi
@ -461,8 +468,8 @@ if $data01 != 1 then
return -1
endi
sql insert into st_bool_32 using mt_bool tags (+300) values (now, +300)
sql select tagname from st_bool_32
if $data00 != 1 then
sql show tags from st_bool_32
if $data05 != true then
print ==63== expect: 1, actually: $data00
return -1
endi
@ -472,8 +479,8 @@ if $data01 != 1 then
return -1
endi
sql insert into st_bool_33 using mt_bool tags (+30.890) values (now, +30.890)
sql select tagname from st_bool_33
if $data00 != 1 then
sql show tags from st_bool_33
if $data05 != true then
print ==63== expect: 1, actually: $data00
return -1
endi
@ -490,140 +497,140 @@ endi
## case 03: alter tag values
#sql alter table st_bool_0 set tag tagname=true
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=NULL
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=false
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != false then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=NULL
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname='true'
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname='NULL'
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname='false'
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != false then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname='NULL'
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname="true"
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname="NULL"
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname="false"
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != false then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname="NULL"
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != NULL then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=1
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=0
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != false then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=6.9
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
#sql alter table st_bool_0 set tag tagname=-3
#sql select tagname from st_bool_0
#sql show tags from st_bool_0
#if $data00 != true then
# return -1
#endi
# case 04: illegal input
sql_error create table st_bool_e0 using mt_bool tags (123abc)
sql_error create table st_bool_e1 using mt_bool tags ("123abc")
sql_error create table st_bool_e2 using mt_bool tags ("123")
sql create table st_bool_e1 using mt_bool tags ("123abc")
sql create table st_bool_e2 using mt_bool tags ("123")
sql_error create table st_bool_e3 using mt_bool tags (abc)
sql_error create table st_bool_e4 using mt_bool tags ("abc")
sql_error create table st_bool_e5 using mt_bool tags (" ")
sql_error create table st_bool_e6 using mt_bool tags ('')
sql create table st_bool_e4 using mt_bool tags ("abc")
sql create table st_bool_e5 using mt_bool tags (" ")
sql create table st_bool_e6 using mt_bool tags ('')
sql create table st_bool_e0 using mt_bool tags (true)
sql create table st_bool_e1 using mt_bool tags (true)
sql create table st_bool_e2 using mt_bool tags (true)
sql create table st_bool_e3 using mt_bool tags (true)
sql create table st_bool_e4 using mt_bool tags (true)
sql create table st_bool_e5 using mt_bool tags (true)
sql create table st_bool_e6 using mt_bool tags (true)
sql create table st_bool_f0 using mt_bool tags (true)
sql create table st_bool_f1 using mt_bool tags (true)
sql create table st_bool_f2 using mt_bool tags (true)
sql create table st_bool_f3 using mt_bool tags (true)
sql create table st_bool_f4 using mt_bool tags (true)
sql create table st_bool_f5 using mt_bool tags (true)
sql create table st_bool_f6 using mt_bool tags (true)
sql_error insert into st_bool_e0 values (now, 123abc)
sql_error insert into st_bool_e1 values (now, "123abc")
sql_error insert into st_bool_e2 values (now, "123")
sql_error insert into st_bool_e3 values (now, abc)
sql_error insert into st_bool_e4 values (now, "abc")
sql_error insert into st_bool_e5 values (now, " ")
sql_error insert into st_bool_e6 values (now, '')
sql_error insert into st_bool_g0 values (now, 123abc)
sql_error insert into st_bool_g1 values (now, "123abc")
sql_error insert into st_bool_g2 values (now, "123")
sql_error insert into st_bool_g3 values (now, abc)
sql_error insert into st_bool_g4 values (now, "abc")
sql_error insert into st_bool_g5 values (now, " ")
sql_error insert into st_bool_g6 values (now, '')
sql_error insert into st_bool_e10 using mt_bool tags (123abc) values (now, 1)
sql_error insert into st_bool_e11 using mt_bool tags ("123abc") values (now, 1)
sql_error insert into st_bool_e12 using mt_bool tags ("123") values (now, 1)
sql_error insert into st_bool_e13 using mt_bool tags (abc) values (now, 1)
sql_error insert into st_bool_e14 using mt_bool tags ("abc") values (now, 1)
sql_error insert into st_bool_e15 using mt_bool tags (" ") values (now, 1)
sql_error insert into st_bool_e16 using mt_bool tags ('') values (now, 1)
sql_error insert into st_bool_h0 using mt_bool tags (123abc) values (now, 1)
sql_error insert into st_bool_h1 using mt_bool tags ("123abc") values (now, 1)
sql_error insert into st_bool_h2 using mt_bool tags ("123") values (now, 1)
sql_error insert into st_bool_h3 using mt_bool tags (abc) values (now, 1)
sql_error insert into st_bool_h4 using mt_bool tags ("abc") values (now, 1)
sql_error insert into st_bool_h5 using mt_bool tags (" ") values (now, 1)
sql_error insert into st_bool_h6 using mt_bool tags ('') values (now, 1)
sql_error insert into st_bool_e17 using mt_bool tags (1) values (now, 123abc)
sql_error insert into st_bool_e18 using mt_bool tags (1) values (now, "123abc")
sql_error insert into st_bool_e19 using mt_bool tags (1) values (now, "123")
sql_error insert into st_bool_e20 using mt_bool tags (1) values (now, abc)
sql_error insert into st_bool_e21 using mt_bool tags (1) values (now, "abc")
sql_error insert into st_bool_e22 using mt_bool tags (1) values (now, " ")
sql_error insert into st_bool_e23 using mt_bool tags (1) values (now, '')
sql_error insert into st_bool_h0 using mt_bool tags (1) values (now, 123abc)
sql_error insert into st_bool_h1 using mt_bool tags (1) values (now, "123abc")
sql_error insert into st_bool_h2 using mt_bool tags (1) values (now, "123")
sql_error insert into st_bool_h3 using mt_bool tags (1) values (now, abc)
sql_error insert into st_bool_h4 using mt_bool tags (1) values (now, "abc")
sql_error insert into st_bool_h5 using mt_bool tags (1) values (now, " ")
sql_error insert into st_bool_h6 using mt_bool tags (1) values (now, '')
sql insert into st_bool_e10 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_e11 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_e12 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_e13 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_e14 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_e15 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_e16 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_i0 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_i1 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_i2 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_i3 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_i4 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_i5 using mt_bool tags (1) values (now, 1)
sql insert into st_bool_i6 using mt_bool tags (1) values (now, 1)
sql_error alter table st_bool_e10 set tag tagname=123abc
sql_error alter table st_bool_e11 set tag tagname="123abc"
sql_error alter table st_bool_e12 set tag tagname="123"
sql_error alter table st_bool_e13 set tag tagname=abc
sql_error alter table st_bool_e14 set tag tagname="abc"
sql_error alter table st_bool_e15 set tag tagname=" "
sql_error alter table st_bool_e16 set tag tagname=''
sql_error alter table st_bool_i0 set tag tagname=123abc
sql alter table st_bool_i1 set tag tagname="123abc"
sql alter table st_bool_i2 set tag tagname="123"
sql_error alter table st_bool_i3 set tag tagname=abc
sql alter table st_bool_i4 set tag tagname="abc"
sql alter table st_bool_i5 set tag tagname=" "
sql alter table st_bool_i6 set tag tagname=''

View File

@ -1,5 +1,12 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database if not exists db
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
@ -10,135 +17,135 @@ sql create table mt_double (ts timestamp, c double) tags (tagname double)
## case 00: static create table for test tag values
sql create table st_double_0 using mt_double tags (NULL )
sql select tagname from st_double_0
if $data00 != NULL then
sql show tags from st_double_0
if $data05 != NULL then
return -1
endi
sql create table st_double_1 using mt_double tags (NULL)
sql select tagname from st_double_1
if $data00 != NULL then
sql show tags from st_double_1
if $data05 != NULL then
return -1
endi
sql create table st_double_2 using mt_double tags ('NULL')
sql select tagname from st_double_2
if $data00 != NULL then
sql show tags from st_double_2
if $data05 != 0.000000000 then
return -1
endi
sql create table st_double_3 using mt_double tags ('NULL')
sql select tagname from st_double_3
if $data00 != NULL then
sql show tags from st_double_3
if $data05 != 0.000000000 then
return -1
endi
sql create table st_double_4 using mt_double tags ("NULL")
sql select tagname from st_double_4
if $data00 != NULL then
sql show tags from st_double_4
if $data05 != 0.000000000 then
return -1
endi
sql create table st_double_5 using mt_double tags ("NULL")
sql select tagname from st_double_5
if $data00 != NULL then
sql show tags from st_double_5
if $data05 != 0.000000000 then
return -1
endi
sql create table st_double_6 using mt_double tags (-123.321)
sql select tagname from st_double_6
if $data00 != -123.321000000 then
print expect -123.321000000, actual: $data00
sql show tags from st_double_6
if $data05 != -123.321000000 then
print expect -123.321000000, actual: $data05
return -1
endi
sql create table st_double_7 using mt_double tags (+1.567)
sql select tagname from st_double_7
if $data00 != 1.567000000 then
sql show tags from st_double_7
if $data05 != 1.567000000 then
return -1
endi
sql create table st_double_8 using mt_double tags (379.001)
sql select tagname from st_double_8
if $data00 != 379.001000000 then
sql show tags from st_double_8
if $data05 != 379.001000000 then
return -1
endi
sql create table st_double_9 using mt_double tags (1.5e+3)
sql select tagname from st_double_9
if $data00 != 1500.000000000 then
sql show tags from st_double_9
if $data05 != 1500.000000000 then
return -1
endi
sql create table st_double_10 using mt_double tags (-1.5e-3)
sql select tagname from st_double_10
if $data00 != -0.001500000 then
sql show tags from st_double_10
if $data05 != -0.001500000 then
return -1
endi
sql create table st_double_11 using mt_double tags (+1.5e+3)
sql select tagname from st_double_11
if $data00 != 1500.000000000 then
sql show tags from st_double_11
if $data05 != 1500.000000000 then
return -1
endi
sql create table st_double_12 using mt_double tags (-1.5e+3)
sql select tagname from st_double_12
if $data00 != -1500.000000000 then
sql show tags from st_double_12
if $data05 != -1500.000000000 then
return -1
endi
sql create table st_double_13 using mt_double tags (1.5e-3)
sql select tagname from st_double_13
if $data00 != 0.001500000 then
sql show tags from st_double_13
if $data05 != 0.001500000 then
return -1
endi
sql create table st_double_14 using mt_double tags (1.5E-3)
sql select tagname from st_double_14
if $data00 != 0.001500000 then
sql show tags from st_double_14
if $data05 != 0.001500000 then
return -1
endi
sql create table st_double_6_0 using mt_double tags ('-123.321')
sql select tagname from st_double_6_0
if $data00 != -123.321000000 then
sql show tags from st_double_6_0
if $data05 != -123.321000000 then
return -1
endi
sql create table st_double_7_0 using mt_double tags ('+1.567')
sql select tagname from st_double_7_0
if $data00 != 1.567000000 then
sql show tags from st_double_7_0
if $data05 != 1.567000000 then
return -1
endi
sql create table st_double_8_0 using mt_double tags ('379.001')
sql select tagname from st_double_8_0
if $data00 != 379.001000000 then
sql show tags from st_double_8_0
if $data05 != 379.001000000 then
return -1
endi
sql create table st_double_9_0 using mt_double tags ('1.5e+3')
sql select tagname from st_double_9_0
if $data00 != 1500.000000000 then
sql show tags from st_double_9_0
if $data05 != 1500.000000000 then
return -1
endi
sql create table st_double_10_0 using mt_double tags ('-1.5e-3')
sql select tagname from st_double_10_0
if $data00 != -0.001500000 then
sql show tags from st_double_10_0
if $data05 != -0.001500000 then
return -1
endi
sql create table st_double_11_0 using mt_double tags ('+1.5e+3')
sql select tagname from st_double_11_0
if $data00 != 1500.000000000 then
sql show tags from st_double_11_0
if $data05 != 1500.000000000 then
return -1
endi
sql create table st_double_12_0 using mt_double tags ('-1.5e+3')
sql select tagname from st_double_12_0
if $data00 != -1500.000000000 then
sql show tags from st_double_12_0
if $data05 != -1500.000000000 then
return -1
endi
sql create table st_double_13_0 using mt_double tags ('1.5e-3')
sql select tagname from st_double_13_0
if $data00 != 0.001500000 then
sql show tags from st_double_13_0
if $data05 != 0.001500000 then
return -1
endi
sql create table st_double_14_0 using mt_double tags ('1.5E-3')
sql select tagname from st_double_14_0
if $data00 != 0.001500000 then
sql show tags from st_double_14_0
if $data05 != 0.001500000 then
return -1
endi
sql create table st_double_15_0 using mt_double tags (1.7976931348623157e+308)
sql select tagname from st_double_15_0
#if $data00 != 0.001500000 then
sql show tags from st_double_15_0
#if $data05 != 0.001500000 then
# return -1
#endi
sql create table st_double_16_0 using mt_double tags (-1.7976931348623157e+308)
sql select tagname from st_double_16_0
#if $data00 != 0.001500000 then
sql show tags from st_double_16_0
#if $data05 != 0.001500000 then
# return -1
#endi
@ -270,8 +277,8 @@ endi
## case 02: dynamic create table for test tag values
sql insert into st_double_16 using mt_double tags (NULL ) values (now, NULL )
sql select tagname from st_double_16
if $data00 != NULL then
sql show tags from st_double_16
if $data05 != NULL then
return -1
endi
sql select * from st_double_16
@ -280,8 +287,8 @@ if $data01 != NULL then
endi
sql insert into st_double_17 using mt_double tags (NULL) values (now, NULL)
sql select tagname from st_double_17
if $data00 != NULL then
sql show tags from st_double_17
if $data05 != NULL then
return -1
endi
sql select * from st_double_17
@ -289,8 +296,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_double_18 using mt_double tags ('NULL') values (now, 'NULL')
sql select tagname from st_double_18
if $data00 != NULL then
sql show tags from st_double_18
if $data05 != NULL then
return -1
endi
sql select * from st_double_18
@ -298,8 +305,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_double_19 using mt_double tags ('NULL') values (now, 'NULL')
sql select tagname from st_double_19
if $data00 != NULL then
sql show tags from st_double_19
if $data05 != NULL then
return -1
endi
sql select * from st_double_19
@ -307,8 +314,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_double_20 using mt_double tags ("NULL") values (now, "NULL")
sql select tagname from st_double_20
if $data00 != NULL then
sql show tags from st_double_20
if $data05 != NULL then
return -1
endi
sql select * from st_double_20
@ -316,8 +323,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_double_21 using mt_double tags ("NULL") values (now, "NULL")
sql select tagname from st_double_21
if $data00 != NULL then
sql show tags from st_double_21
if $data05 != NULL then
return -1
endi
sql select * from st_double_21
@ -325,8 +332,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_double_22 using mt_double tags (127) values (now, 1.7976931348623157e+308)
sql select tagname from st_double_22
#if $data00 != 127 then
sql show tags from st_double_22
#if $data05 != 127 then
# return -1
#endi
sql select * from st_double_22
@ -334,8 +341,8 @@ sql select * from st_double_22
# return -1
#endi
sql insert into st_double_23 using mt_double tags (-127) values (now, -1.7976931348623157e+308)
sql select tagname from st_double_23
#if $data00 != -127 then
sql show tags from st_double_23
#if $data05 != -127 then
# return -1
#endi
sql select * from st_double_23
@ -343,8 +350,8 @@ sql select * from st_double_23
# return -1
#endi
sql insert into st_double_24 using mt_double tags (10) values (now, 10)
sql select tagname from st_double_24
#if $data00 != 10 then
sql show tags from st_double_24
#if $data05 != 10 then
# return -1
#endi
sql select * from st_double_24
@ -352,8 +359,8 @@ sql select * from st_double_24
# return -1
#endi
sql insert into st_double_25 using mt_double tags ("-0") values (now, "-0")
sql select tagname from st_double_25
#if $data00 != 0 then
sql show tags from st_double_25
#if $data05 != 0 then
# return -1
#endi
sql select * from st_double_25
@ -361,8 +368,8 @@ sql select * from st_double_25
# return -1
#endi
sql insert into st_double_26 using mt_double tags ('123') values (now, '12.3')
sql select tagname from st_double_26
#if $data00 != 123 then
sql show tags from st_double_26
#if $data05 != 123 then
# return -1
#endi
sql select * from st_double_26
@ -370,8 +377,8 @@ sql select * from st_double_26
# return -1
#endi
sql insert into st_double_27 using mt_double tags (+056) values (now, +0005.6)
sql select tagname from st_double_27
#if $data00 != 56 then
sql show tags from st_double_27
#if $data05 != 56 then
# return -1
#endi
sql select * from st_double_27
@ -379,8 +386,8 @@ sql select * from st_double_27
# return -1
#endi
sql insert into st_double_28 using mt_double tags (-056) values (now, -005.6)
sql select tagname from st_double_28
#if $data00 != -56 then
sql show tags from st_double_28
#if $data05 != -56 then
# return -1
#endi
sql select * from st_double_28
@ -390,43 +397,43 @@ sql select * from st_double_28
### case 03: alter tag values
#sql alter table st_double_0 set tag tagname=1.7976931348623157e+308
#sql select tagname from st_double_0
##if $data00 != 127 then
#sql show tags from st_double_0
##if $data05 != 127 then
## return -1
##endi
#sql alter table st_double_0 set tag tagname=-1.7976931348623157e+308
#sql select tagname from st_double_0
##if $data00 != -127 then
#sql show tags from st_double_0
##if $data05 != -127 then
## return -1
##endi
#sql alter table st_double_0 set tag tagname=+10.340
#sql select tagname from st_double_0
##if $data00 != 100 then
#sql show tags from st_double_0
##if $data05 != 100 then
## return -1
##endi
#sql alter table st_double_0 set tag tagname=-33.87
#sql select tagname from st_double_0
##if $data00 != -33 then
#sql show tags from st_double_0
##if $data05 != -33 then
## return -1
##endi
#sql alter table st_double_0 set tag tagname='+9.8'
#sql select tagname from st_double_0
##if $data00 != 98 then
#sql show tags from st_double_0
##if $data05 != 98 then
## return -1
##endi
#sql alter table st_double_0 set tag tagname='-07.6'
#sql select tagname from st_double_0
##if $data00 != -76 then
#sql show tags from st_double_0
##if $data05 != -76 then
## return -1
##endi
#sql alter table st_double_0 set tag tagname=+0012.871
#sql select tagname from st_double_0
##if $data00 != 12 then
#sql show tags from st_double_0
##if $data05 != 12 then
## return -1
##endi
#sql alter table st_double_0 set tag tagname=-00063.582
#sql select tagname from st_double_0
##if $data00 != -63 then
#sql show tags from st_double_0
##if $data05 != -63 then
## return -1
##endi
@ -438,11 +445,11 @@ sql_error create table st_double_e0 using mt_double tags (-31.7976931348623157e+
#sql_error create table st_double_e0 using mt_double tags (12.80) truncate integer part
#sql_error create table st_double_e0 using mt_double tags (-11.80)
sql_error create table st_double_e0 using mt_double tags (123abc)
sql_error create table st_double_e0 using mt_double tags ("123abc")
sql create table st_double_e0_1 using mt_double tags ("123abc")
sql_error create table st_double_e0 using mt_double tags (abc)
sql_error create table st_double_e0 using mt_double tags ("abc")
sql_error create table st_double_e0 using mt_double tags (" ")
sql_error create table st_double_e0 using mt_double tags ('')
sql create table st_double_e0_2 using mt_double tags ("abc")
sql create table st_double_e0_3 using mt_double tags (" ")
sql create table st_double_e0_4 using mt_double tags ('')
sql create table st_double_e0 using mt_double tags (123)
sql create table st_double_e1 using mt_double tags (123)
@ -469,7 +476,7 @@ sql_error insert into st_double_e7 values (now, "123abc")
sql_error insert into st_double_e9 values (now, abc)
sql_error insert into st_double_e10 values (now, "abc")
sql_error insert into st_double_e11 values (now, " ")
sql_error insert into st_double_e12 values (now, '')
sql insert into st_double_e12 values (now, '')
sql_error insert into st_double_e13 using mt_double tags (033) values (now, 11.7976931348623157e+308)
sql_error insert into st_double_e14 using mt_double tags (033) values (now, -11.7976931348623157e+308)
@ -482,7 +489,7 @@ sql_error insert into st_double_e20 using mt_double tags (033) values (now, "123
sql_error insert into st_double_e22 using mt_double tags (033) values (now, abc)
sql_error insert into st_double_e23 using mt_double tags (033) values (now, "abc")
sql_error insert into st_double_e24 using mt_double tags (033) values (now, " ")
sql_error insert into st_double_e25 using mt_double tags (033) values (now, '')
sql insert into st_double_e25_1 using mt_double tags (033) values (now, '')
sql_error insert into st_double_e13 using mt_double tags (31.7976931348623157e+308) values (now, -033)
sql_error insert into st_double_e14 using mt_double tags (-31.7976931348623157e+308) values (now, -033)
@ -495,7 +502,7 @@ sql_error insert into st_double_e20 using mt_double tags ("123abc") values (now,
sql_error insert into st_double_e22 using mt_double tags (abc) values (now, -033)
sql_error insert into st_double_e23 using mt_double tags ("abc") values (now, -033)
sql_error insert into st_double_e24 using mt_double tags (" ") values (now, -033)
sql_error insert into st_double_e25 using mt_double tags ('') values (now, -033)
sql insert into st_double_e25 using mt_double tags ('') values (now, -033)
sql insert into st_double_e13 using mt_double tags (033) values (now, 00062)
sql insert into st_double_e14 using mt_double tags (033) values (now, 00062)
@ -516,8 +523,8 @@ sql_error alter table st_double_e14 set tag tagname=-1.8976931348623157e+308
sql_error alter table st_double_e15 set tag tagname=131.7976931348623157e+308
sql_error alter table st_double_e16 set tag tagname=-131.7976931348623157e+308
sql_error alter table st_double_e19 set tag tagname=123abc
sql_error alter table st_double_e20 set tag tagname="123abc"
sql alter table st_double_e20 set tag tagname="123abc"
sql_error alter table st_double_e22 set tag tagname=abc
sql_error alter table st_double_e23 set tag tagname="abc"
sql_error alter table st_double_e24 set tag tagname=" "
sql_error alter table st_double_e25 set tag tagname=''
sql alter table st_double_e23 set tag tagname="abc"
sql alter table st_double_e24 set tag tagname=" "
sql alter table st_double_e25 set tag tagname=''

View File

@ -1,5 +1,12 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database if not exists db
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
@ -10,152 +17,152 @@ sql create table mt_float (ts timestamp, c float) tags (tagname float)
## case 00: static create table for test tag values
sql create table st_float_0 using mt_float tags (NULL)
sql select tagname from st_float_0
if $data00 != NULL then
sql show tags from st_float_0
if $data05 != NULL then
return -1
endi
sql create table st_float_1 using mt_float tags (NULL)
sql select tagname from st_float_1
if $data00 != NULL then
sql show tags from st_float_1
if $data05 != NULL then
return -1
endi
sql create table st_float_2 using mt_float tags ('NULL')
sql select tagname from st_float_2
if $data00 != NULL then
sql show tags from st_float_2
if $data05 != 0.00000 then
return -1
endi
sql create table st_float_3 using mt_float tags ('NULL')
sql select tagname from st_float_3
if $data00 != NULL then
sql show tags from st_float_3
if $data05 != 0.00000 then
return -1
endi
sql create table st_float_4 using mt_float tags ("NULL")
sql select tagname from st_float_4
if $data00 != NULL then
sql show tags from st_float_4
if $data05 != 0.00000 then
return -1
endi
sql create table st_float_5 using mt_float tags ("NULL")
sql select tagname from st_float_5
if $data00 != NULL then
sql show tags from st_float_5
if $data05 != 0.00000 then
return -1
endi
sql create table st_float_6 using mt_float tags (-123.321)
sql select tagname from st_float_6
if $data00 != -123.32100 then
print expect -123.32100, actual: $data00
sql show tags from st_float_6
if $data05 != -123.32100 then
print expect -123.32100, actual: $data05
return -1
endi
sql create table st_float_7 using mt_float tags (+1.567)
sql select tagname from st_float_7
if $data00 != 1.56700 then
print expect 1.56700, actual: $data00
sql show tags from st_float_7
if $data05 != 1.56700 then
print expect 1.56700, actual: $data05
return -1
endi
sql create table st_float_8 using mt_float tags (379.001)
sql select tagname from st_float_8
if $data00 != 379.00101 then
print expect 379.00101, actual: $data00
sql show tags from st_float_8
if $data05 != 379.00101 then
print expect 379.00101, actual: $data05
return -1
endi
sql create table st_float_9 using mt_float tags (1.5e+3)
sql select tagname from st_float_9
if $data00 != 1500.00000 then
print expect 1500.00000, actual: $data00
sql show tags from st_float_9
if $data05 != 1500.00000 then
print expect 1500.00000, actual: $data05
return -1
endi
sql create table st_float_10 using mt_float tags (-1.5e-3)
sql select tagname from st_float_10
if $data00 != -0.00150 then
print expect -0.00150, actual: $data00
sql show tags from st_float_10
if $data05 != -0.00150 then
print expect -0.00150, actual: $data05
return -1
endi
sql create table st_float_11 using mt_float tags (+1.5e+3)
sql select tagname from st_float_11
if $data00 != 1500.00000 then
print expect 1500.00000, actual: $data00
sql show tags from st_float_11
if $data05 != 1500.00000 then
print expect 1500.00000, actual: $data05
return -1
endi
sql create table st_float_12 using mt_float tags (-1.5e+3)
sql select tagname from st_float_12
if $data00 != -1500.00000 then
print expect -1500.00000, actual: $data00
sql show tags from st_float_12
if $data05 != -1500.00000 then
print expect -1500.00000, actual: $data05
return -1
endi
sql create table st_float_13 using mt_float tags (1.5e-3)
sql select tagname from st_float_13
if $data00 != 0.00150 then
print expect 0.00150, actual: $data00
sql show tags from st_float_13
if $data05 != 0.00150 then
print expect 0.00150, actual: $data05
return -1
endi
sql create table st_float_14 using mt_float tags (1.5E-3)
sql select tagname from st_float_14
if $data00 != 0.00150 then
print expect 0.00150, actual: $data00
sql show tags from st_float_14
if $data05 != 0.00150 then
print expect 0.00150, actual: $data05
return -1
endi
sql create table st_float_6_0 using mt_float tags ('-123.321')
sql select tagname from st_float_6_0
if $data00 != -123.32100 then
print expect -123.32100, actual: $data00
sql show tags from st_float_6_0
if $data05 != -123.32100 then
print expect -123.32100, actual: $data05
return -1
endi
sql create table st_float_7_0 using mt_float tags ('+1.567')
sql select tagname from st_float_7_0
if $data00 != 1.56700 then
print expect 1.56700, actual: $data00
sql show tags from st_float_7_0
if $data05 != 1.56700 then
print expect 1.56700, actual: $data05
return -1
endi
sql create table st_float_8_0 using mt_float tags ('379.001')
sql select tagname from st_float_8_0
if $data00 != 379.00101 then
print expect 379.00101, actual: $data00
sql show tags from st_float_8_0
if $data05 != 379.00101 then
print expect 379.00101, actual: $data05
return -1
endi
sql create table st_float_9_0 using mt_float tags ('1.5e+3')
sql select tagname from st_float_9_0
if $data00 != 1500.00000 then
print expect 1500.00000, actual: $data00
sql show tags from st_float_9_0
if $data05 != 1500.00000 then
print expect 1500.00000, actual: $data05
return -1
endi
sql create table st_float_10_0 using mt_float tags ('-1.5e-3')
sql select tagname from st_float_10_0
if $data00 != -0.00150 then
print expect -0.00150, actual: $data00
sql show tags from st_float_10_0
if $data05 != -0.00150 then
print expect -0.00150, actual: $data05
return -1
endi
sql create table st_float_11_0 using mt_float tags ('+1.5e+3')
sql select tagname from st_float_11_0
if $data00 != 1500.00000 then
print expect 1500.00000, actual: $data00
sql show tags from st_float_11_0
if $data05 != 1500.00000 then
print expect 1500.00000, actual: $data05
return -1
endi
sql create table st_float_12_0 using mt_float tags ('-1.5e+3')
sql select tagname from st_float_12_0
if $data00 != -1500.00000 then
print expect -1500.00000, actual: $data00
sql show tags from st_float_12_0
if $data05 != -1500.00000 then
print expect -1500.00000, actual: $data05
return -1
endi
sql create table st_float_13_0 using mt_float tags ('1.5e-3')
sql select tagname from st_float_13_0
if $data00 != 0.00150 then
print expect 0.00150, actual: $data00
sql show tags from st_float_13_0
if $data05 != 0.00150 then
print expect 0.00150, actual: $data05
return -1
endi
sql create table st_float_14_0 using mt_float tags ('1.5E-3')
sql select tagname from st_float_14_0
if $data00 != 0.00150 then
print expect 0.00150, actual: $data00
sql show tags from st_float_14_0
if $data05 != 0.00150 then
print expect 0.00150, actual: $data05
return -1
endi
#sql create table st_float_15_0 using mt_float tags (3.40282347e+38)
#sql select tagname from st_float_15_0
#if $data00 != 0.001500 then
#sql show tags from st_float_15_0
#if $data05 != 0.001500 then
# return -1
#endi
#sql create table st_float_16_0 using mt_float tags (-3.40282347e+38)
#sql select tagname from st_float_16_0
#if $data00 != 0.001500 then
#sql show tags from st_float_16_0
#if $data05 != 0.001500 then
# return -1
#endi
@ -292,8 +299,8 @@ endi
## case 02: dynamic create table for test tag values
sql insert into st_float_16 using mt_float tags (NULL) values (now, NULL)
sql select tagname from st_float_16
if $data00 != NULL then
sql show tags from st_float_16
if $data05 != NULL then
return -1
endi
sql select * from st_float_16
@ -302,8 +309,8 @@ if $data01 != NULL then
endi
sql insert into st_float_17 using mt_float tags (NULL) values (now, NULL)
sql select tagname from st_float_17
if $data00 != NULL then
sql show tags from st_float_17
if $data05 != NULL then
return -1
endi
sql select * from st_float_17
@ -311,8 +318,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_float_18 using mt_float tags ('NULL') values (now, 'NULL')
sql select tagname from st_float_18
if $data00 != NULL then
sql show tags from st_float_18
if $data05 != NULL then
return -1
endi
sql select * from st_float_18
@ -320,8 +327,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_float_19 using mt_float tags ('NULL') values (now, 'NULL')
sql select tagname from st_float_19
if $data00 != NULL then
sql show tags from st_float_19
if $data05 != NULL then
return -1
endi
sql select * from st_float_19
@ -329,8 +336,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_float_20 using mt_float tags ("NULL") values (now, "NULL")
sql select tagname from st_float_20
if $data00 != NULL then
sql show tags from st_float_20
if $data05 != NULL then
return -1
endi
sql select * from st_float_20
@ -338,8 +345,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_float_21 using mt_float tags ("NULL") values (now, "NULL")
sql select tagname from st_float_21
if $data00 != NULL then
sql show tags from st_float_21
if $data05 != NULL then
return -1
endi
sql select * from st_float_21
@ -350,9 +357,9 @@ endi
sql_error insert into st_float_22 using mt_float tags (127) values (now, 3.40282347e+38)
sql insert into st_float_22 using mt_float tags (127) values (now, 340282346638528859811704183484516925440.00000)
sql select tagname from st_float_22
if $data00 != 127.00000 then
print expect 127.00000, actual: $data00
sql show tags from st_float_22
if $data05 != 127.00000 then
print expect 127.00000, actual: $data05
return -1
endi
@ -362,14 +369,14 @@ if $data01 != 127.00000 then
endi
sql insert into st_float_23 using mt_float tags (-127) values (now, -340282346638528859811704183484516925440.00000)
sql select tagname from st_float_23
if $data00 != -127.00000 then
sql show tags from st_float_23
if $data05 != -127.00000 then
return -1
endi
sql insert into st_float_24 using mt_float tags (10) values (now, 10)
sql select tagname from st_float_24
if $data00 != 10.00000 then
sql show tags from st_float_24
if $data05 != 10.00000 then
return -1
endi
sql select * from st_float_24
@ -378,9 +385,9 @@ if $data01 != 10.00000 then
endi
sql insert into st_float_25 using mt_float tags ("-0") values (now, "-0")
sql select tagname from st_float_25
if $data00 != -0.00000 then
print expect -0.00000, actual: $data00
sql show tags from st_float_25
if $data05 != -0.00000 then
print expect -0.00000, actual: $data05
return -1
endi
sql select * from st_float_25
@ -388,9 +395,9 @@ if $data01 != -0.00000 then
return -1
endi
sql insert into st_float_26 using mt_float tags ('123') values (now, '12.3')
sql select tagname from st_float_26
if $data00 != 123.00000 then
print expect 123.00000, actual: $data00
sql show tags from st_float_26
if $data05 != 123.00000 then
print expect 123.00000, actual: $data05
return -1
endi
sql select * from st_float_26
@ -398,9 +405,9 @@ if $data01 != 12.30000 then
return -1
endi
sql insert into st_float_27 using mt_float tags (+056) values (now, +0005.6)
sql select tagname from st_float_27
if $data00 != 56.00000 then
print expect 56.00000, actual:$data00
sql show tags from st_float_27
if $data05 != 56.00000 then
print expect 56.00000, actual:$data05
return -1
endi
sql select * from st_float_27
@ -408,8 +415,8 @@ if $data01 != 5.60000 then
return -1
endi
sql insert into st_float_28 using mt_float tags (-056) values (now, -005.6)
sql select tagname from st_float_28
if $data00 != -56.00000 then
sql show tags from st_float_28
if $data05 != -56.00000 then
return -1
endi
sql select * from st_float_28
@ -419,44 +426,44 @@ endi
### case 03: alter tag values
sql alter table st_float_0 set tag tagname=340282346638528859811704183484516925440.00000
sql select tagname from st_float_0
if $data00 != 340282346638528859811704183484516925440.00000 then
sql show tags from st_float_0
if $data05 != 340282346638528859811704183484516925440.00000 then
return -1
endi
sql alter table st_float_0 set tag tagname=-340282346638528859811704183484516925440.00000
sql select tagname from st_float_0
if $data00 != -340282346638528859811704183484516925440.00000 then
sql show tags from st_float_0
if $data05 != -340282346638528859811704183484516925440.00000 then
return -1
endi
sql alter table st_float_0 set tag tagname=+10.340
sql select tagname from st_float_0
if $data00 != 10.34000 then
sql show tags from st_float_0
if $data05 != 10.34000 then
return -1
endi
sql alter table st_float_0 set tag tagname=-33.87
sql select tagname from st_float_0
if $data00 != -33.87000 then
sql show tags from st_float_0
if $data05 != -33.87000 then
return -1
endi
sql alter table st_float_0 set tag tagname='+9.8'
sql select tagname from st_float_0
if $data00 != 9.80000 then
sql show tags from st_float_0
if $data05 != 9.80000 then
return -1
endi
sql alter table st_float_0 set tag tagname='-07.6'
sql select tagname from st_float_0
if $data00 != -7.60000 then
sql show tags from st_float_0
if $data05 != -7.60000 then
return -1
endi
sql alter table st_float_0 set tag tagname=+0012.871
sql select tagname from st_float_0
if $data00 != 12.87100 then
sql show tags from st_float_0
if $data05 != 12.87100 then
return -1
endi
sql alter table st_float_0 set tag tagname=-00063.582
sql select tagname from st_float_0
if $data00 != -63.58200 then
sql show tags from st_float_0
if $data05 != -63.58200 then
return -1
endi
@ -468,11 +475,11 @@ sql_error create table st_float_e0 using mt_float tags (-333.40282347e+38)
#sql_error create table st_float_e0 using mt_float tags (12.80) truncate integer part
#sql_error create table st_float_e0 using mt_float tags (-11.80)
sql_error create table st_float_e0 using mt_float tags (123abc)
sql_error create table st_float_e0 using mt_float tags ("123abc")
sql create table st_float_e0_1 using mt_float tags ("123abc")
sql_error create table st_float_e0 using mt_float tags (abc)
sql_error create table st_float_e0 using mt_float tags ("abc")
sql_error create table st_float_e0 using mt_float tags (" ")
sql_error create table st_float_e0 using mt_float tags ('')
sql create table st_float_e0_2 using mt_float tags ("abc")
sql create table st_float_e0_3 using mt_float tags (" ")
sql create table st_float_e0_4 using mt_float tags ('')
sql create table st_float_e0 using mt_float tags (123)
sql create table st_float_e1 using mt_float tags (123)
@ -499,7 +506,7 @@ sql_error insert into st_float_e7 values (now, "123abc")
sql_error insert into st_float_e9 values (now, abc)
sql_error insert into st_float_e10 values (now, "abc")
sql_error insert into st_float_e11 values (now, " ")
sql_error insert into st_float_e12 values (now, '')
sql insert into st_float_e12 values (now, '')
sql_error insert into st_float_e13 using mt_float tags (033) values (now, 3.50282347e+38)
sql_error insert into st_float_e14 using mt_float tags (033) values (now, -3.50282347e+38)
@ -512,7 +519,7 @@ sql_error insert into st_float_e20 using mt_float tags (033) values (now, "123ab
sql_error insert into st_float_e22 using mt_float tags (033) values (now, abc)
sql_error insert into st_float_e23 using mt_float tags (033) values (now, "abc")
sql_error insert into st_float_e24 using mt_float tags (033) values (now, " ")
sql_error insert into st_float_e25 using mt_float tags (033) values (now, '')
sql insert into st_float_e25_1 using mt_float tags (033) values (now, '')
sql_error insert into st_float_e13 using mt_float tags (3.50282347e+38) values (now, -033)
sql_error insert into st_float_e14 using mt_float tags (-3.50282347e+38) values (now, -033)
@ -525,7 +532,7 @@ sql_error insert into st_float_e20 using mt_float tags ("123abc") values (now, -
sql_error insert into st_float_e22 using mt_float tags (abc) values (now, -033)
sql_error insert into st_float_e23 using mt_float tags ("abc") values (now, -033)
sql_error insert into st_float_e24 using mt_float tags (" ") values (now, -033)
sql_error insert into st_float_e25 using mt_float tags ('') values (now, -033)
sql insert into st_float_e25_3 using mt_float tags ('') values (now, -033)
sql insert into st_float_e13 using mt_float tags (033) values (now, 00062)
sql insert into st_float_e14 using mt_float tags (033) values (now, 00062)
@ -546,8 +553,8 @@ sql_error alter table st_float_e14 set tag tagname=-3.50282347e+38
sql_error alter table st_float_e15 set tag tagname=13.40282347e+38
sql_error alter table st_float_e16 set tag tagname=-13.40282347e+38
sql_error alter table st_float_e19 set tag tagname=123abc
sql_error alter table st_float_e20 set tag tagname="123abc"
sql alter table st_float_e20 set tag tagname="123abc"
sql_error alter table st_float_e22 set tag tagname=abc
sql_error alter table st_float_e23 set tag tagname="abc"
sql_error alter table st_float_e24 set tag tagname=" "
sql_error alter table st_float_e25 set tag tagname=''
sql alter table st_float_e23 set tag tagname="abc"
sql alter table st_float_e24 set tag tagname=" "
sql alter table st_float_e25 set tag tagname=''

View File

@ -1,5 +1,12 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database if not exists db
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
@ -10,78 +17,64 @@ sql create table mt_int (ts timestamp, c int) tags (tagname int)
## case 00: static create table for test tag values
sql create table st_int_0 using mt_int tags (NULL)
sql select tagname from st_int_0
if $data00 != NULL then
sql show tags from st_int_0
if $data05 != NULL then
return -1
endi
sql create table st_int_1 using mt_int tags (NULL)
sql select tagname from st_int_1
if $data00 != NULL then
return -1
endi
sql create table st_int_2 using mt_int tags ('NULL')
sql select tagname from st_int_2
if $data00 != NULL then
return -1
endi
sql create table st_int_3 using mt_int tags ('NULL')
sql select tagname from st_int_3
if $data00 != NULL then
return -1
endi
sql create table st_int_4 using mt_int tags ("NULL")
sql select tagname from st_int_4
if $data00 != NULL then
return -1
endi
sql create table st_int_5 using mt_int tags ("NULL")
sql select tagname from st_int_5
if $data00 != NULL then
sql show tags from st_int_1
if $data05 != NULL then
return -1
endi
sql_error create table st_int_2 using mt_int tags ('NULL')
sql_error create table st_int_3 using mt_int tags ('NULL')
sql_error create table st_int_4 using mt_int tags ("NULL")
sql_error create table st_int_5 using mt_int tags ("NULL")
sql create table st_int_6 using mt_int tags (-2147483647)
sql select tagname from st_int_6
if $data00 != -2147483647 then
sql show tags from st_int_6
if $data05 != -2147483647 then
return -1
endi
sql create table st_int_7 using mt_int tags (2147483647)
sql select tagname from st_int_7
if $data00 != 2147483647 then
sql show tags from st_int_7
if $data05 != 2147483647 then
return -1
endi
sql create table st_int_8 using mt_int tags (37)
sql select tagname from st_int_8
if $data00 != 37 then
sql show tags from st_int_8
if $data05 != 37 then
return -1
endi
sql create table st_int_9 using mt_int tags (-100)
sql select tagname from st_int_9
if $data00 != -100 then
sql show tags from st_int_9
if $data05 != -100 then
return -1
endi
sql create table st_int_10 using mt_int tags (+113)
sql select tagname from st_int_10
if $data00 != 113 then
sql show tags from st_int_10
if $data05 != 113 then
return -1
endi
sql create table st_int_11 using mt_int tags ('-100')
sql select tagname from st_int_11
if $data00 != -100 then
sql show tags from st_int_11
if $data05 != -100 then
return -1
endi
sql create table st_int_12 using mt_int tags ("+78")
sql select tagname from st_int_12
if $data00 != 78 then
sql show tags from st_int_12
if $data05 != 78 then
return -1
endi
sql create table st_int_13 using mt_int tags (+0078)
sql select tagname from st_int_13
if $data00 != 78 then
sql show tags from st_int_13
if $data05 != 78 then
return -1
endi
sql create table st_int_14 using mt_int tags (-00078)
sql select tagname from st_int_14
if $data00 != -78 then
sql show tags from st_int_14
if $data05 != -78 then
return -1
endi
@ -102,38 +95,6 @@ endi
if $data01 != NULL then
return -1
endi
sql insert into st_int_2 values (now, 'NULL')
sql select * from st_int_2
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_int_3 values (now, 'NULL')
sql select * from st_int_3
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_int_4 values (now, "NULL")
sql select * from st_int_4
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_int_5 values (now, "NULL")
sql select * from st_int_5
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_int_6 values (now, 2147483647)
sql select * from st_int_6
if $rows != 1 then
@ -211,8 +172,8 @@ endi
## case 02: dynamic create table for test tag values
sql insert into st_int_16 using mt_int tags (NULL) values (now, NULL)
sql select tagname from st_int_16
if $data00 != NULL then
sql show tags from st_int_16
if $data05 != NULL then
return -1
endi
sql select * from st_int_16
@ -221,8 +182,8 @@ if $data01 != NULL then
endi
sql insert into st_int_17 using mt_int tags (NULL) values (now, NULL)
sql select tagname from st_int_17
if $data00 != NULL then
sql show tags from st_int_17
if $data05 != NULL then
return -1
endi
sql select * from st_int_17
@ -230,8 +191,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_int_18 using mt_int tags ('NULL') values (now, 'NULL')
sql select tagname from st_int_18
if $data00 != NULL then
sql show tags from st_int_18
if $data05 != NULL then
return -1
endi
sql select * from st_int_18
@ -239,8 +200,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_int_19 using mt_int tags ('NULL') values (now, 'NULL')
sql select tagname from st_int_19
if $data00 != NULL then
sql show tags from st_int_19
if $data05 != NULL then
return -1
endi
sql select * from st_int_19
@ -248,8 +209,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_int_20 using mt_int tags ("NULL") values (now, "NULL")
sql select tagname from st_int_20
if $data00 != NULL then
sql show tags from st_int_20
if $data05 != NULL then
return -1
endi
sql select * from st_int_20
@ -257,8 +218,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_int_21 using mt_int tags ("NULL") values (now, "NULL")
sql select tagname from st_int_21
if $data00 != NULL then
sql show tags from st_int_21
if $data05 != NULL then
return -1
endi
sql select * from st_int_21
@ -266,8 +227,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_int_22 using mt_int tags (2147483647) values (now, 2147483647)
sql select tagname from st_int_22
if $data00 != 2147483647 then
sql show tags from st_int_22
if $data05 != 2147483647 then
return -1
endi
sql select * from st_int_22
@ -275,8 +236,8 @@ if $data01 != 2147483647 then
return -1
endi
sql insert into st_int_23 using mt_int tags (-2147483647) values (now, -2147483647)
sql select tagname from st_int_23
if $data00 != -2147483647 then
sql show tags from st_int_23
if $data05 != -2147483647 then
return -1
endi
sql select * from st_int_23
@ -284,8 +245,8 @@ if $data01 != -2147483647 then
return -1
endi
sql insert into st_int_24 using mt_int tags (10) values (now, 10)
sql select tagname from st_int_24
if $data00 != 10 then
sql show tags from st_int_24
if $data05 != 10 then
return -1
endi
sql select * from st_int_24
@ -293,8 +254,8 @@ if $data01 != 10 then
return -1
endi
sql insert into st_int_25 using mt_int tags ("-0") values (now, "-0")
sql select tagname from st_int_25
if $data00 != 0 then
sql show tags from st_int_25
if $data05 != 0 then
return -1
endi
sql select * from st_int_25
@ -302,8 +263,8 @@ if $data01 != 0 then
return -1
endi
sql insert into st_int_26 using mt_int tags ('123') values (now, '123')
sql select tagname from st_int_26
if $data00 != 123 then
sql show tags from st_int_26
if $data05 != 123 then
return -1
endi
sql select * from st_int_26
@ -311,8 +272,8 @@ if $data01 != 123 then
return -1
endi
sql insert into st_int_27 using mt_int tags (+056) values (now, +00056)
sql select tagname from st_int_27
if $data00 != 56 then
sql show tags from st_int_27
if $data05 != 56 then
return -1
endi
sql select * from st_int_27
@ -320,8 +281,8 @@ if $data01 != 56 then
return -1
endi
sql insert into st_int_28 using mt_int tags (-056) values (now, -0056)
sql select tagname from st_int_28
if $data00 != -56 then
sql show tags from st_int_28
if $data05 != -56 then
return -1
endi
sql select * from st_int_28
@ -331,49 +292,49 @@ endi
### case 03: alter tag values
#sql alter table st_int_0 set tag tagname=2147483647
#sql select tagname from st_int_0
#if $data00 != 2147483647 then
#sql show tags from st_int_0
#if $data05 != 2147483647 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=-2147483647
#sql select tagname from st_int_0
#if $data00 != -2147483647 then
#sql show tags from st_int_0
#if $data05 != -2147483647 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=+100
#sql select tagname from st_int_0
#if $data00 != 100 then
#sql show tags from st_int_0
#if $data05 != 100 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=-33
#sql select tagname from st_int_0
#if $data00 != -33 then
#sql show tags from st_int_0
#if $data05 != -33 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname='+98'
#sql select tagname from st_int_0
#if $data00 != 98 then
#sql show tags from st_int_0
#if $data05 != 98 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname='-076'
#sql select tagname from st_int_0
#if $data00 != -76 then
#sql show tags from st_int_0
#if $data05 != -76 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=+0012
#sql select tagname from st_int_0
#if $data00 != 12 then
#sql show tags from st_int_0
#if $data05 != 12 then
# return -1
#endi
#sql alter table st_int_0 set tag tagname=-00063
#sql select tagname from st_int_0
#if $data00 != -63 then
#sql show tags from st_int_0
#if $data05 != -63 then
# return -1
#endi
## case 04: illegal input
sql_error create table st_int_e0 using mt_int tags (2147483648)
sql_error create table st_int_e0 using mt_int tags (-2147483648)
sql create table st_int_e0_err1 using mt_int tags (-2147483648)
sql_error create table st_int_e0 using mt_int tags (214748364800)
sql_error create table st_int_e0 using mt_int tags (-214748364800)
#sql_error create table st_int_e0 using mt_int tags (12.80) truncate integer part
@ -383,7 +344,7 @@ sql_error create table st_int_e0 using mt_int tags ("123abc")
sql_error create table st_int_e0 using mt_int tags (abc)
sql_error create table st_int_e0 using mt_int tags ("abc")
sql_error create table st_int_e0 using mt_int tags (" ")
sql_error create table st_int_e0 using mt_int tags ('')
sql create table st_int_e0_err2 using mt_int tags ('')
sql create table st_int_e0 using mt_int tags (123)
sql create table st_int_e1 using mt_int tags (123)
@ -400,7 +361,7 @@ sql create table st_int_e11 using mt_int tags (123)
sql create table st_int_e12 using mt_int tags (123)
sql_error insert into st_int_e0 values (now, 2147483648)
sql_error insert into st_int_e1 values (now, -2147483648)
sql insert into st_int_e1 values (now, -2147483648)
sql_error insert into st_int_e2 values (now, 3147483648)
sql_error insert into st_int_e3 values (now, -21474836481)
#sql_error insert into st_int_e4 values (now, 12.80)
@ -410,10 +371,10 @@ sql_error insert into st_int_e7 values (now, "123abc")
sql_error insert into st_int_e9 values (now, abc)
sql_error insert into st_int_e10 values (now, "abc")
sql_error insert into st_int_e11 values (now, " ")
sql_error insert into st_int_e12 values (now, '')
sql insert into st_int_e12 values (now, '')
sql_error insert into st_int_e13 using mt_int tags (033) values (now, 2147483648)
sql_error insert into st_int_e14 using mt_int tags (033) values (now, -2147483648)
sql insert into st_int_e14 using mt_int tags (033) values (now, -2147483648)
sql_error insert into st_int_e15 using mt_int tags (033) values (now, 5147483648)
sql_error insert into st_int_e16 using mt_int tags (033) values (now, -21474836481)
#sql_error insert into st_int_e17 using mt_int tags (033) values (now, 12.80)
@ -423,10 +384,10 @@ sql_error insert into st_int_e20 using mt_int tags (033) values (now, "123abc")
sql_error insert into st_int_e22 using mt_int tags (033) values (now, abc)
sql_error insert into st_int_e23 using mt_int tags (033) values (now, "abc")
sql_error insert into st_int_e24 using mt_int tags (033) values (now, " ")
sql_error insert into st_int_e25 using mt_int tags (033) values (now, '')
sql insert into st_int_e25 using mt_int tags (033) values (now, '')
sql_error insert into st_int_e13 using mt_int tags (2147483648) values (now, -033)
sql_error insert into st_int_e14 using mt_int tags (-2147483648) values (now, -033)
sql insert into st_int_e14_1 using mt_int tags (-2147483648) values (now, -033)
sql_error insert into st_int_e15 using mt_int tags (21474836480) values (now, -033)
sql_error insert into st_int_e16 using mt_int tags (-2147483649) values (now, -033)
#sql_error insert into st_int_e17 using mt_int tags (12.80) values (now, -033)
@ -436,7 +397,7 @@ sql_error insert into st_int_e20 using mt_int tags ("123abc") values (now, -033)
sql_error insert into st_int_e22 using mt_int tags (abc) values (now, -033)
sql_error insert into st_int_e23 using mt_int tags ("abc") values (now, -033)
sql_error insert into st_int_e24 using mt_int tags (" ") values (now, -033)
sql_error insert into st_int_e25 using mt_int tags ('') values (now, -033)
sql insert into st_int_e25_1 using mt_int tags ('') values (now, -033)
sql insert into st_int_e13 using mt_int tags (033) values (now, 00062)
sql insert into st_int_e14 using mt_int tags (033) values (now, 00062)
@ -453,7 +414,7 @@ sql insert into st_int_e24 using mt_int tags (033) values (now, 00062)
sql insert into st_int_e25 using mt_int tags (033) values (now, 00062)
sql_error alter table st_int_e13 set tag tagname=2147483648
sql_error alter table st_int_e14 set tag tagname=-2147483648
sql alter table st_int_e14 set tag tagname=-2147483648
sql_error alter table st_int_e15 set tag tagname=12147483648
sql_error alter table st_int_e16 set tag tagname=-3147483648
sql_error alter table st_int_e19 set tag tagname=123abc
@ -461,4 +422,4 @@ sql_error alter table st_int_e20 set tag tagname="123abc"
sql_error alter table st_int_e22 set tag tagname=abc
sql_error alter table st_int_e23 set tag tagname="abc"
sql_error alter table st_int_e24 set tag tagname=" "
sql_error alter table st_int_e25 set tag tagname=''
sql alter table st_int_e25 set tag tagname=''

View File

@ -1,6 +1,17 @@
sql create database if not exists db
sql use db
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
print ========== columnValues.sim
sql drop database if exists db
sql create database db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
######## case 0: smallint
@ -9,78 +20,64 @@ sql create table mt_smallint (ts timestamp, c smallint) tags (tagname smallint)
## case 00: static create table for test tag values
sql create table st_smallint_0 using mt_smallint tags (NULL)
sql select tagname from st_smallint_0
if $data00 != NULL then
sql show tags from st_smallint_0
if $data05 != NULL then
return -1
endi
sql create table st_smallint_1 using mt_smallint tags (NULL)
sql select tagname from st_smallint_1
if $data00 != NULL then
return -1
endi
sql create table st_smallint_2 using mt_smallint tags ('NULL')
sql select tagname from st_smallint_2
if $data00 != NULL then
return -1
endi
sql create table st_smallint_3 using mt_smallint tags ('NULL')
sql select tagname from st_smallint_3
if $data00 != NULL then
return -1
endi
sql create table st_smallint_4 using mt_smallint tags ("NULL")
sql select tagname from st_smallint_4
if $data00 != NULL then
return -1
endi
sql create table st_smallint_5 using mt_smallint tags ("NULL")
sql select tagname from st_smallint_5
if $data00 != NULL then
sql show tags from st_smallint_1
if $data05 != NULL then
return -1
endi
sql_error create table st_smallint_2 using mt_smallint tags ('NULL')
sql_error create table st_smallint_3 using mt_smallint tags ('NULL')
sql_error create table st_smallint_4 using mt_smallint tags ("NULL")
sql_error create table st_smallint_5 using mt_smallint tags ("NULL")
sql create table st_smallint_6 using mt_smallint tags (-32767)
sql select tagname from st_smallint_6
if $data00 != -32767 then
sql show tags from st_smallint_6
if $data05 != -32767 then
return -1
endi
sql create table st_smallint_7 using mt_smallint tags (32767)
sql select tagname from st_smallint_7
if $data00 != 32767 then
sql show tags from st_smallint_7
if $data05 != 32767 then
return -1
endi
sql create table st_smallint_8 using mt_smallint tags (37)
sql select tagname from st_smallint_8
if $data00 != 37 then
sql show tags from st_smallint_8
if $data05 != 37 then
return -1
endi
sql create table st_smallint_9 using mt_smallint tags (-100)
sql select tagname from st_smallint_9
if $data00 != -100 then
sql show tags from st_smallint_9
if $data05 != -100 then
return -1
endi
sql create table st_smallint_10 using mt_smallint tags (+113)
sql select tagname from st_smallint_10
if $data00 != 113 then
sql show tags from st_smallint_10
if $data05 != 113 then
return -1
endi
sql create table st_smallint_11 using mt_smallint tags ('-100')
sql select tagname from st_smallint_11
if $data00 != -100 then
sql show tags from st_smallint_11
if $data05 != -100 then
return -1
endi
sql create table st_smallint_12 using mt_smallint tags ("+78")
sql select tagname from st_smallint_12
if $data00 != 78 then
sql show tags from st_smallint_12
if $data05 != 78 then
return -1
endi
sql create table st_smallint_13 using mt_smallint tags (+0078)
sql select tagname from st_smallint_13
if $data00 != 78 then
sql show tags from st_smallint_13
if $data05 != 78 then
return -1
endi
sql create table st_smallint_14 using mt_smallint tags (-00078)
sql select tagname from st_smallint_14
if $data00 != -78 then
sql show tags from st_smallint_14
if $data05 != -78 then
return -1
endi
@ -101,38 +98,6 @@ endi
if $data01 != NULL then
return -1
endi
sql insert into st_smallint_2 values (now, 'NULL')
sql select * from st_smallint_2
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_smallint_3 values (now, 'NULL')
sql select * from st_smallint_3
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_smallint_4 values (now, "NULL")
sql select * from st_smallint_4
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_smallint_5 values (now, "NULL")
sql select * from st_smallint_5
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_smallint_6 values (now, 32767)
sql select * from st_smallint_6
if $rows != 1 then
@ -210,8 +175,8 @@ endi
## case 02: dynamic create table for test tag values
sql insert into st_smallint_16 using mt_smallint tags (NULL) values (now, NULL)
sql select tagname from st_smallint_16
if $data00 != NULL then
sql show tags from st_smallint_16
if $data05 != NULL then
return -1
endi
sql select * from st_smallint_16
@ -220,8 +185,8 @@ if $data01 != NULL then
endi
sql insert into st_smallint_17 using mt_smallint tags (NULL) values (now, NULL)
sql select tagname from st_smallint_17
if $data00 != NULL then
sql show tags from st_smallint_17
if $data05 != NULL then
return -1
endi
sql select * from st_smallint_17
@ -229,8 +194,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_smallint_18 using mt_smallint tags ('NULL') values (now, 'NULL')
sql select tagname from st_smallint_18
if $data00 != NULL then
sql show tags from st_smallint_18
if $data05 != NULL then
return -1
endi
sql select * from st_smallint_18
@ -238,8 +203,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_smallint_19 using mt_smallint tags ('NULL') values (now, 'NULL')
sql select tagname from st_smallint_19
if $data00 != NULL then
sql show tags from st_smallint_19
if $data05 != NULL then
return -1
endi
sql select * from st_smallint_19
@ -247,8 +212,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_smallint_20 using mt_smallint tags ("NULL") values (now, "NULL")
sql select tagname from st_smallint_20
if $data00 != NULL then
sql show tags from st_smallint_20
if $data05 != NULL then
return -1
endi
sql select * from st_smallint_20
@ -256,8 +221,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_smallint_21 using mt_smallint tags ("NULL") values (now, "NULL")
sql select tagname from st_smallint_21
if $data00 != NULL then
sql show tags from st_smallint_21
if $data05 != NULL then
return -1
endi
sql select * from st_smallint_21
@ -265,8 +230,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_smallint_22 using mt_smallint tags (32767) values (now, 32767)
sql select tagname from st_smallint_22
if $data00 != 32767 then
sql show tags from st_smallint_22
if $data05 != 32767 then
return -1
endi
sql select * from st_smallint_22
@ -274,8 +239,8 @@ if $data01 != 32767 then
return -1
endi
sql insert into st_smallint_23 using mt_smallint tags (-32767) values (now, -32767)
sql select tagname from st_smallint_23
if $data00 != -32767 then
sql show tags from st_smallint_23
if $data05 != -32767 then
return -1
endi
sql select * from st_smallint_23
@ -283,8 +248,8 @@ if $data01 != -32767 then
return -1
endi
sql insert into st_smallint_24 using mt_smallint tags (10) values (now, 10)
sql select tagname from st_smallint_24
if $data00 != 10 then
sql show tags from st_smallint_24
if $data05 != 10 then
return -1
endi
sql select * from st_smallint_24
@ -292,8 +257,8 @@ if $data01 != 10 then
return -1
endi
sql insert into st_smallint_25 using mt_smallint tags ("-0") values (now, "-0")
sql select tagname from st_smallint_25
if $data00 != 0 then
sql show tags from st_smallint_25
if $data05 != 0 then
return -1
endi
sql select * from st_smallint_25
@ -301,8 +266,8 @@ if $data01 != 0 then
return -1
endi
sql insert into st_smallint_26 using mt_smallint tags ('123') values (now, '123')
sql select tagname from st_smallint_26
if $data00 != 123 then
sql show tags from st_smallint_26
if $data05 != 123 then
return -1
endi
sql select * from st_smallint_26
@ -310,8 +275,8 @@ if $data01 != 123 then
return -1
endi
sql insert into st_smallint_27 using mt_smallint tags (+056) values (now, +00056)
sql select tagname from st_smallint_27
if $data00 != 56 then
sql show tags from st_smallint_27
if $data05 != 56 then
return -1
endi
sql select * from st_smallint_27
@ -319,8 +284,8 @@ if $data01 != 56 then
return -1
endi
sql insert into st_smallint_28 using mt_smallint tags (-056) values (now, -0056)
sql select tagname from st_smallint_28
if $data00 != -56 then
sql show tags from st_smallint_28
if $data05 != -56 then
return -1
endi
sql select * from st_smallint_28
@ -330,49 +295,49 @@ endi
## case 03: alter tag values
#sql alter table st_smallint_0 set tag tagname=32767
#sql select tagname from st_smallint_0
#if $data00 != 32767 then
#sql show tags from st_smallint_0
#if $data05 != 32767 then
# return -1
#endi
#sql alter table st_smallint_0 set tag tagname=-32767
#sql select tagname from st_smallint_0
#if $data00 != -32767 then
#sql show tags from st_smallint_0
#if $data05 != -32767 then
# return -1
#endi
#sql alter table st_smallint_0 set tag tagname=+100
#sql select tagname from st_smallint_0
#if $data00 != 100 then
#sql show tags from st_smallint_0
#if $data05 != 100 then
# return -1
#endi
#sql alter table st_smallint_0 set tag tagname=-33
#sql select tagname from st_smallint_0
#if $data00 != -33 then
#sql show tags from st_smallint_0
#if $data05 != -33 then
# return -1
#endi
#sql alter table st_smallint_0 set tag tagname='+98'
#sql select tagname from st_smallint_0
#if $data00 != 98 then
#sql show tags from st_smallint_0
#if $data05 != 98 then
# return -1
#endi
#sql alter table st_smallint_0 set tag tagname='-076'
#sql select tagname from st_smallint_0
#if $data00 != -76 then
#sql show tags from st_smallint_0
#if $data05 != -76 then
# return -1
#endi
#sql alter table st_smallint_0 set tag tagname=+0012
#sql select tagname from st_smallint_0
#if $data00 != 12 then
#sql show tags from st_smallint_0
#if $data05 != 12 then
# return -1
#endi
#sql alter table st_smallint_0 set tag tagname=-00063
#sql select tagname from st_smallint_0
#if $data00 != -63 then
#sql show tags from st_smallint_0
#if $data05 != -63 then
# return -1
#endi
## case 04: illegal input
sql_error create table st_smallint_e0 using mt_smallint tags (32768)
sql_error create table st_smallint_e0 using mt_smallint tags (-32768)
sql create table st_smallint_e0_0 using mt_smallint tags (-32768)
sql_error create table st_smallint_e0 using mt_smallint tags (3276899)
sql_error create table st_smallint_e0 using mt_smallint tags (-3276833)
#sql_error create table st_smallint_e0 using mt_smallint tags (12.80) truncate integer part
@ -382,7 +347,7 @@ sql_error create table st_smallint_e0 using mt_smallint tags ("123abc")
sql_error create table st_smallint_e0 using mt_smallint tags (abc)
sql_error create table st_smallint_e0 using mt_smallint tags ("abc")
sql_error create table st_smallint_e0 using mt_smallint tags (" ")
sql_error create table st_smallint_e0 using mt_smallint tags ('')
sql create table st_smallint_e0_1 using mt_smallint tags ('')
sql create table st_smallint_e0 using mt_smallint tags (123)
sql create table st_smallint_e1 using mt_smallint tags (123)
@ -399,7 +364,7 @@ sql create table st_smallint_e11 using mt_smallint tags (123)
sql create table st_smallint_e12 using mt_smallint tags (123)
sql_error insert into st_smallint_e0 values (now, 32768)
sql_error insert into st_smallint_e1 values (now, -32768)
sql insert into st_smallint_e1 values (now, -32768)
sql_error insert into st_smallint_e2 values (now, 42768)
sql_error insert into st_smallint_e3 values (now, -32769)
#sql_error insert into st_smallint_e4 values (now, 12.80)
@ -409,10 +374,10 @@ sql_error insert into st_smallint_e7 values (now, "123abc")
sql_error insert into st_smallint_e9 values (now, abc)
sql_error insert into st_smallint_e10 values (now, "abc")
sql_error insert into st_smallint_e11 values (now, " ")
sql_error insert into st_smallint_e12 values (now, '')
sql insert into st_smallint_e12 values (now, '')
sql_error insert into st_smallint_e13 using mt_smallint tags (033) values (now, 32768)
sql_error insert into st_smallint_e14 using mt_smallint tags (033) values (now, -32768)
sql insert into st_smallint_e14_1 using mt_smallint tags (033) values (now, -32768)
sql_error insert into st_smallint_e15 using mt_smallint tags (033) values (now, 32968)
sql_error insert into st_smallint_e16 using mt_smallint tags (033) values (now, -33768)
#sql_error insert into st_smallint_e17 using mt_smallint tags (033) values (now, 12.80)
@ -422,10 +387,10 @@ sql_error insert into st_smallint_e20 using mt_smallint tags (033) values (now,
sql_error insert into st_smallint_e22 using mt_smallint tags (033) values (now, abc)
sql_error insert into st_smallint_e23 using mt_smallint tags (033) values (now, "abc")
sql_error insert into st_smallint_e24 using mt_smallint tags (033) values (now, " ")
sql_error insert into st_smallint_e25 using mt_smallint tags (033) values (now, '')
sql insert into st_smallint_e25_1 using mt_smallint tags (033) values (now, '')
sql_error insert into st_smallint_e13 using mt_smallint tags (32768) values (now, -033)
sql_error insert into st_smallint_e14 using mt_smallint tags (-32768) values (now, -033)
sql insert into st_smallint_e14 using mt_smallint tags (-32768) values (now, -033)
sql_error insert into st_smallint_e15 using mt_smallint tags (72768) values (now, -033)
sql_error insert into st_smallint_e16 using mt_smallint tags (-92768) values (now, -033)
#sql_error insert into st_smallint_e17 using mt_smallint tags (12.80) values (now, -033)
@ -435,7 +400,7 @@ sql_error insert into st_smallint_e20 using mt_smallint tags ("123abc") values (
sql_error insert into st_smallint_e22 using mt_smallint tags (abc) values (now, -033)
sql_error insert into st_smallint_e23 using mt_smallint tags ("abc") values (now, -033)
sql_error insert into st_smallint_e24 using mt_smallint tags (" ") values (now, -033)
sql_error insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033)
sql insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033)
sql insert into st_smallint_e13 using mt_smallint tags (033) values (now, 00062)
sql insert into st_smallint_e14 using mt_smallint tags (033) values (now, 00062)
@ -452,7 +417,7 @@ sql insert into st_smallint_e24 using mt_smallint tags (033) values (now, 00062)
sql insert into st_smallint_e25 using mt_smallint tags (033) values (now, 00062)
sql_error alter table st_smallint_e13 set tag tagname=32768
sql_error alter table st_smallint_e14 set tag tagname=-32768
sql alter table st_smallint_e14 set tag tagname=-32768
sql_error alter table st_smallint_e15 set tag tagname=52768
sql_error alter table st_smallint_e16 set tag tagname=-32778
sql_error alter table st_smallint_e19 set tag tagname=123abc
@ -460,4 +425,4 @@ sql_error alter table st_smallint_e20 set tag tagname="123abc"
sql_error alter table st_smallint_e22 set tag tagname=abc
sql_error alter table st_smallint_e23 set tag tagname="abc"
sql_error alter table st_smallint_e24 set tag tagname=" "
sql_error alter table st_smallint_e25 set tag tagname=''
sql alter table st_smallint_e25 set tag tagname=''

View File

@ -1,4 +1,12 @@
sql create database if not exists db
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value
@ -9,79 +17,65 @@ sql create table mt_tinyint (ts timestamp, c tinyint) tags (tagname tinyint)
## case 00: static create table for test tag values
sql create table st_tinyint_0 using mt_tinyint tags (NULL)
sql select tagname from st_tinyint_0
if $data00 != NULL then
print expect NULL, actually: $data00
sql show tags from st_tinyint_0
if $data05 != NULL then
print expect NULL, actually: $data05
return -1
endi
sql create table st_tinyint_1 using mt_tinyint tags (NULL)
sql select tagname from st_tinyint_1
if $data00 != NULL then
return -1
endi
sql create table st_tinyint_2 using mt_tinyint tags ('NULL')
sql select tagname from st_tinyint_2
if $data00 != NULL then
return -1
endi
sql create table st_tinyint_3 using mt_tinyint tags ('NULL')
sql select tagname from st_tinyint_3
if $data00 != NULL then
return -1
endi
sql create table st_tinyint_4 using mt_tinyint tags ("NULL")
sql select tagname from st_tinyint_4
if $data00 != NULL then
return -1
endi
sql create table st_tinyint_5 using mt_tinyint tags ("NULL")
sql select tagname from st_tinyint_5
if $data00 != NULL then
sql show tags from st_tinyint_1
if $data05 != NULL then
return -1
endi
sql_error create table st_tinyint_2 using mt_tinyint tags ('NULL')
sql_error create table st_tinyint_3 using mt_tinyint tags ('NULL')
sql_error create table st_tinyint_4 using mt_tinyint tags ("NULL")
sql_error create table st_tinyint_5 using mt_tinyint tags ("NULL")
sql create table st_tinyint_6 using mt_tinyint tags (-127)
sql select tagname from st_tinyint_6
if $data00 != -127 then
sql show tags from st_tinyint_6
if $data05 != -127 then
return -1
endi
sql create table st_tinyint_7 using mt_tinyint tags (127)
sql select tagname from st_tinyint_7
if $data00 != 127 then
sql show tags from st_tinyint_7
if $data05 != 127 then
return -1
endi
sql create table st_tinyint_8 using mt_tinyint tags (37)
sql select tagname from st_tinyint_8
if $data00 != 37 then
sql show tags from st_tinyint_8
if $data05 != 37 then
return -1
endi
sql create table st_tinyint_9 using mt_tinyint tags (-100)
sql select tagname from st_tinyint_9
if $data00 != -100 then
sql show tags from st_tinyint_9
if $data05 != -100 then
return -1
endi
sql create table st_tinyint_10 using mt_tinyint tags (+113)
sql select tagname from st_tinyint_10
if $data00 != 113 then
sql show tags from st_tinyint_10
if $data05 != 113 then
return -1
endi
sql create table st_tinyint_11 using mt_tinyint tags ('-100')
sql select tagname from st_tinyint_11
if $data00 != -100 then
sql show tags from st_tinyint_11
if $data05 != -100 then
return -1
endi
sql create table st_tinyint_12 using mt_tinyint tags ("+78")
sql select tagname from st_tinyint_12
if $data00 != 78 then
sql show tags from st_tinyint_12
if $data05 != 78 then
return -1
endi
sql create table st_tinyint_13 using mt_tinyint tags (+0078)
sql select tagname from st_tinyint_13
if $data00 != 78 then
sql show tags from st_tinyint_13
if $data05 != 78 then
return -1
endi
sql create table st_tinyint_14 using mt_tinyint tags (-00078)
sql select tagname from st_tinyint_14
if $data00 != -78 then
sql show tags from st_tinyint_14
if $data05 != -78 then
return -1
endi
@ -102,38 +96,6 @@ endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_2 values (now, 'NULL')
sql select * from st_tinyint_2
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_3 values (now, 'NULL')
sql select * from st_tinyint_3
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_4 values (now, "NULL")
sql select * from st_tinyint_4
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_5 values (now, "NULL")
sql select * from st_tinyint_5
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_6 values (now, 127)
sql select * from st_tinyint_6
if $rows != 1 then
@ -211,8 +173,8 @@ endi
## case 02: dynamic create table for test tag values
sql insert into st_tinyint_16 using mt_tinyint tags (NULL) values (now, NULL)
sql select tagname from st_tinyint_16
if $data00 != NULL then
sql show tags from st_tinyint_16
if $data05 != NULL then
return -1
endi
sql select * from st_tinyint_16
@ -221,8 +183,8 @@ if $data01 != NULL then
endi
sql insert into st_tinyint_17 using mt_tinyint tags (NULL) values (now, NULL)
sql select tagname from st_tinyint_17
if $data00 != NULL then
sql show tags from st_tinyint_17
if $data05 != NULL then
return -1
endi
sql select * from st_tinyint_17
@ -230,8 +192,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_18 using mt_tinyint tags ('NULL') values (now, 'NULL')
sql select tagname from st_tinyint_18
if $data00 != NULL then
sql show tags from st_tinyint_18
if $data05 != NULL then
return -1
endi
sql select * from st_tinyint_18
@ -239,8 +201,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_19 using mt_tinyint tags ('NULL') values (now, 'NULL')
sql select tagname from st_tinyint_19
if $data00 != NULL then
sql show tags from st_tinyint_19
if $data05 != NULL then
return -1
endi
sql select * from st_tinyint_19
@ -248,8 +210,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_20 using mt_tinyint tags ("NULL") values (now, "NULL")
sql select tagname from st_tinyint_20
if $data00 != NULL then
sql show tags from st_tinyint_20
if $data05 != NULL then
return -1
endi
sql select * from st_tinyint_20
@ -257,8 +219,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_21 using mt_tinyint tags ("NULL") values (now, "NULL")
sql select tagname from st_tinyint_21
if $data00 != NULL then
sql show tags from st_tinyint_21
if $data05 != NULL then
return -1
endi
sql select * from st_tinyint_21
@ -266,8 +228,8 @@ if $data01 != NULL then
return -1
endi
sql insert into st_tinyint_22 using mt_tinyint tags (127) values (now, 127)
sql select tagname from st_tinyint_22
if $data00 != 127 then
sql show tags from st_tinyint_22
if $data05 != 127 then
return -1
endi
sql select * from st_tinyint_22
@ -275,8 +237,8 @@ if $data01 != 127 then
return -1
endi
sql insert into st_tinyint_23 using mt_tinyint tags (-127) values (now, -127)
sql select tagname from st_tinyint_23
if $data00 != -127 then
sql show tags from st_tinyint_23
if $data05 != -127 then
return -1
endi
sql select * from st_tinyint_23
@ -284,8 +246,8 @@ if $data01 != -127 then
return -1
endi
sql insert into st_tinyint_24 using mt_tinyint tags (10) values (now, 10)
sql select tagname from st_tinyint_24
if $data00 != 10 then
sql show tags from st_tinyint_24
if $data05 != 10 then
return -1
endi
sql select * from st_tinyint_24
@ -293,8 +255,8 @@ if $data01 != 10 then
return -1
endi
sql insert into st_tinyint_25 using mt_tinyint tags ("-0") values (now, "-0")
sql select tagname from st_tinyint_25
if $data00 != 0 then
sql show tags from st_tinyint_25
if $data05 != 0 then
return -1
endi
sql select * from st_tinyint_25
@ -302,8 +264,8 @@ if $data01 != 0 then
return -1
endi
sql insert into st_tinyint_26 using mt_tinyint tags ('123') values (now, '123')
sql select tagname from st_tinyint_26
if $data00 != 123 then
sql show tags from st_tinyint_26
if $data05 != 123 then
return -1
endi
sql select * from st_tinyint_26
@ -311,8 +273,8 @@ if $data01 != 123 then
return -1
endi
sql insert into st_tinyint_27 using mt_tinyint tags (+056) values (now, +00056)
sql select tagname from st_tinyint_27
if $data00 != 56 then
sql show tags from st_tinyint_27
if $data05 != 56 then
return -1
endi
sql select * from st_tinyint_27
@ -320,8 +282,8 @@ if $data01 != 56 then
return -1
endi
sql insert into st_tinyint_28 using mt_tinyint tags (-056) values (now, -0056)
sql select tagname from st_tinyint_28
if $data00 != -56 then
sql show tags from st_tinyint_28
if $data05 != -56 then
return -1
endi
sql select * from st_tinyint_28
@ -331,49 +293,49 @@ endi
## case 03: alter tag values
#sql alter table st_tinyint_0 set tag tagname=127
#sql select tagname from st_tinyint_0
#if $data00 != 127 then
#sql show tags from st_tinyint_0
#if $data05 != 127 then
# return -1
#endi
#sql alter table st_tinyint_0 set tag tagname=-127
#sql select tagname from st_tinyint_0
#if $data00 != -127 then
#sql show tags from st_tinyint_0
#if $data05 != -127 then
# return -1
#endi
#sql alter table st_tinyint_0 set tag tagname=+100
#sql select tagname from st_tinyint_0
#if $data00 != 100 then
#sql show tags from st_tinyint_0
#if $data05 != 100 then
# return -1
#endi
#sql alter table st_tinyint_0 set tag tagname=-33
#sql select tagname from st_tinyint_0
#if $data00 != -33 then
#sql show tags from st_tinyint_0
#if $data05 != -33 then
# return -1
#endi
#sql alter table st_tinyint_0 set tag tagname='+98'
#sql select tagname from st_tinyint_0
#if $data00 != 98 then
#sql show tags from st_tinyint_0
#if $data05 != 98 then
# return -1
#endi
#sql alter table st_tinyint_0 set tag tagname='-076'
#sql select tagname from st_tinyint_0
#if $data00 != -76 then
#sql show tags from st_tinyint_0
#if $data05 != -76 then
# return -1
#endi
#sql alter table st_tinyint_0 set tag tagname=+0012
#sql select tagname from st_tinyint_0
#if $data00 != 12 then
#sql show tags from st_tinyint_0
#if $data05 != 12 then
# return -1
#endi
#sql alter table st_tinyint_0 set tag tagname=-00063
#sql select tagname from st_tinyint_0
#if $data00 != -63 then
#sql show tags from st_tinyint_0
#if $data05 != -63 then
# return -1
#endi
## case 04: illegal input
sql_error create table st_tinyint_e0 using mt_tinyint tags (128)
sql_error create table st_tinyint_e0 using mt_tinyint tags (-128)
sql create table st_tinyint_e0_1 using mt_tinyint tags (-128)
sql_error create table st_tinyint_e0 using mt_tinyint tags (1280)
sql_error create table st_tinyint_e0 using mt_tinyint tags (-1280)
#sql_error create table st_tinyint_e0 using mt_tinyint tags (12.80) truncate integer part
@ -383,7 +345,7 @@ sql_error create table st_tinyint_e0 using mt_tinyint tags ("123abc")
sql_error create table st_tinyint_e0 using mt_tinyint tags (abc)
sql_error create table st_tinyint_e0 using mt_tinyint tags ("abc")
sql_error create table st_tinyint_e0 using mt_tinyint tags (" ")
sql_error create table st_tinyint_e0 using mt_tinyint tags ('')
sql create table st_tinyint_e0_2 using mt_tinyint tags ('')
sql create table st_tinyint_e0 using mt_tinyint tags (123)
sql create table st_tinyint_e1 using mt_tinyint tags (123)
@ -400,7 +362,7 @@ sql create table st_tinyint_e11 using mt_tinyint tags (123)
sql create table st_tinyint_e12 using mt_tinyint tags (123)
sql_error insert into st_tinyint_e0 values (now, 128)
sql_error insert into st_tinyint_e1 values (now, -128)
sql insert into st_tinyint_e1 values (now, -128)
sql_error insert into st_tinyint_e2 values (now, 1280)
sql_error insert into st_tinyint_e3 values (now, -1280)
#sql_error insert into st_tinyint_e4 values (now, 12.80)
@ -410,10 +372,10 @@ sql_error insert into st_tinyint_e7 values (now, "123abc")
sql_error insert into st_tinyint_e9 values (now, abc)
sql_error insert into st_tinyint_e10 values (now, "abc")
sql_error insert into st_tinyint_e11 values (now, " ")
sql_error insert into st_tinyint_e12 values (now, '')
sql insert into st_tinyint_e12 values (now, '')
sql_error insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 128)
sql_error insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, -128)
sql insert into st_tinyint_e14_1 using mt_tinyint tags (033) values (now, -128)
sql_error insert into st_tinyint_e15 using mt_tinyint tags (033) values (now, 1280)
sql_error insert into st_tinyint_e16 using mt_tinyint tags (033) values (now, -1280)
#sql_error insert into st_tinyint_e17 using mt_tinyint tags (033) values (now, 12.80)
@ -423,10 +385,10 @@ sql_error insert into st_tinyint_e20 using mt_tinyint tags (033) values (now, "1
sql_error insert into st_tinyint_e22 using mt_tinyint tags (033) values (now, abc)
sql_error insert into st_tinyint_e23 using mt_tinyint tags (033) values (now, "abc")
sql_error insert into st_tinyint_e24 using mt_tinyint tags (033) values (now, " ")
sql_error insert into st_tinyint_e25 using mt_tinyint tags (033) values (now, '')
sql insert into st_tinyint_e25_2 using mt_tinyint tags (033) values (now, '')
sql_error insert into st_tinyint_e13 using mt_tinyint tags (128) values (now, -033)
sql_error insert into st_tinyint_e14 using mt_tinyint tags (-128) values (now, -033)
sql insert into st_tinyint_e14 using mt_tinyint tags (-128) values (now, -033)
sql_error insert into st_tinyint_e15 using mt_tinyint tags (1280) values (now, -033)
sql_error insert into st_tinyint_e16 using mt_tinyint tags (-1280) values (now, -033)
#sql_error insert into st_tinyint_e17 using mt_tinyint tags (12.80) values (now, -033)
@ -436,7 +398,7 @@ sql_error insert into st_tinyint_e20 using mt_tinyint tags ("123abc") values (no
sql_error insert into st_tinyint_e22 using mt_tinyint tags (abc) values (now, -033)
sql_error insert into st_tinyint_e23 using mt_tinyint tags ("abc") values (now, -033)
sql_error insert into st_tinyint_e24 using mt_tinyint tags (" ") values (now, -033)
sql_error insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033)
sql insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033)
sql insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 00062)
sql insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, 00062)
@ -453,7 +415,7 @@ sql insert into st_tinyint_e24 using mt_tinyint tags (033) values (now, 00062)
sql insert into st_tinyint_e25 using mt_tinyint tags (033) values (now, 00062)
sql_error alter table st_tinyint_e13 set tag tagname=128
sql_error alter table st_tinyint_e14 set tag tagname=-128
sql alter table st_tinyint_e14 set tag tagname=-128
sql_error alter table st_tinyint_e15 set tag tagname=1280
sql_error alter table st_tinyint_e16 set tag tagname=-1280
sql_error alter table st_tinyint_e19 set tag tagname=123abc
@ -461,4 +423,4 @@ sql_error alter table st_tinyint_e20 set tag tagname="123abc"
sql_error alter table st_tinyint_e22 set tag tagname=abc
sql_error alter table st_tinyint_e23 set tag tagname="abc"
sql_error alter table st_tinyint_e24 set tag tagname=" "
sql_error alter table st_tinyint_e25 set tag tagname=''
sql alter table st_tinyint_e25 set tag tagname=''

View File

@ -1,4 +1,12 @@
sql create database if not exists db
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ========== columnValues.sim
sql drop database if exists db
sql create database db
sql use db
sql drop table if exists mt_unsigned;
@ -10,28 +18,21 @@ sql alter table mt_unsigned_1 set tag t1=138;
sql alter table mt_unsigned_1 set tag t2=32769;
sql alter table mt_unsigned_1 set tag t3=294967295;
sql alter table mt_unsigned_1 set tag t4=446744073709551615;
sql insert into mt_unsigned_1 values (now, 0, 0, 0, 0, 0, 0, 0, 0, 0)
sql select t1,t2,t3,t4 from mt_unsigned_1
if $rows != 1 then
return -1
endi
print $data00, $data01, $data02, $data03
if $data00 != 138 then
print expect 138, actual: $data00
return -1
endi
print $data01, $data02, $data03
if $data01 != 32769 then
return -1
return -1
endi
if $data02 != 294967295 then
return -1
return -1
endi
if $data03 != 446744073709551615 then
return -1
return -1
endi
sql_error sql alter table mt_unsigned_1 set tag t1 = 999;
@ -44,10 +45,10 @@ sql_error create table mt_unsigned_3 using mt_unsigned tags(0, -1, 0, 0, 0, 0, 0
sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, -1, 0, 0, 0, 0, 0);
sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, -1, 0, 0, 0, 0);
sql_error create table mt_unsigned_2 using mt_unsigned tags(255, 0, 0, 0, 0, 0, 0, 0);
sql_error create table mt_unsigned_3 using mt_unsigned tags(0, 65535, 0, 0, 0, 0, 0, 0);
sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, 4294967295, 0, 0, 0, 0, 0);
sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, 18446744073709551615, 0, 0, 0, 0);
sql create table mt_unsigned_21 using mt_unsigned tags(255, 0, 0, 0, 0, 0, 0, 0);
sql create table mt_unsigned_31 using mt_unsigned tags(0, 65535, 0, 0, 0, 0, 0, 0);
sql create table mt_unsigned_41 using mt_unsigned tags(0, 0, 4294967295, 0, 0, 0, 0, 0);
sql create table mt_unsigned_51 using mt_unsigned tags(0, 0, 0, 18446744073709551615, 0, 0, 0, 0);
sql_error create table mt_unsigned_2 using mt_unsigned tags(999, 0, 0, 0, 0, 0, 0, 0);
sql_error create table mt_unsigned_3 using mt_unsigned tags(0, 95535, 0, 0, 0, 0, 0, 0);
@ -63,11 +64,6 @@ if $rows != 1 then
return -1;
endi
if $data00 != NULL then
print expect NULL, actual: $data00
return -1
endi
if $data01 != NULL then
return -1
endi
@ -87,82 +83,44 @@ sql_error insert into mt_unsigned_1 values(now, -1, NULL, NULL, NULL, NULL, NULL
sql_error insert into mt_unsigned_1 values(now, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
sql_error insert into mt_unsigned_1 values(now, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL);
sql_error insert into mt_unsigned_1 values(now, NULL, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL);
sql_error insert into mt_unsigned_1 values(now, 255, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
sql_error insert into mt_unsigned_1 values(now, NULL, 65535, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
sql_error insert into mt_unsigned_1 values(now, NULL, NULL, 4294967295, NULL, NULL, NULL, NULL, NULL, NULL);
sql_error insert into mt_unsigned_1 values(now, NULL, NULL, NULL, 18446744073709551615, NULL, NULL, NULL, NULL, NULL);
sql insert into mt_unsigned_1 values(now, 255, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
sql insert into mt_unsigned_1 values(now, NULL, 65535, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
sql insert into mt_unsigned_1 values(now, NULL, NULL, 4294967295, NULL, NULL, NULL, NULL, NULL, NULL);
sql insert into mt_unsigned_1 values(now, NULL, NULL, NULL, 18446744073709551615, NULL, NULL, NULL, NULL, NULL);
sql select count(a),count(b),count(c),count(d), count(e) from mt_unsigned_1
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select a+b+c from mt_unsigned_1 where a is null;
if $rows != 1 then
return -1
endi
if $data00 != NULL then
print expect NULL, actual:$data00
return -1
endi
sql select count(*), a from mt_unsigned_1 group by a;
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select count(*), b from mt_unsigned_1 group by b;
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
sql select count(*), c from mt_unsigned_1 group by c;
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 3 then
return -1
endi
sql select a+b+c from mt_unsigned_1 where a is null;
if $rows != 4 then
return -1
endi
sql select count(*), a from mt_unsigned_1 group by a;
if $rows != 4 then
return -1
endi
sql select count(*), b from mt_unsigned_1 group by b;
if $rows != 4 then
return -1
endi
sql select count(*), c from mt_unsigned_1 group by c;
if $rows != 4 then
return -1
endi
sql select count(*), d from mt_unsigned_1 group by d;
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 4 then
if $rows != 4 then
return -1
endi

File diff suppressed because it is too large Load Diff

View File

@ -243,9 +243,6 @@ if $rows != $val then
return -1
endi
#TODO
return
#===========================aggregation===================================
#select + where condition
sql select count(join_tb1.*), count(join_tb0.*) from $tb1 , $tb2 where $ts1 = $ts2 and join_tb1.ts >= 100000 and join_tb0.c7 = false;

View File

@ -135,6 +135,7 @@ print ===================> nest query interval
sql_error select ts, avg(c1) from (select ts, c1 from nest_tb0);
sql select _wstart, avg(c1) from (select * from nest_tb0) interval(3d)
print $data00 $data01 $data10 $data11 $data20 $data21
if $rows != 3 then
return -1
endi
@ -147,19 +148,19 @@ endi
if $data10 != @20-09-17 00:00:00.000@ then
return -1
endi
if $data11 != 49.581325301 then
if $data11 != 49.685185185 then
return -1
endi
if $data20 != @20-09-20 00:00:00.000@ then
return -1
endi
if $data21 != 49.703539823 then
if $data21 != 49.500000000 then
return -1
endi
sql select stddev(c1) from (select c1 from nest_tb0);
sql_error select percentile(c1, 20) from (select * from nest_tb0);
sql_error select interp(c1) from (select * from nest_tb0);
sql select interp(c1) from (select * from nest_tb0);
sql_error select derivative(val, 1s, 0) from (select c1 val from nest_tb0);
sql_error select twa(c1) from (select c1 from nest_tb0);
sql_error select irate(c1) from (select c1 from nest_tb0);
@ -217,19 +218,14 @@ if $data00 != 0.016666667 then
endi
sql select derivative(c1, 1s, 0) from (select * from nest_tb0);
print $rows $data00 $data10
if $rows != 9999 then
return -1
endi
if $data00 != @20-09-15 00:01:00.000@ then
if $data00 != 0.016666667 then
return -1
endi
if $data01 != 0.016666667 then
return -1
endi
if $data10 != @20-09-15 00:02:00.000@ then
return -1
endi
if $data11 != 0.016666667 then
if $data10 != 0.016666667 then
return -1
endi
@ -238,7 +234,7 @@ if $rows != 9999 then
return -1
endi
sql select avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spread(c6) from (select * from nest_tb0) interval(1d);
sql select _wstart, avg(c1),sum(c2), max(c3), min(c4), count(*), first(c7), last(c7),spread(c6) from (select * from nest_tb0) interval(1d);
if $rows != 7 then
return -1
endi
@ -291,7 +287,7 @@ print ===================> group by + having
print =========================> ascending order/descending order
print =========================> nest query join
sql select a.ts,a.k,b.ts from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ;
sql select a.ts,a.k,b.ts from (select _wstart ts, count(*) k from nest_tb0 interval(30a)) a, (select _wstart ts, count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ;
if $rows != 10000 then
return -1
endi
@ -314,7 +310,7 @@ if $data12 != @20-09-15 00:01:00.000@ then
return -1
endi
sql select sum(a.k), sum(b.f) from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ;
sql select sum(a.k), sum(b.f) from (select _wstart ts, count(*) k from nest_tb0 interval(30a)) a, (select _wstart ts, count(*) f from nest_tb1 interval(30a)) b where a.ts = b.ts ;
if $rows != 1 then
return -1
endi
@ -325,7 +321,7 @@ if $data01 != 10000 then
return -1
endi
sql select a.ts,a.k,b.ts,c.ts,c.ts,c.x from (select count(*) k from nest_tb0 interval(30a)) a, (select count(*) f from nest_tb1 interval(30a)) b, (select count(*) x from nest_tb2 interval(30a)) c where a.ts = b.ts and a.ts = c.ts
sql select a.ts,a.k,b.ts,c.ts,c.ts,c.x from (select _wstart ts, count(*) k from nest_tb0 interval(30a)) a, (select _wstart ts, count(*) f from nest_tb1 interval(30a)) b, (select _wstart ts, count(*) x from nest_tb2 interval(30a)) c where a.ts = b.ts and a.ts = c.ts
if $rows != 10000 then
return -1
endi
@ -346,10 +342,7 @@ sql select diff(val) from (select c1 val from nest_tb0);
if $rows != 9999 then
return -1
endi
if $data00 != @70-01-01 08:00:00.000@ then
return -1
endi
if $data01 != 1 then
if $data00 != 1 then
return -1
endi
@ -376,7 +369,7 @@ if $data11 != 1 then
endi
print =====================>TD-5157
sql select twa(c1) from nest_tb1 interval(19a);
sql select _wstart, twa(c1) from nest_tb1 interval(19a);
if $rows != 10000 then
return -1
endi
@ -388,29 +381,14 @@ if $data01 != 0.000083333 then
endi
print ======================>TD-5271
sql select min(val),max(val),first(val),last(val),count(val),sum(val),avg(val) from (select count(*) val from nest_mt0 group by tbname)
if $rows != 1 then
return -1
endi
if $data00 != 10000 then
return -1
endi
if $data01 != 10000 then
return -1
endi
if $data04 != 10 then
return -1
endi
if $data05 != 100000 then
return -1
endi
sql_error select min(val),max(val),first(val),last(val),count(val),sum(val),avg(val) from (select count(*) val from nest_mt0 group by tbname)
print =================>us database interval query, TD-5039
sql create database test precision 'us';
sql use test;
sql create table t1(ts timestamp, k int);
sql insert into t1 values('2020-01-01 01:01:01.000', 1) ('2020-01-01 01:02:00.000', 2);
sql select avg(k) from (select avg(k) k from t1 interval(1s)) interval(1m);
sql select _wstart, avg(k) from (select _wstart, avg(k) k from t1 interval(1s)) interval(1m);
if $rows != 2 then
return -1
endi
@ -427,4 +405,4 @@ if $data11 != 2.000000000 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -41,12 +41,10 @@ sql_error insert into tb17 (ts, c1, c3) using stb (t1, t3) tags ('tag5', 11.11,
sql_error insert into tb18 (ts, c1, c3) using stb tags ('tag5', 16) values ( now + 5s, 'binary6', 6.6)
sql_error insert into tb19 (ts, c1, c2, c3) using stb tags (19, 'tag5', 91.11) values ( now + 5s, 'binary7', 7, 7.7)
sql create table stbx (ts timestamp, c1 binary(10), c2 int, c3 float) tags (t1 binary(10), t2 int, t3 float)
sql insert into tb100 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag100', 100, 100.123456) values ( now + 10s, 'binary100', 100, 100.9) tb101 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag101', 101, 101.9) values ( now + 10s, 'binary101', 101, 101.9) tb102 (ts, c1, c2, c3) using stbx (t1, t2, t3) tags ('tag102', 102, 102.9) values ( now + 10s, 'binary102', 102, 102.9)
sql select * from stbx
sql select * from stbx order by t1
if $rows != 3 then
return -1
endi

View File

@ -100,7 +100,7 @@ endi
sql drop database $db
sql show databases
if $rows != 0 then
if $rows != 2 then
return -1
endi

View File

@ -25,11 +25,5 @@ sql (select database()) union all (select database())
if $rows != 2 then
return -1
endi
if $data00 != @union_db0@ then
return -1
endi
if $data10 != @union_db0@ then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -77,12 +77,12 @@ if $rows != $val then
return -1
endi
sql select tbname from $mt
sql select distinct tbname from $mt
if $rows != $tbNum then
return -1
endi
sql select tbname from $mt where t1 < 2
sql select distinct tbname from $mt where t1 < 2
if $rows != 2 then
return -1
endi
@ -249,14 +249,14 @@ sql_error insert into tb_where_NULL values(now, ?, '12')
sql insert into tb_where_NULL values ('2019-01-01 09:00:00.000', 1, 'val1')
sql insert into tb_where_NULL values ('2019-01-01 09:00:01.000', NULL, NULL)
sql insert into tb_where_NULL values ('2019-01-01 09:00:02.000', 2, 'val2')
sql_error select * from tb_where_NULL where c1 = NULL
sql_error select * from tb_where_NULL where c1 <> NULL
sql_error select * from tb_where_NULL where c1 < NULL
sql_error select * from tb_where_NULL where c1 = "NULL"
sql_error select * from tb_where_NULL where c1 <> "NULL"
sql_error select * from tb_where_NULL where c1 <> "nulL"
sql_error select * from tb_where_NULL where c1 > "NULL"
sql_error select * from tb_where_NULL where c1 >= "NULL"
sql select * from tb_where_NULL where c1 = NULL
sql select * from tb_where_NULL where c1 <> NULL
sql select * from tb_where_NULL where c1 < NULL
sql select * from tb_where_NULL where c1 = "NULL"
sql select * from tb_where_NULL where c1 <> "NULL"
sql select * from tb_where_NULL where c1 <> "nulL"
sql select * from tb_where_NULL where c1 > "NULL"
sql select * from tb_where_NULL where c1 >= "NULL"
sql select * from tb_where_NULL where c2 = "NULL"
if $rows != 0 then
return -1
@ -300,15 +300,17 @@ endw
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
sql_error select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter');
sql select * from wh_mt0 where c3 = 'abc' and tbname in ('test_null_filter');
sql select * from wh_mt0 where c3 = '1' and tbname in ('test_null_filter');
if $row != 0 then
return -1
endi
sql select * from wh_mt0 where c3 = '1';
if $row == 0 then
sql select * from wh_mt0 where c3 = 1;
print $rows -> 1000
print $data00 $data01 $data02
if $row != 1000 then
return -1
endi
@ -336,7 +338,7 @@ sql insert into where_ts values('2021-06-19 16:22:00', 1);
sql insert into where_ts values('2021-06-19 16:23:00', 2);
sql insert into where_ts values('2021-06-19 16:24:00', 3);
sql insert into where_ts values('2021-06-19 16:25:00', 1);
sql select * from (select * from where_ts) where ts<'2021-06-19 16:25:00' and ts>'2021-06-19 16:22:00'
sql select * from (select * from where_ts) where ts<'2021-06-19 16:25:00' and ts>'2021-06-19 16:22:00' order by ts;
if $rows != 2 then
return -1
endi

View File

@ -498,4 +498,7 @@ if $data15 != 3 then
goto loop5
endi
sql drop database test;
sql drop database test1;
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -0,0 +1,172 @@
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
sql connect
sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
sql create dnode $hostname port 7400
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
return -1
endi
if $data(1)[4] != ready then
goto step1
endi
if $data(2)[4] != ready then
goto step1
endi
if $data(3)[4] != ready then
goto step1
endi
if $data(4)[4] != ready then
goto step1
endi
$replica = 3
$vgroups = 1
$retentions = 5s:7d,15s:21d
print ============= create database
sql create database db replica $replica vgroups $vgroups retentions $retentions
$loop_cnt = 0
check_db_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 100 then
print ====> db not ready!
return -1
endi
sql show databases
print ===> rows: $rows
print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6] $data[2][7] $data[2][8] $data[2][9] $data[2][6] $data[2][11] $data[2][12] $data[2][13] $data[2][14] $data[2][15] $data[2][16] $data[2][17] $data[2][18] $data[2][19]
if $rows != 3 then
return -1
endi
if $data[2][15] != ready then
goto check_db_ready
endi
sql use db
$loop_cnt = 0
check_vg_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 300 then
print ====> vgroups not ready!
return -1
endi
sql show vgroups
print ===> rows: $rows
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] $data[0][7] $data[0][8] $data[0][9] $data[0][10] $data[0][11]
if $rows != $vgroups then
return -1
endi
if $data[0][4] == leader then
if $data[0][6] == follower then
if $data[0][8] == follower then
print ---- vgroup $data[0][0] leader locate on dnode $data[0][3]
endi
endi
elif $data[0][6] == leader then
if $data[0][4] == follower then
if $data[0][8] == follower then
print ---- vgroup $data[0][0] leader locate on dnode $data[0][5]
endi
endi
elif $data[0][8] == leader then
if $data[0][4] == follower then
if $data[0][6] == follower then
print ---- vgroup $data[0][0] leader locate on dnode $data[0][7]
endi
endi
else
goto check_vg_ready
endi
vg_ready:
print ====> create stable/child table
sql create table stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int) rollup(sum)
sql show stables
if $rows != 1 then
return -1
endi
sql create table ct1 using stb tags(1000)
print ===> stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep 3000
print ===> write 100 records
$N = 100
$count = 0
while $count < $N
$ms = 1659000000000 + $count
sql insert into ct1 values( $ms , $count , 2.1, 3.1)
$count = $count + 1
endw
#sql flush database db;
sleep 3000
print ===> stop dnode1 dnode2 dnode3
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
sleep 10000
########################################################
print ===> start dnode1 dnode2 dnode3 dnode4
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
sleep 3000
print =============== query data
sql connect
sql use db
sql select * from ct1
print rows: $rows
print $data00 $data01 $data02
if $rows != 100 then
return -1
endi

View File

@ -311,7 +311,7 @@ sql select * from $mt where tgcol2 = 1 -x step52
return -1
step52:
sql select * from $mt where tgcol3 = 1
sql select * from $mt where tgcol3 < 2
print $data01 $data02 $data03
if $rows != 1 then
return -1

View File

@ -97,10 +97,10 @@ if $data23 != TAG then
return -1
endi
sql alter table $mt drop tag tgcol2
sql alter table $mt drop tag tgcol1 -x step40
return -1
step40:
sql alter table $mt drop tag tgcol2
print =============== step5
$i = 5
@ -123,11 +123,11 @@ if $data03 != 2 then
return -1
endi
sql alter table $mt drop tag tgcol2
sql alter table $mt drop tag tgcol1 -x step50
return -1
step50:
sql alter table $mt drop tag tgcol2
print =============== step6
$i = 6
$mt = $mtPrefix . $i
@ -186,7 +186,7 @@ endi
if $data31 != TINYINT then
return -1
endi
if $data41 != BINARY then
if $data41 != VARCHAR then
return -1
endi
if $data22 != 2 then
@ -405,8 +405,6 @@ sql alter table $mt drop tag tgcol3
sql alter table $mt drop tag tgcol4
sql alter table $mt drop tag tgcol6
sleep 3000
print =============== step2
$i = 2
$mt = $mtPrefix . $i

View File

@ -32,7 +32,7 @@ if $data(2)[4] != ready then
endi
print =============== kill dnode2
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGKILL
print =============== create database
sql show transactions
@ -88,7 +88,7 @@ endi
sql show transactions
if $rows != 0 then
return -1
goto step2
endi
sql_error create database d1 vgroups 2;

View File

@ -50,9 +50,9 @@ class TDTestCase:
'col11': 'bool',
'col12': f'binary({self.str_length})',
'col13': f'nchar({self.str_length})',
}
self.tinyint_val = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX)
self.smallint_val = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX)
self.int_val = random.randint(constant.INT_MIN,constant.INT_MAX)
@ -100,15 +100,15 @@ class TDTestCase:
elif col_type.lower() == 'bigint unsigned':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bigint unsigned"]})')
elif col_type.lower() == 'bool':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})')
elif col_type.lower() == 'float':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})')
elif col_type.lower() == 'double':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["double"]})')
elif 'binary' in col_type.lower():
tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['binary']}")''')
elif 'nchar' in col_type.lower():
tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''')
tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''')
def delete_all_data(self,tbname,col_type,row_num,base_data,dbname,tb_type,tb_num=1):
tdSql.execute(f'delete from {tbname}')
tdSql.execute(f'flush database {dbname}')
@ -164,7 +164,7 @@ class TDTestCase:
elif 'nchar' in column_type.lower():
tdSql.checkEqual(tdSql.queryResult[0][0],base_data['nchar'])
else:
tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type])
tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type])
def delete_rows(self,dbname,tbname,col_name,col_type,base_data,row_num,tb_type,tb_num=1):
for i in range(row_num):
tdSql.execute(f'delete from {tbname} where ts>{self.ts+i}')
@ -189,7 +189,7 @@ class TDTestCase:
elif tb_type == 'stb':
tdSql.checkRows(i*tb_num)
for j in range(tb_num):
self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data)
self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data)
for i in range(row_num):
tdSql.execute(f'delete from {tbname} where ts<={self.ts+i}')
tdSql.execute(f'flush database {dbname}')
@ -240,7 +240,7 @@ class TDTestCase:
tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['nchar']}"''')
else:
tdSql.error(f'delete from {tbname} where {error_list} {column_name} = {base_data[column_type]}')
def delete_data_ntb(self):
tdSql.execute(f'create database if not exists {self.dbname}')
tdSql.execute(f'use {self.dbname}')
@ -295,4 +295,4 @@ class TDTestCase:
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -26,13 +26,13 @@ from util.common import tdCom
import platform
import io
if platform.system().lower() == 'windows':
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self._conn = conn
self._conn = conn
def createDb(self, name="test", db_update_tag=0):
if db_update_tag == 0:
@ -67,7 +67,7 @@ class TDTestCase:
td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts))
return td_ts
#return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f"))
def dateToTs(self, datetime_input):
return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))
@ -274,7 +274,7 @@ class TDTestCase:
input_sql = self.gen_influxdb_line(stb_name, tb_name, id, t0, t1, t2, t3, t4, t5, t6, t7, t8, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, ts,
id_noexist_tag, id_change_tag, id_double_tag, ct_add_tag, ct_am_tag, ct_ma_tag, ct_min_tag, c_multi_tag, t_multi_tag, c_blank_tag, t_blank_tag, chinese_tag)
return input_sql, stb_name
def genMulTagColStr(self, gen_type, count):
"""
gen_type must be "tag"/"col"
@ -370,10 +370,10 @@ class TDTestCase:
for t_type in full_type_list:
input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type)
self.resCmp(input_sql, stb_name)
def symbolsCheckCase(self):
"""
check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/?
check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/?
"""
'''
please test :
@ -395,7 +395,7 @@ class TDTestCase:
for ts in ts_list:
input_sql, stb_name = self.genFullTypeSql(ts=ts)
self.resCmp(input_sql, stb_name, ts=ts)
def idSeqCheckCase(self):
"""
check id.index in tags
@ -404,7 +404,7 @@ class TDTestCase:
tdCom.cleanTb()
input_sql, stb_name = self.genFullTypeSql(id_change_tag=True)
self.resCmp(input_sql, stb_name)
def idUpperCheckCase(self):
"""
check id param
@ -444,7 +444,7 @@ class TDTestCase:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def idIllegalNameCheckCase(self):
"""
test illegal id name
@ -490,7 +490,7 @@ class TDTestCase:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def illegalTsCheckCase(self):
"""
check ts format like 16260068336390us19
@ -575,11 +575,11 @@ class TDTestCase:
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
# binary
# binary
stb_name = tdCom.getLongName(7, "letters")
input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}" c0=f 1626006833639000000'
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16375, "letters")}" c0=f 1626006833639000000'
try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
@ -647,7 +647,7 @@ class TDTestCase:
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
# f32
# f32
for c5 in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]:
input_sql, stb_name = self.genFullTypeSql(c5=c5)
self.resCmp(input_sql, stb_name)
@ -671,11 +671,11 @@ class TDTestCase:
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
# # # binary
# # # binary
# stb_name = tdCom.getLongName(7, "letters")
# input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16374, "letters")}" 1626006833639000000'
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
# input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16375, "letters")}" 1626006833639000000'
# try:
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
@ -715,13 +715,13 @@ class TDTestCase:
# i8 i16 i32 i64 f32 f64
for input_sql in [
self.genFullTypeSql(t1="1s2i8")[0],
self.genFullTypeSql(t1="1s2i8")[0],
self.genFullTypeSql(t2="1s2i16")[0],
self.genFullTypeSql(t3="1s2i32")[0],
self.genFullTypeSql(t4="1s2i64")[0],
self.genFullTypeSql(t5="11.1s45f32")[0],
self.genFullTypeSql(t6="11.1s45f64")[0],
self.genFullTypeSql(c1="1s2i8")[0],
self.genFullTypeSql(t6="11.1s45f64")[0],
self.genFullTypeSql(c1="1s2i8")[0],
self.genFullTypeSql(c2="1s2i16")[0],
self.genFullTypeSql(c3="1s2i32")[0],
self.genFullTypeSql(c4="1s2i64")[0],
@ -746,14 +746,14 @@ class TDTestCase:
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
# check accepted binary and nchar symbols
# check accepted binary and nchar symbols
# # * ~!@#$¥%^&*()-+={}|[]、「」:;
for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'):
input_sql1 = f'{stb_name},t0=t c0=f,c1="abc{symbol}aaa" 1626006833639000000'
input_sql2 = f'{stb_name},t0=t,t1="abc{symbol}aaa" c0=f 1626006833639000000'
self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
# self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
def duplicateIdTagColInsertCheckCase(self):
"""
check duplicate Id Tag Col
@ -810,7 +810,7 @@ class TDTestCase:
self.resCmp(input_sql, stb_name)
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
self.resCmp(input_sql, stb_name)
@tdCom.smlPass
def tagColBinaryNcharLengthCheckCase(self):
"""
@ -829,7 +829,7 @@ class TDTestCase:
check column and tag count add, stb and tb duplicate
* tag: alter table ...
* col: when update==0 and ts is same, unchange
* so this case tag&&value will be added,
* so this case tag&&value will be added,
* col is added without value when update==0
* col is added with value when update==1
"""
@ -897,7 +897,7 @@ class TDTestCase:
# * every binary and nchar must be length+2, so here is two tag, max length could not larger than 16384-2*2
input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(5, "letters")}" c0=f 1626006833639000000'
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
tdSql.query(f"select * from {stb_name}")
tdSql.checkRows(2)
input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(6, "letters")}" c0=f 1626006833639000000'
@ -922,7 +922,7 @@ class TDTestCase:
tdSql.checkNotEqual(err.errno, 0)
tdSql.query(f"select * from {stb_name}")
tdSql.checkRows(3)
# * tag nchar max is 16374/4, col+ts nchar max 49151
def tagColNcharMaxLengthCheckCase(self):
"""
@ -977,7 +977,7 @@ class TDTestCase:
"st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000"
]
self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
def multiInsertCheckCase(self, count):
"""
test multi insert
@ -1073,7 +1073,7 @@ class TDTestCase:
self.multiThreadRun(self.genMultiThreadSeq(input_sql))
tdSql.query(f"show tables;")
tdSql.checkRows(5)
def sStbStbDdataInsertMultiThreadCheckCase(self):
"""
thread input same stb tb, different data, result keep first data
@ -1107,7 +1107,7 @@ class TDTestCase:
tdSql.checkEqual(tb_name, expected_tb_name)
tdSql.query(f"select * from {stb_name};")
tdSql.checkRows(1)
def sStbStbDdataMtcInsertMultiThreadCheckCase(self):
"""
thread input same stb tb, different data, minus columes and tags, result keep first data
@ -1217,7 +1217,7 @@ class TDTestCase:
tdSql.checkRows(6)
for c in ["c7", "c8", "c9"]:
tdSql.query(f"select * from {stb_name} where {c} is NULL")
tdSql.checkRows(5)
tdSql.checkRows(5)
for t in ["t10", "t11"]:
tdSql.query(f"select * from {stb_name} where {t} is not NULL;")
tdSql.checkRows(6)

View File

@ -43,7 +43,7 @@ class TDTestCase:
case1: limit offset base function test
case2: offset return valid
'''
return
return
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
@ -69,7 +69,7 @@ class TDTestCase:
# self.create_tables();
self.ts = 1500000000000
# stop
# stop
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
@ -80,7 +80,7 @@ class TDTestCase:
def newcur(self,host,cfg):
user = "root"
password = "taosdata"
port =6030
port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
cur=con.cursor()
print(cur)
@ -90,7 +90,7 @@ class TDTestCase:
def create_tables(self,host,dbname,stbname,count):
buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config)
tsql.execute("use %s" %dbname)
@ -109,7 +109,7 @@ class TDTestCase:
tsql.execute(sql)
sql = pre_create
# print(time.time())
# end sql
# end sql
if sql != pre_create:
# print(sql)
tsql.execute(sql)
@ -122,7 +122,7 @@ class TDTestCase:
def mutiThread_create_tables(self,host,dbname,stbname,vgroups,threadNumbers,childcount):
buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config)
tdLog.debug("create database %s"%dbname)
tsql.execute("drop database if exists %s"%dbname)
@ -132,7 +132,7 @@ class TDTestCase:
threads = []
for i in range(threadNumbers):
tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i))
threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,)))
threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,)))
start_time = time.time()
for tr in threads:
tr.start()
@ -142,7 +142,7 @@ class TDTestCase:
spendTime=end_time-start_time
speedCreate=threadNumbers*count/spendTime
tdLog.debug("spent %.2fs to create %d stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,threadNumbers,threadNumbers*count,speedCreate))
return
# def create_tables(self,host,dbname,stbname,vgroups,tcountStart,tcountStop):
@ -169,7 +169,7 @@ class TDTestCase:
# print(sql)
tsql.execute(sql)
sql = "insert into %s_%d values " %(stbname,i)
# end sql
# end sql
if sql != pre_insert:
# print(sql)
print(len(sql))
@ -184,7 +184,7 @@ class TDTestCase:
def mutiThread_insert_data(self, host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount):
buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config)
tdLog.debug("ready to inser data")
@ -193,7 +193,7 @@ class TDTestCase:
threads = []
for i in range(threadNumbers):
# tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i))
threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,)))
threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,)))
start_time = time.time()
for tr in threads:
tr.start()
@ -224,10 +224,10 @@ class TDTestCase:
tdLog.info("taosd found in %s" % buildPath)
taosBenchbin = buildPath+ "/build/bin/taosBenchmark"
os.system("%s -f %s -y " %(taosBenchbin,jsonFile))
return
def taosBenchCreate(self,host,dropdb,dbname,stbname,vgroups,processNumbers,count):
# count=50000
buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/"
@ -241,7 +241,7 @@ class TDTestCase:
# tsql.getResult("show databases")
# print(tdSql.queryResult)
tsql.execute("use %s" %dbname)
threads = []
for i in range(processNumbers):
jsonfile="1-insert/Vgroups%d%d.json"%(vgroups,i)
@ -252,7 +252,7 @@ class TDTestCase:
os.system("sed -i 's/\"childtable_count\": 10000,/\"childtable_count\": %d,/g' %s "%(count,jsonfile))
os.system("sed -i 's/\"name\": \"stb1\",/\"name\": \"%s%d\",/g' %s "%(stbname,i,jsonfile))
os.system("sed -i 's/\"childtable_prefix\": \"stb1_\",/\"childtable_prefix\": \"%s%d_\",/g' %s "%(stbname,i,jsonfile))
threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,)))
threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,)))
start_time = time.time()
for tr in threads:
tr.start()
@ -274,10 +274,10 @@ class TDTestCase:
for i in range(stableCount):
tdSql.query("select count(*) from %s%d"%(stbname,i))
tdSql.checkData(0,0,rowsPerSTable)
return
# test case1 base
return
# test case1 base
def test_case1(self):
#stableCount=threadNumbersCtb
parameterDict = {'vgroups': 1, \
@ -290,22 +290,22 @@ class TDTestCase:
'stbname': 'stb', \
'host': 'localhost', \
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
tdLog.debug("-----create database and muti-thread create tables test------- ")
#host,dbname,stbname,vgroups,threadNumbers,tcountStart,tcountStop
#host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount
self.mutiThread_create_tables(
host=parameterDict['host'],
dbname=parameterDict['dbname'],
stbname=parameterDict['stbname'],
vgroups=parameterDict['vgroups'],
threadNumbers=parameterDict['threadNumbersCtb'],
stbname=parameterDict['stbname'],
vgroups=parameterDict['vgroups'],
threadNumbers=parameterDict['threadNumbersCtb'],
childcount=parameterDict['tablesPerStb'])
self.mutiThread_insert_data(
host=parameterDict['host'],
dbname=parameterDict['dbname'],
stbname=parameterDict['stbname'],
stbname=parameterDict['stbname'],
threadNumbers=parameterDict['threadNumbersIda'],
chilCount=parameterDict['tablesPerStb'],
ts_start=parameterDict['startTs'],
@ -315,7 +315,7 @@ class TDTestCase:
rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb']
self.checkData(dbname=parameterDict['dbname'],stbname=parameterDict['stbname'], stableCount=parameterDict['threadNumbersCtb'],CtableCount=tableCount,rowsPerSTable=rowsPerStable)
def test_case3(self):
#stableCount=threadNumbersCtb
parameterDict = {'vgroups': 1, \
@ -327,21 +327,21 @@ class TDTestCase:
'stbname': 'stb1', \
'host': 'localhost', \
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
self.taosBenchCreate(
parameterDict['host'],
"no",
parameterDict['dbname'],
parameterDict['stbname'],
parameterDict['vgroups'],
parameterDict['threadNumbersCtb'],
parameterDict['dbname'],
parameterDict['stbname'],
parameterDict['vgroups'],
parameterDict['threadNumbersCtb'],
parameterDict['tablesPerStb'])
tableCount=parameterDict['threadNumbersCtb']*parameterDict['tablesPerStb']
rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb']
self.checkData(
dbname=parameterDict['dbname'],
stbname=parameterDict['stbname'],
stbname=parameterDict['stbname'],
stableCount=parameterDict['threadNumbersCtb'],
CtableCount=tableCount,
rowsPerSTable=rowsPerStable)
@ -353,9 +353,9 @@ class TDTestCase:
# self.taosBenchCreate("db1", "stb1", 4, 5, 100*10000)
# self.taosBenchCreate("db1", "stb1", 1, 5, 100*10000)
return
return
# run case
# run case
def run(self):
# create database and tables。
@ -368,7 +368,7 @@ class TDTestCase:
return
return
#
# add case with filename
#

View File

@ -38,7 +38,7 @@ class TDTestCase:
tlist = self.genMultiThreadSeq(sql_list)
self.multiThreadRun(tlist)
tdSql.query(f'show databases')
def stop(self):
tdSql.close()

View File

@ -34,14 +34,14 @@ class TDTestCase:
#
# --------------- main frame -------------------
#
def caseDescription(self):
'''
limit and offset keyword function test cases;
case1: limit offset base function test
case2: offset return valid
'''
return
return
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
@ -68,7 +68,7 @@ class TDTestCase:
self.ts = 1500000000000
# run case
# run case
def run(self):
# test base case
@ -79,7 +79,7 @@ class TDTestCase:
# self.test_case2()
# tdLog.debug(" LIMIT test_case2 ............ [OK]")
# stop
# stop
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
@ -101,7 +101,7 @@ class TDTestCase:
tdSql.execute(sql)
sql = pre_create
# print(time.time())
# end sql
# end sql
if sql != pre_create:
tdSql.execute(sql)
exeEndTime=time.time()
@ -113,7 +113,7 @@ class TDTestCase:
def newcur(self,host,cfg):
user = "root"
password = "taosdata"
port =6030
port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
cur=con.cursor()
print(cur)
@ -123,7 +123,7 @@ class TDTestCase:
host = "127.0.0.1"
buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config)
tsql.execute("drop database if exists %s" %(dbname))
tsql.execute("create database if not exists %s vgroups %d"%(dbname,vgroups))
@ -147,7 +147,7 @@ class TDTestCase:
tsql.execute(sql)
sql = pre_create
# print(time.time())
# end sql
# end sql
if sql != pre_create:
# print(sql)
tsql.execute(sql)
@ -176,7 +176,7 @@ class TDTestCase:
# print(sql)
tdSql.execute(sql)
sql = "insert into %s_%d values " %(stbname,i)
# end sql
# end sql
if sql != pre_insert:
# print(sql)
tdSql.execute(sql)
@ -189,7 +189,7 @@ class TDTestCase:
return
# test case1 base
# test case1 base
def test_case1(self):
tdLog.debug("-----create database and tables test------- ")
# tdSql.execute("drop database if exists db1")
@ -220,7 +220,7 @@ class TDTestCase:
threads = []
threadNumbers=2
for i in range(threadNumbers):
threads.append(mp.Process(target=self.new_create_tables, args=("db1%d"%i, vgroups, "stb1", 0,count,)))
threads.append(mp.Process(target=self.new_create_tables, args=("db1%d"%i, vgroups, "stb1", 0,count,)))
start_time = time.time()
for tr in threads:
tr.start()
@ -247,7 +247,7 @@ class TDTestCase:
# tdSql.execute("create database db16 vgroups 16")
# self.create_tables("db16", "stb16", 30*10000)
return
return
# test case2 base:insert data
def test_case2(self):
@ -266,7 +266,7 @@ class TDTestCase:
tdSql.execute("create database db1 vgroups 1")
self.create_tables("db1", "stb1", 1*100)
self.insert_data("db1", "stb1", self.ts, 1*50,1*10000)
tdSql.execute("create database db4 vgroups 4")
self.create_tables("db4", "stb4", 1*100)
@ -287,7 +287,7 @@ class TDTestCase:
tdSql.execute("create database db16 vgroups 16")
self.create_tables("db16", "stb16", 1*100)
self.insert_data("db16", "stb16", self.ts, 1*100,1*10000)
return
#
@ -296,4 +296,4 @@ class TDTestCase:
# tdCases.addWindows(__file__, TDTestCase())
# tdCases.addLinux(__file__, TDTestCase())
case=TDTestCase()
case.test_case1()
case.test_case1()

View File

@ -27,13 +27,13 @@ class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self._conn = conn
self._conn = conn
self.defaultJSONStrType_value = "NCHAR"
def createDb(self, name="test", db_update_tag=0, protocol=None):
if protocol == "telnet-tcp":
name = "opentsdb_telnet"
if db_update_tag == 0:
tdSql.execute(f"drop database if exists {name}")
tdSql.execute(f"create database if not exists {name} precision 'ms' schemaless 1")
@ -225,7 +225,7 @@ class TDTestCase:
def genTagValue(self, t0_type="bool", t0_value="", t1_type="tinyint", t1_value=127, t2_type="smallint", t2_value=32767,
t3_type="int", t3_value=2147483647, t4_type="bigint", t4_value=9223372036854775807,
t5_type="float", t5_value=11.12345027923584, t6_type="double", t6_value=22.123456789,
t5_type="float", t5_value=11.12345027923584, t6_type="double", t6_value=22.123456789,
t7_type="binary", t7_value="binaryTagValue", t8_type="nchar", t8_value="ncharTagValue", value_type="obj"):
if t0_value == "":
t0_value = random.choice([True, False])
@ -256,9 +256,9 @@ class TDTestCase:
}
return tag_value
def genFullTypeJson(self, ts_value="", col_value="", tag_value="", stb_name="", tb_name="",
def genFullTypeJson(self, ts_value="", col_value="", tag_value="", stb_name="", tb_name="",
id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_mixul_tag=None, id_double_tag=None,
t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None,
t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None,
chinese_tag=None, multi_field_tag=None, point_trans_tag=None, value_type="obj"):
if value_type == "obj":
if stb_name == "":
@ -370,7 +370,7 @@ class TDTestCase:
if point_trans_tag is not None:
sql_json = {"metric": ".point.trans.test", "timestamp": ts_value, "value": col_value, "tags": tag_value}
return sql_json, stb_name
def genMulTagColDict(self, genType, count=1, value_type="obj"):
"""
genType must be tag/col
@ -479,10 +479,10 @@ class TDTestCase:
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def symbolsCheckCase(self, value_type="obj"):
"""
check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/?
check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/?
"""
'''
please test :
@ -492,9 +492,9 @@ class TDTestCase:
tdCom.cleanTb()
binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"'
nchar_symbols = binary_symbols
input_sql1, stb_name1 = self.genFullTypeJson(col_value=self.genTsColValue(value=binary_symbols, t_type="binary", value_type=value_type),
input_sql1, stb_name1 = self.genFullTypeJson(col_value=self.genTsColValue(value=binary_symbols, t_type="binary", value_type=value_type),
tag_value=self.genTagValue(t7_value=binary_symbols, t8_value=nchar_symbols, value_type=value_type))
input_sql2, stb_name2 = self.genFullTypeJson(col_value=self.genTsColValue(value=nchar_symbols, t_type="nchar", value_type=value_type),
input_sql2, stb_name2 = self.genFullTypeJson(col_value=self.genTsColValue(value=nchar_symbols, t_type="nchar", value_type=value_type),
tag_value=self.genTagValue(t7_value=binary_symbols, t8_value=nchar_symbols, value_type=value_type))
self.resCmp(input_sql1, stb_name1)
self.resCmp(input_sql2, stb_name2)
@ -574,7 +574,7 @@ class TDTestCase:
tdCom.cleanTb()
input_json, stb_name = self.genFullTypeJson(id_change_tag=True, value_type=value_type)
self.resCmp(input_json, stb_name)
def idLetterCheckCase(self, value_type="obj"):
"""
check id param
@ -618,7 +618,7 @@ class TDTestCase:
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def idIllegalNameCheckCase(self, value_type="obj"):
"""
test illegal id name
@ -669,7 +669,7 @@ class TDTestCase:
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def illegalTsCheckCase(self, value_type="obj"):
"""
check ts format like 16260068336390us19
@ -726,7 +726,7 @@ class TDTestCase:
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
tdSql.checkNotEqual(err.errno, 0)
def tagValueLengthCheckCase(self, value_type="obj"):
"""
@ -770,11 +770,11 @@ class TDTestCase:
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
#i64
#i64
for t4 in [-9223372036854775807, 9223372036854775807]:
input_json, stb_name = self.genFullTypeJson(tag_value=self.genTagValue(t4_value=t4, value_type=value_type))
self.resCmp(input_json, stb_name)
for t4 in [-9223372036854775808, 9223372036854775808]:
input_json = self.genFullTypeJson(tag_value=self.genTagValue(t4_value=t4))[0]
try:
@ -809,7 +809,7 @@ class TDTestCase:
tdSql.checkNotEqual(err.errno, 0)
if value_type == "obj":
# binary
# binary
stb_name = tdCom.getLongName(7, "letters")
input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': True, 'type': 'bool'}, "tags": {"t0": {'value': True, 'type': 'bool'}, "t1":{'value': tdCom.getLongName(16374, "letters"), 'type': 'binary'}}}
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
@ -895,7 +895,7 @@ class TDTestCase:
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
# i64
# i64
tdCom.cleanTb()
for value in [-9223372036854775808]:
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="bigint", value_type=value_type))
@ -912,7 +912,7 @@ class TDTestCase:
# except SchemalessError as err:
# tdSql.checkNotEqual(err.errno, 0)
# f32
# f32
tdCom.cleanTb()
for value in [-3.4028234663852885981170418348451692544*(10**38), 3.4028234663852885981170418348451692544*(10**38)]:
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="float", value_type=value_type))
@ -943,12 +943,12 @@ class TDTestCase:
tdSql.checkNotEqual(err.errno, 0)
# if value_type == "obj":
# # binary
# # binary
# tdCom.cleanTb()
# stb_name = tdCom.getLongName(7, "letters")
# input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16374, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}}
# self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
# tdCom.cleanTb()
# input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16375, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}}
# try:
@ -972,7 +972,7 @@ class TDTestCase:
# except SchemalessError as err:
# tdSql.checkNotEqual(err.errno, 0)
# elif value_type == "default":
# # binary
# # binary
# tdCom.cleanTb()
# stb_name = tdCom.getLongName(7, "letters")
# if tdSql.getVariable("defaultJSONStrType")[0].lower() == "binary":
@ -1010,12 +1010,12 @@ class TDTestCase:
# i8 i16 i32 i64 f32 f64
for input_json in [
self.genFullTypeJson(tag_value=self.genTagValue(t1_value="1s2"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t2_value="1s2"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t3_value="1s2"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t4_value="1s2"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t5_value="11.1s45"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t6_value="11.1s45"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t1_value="1s2"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t2_value="1s2"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t3_value="1s2"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t4_value="1s2"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t5_value="11.1s45"))[0],
self.genFullTypeJson(tag_value=self.genTagValue(t6_value="11.1s45"))[0],
]:
try:
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
@ -1033,7 +1033,7 @@ class TDTestCase:
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
# check accepted binary and nchar symbols
# check accepted binary and nchar symbols
# # * ~!@#$¥%^&*()-+={}|[]、「」:;
for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'):
input_json1 = self.genFullTypeJson(col_value=self.genTsColValue(value=f"abc{symbol}aaa", t_type="binary", value_type=value_type))[0]
@ -1123,7 +1123,7 @@ class TDTestCase:
check tag count add, stb and tb duplicate
* tag: alter table ...
* col: when update==0 and ts is same, unchange
* so this case tag&&value will be added,
* so this case tag&&value will be added,
* col is added without value when update==0
* col is added with value when update==1
"""
@ -1139,14 +1139,14 @@ class TDTestCase:
if db_update_tag == 1 :
self.resCmp(input_json, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True)
tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None)
tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None)
else:
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
tdSql.checkData(0, 1, True)
tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None)
tdSql.checkData(0, 1, True)
tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None)
self.createDb()
def tagAddCheckCase(self, value_type="obj"):
@ -1216,7 +1216,7 @@ class TDTestCase:
tag_value["t2"] = tdCom.getLongName(1, "letters")
tag_value.pop('id')
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
tdSql.query(f"select * from {stb_name}")
tdSql.checkRows(2)
if value_type == "obj":
@ -1313,7 +1313,7 @@ class TDTestCase:
tdSql.checkRows(6)
tdSql.query('select * from st123456')
tdSql.checkRows(5)
def multiInsertCheckCase(self, count, value_type="obj"):
"""
test multi insert
@ -1356,7 +1356,7 @@ class TDTestCase:
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def blankColInsertCheckCase(self, value_type="obj"):
"""
test blank col insert
@ -1382,7 +1382,7 @@ class TDTestCase:
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def chineseCheckCase(self):
"""
check nchar ---> chinese
@ -1419,7 +1419,7 @@ class TDTestCase:
{"metric": f'{stb_name}_8', "timestamp": {"value": 1626006833641, "type": "mS"}, "value": {"value": "vozamcts", "type": "nchAr"}, "tags": {"t1": {"value": "vozamcts", "type": "nchAr"}}},
{"metric": f'{stb_name}_9', "timestamp": {"value": 1626006833642, "type": "MS"}, "value": {"value": "vozamcts", "type": "nchAr"}, "tags": {"t1": {"value": "vozamcts", "type": "nchAr"}}},
{"metric": f'{stb_name}_10', "timestamp": {"value": 1626006834, "type": "S"}, "value": {"value": "vozamcts", "type": "nchAr"}, "tags": {"t1": {"value": "vozamcts", "type": "nchAr"}}}]
for input_sql in input_json_list:
stb_name = input_sql["metric"]
self.resCmp(input_sql, stb_name)
@ -1514,7 +1514,7 @@ class TDTestCase:
self.multiThreadRun(self.genMultiThreadSeq(input_json))
tdSql.query(f"show tables;")
tdSql.checkRows(5)
def sStbStbDdataInsertMultiThreadCheckCase(self, value_type="obj"):
"""
thread input same stb tb, different data, result keep first data
@ -1550,7 +1550,7 @@ class TDTestCase:
tdSql.checkEqual(tb_name, expected_tb_name)
tdSql.query(f"select * from {stb_name};")
tdSql.checkRows(1)
def sStbStbDdataMtInsertMultiThreadCheckCase(self, value_type="obj"):
"""
thread input same stb tb, different data, minus columes and tags, result keep first data
@ -1595,7 +1595,7 @@ class TDTestCase:
({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "plgkckpv", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz'),
({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "cujyqvlj", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz'),
({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "twjxisat", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz')]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_m_tag_list))
tdSql.query(f"show tables;")
tdSql.checkRows(2)
@ -1642,10 +1642,10 @@ class TDTestCase:
tb_name = tdCom.getLongName(7, "letters")
input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary"))
self.resCmp(input_json, stb_name)
s_stb_s_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 'id': tb_name}}, 'punftb'),
s_stb_s_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rhnikvfq', 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'afcibyeb', 'type': 'binary'}, 'id': tb_name}}, 'punftb')]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_m_tag_list))
tdSql.query(f"show tables;")
@ -1664,10 +1664,10 @@ class TDTestCase:
tb_name = tdCom.getLongName(7, "letters")
input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary"))
self.resCmp(input_json, stb_name)
s_stb_s_tb_d_ts_a_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'tclbosqc', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'),
s_stb_s_tb_d_ts_a_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'tuzsfrom', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'llqzvgvw', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'nttjdzgi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'tclbosqc', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'uatpzgpi', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'rlpuzodt', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'cwnpdnng', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rhnikvfq', 'type': 'binary'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}, 't7': {'value': 'afcibyeb', 'type': 'binary'}, 't8': {'value': 'ncharTagValue', 'type': 'nchar'}, 't11': {'value': 127, 'type': 'tinyint'}, 't10': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': tb_name}}, 'punftb')]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_tag_list))
tdSql.query(f"show tables;")
@ -1699,10 +1699,10 @@ class TDTestCase:
tdCom.cleanTb()
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary"))
self.resCmp(input_json, stb_name)
s_stb_d_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'llqzvgvw', 'type': 'binary'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rlpuzodt', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'),
s_stb_d_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'llqzvgvw', 'type': 'binary'}, 'tags': {'t0': {'value': True, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'tclbosqc', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rlpuzodt', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'),
({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': {'value': 'rhnikvfq', 'type': 'binary'}, 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb')]
self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_m_tag_list))
tdSql.query(f"show tables;")
@ -1713,7 +1713,7 @@ class TDTestCase:
input_json = f'test_nchar 0 L"涛思数据" t0=f,t1=L"涛思数据",t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64'
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
# input_json, stb_name = self.genFullTypeJson()
# self.resCmp(input_json, stb_name)
# self.resCmp(input_json, stb_name)
except SchemalessError as err:
print(err.errno)

View File

@ -25,19 +25,19 @@ import threading
import platform
import io
if platform.system().lower() == 'windows':
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self._conn = conn
self._conn = conn
self.smlChildTableName_value = "id"
def createDb(self, name="test", db_update_tag=0, protocol=None):
if protocol == "telnet-tcp":
name = "opentsdb_telnet"
if db_update_tag == 0:
tdSql.execute(f"drop database if exists {name}")
tdSql.execute(f"create database if not exists {name} precision 'us' schemaless 1")
@ -66,7 +66,7 @@ class TDTestCase:
td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts))
return td_ts
#return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f"))
def dateToTs(self, datetime_input):
return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))
@ -191,7 +191,7 @@ class TDTestCase:
tb_name = ""
td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1])
td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0])
col_name_list.append('_value')
col_value_list.append(stb_col_value)
@ -218,7 +218,7 @@ class TDTestCase:
t4="9223372036854775807i64", t5="11.12345f32", t6="22.123456789f64", t7="\"binaryTagValue\"",
t8="L\"ncharTagValue\"", ts="1626006833641",
id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_mixul_tag=None, id_double_tag=None,
t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None,
t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None,
chinese_tag=None, multi_field_tag=None, point_trans_tag=None, protocol=None, tcp_keyword_tag=None):
if stb_name == "":
stb_name = tdCom.getLongName(len=6, mode="letters")
@ -268,7 +268,7 @@ class TDTestCase:
if protocol == "telnet-tcp":
sql_seq = 'put ' + sql_seq + '\n'
return sql_seq, stb_name
def genMulTagColStr(self, genType, count=1):
"""
genType must be tag/col
@ -365,10 +365,10 @@ class TDTestCase:
for t_type in full_type_list:
input_sql, stb_name = self.genFullTypeSql(t0=t_type, protocol=protocol)
self.resCmp(input_sql, stb_name, protocol=protocol)
def symbolsCheckCase(self, protocol=None):
"""
check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/?
check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/?
"""
'''
please test :
@ -424,7 +424,7 @@ class TDTestCase:
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def idSeqCheckCase(self, protocol=None):
"""
check id.index in tags
@ -434,7 +434,7 @@ class TDTestCase:
tdCom.cleanTb()
input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, protocol=protocol)
self.resCmp(input_sql, stb_name, protocol=protocol)
def idLetterCheckCase(self, protocol=None):
"""
check id param
@ -527,7 +527,7 @@ class TDTestCase:
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def illegalTsCheckCase(self):
"""
check ts format like 16260068336390us19
@ -592,7 +592,7 @@ class TDTestCase:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
tdSql.checkNotEqual(err.errno, 0)
def tagValueLengthCheckCase(self):
"""
@ -673,7 +673,7 @@ class TDTestCase:
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
# f32
# f32
tdCom.cleanTb()
for value in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]:
input_sql, stb_name = self.genFullTypeSql(value=value)
@ -703,12 +703,12 @@ class TDTestCase:
# except SchemalessError as err:
# tdSql.checkNotEqual(err.errno, 0)
# # # binary
# # # binary
# tdCom.cleanTb()
# stb_name = tdCom.getLongName(7, "letters")
# input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16374, "letters")}" t0=t'
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
# tdCom.cleanTb()
# input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16375, "letters")}" t0=t'
# try:
@ -748,12 +748,12 @@ class TDTestCase:
# i8 i16 i32 i64 f32 f64
for input_sql in [
self.genFullTypeSql(value="1s2i8")[0],
self.genFullTypeSql(value="1s2i8")[0],
self.genFullTypeSql(value="1s2i16")[0],
self.genFullTypeSql(value="1s2i32")[0],
self.genFullTypeSql(value="1s2i64")[0],
self.genFullTypeSql(value="11.1s45f32")[0],
self.genFullTypeSql(value="11.1s45f64")[0],
self.genFullTypeSql(value="11.1s45f64")[0],
]:
try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
@ -761,14 +761,14 @@ class TDTestCase:
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
# check accepted binary and nchar symbols
# check accepted binary and nchar symbols
# # * ~!@#$¥%^&*()-+={}|[]、「」:;
for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'):
input_sql1 = f'{tdCom.getLongName(7, "letters")} 1626006833640 "abc{symbol}aaa" t0=t'
input_sql2 = f'{tdCom.getLongName(7, "letters")} 1626006833640 t t0=t t1="abc{symbol}aaa"'
self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.TELNET.value, None)
# self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.TELNET.value, None)
def blankCheckCase(self):
'''
check blank case
@ -853,7 +853,7 @@ class TDTestCase:
check tag count add, stb and tb duplicate
* tag: alter table ...
* col: when update==0 and ts is same, unchange
* so this case tag&&value will be added,
* so this case tag&&value will be added,
* col is added without value when update==0
* col is added with value when update==1
"""
@ -869,14 +869,14 @@ class TDTestCase:
if db_update_tag == 1 :
self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True)
tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None)
tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None)
else:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
tdSql.checkData(0, 1, True)
tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None)
tdSql.checkData(0, 1, True)
tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None)
self.createDb()
@tdCom.smlPass
@ -952,7 +952,7 @@ class TDTestCase:
tdCom.cleanTb()
stb_name = tdCom.getLongName(8, "letters")
tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
lines = ["st123456 1626006833640 1i64 t1=3i64 t2=4f64 t3=\"t3\"",
"st123456 1626006833641 2i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64",
f'{stb_name} 1626006833642 3i64 t2=5f64 t3=L\"ste\"',
@ -970,7 +970,7 @@ class TDTestCase:
tdSql.checkRows(6)
tdSql.query('select * from st123456')
tdSql.checkRows(5)
def multiInsertCheckCase(self, count):
"""
test multi insert
@ -1014,7 +1014,7 @@ class TDTestCase:
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def blankColInsertCheckCase(self):
"""
test blank col insert
@ -1040,7 +1040,7 @@ class TDTestCase:
raise Exception("should not reach here")
except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0)
def chineseCheckCase(self):
"""
check nchar ---> chinese
@ -1210,7 +1210,7 @@ class TDTestCase:
self.multiThreadRun(self.genMultiThreadSeq(input_sql))
tdSql.query(f"show tables;")
tdSql.checkRows(5)
def sStbStbDdataInsertMultiThreadCheckCase(self):
"""
thread input same stb tb, different data, result keep first data
@ -1248,7 +1248,7 @@ class TDTestCase:
tdSql.checkEqual(tb_name, expected_tb_name)
tdSql.query(f"select * from {stb_name};")
tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
def sStbStbDdataMtInsertMultiThreadCheckCase(self):
"""
thread input same stb tb, different data, minus columes and tags, result keep first data
@ -1466,7 +1466,7 @@ class TDTestCase:
def run(self):
print("running {}".format(__file__))
try:
self.createDb()
self.runAll()

View File

@ -42,7 +42,7 @@ class TDTestCase:
self.comment_flag_list = [True,False]
def __set_and_alter_comment(self,tb_type='',comment_flag= False):
column_sql = ''
tag_sql = ''
for k,v in self.column_dict.items():
@ -78,7 +78,7 @@ class TDTestCase:
tdSql.execute(f'create {operation} {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]}) comment "{comment_info}"')
self.check_comment_info(comment_info,'stable')
self.alter_comment(self.stbname,'stable')
tdSql.execute(f'drop table {self.stbname}')
tdSql.execute(f'drop table {self.stbname}')
elif tb_type == 'child_table':
tdSql.execute(f'create table if not exists {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})')
if comment_flag == False:
@ -122,7 +122,7 @@ class TDTestCase:
for flag in comment_flag:
self.__set_and_alter_comment(tb,flag)
tdSql.execute('drop database db')
def run(self):
self.comment_check_case(self.table_type_list,self.comment_flag_list)
@ -131,4 +131,4 @@ class TDTestCase:
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -20,7 +20,7 @@ class TDTestCase:
updatecfgDict = {'ttlUnit':5,'ttlPushInterval':3}
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
tdSql.init(conn.cursor())
self.ntbname = 'ntb'
self.stbname = 'stb'
self.tbnum = 10

View File

@ -38,7 +38,7 @@ class TDTestCase:
case1: limit offset base function test
case2: offset return valid
'''
return
return
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
@ -64,7 +64,7 @@ class TDTestCase:
# self.create_tables();
self.ts = 1500000000000
# stop
# stop
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
@ -76,7 +76,7 @@ class TDTestCase:
def newcon(self,host,cfg):
user = "root"
password = "taosdata"
port =6030
port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
print(con)
return con
@ -126,14 +126,14 @@ class TDTestCase:
end = datetime.now()
print("elapsed time: ", end - start)
assert stmt.affected_rows == 3
#query 1
querystmt=conn.statement("select ?,bu from stb1")
queryparam=new_bind_params(1)
print(type(queryparam))
queryparam[0].binary("ts")
querystmt.bind_param(queryparam)
querystmt.execute()
querystmt.execute()
result=querystmt.use_result()
# rows=result.fetch_all()
# print( querystmt.use_result())
@ -152,7 +152,7 @@ class TDTestCase:
print(type(queryparam1))
queryparam1[0].int(4)
querystmt1.bind_param(queryparam1)
querystmt1.execute()
querystmt1.execute()
result1=querystmt1.use_result()
rows1=result1.fetch_all()
print(rows1)
@ -176,10 +176,10 @@ class TDTestCase:
host="localhost"
connectstmt=self.newcon(host,config)
self.test_stmt_insert_multi(connectstmt)
return
return
# add case with filename
#
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -38,7 +38,7 @@ class TDTestCase:
case1: limit offset base function test
case2: offset return valid
'''
return
return
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
@ -64,7 +64,7 @@ class TDTestCase:
# self.create_tables();
self.ts = 1500000000000
# stop
# stop
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
@ -76,7 +76,7 @@ class TDTestCase:
def newcon(self,host,cfg):
user = "root"
password = "taosdata"
port =6030
port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
tdLog.debug(con)
return con
@ -84,7 +84,7 @@ class TDTestCase:
def stmtExe(self,conn,sql,bindStat):
queryStat=conn.statement("%s"%sql)
queryStat.bind_param(bindStat)
queryStat.execute()
queryStat.execute()
result=queryStat.use_result()
rows=result.fetch_all()
return rows
@ -101,7 +101,7 @@ class TDTestCase:
ff float, dd double, bb binary(100), nn nchar(100), tt timestamp , vc varchar(100)) tags (t1 timestamp, t2 bool,\
t3 tinyint, t4 tinyint, t5 smallint, t6 int, t7 bigint, t8 tinyint unsigned, t9 smallint unsigned, \
t10 int unsigned, t11 bigint unsigned, t12 float, t13 double, t14 binary(100), t15 nchar(100), t16 timestamp)"%stablename)
stmt = conn.statement("insert into ? using log tags (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) \
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
tags = new_bind_params(16)
@ -140,13 +140,13 @@ class TDTestCase:
params[14].nchar(["涛思数据", None, "a long string with 中文?字符"])
params[15].timestamp([None, None, 1626861392591])
params[16].binary(["涛思数据16", None, None])
stmt.bind_param_batch(params)
stmt.execute()
assert stmt.affected_rows == 3
#query all
#query all
queryparam=new_bind_params(1)
queryparam[0].int(10)
rows=self.stmtExe(conn,"select * from log where bu < ?",queryparam)
@ -189,7 +189,7 @@ class TDTestCase:
#query: conversion Functions
queryparam=new_bind_params(1)
queryparam[0].binary('1232a')
queryparam[0].binary('1232a')
rows=self.stmtExe(conn,"select cast( ? as bigint) from log",queryparam)
tdLog.debug("assert 5th case %s"%rows)
assert rows[0][0] == 1232, '5th.1 case is failed'
@ -210,7 +210,7 @@ class TDTestCase:
tdLog.debug("assert 7th case %s"%rows)
assert rows[0][0] == 1, '7th case is failed'
assert rows[1][0] == 1, '7th case is failed'
#query: aggregate Functions
queryparam=new_bind_params(1)
queryparam[0].int(123)
@ -238,7 +238,7 @@ class TDTestCase:
# conn.execute("drop database if exists %s" % dbname)
conn.close()
except Exception as err:
# conn.execute("drop database if exists %s" % dbname)
conn.close()
@ -251,10 +251,10 @@ class TDTestCase:
connectstmt=self.newcon(host,config)
self.test_stmt_set_tbname_tag(connectstmt)
return
return
# add case with filename
#
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

Some files were not shown because too many files have changed in this diff Show More