diff --git a/.gitmodules b/.gitmodules index a2266c46afd180b52d3aa19003380078894f6a4b..3d721fa8954023f92f8dcc70b09a1424d0104bbe 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,12 @@ [submodule "src/connector/go"] path = src/connector/go - url = git@github.com:taosdata/driver-go.git + url = https://github.com/taosdata/driver-go.git [submodule "src/connector/grafanaplugin"] path = src/connector/grafanaplugin - url = git@github.com:taosdata/grafanaplugin.git + url = https://github.com/taosdata/grafanaplugin.git [submodule "src/connector/hivemq-tdengine-extension"] path = src/connector/hivemq-tdengine-extension - url = git@github.com:taosdata/hivemq-tdengine-extension.git + url = https://github.com/taosdata/hivemq-tdengine-extension.git [submodule "tests/examples/rust"] path = tests/examples/rust url = https://github.com/songtianyi/tdengine-rust-bindings.git diff --git a/Jenkinsfile b/Jenkinsfile index 4a584fbb35973cc1da82c235f0f47bebe3c50ca2..f076a046686fd62a07695cfe3911e1baacf5c5d5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -271,12 +271,12 @@ pipeline { ''' } timeout(time: 60, unit: 'MINUTES'){ - // sh ''' - // cd ${WKC}/tests/pytest - // rm -rf /var/lib/taos/* - // rm -rf /var/log/taos/* - // ./handle_crash_gen_val_log.sh - // ''' + sh ''' + cd ${WKC}/tests/pytest + rm -rf /var/lib/taos/* + rm -rf /var/log/taos/* + ./handle_crash_gen_val_log.sh + ''' sh ''' cd ${WKC}/tests/pytest rm -rf /var/lib/taos/* diff --git a/README-CN.md b/README-CN.md index a9bc814e8d6f6bef0ad94e29588f62e2e4c0e7f1..f851a906b88a0676abdc39150a2a93ae7fbe7f56 100644 --- a/README-CN.md +++ b/README-CN.md @@ -7,6 +7,7 @@ [![TDengine](TDenginelogo.png)](https://www.taosdata.com) 简体中文 | [English](./README.md) +很多职位正在热招中,请看[这里](https://www.taosdata.com/cn/careers/) # TDengine 简介 @@ -107,6 +108,12 @@ Go 连接器和 Grafana 插件在其他独立仓库,如果安装它们的话 git submodule update --init --recursive ``` +如果使用 https 协议下载比较慢,可以通过修改 ~/.gitconfig 文件添加以下两行设置使用 ssh 协议下载。需要首先上传 ssh 密钥到 GitHub,详细方法请参考 GitHub 官方文档。 +``` +[url "git@github.com:"] + insteadOf = https://github.com/ +``` + ## 构建 TDengine ### Linux 系统 diff --git a/README.md b/README.md index 2dea05f09d268b0d78de15ab98f3584df055c353..d5b6f1fa85b962253fe504fadff78e953d4da598 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ [![TDengine](TDenginelogo.png)](https://www.taosdata.com) English | [简体中文](./README-CN.md) +We are hiring, check [here](https://www.taosdata.com/en/careers/) # What is TDengine? @@ -101,6 +102,12 @@ so you should run this command in the TDengine directory to install them: git submodule update --init --recursive ``` +You can modify the file ~/.gitconfig to use ssh protocol instead of https for better download speed. You need to upload ssh public key to GitHub first. Please refer to GitHub official documentation for detail. +``` +[url "git@github.com:"] + insteadOf = https://github.com/ +``` + ## Build TDengine ### On Linux platform diff --git a/cmake/define.inc b/cmake/define.inc index 337a143e1f129d433f12d6772e9ed9c43d57c423..7894e6dab5d4ddd44e69f77702004183f431d3a6 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -45,6 +45,10 @@ IF (TD_TQ) ADD_DEFINITIONS(-D_TD_TQ_) ENDIF () +IF (TD_PRO) + ADD_DEFINITIONS(-D_TD_PRO_) +ENDIF () + IF (TD_MEM_CHECK) ADD_DEFINITIONS(-DTAOS_MEM_CHECK) ENDIF () diff --git a/cmake/input.inc b/cmake/input.inc index 9d716e1e7345955f7b6b844c85ace7e7bd5c6080..d746cf52f6eb016795d6fa6d01f408925159c710 100755 --- a/cmake/input.inc +++ b/cmake/input.inc @@ -49,6 +49,9 @@ IF (${DBNAME} MATCHES "power") ELSEIF (${DBNAME} MATCHES "tq") SET(TD_TQ TRUE) MESSAGE(STATUS "tq is true") +ELSEIF (${DBNAME} MATCHES "pro") + SET(TD_PRO TRUE) + MESSAGE(STATUS "pro is true") ENDIF () IF (${DLLTYPE} MATCHES "go") diff --git a/cmake/install.inc b/cmake/install.inc index e9ad240a793b9736edbe5769c6af12276e13a1a6..7ea2ba8da0af79c15378cda956a330b357804c5a 100755 --- a/cmake/install.inc +++ b/cmake/install.inc @@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS) #INSTALL(TARGETS taos RUNTIME DESTINATION driver) #INSTALL(TARGETS shell RUNTIME DESTINATION .) IF (TD_MVN_INSTALLED) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.34-dist.jar DESTINATION connector/jdbc) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.35-dist.jar DESTINATION connector/jdbc) ENDIF () ELSEIF (TD_DARWIN) SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") diff --git a/documentation20/cn/01.evaluation/docs.md b/documentation20/cn/01.evaluation/docs.md index 050046645c24e7db58ef2f39683433c3a4b53169..9ed9e2e7ebbcfdf63c9f8dddd8b6f716c4bb1a61 100644 --- a/documentation20/cn/01.evaluation/docs.md +++ b/documentation20/cn/01.evaluation/docs.md @@ -16,7 +16,7 @@ TDengine 的模块之一是时序数据库。但除此之外,为减少研发 采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。但需要指出的是,因充分利用了物联网时序数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。 -![TDengine技术生态图](page://images/eco_system.png) +![TDengine技术生态图](../images/eco_system.png)
图 1. TDengine技术生态图
## TDengine 总体适用场景 diff --git a/documentation20/cn/03.architecture/01.taosd/docs.md b/documentation20/cn/03.architecture/01.taosd/docs.md index 66d51ed2dc2ea1546ab167cad680c20b3fa9729c..c791d2c20d0daceec21949064f99289cf4994323 100644 --- a/documentation20/cn/03.architecture/01.taosd/docs.md +++ b/documentation20/cn/03.architecture/01.taosd/docs.md @@ -6,7 +6,7 @@ taosd包含rpc, dnode, vnode, tsdb, query, cq, sync, wal, mnode, http, monitor等模块,具体如下图: -![modules.png](page://images/architecture/modules.png) +![modules.png](../../images/architecture/modules.png) taosd的启动入口是dnode模块,dnode然后启动其他模块,包括可选配置的http, monitor模块。taosc或dnode之间交互的消息都是通过rpc模块进行,dnode模块根据接收到的消息类型,将消息分发到vnode或mnode的消息队列,或由dnode模块自己消费。dnode的工作线程(worker)消费消息队列里的消息,交给mnode或vnode进行处理。下面对各个模块做简要说明。 @@ -41,13 +41,13 @@ RPC模块还提供数据压缩功能,如果数据包的字节数超过系统 taosd的消息消费由dnode通过读写线程池进行控制,是系统的中枢。该模块内的结构体图如下: -![dnode.png](page://images/architecture/dnode.png) +![dnode.png](../../images/architecture/dnode.png) ## VNODE模块 vnode是一独立的数据存储查询逻辑单元,但因为一个vnode只能容许一个DB,因此vnode内部没有account, DB, user等概念。为实现更好的模块化、封装以及未来的扩展,它有很多子模块,包括负责存储的TSDB,负责查询的Query, 负责数据复制的sync,负责数据库日志的的wal, 负责连续查询的cq(continuous query), 负责事件触发的流计算的event等模块,这些子模块只与vnode模块发生关系,与其他模块没有任何调用关系。模块图如下: -![vnode.png](page://images/architecture/vnode.png) +![vnode.png](../../images/architecture/vnode.png) vnode模块向下,与dnodeVRead,dnodeVWrite发生互动,向上,与子模块发生互动。它主要的功能有: diff --git a/documentation20/cn/03.architecture/02.replica/docs.md b/documentation20/cn/03.architecture/02.replica/docs.md index 27ac7f123cdd2a56df9e65ae0fa13d1ff8faa23d..e80a03696b5321e327c19ac9445d3bf1dee8f28e 100644 --- a/documentation20/cn/03.architecture/02.replica/docs.md +++ b/documentation20/cn/03.architecture/02.replica/docs.md @@ -90,7 +90,7 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性 具体的流程图如下: -![replica-master.png](page://images/architecture/replica-master.png) +![replica-master.png](../../images/architecture/replica-master.png) 选择Master的具体规则如下: @@ -105,7 +105,7 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性 如果vnode A是master, vnode B是slave, vnode A能接受客户端的写请求,而vnode B不能。当vnode A收到写的请求后,遵循下面的流程: -![replica-forward.png](page://images/architecture/replica-forward.png) +![replica-forward.png](../../images/architecture/replica-forward.png) 1. 应用对写请求做基本的合法性检查,通过,则给该请求包打上一个版本号(version, 单调递增) 2. 应用将打上版本号的写请求封装一个WAL Head, 写入WAL(Write Ahead Log) @@ -140,7 +140,7 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性 整个数据恢复流程分为两大步骤,第一步,先恢复archived data(file), 然后恢复wal。具体流程如下: -![replica-restore.png](page://images/architecture/replica-restore.png) +![replica-restore.png](../../images/architecture/replica-restore.png) 1. 通过已经建立的TCP连接,发送sync req给master节点 2. master收到sync req后,以client的身份,向vnode B主动建立一新的专用于同步的TCP连接(syncFd) diff --git a/documentation20/cn/03.architecture/docs.md b/documentation20/cn/03.architecture/docs.md index 3e9877b4465eac2ca05d99c88a620a0c6bf89689..a92382169c62c9b79de69a92249b681a69c02139 100644 --- a/documentation20/cn/03.architecture/docs.md +++ b/documentation20/cn/03.architecture/docs.md @@ -156,7 +156,7 @@ TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何 TDengine 分布式架构的逻辑结构图如下: -![TDengine架构示意图](page://images/architecture/structure.png) +![TDengine架构示意图](../images/architecture/structure.png)
图 1 TDengine架构示意图
一个完整的 TDengine 系统是运行在一到多个物理节点上的,逻辑上,它包含数据节点(dnode)、TDengine应用驱动(taosc)以及应用(app)。系统中存在一到多个数据节点,这些数据节点组成一个集群(cluster)。应用通过taosc的API与TDengine集群进行互动。下面对每个逻辑单元进行简要介绍。 @@ -207,7 +207,7 @@ TDengine 分布式架构的逻辑结构图如下: 为解释vnode、mnode、taosc和应用之间的关系以及各自扮演的角色,下面对写入数据这个典型操作的流程进行剖析。 -![TDengine典型的操作流程](page://images/architecture/message.png) +![TDengine典型的操作流程](../images/architecture/message.png)
图 2 TDengine典型的操作流程
1. 应用通过JDBC、ODBC或其他API接口发起插入数据的请求。 @@ -278,7 +278,7 @@ TDengine除vnode分片之外,还对时序数据按照时间段进行分区。 Master Vnode遵循下面的写入流程: -![TDengine Master写入流程](page://images/architecture/write_master.png) +![TDengine Master写入流程](../images/architecture/write_master.png)
图 3 TDengine Master写入流程
1. master vnode收到应用的数据插入请求,验证OK,进入下一步; @@ -292,7 +292,7 @@ Master Vnode遵循下面的写入流程: 对于slave vnode,写入流程是: -![TDengine Slave写入流程](page://images/architecture/write_slave.png) +![TDengine Slave写入流程](../images/architecture/write_slave.png)
图 4 TDengine Slave写入流程
1. slave vnode收到Master vnode转发了的数据插入请求。检查last version是否与master一致,如果一致,进入下一步。如果不一致,需要进入同步状态。 @@ -434,7 +434,7 @@ SELECT COUNT(*) FROM d1001 WHERE ts >= '2017-7-14 00:00:00' AND ts < '2017-7-14 TDengine对每个数据采集点单独建表,但在实际应用中经常需要对不同的采集点数据进行聚合。为高效的进行聚合操作,TDengine引入超级表(STable)的概念。超级表用来代表一特定类型的数据采集点,它是包含多张表的表集合,集合里每张表的模式(schema)完全一致,但每张表都带有自己的静态标签,标签可以有多个,可以随时增加、删除和修改。应用可通过指定标签的过滤条件,对一个STable下的全部或部分表进行聚合或统计操作,这样大大简化应用的开发。其具体流程如下图所示: -![多表聚合查询原理图](page://images/architecture/multi_tables.png) +![多表聚合查询原理图](../images/architecture/multi_tables.png)
图 5 多表聚合查询原理图
1. 应用将一个查询条件发往系统; diff --git a/documentation20/cn/06.queries/docs.md b/documentation20/cn/06.queries/docs.md index 294a9721e1dd4b9ea2e60308a48372dd83395010..32b74d1b23416814b39addb68303587ecc0ba3f8 100644 --- a/documentation20/cn/06.queries/docs.md +++ b/documentation20/cn/06.queries/docs.md @@ -3,7 +3,7 @@ ## 主要查询功能 -TDengine 采用 SQL 作为查询语言。应用程序可以通过 C/C++, Java, Go, Python 连接器发送 SQL 语句,用户可以通过 TDengine 提供的命令行(Command Line Interface, CLI)工具 TAOS Shell 手动执行 SQL 即席查询(Ad-Hoc Query)。TDengine 支持如下查询功能: +TDengine 采用 SQL 作为查询语言。应用程序可以通过 C/C++, Java, Go, C#, Python, Node.js 连接器发送 SQL 语句,用户可以通过 TDengine 提供的命令行(Command Line Interface, CLI)工具 TAOS Shell 手动执行 SQL 即席查询(Ad-Hoc Query)。TDengine 支持如下查询功能: - 单列、多列数据查询 - 标签和数值的多种过滤条件:>, <, =, <>, like 等 diff --git a/documentation20/cn/08.connector/01.java/docs.md b/documentation20/cn/08.connector/01.java/docs.md index def8d4a905eaa6ab63256673aad04bd159a5478d..110b902b2051a88e14eaa73627780e56be158928 100644 --- a/documentation20/cn/08.connector/01.java/docs.md +++ b/documentation20/cn/08.connector/01.java/docs.md @@ -4,7 +4,7 @@ `taos-jdbcdriver` 的实现包括 2 种形式: JDBC-JNI 和 JDBC-RESTful(taos-jdbcdriver-2.0.18 开始支持 JDBC-RESTful)。 JDBC-JNI 通过调用客户端 libtaos.so(或 taos.dll )的本地方法实现, JDBC-RESTful 则在内部封装了 RESTful 接口实现。 -![tdengine-connector](page://images/tdengine-jdbc-connector.png) +![tdengine-connector](../../images/tdengine-jdbc-connector.png) 上图显示了 3 种 Java 应用使用连接器访问 TDengine 的方式: @@ -68,18 +68,18 @@ INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES( TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对应类型转换如下: -| TDengine DataType | Java DataType | -| ----------------- | ------------------ | -| TIMESTAMP | java.sql.Timestamp | -| INT | java.lang.Integer | -| BIGINT | java.lang.Long | -| FLOAT | java.lang.Float | -| DOUBLE | java.lang.Double | -| SMALLINT | java.lang.Short | -| TINYINT | java.lang.Byte | -| BOOL | java.lang.Boolean | -| BINARY | byte array | -| NCHAR | java.lang.String | +| TDengine DataType | JDBCType (driver 版本 < 2.0.24) | JDBCType (driver 版本 >= 2.0.24) | +| ----------------- | ------------------ | ------------------ | +| TIMESTAMP | java.lang.Long | java.sql.Timestamp | +| INT | java.lang.Integer | java.lang.Integer | +| BIGINT | java.lang.Long | java.lang.Long | +| FLOAT | java.lang.Float | java.lang.Float | +| DOUBLE | java.lang.Double | java.lang.Double | +| SMALLINT | java.lang.Short | java.lang.Short | +| TINYINT | java.lang.Byte | java.lang.Byte | +| BOOL | java.lang.Boolean | java.lang.Boolean | +| BINARY | java.lang.String | byte array | +| NCHAR | java.lang.String | java.lang.String | ## 安装Java Connector diff --git a/documentation20/cn/08.connector/docs.md b/documentation20/cn/08.connector/docs.md index 68b8d6f052384615ca0643663cca6ddab3b7e1d3..8cf3a889ceedb6cedcb5b7f1e581297b61986bcd 100644 --- a/documentation20/cn/08.connector/docs.md +++ b/documentation20/cn/08.connector/docs.md @@ -2,7 +2,7 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、Java、Python、Go、Node.js、C# 、RESTful 等,便于用户快速开发应用。 -![image-connecotr](page://images/connector.png) +![image-connecotr](../images/connector.png) 目前TDengine的连接器可支持的平台广泛,包括:X64/X86/ARM64/ARM32/MIPS/Alpha等硬件平台,以及Linux/Win64/Win32等开发环境。对照矩阵如下: @@ -64,8 +64,7 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、Java、 编辑taos.cfg文件(默认路径/etc/taos/taos.cfg),将firstEP修改为TDengine服务器的End Point,例如:h1.taos.com:6030 -**提示: ** - +**提示:** 1. **如本机没有部署TDengine服务,仅安装了应用驱动,则taos.cfg中仅需配置firstEP,无需配置FQDN。** 2. **为防止与服务器端连接时出现“unable to resolve FQDN”错误,建议确认客户端的hosts文件已经配置正确的FQDN值。** @@ -1166,7 +1165,7 @@ var affectRows = cursor.execute('insert into test.weather values(now, 22.3, 34); execute方法的返回值为该语句影响的行数,上面的sql向test库的weather表中,插入了一条数据,则返回值affectRows为1。 -TDengine目前还不支持update和delete语句。 +TDengine 目前还不支持 delete 语句。但从 2.0.8.0 版本开始,可以通过 `CREATE DATABASE` 时指定的 UPDATE 参数来启用对数据行的 update。 #### 查询 diff --git a/documentation20/cn/09.connections/docs.md b/documentation20/cn/09.connections/docs.md index d5a2f2763550e54a0c1829ff87c60b7bbca3defe..799cfc14a300d3f4c9fcbf8537f04984ae8e1df4 100644 --- a/documentation20/cn/09.connections/docs.md +++ b/documentation20/cn/09.connections/docs.md @@ -32,15 +32,15 @@ allow_loading_unsigned_plugins = taosdata-tdengine-datasource 用户可以直接通过 localhost:3000 的网址,登录 Grafana 服务器(用户名/密码:admin/admin),通过左侧 `Configuration -> Data Sources` 可以添加数据源,如下图所示: -![img](page://images/connections/add_datasource1.jpg) +![img](../images/connections/add_datasource1.jpg) 点击 `Add data source` 可进入新增数据源页面,在查询框中输入 TDengine 可选择添加,如下图所示: -![img](page://images/connections/add_datasource2.jpg) +![img](../images/connections/add_datasource2.jpg) 进入数据源配置页面,按照默认提示修改相应配置即可: -![img](page://images/connections/add_datasource3.jpg) +![img](../images/connections/add_datasource3.jpg) * Host: TDengine 集群的中任意一台服务器的 IP 地址与 TDengine RESTful 接口的端口号(6041),默认 http://localhost:6041 。 * User:TDengine 用户名。 @@ -48,13 +48,13 @@ allow_loading_unsigned_plugins = taosdata-tdengine-datasource 点击 `Save & Test` 进行测试,成功会有如下提示: -![img](page://images/connections/add_datasource4.jpg) +![img](../images/connections/add_datasource4.jpg) #### 创建 Dashboard 回到主界面创建 Dashboard,点击 Add Query 进入面板查询页面: -![img](page://images/connections/create_dashboard1.jpg) +![img](../images/connections/create_dashboard1.jpg) 如上图所示,在 Query 中选中 `TDengine` 数据源,在下方查询框可输入相应 sql 进行查询,具体说明如下: @@ -65,7 +65,7 @@ allow_loading_unsigned_plugins = taosdata-tdengine-datasource 按照默认提示查询当前 TDengine 部署所在服务器指定间隔系统内存平均使用量如下: -![img](page://images/connections/create_dashboard2.jpg) +![img](../images/connections/create_dashboard2.jpg) > 关于如何使用Grafana创建相应的监测界面以及更多有关使用Grafana的信息,请参考Grafana官方的[文档](https://grafana.com/docs/)。 @@ -75,11 +75,11 @@ allow_loading_unsigned_plugins = taosdata-tdengine-datasource 点击左侧 `Import` 按钮,并上传 `tdengine-grafana.json` 文件: -![img](page://images/connections/import_dashboard1.jpg) +![img](../images/connections/import_dashboard1.jpg) 导入完成之后可看到如下效果: -![img](page://images/connections/import_dashboard2.jpg) +![img](../images/connections/import_dashboard2.jpg) ## MATLAB diff --git a/documentation20/cn/11.administrator/docs.md b/documentation20/cn/11.administrator/docs.md index fe9417a861a5284b25525f16c87ab8d07d43181e..d26cd3c845527084612d1a876076838f5d0f9f1a 100644 --- a/documentation20/cn/11.administrator/docs.md +++ b/documentation20/cn/11.administrator/docs.md @@ -216,7 +216,7 @@ taosd -C | 98 | maxBinaryDisplayWidth | | **C** | | Taos shell中binary 和 nchar字段的显示宽度上限,超过此限制的部分将被隐藏 | 5 - | 30 | 实际上限按以下规则计算:如果字段值的长度大于 maxBinaryDisplayWidth,则显示上限为 **字段名长度** 和 **maxBinaryDisplayWidth** 的较大者。否则,上限为 **字段名长度** 和 **字段值长度** 的较大者。可在 shell 中通过命令 set max_binary_display_width nn动态修改此选项 | | 99 | queryBufferSize | | **S** | MB | 为所有并发查询占用保留的内存大小。 | | | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。(2.0.15 以前的版本中,此参数的单位是字节) | | 100 | ratioOfQueryCores | | **S** | | 设置查询线程的最大数量。 | | | 最小值0 表示只有1个查询线程;最大值2表示最大建立2倍CPU核数的查询线程。默认为1,表示最大和CPU核数相等的查询线程。该值可以为小数,即0.5表示最大建立CPU核数一半的查询线程。 | -| 101 | update | | **S** | | 允许更新已存在的数据行 | 0 \| 1 | 0 | 从 2.0.8.0 版本开始 | +| 101 | update | | **S** | | 允许更新已存在的数据行 | 0:不允许更新;1:允许整行更新;2:允许部分列更新。(2.1.7.0 版本开始此参数支持设为 2,在此之前取值只能是 [0, 1]) | 0 | 2.0.8.0 版本之前,不支持此参数。 | | 102 | cacheLast | | **S** | | 是否在内存中缓存子表的最近数据 | 0:关闭;1:缓存子表最近一行数据;2:缓存子表每一列的最近的非NULL值;3:同时打开缓存最近行和列功能。(2.1.2.0 版本开始此参数支持 0~3 的取值范围,在此之前取值只能是 [0, 1]) | 0 | 2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。 | | 103 | numOfCommitThreads | YES | **S** | | 设置写入线程的最大数量 | | | | | 104 | maxWildCardsLength | | **C** | bytes | 设定 LIKE 算子的通配符字符串允许的最大长度 | 0-16384 | 100 | 2.1.6.1 版本新增。 | @@ -239,7 +239,7 @@ taosd -C | 10 | fsync | 毫秒 | 当wal设置为2时,执行fsync的周期。设置为0,表示每次写入,立即执行fsync。 | | 3000 | | 11 | replica | | (可通过 alter database 修改)副本个数 | 1-3 | 1 | | 12 | precision | | 时间戳精度标识(2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。)(从 2.1.5.0 版本开始,新增对纳秒时间精度的支持) | ms 表示毫秒,us 表示微秒,ns 表示纳秒 | ms | -| 13 | update | | 是否允许更新 | 0:不允许;1:允许 | 0 | +| 13 | update | | 是否允许数据更新(从 2.1.7.0 版本开始此参数支持 0~2 的取值范围,在此之前取值只能是 [0, 1];而 2.0.8.0 之前的版本在 SQL 指令中不支持此参数。) | 0:不允许;1:允许更新整行;2:允许部分列更新。 | 0 | | 14 | cacheLast | | (可通过 alter database 修改)是否在内存中缓存子表的最近数据(从 2.1.2.0 版本开始此参数支持 0~3 的取值范围,在此之前取值只能是 [0, 1];而 2.0.11.0 之前的版本在 SQL 指令中不支持此参数。)(2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。) | 0:关闭;1:缓存子表最近一行数据;2:缓存子表每一列的最近的非NULL值;3:同时打开缓存最近行和列功能 | 0 | 对于一个应用场景,可能有多种数据特征的数据并存,最佳的设计是将具有相同数据特征的表放在一个库里,这样一个应用有多个库,而每个库可以配置不同的存储参数,从而保证系统有最优的性能。TDengine允许应用在创建库时指定上述存储参数,如果指定,该参数就将覆盖对应的系统配置参数。举例,有下述SQL: diff --git a/documentation20/cn/12.taos-sql/02.udf/docs.md b/documentation20/cn/12.taos-sql/02.udf/docs.md index db820cfa87f38c8f2cf185d433c4ca70443964f9..cced65db802d9a589602fe9371b0468605cb4819 100644 --- a/documentation20/cn/12.taos-sql/02.udf/docs.md +++ b/documentation20/cn/12.taos-sql/02.udf/docs.md @@ -99,22 +99,32 @@ gcc -g -O0 -fPIC -shared add_one.c -o add_one.so 在创建 UDF 时,需要区分标量函数和聚合函数。如果创建时声明了错误的函数类别,则可能导致通过 SQL 指令调用函数时出错。 -- 创建标量函数:`CREATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) bufsize(B);` - * X:标量函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; - * Y:包含 UDF 函数实现的动态链接库的库文件路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件); - * Z:此函数计算结果的数据类型,使用数字表示,含义与上文中 udfNormalFunc 的 itype 参数一致; +- 创建标量函数:`CREATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) bufsize B;` + * ids(X):标量函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; + * ids(Y):包含 UDF 函数实现的动态链接库的库文件路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来; + * typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可; * B:系统使用的中间临时缓冲区大小,单位是字节,最小 0,最大 512,通常可以设置为 128。 -- 创建聚合函数:`CREATE AGGREGATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) bufsize(B);` - * X:标量函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; - * Y:包含 UDF 函数实现的动态链接库的库文件路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件); - * Z:此函数计算结果的数据类型,使用数字表示,含义与上文中 udfNormalFunc 的 itype 参数一致; + 例如,如下语句可以把 add_one.so 创建为系统中可用的 UDF: + ```sql + CREATE FUNCTION add_one AS "/home/taos/udf_example/add_one.so" OUTPUTTYPE INT bufsize 128; + ``` + +- 创建聚合函数:`CREATE AGGREGATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) bufsize B;` + * ids(X):聚合函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; + * ids(Y):包含 UDF 函数实现的动态链接库的库文件路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来; + * typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可; * B:系统使用的中间临时缓冲区大小,单位是字节,最小 0,最大 512,通常可以设置为 128。 + 例如,如下语句可以把 add_one.so 创建为系统中可用的 UDF: + ```sql + CREATE FUNCTION abs_max AS "/home/taos/udf_example/abs_max.so" OUTPUTTYPE BIGINT bufsize 128; + ``` + ### 管理 UDF - 删除指定名称的用户定义函数:`DROP FUNCTION ids(X);` - * X:此参数的含义与 CREATE 指令中的 X 参数一致。 + * ids(X):此参数的含义与 CREATE 指令中的 ids(X) 参数一致,也即要删除的函数的名字,例如 `DROP FUNCTION add_one;`。 - 显示系统中当前可用的所有 UDF:`SHOW FUNCTIONS;` ### 调用 UDF diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md index d4ae0be7202c4a452024d58839dacef818cd4c64..dabbb3d2af598c84f6c55f921d524cb9ddccb83b 100644 --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -70,7 +70,7 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传 1) KEEP是该数据库的数据保留多长天数,缺省是3650天(10年),数据库会自动删除超过时限的数据; - 2) UPDATE 标志数据库支持更新相同时间戳数据; + 2) UPDATE 标志数据库支持更新相同时间戳数据;(从 2.1.7.0 版本开始此参数支持设为 2,表示允许部分列更新,也即更新数据行时未被设置的列会保留原值。)(从 2.0.8.0 版本开始支持此参数。注意此参数不能通过 `ALTER DATABASE` 指令进行修改。) 3) 数据库名最大长度为33; @@ -573,16 +573,24 @@ Query OK, 2 row(s) in set (0.003112s) 注意:普通表的通配符 * 中并不包含 _标签列_。 -##### 获取标签列的去重取值 +#### 获取标签列或普通列的去重取值 -从 2.0.15 版本开始,支持在超级表查询标签列时,指定 DISTINCT 关键字,这样将返回指定标签列的所有不重复取值。 -```mysql -SELECT DISTINCT tag_name FROM stb_name; +从 2.0.15.0 版本开始,支持在超级表查询标签列时,指定 DISTINCT 关键字,这样将返回指定标签列的所有不重复取值。注意,在 2.1.6.0 版本之前,DISTINCT 只支持处理单个标签列,而从 2.1.6.0 版本开始,DISTINCT 可以对多个标签列进行处理,输出这些标签列取值不重复的组合。 +```sql +SELECT DISTINCT tag_name [, tag_name ...] FROM stb_name; ``` -注意:目前 DISTINCT 关键字只支持对超级表的标签列进行去重,而不能用于普通列。 +从 2.1.7.0 版本开始,DISTINCT 也支持对数据子表或普通表进行处理,也即支持获取单个普通列的不重复取值,或多个普通列取值的不重复组合。 +```sql +SELECT DISTINCT col_name [, col_name ...] FROM tb_name; +``` +需要注意的是,DISTINCT 目前不支持对超级表中的普通列进行处理。如果需要进行此类操作,那么需要把超级表放在子查询中,再对子查询的计算结果执行 DISTINCT。 +说明: +1. cfg 文件中的配置参数 maxNumOfDistinctRes 将对 DISTINCT 能够输出的数据行数进行限制。其最小值是 100000,最大值是 100000000,默认值是 10000000。如果实际计算结果超出了这个限制,那么会仅输出这个数量范围内的部分。 +2. 由于浮点数天然的精度机制原因,在特定情况下,对 FLOAT 和 DOUBLE 列使用 DISTINCT 并不能保证输出值的完全唯一性。 +3. 在当前版本下,DISTINCT 不能在嵌套查询的子查询中使用,也不能与聚合函数、GROUP BY、或 JOIN 在同一条语句中混用。 #### 结果集列名 @@ -1453,8 +1461,6 @@ SELECT function_list FROM tb_name SELECT function_list FROM stb_name [WHERE where_condition] - [SESSION(ts_col, tol_val)] - [STATE_WINDOW(col)] [INTERVAL(interval [, offset]) [SLIDING sliding]] [FILL({NONE | VALUE | PREV | NULL | LINEAR | NEXT})] [GROUP BY tags] @@ -1465,8 +1471,8 @@ SELECT function_list FROM stb_name 1. 时间窗口:聚合时间段的窗口宽度由关键词 INTERVAL 指定,最短时间间隔 10 毫秒(10a);并且支持偏移 offset(偏移必须小于间隔),也即时间窗口划分与“UTC 时刻 0”相比的偏移量。SLIDING 语句用于指定聚合时间段的前向增量,也即每次窗口向前滑动的时长。当 SLIDING 与 INTERVAL 取值相等的时候,滑动窗口即为翻转窗口。 * 从 2.1.5.0 版本开始,INTERVAL 语句允许的最短时间间隔调整为 1 微秒(1u),当然如果所查询的 DATABASE 的时间精度设置为毫秒级,那么允许的最短时间间隔为 1 毫秒(1a)。 * **注意:**用到 INTERVAL 语句时,除非极特殊的情况,都要求把客户端和服务端的 taos.cfg 配置文件中的 timezone 参数配置为相同的取值,以避免时间处理函数频繁进行跨时区转换而导致的严重性能影响。 - 2. 状态窗口:使用整数或布尔值来标识产生记录时设备的状态量,产生的记录如果具有相同的状态量取值则归属于同一个状态窗口,数值改变后该窗口关闭。状态量所对应的列作为 STATE_WINDOW 语句的参数来指定。 - 3. 会话窗口:时间戳所在的列由 SESSION 语句的 ts_col 参数指定,会话窗口根据相邻两条记录的时间戳差值来确定是否属于同一个会话——如果时间戳差异在 tol_val 以内,则认为记录仍属于同一个窗口;如果时间变化超过 tol_val,则自动开启下一个窗口。 + 2. 状态窗口:使用整数或布尔值来标识产生记录时设备的状态量,产生的记录如果具有相同的状态量取值则归属于同一个状态窗口,数值改变后该窗口关闭。状态量所对应的列作为 STATE_WINDOW 语句的参数来指定。(状态窗口暂不支持对超级表使用) + 3. 会话窗口:时间戳所在的列由 SESSION 语句的 ts_col 参数指定,会话窗口根据相邻两条记录的时间戳差值来确定是否属于同一个会话——如果时间戳差异在 tol_val 以内,则认为记录仍属于同一个窗口;如果时间变化超过 tol_val,则自动开启下一个窗口。(会话窗口暂不支持对超级表使用) - WHERE 语句可以指定查询的起止时间和其他过滤条件。 - FILL 语句指定某一窗口区间数据缺失的情况下的填充模式。填充模式包括以下几种: 1. 不进行填充:NONE(默认填充模式)。 diff --git a/documentation20/cn/13.faq/docs.md b/documentation20/cn/13.faq/docs.md index 3d6f03b30353524d55a4a49ea69625a519fe3ebe..14599079b7c5bf99d736b34504cf59f1112900b0 100644 --- a/documentation20/cn/13.faq/docs.md +++ b/documentation20/cn/13.faq/docs.md @@ -96,6 +96,8 @@ TDengine 目前尚不支持删除功能,未来根据用户需求可能会支 另需注意,在 UPDATE 设置为 0 时,后发送的相同时间戳的数据会被直接丢弃,但并不会报错,而且仍然会被计入 affected rows (所以不能利用 INSERT 指令的返回信息进行时间戳查重)。这样设计的主要原因是,TDengine 把写入的数据看做一个数据流,无论时间戳是否出现冲突,TDengine 都认为产生数据的原始设备真实地产生了这样的数据。UPDATE 参数只是控制这样的流数据在进行持久化时要怎样处理——UPDATE 为 0 时,表示先写入的数据覆盖后写入的数据;而 UPDATE 为 1 时,表示后写入的数据覆盖先写入的数据。这种覆盖关系如何选择,取决于对数据的后续使用和统计中,希望以先还是后生成的数据为准。 +此外,从 2.1.7.0 版本开始,支持将 UPDATE 参数设为 2,表示“支持部分列更新”。也即,当 UPDATE 设为 1 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会被设为 NULL;而当 UPDATE 设为 2 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会保持原有数据行中的对应值。 + ## 10. 我怎么创建超过1024列的表? 使用 2.0 及其以上版本,默认支持 1024 列;2.0 之前的版本,TDengine 最大允许创建 250 列的表。但是如果确实超过限值,建议按照数据特性,逻辑地将这个宽表分解成几个小表。(从 2.1.7.0 版本开始,表的最大列数增加到了 4096 列。) diff --git a/documentation20/en/01.evaluation/docs.md b/documentation20/en/01.evaluation/docs.md index 5b2d0dd974203db1dafe8758e673a2f0970c3f17..b296ae999fbf63f65422993dde4586b6bec08497 100644 --- a/documentation20/en/01.evaluation/docs.md +++ b/documentation20/en/01.evaluation/docs.md @@ -15,7 +15,8 @@ One of the modules of TDengine is the time-series database. However, in addition With TDengine, the total cost of ownership of typical IoT, Internet of Vehicles, and Industrial Internet Big Data platforms can be greatly reduced. However, since it makes full use of the characteristics of IoT time-series data, TDengine cannot be used to process general data from web crawlers, microblogs, WeChat, e-commerce, ERP, CRM, and other sources. -![TDengine Technology Ecosystem](page://images/eco_system.png) +![TDengine Technology Ecosystem](../images/eco_system.png) +
Figure 1. TDengine Technology Ecosystem
## Overall Scenarios of TDengine diff --git a/documentation20/en/03.architecture/docs.md b/documentation20/en/03.architecture/docs.md index e0a324acad37d3c9e23d73a1f5762651b32e924d..ea73cd9f87f8cfacaced66ab79f00f2f3ab727cc 100644 --- a/documentation20/en/03.architecture/docs.md +++ b/documentation20/en/03.architecture/docs.md @@ -154,10 +154,8 @@ The design of TDengine is based on the assumption that one single node or softwa Logical structure diagram of TDengine distributed architecture as following: -![TDengine architecture diagram](page://images/architecture/structure.png) -
Picture 1: TDengine architecture diagram
- - +![TDengine architecture diagram](../images/architecture/structure.png) +
Figure 1: TDengine architecture diagram
A complete TDengine system runs on one or more physical nodes. Logically, it includes data node (dnode), TDEngine application driver (TAOSC) and application (app). There are one or more data nodes in the system, which form a cluster. The application interacts with the TDengine cluster through TAOSC's API. The following is a brief introduction to each logical unit. @@ -199,8 +197,8 @@ A complete TDengine system runs on one or more physical nodes. Logically, it inc To explain the relationship between vnode, mnode, TAOSC and application and their respective roles, the following is an analysis of a typical data writing process. -![ typical process of TDengine](page://images/architecture/message.png) -
Picture 2 typical process of TDengine
+![typical process of TDengine](../images/architecture/message.png) +
Figure 2: Typical process of TDengine
1. Application initiates a request to insert data through JDBC, ODBC, or other APIs. 2. TAOSC checks if meta data existing for the table in the cache. If so, go straight to Step 4. If not, TAOSC sends a get meta-data request to mnode. @@ -268,7 +266,8 @@ If a database has N replicas, thus a virtual node group has N virtual nodes, but Master Vnode uses a writing process as follows: -Figure 3: TDengine Master writing process +![TDengine Master Writing Process](../images/architecture/write_master.png) +
Figure 3: TDengine Master writing process
1. Master vnode receives the application data insertion request, verifies, and moves to next step; 2. If the system configuration parameter `walLevel` is greater than 0, vnode will write the original request packet into database log file WAL. If walLevel is set to 2 and fsync is set to 0, TDengine will make WAL data written immediately to ensure that even system goes down, all data can be recovered from database log file; @@ -281,8 +280,8 @@ Figure 3: TDengine Master writing process For a slave vnode, the write process as follows: -![TDengine Slave Writing Process](page://images/architecture/write_master.png) -
Picture 3 TDengine Slave Writing Process
+![TDengine Slave Writing Process](../images/architecture/write_slave.png) +
Figure 4: TDengine Slave Writing Process
1. Slave vnode receives a data insertion request forwarded by Master vnode; 2. If the system configuration parameter `walLevel` is greater than 0, vnode will write the original request packet into database log file WAL. If walLevel is set to 2 and fsync is set to 0, TDengine will make WAL data written immediately to ensure that even system goes down, all data can be recovered from database log file; @@ -355,8 +354,6 @@ When data is written to disk, it is decided whether to compress the data accordi By default, TDengine saves all data in /var/lib/taos directory, and the data files of each vnode are saved in a different directory under this directory. In order to expand the storage space, minimize the bottleneck of file reading and improve the data throughput rate, TDengine can configure the system parameter “dataDir” to allow multiple mounted hard disks to be used by system at the same time. In addition, TDengine also provides the function of tiered data storage, i.e. storage on different storage media according to the time stamps of data files. For example, the latest data is stored on SSD, the data for more than one week is stored on local hard disk, and the data for more than four weeks is stored on network storage device, thus reducing the storage cost and ensuring efficient data access. The movement of data on different storage media is automatically done by the system and completely transparent to applications. Tiered storage of data is also configured through the system parameter “dataDir”. - - dataDir format is as follows: ``` dataDir data_path [tier_level] @@ -364,8 +361,6 @@ dataDir data_path [tier_level] Where data_path is the folder path of mount point and tier_level is the media storage-tier. The higher the media storage-tier, means the older the data file. Multiple hard disks can be mounted at the same storage-tier, and data files on the same storage-tier are distributed on all hard disks within the tier. TDengine supports up to 3 tiers of storage, so tier_level values are 0, 1, and 2. When configuring dataDir, there must be only one mount path without specifying tier_level, which is called special mount disk (path). The mount path defaults to level 0 storage media and contains special file links, which cannot be removed, otherwise it will have a devastating impact on the written data. - - Suppose a physical node with six mountable hard disks/mnt/disk1,/mnt/disk2, …,/mnt/disk6, where disk1 and disk2 need to be designated as level 0 storage media, disk3 and disk4 are level 1 storage media, and disk5 and disk6 are level 2 storage media. Disk1 is a special mount disk, you can configure it in/etc/taos/taos.cfg as follows: ``` @@ -379,7 +374,6 @@ dataDir /mnt/disk6/taos 2 Mounted disks can also be a non-local network disk, as long as the system can access it. - Note: Tiered Storage is only supported in Enterprise Edition ## Data Query @@ -418,8 +412,8 @@ For the data collected by device D1001, the number of records per hour is counte TDengine creates a separate table for each data collection point, but in practical applications, it is often necessary to aggregate data from different data collection points. In order to perform aggregation operations efficiently, TDengine introduces the concept of STable. STable is used to represent a specific type of data collection point. It is a table set containing multiple tables. The schema of each table in the set is the same, but each table has its own static tag. The tags can be multiple and be added, deleted and modified at any time. Applications can aggregate or statistically operate all or a subset of tables under a STABLE by specifying tag filters, thus greatly simplifying the development of applications. The process is shown in the following figure: -![Diagram of multi-table aggregation query](page://images/architecture/multi_tables.png) -
Picture 4 Diagram of multi-table aggregation query
+![Diagram of multi-table aggregation query](../images/architecture/multi_tables.png) +
Figure 5: Diagram of multi-table aggregation query
1. Application sends a query condition to system; 2. TAOSC sends the STable name to Meta Node(management node); diff --git a/documentation20/en/06.queries/docs.md b/documentation20/en/06.queries/docs.md index 7688a941f0fb5b685f592833322906e4c4760b79..d906443153bb7e83cee69da4588554893ce154a3 100644 --- a/documentation20/en/06.queries/docs.md +++ b/documentation20/en/06.queries/docs.md @@ -2,7 +2,7 @@ ## Main Query Features -TDengine uses SQL as the query language. Applications can send SQL statements through C/C++, Java, Go, Python connectors, and users can manually execute SQL Ad-Hoc Query through the Command Line Interface (CLI) tool TAOS Shell provided by TDengine. TDengine supports the following query functions: +TDengine uses SQL as the query language. Applications can send SQL statements through C/C++, Java, Go, C#, Python, Node.js connectors, and users can manually execute SQL Ad-Hoc Query through the Command Line Interface (CLI) tool TAOS Shell provided by TDengine. TDengine supports the following query functions: - Single-column and multi-column data query - Multiple filters for tags and numeric values: >, <, =, < >, like, etc @@ -96,4 +96,4 @@ Query OK, 5 row(s) in set (0.001521s) In IoT scenario, it is difficult to synchronize the time stamp of collected data at each point, but many analysis algorithms (such as FFT) need to align the collected data strictly at equal intervals of time. In many systems, it’s required to write their own programs to process, but the down sampling operation of TDengine can be used to solve the problem easily. If there is no collected data in an interval, TDengine also provides interpolation calculation function. -For details of syntax rules, please refer to the [Time-dimension Aggregation section of TAOS SQL](https://www.taosdata.com/en/documentation/taos-sql#aggregation). \ No newline at end of file +For details of syntax rules, please refer to the [Time-dimension Aggregation section of TAOS SQL](https://www.taosdata.com/en/documentation/taos-sql#aggregation). diff --git a/documentation20/en/08.connector/01.java/docs.md b/documentation20/en/08.connector/01.java/docs.md index bd5df5a4952d5b56badde4eb3d6c88051cfa7b51..75cc380c141383cce0bc3c9790c91fa97563e3ca 100644 --- a/documentation20/en/08.connector/01.java/docs.md +++ b/documentation20/en/08.connector/01.java/docs.md @@ -4,7 +4,7 @@ The taos-jdbcdriver is implemented in two forms: JDBC-JNI and JDBC-RESTful (supported from taos-jdbcdriver-2.0.18). JDBC-JNI is implemented by calling the local methods of libtaos.so (or taos.dll) on the client, while JDBC-RESTful encapsulates the RESTful interface implementation internally. -![tdengine-connector](page://images/tdengine-jdbc-connector.png) +![tdengine-connector](../../images/tdengine-jdbc-connector.png) The figure above shows the three ways Java applications can access the TDengine: @@ -69,18 +69,18 @@ INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES( The TDengine supports the following data types and Java data types: -| TDengine DataType | Java DataType | -| ----------------- | ------------------ | -| TIMESTAMP | java.sql.Timestamp | -| INT | java.lang.Integer | -| BIGINT | java.lang.Long | -| FLOAT | java.lang.Float | -| DOUBLE | java.lang.Double | -| SMALLINT | java.lang.Short | -| TINYINT | java.lang.Byte | -| BOOL | java.lang.Boolean | -| BINARY | byte[] | -| NCHAR | java.lang.String | +| TDengine DataType | JDBCType (driver version < 2.0.24) | JDBCType (driver version >= 2.0.24) | +| ----------------- | ------------------ | ------------------ | +| TIMESTAMP | java.lang.Long | java.sql.Timestamp | +| INT | java.lang.Integer | java.lang.Integer | +| BIGINT | java.lang.Long | java.lang.Long | +| FLOAT | java.lang.Float | java.lang.Float | +| DOUBLE | java.lang.Double | java.lang.Double | +| SMALLINT | java.lang.Short | java.lang.Short | +| TINYINT | java.lang.Byte | java.lang.Byte | +| BOOL | java.lang.Boolean | java.lang.Boolean | +| BINARY | java.lang.String | byte array | +| NCHAR | java.lang.String | java.lang.String | ## Install Java connector diff --git a/documentation20/en/08.connector/docs.md b/documentation20/en/08.connector/docs.md index fd9d129e50fa4450aed2fbebe80eddb978ef1263..b4d2ee3a05850aa9b1a3c886ec26e4661b7f997b 100644 --- a/documentation20/en/08.connector/docs.md +++ b/documentation20/en/08.connector/docs.md @@ -2,7 +2,7 @@ TDengine provides many connectors for development, including C/C++, JAVA, Python, RESTful, Go, Node.JS, etc. -![image-connector](page://images/connector.png) +![image-connector](../images/connector.png) At present, TDengine connectors support a wide range of platforms, including hardware platforms such as X64/X86/ARM64/ARM32/MIPS/Alpha, and development environments such as Linux/Win64/Win32. The comparison matrix is as follows: diff --git a/documentation20/en/09.connections/docs.md b/documentation20/en/09.connections/docs.md index 19544af0fa50af258f975532ad8399fcb8588b42..f1bbf0ff639719c7609f4a04685adf9c16a4e623 100644 --- a/documentation20/en/09.connections/docs.md +++ b/documentation20/en/09.connections/docs.md @@ -26,15 +26,15 @@ sudo cp -rf /usr/local/taos/connector/grafanaplugin /var/lib/grafana/plugins/tde You can log in the Grafana server (username/password:admin/admin) through localhost:3000, and add data sources through `Configuration -> Data Sources` on the left panel, as shown in the following figure: -![img](page://images/connections/add_datasource1.jpg) +![img](../images/connections/add_datasource1.jpg) Click `Add data source` to enter the Add Data Source page, and enter TDengine in the query box to select Add, as shown in the following figure: -![img](page://images/connections/add_datasource2.jpg) +![img](../images/connections/add_datasource2.jpg) Enter the data source configuration page and modify the corresponding configuration according to the default prompt: -![img](page://images/connections/add_datasource3.jpg) +![img](../images/connections/add_datasource3.jpg) - Host: IP address of any server in TDengine cluster and port number of TDengine RESTful interface (6041), default [http://localhost:6041](http://localhost:6041/) - User: TDengine username. @@ -42,13 +42,13 @@ Enter the data source configuration page and modify the corresponding configurat Click `Save & Test` to test. Success will be prompted as follows: -![img](page://images/connections/add_datasource4.jpg) +![img](../images/connections/add_datasource4.jpg) #### Create Dashboard Go back to the home to create Dashboard, and click `Add Query` to enter the panel query page: -![img](page://images/connections/create_dashboard1.jpg) +![img](../images/connections/create_dashboard1.jpg) As shown in the figure above, select the TDengine data source in Query, and enter the corresponding sql in the query box below to query. Details are as follows: @@ -58,7 +58,7 @@ As shown in the figure above, select the TDengine data source in Query, and ente According to the default prompt, query the average system memory usage at the specified interval of the server where the current TDengine deployed in as follows: -![img](page://images/connections/create_dashboard2.jpg) +![img](../images/connections/create_dashboard2.jpg) > Please refer to Grafana [documents](https://grafana.com/docs/) for how to use Grafana to create the corresponding monitoring interface and for more about Grafana usage. @@ -68,11 +68,11 @@ A `tdengine-grafana.json` importable dashboard is provided under the Grafana plu Click the `Import` button on the left panel and upload the `tdengine-grafana.json` file: -![img](page://images/connections/import_dashboard1.jpg) +![img](../images/connections/import_dashboard1.jpg) You can see as follows after Dashboard imported. -![img](page://images/connections/import_dashboard2.jpg) +![img](../images/connections/import_dashboard2.jpg) ## MATLAB diff --git a/packaging/docker/dockerManifest.sh b/packaging/docker/dockerManifest.sh index 98abe4e099d9bfe5b06d0a61d667391a9f667eb7..e4d3cda7f29fea96cabfe48f5b10ab668a085ea8 100755 --- a/packaging/docker/dockerManifest.sh +++ b/packaging/docker/dockerManifest.sh @@ -45,6 +45,7 @@ echo "version=${version}" #docker manifest rm tdengine/tdengine:${version} if [ "$verType" == "beta" ]; then docker manifest inspect tdengine/tdengine-beta:latest + docker manifest create -a tdengine/tdengine-beta:latest tdengine/tdengine-amd64-beta:latest tdengine/tdengine-aarch64-beta:latest tdengine/tdengine-aarch32-beta:latest docker manifest rm tdengine/tdengine-beta:latest docker manifest create -a tdengine/tdengine-beta:${version} tdengine/tdengine-amd64-beta:${version} tdengine/tdengine-aarch64-beta:${version} tdengine/tdengine-aarch32-beta:${version} docker manifest create -a tdengine/tdengine-beta:latest tdengine/tdengine-amd64-beta:latest tdengine/tdengine-aarch64-beta:latest tdengine/tdengine-aarch32-beta:latest @@ -54,6 +55,7 @@ if [ "$verType" == "beta" ]; then elif [ "$verType" == "stable" ]; then docker manifest inspect tdengine/tdengine:latest + docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest docker manifest rm tdengine/tdengine:latest docker manifest create -a tdengine/tdengine:${version} tdengine/tdengine-amd64:${version} tdengine/tdengine-aarch64:${version} tdengine/tdengine-aarch32:${version} docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest diff --git a/packaging/release.sh b/packaging/release.sh index 5ba6c01a0bd5689278bdb5c86b538b3c447f086a..44887c6cf749ecfecdef46799311de38dbbbed23 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -22,7 +22,7 @@ cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 ...] osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] pagMode=full # [full | lite] soMode=dynamic # [static | dynamic] -dbName=taos # [taos | power | tq] +dbName=taos # [taos | power | tq | pro] allocator=glibc # [glibc | jemalloc] verNumber="" verNumberComp="1.0.0.0" @@ -78,7 +78,7 @@ do echo " -l [full | lite] " echo " -a [glibc | jemalloc] " echo " -s [static | dynamic] " - echo " -d [taos | power | tq ] " + echo " -d [taos | power | tq | pro] " echo " -n [version number] " echo " -m [compatible version number] " exit 0 @@ -253,6 +253,10 @@ if [ "$osType" != "Darwin" ]; then ${csudo} ./makepkg_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} ${csudo} ./makeclient_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${csudo} ./makearbi_tq.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} + elif [[ "$dbName" == "pro" ]]; then + ${csudo} ./makepkg_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} + ${csudo} ./makeclient_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} + ${csudo} ./makearbi_pro.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} else ${csudo} ./makepkg_power.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} ${verNumberComp} ${csudo} ./makeclient_power.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName} @@ -262,4 +266,3 @@ else cd ${script_dir}/tools ./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${dbName} fi - diff --git a/packaging/tools/install_arbi_pro.sh b/packaging/tools/install_arbi_pro.sh new file mode 100755 index 0000000000000000000000000000000000000000..11165dbdd8bdf6afb4659250499cf1d9184c2395 --- /dev/null +++ b/packaging/tools/install_arbi_pro.sh @@ -0,0 +1,293 @@ +#!/bin/bash +# +# This file is used to install database on linux systems. The operating system +# is required to use systemd to manage services at boot + +set -e +#set -x + +# -----------------------Variables definition--------------------- +script_dir=$(dirname $(readlink -f "$0")) + +bin_link_dir="/usr/bin" +#inc_link_dir="/usr/include" + +#install main path +install_main_dir="/usr/local/tarbitrator" + +# old bin dir +bin_dir="/usr/local/tarbitrator/bin" + +service_config_dir="/etc/systemd/system" + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +csudo="" +if command -v sudo > /dev/null; then + csudo="sudo" +fi + +update_flag=0 + +initd_mod=0 +service_mod=2 +if pidof systemd &> /dev/null; then + service_mod=0 +elif $(which service &> /dev/null); then + service_mod=1 + service_config_dir="/etc/init.d" + if $(which chkconfig &> /dev/null); then + initd_mod=1 + elif $(which insserv &> /dev/null); then + initd_mod=2 + elif $(which update-rc.d &> /dev/null); then + initd_mod=3 + else + service_mod=2 + fi +else + service_mod=2 +fi + + +# get the operating system type for using the corresponding init file +# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification +#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) +if [[ -e /etc/os-release ]]; then + osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) ||: +else + osinfo="" +fi +#echo "osinfo: ${osinfo}" +os_type=0 +if echo $osinfo | grep -qwi "ubuntu" ; then +# echo "This is ubuntu system" + os_type=1 +elif echo $osinfo | grep -qwi "debian" ; then +# echo "This is debian system" + os_type=1 +elif echo $osinfo | grep -qwi "Kylin" ; then +# echo "This is Kylin system" + os_type=1 +elif echo $osinfo | grep -qwi "centos" ; then +# echo "This is centos system" + os_type=2 +elif echo $osinfo | grep -qwi "fedora" ; then +# echo "This is fedora system" + os_type=2 +else + echo " osinfo: ${osinfo}" + echo " This is an officially unverified linux system," + echo " if there are any problems with the installation and operation, " + echo " please feel free to contact hanatech.com.cn for support." + os_type=1 +fi + +function kill_tarbitrator() { + pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + +function install_main_path() { + #create install main dir and all sub dir + ${csudo} rm -rf ${install_main_dir} || : + ${csudo} mkdir -p ${install_main_dir} + ${csudo} mkdir -p ${install_main_dir}/bin + #${csudo} mkdir -p ${install_main_dir}/include + ${csudo} mkdir -p ${install_main_dir}/init.d +} + +function install_bin() { + # Remove links + ${csudo} rm -f ${bin_link_dir}/rmtarbitrator || : + ${csudo} rm -f ${bin_link_dir}/tarbitrator || : + ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + + #Make link + [ -x ${install_main_dir}/bin/remove_arbi_prodb.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_arbi_prodb.sh ${bin_link_dir}/rmtarbitrator || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : +} + +function install_header() { + ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* + ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h +} + +function clean_service_on_sysvinit() { + #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" + #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : + + if pidof tarbitrator &> /dev/null; then + ${csudo} service tarbitratord stop || : + fi + + if ((${initd_mod}==1)); then + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} chkconfig --del tarbitratord || : + fi + elif ((${initd_mod}==2)); then + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} insserv -r tarbitratord || : + fi + elif ((${initd_mod}==3)); then + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} update-rc.d -f tarbitratord remove || : + fi + fi + + ${csudo} rm -f ${service_config_dir}/tarbitratord || : + + if $(which init &> /dev/null); then + ${csudo} init q || : + fi +} + +function install_service_on_sysvinit() { + clean_service_on_sysvinit + sleep 1 + + # Install prodbs service + + if ((${os_type}==1)); then + ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + elif ((${os_type}==2)); then + ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + fi + + if ((${initd_mod}==1)); then + ${csudo} chkconfig --add tarbitratord || : + ${csudo} chkconfig --level 2345 tarbitratord on || : + elif ((${initd_mod}==2)); then + ${csudo} insserv tarbitratord || : + ${csudo} insserv -d tarbitratord || : + elif ((${initd_mod}==3)); then + ${csudo} update-rc.d tarbitratord defaults || : + fi +} + +function clean_service_on_systemd() { + tarbitratord_service_config="${service_config_dir}/tarbitratord.service" + if systemctl is-active --quiet tarbitratord; then + echo "tarbitrator is running, stopping it..." + ${csudo} systemctl stop tarbitratord &> /dev/null || echo &> /dev/null + fi + ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + + ${csudo} rm -f ${tarbitratord_service_config} +} + +function install_service_on_systemd() { + clean_service_on_systemd + + tarbitratord_service_config="${service_config_dir}/tarbitratord.service" + + ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'Description=ProDB arbitrator service' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + ${csudo} systemctl enable tarbitratord +} + +function install_service() { + if ((${service_mod}==0)); then + install_service_on_systemd + elif ((${service_mod}==1)); then + install_service_on_sysvinit + else + # must manual stop taosd + kill_tarbitrator + fi +} + +function update_prodb() { + # Start to update + echo -e "${GREEN}Start to update ProDB's arbitrator ...${NC}" + # Stop the service if running + if pidof tarbitrator &> /dev/null; then + if ((${service_mod}==0)); then + ${csudo} systemctl stop tarbitratord || : + elif ((${service_mod}==1)); then + ${csudo} service tarbitratord stop || : + else + kill_tarbitrator + fi + sleep 1 + fi + + install_main_path + #install_header + install_bin + install_service + + echo + #echo -e "${GREEN_DARK}To configure ProDB ${NC}: edit /etc/taos/taos.cfg" + if ((${service_mod}==0)); then + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + elif ((${service_mod}==1)); then + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + else + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}" + fi + echo + echo -e "\033[44;32;1mProDB's arbitrator is updated successfully!${NC}" +} + +function install_prodb() { + # Start to install + echo -e "${GREEN}Start to install ProDB's arbitrator ...${NC}" + + install_main_path + #install_header + install_bin + install_service + echo + #echo -e "${GREEN_DARK}To configure ProDB ${NC}: edit /etc/taos/taos.cfg" + if ((${service_mod}==0)); then + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}" + elif ((${service_mod}==1)); then + echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}" + else + echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}" + fi + + echo -e "\033[44;32;1mProDB's arbitrator is installed successfully!${NC}" + echo +} + + +## ==============================Main program starts from here============================ +# Install server and client +if [ -x ${bin_dir}/tarbitrator ]; then + update_flag=1 + update_prodb +else + install_prodb +fi + diff --git a/packaging/tools/install_client_pro.sh b/packaging/tools/install_client_pro.sh new file mode 100755 index 0000000000000000000000000000000000000000..fff8ae31200669ee3ab918a873e33fc32ece37c8 --- /dev/null +++ b/packaging/tools/install_client_pro.sh @@ -0,0 +1,248 @@ +#!/bin/bash +# +# This file is used to install ProDB client on linux systems. The operating system +# is required to use systemd to manage services at boot + +set -e +#set -x + +# -----------------------Variables definition--------------------- + +osType=Linux +pagMode=full + +if [ "$osType" != "Darwin" ]; then + script_dir=$(dirname $(readlink -f "$0")) + # Dynamic directory + data_dir="/var/lib/ProDB" + log_dir="/var/log/ProDB" +else + script_dir=`dirname $0` + cd ${script_dir} + script_dir="$(pwd)" + data_dir="/var/lib/ProDB" + log_dir="~/ProDB/log" +fi + +log_link_dir="/usr/local/ProDB/log" + +cfg_install_dir="/etc/ProDB" + +if [ "$osType" != "Darwin" ]; then + bin_link_dir="/usr/bin" + lib_link_dir="/usr/lib" + lib64_link_dir="/usr/lib64" + inc_link_dir="/usr/include" +else + bin_link_dir="/usr/local/bin" + lib_link_dir="/usr/local/lib" + inc_link_dir="/usr/local/include" +fi + +#install main path +install_main_dir="/usr/local/ProDB" + +# old bin dir +bin_dir="/usr/local/ProDB/bin" + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +csudo="" +if command -v sudo > /dev/null; then + csudo="sudo" +fi + +update_flag=0 + +function kill_client() { + pid=$(ps -ef | grep "prodbc" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + +function install_main_path() { + #create install main dir and all sub dir + ${csudo} rm -rf ${install_main_dir} || : + ${csudo} mkdir -p ${install_main_dir} + ${csudo} mkdir -p ${install_main_dir}/cfg + ${csudo} mkdir -p ${install_main_dir}/bin + ${csudo} mkdir -p ${install_main_dir}/connector + ${csudo} mkdir -p ${install_main_dir}/driver + ${csudo} mkdir -p ${install_main_dir}/examples + ${csudo} mkdir -p ${install_main_dir}/include +} + +function install_bin() { + # Remove links + ${csudo} rm -f ${bin_link_dir}/prodbc || : + if [ "$osType" != "Darwin" ]; then + ${csudo} rm -f ${bin_link_dir}/prodemo || : + ${csudo} rm -f ${bin_link_dir}/prodump || : + fi + ${csudo} rm -f ${bin_link_dir}/rmprodb || : + ${csudo} rm -f ${bin_link_dir}/set_core || : + + ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + + #Make link + [ -x ${install_main_dir}/bin/prodbc ] && ${csudo} ln -s ${install_main_dir}/bin/prodbc ${bin_link_dir}/prodbc || : + if [ "$osType" != "Darwin" ]; then + [ -x ${install_main_dir}/bin/prodemo ] && ${csudo} ln -s ${install_main_dir}/bin/prodemo ${bin_link_dir}/prodemo || : + [ -x ${install_main_dir}/bin/prodump ] && ${csudo} ln -s ${install_main_dir}/bin/prodump ${bin_link_dir}/prodump || : + fi + [ -x ${install_main_dir}/bin/remove_client_prodb.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client_prodb.sh ${bin_link_dir}/rmprodb || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : +} + +function clean_lib() { + sudo rm -f /usr/lib/libtaos.* || : + sudo rm -rf ${lib_dir} || : +} + +function install_lib() { + # Remove links + ${csudo} rm -f ${lib_link_dir}/libtaos.* || : + ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + #${csudo} rm -rf ${v15_java_app_dir} || : + + ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + + if [ "$osType" != "Darwin" ]; then + ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + + if [ -d "${lib64_link_dir}" ]; then + ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + fi + else + ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib + ${csudo} ln -s ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib + fi + + ${csudo} ldconfig +} + +function install_header() { + ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* + ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h +} + +function install_config() { + #${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : + + if [ ! -f ${cfg_install_dir}/taos.cfg ]; then + ${csudo} mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} + ${csudo} chmod 644 ${cfg_install_dir}/* + fi + + ${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org + ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg +} + + +function install_log() { + ${csudo} rm -rf ${log_dir} || : + + if [ "$osType" != "Darwin" ]; then + ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + else + mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + fi + ${csudo} ln -s ${log_dir} ${install_main_dir}/log +} + +function install_connector() { + ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector +} + +function install_examples() { + if [ -d ${script_dir}/examples ]; then + ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + fi +} + +function update_prodb() { + # Start to update + if [ ! -e prodb.tar.gz ]; then + echo "File prodb.tar.gz does not exist" + exit 1 + fi + tar -zxf prodb.tar.gz + + echo -e "${GREEN}Start to update ProDB client...${NC}" + # Stop the client shell if running + if pidof prodbc &> /dev/null; then + kill_client + sleep 1 + fi + + install_main_path + + install_log + install_header + install_lib + if [ "$pagMode" != "lite" ]; then + install_connector + fi + install_examples + install_bin + install_config + + echo + echo -e "\033[44;32;1mProDB client is updated successfully!${NC}" + + rm -rf $(tar -tf prodb.tar.gz) +} + +function install_prodb() { + # Start to install + if [ ! -e prodb.tar.gz ]; then + echo "File prodb.tar.gz does not exist" + exit 1 + fi + tar -zxf prodb.tar.gz + + echo -e "${GREEN}Start to install ProDB client...${NC}" + + install_main_path + install_log + install_header + install_lib + if [ "$pagMode" != "lite" ]; then + install_connector + fi + install_examples + install_bin + install_config + + echo + echo -e "\033[44;32;1mProDB client is installed successfully!${NC}" + + rm -rf $(tar -tf prodb.tar.gz) +} + + +## ==============================Main program starts from here============================ +# Install or updata client and client +# if server is already install, don't install client + if [ -e ${bin_dir}/prodbs ]; then + echo -e "\033[44;32;1mThere are already installed ProDB server, so don't need install client!${NC}" + exit 0 + fi + + if [ -x ${bin_dir}/prodbc ]; then + update_flag=1 + update_prodb + else + install_prodb + fi diff --git a/packaging/tools/install_pro.sh b/packaging/tools/install_pro.sh new file mode 100755 index 0000000000000000000000000000000000000000..564561441646d4bd27f22c5abd9250a9c3377002 --- /dev/null +++ b/packaging/tools/install_pro.sh @@ -0,0 +1,948 @@ +#!/bin/bash +# +# This file is used to install database on linux systems. The operating system +# is required to use systemd to manage services at boot + +set -e +#set -x + +verMode=edge +pagMode=full + +iplist="" +serverFqdn="" +# -----------------------Variables definition--------------------- +script_dir=$(dirname $(readlink -f "$0")) +# Dynamic directory +data_dir="/var/lib/ProDB" +log_dir="/var/log/ProDB" + +data_link_dir="/usr/local/ProDB/data" +log_link_dir="/usr/local/ProDB/log" + +cfg_install_dir="/etc/ProDB" + +bin_link_dir="/usr/bin" +lib_link_dir="/usr/lib" +lib64_link_dir="/usr/lib64" +inc_link_dir="/usr/include" + +#install main path +install_main_dir="/usr/local/ProDB" + +# old bin dir +bin_dir="/usr/local/ProDB/bin" + +service_config_dir="/etc/systemd/system" +nginx_port=6060 +nginx_dir="/usr/local/nginxd" + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +csudo="" +if command -v sudo > /dev/null; then + csudo="sudo" +fi + +update_flag=0 + +initd_mod=0 +service_mod=2 +if pidof systemd &> /dev/null; then + service_mod=0 +elif $(which service &> /dev/null); then + service_mod=1 + service_config_dir="/etc/init.d" + if $(which chkconfig &> /dev/null); then + initd_mod=1 + elif $(which insserv &> /dev/null); then + initd_mod=2 + elif $(which update-rc.d &> /dev/null); then + initd_mod=3 + else + service_mod=2 + fi +else + service_mod=2 +fi + + +# get the operating system type for using the corresponding init file +# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification +#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) +if [[ -e /etc/os-release ]]; then + osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) ||: +else + osinfo="" +fi +#echo "osinfo: ${osinfo}" +os_type=0 +if echo $osinfo | grep -qwi "ubuntu" ; then +# echo "This is ubuntu system" + os_type=1 +elif echo $osinfo | grep -qwi "debian" ; then +# echo "This is debian system" + os_type=1 +elif echo $osinfo | grep -qwi "Kylin" ; then +# echo "This is Kylin system" + os_type=1 +elif echo $osinfo | grep -qwi "centos" ; then +# echo "This is centos system" + os_type=2 +elif echo $osinfo | grep -qwi "fedora" ; then +# echo "This is fedora system" + os_type=2 +else + echo " osinfo: ${osinfo}" + echo " This is an officially unverified linux system," + echo " if there are any problems with the installation and operation, " + echo " please feel free to contact hanatech.com.cn for support." + os_type=1 +fi + + +# ============================= get input parameters ================================================= + +# install.sh -v [server | client] -e [yes | no] -i [systemd | service | ...] + +# set parameters by default value +interactiveFqdn=yes # [yes | no] +verType=server # [server | client] +initType=systemd # [systemd | service | ...] + +while getopts "hv:e:i:" arg +do + case $arg in + e) + #echo "interactiveFqdn=$OPTARG" + interactiveFqdn=$( echo $OPTARG ) + ;; + v) + #echo "verType=$OPTARG" + verType=$(echo $OPTARG) + ;; + i) + #echo "initType=$OPTARG" + initType=$(echo $OPTARG) + ;; + h) + echo "Usage: `basename $0` -v [server | client] -e [yes | no]" + exit 0 + ;; + ?) #unknow option + echo "unkonw argument" + exit 1 + ;; + esac +done + +function kill_process() { + pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + +function install_main_path() { + #create install main dir and all sub dir + ${csudo} rm -rf ${install_main_dir} || : + ${csudo} mkdir -p ${install_main_dir} + ${csudo} mkdir -p ${install_main_dir}/cfg + ${csudo} mkdir -p ${install_main_dir}/bin + ${csudo} mkdir -p ${install_main_dir}/connector + ${csudo} mkdir -p ${install_main_dir}/driver + ${csudo} mkdir -p ${install_main_dir}/examples + ${csudo} mkdir -p ${install_main_dir}/include + ${csudo} mkdir -p ${install_main_dir}/init.d + if [ "$verMode" == "cluster" ]; then + ${csudo} mkdir -p ${nginx_dir} + fi +} + +function install_bin() { + # Remove links + ${csudo} rm -f ${bin_link_dir}/prodbc || : + ${csudo} rm -f ${bin_link_dir}/prodbs || : + ${csudo} rm -f ${bin_link_dir}/prodemo || : + ${csudo} rm -f ${bin_link_dir}/rmprodb || : + ${csudo} rm -f ${bin_link_dir}/tarbitrator || : + ${csudo} rm -f ${bin_link_dir}/set_core || : + + ${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/* + + #Make link + [ -x ${install_main_dir}/bin/prodbc ] && ${csudo} ln -s ${install_main_dir}/bin/prodbc ${bin_link_dir}/prodbc || : + [ -x ${install_main_dir}/bin/prodbs ] && ${csudo} ln -s ${install_main_dir}/bin/prodbs ${bin_link_dir}/prodbs || : + [ -x ${install_main_dir}/bin/prodemo ] && ${csudo} ln -s ${install_main_dir}/bin/prodemo ${bin_link_dir}/prodemo || : + [ -x ${install_main_dir}/bin/remove_pro.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_pro.sh ${bin_link_dir}/rmprodb || : + [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : + + if [ "$verMode" == "cluster" ]; then + ${csudo} cp -r ${script_dir}/nginxd/* ${nginx_dir} && ${csudo} chmod 0555 ${nginx_dir}/* + ${csudo} mkdir -p ${nginx_dir}/logs + ${csudo} chmod 777 ${nginx_dir}/sbin/nginx + fi +} + +function install_lib() { + # Remove links + ${csudo} rm -f ${lib_link_dir}/libtaos.* || : + ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + + ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + + if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then + ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + fi + + if [ "$osType" != "Darwin" ]; then + ${csudo} ldconfig + else + ${csudo} update_dyld_shared_cache + fi +} + +function install_header() { + ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* + ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h +} + +function install_jemalloc() { + jemalloc_dir=${script_dir}/jemalloc + + if [ -d ${jemalloc_dir} ]; then + ${csudo} /usr/bin/install -c -d /usr/local/bin + + if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then + ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + fi + if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then + ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + fi + if [ -f ${jemalloc_dir}/bin/jeprof ]; then + ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + fi + if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then + ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + fi + if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then + ${csudo} /usr/bin/install -c -d /usr/local/lib + ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo} /usr/bin/install -c -d /usr/local/lib + if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then + ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + fi + if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then + ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + fi + if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then + ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + fi + fi + if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then + ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + fi + if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then + ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + fi + + if [ -d /etc/ld.so.conf.d ]; then + ${csudo} echo "/usr/local/lib" > /etc/ld.so.conf.d/jemalloc.conf + ${csudo} ldconfig + else + echo "/etc/ld.so.conf.d not found!" + fi + fi +} + +function add_newHostname_to_hosts() { + localIp="127.0.0.1" + OLD_IFS="$IFS" + IFS=" " + iphost=$(cat /etc/hosts | grep $1 | awk '{print $1}') + arr=($iphost) + IFS="$OLD_IFS" + for s in ${arr[@]} + do + if [[ "$s" == "$localIp" ]]; then + return + fi + done + ${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||: +} + +function set_hostname() { + echo -e -n "${GREEN}Please enter one hostname(must not be 'localhost')${NC}:" + read newHostname + while true; do + if [[ ! -z "$newHostname" && "$newHostname" != "localhost" ]]; then + break + else + read -p "Please enter one hostname(must not be 'localhost'):" newHostname + fi + done + + ${csudo} hostname $newHostname ||: + retval=`echo $?` + if [[ $retval != 0 ]]; then + echo + echo "set hostname fail!" + return + fi + + #ubuntu/centos /etc/hostname + if [[ -e /etc/hostname ]]; then + ${csudo} echo $newHostname > /etc/hostname ||: + fi + + #debian: #HOSTNAME=yourname + if [[ -e /etc/sysconfig/network ]]; then + ${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||: + fi + + ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg + serverFqdn=$newHostname + + if [[ -e /etc/hosts ]]; then + add_newHostname_to_hosts $newHostname + fi +} + +function is_correct_ipaddr() { + newIp=$1 + OLD_IFS="$IFS" + IFS=" " + arr=($iplist) + IFS="$OLD_IFS" + for s in ${arr[@]} + do + if [[ "$s" == "$newIp" ]]; then + return 0 + fi + done + + return 1 +} + +function set_ipAsFqdn() { + iplist=$(ip address |grep inet |grep -v inet6 |grep -v 127.0.0.1 |awk '{print $2}' |awk -F "/" '{print $1}') ||: + if [ -z "$iplist" ]; then + iplist=$(ifconfig |grep inet |grep -v inet6 |grep -v 127.0.0.1 |awk '{print $2}' |awk -F ":" '{print $2}') ||: + fi + + if [ -z "$iplist" ]; then + echo + echo -e -n "${GREEN}Unable to get local ip, use 127.0.0.1${NC}" + localFqdn="127.0.0.1" + # Write the local FQDN to configuration file + ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + serverFqdn=$localFqdn + echo + return + fi + + echo -e -n "${GREEN}Please choose an IP from local IP list${NC}:" + echo + echo -e -n "${GREEN}$iplist${NC}" + echo + echo + echo -e -n "${GREEN}Notes: if IP is used as the node name, data can NOT be migrated to other machine directly${NC}:" + read localFqdn + while true; do + if [ ! -z "$localFqdn" ]; then + # Check if correct ip address + is_correct_ipaddr $localFqdn + retval=`echo $?` + if [[ $retval != 0 ]]; then + read -p "Please choose an IP from local IP list:" localFqdn + else + # Write the local FQDN to configuration file + ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg + serverFqdn=$localFqdn + break + fi + else + read -p "Please choose an IP from local IP list:" localFqdn + fi + done +} + +function local_fqdn_check() { + #serverFqdn=$(hostname) + echo + echo -e -n "System hostname is: ${GREEN}$serverFqdn${NC}" + echo + if [[ "$serverFqdn" == "" ]] || [[ "$serverFqdn" == "localhost" ]]; then + echo -e -n "${GREEN}It is strongly recommended to configure a hostname for this machine ${NC}" + echo + + while true + do + read -r -p "Set hostname now? [Y/n] " input + if [ ! -n "$input" ]; then + set_hostname + break + else + case $input in + [yY][eE][sS]|[yY]) + set_hostname + break + ;; + + [nN][oO]|[nN]) + set_ipAsFqdn + break + ;; + + *) + echo "Invalid input..." + ;; + esac + fi + done + fi +} + +function install_config() { + if [ ! -f ${cfg_install_dir}/taos.cfg ]; then + ${csudo} mkdir -p ${cfg_install_dir} + [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} + ${csudo} chmod 644 ${cfg_install_dir}/* + fi + + ${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org + ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg + + [ ! -z $1 ] && return 0 || : # only install client + + if ((${update_flag}==1)); then + return 0 + fi + + if [ "$interactiveFqdn" == "no" ]; then + return 0 + fi + + local_fqdn_check + + #FQDN_FORMAT="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" + #FQDN_FORMAT="(:[1-6][0-9][0-9][0-9][0-9]$)" + #PORT_FORMAT="(/[1-6][0-9][0-9][0-9][0-9]?/)" + #FQDN_PATTERN=":[0-9]{1,5}$" + + # first full-qualified domain name (FQDN) for ProDB cluster system + echo + echo -e -n "${GREEN}Enter FQDN:port (like h1.hanatech.com.cn:6030) of an existing ProDB cluster node to join${NC}" + echo + echo -e -n "${GREEN}OR leave it blank to build one${NC}:" + read firstEp + while true; do + if [ ! -z "$firstEp" ]; then + # check the format of the firstEp + #if [[ $firstEp == $FQDN_PATTERN ]]; then + # Write the first FQDN to configuration file + ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg + break + #else + # read -p "Please enter the correct FQDN:port: " firstEp + #fi + else + break + fi + done +} + + +function install_log() { + ${csudo} rm -rf ${log_dir} || : + ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + + ${csudo} ln -s ${log_dir} ${install_main_dir}/log +} + +function install_data() { + ${csudo} mkdir -p ${data_dir} + + ${csudo} ln -s ${data_dir} ${install_main_dir}/data +} + +function install_connector() { + ${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector +} + +function install_examples() { + if [ -d ${script_dir}/examples ]; then + ${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + fi +} + +function clean_service_on_sysvinit() { + if pidof prodbs &> /dev/null; then + ${csudo} service prodbs stop || : + fi + + if pidof tarbitrator &> /dev/null; then + ${csudo} service tarbitratord stop || : + fi + + if ((${initd_mod}==1)); then + if [ -e ${service_config_dir}/prodbs ]; then + ${csudo} chkconfig --del prodbs || : + fi + + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} chkconfig --del tarbitratord || : + fi + elif ((${initd_mod}==2)); then + if [ -e ${service_config_dir}/prodbs ]; then + ${csudo} insserv -r prodbs || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} insserv -r tarbitratord || : + fi + elif ((${initd_mod}==3)); then + if [ -e ${service_config_dir}/prodbs ]; then + ${csudo} update-rc.d -f prodbs remove || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} update-rc.d -f tarbitratord remove || : + fi + fi + + ${csudo} rm -f ${service_config_dir}/prodbs || : + ${csudo} rm -f ${service_config_dir}/tarbitratord || : + + if $(which init &> /dev/null); then + ${csudo} init q || : + fi +} + +function install_service_on_sysvinit() { + clean_service_on_sysvinit + sleep 1 + + # Install prodbs service + + if ((${os_type}==1)); then + ${csudo} cp -f ${script_dir}/init.d/prodbs.deb ${install_main_dir}/init.d/prodbs + ${csudo} cp ${script_dir}/init.d/prodbs.deb ${service_config_dir}/prodbs && ${csudo} chmod a+x ${service_config_dir}/prodbs + ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord + ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + elif ((${os_type}==2)); then + ${csudo} cp -f ${script_dir}/init.d/prodbs.rpm ${install_main_dir}/init.d/prodbs + ${csudo} cp ${script_dir}/init.d/prodbs.rpm ${service_config_dir}/prodbs && ${csudo} chmod a+x ${service_config_dir}/prodbs + ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord + ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + fi + + if ((${initd_mod}==1)); then + ${csudo} chkconfig --add prodbs || : + ${csudo} chkconfig --level 2345 prodbs on || : + ${csudo} chkconfig --add tarbitratord || : + ${csudo} chkconfig --level 2345 tarbitratord on || : + elif ((${initd_mod}==2)); then + ${csudo} insserv prodbs || : + ${csudo} insserv -d prodbs || : + ${csudo} insserv tarbitratord || : + ${csudo} insserv -d tarbitratord || : + elif ((${initd_mod}==3)); then + ${csudo} update-rc.d prodbs defaults || : + ${csudo} update-rc.d tarbitratord defaults || : + fi +} + +function clean_service_on_systemd() { + prodbs_service_config="${service_config_dir}/prodbs.service" + if systemctl is-active --quiet prodbs; then + echo "ProDB is running, stopping it..." + ${csudo} systemctl stop prodbs &> /dev/null || echo &> /dev/null + fi + ${csudo} systemctl disable prodbs &> /dev/null || echo &> /dev/null + ${csudo} rm -f ${prodbs_service_config} + + tarbitratord_service_config="${service_config_dir}/tarbitratord.service" + if systemctl is-active --quiet tarbitratord; then + echo "tarbitrator is running, stopping it..." + ${csudo} systemctl stop tarbitratord &> /dev/null || echo &> /dev/null + fi + ${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null + ${csudo} rm -f ${tarbitratord_service_config} + + if [ "$verMode" == "cluster" ]; then + nginx_service_config="${service_config_dir}/nginxd.service" + if systemctl is-active --quiet nginxd; then + echo "Nginx for ProDB is running, stopping it..." + ${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null + fi + ${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null + ${csudo} rm -f ${nginx_service_config} + fi +} + +function install_service_on_systemd() { + clean_service_on_systemd + + prodbs_service_config="${service_config_dir}/prodbs.service" + ${csudo} bash -c "echo '[Unit]' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'Description=ProDB server service' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'After=network-online.target' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'Wants=network-online.target' >> ${prodbs_service_config}" + ${csudo} bash -c "echo >> ${prodbs_service_config}" + ${csudo} bash -c "echo '[Service]' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'Type=simple' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'ExecStart=/usr/bin/prodbs' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'ExecStartPre=/usr/local/ProDB/bin/startPre.sh' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'StandardOutput=null' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'Restart=always' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${prodbs_service_config}" + ${csudo} bash -c "echo >> ${prodbs_service_config}" + ${csudo} bash -c "echo '[Install]' >> ${prodbs_service_config}" + ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${prodbs_service_config}" + ${csudo} systemctl enable prodbs + + tarbitratord_service_config="${service_config_dir}/tarbitratord.service" + ${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'Description=ProDB arbitrator service' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" + ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" + #${csudo} systemctl enable tarbitratord + + if [ "$verMode" == "cluster" ]; then + nginx_service_config="${service_config_dir}/nginxd.service" + ${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'Description=Nginx For PowrDB Service' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'After=network-online.target' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'Wants=network-online.target' >> ${nginx_service_config}" + ${csudo} bash -c "echo >> ${nginx_service_config}" + ${csudo} bash -c "echo '[Service]' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'Type=forking' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'TimeoutStopSec=1000000s' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'LimitCORE=infinity' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'StandardOutput=null' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'Restart=always' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'StartLimitBurst=3' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${nginx_service_config}" + ${csudo} bash -c "echo >> ${nginx_service_config}" + ${csudo} bash -c "echo '[Install]' >> ${nginx_service_config}" + ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${nginx_service_config}" + if ! ${csudo} systemctl enable nginxd &> /dev/null; then + ${csudo} systemctl daemon-reexec + ${csudo} systemctl enable nginxd + fi + ${csudo} systemctl start nginxd + fi +} + +function install_service() { + if ((${service_mod}==0)); then + install_service_on_systemd + elif ((${service_mod}==1)); then + install_service_on_sysvinit + else + # must manual stop prodbs + kill_process prodbs + fi +} + +vercomp () { + if [[ $1 == $2 ]]; then + return 0 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do + ver1[i]=0 + done + + for ((i=0; i<${#ver1[@]}; i++)); do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + return 2 + fi + done + return 0 +} + +function is_version_compatible() { + curr_version=`ls ${script_dir}/driver/libtaos.so* |cut -d '.' -f 3-6` + + if [ -f ${script_dir}/driver/vercomp.txt ]; then + min_compatible_version=`cat ${script_dir}/driver/vercomp.txt` + else + min_compatible_version=$(${script_dir}/bin/prodbs -V | head -1 | cut -d ' ' -f 5) + fi + + vercomp $curr_version $min_compatible_version + case $? in + 0) return 0;; + 1) return 0;; + 2) return 1;; + esac +} + +function update_prodb() { + # Start to update + if [ ! -e prodb.tar.gz ]; then + echo "File prodb.tar.gz does not exist" + exit 1 + fi + tar -zxf prodb.tar.gz + install_jemalloc + + # Check if version compatible + if ! is_version_compatible; then + echo -e "${RED}Version incompatible${NC}" + return 1 + fi + + echo -e "${GREEN}Start to update ProDB...${NC}" + # Stop the service if running + if pidof prodbs &> /dev/null; then + if ((${service_mod}==0)); then + ${csudo} systemctl stop prodbs || : + elif ((${service_mod}==1)); then + ${csudo} service prodbs stop || : + else + kill_process prodbs + fi + sleep 1 + fi + if [ "$verMode" == "cluster" ]; then + if pidof nginx &> /dev/null; then + if ((${service_mod}==0)); then + ${csudo} systemctl stop nginxd || : + elif ((${service_mod}==1)); then + ${csudo} service nginxd stop || : + else + kill_process nginx + fi + sleep 1 + fi + fi + + install_main_path + + install_log + install_header + install_lib + if [ "$pagMode" != "lite" ]; then + install_connector + fi + install_examples + if [ -z $1 ]; then + install_bin + install_service + install_config + + openresty_work=false + if [ "$verMode" == "cluster" ]; then + # Check if openresty is installed + # Check if nginx is installed successfully + if type curl &> /dev/null; then + if curl -sSf http://127.0.0.1:${nginx_port} &> /dev/null; then + echo -e "\033[44;32;1mNginx for ProDB is updated successfully!${NC}" + openresty_work=true + else + echo -e "\033[44;31;5mNginx for ProDB does not work! Please try again!\033[0m" + fi + fi + fi + + #echo + #echo -e "\033[44;32;1mProDB is updated successfully!${NC}" + echo + echo -e "${GREEN_DARK}To configure ProDB ${NC}: edit /etc/ProDB/taos.cfg" + if ((${service_mod}==0)); then + echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo} systemctl start prodbs${NC}" + elif ((${service_mod}==1)); then + echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo} service prodbs start${NC}" + else + echo -e "${GREEN_DARK}To start ProDB ${NC}: ./prodbs${NC}" + fi + + if [ ${openresty_work} = 'true' ]; then + echo -e "${GREEN_DARK}To access ProDB ${NC}: use ${GREEN_UNDERLINE}prodbc -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${nginx_port}${NC}" + else + echo -e "${GREEN_DARK}To access ProDB ${NC}: use ${GREEN_UNDERLINE}prodbc -h $serverFqdn${NC} in shell${NC}" + fi + + echo + echo -e "\033[44;32;1mProDB is updated successfully!${NC}" + else + install_bin + install_config + + echo + echo -e "\033[44;32;1mProDB client is updated successfully!${NC}" + fi + + rm -rf $(tar -tf prodb.tar.gz) +} + +function install_prodb() { + # Start to install + if [ ! -e prodb.tar.gz ]; then + echo "File prodb.tar.gz does not exist" + exit 1 + fi + tar -zxf prodb.tar.gz + + echo -e "${GREEN}Start to install ProDB...${NC}" + + install_main_path + + if [ -z $1 ]; then + install_data + fi + + install_log + install_header + install_lib + install_jemalloc + if [ "$pagMode" != "lite" ]; then + install_connector + fi + install_examples + + if [ -z $1 ]; then # install service and client + # For installing new + install_bin + install_service + + openresty_work=false + if [ "$verMode" == "cluster" ]; then + # Check if nginx is installed successfully + if type curl &> /dev/null; then + if curl -sSf http://127.0.0.1:${nginx_port} &> /dev/null; then + echo -e "\033[44;32;1mNginx for ProDB is installed successfully!${NC}" + openresty_work=true + else + echo -e "\033[44;31;5mNginx for ProDB does not work! Please try again!\033[0m" + fi + fi + fi + + install_config + + # Ask if to start the service + #echo + #echo -e "\033[44;32;1mProDB is installed successfully!${NC}" + echo + echo -e "${GREEN_DARK}To configure ProDB ${NC}: edit /etc/ProDB/taos.cfg" + if ((${service_mod}==0)); then + echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo} systemctl start prodbs${NC}" + elif ((${service_mod}==1)); then + echo -e "${GREEN_DARK}To start ProDB ${NC}: ${csudo} service prodbs start${NC}" + else + echo -e "${GREEN_DARK}To start ProDB ${NC}: prodbs${NC}" + fi + + if [ ! -z "$firstEp" ]; then + tmpFqdn=${firstEp%%:*} + substr=":" + if [[ $firstEp =~ $substr ]];then + tmpPort=${firstEp#*:} + else + tmpPort="" + fi + if [[ "$tmpPort" != "" ]];then + echo -e "${GREEN_DARK}To access ProDB ${NC}: prodbc -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}" + else + echo -e "${GREEN_DARK}To access ProDB ${NC}: prodbc -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}" + fi + echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}" + echo + elif [ ! -z "$serverFqdn" ]; then + echo -e "${GREEN_DARK}To access ProDB ${NC}: prodbc -h $serverFqdn${GREEN_DARK} to login into ProDB server${NC}" + echo + fi + echo -e "\033[44;32;1mProDB is installed successfully!${NC}" + echo + else # Only install client + install_bin + install_config + + echo + echo -e "\033[44;32;1mProDB client is installed successfully!${NC}" + fi + + rm -rf $(tar -tf prodb.tar.gz) +} + + +## ==============================Main program starts from here============================ +serverFqdn=$(hostname) +if [ "$verType" == "server" ]; then + # Install server and client + if [ -x ${bin_dir}/prodbs ]; then + update_flag=1 + update_prodb + else + install_prodb + fi +elif [ "$verType" == "client" ]; then + interactiveFqdn=no + # Only install client + if [ -x ${bin_dir}/prodbc ]; then + update_flag=1 + update_prodb client + else + install_prodb client + fi +else + echo "please input correct verType" +fi diff --git a/packaging/tools/makearbi_pro.sh b/packaging/tools/makearbi_pro.sh new file mode 100755 index 0000000000000000000000000000000000000000..6ce3765e44acc408ced9730c54b793338eb37b38 --- /dev/null +++ b/packaging/tools/makearbi_pro.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# +# Generate arbitrator's tar.gz setup package for all os system + +set -e +#set -x + +curr_dir=$(pwd) +compile_dir=$1 +version=$2 +build_time=$3 +cpuType=$4 +osType=$5 +verMode=$6 +verType=$7 +pagMode=$8 + +script_dir="$(dirname $(readlink -f $0))" +top_dir="$(readlink -f ${script_dir}/../..)" + +# create compressed install file. +build_dir="${compile_dir}/build" +code_dir="${top_dir}/src" +release_dir="${top_dir}/release" + +#package_name='linux' +if [ "$verMode" == "cluster" ]; then + install_dir="${release_dir}/ProDB-enterprise-arbitrator-${version}" +else + install_dir="${release_dir}/ProDB-arbitrator-${version}" +fi + +# Directories and files. +bin_files="${build_dir}/bin/tarbitrator ${script_dir}/remove_arbi_pro.sh" +install_files="${script_dir}/install_arbi_pro.sh" + +#header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h" +init_file_tarbitrator_deb=${script_dir}/../deb/tarbitratord +init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord + +# make directories. +mkdir -p ${install_dir} && cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install_arbi_pro.sh || : +#mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc || : +mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* || : +mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || : +mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || : + +cd ${release_dir} + +if [ "$verMode" == "cluster" ]; then + pkg_name=${install_dir}-${osType}-${cpuType} +elif [ "$verMode" == "edge" ]; then + pkg_name=${install_dir}-${osType}-${cpuType} +else + echo "unknow verMode, nor cluster or edge" + exit 1 +fi + +if [ "$verType" == "beta" ]; then + pkg_name=${pkg_name}-${verType} +elif [ "$verType" == "stable" ]; then + pkg_name=${pkg_name} +else + echo "unknow verType, nor stabel or beta" + exit 1 +fi + +tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : +exitcode=$? +if [ "$exitcode" != "0" ]; then + echo "tar ${pkg_name}.tar.gz error !!!" + exit $exitcode +fi + +cd ${curr_dir} diff --git a/packaging/tools/makeclient_pro.sh b/packaging/tools/makeclient_pro.sh new file mode 100755 index 0000000000000000000000000000000000000000..599c91fbf082955887c677b750aa12f946c0890b --- /dev/null +++ b/packaging/tools/makeclient_pro.sh @@ -0,0 +1,225 @@ +#!/bin/bash +# +# Generate tar.gz package for linux client in all os system +set -e +#set -x + +curr_dir=$(pwd) +compile_dir=$1 +version=$2 +build_time=$3 +cpuType=$4 +osType=$5 +verMode=$6 +verType=$7 +pagMode=$8 + +if [ "$osType" != "Darwin" ]; then + script_dir="$(dirname $(readlink -f $0))" + top_dir="$(readlink -f ${script_dir}/../..)" +else + script_dir=`dirname $0` + cd ${script_dir} + script_dir="$(pwd)" + top_dir=${script_dir}/../.. +fi + +# create compressed install file. +build_dir="${compile_dir}/build" +code_dir="${top_dir}/src" +release_dir="${top_dir}/release" + +#package_name='linux' + +if [ "$verMode" == "cluster" ]; then + install_dir="${release_dir}/ProDB-enterprise-client-${version}" +else + install_dir="${release_dir}/ProDB-client-${version}" +fi + +# Directories and files. + +if [ "$osType" != "Darwin" ]; then + lib_files="${build_dir}/lib/libtaos.so.${version}" +else + bin_files="${build_dir}/bin/taos ${script_dir}/remove_client_pro.sh" + lib_files="${build_dir}/lib/libtaos.${version}.dylib" +fi + +header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h" +if [ "$verMode" == "cluster" ]; then + cfg_dir="${top_dir}/../enterprise/packaging/cfg" +else + cfg_dir="${top_dir}/packaging/cfg" +fi + +install_files="${script_dir}/install_client_pro.sh" + +# make directories. +mkdir -p ${install_dir} +mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc +mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg + +sed -i '/dataDir/ {s/taos/ProDB/g}' ${install_dir}/cfg/taos.cfg +sed -i '/logDir/ {s/taos/ProDB/g}' ${install_dir}/cfg/taos.cfg +sed -i "s/TDengine/ProDB/g" ${install_dir}/cfg/taos.cfg + +mkdir -p ${install_dir}/bin +if [ "$osType" != "Darwin" ]; then + if [ "$pagMode" == "lite" ]; then + strip ${build_dir}/bin/taos + cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc + cp ${script_dir}/remove_pro.sh ${install_dir}/bin + else + cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc + cp ${script_dir}/remove_pro.sh ${install_dir}/bin + cp ${build_dir}/bin/taosdemo ${install_dir}/bin/prodemo + cp ${build_dir}/bin/taosdump ${install_dir}/bin/prodump + cp ${script_dir}/set_core.sh ${install_dir}/bin + cp ${script_dir}/get_client.sh ${install_dir}/bin + cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin + fi +else + cp ${bin_files} ${install_dir}/bin +fi +chmod a+x ${install_dir}/bin/* || : + +if [ -f ${build_dir}/bin/jemalloc-config ]; then + mkdir -p ${install_dir}/jemalloc/{bin,lib,lib/pkgconfig,include/jemalloc,share/doc/jemalloc,share/man/man3} + cp ${build_dir}/bin/jemalloc-config ${install_dir}/jemalloc/bin + if [ -f ${build_dir}/bin/jemalloc.sh ]; then + cp ${build_dir}/bin/jemalloc.sh ${install_dir}/jemalloc/bin + fi + if [ -f ${build_dir}/bin/jeprof ]; then + cp ${build_dir}/bin/jeprof ${install_dir}/jemalloc/bin + fi + if [ -f ${build_dir}/include/jemalloc/jemalloc.h ]; then + cp ${build_dir}/include/jemalloc/jemalloc.h ${install_dir}/jemalloc/include/jemalloc + fi + if [ -f ${build_dir}/lib/libjemalloc.so.2 ]; then + cp ${build_dir}/lib/libjemalloc.so.2 ${install_dir}/jemalloc/lib + ln -sf libjemalloc.so.2 ${install_dir}/jemalloc/lib/libjemalloc.so + fi + if [ -f ${build_dir}/lib/libjemalloc.a ]; then + cp ${build_dir}/lib/libjemalloc.a ${install_dir}/jemalloc/lib + fi + if [ -f ${build_dir}/lib/libjemalloc_pic.a ]; then + cp ${build_dir}/lib/libjemalloc_pic.a ${install_dir}/jemalloc/lib + fi + if [ -f ${build_dir}/lib/pkgconfig/jemalloc.pc ]; then + cp ${build_dir}/lib/pkgconfig/jemalloc.pc ${install_dir}/jemalloc/lib/pkgconfig + fi + if [ -f ${build_dir}/share/doc/jemalloc/jemalloc.html ]; then + cp ${build_dir}/share/doc/jemalloc/jemalloc.html ${install_dir}/jemalloc/share/doc/jemalloc + fi + if [ -f ${build_dir}/share/man/man3/jemalloc.3 ]; then + cp ${build_dir}/share/man/man3/jemalloc.3 ${install_dir}/jemalloc/share/man/man3 + fi +fi + +cd ${install_dir} + +if [ "$osType" != "Darwin" ]; then + tar -zcv -f prodb.tar.gz * --remove-files || : +else + tar -zcv -f prodb.tar.gz * || : + mv prodb.tar.gz .. + rm -rf ./* + mv ../prodb.tar.gz . +fi + +cd ${curr_dir} +cp ${install_files} ${install_dir} +if [ "$osType" == "Darwin" ]; then + sed 's/osType=Linux/osType=Darwin/g' ${install_dir}/install_client_pro.sh >> install_client_prodb_temp.sh + mv install_client_prodb_temp.sh ${install_dir}/install_client_pro.sh +fi +if [ "$pagMode" == "lite" ]; then + sed 's/pagMode=full/pagMode=lite/g' ${install_dir}/install_client_pro.sh >> install_client_prodb_temp.sh + mv install_client_prodb_temp.sh ${install_dir}/install_client_pro.sh +fi +chmod a+x ${install_dir}/install_client_pro.sh + +# Copy example code +mkdir -p ${install_dir}/examples +examples_dir="${top_dir}/tests/examples" +cp -r ${examples_dir}/c ${install_dir}/examples +sed -i '/passwd/ {s/taosdata/prodb/g}' ${install_dir}/examples/c/*.c +sed -i '/root/ {s/taosdata/prodb/g}' ${install_dir}/examples/c/*.c + +if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then + cp -r ${examples_dir}/JDBC ${install_dir}/examples + cp -r ${examples_dir}/matlab ${install_dir}/examples + mv ${install_dir}/examples/matlab/TDengineDemo.m ${install_dir}/examples/matlab/ProDBDemo.m + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/examples/matlab/ProDBDemo.m + cp -r ${examples_dir}/python ${install_dir}/examples + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/examples/python/read_example.py + cp -r ${examples_dir}/R ${install_dir}/examples + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/examples/R/command.txt + cp -r ${examples_dir}/go ${install_dir}/examples + mv ${install_dir}/examples/go/taosdemo.go ${install_dir}/examples/go/prodemo.go + sed -i '/root/ {s/taosdata/prodb/g}' ${install_dir}/examples/go/prodemo.go +fi +# Copy driver +mkdir -p ${install_dir}/driver +cp ${lib_files} ${install_dir}/driver + +# Copy connector +connector_dir="${code_dir}/connector" +mkdir -p ${install_dir}/connector + +if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then + if [ "$osType" != "Darwin" ]; then + cp ${build_dir}/lib/*.jar ${install_dir}/connector ||: + fi + if [ -d "${connector_dir}/grafanaplugin/dist" ]; then + cp -r ${connector_dir}/grafanaplugin/dist ${install_dir}/connector/grafanaplugin + else + echo "WARNING: grafanaplugin bunlded dir not found, please check if want to use it!" + fi + if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then + cp -r ${connector_dir}/go ${install_dir}/connector + else + echo "WARNING: go connector not found, please check if want to use it!" + fi + cp -r ${connector_dir}/python ${install_dir}/connector + mv ${install_dir}/connector/python/taos ${install_dir}/connector/python/prodb + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/connector/python/prodb/cinterface.py + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/connector/python/prodb/subscription.py + sed -i '/self._password/ {s/taosdata/prodb/g}' ${install_dir}/connector/python/prodb/connection.py +fi + +cd ${release_dir} + +if [ "$verMode" == "cluster" ]; then + pkg_name=${install_dir}-${osType}-${cpuType} +elif [ "$verMode" == "edge" ]; then + pkg_name=${install_dir}-${osType}-${cpuType} +else + echo "unknow verMode, nor cluster or edge" + exit 1 +fi + +if [ "$pagMode" == "lite" ]; then + pkg_name=${pkg_name}-Lite +fi + +if [ "$verType" == "beta" ]; then + pkg_name=${pkg_name}-${verType} +elif [ "$verType" == "stable" ]; then + pkg_name=${pkg_name} +else + echo "unknow verType, nor stable or beta" + exit 1 +fi + +if [ "$osType" != "Darwin" ]; then + tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : +else + tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) || : + mv "$(basename ${pkg_name}).tar.gz" .. + rm -rf ./* + mv ../"$(basename ${pkg_name}).tar.gz" . +fi + +cd ${curr_dir} diff --git a/packaging/tools/makepkg_pro.sh b/packaging/tools/makepkg_pro.sh new file mode 100755 index 0000000000000000000000000000000000000000..ffe4566b42017a7bffa6166ae28e18ca29bd03cd --- /dev/null +++ b/packaging/tools/makepkg_pro.sh @@ -0,0 +1,193 @@ +#!/bin/bash +# +# Generate tar.gz package for all os system + +set -e +#set -x + +curr_dir=$(pwd) +compile_dir=$1 +version=$2 +build_time=$3 +cpuType=$4 +osType=$5 +verMode=$6 +verType=$7 +pagMode=$8 +versionComp=$9 + +script_dir="$(dirname $(readlink -f $0))" +top_dir="$(readlink -f ${script_dir}/../..)" + +# create compressed install file. +build_dir="${compile_dir}/build" +code_dir="${top_dir}/src" +release_dir="${top_dir}/release" + +#package_name='linux' +if [ "$verMode" == "cluster" ]; then + install_dir="${release_dir}/ProDB-enterprise-server-${version}" +else + install_dir="${release_dir}/ProDB-server-${version}" +fi + +lib_files="${build_dir}/lib/libtaos.so.${version}" +header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h" +if [ "$verMode" == "cluster" ]; then + cfg_dir="${top_dir}/../enterprise/packaging/cfg" +else + cfg_dir="${top_dir}/packaging/cfg" +fi +install_files="${script_dir}/install_pro.sh" +nginx_dir="${code_dir}/../../enterprise/src/plugins/web" + +# make directories. +mkdir -p ${install_dir} +mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc +mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg + +#mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* || : +mkdir -p ${install_dir}/bin +if [ "$pagMode" == "lite" ]; then + strip ${build_dir}/bin/taosd + strip ${build_dir}/bin/taos + cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc + cp ${build_dir}/bin/taosd ${install_dir}/bin/prodbs + cp ${script_dir}/remove_pro.sh ${install_dir}/bin +else + cp ${build_dir}/bin/taos ${install_dir}/bin/prodbc + cp ${build_dir}/bin/taosd ${install_dir}/bin/prodbs + cp ${script_dir}/remove_pro.sh ${install_dir}/bin + cp ${build_dir}/bin/taosdemo ${install_dir}/bin/prodemo + cp ${build_dir}/bin/taosdump ${install_dir}/bin/prodump + cp ${build_dir}/bin/tarbitrator ${install_dir}/bin + cp ${script_dir}/set_core.sh ${install_dir}/bin + cp ${script_dir}/get_client.sh ${install_dir}/bin + cp ${script_dir}/startPre.sh ${install_dir}/bin + cp ${script_dir}/taosd-dump-cfg.gdb ${install_dir}/bin +fi +chmod a+x ${install_dir}/bin/* || : + +if [ "$verMode" == "cluster" ]; then + sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove_pro.sh >> remove_prodb_temp.sh + mv remove_prodb_temp.sh ${install_dir}/bin/remove_pro.sh + + mkdir -p ${install_dir}/nginxd && cp -r ${nginx_dir}/* ${install_dir}/nginxd + cp ${nginx_dir}/png/taos.png ${install_dir}/nginxd/admin/images/taos.png + rm -rf ${install_dir}/nginxd/png + + sed -i "s/TDengine/ProDB/g" ${install_dir}/nginxd/admin/*.html + sed -i "s/TDengine/ProDB/g" ${install_dir}/nginxd/admin/js/*.js + + sed -i '/dataDir/ {s/taos/ProDB/g}' ${install_dir}/cfg/taos.cfg + sed -i '/logDir/ {s/taos/ProDB/g}' ${install_dir}/cfg/taos.cfg + sed -i "s/TDengine/ProDB/g" ${install_dir}/cfg/taos.cfg + + if [ "$cpuType" == "aarch64" ]; then + cp -f ${install_dir}/nginxd/sbin/arm/64bit/nginx ${install_dir}/nginxd/sbin/ + elif [ "$cpuType" == "aarch32" ]; then + cp -f ${install_dir}/nginxd/sbin/arm/32bit/nginx ${install_dir}/nginxd/sbin/ + fi + rm -rf ${install_dir}/nginxd/sbin/arm +fi + +cd ${install_dir} +tar -zcv -f prodb.tar.gz * --remove-files || : +exitcode=$? +if [ "$exitcode" != "0" ]; then + echo "tar prodb.tar.gz error !!!" + exit $exitcode +fi + +cd ${curr_dir} +cp ${install_files} ${install_dir} +if [ "$verMode" == "cluster" ]; then + sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/install_pro.sh >> install_prodb_temp.sh + mv install_prodb_temp.sh ${install_dir}/install_pro.sh +fi +if [ "$pagMode" == "lite" ]; then + sed 's/pagMode=full/pagMode=lite/g' ${install_dir}/install.sh >> install_prodb_temp.sh + mv install_prodb_temp.sh ${install_dir}/install_pro.sh +fi +chmod a+x ${install_dir}/install_pro.sh + +# Copy example code +mkdir -p ${install_dir}/examples +examples_dir="${top_dir}/tests/examples" +cp -r ${examples_dir}/c ${install_dir}/examples +sed -i '/passwd/ {s/taosdata/prodb/g}' ${install_dir}/examples/c/*.c +sed -i '/root/ {s/taosdata/prodb/g}' ${install_dir}/examples/c/*.c + +if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then + cp -r ${examples_dir}/JDBC ${install_dir}/examples + cp -r ${examples_dir}/matlab ${install_dir}/examples + mv ${install_dir}/examples/matlab/TDengineDemo.m ${install_dir}/examples/matlab/ProDBDemo.m + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/examples/matlab/ProDBDemo.m + cp -r ${examples_dir}/python ${install_dir}/examples + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/examples/python/read_example.py + cp -r ${examples_dir}/R ${install_dir}/examples + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/examples/R/command.txt + cp -r ${examples_dir}/go ${install_dir}/examples + mv ${install_dir}/examples/go/taosdemo.go ${install_dir}/examples/go/prodemo.go + sed -i '/root/ {s/taosdata/prodb/g}' ${install_dir}/examples/go/prodemo.go +fi +# Copy driver +mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && echo "${versionComp}" > ${install_dir}/driver/vercomp.txt + +# Copy connector +connector_dir="${code_dir}/connector" +mkdir -p ${install_dir}/connector +if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then + cp ${build_dir}/lib/*.jar ${install_dir}/connector ||: + + if [ -d "${connector_dir}/grafanaplugin/dist" ]; then + cp -r ${connector_dir}/grafanaplugin/dist ${install_dir}/connector/grafanaplugin + else + echo "WARNING: grafanaplugin bundled dir not found, please check if want to use it!" + fi + if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then + cp -r ${connector_dir}/go ${install_dir}/connector + else + echo "WARNING: go connector not found, please check if want to use it!" + fi + cp -r ${connector_dir}/python ${install_dir}/connector/ + mv ${install_dir}/connector/python/taos ${install_dir}/connector/python/prodb + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/connector/python/prodb/cinterface.py + + sed -i '/password/ {s/taosdata/prodb/g}' ${install_dir}/connector/python/prodb/subscription.py + + sed -i '/self._password/ {s/taosdata/prodb/g}' ${install_dir}/connector/python/prodb/connection.py +fi + +cd ${release_dir} + +if [ "$verMode" == "cluster" ]; then + pkg_name=${install_dir}-${osType}-${cpuType} +elif [ "$verMode" == "edge" ]; then + pkg_name=${install_dir}-${osType}-${cpuType} +else + echo "unknow verMode, nor cluster or edge" + exit 1 +fi + +if [ "$pagMode" == "lite" ]; then + pkg_name=${pkg_name}-Lite +fi + +if [ "$verType" == "beta" ]; then + pkg_name=${pkg_name}-${verType} +elif [ "$verType" == "stable" ]; then + pkg_name=${pkg_name} +else + echo "unknow verType, nor stabel or beta" + exit 1 +fi + +tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : +exitcode=$? +if [ "$exitcode" != "0" ]; then + echo "tar ${pkg_name}.tar.gz error !!!" + exit $exitcode +fi + +cd ${curr_dir} diff --git a/packaging/tools/remove_arbi_pro.sh b/packaging/tools/remove_arbi_pro.sh new file mode 100755 index 0000000000000000000000000000000000000000..ff10478881628bdaf027c618a1b89f204ebbdb35 --- /dev/null +++ b/packaging/tools/remove_arbi_pro.sh @@ -0,0 +1,130 @@ +#!/bin/bash +# +# Script to stop the service and uninstall ProDB's arbitrator + +set -e +#set -x + +verMode=edge + +RED='\033[0;31m' +GREEN='\033[1;32m' +NC='\033[0m' + +#install main path +install_main_dir="/usr/local/tarbitrator" +bin_link_dir="/usr/bin" + +service_config_dir="/etc/systemd/system" +tarbitrator_service_name="tarbitratord" +csudo="" +if command -v sudo > /dev/null; then + csudo="sudo" +fi + +initd_mod=0 +service_mod=2 +if pidof systemd &> /dev/null; then + service_mod=0 +elif $(which service &> /dev/null); then + service_mod=1 + service_config_dir="/etc/init.d" + if $(which chkconfig &> /dev/null); then + initd_mod=1 + elif $(which insserv &> /dev/null); then + initd_mod=2 + elif $(which update-rc.d &> /dev/null); then + initd_mod=3 + else + service_mod=2 + fi +else + service_mod=2 +fi + +function kill_tarbitrator() { + pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + +function clean_bin() { + # Remove link + ${csudo} rm -f ${bin_link_dir}/tarbitrator || : +} + +function clean_header() { + # Remove link + ${csudo} rm -f ${inc_link_dir}/taos.h || : + ${csudo} rm -f ${inc_link_dir}/taoserror.h || : +} + +function clean_log() { + # Remove link + ${csudo} rm -rf /arbitrator.log || : +} + +function clean_service_on_systemd() { + tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" + + if systemctl is-active --quiet ${tarbitrator_service_name}; then + echo "ProDB tarbitrator is running, stopping it..." + ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + fi + ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + + ${csudo} rm -f ${tarbitratord_service_config} +} + +function clean_service_on_sysvinit() { + if pidof tarbitrator &> /dev/null; then + echo "ProDB's tarbitrator is running, stopping it..." + ${csudo} service tarbitratord stop || : + fi + + if ((${initd_mod}==1)); then + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} chkconfig --del tarbitratord || : + fi + elif ((${initd_mod}==2)); then + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} insserv -r tarbitratord || : + fi + elif ((${initd_mod}==3)); then + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} update-rc.d -f tarbitratord remove || : + fi + fi + + ${csudo} rm -f ${service_config_dir}/tarbitratord || : + + if $(which init &> /dev/null); then + ${csudo} init q || : + fi +} + +function clean_service() { + if ((${service_mod}==0)); then + clean_service_on_systemd + elif ((${service_mod}==1)); then + clean_service_on_sysvinit + else + # must manual stop + kill_tarbitrator + fi +} + +# Stop service and disable booting start. +clean_service +# Remove binary file and links +clean_bin +# Remove header file. +##clean_header +# Remove log file +clean_log + +${csudo} rm -rf ${install_main_dir} + +echo -e "${GREEN}ProDB's arbitrator is removed successfully!${NC}" +echo diff --git a/packaging/tools/remove_client_pro.sh b/packaging/tools/remove_client_pro.sh new file mode 100755 index 0000000000000000000000000000000000000000..59e4e8997620af035821df5a975fe58f1357c9dc --- /dev/null +++ b/packaging/tools/remove_client_pro.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# Script to stop the client and uninstall database, but retain the config and log files. +set -e +# set -x + +RED='\033[0;31m' +GREEN='\033[1;32m' +NC='\033[0m' + +#install main path +install_main_dir="/usr/local/ProDB" + +log_link_dir="/usr/local/ProDB/log" +cfg_link_dir="/usr/local/ProDB/cfg" +bin_link_dir="/usr/bin" +lib_link_dir="/usr/lib" +lib64_link_dir="/usr/lib64" +inc_link_dir="/usr/include" + +csudo="" +if command -v sudo > /dev/null; then + csudo="sudo" +fi + +function kill_client() { + if [ -n "$(pidof prodbc)" ]; then + ${csudo} kill -9 $pid || : + fi +} + +function clean_bin() { + # Remove link + ${csudo} rm -f ${bin_link_dir}/prodbc || : + ${csudo} rm -f ${bin_link_dir}/prodemo || : + ${csudo} rm -f ${bin_link_dir}/prodump || : + ${csudo} rm -f ${bin_link_dir}/rmprodb || : + ${csudo} rm -f ${bin_link_dir}/set_core || : +} + +function clean_lib() { + # Remove link + ${csudo} rm -f ${lib_link_dir}/libtaos.* || : + ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : +} + +function clean_header() { + # Remove link + ${csudo} rm -f ${inc_link_dir}/taos.h || : + ${csudo} rm -f ${inc_link_dir}/taoserror.h || : +} + +function clean_config() { + # Remove link + ${csudo} rm -f ${cfg_link_dir}/* || : +} + +function clean_log() { + # Remove link + ${csudo} rm -rf ${log_link_dir} || : +} + +# Stop client. +kill_client +# Remove binary file and links +clean_bin +# Remove header file. +clean_header +# Remove lib file +clean_lib +# Remove link log directory +clean_log +# Remove link configuration file +clean_config + +${csudo} rm -rf ${install_main_dir} + +echo -e "${GREEN}ProDB client is removed successfully!${NC}" +echo diff --git a/packaging/tools/remove_pro.sh b/packaging/tools/remove_pro.sh new file mode 100755 index 0000000000000000000000000000000000000000..f6dad22bc21b02a9d717d530c50bc19c5a718478 --- /dev/null +++ b/packaging/tools/remove_pro.sh @@ -0,0 +1,210 @@ +#!/bin/bash +# +# Script to stop the service and uninstall ProDB, but retain the config, data and log files. + +set -e +#set -x + +verMode=edge + +RED='\033[0;31m' +GREEN='\033[1;32m' +NC='\033[0m' + +#install main path +install_main_dir="/usr/local/ProDB" +data_link_dir="/usr/local/ProDB/data" +log_link_dir="/usr/local/ProDB/log" +cfg_link_dir="/usr/local/ProDB/cfg" +bin_link_dir="/usr/bin" +lib_link_dir="/usr/lib" +lib64_link_dir="/usr/lib64" +inc_link_dir="/usr/include" +install_nginxd_dir="/usr/local/nginxd" + +service_config_dir="/etc/systemd/system" +prodb_service_name="prodbs" +tarbitrator_service_name="tarbitratord" +nginx_service_name="nginxd" +csudo="" +if command -v sudo > /dev/null; then + csudo="sudo" +fi + +initd_mod=0 +service_mod=2 +if pidof systemd &> /dev/null; then + service_mod=0 +elif $(which service &> /dev/null); then + service_mod=1 + service_config_dir="/etc/init.d" + if $(which chkconfig &> /dev/null); then + initd_mod=1 + elif $(which insserv &> /dev/null); then + initd_mod=2 + elif $(which update-rc.d &> /dev/null); then + initd_mod=3 + else + service_mod=2 + fi +else + service_mod=2 +fi + +function kill_prodbs() { + pid=$(ps -ef | grep "prodbs" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + +function kill_tarbitrator() { + pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}') + if [ -n "$pid" ]; then + ${csudo} kill -9 $pid || : + fi +} + +function clean_bin() { + # Remove link + ${csudo} rm -f ${bin_link_dir}/prodbc || : + ${csudo} rm -f ${bin_link_dir}/prodbs || : + ${csudo} rm -f ${bin_link_dir}/prodemo || : + ${csudo} rm -f ${bin_link_dir}/prodump || : + ${csudo} rm -f ${bin_link_dir}/rmprodb || : + ${csudo} rm -f ${bin_link_dir}/tarbitrator || : + ${csudo} rm -f ${bin_link_dir}/set_core || : +} + +function clean_lib() { + # Remove link + ${csudo} rm -f ${lib_link_dir}/libtaos.* || : + ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : +} + +function clean_header() { + # Remove link + ${csudo} rm -f ${inc_link_dir}/taos.h || : + ${csudo} rm -f ${inc_link_dir}/taoserror.h || : +} + +function clean_config() { + # Remove link + ${csudo} rm -f ${cfg_link_dir}/* || : +} + +function clean_log() { + # Remove link + ${csudo} rm -rf ${log_link_dir} || : +} + +function clean_service_on_systemd() { + prodb_service_config="${service_config_dir}/${prodb_service_name}.service" + if systemctl is-active --quiet ${prodb_service_name}; then + echo "ProDB prodbs is running, stopping it..." + ${csudo} systemctl stop ${prodb_service_name} &> /dev/null || echo &> /dev/null + fi + ${csudo} systemctl disable ${prodb_service_name} &> /dev/null || echo &> /dev/null + ${csudo} rm -f ${prodb_service_config} + + tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service" + if systemctl is-active --quiet ${tarbitrator_service_name}; then + echo "ProDB tarbitrator is running, stopping it..." + ${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + fi + ${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null + ${csudo} rm -f ${tarbitratord_service_config} + + if [ "$verMode" == "cluster" ]; then + nginx_service_config="${service_config_dir}/${nginx_service_name}.service" + if [ -d ${bin_dir}/web ]; then + if systemctl is-active --quiet ${nginx_service_name}; then + echo "Nginx for ProDB is running, stopping it..." + ${csudo} systemctl stop ${nginx_service_name} &> /dev/null || echo &> /dev/null + fi + ${csudo} systemctl disable ${nginx_service_name} &> /dev/null || echo &> /dev/null + + ${csudo} rm -f ${nginx_service_config} + fi + fi +} + +function clean_service_on_sysvinit() { + if pidof prodbs &> /dev/null; then + echo "ProDB prodbs is running, stopping it..." + ${csudo} service prodbs stop || : + fi + + if pidof tarbitrator &> /dev/null; then + echo "ProDB tarbitrator is running, stopping it..." + ${csudo} service tarbitratord stop || : + fi + + if ((${initd_mod}==1)); then + if [ -e ${service_config_dir}/prodbs ]; then + ${csudo} chkconfig --del prodbs || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} chkconfig --del tarbitratord || : + fi + elif ((${initd_mod}==2)); then + if [ -e ${service_config_dir}/prodbs ]; then + ${csudo} insserv -r prodbs || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} insserv -r tarbitratord || : + fi + elif ((${initd_mod}==3)); then + if [ -e ${service_config_dir}/prodbs ]; then + ${csudo} update-rc.d -f prodbs remove || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then + ${csudo} update-rc.d -f tarbitratord remove || : + fi + fi + + ${csudo} rm -f ${service_config_dir}/prodbs || : + ${csudo} rm -f ${service_config_dir}/tarbitratord || : + + if $(which init &> /dev/null); then + ${csudo} init q || : + fi +} + +function clean_service() { + if ((${service_mod}==0)); then + clean_service_on_systemd + elif ((${service_mod}==1)); then + clean_service_on_sysvinit + else + # must manual stop taosd + kill_prodbs + kill_tarbitrator + fi +} + +# Stop service and disable booting start. +clean_service +# Remove binary file and links +clean_bin +# Remove header file. +clean_header +# Remove lib file +clean_lib +# Remove link log directory +clean_log +# Remove link configuration file +clean_config +# Remove data link directory +${csudo} rm -rf ${data_link_dir} || : + +${csudo} rm -rf ${install_main_dir} +${csudo} rm -rf ${install_nginxd_dir} +if [[ -e /etc/os-release ]]; then + osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) +else + osinfo="" +fi + +echo -e "${GREEN}ProDB is removed successfully!${NC}" +echo diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index df0cf15fe00eda5bc8e6004e2794733537b8aee0..cf53977103c3a9760286e70447d826f7026d7e53 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -10,6 +10,7 @@ AUX_SOURCE_DIRECTORY(src SRC) IF (TD_LINUX) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) # set the static lib name ADD_LIBRARY(taos_static STATIC ${SRC}) @@ -21,7 +22,7 @@ IF (TD_LINUX) ADD_LIBRARY(taos SHARED ${SRC}) TARGET_LINK_LIBRARIES(taos common query trpc tutil pthread m rt cJson) IF (TD_LINUX_64) - TARGET_LINK_LIBRARIES(taos lua) + TARGET_LINK_LIBRARIES(taos lua cJson) ENDIF () SET_TARGET_PROPERTIES(taos PROPERTIES CLEAN_DIRECT_OUTPUT 1) @@ -36,6 +37,7 @@ IF (TD_LINUX) ELSEIF (TD_DARWIN) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) # set the static lib name ADD_LIBRARY(taos_static STATIC ${SRC}) @@ -59,6 +61,7 @@ ELSEIF (TD_DARWIN) ELSEIF (TD_WINDOWS) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) CONFIGURE_FILE("${TD_COMMUNITY_DIR}/src/client/src/taos.rc.in" "${TD_COMMUNITY_DIR}/src/client/src/taos.rc") @@ -75,6 +78,7 @@ ELSEIF (TD_WINDOWS) ELSEIF (TD_DARWIN) SET(CMAKE_MACOSX_RPATH 1) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) ADD_LIBRARY(taos_static STATIC ${SRC}) TARGET_LINK_LIBRARIES(taos_static query trpc tutil pthread m lua cJson) diff --git a/src/client/inc/tscParseLine.h b/src/client/inc/tscParseLine.h index 401dcafdfbefd28e79ebdf30d810e194564a5056..e36c0bbc0b2d9c02e798aed1fe1e68dbe02939f5 100644 --- a/src/client/inc/tscParseLine.h +++ b/src/client/inc/tscParseLine.h @@ -54,6 +54,9 @@ typedef struct { int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLinesInfo* info); bool checkDuplicateKey(char *key, SHashObj *pHash, SSmlLinesInfo* info); +bool isValidInteger(char *str); +bool isValidFloat(char *str); + int32_t isValidChildTableName(const char *pTbName, int16_t len); bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, diff --git a/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h b/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h index 7181c658ddcdfde3efe7df3c0784c20f18bd4c03..61ae5082f31cd9129a3cec1eaa1e0552ada7993b 100644 --- a/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h +++ b/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h @@ -41,6 +41,14 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_initImp JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions (JNIEnv *, jclass, jint, jstring); +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: setConfigImp + * Signature: (Ljava/lang/String;)Lcom/taosdata/jdbc/TSDBException; + */ +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setConfigImp + (JNIEnv *, jclass, jstring); + /* * Class: com_taosdata_jdbc_TSDBJNIConnector * Method: getTsCharset diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 506c8d64b9f4213713656ecd08612a103e0b1b2d..925b7d75db9f88c9905270aa365c60990e9f45a3 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -200,6 +200,64 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_initImp(JNIEnv *e jniDebug("jni initialized successfully, config directory: %s", configDir); } +JNIEXPORT jobject createTSDBException(JNIEnv *env, int code, char *msg) { + // find class + jclass exception_clazz = (*env)->FindClass(env, "com/taosdata/jdbc/TSDBException"); + // find methods + jmethodID init_method = (*env)->GetMethodID(env, exception_clazz, "", "()V"); + jmethodID setCode_method = (*env)->GetMethodID(env, exception_clazz, "setCode", "(I)V"); + jmethodID setMessage_method = (*env)->GetMethodID(env, exception_clazz, "setMessage", "(Ljava/lang/String;)V"); + // new exception + jobject exception_obj = (*env)->NewObject(env, exception_clazz, init_method); + // set code + (*env)->CallVoidMethod(env, exception_obj, setCode_method, code); + // set message + jstring message = (*env)->NewStringUTF(env, msg); + (*env)->CallVoidMethod(env, exception_obj, setMessage_method, message); + + return exception_obj; +} + +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: setConfigImp + * Signature: (Ljava/lang/String;)Lcom/taosdata/jdbc/TSDBException; + */ +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setConfigImp(JNIEnv *env, jclass jobj, + jstring config) { + /* + if (config == NULL) { + jniDebug("config value is null"); + return -1; + } + + const char *cfg = (*env)->GetStringUTFChars(env, config, NULL); + if (!cfg) { + return -1; + } + return 0; + */ + + if (config == NULL) { + char *msg = "config value is null"; + jniDebug("config value is null"); + return createTSDBException(env, -1, msg); + } + + const char *cfg = (*env)->GetStringUTFChars(env, config, NULL); + if (!cfg) { + char *msg = "config value is null"; + jniDebug("config value is null"); + return createTSDBException(env, -1, msg); + } + + setConfRet result = taos_set_config(cfg); + int code = result.retCode; + char * msg = result.retMsg; + + return createTSDBException(env, code, msg); +} + JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions(JNIEnv *env, jobject jobj, jint optionIndex, jstring optionValue) { if (optionValue == NULL) { diff --git a/src/client/src/taos.def b/src/client/src/taos.def index 7d3b8e80c20226c4a509c95ab5728f41852110f5..f1ff17a491e795120494b00f59a800aa6bbc889a 100644 --- a/src/client/src/taos.def +++ b/src/client/src/taos.def @@ -2,6 +2,7 @@ EXPORTS taos_init taos_cleanup taos_options +taos_set_config taos_connect taos_connect_auth taos_close diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index e26e439492cec9c83b624c2bbb2bbc3a95de97b0..22392ba306faeed05af5d695ca0090057ac211cf 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -1137,7 +1137,7 @@ static void escapeSpecialCharacter(uint8_t field, const char **pos) { *pos = cur; } -static bool isValidInteger(char *str) { +bool isValidInteger(char *str) { char *c = str; if (*c != '+' && *c != '-' && !isdigit(*c)) { return false; @@ -1152,7 +1152,7 @@ static bool isValidInteger(char *str) { return true; } -static bool isValidFloat(char *str) { +bool isValidFloat(char *str) { char *c = str; uint8_t has_dot, has_exp, has_sign; has_dot = 0; @@ -1212,7 +1212,7 @@ static bool isTinyInt(char *pVal, uint16_t len) { if (len <= 2) { return false; } - if (!strcmp(&pVal[len - 2], "i8")) { + if (!strcasecmp(&pVal[len - 2], "i8")) { //printf("Type is int8(%s)\n", pVal); return true; } @@ -1226,7 +1226,7 @@ static bool isTinyUint(char *pVal, uint16_t len) { if (pVal[0] == '-') { return false; } - if (!strcmp(&pVal[len - 2], "u8")) { + if (!strcasecmp(&pVal[len - 2], "u8")) { //printf("Type is uint8(%s)\n", pVal); return true; } @@ -1237,7 +1237,7 @@ static bool isSmallInt(char *pVal, uint16_t len) { if (len <= 3) { return false; } - if (!strcmp(&pVal[len - 3], "i16")) { + if (!strcasecmp(&pVal[len - 3], "i16")) { //printf("Type is int16(%s)\n", pVal); return true; } @@ -1251,7 +1251,7 @@ static bool isSmallUint(char *pVal, uint16_t len) { if (pVal[0] == '-') { return false; } - if (strcmp(&pVal[len - 3], "u16") == 0) { + if (strcasecmp(&pVal[len - 3], "u16") == 0) { //printf("Type is uint16(%s)\n", pVal); return true; } @@ -1262,7 +1262,7 @@ static bool isInt(char *pVal, uint16_t len) { if (len <= 3) { return false; } - if (strcmp(&pVal[len - 3], "i32") == 0) { + if (strcasecmp(&pVal[len - 3], "i32") == 0) { //printf("Type is int32(%s)\n", pVal); return true; } @@ -1276,7 +1276,7 @@ static bool isUint(char *pVal, uint16_t len) { if (pVal[0] == '-') { return false; } - if (strcmp(&pVal[len - 3], "u32") == 0) { + if (strcasecmp(&pVal[len - 3], "u32") == 0) { //printf("Type is uint32(%s)\n", pVal); return true; } @@ -1287,7 +1287,7 @@ static bool isBigInt(char *pVal, uint16_t len) { if (len <= 3) { return false; } - if (strcmp(&pVal[len - 3], "i64") == 0) { + if (strcasecmp(&pVal[len - 3], "i64") == 0) { //printf("Type is int64(%s)\n", pVal); return true; } @@ -1301,7 +1301,7 @@ static bool isBigUint(char *pVal, uint16_t len) { if (pVal[0] == '-') { return false; } - if (strcmp(&pVal[len - 3], "u64") == 0) { + if (strcasecmp(&pVal[len - 3], "u64") == 0) { //printf("Type is uint64(%s)\n", pVal); return true; } @@ -1312,7 +1312,7 @@ static bool isFloat(char *pVal, uint16_t len) { if (len <= 3) { return false; } - if (strcmp(&pVal[len - 3], "f32") == 0) { + if (strcasecmp(&pVal[len - 3], "f32") == 0) { //printf("Type is float(%s)\n", pVal); return true; } @@ -1323,7 +1323,7 @@ static bool isDouble(char *pVal, uint16_t len) { if (len <= 3) { return false; } - if (strcmp(&pVal[len - 3], "f64") == 0) { + if (strcasecmp(&pVal[len - 3], "f64") == 0) { //printf("Type is double(%s)\n", pVal); return true; } @@ -1331,34 +1331,24 @@ static bool isDouble(char *pVal, uint16_t len) { } static bool isBool(char *pVal, uint16_t len, bool *bVal) { - if ((len == 1) && - (pVal[len - 1] == 't' || - pVal[len - 1] == 'T')) { + if ((len == 1) && !strcasecmp(&pVal[len - 1], "t")) { //printf("Type is bool(%c)\n", pVal[len - 1]); *bVal = true; return true; } - if ((len == 1) && - (pVal[len - 1] == 'f' || - pVal[len - 1] == 'F')) { + if ((len == 1) && !strcasecmp(&pVal[len - 1], "f")) { //printf("Type is bool(%c)\n", pVal[len - 1]); *bVal = false; return true; } - if((len == 4) && - (!strcmp(&pVal[len - 4], "true") || - !strcmp(&pVal[len - 4], "True") || - !strcmp(&pVal[len - 4], "TRUE"))) { + if((len == 4) && !strcasecmp(&pVal[len - 4], "true")) { //printf("Type is bool(%s)\n", &pVal[len - 4]); *bVal = true; return true; } - if((len == 5) && - (!strcmp(&pVal[len - 5], "false") || - !strcmp(&pVal[len - 5], "False") || - !strcmp(&pVal[len - 5], "FALSE"))) { + if((len == 5) && !strcasecmp(&pVal[len - 5], "false")) { //printf("Type is bool(%s)\n", &pVal[len - 5]); *bVal = false; return true; @@ -1384,7 +1374,7 @@ static bool isNchar(char *pVal, uint16_t len) { if (len < 3) { return false; } - if (pVal[0] == 'L' && pVal[1] == '"' && pVal[len - 1] == '"') { + if ((pVal[0] == 'l' || pVal[0] == 'L')&& pVal[1] == '"' && pVal[len - 1] == '"') { //printf("Type is nchar(%s)\n", pVal); return true; } @@ -1434,7 +1424,7 @@ static bool isTimeStamp(char *pVal, uint16_t len, SMLTimeStampType *tsType) { return false; } -static bool convertStrToNumber(TAOS_SML_KV *pVal, char*str, SSmlLinesInfo* info) { +static bool convertStrToNumber(TAOS_SML_KV *pVal, char *str, SSmlLinesInfo* info) { errno = 0; uint8_t type = pVal->type; int16_t length = pVal->length; @@ -1442,6 +1432,7 @@ static bool convertStrToNumber(TAOS_SML_KV *pVal, char*str, SSmlLinesInfo* info) uint64_t val_u; double val_d; + strntolower_s(str, str, (int32_t)strlen(str)); if (IS_FLOAT_TYPE(type)) { val_d = strtod(str, NULL); } else { @@ -1659,9 +1650,19 @@ bool convertSmlValueType(TAOS_SML_KV *pVal, char *value, memcpy(pVal->value, &bVal, pVal->length); return true; } - //Handle default(no appendix) as float - if (isValidInteger(value) || isValidFloat(value)) { - pVal->type = TSDB_DATA_TYPE_FLOAT; + //Handle default(no appendix) interger type as BIGINT + if (isValidInteger(value)) { + pVal->type = TSDB_DATA_TYPE_BIGINT; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + if (!convertStrToNumber(pVal, value, info)) { + return false; + } + return true; + } + + //Handle default(no appendix) floating number type as DOUBLE + if (isValidFloat(value)) { + pVal->type = TSDB_DATA_TYPE_DOUBLE; pVal->length = (int16_t)tDataTypes[pVal->type].bytes; if (!convertStrToNumber(pVal, value, info)) { return false; @@ -1724,6 +1725,7 @@ int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value, SMLTimeStampType type; int64_t tsVal; + strntolower_s(value, value, len); if (!isTimeStamp(value, len, &type)) { return TSDB_CODE_TSC_INVALID_TIME_STAMP; } diff --git a/src/client/src/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index 12f8ec84fd301d2d8851e92826cfcb3d860c1ceb..14693ae361b533287e3377e644908c5c8a613c79 100644 --- a/src/client/src/tscParseOpenTSDB.c +++ b/src/client/src/tscParseOpenTSDB.c @@ -38,7 +38,7 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index, uint16_t len = 0; pSml->stableName = tcalloc(TSDB_TABLE_NAME_LEN + 1, 1); // +1 to avoid 1772 line over write - if (pSml->stableName == NULL){ + if (pSml->stableName == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } if (isdigit(*cur)) { @@ -58,7 +58,13 @@ static int32_t parseTelnetMetric(TAOS_SML_DATA_POINT *pSml, const char **index, break; } - pSml->stableName[len] = *cur; + //convert dot to underscore for now, will be removed once dot is allowed in tbname. + if (*cur == '.') { + pSml->stableName[len] = '_'; + } else { + pSml->stableName[len] = *cur; + } + cur++; len++; } @@ -178,6 +184,9 @@ static int32_t parseTelnetTagKey(TAOS_SML_KV *pKV, const char **index, SHashObj tscError("OTD:0x%"PRIx64" Tag key cannot exceeds 65 characters", info->id); return TSDB_CODE_TSC_INVALID_COLUMN_LENGTH; } + if (*cur == ' ') { + return TSDB_CODE_TSC_LINE_SYNTAX_ERROR; + } if (*cur == '=') { break; } @@ -211,8 +220,8 @@ static int32_t parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index, start = cur = *index; while (1) { - // ',' or '\0' identifies a value - if (*cur == ',' || *cur == '\0') { + // whitespace or '\0' identifies a value + if (*cur == ' ' || *cur == '\0') { // '\0' indicates end of value *is_last_kv = (*cur == '\0') ? true : false; break; @@ -452,6 +461,13 @@ int32_t parseMetricFromJSON(cJSON *root, TAOS_SML_DATA_POINT* pSml, SSmlLinesInf return TSDB_CODE_TSC_INVALID_JSON; } + //convert dot to underscore for now, will be removed once dot is allowed in tbname. + for (int i = 0; i < strlen(metric->valuestring); ++i) { + if (metric->valuestring[i] == '.') { + metric->valuestring[i] = '_'; + } + } + tstrncpy(pSml->stableName, metric->valuestring, stableLen + 1); return TSDB_CODE_SUCCESS; @@ -482,6 +498,7 @@ int32_t parseTimestampFromJSONObj(cJSON *root, int64_t *tsVal, SSmlLinesInfo* in } size_t typeLen = strlen(type->valuestring); + strntolower_s(type->valuestring, type->valuestring, (int32_t)typeLen); if (typeLen == 1 && type->valuestring[0] == 's') { //seconds *tsVal = (int64_t)(*tsVal * 1e9); @@ -502,6 +519,8 @@ int32_t parseTimestampFromJSONObj(cJSON *root, int64_t *tsVal, SSmlLinesInfo* in default: return TSDB_CODE_TSC_INVALID_JSON; } + } else { + return TSDB_CODE_TSC_INVALID_JSON; } return TSDB_CODE_SUCCESS; @@ -722,16 +741,34 @@ int32_t parseValueFromJSON(cJSON *root, TAOS_SML_KV *pVal, SSmlLinesInfo* info) break; } case cJSON_Number: { - //convert default JSON Number type to float - pVal->type = TSDB_DATA_TYPE_FLOAT; - pVal->length = (int16_t)tDataTypes[pVal->type].bytes; - pVal->value = tcalloc(pVal->length, 1); - *(float *)(pVal->value) = (float)(root->valuedouble); + //convert default JSON Number type to BIGINT/DOUBLE + if (isValidInteger(root->numberstring)) { + pVal->type = TSDB_DATA_TYPE_BIGINT; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->value = tcalloc(pVal->length, 1); + *(int64_t *)(pVal->value) = (int64_t)(root->valuedouble); + } else if (isValidFloat(root->numberstring)) { + pVal->type = TSDB_DATA_TYPE_DOUBLE; + pVal->length = (int16_t)tDataTypes[pVal->type].bytes; + pVal->value = tcalloc(pVal->length, 1); + *(double *)(pVal->value) = (double)(root->valuedouble); + } else { + return TSDB_CODE_TSC_INVALID_JSON_TYPE; + } break; } case cJSON_String: { - //convert default JSON String type to nchar - pVal->type = TSDB_DATA_TYPE_NCHAR; + /* set default JSON type to binary/nchar according to + * user configured parameter tsDefaultJSONStrType + */ + if (strcasecmp(tsDefaultJSONStrType, "binary") == 0) { + pVal->type = TSDB_DATA_TYPE_BINARY; + } else if (strcasecmp(tsDefaultJSONStrType, "nchar") == 0) { + pVal->type = TSDB_DATA_TYPE_NCHAR; + } else { + tscError("OTD:0x%"PRIx64" Invalid default JSON string type set from config %s", info->id, tsDefaultJSONStrType); + return TSDB_CODE_TSC_INVALID_JSON_CONFIG; + } //pVal->length = wcslen((wchar_t *)root->valuestring) * TSDB_NCHAR_SIZE; pVal->length = (int16_t)strlen(root->valuestring); pVal->value = tcalloc(pVal->length + 1, 1); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 9746f79d9ae51845c9b997929916b6f83a0cc140..a62a8ac3efca0836faab778224aa4a831e84e580 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -76,7 +76,6 @@ static int32_t getDelimiterIndex(SStrToken* pTableName); static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd); static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd); -static int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStrToken* tableName, int32_t* len); static void getColumnName(tSqlExprItem* pItem, char* resultFieldName, char* rawName, int32_t nameLength); static int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSqlExprItem* pItem, @@ -335,7 +334,7 @@ static int setColumnFilterInfoForTimestamp(SSqlCmd* pCmd, SQueryInfo* pQueryInfo STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); - if (convertTimestampStrToInt64(pVar, tinfo.precision) < -1) { + if (convertTimestampStrToInt64(pVar, tinfo.precision) < 0) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); } return TSDB_CODE_SUCCESS; @@ -1698,57 +1697,6 @@ static int32_t getDelimiterIndex(SStrToken* pTableName) { return -1; } -int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStrToken* tableName, int32_t* xlen) { - int32_t totalLen = 0; - - if (account != NULL) { - int32_t len = (int32_t)strlen(account); - strcpy(fullName, account); - fullName[len] = TS_PATH_DELIMITER[0]; - totalLen += (len + 1); - } - - /* db name is not specified, the tableName dose not include db name */ - if (pDB != NULL) { - if (pDB->n >= TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN || pDB->n == 0) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - - memcpy(&fullName[totalLen], pDB->z, pDB->n); - totalLen += pDB->n; - } - - if (tableName != NULL) { - if (pDB != NULL) { - fullName[totalLen] = TS_PATH_DELIMITER[0]; - totalLen += 1; - - /* here we only check the table name length limitation */ - if (!tscValidateTableNameLength(tableName->n)) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - } else { // pDB == NULL, the db prefix name is specified in tableName - /* the length limitation includes tablename + dbname + sep */ - if (tableName->n >= TSDB_TABLE_NAME_LEN + TSDB_DB_NAME_LEN) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - } - - memcpy(&fullName[totalLen], tableName->z, tableName->n); - totalLen += tableName->n; - } - - if (xlen != NULL) { - *xlen = totalLen; - } - - if (totalLen < TSDB_TABLE_FNAME_LEN) { - fullName[totalLen] = 0; - } - - return (totalLen < TSDB_TABLE_FNAME_LEN) ? TSDB_CODE_SUCCESS : TSDB_CODE_TSC_INVALID_OPERATION; -} - void tscInsertPrimaryTsSourceColumn(SQueryInfo* pQueryInfo, uint64_t tableUid) { SSchema s = {.type = TSDB_DATA_TYPE_TIMESTAMP, .bytes = TSDB_KEYSIZE, .colId = PRIMARYKEY_TIMESTAMP_COL_INDEX}; tscColumnListInsert(pQueryInfo->colList, PRIMARYKEY_TIMESTAMP_COL_INDEX, tableUid, &s); @@ -2551,6 +2499,9 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col case TSDB_FUNC_MAX: case TSDB_FUNC_DIFF: case TSDB_FUNC_DERIVATIVE: + case TSDB_FUNC_CEIL: + case TSDB_FUNC_FLOOR: + case TSDB_FUNC_ROUND: case TSDB_FUNC_STDDEV: case TSDB_FUNC_LEASTSQR: { // 1. valid the number of parameters @@ -2741,6 +2692,10 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex); + if (pParamElem->pNode->columnName.z == NULL) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + // functions can not be applied to tags if ((index.columnIndex >= tscGetNumOfColumns(pTableMetaInfo->pTableMeta)) || (index.columnIndex < 0)) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); @@ -3474,6 +3429,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool int32_t scalarUdf = 0; int32_t prjNum = 0; int32_t aggNum = 0; + int32_t scalNum = 0; size_t numOfExpr = tscNumOfExprs(pQueryInfo); assert(numOfExpr > 0); @@ -3505,6 +3461,10 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool ++prjNum; } + if (functionId == TSDB_FUNC_CEIL || functionId == TSDB_FUNC_FLOOR || functionId == TSDB_FUNC_ROUND) { + ++scalNum; + } + if (functionId == TSDB_FUNC_PRJ && (pExpr1->base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX || TSDB_COL_IS_UD_COL(pExpr1->base.colInfo.flag))) { continue; } @@ -3526,15 +3486,19 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool } } - aggNum = (int32_t)size - prjNum - aggUdf - scalarUdf; + aggNum = (int32_t)size - prjNum - scalNum - aggUdf - scalarUdf; assert(aggNum >= 0); - if (aggUdf > 0 && (prjNum > 0 || aggNum > 0 || scalarUdf > 0)) { + if (aggUdf > 0 && (prjNum > 0 || aggNum > 0 || scalNum > 0 || scalarUdf > 0)) { + return false; + } + + if (scalarUdf > 0 && (aggNum > 0 || scalNum > 0)) { return false; } - if (scalarUdf > 0 && aggNum > 0) { + if (aggNum > 0 && scalNum > 0) { return false; } @@ -3721,11 +3685,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, } } - if (pExpr->tokenId == TK_LE || pExpr->tokenId == TK_LT) { - retVal = tVariantDump(&pRight->value, (char*)&pColumnFilter->upperBndd, colType, false); - - // TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd - } else if (pExpr->tokenId == TK_IN) { + if (pExpr->tokenId == TK_IN) { tVariant *pVal; if (pRight->tokenId != TK_SET || !serializeExprListToVariant(pRight->Expr.paramList, &pVal, colType, timePrecision)) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); @@ -3751,6 +3711,10 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, size_t len = twcslen((wchar_t*)pColumnFilter->pz); pColumnFilter->len = len * TSDB_NCHAR_SIZE; + } else if (pExpr->tokenId == TK_LE || pExpr->tokenId == TK_LT) { + retVal = tVariantDump(&pRight->value, (char*)&pColumnFilter->upperBndd, colType, false); + + // TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd } else { retVal = tVariantDump(&pRight->value, (char*)&pColumnFilter->lowerBndd, colType, false); } @@ -3809,9 +3773,6 @@ typedef struct SCondExpr { tSqlExpr* pColumnCond; - tSqlExpr* pTableCond; - int16_t relType; // relation between table name in expression and other tag - // filter condition expression, TK_AND or TK_OR int16_t tableCondIndex; tSqlExpr* pJoinExpr; // join condition @@ -3820,51 +3781,6 @@ typedef struct SCondExpr { static int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t timePrecision); -static int32_t tablenameListToString(tSqlExpr* pExpr, SStringBuilder* sb) { - SArray* pList = pExpr->Expr.paramList; - - int32_t size = (int32_t) taosArrayGetSize(pList); - if (size <= 0) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - - if (size > 0) { - taosStringBuilderAppendStringLen(sb, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN); - } - - for (int32_t i = 0; i < size; ++i) { - tSqlExprItem* pSub = taosArrayGet(pList, i); - tVariant* pVar = &pSub->pNode->value; - - taosStringBuilderAppendStringLen(sb, pVar->pz, pVar->nLen); - - if (i < size - 1) { - taosStringBuilderAppendString(sb, TBNAME_LIST_SEP); - } - - if (pVar->nLen <= 0 || !tscValidateTableNameLength(pVar->nLen)) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - } - - return TSDB_CODE_SUCCESS; -} - -static int32_t tablenameCondToString(tSqlExpr* pExpr, uint32_t opToken, SStringBuilder* sb) { - assert(opToken == TK_LIKE || opToken == TK_MATCH || opToken == TK_NMATCH); - if (opToken == TK_LIKE) { - taosStringBuilderAppendStringLen(sb, QUERY_COND_REL_PREFIX_LIKE, QUERY_COND_REL_PREFIX_LIKE_LEN); - taosStringBuilderAppendString(sb, pExpr->value.pz); - } else if (opToken == TK_MATCH) { - taosStringBuilderAppendStringLen(sb, QUERY_COND_REL_PREFIX_MATCH, QUERY_COND_REL_PREFIX_MATCH_LEN); - taosStringBuilderAppendString(sb, pExpr->value.pz); - } else if (opToken == TK_NMATCH) { - taosStringBuilderAppendStringLen(sb, QUERY_COND_REL_PREFIX_NMATCH, QUERY_COND_REL_PREFIX_NMATCH_LEN); - taosStringBuilderAppendString(sb, pExpr->value.pz); - } - return TSDB_CODE_SUCCESS; -} - enum { TSQL_EXPR_TS = 1, TSQL_EXPR_TAG = 2, @@ -3882,7 +3798,6 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, pIndex->columnIndex); int32_t ret = 0; const char* msg1 = "non binary column not support like/match operator"; - const char* msg2 = "binary column not support this operator"; const char* msg3 = "bool column not support this operator"; const char* msg4 = "primary key not support this operator"; @@ -3903,19 +3818,7 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol pColFilter->filterstr = ((pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) ? 1 : 0); - if (pColFilter->filterstr) { - if (pExpr->tokenId != TK_EQ - && pExpr->tokenId != TK_NE - && pExpr->tokenId != TK_ISNULL - && pExpr->tokenId != TK_NOTNULL - && pExpr->tokenId != TK_LIKE - && pExpr->tokenId != TK_MATCH - && pExpr->tokenId != TK_NMATCH - && pExpr->tokenId != TK_IN) { - ret = invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); - goto _err_ret; - } - } else { + if (!pColFilter->filterstr) { if (pExpr->tokenId == TK_LIKE || pExpr->tokenId == TK_MATCH || pExpr->tokenId == TK_NMATCH) { ret = invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); goto _err_ret; @@ -3945,40 +3848,6 @@ _err_ret: return ret; } -static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pTableCond, SStringBuilder* sb) { - const char* msg0 = "invalid table name list"; - const char* msg1 = "not string following like"; - - if (pTableCond == NULL) { - return TSDB_CODE_SUCCESS; - } - - tSqlExpr* pLeft = pTableCond->pLeft; - tSqlExpr* pRight = pTableCond->pRight; - - if (!isTablenameToken(&pLeft->columnName)) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - - int32_t ret = TSDB_CODE_SUCCESS; - - if (pTableCond->tokenId == TK_IN) { - ret = tablenameListToString(pRight, sb); - } else if (pTableCond->tokenId == TK_LIKE || pTableCond->tokenId == TK_MATCH || pTableCond->tokenId == TK_NMATCH) { - if (pRight->tokenId != TK_STRING) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); - } - - ret = tablenameCondToString(pRight, pTableCond->tokenId, sb); - } - - if (ret != TSDB_CODE_SUCCESS) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg0); - } - - return ret; -} - static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr) { int32_t ret = TSDB_CODE_SUCCESS; @@ -4101,8 +3970,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS index.columnIndex = index.columnIndex - tscGetNumOfColumns(pTableMetaInfo->pTableMeta); if (tscColumnExists(pTableMetaInfo->tagColList, pTagSchema1->colId, pTableMetaInfo->pTableMeta->id.uid) < 0) { tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pTagSchema1); + atomic_add_fetch_32(&pTableMetaInfo->joinTagNum, 1); - if (taosArrayGetSize(pTableMetaInfo->tagColList) > 1) { + if (pTableMetaInfo->joinTagNum > 1) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } } @@ -4134,7 +4004,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS if (tscColumnExists(pTableMetaInfo->tagColList, pTagSchema2->colId, pTableMeta->id.uid) < 0) { tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pTagSchema2); - if (taosArrayGetSize(pTableMetaInfo->tagColList) > 1) { + atomic_add_fetch_32(&pTableMetaInfo->joinTagNum, 1); + + if (pTableMetaInfo->joinTagNum > 1) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } } @@ -4417,18 +4289,6 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr return true; } -static bool validTableNameOptr(tSqlExpr* pExpr) { - const char nameFilterOptr[] = {TK_IN, TK_LIKE, TK_MATCH, TK_NMATCH}; - - for (int32_t i = 0; i < tListLen(nameFilterOptr); ++i) { - if (pExpr->tokenId == nameFilterOptr[i]) { - return true; - } - } - - return false; -} - static int32_t setExprToCond(tSqlExpr** parent, tSqlExpr* pExpr, const char* msg, int32_t parentOptr, char* msgBuf) { if (*parent != NULL) { if (parentOptr == TK_OR && msg != NULL) { @@ -4539,7 +4399,16 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_ regex_t regex; char regErrBuf[256] = {0}; - const char* pattern = pRight->value.pz; + //remove the quote at the begin end of original sql string. + uint32_t lenPattern = pRight->exprToken.n - 2; + char* pattern = malloc(lenPattern + 1); + strncpy(pattern, pRight->exprToken.z+1, lenPattern); + pattern[lenPattern] = '\0'; + + tfree(pRight->value.pz); + pRight->value.pz = pattern; + pRight->value.nLen = lenPattern; + int cflags = REG_EXTENDED; if ((errCode = regcomp(®ex, pattern, cflags)) != 0) { regerror(errCode, ®ex, regErrBuf, sizeof(regErrBuf)); @@ -4572,8 +4441,6 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql const char* msg2 = "illegal column name"; const char* msg4 = "too many join tables"; const char* msg5 = "not support ordinary column join"; - const char* msg6 = "only one query condition on tbname allowed"; - const char* msg7 = "only in/like allowed in filter table name"; tSqlExpr* pLeft = (*pExpr)->pLeft; tSqlExpr* pRight = (*pExpr)->pRight; @@ -4690,54 +4557,30 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } - // in case of in operator, keep it in a seprate attribute - if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { - if (!validTableNameOptr(*pExpr)) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); - } - - if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + if (pRight != NULL && pRight->tokenId == TK_ID) { // join on tag columns for stable query + if (!validateJoinExprNode(pCmd, pQueryInfo, *pExpr, &index)) { + return TSDB_CODE_TSC_INVALID_OPERATION; } - if (pCondExpr->pTableCond == NULL) { - pCondExpr->pTableCond = *pExpr; - pCondExpr->relType = parentOptr; - pCondExpr->tableCondIndex = index.tableIndex; - } else { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); + pQueryInfo->type |= TSDB_QUERY_TYPE_JOIN_QUERY; + ret = setExprToCond(&pCondExpr->pJoinExpr, *pExpr, NULL, parentOptr, pCmd->payload); + *pExpr = NULL; + if (type) { + *type |= TSQL_EXPR_JOIN; + } + } else { + // do nothing + // ret = setExprToCond(pCmd, &pCondExpr->pTagCond, + // *pExpr, NULL, parentOptr); + tSqlExpr *rexpr = NULL; + if ((*pExpr)->tokenId == TK_NE && (pSchema->type != TSDB_DATA_TYPE_BINARY && pSchema->type != TSDB_DATA_TYPE_NCHAR && pSchema->type != TSDB_DATA_TYPE_BOOL)) { + handleNeOptr(&rexpr, *pExpr); + *pExpr = rexpr; } - + if (type) { *type |= TSQL_EXPR_TAG; } - *pExpr = NULL; - } else { - if (pRight != NULL && pRight->tokenId == TK_ID) { // join on tag columns for stable query - if (!validateJoinExprNode(pCmd, pQueryInfo, *pExpr, &index)) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - - pQueryInfo->type |= TSDB_QUERY_TYPE_JOIN_QUERY; - ret = setExprToCond(&pCondExpr->pJoinExpr, *pExpr, NULL, parentOptr, pCmd->payload); - *pExpr = NULL; - if (type) { - *type |= TSQL_EXPR_JOIN; - } - } else { - // do nothing - // ret = setExprToCond(pCmd, &pCondExpr->pTagCond, - // *pExpr, NULL, parentOptr); - tSqlExpr *rexpr = NULL; - if ((*pExpr)->tokenId == TK_NE && (pSchema->type != TSDB_DATA_TYPE_BINARY && pSchema->type != TSDB_DATA_TYPE_NCHAR && pSchema->type != TSDB_DATA_TYPE_BOOL)) { - handleNeOptr(&rexpr, *pExpr); - *pExpr = rexpr; - } - - if (type) { - *type |= TSQL_EXPR_TAG; - } - } } } else { // query on other columns if (type) { @@ -4924,84 +4767,6 @@ int tableNameCompar(const void* lhs, const void* rhs) { return ret > 0 ? 1 : -1; } -static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, const char* account, - tSqlExpr* pExpr, int16_t tableCondIndex, SStringBuilder* sb) { - const char* msg = "table name too long"; - - if (pExpr == NULL) { - return TSDB_CODE_SUCCESS; - } - - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableCondIndex); - - STagCond* pTagCond = &pQueryInfo->tagCond; - pTagCond->tbnameCond.uid = pTableMetaInfo->pTableMeta->id.uid; - - assert(pExpr->tokenId == TK_LIKE - || pExpr->tokenId == TK_MATCH - || pExpr->tokenId == TK_NMATCH - || pExpr->tokenId == TK_IN); - - if (pExpr->tokenId == TK_LIKE || pExpr->tokenId == TK_MATCH || pExpr->tokenId == TK_NMATCH) { - char* str = taosStringBuilderGetResult(sb, NULL); - pQueryInfo->tagCond.tbnameCond.cond = strdup(str); - pQueryInfo->tagCond.tbnameCond.len = (int32_t) strlen(str); - return TSDB_CODE_SUCCESS; - } else { - SStringBuilder sb1; - memset(&sb1, 0, sizeof(sb1)); - taosStringBuilderAppendStringLen(&sb1, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN); - - // remove the duplicated input table names - int32_t num = 0; - char* tableNameString = taosStringBuilderGetResult(sb, NULL); - - char** segments = strsplit(tableNameString + QUERY_COND_REL_PREFIX_IN_LEN, TBNAME_LIST_SEP, &num); - qsort(segments, num, POINTER_BYTES, tableNameCompar); - - int32_t j = 1; - for (int32_t i = 1; i < num; ++i) { - if (strcmp(segments[i], segments[i - 1]) != 0) { - segments[j++] = segments[i]; - } - } - num = j; - - char name[TSDB_DB_NAME_LEN] = {0}; - tNameGetDbName(&pTableMetaInfo->name, name); - SStrToken dbToken = {.type = TK_STRING, .z = name, .n = (uint32_t)strlen(name)}; - - for (int32_t i = 0; i < num; ++i) { - if (i >= 1) { - taosStringBuilderAppendStringLen(&sb1, TBNAME_LIST_SEP, 1); - } - - char idBuf[TSDB_TABLE_FNAME_LEN] = {0}; - int32_t xlen = (int32_t)strlen(segments[i]); - SStrToken t = {.z = segments[i], .n = xlen, .type = TK_STRING}; - - int32_t ret = setObjFullName(idBuf, account, &dbToken, &t, &xlen); - if (ret != TSDB_CODE_SUCCESS) { - taosStringBuilderDestroy(&sb1); - tfree(segments); - - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); - return ret; - } - - taosStringBuilderAppendString(&sb1, idBuf); - } - - char* str = taosStringBuilderGetResult(&sb1, NULL); - pQueryInfo->tagCond.tbnameCond.cond = strdup(str); - pQueryInfo->tagCond.tbnameCond.len = (int32_t)strlen(str); - - taosStringBuilderDestroy(&sb1); - tfree(segments); - return TSDB_CODE_SUCCESS; - } -} - int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_t optr) { const char* msg0 = "only one time stamp window allowed"; @@ -5141,10 +4906,6 @@ static int32_t validateJoinExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondExpr } static void cleanQueryExpr(SCondExpr* pCondExpr) { - if (pCondExpr->pTableCond) { - tSqlExprDestroy(pCondExpr->pTableCond); - } - if (pCondExpr->pColumnCond) { tSqlExprDestroy(pCondExpr->pColumnCond); } @@ -5440,7 +5201,7 @@ static int32_t getQueryTimeRange(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr //multiple tables's query time range mixed together tExprNode* p = NULL; - SFilterInfo *filter = NULL; + void *filter = NULL; SArray* colList = taosArrayInit(10, sizeof(SColIndex)); ret = exprTreeFromSqlExpr(pCmd, &p, *pExpr, pQueryInfo, colList, NULL); @@ -5482,7 +5243,6 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq int32_t ret = TSDB_CODE_SUCCESS; // tags query condition may be larger than 512bytes, therefore, we need to prepare enough large space - SStringBuilder sb; memset(&sb, 0, sizeof(sb)); SCondExpr condExpr = {0}; if ((*pExpr)->pLeft == NULL || (*pExpr)->pRight == NULL) { @@ -5515,12 +5275,12 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq condExpr.pTagCond = (*pExpr); *pExpr = NULL; - // 1. check if it is a join query + // check if it is a join query if ((ret = validateJoinExpr(&pSql->cmd, pQueryInfo, &condExpr)) != TSDB_CODE_SUCCESS) { goto PARSE_WHERE_EXIT; } - // 2. get the query time range + // get the query time range if ((ret = convertTimeRangeFromExpr(&pSql->cmd, pQueryInfo, condExpr.pTimewindow)) != TSDB_CODE_SUCCESS) { goto PARSE_WHERE_EXIT; } @@ -5528,19 +5288,13 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq if ((ret = getQueryTimeRange(&pSql->cmd, pQueryInfo, &condExpr.pTimewindow)) != TSDB_CODE_SUCCESS) { goto PARSE_WHERE_EXIT; } - - // 3. get the tag query condition + // get the tag query condition if ((ret = getTagQueryCondExpr(&pSql->cmd, pQueryInfo, &condExpr)) != TSDB_CODE_SUCCESS) { goto PARSE_WHERE_EXIT; } - // 4. get the table name query condition - if ((ret = getTablenameCond(&pSql->cmd, pQueryInfo, condExpr.pTableCond, &sb)) != TSDB_CODE_SUCCESS) { - goto PARSE_WHERE_EXIT; - } - - // 5. other column query condition + // other column query condition if ((ret = checkColumnQueryCondInfo(&pSql->cmd, pQueryInfo, condExpr.pColumnCond, TK_AND)) != TSDB_CODE_SUCCESS) { goto PARSE_WHERE_EXIT; } @@ -5549,21 +5303,11 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq goto PARSE_WHERE_EXIT; } - - // 6. join condition + // join condition if ((ret = getJoinCondInfo(&pSql->cmd, pQueryInfo, condExpr.pJoinExpr)) != TSDB_CODE_SUCCESS) { goto PARSE_WHERE_EXIT; } - // 7. query condition for table name - pQueryInfo->tagCond.relType = (condExpr.relType == TK_AND) ? TSDB_RELATION_AND : TSDB_RELATION_OR; - - ret = setTableCondForSTableQuery(&pSql->cmd, pQueryInfo, getAccountId(pSql), condExpr.pTableCond, condExpr.tableCondIndex, &sb); - taosStringBuilderDestroy(&sb); - if (ret) { - goto PARSE_WHERE_EXIT; - } - //if (!validateFilterExpr(pQueryInfo)) { // ret = invalidOperationMsg(tscGetErrorMsgPayload(&pSql->cmd), msg2); // goto PARSE_WHERE_EXIT; @@ -5634,6 +5378,10 @@ int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t t pRight->flags &= ~(1 << EXPR_FLAG_NS_TIMESTAMP); } + if (pRight->value.nType == -1) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + tVariantDump(&pRight->value, (char*)&val, TSDB_DATA_TYPE_BIGINT, true); } @@ -6536,7 +6284,9 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu } int32_t f = pExpr->base.functionId; - if ((f == TSDB_FUNC_PRJ && pExpr->base.numOfParams == 0) || f == TSDB_FUNC_DIFF || f == TSDB_FUNC_ARITHM || f == TSDB_FUNC_DERIVATIVE) { + if ((f == TSDB_FUNC_PRJ && pExpr->base.numOfParams == 0) || f == TSDB_FUNC_DIFF || f == TSDB_FUNC_ARITHM || f == TSDB_FUNC_DERIVATIVE || + f == TSDB_FUNC_CEIL || f == TSDB_FUNC_FLOOR || f == TSDB_FUNC_ROUND) + { isProjectionFunction = true; break; } @@ -7138,6 +6888,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { const char* msg2 = "aggregation function should not be mixed up with projection"; bool tagTsColExists = false; + int16_t numOfScalar = 0; int16_t numOfSelectivity = 0; int16_t numOfAggregation = 0; @@ -7171,6 +6922,8 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) { numOfSelectivity++; + } else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SCALAR) != 0) { + numOfScalar++; } else { numOfAggregation++; } @@ -9209,13 +8962,17 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS (*pExpr)->pVal = calloc(1, sizeof(tVariant)); tVariantAssign((*pExpr)->pVal, &pSqlExpr->value); - STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta; - if (pCols != NULL && taosArrayGetSize(pCols) > 0) { - SColIndex* idx = taosArrayGet(pCols, 0); - SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex); - // convert time by precision - if (pSchema != NULL && TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && TSDB_DATA_TYPE_BINARY == (*pExpr)->pVal->nType) { - ret = setColumnFilterInfoForTimestamp(pCmd, pQueryInfo, (*pExpr)->pVal); + STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, pQueryInfo->curTableIdx)->pTableMeta; + if (pCols != NULL) { + size_t colSize = taosArrayGetSize(pCols); + + if (colSize > 0) { + SColIndex* idx = taosArrayGet(pCols, colSize - 1); + SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex); + // convert time by precision + if (pSchema != NULL && TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && TSDB_DATA_TYPE_BINARY == (*pExpr)->pVal->nType) { + ret = setColumnFilterInfoForTimestamp(pCmd, pQueryInfo, (*pExpr)->pVal); + } } } return ret; @@ -9258,8 +9015,18 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS (*pExpr)->nodeType = TSQL_NODE_COL; (*pExpr)->pSchema = calloc(1, sizeof(SSchema)); - SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); - *(*pExpr)->pSchema = *pSchema; + SSchema* pSchema = NULL; + + if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { + pSchema = (*pExpr)->pSchema; + strcpy(pSchema->name, TSQL_TBNAME_L); + pSchema->type = TSDB_DATA_TYPE_BINARY; + pSchema->colId = TSDB_TBNAME_COLUMN_INDEX; + pSchema->bytes = -1; + } else { + pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); + *(*pExpr)->pSchema = *pSchema; + } if (pCols != NULL) { // record the involved columns SColIndex colIndex = {0}; @@ -9280,9 +9047,13 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS if (colSize > 0) { SColIndex* idx = taosArrayGet(pCols, colSize - 1); - SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex); - if (pSchema != NULL) { - colType = pSchema->type; + if (idx->colIndex == TSDB_TBNAME_COLUMN_INDEX) { + colType = TSDB_DATA_TYPE_BINARY; + } else { + SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex); + if (pSchema != NULL) { + colType = pSchema->type; + } } } } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index b87ec92ff1f056fdc5eeb8992cec418d07158b0b..dcfbc857d5d6792b3796a098ea61046439fc5d0f 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -703,11 +703,6 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql) { } } - SCond* pCond = &pQueryInfo->tagCond.tbnameCond; - if (pCond->len > 0) { - srcColListSize += pCond->len; - } - return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + srcColFilterSize + srcTagFilterSize + exprSize + tsBufSize + tableSerialize + sqlLen + 4096 + pQueryInfo->bufLen; } @@ -956,8 +951,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pQueryMsg->numOfOutput = htons((int16_t)query.numOfOutput); // this is the stage one output column number pQueryMsg->numOfGroupCols = htons(pQueryInfo->groupbyExpr.numOfGroupCols); - pQueryMsg->tagNameRelType = htons(pQueryInfo->tagCond.relType); - pQueryMsg->tbnameCondLen = htonl(pQueryInfo->tagCond.tbnameCond.len); pQueryMsg->queryType = htonl(pQueryInfo->type); pQueryMsg->prevResultLen = htonl(pQueryInfo->bufLen); @@ -1076,12 +1069,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pMsg += pQueryInfo->bufLen; } - SCond* pCond = &pQueryInfo->tagCond.tbnameCond; - if (pCond->len > 0) { - strncpy(pMsg, pCond->cond, pCond->len); - pMsg += pCond->len; - } - // compressed ts block pQueryMsg->tsBuf.tsOffset = htonl((int32_t)(pMsg - pCmd->payload)); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 275042a238dc9bd580ff5d09b8e85874b9031031..99a2a79dc60c89530eb9c2c7f6b5645ca0133ba1 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1347,7 +1347,11 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow pCmd->command = TSDB_SQL_SELECT; tscResetForNextRetrieve(&pSql->res); - assert(pSupporter->f == NULL); + if (pSupporter->f != NULL) { + fclose(pSupporter->f); + pSupporter->f = NULL; + } + taosGetTmpfilePath("ts-join", pSupporter->path); // TODO check for failure diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 8af340030cccee1431a82eb88344642011f2e019..b3b83db80a70c19f79d1cd6a732d729817436dd3 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -50,6 +50,7 @@ int tscLogFileNum = 10; static pthread_mutex_t rpcObjMutex; // mutex to protect open the rpc obj concurrently static pthread_once_t tscinit = PTHREAD_ONCE_INIT; +static pthread_mutex_t setConfMutex = PTHREAD_MUTEX_INITIALIZER; // pthread_once can not return result code, so result code is set to a global variable. static volatile int tscInitRes = 0; @@ -249,6 +250,7 @@ void taos_cleanup(void) { pthread_mutex_destroy(&rpcObjMutex); } + pthread_mutex_destroy(&setConfMutex); taosCacheCleanup(tscVgroupListBuf); tscVgroupListBuf = NULL; @@ -437,3 +439,66 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) { atomic_store_32(&lock, 0); return ret; } + +#include "cJSON.h" +static setConfRet taos_set_config_imp(const char *config){ + setConfRet ret = {SET_CONF_RET_SUCC, {0}}; + static bool setConfFlag = false; + if (setConfFlag) { + ret.retCode = SET_CONF_RET_ERR_ONLY_ONCE; + strcpy(ret.retMsg, "configuration can only set once"); + return ret; + } + taosInitGlobalCfg(); + cJSON *root = cJSON_Parse(config); + if (root == NULL){ + ret.retCode = SET_CONF_RET_ERR_JSON_PARSE; + strcpy(ret.retMsg, "parse json error"); + return ret; + } + + int size = cJSON_GetArraySize(root); + if(!cJSON_IsObject(root) || size == 0) { + ret.retCode = SET_CONF_RET_ERR_JSON_INVALID; + strcpy(ret.retMsg, "json content is invalid, must be not empty object"); + return ret; + } + + if(size >= 1000) { + ret.retCode = SET_CONF_RET_ERR_TOO_LONG; + strcpy(ret.retMsg, "json object size is too long"); + return ret; + } + + for(int i = 0; i < size; i++){ + cJSON *item = cJSON_GetArrayItem(root, i); + if(!item) { + ret.retCode = SET_CONF_RET_ERR_INNER; + strcpy(ret.retMsg, "inner error"); + return ret; + } + if(!taosReadConfigOption(item->string, item->valuestring, NULL, NULL, TAOS_CFG_CSTATUS_OPTION, TSDB_CFG_CTYPE_B_CLIENT)){ + ret.retCode = SET_CONF_RET_ERR_PART; + if (strlen(ret.retMsg) == 0){ + snprintf(ret.retMsg, RET_MSG_LENGTH, "part error|%s", item->string); + }else{ + int tmp = RET_MSG_LENGTH - 1 - (int)strlen(ret.retMsg); + size_t leftSize = tmp >= 0 ? tmp : 0; + strncat(ret.retMsg, "|", leftSize); + tmp = RET_MSG_LENGTH - 1 - (int)strlen(ret.retMsg); + leftSize = tmp >= 0 ? tmp : 0; + strncat(ret.retMsg, item->string, leftSize); + } + } + } + cJSON_Delete(root); + setConfFlag = true; + return ret; +} + +setConfRet taos_set_config(const char *config){ + pthread_mutex_lock(&setConfMutex); + setConfRet ret = taos_set_config_imp(config); + pthread_mutex_unlock(&setConfMutex); + return ret; +} diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 2bd601d812294ea311e30fece732d1e1c2c533ec..60a6e241ccdfd48c7eb5a68f2dd7a251f76097a5 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -269,7 +269,10 @@ bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex) { functionId != TSDB_FUNC_DIFF && functionId != TSDB_FUNC_DERIVATIVE && functionId != TSDB_FUNC_TS_DUMMY && - functionId != TSDB_FUNC_TID_TAG) { + functionId != TSDB_FUNC_TID_TAG && + functionId != TSDB_FUNC_CEIL && + functionId != TSDB_FUNC_FLOOR && + functionId != TSDB_FUNC_ROUND) { return false; } } @@ -811,7 +814,7 @@ typedef struct SDummyInputInfo { SSDataBlock *block; STableQueryInfo *pTableQueryInfo; SSqlObj *pSql; // refactor: remove it - SFilterInfo *pFilterInfo; + void *pFilterInfo; } SDummyInputInfo; typedef struct SJoinStatus { @@ -827,7 +830,7 @@ typedef struct SJoinOperatorInfo { SRspResultInfo resultInfo; // todo refactor, add this info for each operator } SJoinOperatorInfo; -static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, SFilterInfo* pFilterInfo) { +static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, void* pFilterInfo) { int32_t offset = 0; char* pData = pRes->data; @@ -844,8 +847,9 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, SFilterInfo* p // filter data if needed if (pFilterInfo) { - //doSetFilterColumnInfo(pFilterInfo, numOfFilterCols, pBlock); - filterSetColFieldData(pFilterInfo, pBlock->info.numOfCols, pBlock->pDataBlock); + SColumnDataParam param = {.numOfCols = pBlock->info.numOfCols, .pDataBlock = pBlock->pDataBlock}; + filterSetColFieldData(pFilterInfo, ¶m, getColumnDataFromId); + bool gotNchar = false; filterConverNcharColumns(pFilterInfo, pBlock->info.rows, &gotNchar); int8_t* p = NULL; @@ -1108,7 +1112,7 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) { } // todo this operator servers as the adapter for Operator tree and SqlRes result, remove it later -SOperatorInfo* createDummyInputOperator(SSqlObj* pSql, SSchema* pSchema, int32_t numOfCols, SFilterInfo* pFilters) { +SOperatorInfo* createDummyInputOperator(SSqlObj* pSql, SSchema* pSchema, int32_t numOfCols, void* pFilters) { assert(numOfCols > 0); STimeWindow win = {.skey = INT64_MIN, .ekey = INT64_MAX}; @@ -1250,7 +1254,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue // if it is a join query, create join operator here int32_t numOfCol1 = pTableMeta->tableInfo.numOfColumns; - SFilterInfo *pFilters = NULL; + void *pFilters = NULL; STblCond *pCond = NULL; if (px->colCond) { pCond = tsGetTableFilter(px->colCond, pTableMeta->id.uid, 0); @@ -1277,7 +1281,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue for(int32_t i = 1; i < px->numOfTables; ++i) { STableMeta* pTableMeta1 = tscGetMetaInfo(px, i)->pTableMeta; numOfCol1 = pTableMeta1->tableInfo.numOfColumns; - SFilterInfo *pFilters1 = NULL; + void *pFilters1 = NULL; SSchema* pSchema1 = tscGetTableSchema(pTableMeta1); int32_t n = pTableMeta1->tableInfo.numOfColumns; @@ -1465,7 +1469,12 @@ void tscFreeSubobj(SSqlObj* pSql) { tscDebug("0x%"PRIx64" start to free sub SqlObj, numOfSub:%d", pSql->self, pSql->subState.numOfSub); for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { - tscDebug("0x%"PRIx64" free sub SqlObj:0x%"PRIx64", index:%d", pSql->self, pSql->pSubs[i]->self, i); + if (pSql->pSubs[i] != NULL) { + tscDebug("0x%"PRIx64" free sub SqlObj:0x%"PRIx64", index:%d", pSql->self, pSql->pSubs[i]->self, i); + } else { + /* just for python error test case */ + tscDebug("0x%"PRIx64" free sub SqlObj:0x0, index:%d", pSql->self, i); + } taos_free_result(pSql->pSubs[i]); pSql->pSubs[i] = NULL; } @@ -2898,16 +2907,6 @@ bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) { memset(dest, 0, sizeof(STagCond)); - if (src->tbnameCond.cond != NULL) { - dest->tbnameCond.cond = strdup(src->tbnameCond.cond); - if (dest->tbnameCond.cond == NULL) { - return -1; - } - } - - dest->tbnameCond.uid = src->tbnameCond.uid; - dest->tbnameCond.len = src->tbnameCond.len; - dest->joinInfo.hasJoin = src->joinInfo.hasJoin; for (int32_t i = 0; i < TSDB_MAX_JOIN_TABLE_NUM; ++i) { @@ -2926,9 +2925,6 @@ int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) { } } - - dest->relType = src->relType; - if (src->pCond == NULL) { return 0; } @@ -3018,8 +3014,6 @@ void tscColCondRelease(SArray** pCond) { void tscTagCondRelease(STagCond* pTagCond) { - free(pTagCond->tbnameCond.cond); - if (pTagCond->pCond != NULL) { size_t s = taosArrayGetSize(pTagCond->pCond); for (int32_t i = 0; i < s; ++i) { diff --git a/src/client/tests/CMakeLists.txt b/src/client/tests/CMakeLists.txt index 24bfb44ac90e11e01ba99423aa68bd5a9511f746..5de18942acbb5b3ac59d2496728c500b63246fe9 100644 --- a/src/client/tests/CMakeLists.txt +++ b/src/client/tests/CMakeLists.txt @@ -17,5 +17,5 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) ADD_EXECUTABLE(cliTest ${SOURCE_LIST}) - TARGET_LINK_LIBRARIES(cliTest taos tutil common gtest pthread) + TARGET_LINK_LIBRARIES(cliTest taos cJson tutil common gtest pthread) ENDIF() diff --git a/src/client/tests/setConfigTest.cpp b/src/client/tests/setConfigTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fb016715f6ad2f5311aa2d81b608c2043f86c4f0 --- /dev/null +++ b/src/client/tests/setConfigTest.cpp @@ -0,0 +1,71 @@ +#include +#include + +#include "taos.h" +#include "tglobal.h" +#include "tconfig.h" + +/* test set config function */ +TEST(testCase, set_config_test1) { + const char *config = "{\"debugFlag\":\"131\"}"; + setConfRet ret = taos_set_config(config); + ASSERT_EQ(ret.retCode, 0); + printf("msg:%d->%s", ret.retCode, ret.retMsg); + + const char *config2 = "{\"debugFlag\":\"199\"}"; + ret = taos_set_config(config2); // not take effect + ASSERT_EQ(ret.retCode, -5); + printf("msg:%d->%s", ret.retCode, ret.retMsg); + + bool readResult = taosReadGlobalCfg(); // load file config, debugFlag not take effect + ASSERT_TRUE(readResult); + int32_t checkResult = taosCheckGlobalCfg(); + ASSERT_EQ(checkResult, 0); + + SGlobalCfg *cfg = taosGetConfigOption("debugFlag"); + ASSERT_EQ(cfg->cfgStatus, TAOS_CFG_CSTATUS_OPTION); + int32_t result = *(int32_t *)cfg->ptr; + ASSERT_EQ(result, 131); +} + +TEST(testCase, set_config_test2) { + const char *config = "{\"numOfCommitThreads\":\"10\"}"; + taos_set_config(config); + + bool readResult = taosReadGlobalCfg(); // load file config, debugFlag not take effect + ASSERT_TRUE(readResult); + int32_t checkResult = taosCheckGlobalCfg(); + ASSERT_EQ(checkResult, 0); + + SGlobalCfg *cfg = taosGetConfigOption("numOfCommitThreads"); + int32_t result = *(int32_t*)cfg->ptr; + ASSERT_NE(result, 10); // numOfCommitThreads not type of TSDB_CFG_CTYPE_B_CLIENT +} + +TEST(testCase, set_config_test3) { + const char *config = "{\"numOfCoitThreads\":\"10\", \"esdfa\":\"10\"}"; + setConfRet ret = taos_set_config(config); + ASSERT_EQ(ret.retCode, -1); + printf("msg:%d->%s", ret.retCode, ret.retMsg); +} + +TEST(testCase, set_config_test4) { + const char *config = "{null}"; + setConfRet ret = taos_set_config(config); + ASSERT_EQ(ret.retCode, -4); + printf("msg:%d->%s", ret.retCode, ret.retMsg); +} + +TEST(testCase, set_config_test5) { + const char *config = "\"ddd\""; + setConfRet ret = taos_set_config(config); + ASSERT_EQ(ret.retCode, -3); + printf("msg:%d->%s", ret.retCode, ret.retMsg); +} + +TEST(testCase, set_config_test6) { + const char *config = "{\"numOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitT3333dd\":\"10\", \"esdfa\":\"10\"}"; + setConfRet ret = taos_set_config(config); + ASSERT_EQ(ret.retCode, -1); + printf("msg:%d->%s", ret.retCode, ret.retMsg); +} diff --git a/src/common/inc/texpr.h b/src/common/inc/texpr.h index 0ede2e1e6f71c69aa6aaed2c05d671840679ce5c..bfeb3a6dfeee22f793c82748611c28ec537e8825 100644 --- a/src/common/inc/texpr.h +++ b/src/common/inc/texpr.h @@ -88,7 +88,6 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)); void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); tExprNode* exprTreeFromBinary(const void* data, size_t size); -tExprNode* exprTreeFromTableName(const char* tbnameCond); tExprNode* exprdup(tExprNode* pTree); void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 38f8721f5f28927d164859e3e522da5b66735c83..cd30e707be6101591063a3970e9fe2bfe6e3b58d 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -218,7 +218,7 @@ extern int32_t cqDebugFlag; extern int32_t debugFlag; #ifdef TD_TSZ -// lossy +// lossy extern char lossyColumns[]; extern double fPrecision; extern double dPrecision; @@ -226,9 +226,12 @@ extern uint32_t maxRange; extern uint32_t curRange; extern char Compressor[]; #endif -// long query +// long query extern int8_t tsDeadLockKillQuery; +// schemaless +extern char tsDefaultJSONStrType[]; + typedef struct { char dir[TSDB_FILENAME_LEN]; int level; diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 6823de631fe65a27f527be011def4819dd77c73a..cc2bb8803badc2aae2e80200691be0439bac3afe 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -325,14 +325,6 @@ static void* exception_calloc(size_t nmemb, size_t size) { return p; } -static void* exception_malloc(size_t size) { - void* p = malloc(size); - if (p == NULL) { - THROW(TSDB_CODE_QRY_OUT_OF_MEMORY); - } - return p; -} - static UNUSED_FUNC char* exception_strdup(const char* str) { char* p = strdup(str); if (p == NULL) { @@ -395,97 +387,6 @@ tExprNode* exprTreeFromBinary(const void* data, size_t size) { return exprTreeFromBinaryImpl(&br); } -tExprNode* exprTreeFromTableName(const char* tbnameCond) { - if (!tbnameCond) { - return NULL; - } - - int32_t anchor = CLEANUP_GET_ANCHOR(); - - tExprNode* expr = exception_calloc(1, sizeof(tExprNode)); - CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, expr, NULL); - - expr->nodeType = TSQL_NODE_EXPR; - - tExprNode* left = exception_calloc(1, sizeof(tExprNode)); - expr->_node.pLeft = left; - - left->nodeType = TSQL_NODE_COL; - SSchema* pSchema = exception_calloc(1, sizeof(SSchema)); - left->pSchema = pSchema; - - *pSchema = *tGetTbnameColumnSchema(); - - tExprNode* right = exception_calloc(1, sizeof(tExprNode)); - expr->_node.pRight = right; - - if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_LIKE, QUERY_COND_REL_PREFIX_LIKE_LEN) == 0) { - right->nodeType = TSQL_NODE_VALUE; - expr->_node.optr = TSDB_RELATION_LIKE; - tVariant* pVal = exception_calloc(1, sizeof(tVariant)); - right->pVal = pVal; - size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_LIKE_LEN) + 1; - pVal->pz = exception_malloc(len); - memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_LIKE_LEN, len); - pVal->nType = TSDB_DATA_TYPE_BINARY; - pVal->nLen = (int32_t)len; - - } else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_MATCH, QUERY_COND_REL_PREFIX_MATCH_LEN) == 0) { - right->nodeType = TSQL_NODE_VALUE; - expr->_node.optr = TSDB_RELATION_MATCH; - tVariant* pVal = exception_calloc(1, sizeof(tVariant)); - right->pVal = pVal; - size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_MATCH_LEN) + 1; - pVal->pz = exception_malloc(len); - memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_MATCH_LEN, len); - pVal->nType = TSDB_DATA_TYPE_BINARY; - pVal->nLen = (int32_t)len; - } else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_NMATCH, QUERY_COND_REL_PREFIX_NMATCH_LEN) == 0) { - right->nodeType = TSQL_NODE_VALUE; - expr->_node.optr = TSDB_RELATION_NMATCH; - tVariant* pVal = exception_calloc(1, sizeof(tVariant)); - right->pVal = pVal; - size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_NMATCH_LEN) + 1; - pVal->pz = exception_malloc(len); - memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_NMATCH_LEN, len); - pVal->nType = TSDB_DATA_TYPE_BINARY; - pVal->nLen = (int32_t)len; - } else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN) == 0) { - right->nodeType = TSQL_NODE_VALUE; - expr->_node.optr = TSDB_RELATION_IN; - tVariant* pVal = exception_calloc(1, sizeof(tVariant)); - right->pVal = pVal; - pVal->nType = TSDB_DATA_TYPE_POINTER_ARRAY; - pVal->arr = taosArrayInit(2, POINTER_BYTES); - - const char* cond = tbnameCond + QUERY_COND_REL_PREFIX_IN_LEN; - for (const char *e = cond; *e != 0; e++) { - if (*e == TS_PATH_DELIMITER[0]) { - cond = e + 1; - } else if (*e == ',') { - size_t len = e - cond; - char* p = exception_malloc(len + VARSTR_HEADER_SIZE); - STR_WITH_SIZE_TO_VARSTR(p, cond, (VarDataLenT)len); - cond += len; - taosArrayPush(pVal->arr, &p); - } - } - - if (*cond != 0) { - size_t len = strlen(cond) + VARSTR_HEADER_SIZE; - - char* p = exception_malloc(len); - STR_WITH_SIZE_TO_VARSTR(p, cond, (VarDataLenT)(len - VARSTR_HEADER_SIZE)); - taosArrayPush(pVal->arr, &p); - } - - taosArraySortString(pVal->arr, taosArrayCompareString); - } - - CLEANUP_EXECUTE_TO(anchor, false); - return expr; -} - void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) { SBufferReader br = tbufInitReader(buf, len, false); uint32_t type = tbufReadUint32(&br); diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index b0469aae1254be05799165702b5a90110c9f0ed3..acfceb792b5b5438d5cd97ac6549a1e83eba7f23 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -284,6 +284,9 @@ char Compressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESS // long query death-lock int8_t tsDeadLockKillQuery = 0; +// default JSON string type +char tsDefaultJSONStrType[7] = "binary"; + int32_t (*monStartSystemFp)() = NULL; void (*monStopSystemFp)() = NULL; void (*monExecuteSQLFp)(char *sql) = NULL; @@ -1639,6 +1642,17 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + // default JSON string type option "binary"/"nchar" + cfg.option = "defaultJSONStrType"; + cfg.ptr = tsDefaultJSONStrType; + cfg.valType = TAOS_CFG_VTYPE_STRING; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = 0; + cfg.maxValue = 0; + cfg.ptrLength = tListLen(tsDefaultJSONStrType); + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + #ifdef TD_TSZ // lossy compress cfg.option = "lossyColumns"; diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt index e432dac1cea593b371a173f334e5313236091ab3..1e5cede714820f29defe3c6b458b2daf467bc4d2 100644 --- a/src/connector/jdbc/CMakeLists.txt +++ b/src/connector/jdbc/CMakeLists.txt @@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED) ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME} POST_BUILD COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.34-dist.jar ${LIBRARY_OUTPUT_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.35-dist.jar ${LIBRARY_OUTPUT_PATH} COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMENT "build jdbc driver") ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME}) diff --git a/src/connector/jdbc/deploy-pom.xml b/src/connector/jdbc/deploy-pom.xml index ef57198e78d2268faba526d5506b0dc384f5766f..7caf46848d18c4491cdea1ab50df31d8d2d26daf 100755 --- a/src/connector/jdbc/deploy-pom.xml +++ b/src/connector/jdbc/deploy-pom.xml @@ -5,7 +5,7 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.34 + 2.0.35 jar JDBCDriver diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index 256fa614e0bd0a88e0c676a3ae13c9c177eb5215..810a85f8a33b3f244dab81e349b9df786ec50c21 100644 --- a/src/connector/jdbc/pom.xml +++ b/src/connector/jdbc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.taosdata.jdbc taos-jdbcdriver - 2.0.34 + 2.0.35 jar JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java index 521a88b128ff930510bf00cdcb6a12cbc3211742..307451e014c59c1c3419f1a9daff4f89e8b90d46 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java @@ -118,9 +118,6 @@ public class TSDBDriver extends AbstractDriver { } public Connection connect(String url, Properties info) throws SQLException { - if (url == null) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_URL_NOT_SET); - if (!acceptsURL(url)) return null; @@ -135,8 +132,7 @@ public class TSDBDriver extends AbstractDriver { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PASSWORD_IS_REQUIRED); try { - TSDBJNIConnector.init((String) props.get(PROPERTY_KEY_CONFIG_DIR), (String) props.get(PROPERTY_KEY_LOCALE), - (String) props.get(PROPERTY_KEY_CHARSET), (String) props.get(PROPERTY_KEY_TIME_ZONE)); + TSDBJNIConnector.init(props); return new TSDBConnection(props, this.dbMetaData); } catch (SQLWarning sqlWarning) { sqlWarning.printStackTrace(); @@ -205,6 +201,7 @@ public class TSDBDriver extends AbstractDriver { String dbProductName = url.substring(0, beginningOfSlashes); dbProductName = dbProductName.substring(dbProductName.indexOf(":") + 1); dbProductName = dbProductName.substring(0, dbProductName.indexOf(":")); + urlProps.setProperty(TSDBDriver.PROPERTY_KEY_PRODUCT_NAME, dbProductName); // parse database name url = url.substring(beginningOfSlashes + 2); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java index bdb3ea410005cadd865de1d9e080dd5b9f20834f..0970148b1dfb6c6c1fb85330e312bf2c8168b3c7 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java @@ -35,6 +35,7 @@ public class TSDBError { TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN_TIMESTAMP_PRECISION, "unknown timestamp precision"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_USER_IS_REQUIRED, "user is required"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_PASSWORD_IS_REQUIRED, "password is required"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_JSON_FORMAT, "invalid json format"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown error"); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java index 2207db6f9379595e68b8ed00ea8f7298ca3b45ad..0f4427fa20e272917df0327552efd1a80cd56b4d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java @@ -31,6 +31,7 @@ public class TSDBErrorNumbers { public static final int ERROR_RESTFul_Client_IOException = 0x2318; public static final int ERROR_USER_IS_REQUIRED = 0x2319; // user is required public static final int ERROR_PASSWORD_IS_REQUIRED = 0x231a; // password is required + public static final int ERROR_INVALID_JSON_FORMAT = 0x231b; public static final int ERROR_UNKNOWN = 0x2350; //unknown error @@ -72,6 +73,7 @@ public class TSDBErrorNumbers { errorNumbers.add(ERROR_RESTFul_Client_IOException); errorNumbers.add(ERROR_USER_IS_REQUIRED); errorNumbers.add(ERROR_PASSWORD_IS_REQUIRED); + errorNumbers.add(ERROR_INVALID_JSON_FORMAT); errorNumbers.add(ERROR_RESTFul_Client_Protocol_Exception); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBException.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBException.java new file mode 100644 index 0000000000000000000000000000000000000000..31299a1c6f37a8b75521a65e7de09f5162558dd6 --- /dev/null +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBException.java @@ -0,0 +1,22 @@ +package com.taosdata.jdbc; + +public class TSDBException { + private int code; + private String message; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} \ No newline at end of file diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java index 4a9e80ba53b096f057840eab67e61418332dbf81..aaada2e78ec284f4019b29465a38db109cf9d80a 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java @@ -16,18 +16,21 @@ */ package com.taosdata.jdbc; +import com.alibaba.fastjson.JSONObject; import com.taosdata.jdbc.utils.TaosInfo; import java.nio.ByteBuffer; import java.sql.SQLException; import java.sql.SQLWarning; import java.util.List; +import java.util.Properties; /** * JNI connector */ public class TSDBJNIConnector { - private static volatile Boolean isInitialized = false; + private static final Object LOCK = new Object(); + private static volatile boolean isInitialized; private final TaosInfo taosInfo = TaosInfo.getInstance(); private long taos = TSDBConstants.JNI_NULL_POINTER; // Connection pointer used in C @@ -38,24 +41,27 @@ public class TSDBJNIConnector { System.loadLibrary("taos"); } - public boolean isClosed() { - return this.taos == TSDBConstants.JNI_NULL_POINTER; - } + public static void init(Properties props) throws SQLWarning { + synchronized (LOCK) { + if (!isInitialized) { - public boolean isResultsetClosed() { - return this.isResultsetClosed; - } + JSONObject configJSON = new JSONObject(); + for (String key : props.stringPropertyNames()) { + configJSON.put(key, props.getProperty(key)); + } + setConfigImp(configJSON.toJSONString()); - public static void init(String configDir, String locale, String charset, String timezone) throws SQLWarning { - synchronized (isInitialized) { - if (!isInitialized) { - initImp(configDir); + initImp(props.getProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR, null)); + + String locale = props.getProperty(TSDBDriver.PROPERTY_KEY_LOCALE); if (setOptions(0, locale) < 0) { throw TSDBError.createSQLWarning("Failed to set locale: " + locale + ". System default will be used."); } + String charset = props.getProperty(TSDBDriver.PROPERTY_KEY_CHARSET); if (setOptions(1, charset) < 0) { throw TSDBError.createSQLWarning("Failed to set charset: " + charset + ". System default will be used."); } + String timezone = props.getProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE); if (setOptions(2, timezone) < 0) { throw TSDBError.createSQLWarning("Failed to set timezone: " + timezone + ". System default will be used."); } @@ -65,11 +71,13 @@ public class TSDBJNIConnector { } } - public static native void initImp(String configDir); + private static native void initImp(String configDir); + + private static native int setOptions(int optionIndex, String optionValue); - public static native int setOptions(int optionIndex, String optionValue); + private static native String getTsCharset(); - public static native String getTsCharset(); + private static native TSDBException setConfigImp(String config); public boolean connect(String host, int port, String dbName, String user, String password) throws SQLException { if (this.taos != TSDBConstants.JNI_NULL_POINTER) { @@ -159,6 +167,14 @@ public class TSDBJNIConnector { private native long isUpdateQueryImp(long connection, long pSql); + public boolean isClosed() { + return this.taos == TSDBConstants.JNI_NULL_POINTER; + } + + public boolean isResultsetClosed() { + return this.isResultsetClosed; + } + /** * Free result set operation from C to release result set pointer by JNI */ @@ -351,4 +367,6 @@ public class TSDBJNIConnector { } private native int insertLinesImp(String[] lines, long conn); + + } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java new file mode 100644 index 0000000000000000000000000000000000000000..6a983cd5bdd6d886dcac01f6085c70eade4f7cf5 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java @@ -0,0 +1,249 @@ +package com.taosdata.jdbc; + +import org.junit.Test; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + + +public class SetConfigurationInJNITest { + + private String host = "127.0.0.1"; + private String dbname = "test_set_config"; + + @Test + public void setConfigInUrl() { + try { + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata&debugFlag=143&rpcTimer=500"); + Statement stmt = conn.createStatement(); + + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Test + public void setConfigInProperties() { + try { + Properties props = new Properties(); + props.setProperty("debugFlag", "143"); + props.setProperty("r pcTimer", "500"); + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", props); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Test + //test case1:set debugFlag=135 + //expect:debugFlag:135 + //result:pass + public void setConfigfordebugFlag() { + try { + Properties props = new Properties(); + //set debugFlag=135 + props.setProperty("debugFlag", "135"); + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", props); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + @Test + //test case2:set debugFlag=abc (wrong type) + //expect:debugFlag:135 + //result:pass + public void setConfigforwrongtype() { + try { + Properties props = new Properties(); + //set debugFlag=135 + props.setProperty("debugFlag", "abc"); + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", props); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + @Test + //test case3:set rpcTimer=0 (smaller than the boundary conditions) + //expect:rpcTimer:300 + //result:pass + public void setConfigrpcTimer() { + try { + Properties props = new Properties(); + //set rpcTimer=0 + props.setProperty("rpcTimer", "0"); + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", props); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + @Test + //test case4:set rpcMaxTime=10000 (bigger than the boundary conditions) + //expect:rpcMaxTime:600 + //result:pass + public void setConfigforrpcMaxTime() { + try { + Properties props = new Properties(); + //set rpcMaxTime=10000 + props.setProperty("rpcMaxTime", "10000"); + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", props); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + @Test + //test case5:set numOfThreadsPerCore=aaa (wrong type) + //expect:numOfThreadsPerCore:1.0 + //result:pass + public void setConfigfornumOfThreadsPerCore() { + try { + Properties props = new Properties(); + //set numOfThreadsPerCore=aaa + props.setProperty("numOfThreadsPerCore", "aaa"); + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", props); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + @Test + //test case6:set numOfThreadsPerCore=100000 (bigger than the boundary conditions) + //expect:numOfThreadsPerCore:1.0 + //result:pass + public void setConfignumOfThreadsPerCore() { + try { + Properties props = new Properties(); + //set numOfThreadsPerCore=100000 + props.setProperty("numOfThreadsPerCore", "100000"); + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", props); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + @Test + // test case7:set both true and wrong config(debugFlag=0,rpcDebugFlag=143,cDebugFlag=143,rpcTimer=100000) + // expect:rpcDebugFlag:143,cDebugFlag:143,rpcTimer:300 + // result:pass + public void setConfigformaxTmrCtrl() { + try { + Properties props = new Properties(); + props.setProperty("debugFlag", "0"); + props.setProperty("rpcDebugFlag", "143"); + props.setProperty("cDebugFlag", "143"); + props.setProperty("rpcTimer", "100000"); + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", props); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + @Test + //test case 8:use url to set with wrong type(debugFlag=abc,rpcTimer=abc) + //expect:default value + //result:pass + public void setConfigInUrlwithwrongtype() { + try { + Connection conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata&debugFlag=abc&rpcTimer=abc"); + Statement stmt = conn.createStatement(); + + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + stmt.execute("drop database if exists " + dbname); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java index 88ff5d3a811e17aaabbeb0a451fbff010307ab6d..8be6ae6b1c566abcd7ec398e7df3f5308e29e1b1 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java @@ -5,9 +5,9 @@ import org.junit.Test; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.sql.SQLException; -import java.sql.SQLWarning; import java.util.ArrayList; import java.util.List; +import java.util.Properties; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -19,25 +19,25 @@ public class TSDBJNIConnectorTest { @Test public void test() { try { - try { //change sleepSeconds when debugging with attach to process to find PID int sleepSeconds = -1; - if (sleepSeconds>0) { + if (sleepSeconds > 0) { RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); String jvmName = runtimeBean.getName(); long pid = Long.valueOf(jvmName.split("@")[0]); System.out.println("JVM PID = " + pid); - Thread.sleep(sleepSeconds*1000); + Thread.sleep(sleepSeconds * 1000); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } // init - TSDBJNIConnector.init("/etc/taos", null, null, null); + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR, "/etc/taos"); + TSDBJNIConnector.init(properties); // connect TSDBJNIConnector connector = new TSDBJNIConnector(); @@ -45,12 +45,12 @@ public class TSDBJNIConnectorTest { // setup String setupSqlStrs[] = {"create database if not exists d precision \"us\"", - "create table if not exists d.t(ts timestamp, f int)", - "create database if not exists d2", - "create table if not exists d2.t2(ts timestamp, f int)", - "insert into d.t values(now+100s, 100)", - "insert into d2.t2 values(now+200s, 200)" - }; + "create table if not exists d.t(ts timestamp, f int)", + "create database if not exists d2", + "create table if not exists d2.t2(ts timestamp, f int)", + "insert into d.t values(now+100s, 100)", + "insert into d2.t2 values(now+200s, 200)" + }; for (String setupSqlStr : setupSqlStrs) { long setupSql = connector.executeQuery(setupSqlStr); @@ -115,15 +115,13 @@ public class TSDBJNIConnectorTest { } // close statement connector.executeQuery("use d"); - String[] lines = new String[] {"st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", - "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns"}; + String[] lines = new String[]{"st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns", + "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns"}; connector.insertLines(lines); // close connection connector.closeConnection(); - } catch (SQLWarning throwables) { - throwables.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } @@ -140,11 +138,7 @@ public class TSDBJNIConnectorTest { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL); } else if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0); - } else if (code == TSDBConstants.JNI_FETCH_END) { - return false; - } else { - return true; - } + } else return code != TSDBConstants.JNI_FETCH_END; } } diff --git a/src/connector/python/taos/field.py b/src/connector/python/taos/field.py index 445cd8afdba6f2512c73be95c9b0dbd8dc00da8a..b0bec58b932f2136b868739bb28fca04de759e3f 100644 --- a/src/connector/python/taos/field.py +++ b/src/connector/python/taos/field.py @@ -165,12 +165,14 @@ def _crow_binary_to_python_block(data, num_of_rows, nbytes=None, precision=Field assert nbytes is not None res = [] for i in range(abs(num_of_rows)): - try: - rbyte = ctypes.cast(data + nbytes * i, ctypes.POINTER(ctypes.c_short))[:1].pop() - tmpstr = ctypes.c_char_p(data + nbytes * i + 2) - res.append(tmpstr.value.decode()[0:rbyte]) - except ValueError: + rbyte = ctypes.cast(data + nbytes * i, ctypes.POINTER(ctypes.c_short))[:1].pop() + chars = ctypes.cast(c_char_p(data + nbytes * i + 2), ctypes.POINTER(c_char * rbyte)) + buffer = create_string_buffer(rbyte + 1) + buffer[:rbyte] = chars[0][:rbyte] + if rbyte == 1 and buffer[0] == b'\xff': res.append(None) + else: + res.append(cast(buffer, c_char_p).value.decode()) return res @@ -179,11 +181,14 @@ def _crow_nchar_to_python_block(data, num_of_rows, nbytes=None, precision=FieldT assert nbytes is not None res = [] for i in range(abs(num_of_rows)): - try: - tmpstr = ctypes.c_char_p(data + nbytes * i + 2) - res.append(tmpstr.value.decode()) - except ValueError: + rbyte = ctypes.cast(data + nbytes * i, ctypes.POINTER(ctypes.c_short))[:1].pop() + chars = ctypes.cast(c_char_p(data + nbytes * i + 2), ctypes.POINTER(c_char * rbyte)) + buffer = create_string_buffer(rbyte + 1) + buffer[:rbyte] = chars[0][:rbyte] + if rbyte == 4 and buffer[:4] == b'\xff'*4: res.append(None) + else: + res.append(cast(buffer, c_char_p).value.decode()) return res diff --git a/src/inc/taos.h b/src/inc/taos.h index edb1552b811a2ff4b8c78c19523cc6f2ad82ba74..be5123797069696ffad817c0db7bc2c8c03e9606 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -62,6 +62,22 @@ typedef struct taosField { int16_t bytes; } TAOS_FIELD; +typedef enum { + SET_CONF_RET_SUCC = 0, + SET_CONF_RET_ERR_PART = -1, + SET_CONF_RET_ERR_INNER = -2, + SET_CONF_RET_ERR_JSON_INVALID = -3, + SET_CONF_RET_ERR_JSON_PARSE = -4, + SET_CONF_RET_ERR_ONLY_ONCE = -5, + SET_CONF_RET_ERR_TOO_LONG = -6 +} SET_CONF_RET_CODE; + +#define RET_MSG_LENGTH 1024 +typedef struct setConfRet { + SET_CONF_RET_CODE retCode; + char retMsg[RET_MSG_LENGTH]; +} setConfRet; + #ifdef _TD_GO_DLL_ #define DLL_EXPORT __declspec(dllexport) #else @@ -71,6 +87,7 @@ typedef struct taosField { DLL_EXPORT int taos_init(); DLL_EXPORT void taos_cleanup(void); DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...); +DLL_EXPORT setConfRet taos_set_config(const char *config); DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port); DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port); DLL_EXPORT void taos_close(TAOS *taos); diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 993a2f71519421d2179c3872afb187cfc72dbbac..cb184b1b47865030fd1bb3d1a2ebe298cba1cae6 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -84,6 +84,8 @@ extern const int32_t TYPE_BYTES[15]; #define TSDB_DEFAULT_PASS "powerdb" #elif (_TD_TQ_ == true) #define TSDB_DEFAULT_PASS "tqueue" +#elif (_TD_PRO_ == true) +#define TSDB_DEFAULT_PASS "prodb" #else #define TSDB_DEFAULT_PASS "taosdata" #endif diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index d59b88c7e698b3e965b5923efdc760e0289f7250..887c51f10c5a6c10e213bb893725a837a0be77cd 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -110,7 +110,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TSC_DUP_TAG_NAMES TAOS_DEF_ERROR_CODE(0, 0x0220) //"duplicated tag names") #define TSDB_CODE_TSC_INVALID_JSON TAOS_DEF_ERROR_CODE(0, 0x0221) //"Invalid JSON format") #define TSDB_CODE_TSC_INVALID_JSON_TYPE TAOS_DEF_ERROR_CODE(0, 0x0222) //"Invalid JSON data type") -#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0223) //"Value out of range") +#define TSDB_CODE_TSC_INVALID_JSON_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0223) //"Invalid JSON configuration") +#define TSDB_CODE_TSC_VALUE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0224) //"Value out of range") // mnode #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed") diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index bb93c52142a73d00ebde9e039143a5e124eb6e9a..c3c8625fec3290e2d39d64f53a173b43cf21d7e3 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -492,7 +492,6 @@ typedef struct { SSessionWindow sw; // session window uint16_t tagCondLen; // tag length in current query uint16_t colCondLen; // column length in current query - uint32_t tbnameCondLen; // table name filter condition string length int16_t numOfGroupCols; // num of group by columns int16_t orderByIdx; int16_t orderType; // used in group by xx order by xxx @@ -502,7 +501,6 @@ typedef struct { int64_t offset; uint32_t queryType; // denote another query process int16_t numOfOutput; // final output columns numbers - int16_t tagNameRelType; // relation of tag criteria and tbname criteria int16_t fillType; // interpolate type uint64_t fillVal; // default value array list int32_t secondStageOutput; diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 089e30ac3728761c68fe155f960c8650a32c2f7a..4e11e4f2478fe0616701e0d183d38455b9526514 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -352,8 +352,7 @@ SArray *tsdbRetrieveDataBlock(TsdbQueryHandleT *pQueryHandle, SArray *pColumnIdL * @param pTagCond. tag query condition */ int32_t tsdbQuerySTableByTagCond(STsdbRepo *tsdb, uint64_t uid, TSKEY key, const char *pTagCond, size_t len, - int16_t tagNameRelType, const char *tbnameCond, STableGroupInfo *pGroupList, - SColIndex *pColIndex, int32_t numOfCols); + STableGroupInfo *pGroupList, SColIndex *pColIndex, int32_t numOfCols); /** * destroy the created table group list, which is generated by tag query diff --git a/src/kit/shell/CMakeLists.txt b/src/kit/shell/CMakeLists.txt index bf2bbca14d25aff3b3717c7b9785f1dc470a013a..bca1b72a1bc2c1f5b3da311baad38cd1d55ddaed 100644 --- a/src/kit/shell/CMakeLists.txt +++ b/src/kit/shell/CMakeLists.txt @@ -19,9 +19,9 @@ ELSE () ENDIF () IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(shell taos_static lua ${LINK_JEMALLOC}) + TARGET_LINK_LIBRARIES(shell taos_static cJson lua ${LINK_JEMALLOC}) ELSE () - TARGET_LINK_LIBRARIES(shell taos lua ${LINK_JEMALLOC}) + TARGET_LINK_LIBRARIES(shell taos cJson lua ${LINK_JEMALLOC}) ENDIF () SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) @@ -30,7 +30,7 @@ ELSEIF (TD_WINDOWS) LIST(APPEND SRC ./src/shellMain.c) LIST(APPEND SRC ./src/shellWindows.c) ADD_EXECUTABLE(shell ${SRC}) - TARGET_LINK_LIBRARIES(shell taos_static) + TARGET_LINK_LIBRARIES(shell taos_static cJson) IF (TD_POWER) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME power) @@ -46,7 +46,7 @@ ELSEIF (TD_DARWIN) LIST(APPEND SRC ./src/shellCheck.c) ADD_EXECUTABLE(shell ${SRC}) # linking with dylib - TARGET_LINK_LIBRARIES(shell taos) + TARGET_LINK_LIBRARIES(shell taos cJson) # linking taos statically # TARGET_LINK_LIBRARIES(shell taos_static) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index efc37403b46f2bfdd8e40eecd2ff53d00af6cd8a..d30b868bd59d8891db06f78e80cad8cb8eca10be 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -44,6 +44,13 @@ char PROMPT_HEADER[] = "tq> "; char CONTINUE_PROMPT[] = " -> "; int prompt_size = 4; +#elif (_TD_PRO_ == true) +char CLIENT_VERSION[] = "Welcome to the ProDB shell from %s, Client Version:%s\n" + "Copyright (c) 2020 by Hanatech, Inc. All rights reserved.\n\n"; +char PROMPT_HEADER[] = "ProDB> "; + +char CONTINUE_PROMPT[] = " -> "; +int prompt_size = 7; #else char CLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n" "Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.\n\n"; @@ -569,7 +576,7 @@ static void shellPrintNChar(const char *str, int length, int width) { while (pos < length) { wchar_t wc; int bytes = mbtowc(&wc, str + pos, MB_CUR_MAX); - if (bytes == 0) { + if (bytes <= 0) { break; } pos += bytes; diff --git a/src/kit/taosdemo/CMakeLists.txt b/src/kit/taosdemo/CMakeLists.txt index 2034093ad5841c267b722930681127d745d27153..bdfdf74715a07d5fca1a4e73b75842ffa47b6e68 100644 --- a/src/kit/taosdemo/CMakeLists.txt +++ b/src/kit/taosdemo/CMakeLists.txt @@ -8,12 +8,14 @@ IF (GIT_FOUND) MESSAGE("Git found") EXECUTE_PROCESS( COMMAND ${GIT_EXECUTABLE} log --pretty=oneline -n 1 ${CMAKE_CURRENT_LIST_DIR}/taosdemo.c + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} RESULT_VARIABLE RESULT OUTPUT_VARIABLE TAOSDEMO_COMMIT_SHA1) IF ("${TAOSDEMO_COMMIT_SHA1}" STREQUAL "") - MESSAGE("taosdemo's latest commit in short is:" ${TAOSDEMO_COMMIT_SHA1}) + SET(TAOSDEMO_COMMIT_SHA1 "unknown") ELSE () STRING(SUBSTRING "${TAOSDEMO_COMMIT_SHA1}" 0 7 TAOSDEMO_COMMIT_SHA1) + STRING(STRIP "${TAOSDEMO_COMMIT_SHA1}" TAOSDEMO_COMMIT_SHA1) ENDIF () EXECUTE_PROCESS( COMMAND ${GIT_EXECUTABLE} status -z -s ${CMAKE_CURRENT_LIST_DIR}/taosdemo.c @@ -25,14 +27,13 @@ IF (GIT_FOUND) RESULT_VARIABLE RESULT OUTPUT_VARIABLE TAOSDEMO_STATUS) ENDIF (TD_LINUX) - MESSAGE("taosdemo.c status: " ${TAOSDEMO_STATUS}) ELSE() MESSAGE("Git not found") SET(TAOSDEMO_COMMIT_SHA1 "unknown") SET(TAOSDEMO_STATUS "unknown") ENDIF (GIT_FOUND) -STRING(STRIP "${TAOSDEMO_COMMIT_SHA1}" TAOSDEMO_COMMIT_SHA1) + MESSAGE("taosdemo's latest commit in short is:" ${TAOSDEMO_COMMIT_SHA1}) STRING(STRIP "${TAOSDEMO_STATUS}" TAOSDEMO_STATUS) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 9b3be1556a47b52142f41b84ca385108088a9018..88ff34991514212854aac3296bfd81a57e480f08 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -79,10 +79,10 @@ extern char configDir[]; #define DEFAULT_START_TIME 1500000000000 #define MAX_PREPARED_RAND 1000000 -#define INT_BUFF_LEN 11 +#define INT_BUFF_LEN 12 #define BIGINT_BUFF_LEN 21 -#define SMALLINT_BUFF_LEN 6 -#define TINYINT_BUFF_LEN 4 +#define SMALLINT_BUFF_LEN 7 +#define TINYINT_BUFF_LEN 5 #define BOOL_BUFF_LEN 6 #define FLOAT_BUFF_LEN 22 #define DOUBLE_BUFF_LEN 42 @@ -104,6 +104,7 @@ extern char configDir[]; #define DATATYPE_BUFF_LEN (SMALL_BUFF_LEN*3) #define NOTE_BUFF_LEN (SMALL_BUFF_LEN*16) +#define DEFAULT_NTHREADS 8 #define DEFAULT_TIMESTAMP_STEP 1 #define DEFAULT_INTERLACE_ROWS 0 #define DEFAULT_DATATYPE_NUM 1 @@ -227,7 +228,7 @@ typedef struct SArguments_S { char * sqlFile; bool use_metric; bool drop_database; - bool insert_only; + bool aggr_func; bool answer_yes; bool debug_print; bool verbose_print; @@ -375,8 +376,7 @@ typedef struct SDbs_S { char password[SHELL_MAX_PASSWORD_LEN]; char resultFile[MAX_FILE_NAME_LEN]; bool use_metric; - bool insert_only; - bool do_aggreFunc; + bool aggr_func; bool asyncMode; uint32_t threadCount; @@ -590,21 +590,30 @@ static void init_rand_data(); /* ************ Global variables ************ */ int32_t g_randint[MAX_PREPARED_RAND]; +uint32_t g_randuint[MAX_PREPARED_RAND]; int64_t g_randbigint[MAX_PREPARED_RAND]; +uint64_t g_randubigint[MAX_PREPARED_RAND]; float g_randfloat[MAX_PREPARED_RAND]; double g_randdouble[MAX_PREPARED_RAND]; char *g_randbool_buff = NULL; char *g_randint_buff = NULL; +char *g_randuint_buff = NULL; char *g_rand_voltage_buff = NULL; char *g_randbigint_buff = NULL; +char *g_randubigint_buff = NULL; char *g_randsmallint_buff = NULL; +char *g_randusmallint_buff = NULL; char *g_randtinyint_buff = NULL; +char *g_randutinyint_buff = NULL; char *g_randfloat_buff = NULL; char *g_rand_current_buff = NULL; char *g_rand_phase_buff = NULL; char *g_randdouble_buff = NULL; +char *g_aggreFuncDemo[] = {"*", "count(*)", "avg(current)", "sum(current)", + "max(current)", "min(current)", "first(current)", "last(current)"}; + char *g_aggreFunc[] = {"*", "count(*)", "avg(C0)", "sum(C0)", "max(C0)", "min(C0)", "first(C0)", "last(C0)"}; @@ -619,6 +628,8 @@ SArguments g_args = { "powerdb", // password #elif (_TD_TQ_ == true) "tqueue", // password +#elif (_TD_PRO_ == true) + "prodb", // password #else "taosdata", // password #endif @@ -628,7 +639,7 @@ SArguments g_args = { NULL, // sqlFile true, // use_metric true, // drop_database - true, // insert_only + false, // aggr_func false, // debug_print false, // verbose_print false, // performance statistic print @@ -646,7 +657,7 @@ SArguments g_args = { 64, // binwidth 4, // columnCount, timestamp + float + int + float 20 + FLOAT_BUFF_LEN + INT_BUFF_LEN + FLOAT_BUFF_LEN, // lenOfOneRow - 8, // num_of_connections/thread + DEFAULT_NTHREADS,// nthreads 0, // insert_interval DEFAULT_TIMESTAMP_STEP, // timestamp_step 1, // query_times @@ -748,19 +759,24 @@ static void printHelp() { char indent[10] = " "; printf("%s\n\n", "Usage: taosdemo [OPTION...]"); printf("%s%s%s%s\n", indent, "-f, --file=FILE", "\t\t", - "The meta file to the execution procedure. Default is './meta.json'."); + "The meta file to the execution procedure."); printf("%s%s%s%s\n", indent, "-u, --user=USER", "\t\t", "The user name to use when connecting to the server."); #ifdef _TD_POWER_ printf("%s%s%s%s\n", indent, "-p, --password", "\t\t", - "The password to use when connecting to the server. Default is 'powerdb'"); + "The password to use when connecting to the server. By default is 'powerdb'"); printf("%s%s%s%s\n", indent, "-c, --config-dir=CONFIG_DIR", "\t", - "Configuration directory. Default is '/etc/power/'."); + "Configuration directory. By default is '/etc/power/'."); #elif (_TD_TQ_ == true) printf("%s%s%s%s\n", indent, "-p, --password", "\t\t", - "The password to use when connecting to the server. Default is 'tqueue'"); + "The password to use when connecting to the server. By default is 'tqueue'"); + printf("%s%s%s%s\n", indent, "-c, --config-dir=CONFIG_DIR", "\t", + "Configuration directory. By default is '/etc/tq/'."); +#elif (_TD_PRO_ == true) + printf("%s%s%s%s\n", indent, "-p, --password", "\t\t", + "The password to use when connecting to the server. By default is 'prodb'"); printf("%s%s%s%s\n", indent, "-c, --config-dir=CONFIG_DIR", "\t", - "Configuration directory. Default is '/etc/tq/'."); + "Configuration directory. By default is '/etc/ProDB/'."); #else printf("%s%s%s%s\n", indent, "-p, --password", "\t\t", "The password to use when connecting to the server."); @@ -772,24 +788,24 @@ static void printHelp() { printf("%s%s%s%s\n", indent, "-P, --port=PORT", "\t\t", "The TCP/IP port number to use for the connection."); printf("%s%s%s%s\n", indent, "-I, --interface=INTERFACE", "\t", - "The interface (taosc, rest, and stmt) taosdemo uses. Default is 'taosc'."); + "The interface (taosc, rest, and stmt) taosdemo uses. By default use 'taosc'."); printf("%s%s%s%s\n", indent, "-d, --database=DATABASE", "\t", - "Destination database. Default is 'test'."); + "Destination database. By default is 'test'."); printf("%s%s%s%s\n", indent, "-a, --replica=REPLICA", "\t\t", - "Set the replica parameters of the database, Default 1, min: 1, max: 3."); + "Set the replica parameters of the database, By default use 1, min: 1, max: 3."); printf("%s%s%s%s\n", indent, "-m, --table-prefix=TABLEPREFIX", "\t", - "Table prefix name. Default is 'd'."); + "Table prefix name. By default use 'd'."); printf("%s%s%s%s\n", indent, "-s, --sql-file=FILE", "\t\t", "The select sql file."); printf("%s%s%s%s\n", indent, "-N, --normal-table", "\t\t", "Use normal table flag."); printf("%s%s%s%s\n", indent, "-o, --output=FILE", "\t\t", - "Direct output to the named file. Default is './output.txt'."); + "Direct output to the named file. By default use './output.txt'."); printf("%s%s%s%s\n", indent, "-q, --query-mode=MODE", "\t\t", - "Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC."); + "Query mode -- 0: SYNC, 1: ASYNC. By default use SYNC."); printf("%s%s%s%s\n", indent, "-b, --data-type=DATATYPE", "\t", - "The data_type of columns, default: FLOAT, INT, FLOAT."); + "The data_type of columns, By default use: FLOAT, INT, FLOAT."); printf("%s%s%s%s%d\n", indent, "-w, --binwidth=WIDTH", "\t\t", - "The width of data_type 'BINARY' or 'NCHAR'. Default is ", + "The width of data_type 'BINARY' or 'NCHAR'. By default use ", g_args.binwidth); printf("%s%s%s%s%d%s%d\n", indent, "-l, --columns=COLUMNS", "\t\t", "The number of columns per record. Demo mode by default is ", @@ -798,32 +814,32 @@ static void printHelp() { MAX_NUM_COLUMNS); printf("%s%s%s%s\n", indent, indent, indent, "\t\t\t\tAll of the new column(s) type is INT. If use -b to specify column type, -l will be ignored."); - printf("%s%s%s%s\n", indent, "-T, --threads=NUMBER", "\t\t", - "The number of threads. Default is 10."); + printf("%s%s%s%s%d.\n", indent, "-T, --threads=NUMBER", "\t\t", + "The number of threads. By default use ", DEFAULT_NTHREADS); printf("%s%s%s%s\n", indent, "-i, --insert-interval=NUMBER", "\t", - "The sleep time (ms) between insertion. Default is 0."); + "The sleep time (ms) between insertion. By default is 0."); printf("%s%s%s%s%d.\n", indent, "-S, --time-step=TIME_STEP", "\t", - "The timestamp step between insertion. Default is ", + "The timestamp step between insertion. By default is ", DEFAULT_TIMESTAMP_STEP); printf("%s%s%s%s%d.\n", indent, "-B, --interlace-rows=NUMBER", "\t", - "The interlace rows of insertion. Default is ", + "The interlace rows of insertion. By default is ", DEFAULT_INTERLACE_ROWS); printf("%s%s%s%s\n", indent, "-r, --rec-per-req=NUMBER", "\t", - "The number of records per request. Default is 30000."); + "The number of records per request. By default is 30000."); printf("%s%s%s%s\n", indent, "-t, --tables=NUMBER", "\t\t", - "The number of tables. Default is 10000."); + "The number of tables. By default is 10000."); printf("%s%s%s%s\n", indent, "-n, --records=NUMBER", "\t\t", - "The number of records per table. Default is 10000."); + "The number of records per table. By default is 10000."); printf("%s%s%s%s\n", indent, "-M, --random", "\t\t\t", "The value of records generated are totally random."); - printf("%s\n", "\t\t\t\tThe default is to simulate power equipment scenario."); - printf("%s%s%s%s\n", indent, "-x, --no-insert", "\t\t", - "No-insert flag."); - printf("%s%s%s%s\n", indent, "-y, --answer-yes", "\t\t", "Default input yes for prompt."); + printf("%s\n", "\t\t\t\tBy default to simulate power equipment scenario."); + printf("%s%s%s%s\n", indent, "-x, --aggr-func", "\t\t", + "Test aggregation functions after insertion."); + printf("%s%s%s%s\n", indent, "-y, --answer-yes", "\t\t", "Input yes for prompt."); printf("%s%s%s%s\n", indent, "-O, --disorder=NUMBER", "\t\t", - "Insert order mode--0: In order, 1 ~ 50: disorder ratio. Default is in order."); + "Insert order mode--0: In order, 1 ~ 50: disorder ratio. By default is in order."); printf("%s%s%s%s\n", indent, "-R, --disorder-range=NUMBER", "\t", - "Out of order data's range, ms, default is 1000."); + "Out of order data's range. Unit is ms. By default is 1000."); printf("%s%s%s%s\n", indent, "-g, --debug", "\t\t\t", "Print debug info."); printf("%s%s%s%s\n", indent, "-?, --help\t", "\t\t", @@ -1565,7 +1581,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { && strcasecmp(dataType, "DOUBLE") && strcasecmp(dataType, "BINARY") && strcasecmp(dataType, "TIMESTAMP") - && strcasecmp(dataType, "NCHAR")) { + && strcasecmp(dataType, "NCHAR") + && strcasecmp(dataType, "UTINYINT") + && strcasecmp(dataType, "USMALLINT") + && strcasecmp(dataType, "UINT") + && strcasecmp(dataType, "UBIGINT")) { printHelp(); errorPrint("%s", "-b: Invalid data_type!\n"); exit(EXIT_FAILURE); @@ -1591,6 +1611,14 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { arguments->data_type[0] = TSDB_DATA_TYPE_BOOL; } else if (0 == strcasecmp(dataType, "TIMESTAMP")) { arguments->data_type[0] = TSDB_DATA_TYPE_TIMESTAMP; + } else if (0 == strcasecmp(dataType, "UTINYINT")) { + arguments->data_type[0] = TSDB_DATA_TYPE_UTINYINT; + } else if (0 == strcasecmp(dataType, "USMALLINT")) { + arguments->data_type[0] = TSDB_DATA_TYPE_USMALLINT; + } else if (0 == strcasecmp(dataType, "UINT")) { + arguments->data_type[0] = TSDB_DATA_TYPE_UINT; + } else if (0 == strcasecmp(dataType, "UBIGINT")) { + arguments->data_type[0] = TSDB_DATA_TYPE_UBIGINT; } else { arguments->data_type[0] = TSDB_DATA_TYPE_NULL; } @@ -1612,7 +1640,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { && strcasecmp(token, "DOUBLE") && strcasecmp(token, "BINARY") && strcasecmp(token, "TIMESTAMP") - && strcasecmp(token, "NCHAR")) { + && strcasecmp(token, "NCHAR") + && strcasecmp(token, "UTINYINT") + && strcasecmp(token, "USMALLINT") + && strcasecmp(token, "UINT") + && strcasecmp(token, "UBIGINT")) { printHelp(); free(g_dupstr); errorPrint("%s", "-b: Invalid data_type!\n"); @@ -1628,7 +1660,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { } else if (0 == strcasecmp(token, "BIGINT")) { arguments->data_type[index] = TSDB_DATA_TYPE_BIGINT; } else if (0 == strcasecmp(token, "DOUBLE")) { - arguments->data_type[index] = TSDB_DATA_TYPE_FLOAT; + arguments->data_type[index] = TSDB_DATA_TYPE_DOUBLE; } else if (0 == strcasecmp(token, "TINYINT")) { arguments->data_type[index] = TSDB_DATA_TYPE_TINYINT; } else if (0 == strcasecmp(token, "BINARY")) { @@ -1639,6 +1671,14 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { arguments->data_type[index] = TSDB_DATA_TYPE_BOOL; } else if (0 == strcasecmp(token, "TIMESTAMP")) { arguments->data_type[index] = TSDB_DATA_TYPE_TIMESTAMP; + } else if (0 == strcasecmp(token, "UTINYINT")) { + arguments->data_type[index] = TSDB_DATA_TYPE_UTINYINT; + } else if (0 == strcasecmp(token, "USMALLINT")) { + arguments->data_type[index] = TSDB_DATA_TYPE_USMALLINT; + } else if (0 == strcasecmp(token, "UINT")) { + arguments->data_type[index] = TSDB_DATA_TYPE_UINT; + } else if (0 == strcasecmp(token, "UBIGINT")) { + arguments->data_type[index] = TSDB_DATA_TYPE_UBIGINT; } else { arguments->data_type[index] = TSDB_DATA_TYPE_NULL; } @@ -1712,13 +1752,14 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { } } else if ((strcmp(argv[i], "-N") == 0) || (0 == strcmp(argv[i], "--normal-table"))) { + arguments->demo_mode = false; arguments->use_metric = false; } else if ((strcmp(argv[i], "-M") == 0) || (0 == strcmp(argv[i], "--random"))) { arguments->demo_mode = false; } else if ((strcmp(argv[i], "-x") == 0) - || (0 == strcmp(argv[i], "--no-insert"))) { - arguments->insert_only = false; + || (0 == strcmp(argv[i], "--aggr-func"))) { + arguments->aggr_func = true; } else if ((strcmp(argv[i], "-y") == 0) || (0 == strcmp(argv[i], "--answer-yes"))) { arguments->answer_yes = true; @@ -1941,18 +1982,22 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { break; case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: g_args.lenOfOneRow += INT_BUFF_LEN; break; case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: g_args.lenOfOneRow += BIGINT_BUFF_LEN; break; case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT: g_args.lenOfOneRow += SMALLINT_BUFF_LEN; break; case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: g_args.lenOfOneRow += TINYINT_BUFF_LEN; break; @@ -2184,6 +2229,23 @@ static int32_t rand_tinyint() return g_randint[cursor % MAX_PREPARED_RAND] % 128; } +static char *rand_utinyint_str() +{ + static int cursor; + cursor++; + if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; + return g_randutinyint_buff + + ((cursor % MAX_PREPARED_RAND) * TINYINT_BUFF_LEN); +} + +static int32_t rand_utinyint() +{ + static int cursor; + cursor++; + if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; + return g_randuint[cursor % MAX_PREPARED_RAND] % 255; +} + static char *rand_smallint_str() { static int cursor; @@ -2198,7 +2260,24 @@ static int32_t rand_smallint() static int cursor; cursor++; if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; - return g_randint[cursor % MAX_PREPARED_RAND] % 32767; + return g_randint[cursor % MAX_PREPARED_RAND] % 32768; +} + +static char *rand_usmallint_str() +{ + static int cursor; + cursor++; + if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; + return g_randusmallint_buff + + ((cursor % MAX_PREPARED_RAND) * SMALLINT_BUFF_LEN); +} + +static int32_t rand_usmallint() +{ + static int cursor; + cursor++; + if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; + return g_randuint[cursor % MAX_PREPARED_RAND] % 65535; } static char *rand_int_str() @@ -2217,6 +2296,22 @@ static int32_t rand_int() return g_randint[cursor % MAX_PREPARED_RAND]; } +static char *rand_uint_str() +{ + static int cursor; + cursor++; + if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; + return g_randuint_buff + ((cursor % MAX_PREPARED_RAND) * INT_BUFF_LEN); +} + +static int32_t rand_uint() +{ + static int cursor; + cursor++; + if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; + return g_randuint[cursor % MAX_PREPARED_RAND]; +} + static char *rand_bigint_str() { static int cursor; @@ -2234,6 +2329,23 @@ static int64_t rand_bigint() return g_randbigint[cursor % MAX_PREPARED_RAND]; } +static char *rand_ubigint_str() +{ + static int cursor; + cursor++; + if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; + return g_randubigint_buff + + ((cursor % MAX_PREPARED_RAND) * BIGINT_BUFF_LEN); +} + +static int64_t rand_ubigint() +{ + static int cursor; + cursor++; + if (cursor > (MAX_PREPARED_RAND - 1)) cursor = 0; + return g_randubigint[cursor % MAX_PREPARED_RAND]; +} + static char *rand_float_str() { static int cursor; @@ -2371,9 +2483,18 @@ static void init_rand_data() { assert(g_rand_phase_buff); g_randdouble_buff = calloc(1, DOUBLE_BUFF_LEN * MAX_PREPARED_RAND); assert(g_randdouble_buff); + g_randuint_buff = calloc(1, INT_BUFF_LEN * MAX_PREPARED_RAND); + assert(g_randuint_buff); + g_randutinyint_buff = calloc(1, TINYINT_BUFF_LEN * MAX_PREPARED_RAND); + assert(g_randutinyint_buff); + g_randusmallint_buff = calloc(1, SMALLINT_BUFF_LEN * MAX_PREPARED_RAND); + assert(g_randusmallint_buff); + g_randubigint_buff = calloc(1, BIGINT_BUFF_LEN * MAX_PREPARED_RAND); + assert(g_randubigint_buff); for (int i = 0; i < MAX_PREPARED_RAND; i++) { - g_randint[i] = (int)(taosRandom() % 65535); + g_randint[i] = (int)(taosRandom() % RAND_MAX - (RAND_MAX >> 1)); + g_randuint[i] = (int)(taosRandom()); sprintf(g_randint_buff + i * INT_BUFF_LEN, "%d", g_randint[i]); sprintf(g_rand_voltage_buff + i * INT_BUFF_LEN, "%d", @@ -2382,15 +2503,24 @@ static void init_rand_data() { sprintf(g_randbool_buff + i * BOOL_BUFF_LEN, "%s", ((g_randint[i] % 2) & 1)?"true":"false"); sprintf(g_randsmallint_buff + i * SMALLINT_BUFF_LEN, "%d", - g_randint[i] % 32767); + g_randint[i] % 32768); sprintf(g_randtinyint_buff + i * TINYINT_BUFF_LEN, "%d", g_randint[i] % 128); - - g_randbigint[i] = (int64_t)(taosRandom() % 2147483648); + sprintf(g_randuint_buff + i * INT_BUFF_LEN, "%d", + g_randuint[i]); + sprintf(g_randusmallint_buff + i * SMALLINT_BUFF_LEN, "%d", + g_randuint[i] % 65535); + sprintf(g_randutinyint_buff + i * TINYINT_BUFF_LEN, "%d", + g_randuint[i] % 255); + + g_randbigint[i] = (int64_t)(taosRandom() % RAND_MAX - (RAND_MAX >> 1)); + g_randubigint[i] = (uint64_t)(taosRandom()); sprintf(g_randbigint_buff + i * BIGINT_BUFF_LEN, "%"PRId64"", g_randbigint[i]); + sprintf(g_randubigint_buff + i * BIGINT_BUFF_LEN, "%"PRId64"", + g_randubigint[i]); - g_randfloat[i] = (float)(taosRandom() / 1000.0); + g_randfloat[i] = (float)(taosRandom() / 1000.0) * (taosRandom() % 2 > 0.5 ? 1 : -1); sprintf(g_randfloat_buff + i * FLOAT_BUFF_LEN, "%f", g_randfloat[i]); sprintf(g_rand_current_buff + i * FLOAT_BUFF_LEN, "%f", @@ -2400,7 +2530,7 @@ static void init_rand_data() { (float)((115 + g_randint[i] % 10 + g_randfloat[i]/1000000000)/360)); - g_randdouble[i] = (double)(taosRandom() / 1000000.0); + g_randdouble[i] = (double)(taosRandom() / 1000000.0) * (taosRandom() % 2 > 0.5 ? 1 : -1); sprintf(g_randdouble_buff + i * DOUBLE_BUFF_LEN, "%f", g_randdouble[i]); } @@ -2429,10 +2559,11 @@ static void init_rand_data() { static int printfInsertMeta() { SHOW_PARSE_RESULT_START(); - if (g_args.demo_mode) - printf("\ntaosdemo is simulating data generated by power equipments monitoring...\n\n"); - else + if (g_args.demo_mode) { + printf("\ntaosdemo is simulating data generated by power equipment monitoring...\n\n"); + } else { printf("\ntaosdemo is simulating random data as you request..\n\n"); + } if (g_args.iface != INTERFACE_BUT) { // first time if no iface specified @@ -2962,18 +3093,34 @@ static void xDumpFieldToFile(FILE* fp, const char* val, fprintf(fp, "%d", *((int8_t *)val)); break; + case TSDB_DATA_TYPE_UTINYINT: + fprintf(fp, "%d", *((uint8_t *)val)); + break; + case TSDB_DATA_TYPE_SMALLINT: fprintf(fp, "%d", *((int16_t *)val)); break; + case TSDB_DATA_TYPE_USMALLINT: + fprintf(fp, "%d", *((uint16_t *)val)); + break; + case TSDB_DATA_TYPE_INT: fprintf(fp, "%d", *((int32_t *)val)); break; + case TSDB_DATA_TYPE_UINT: + fprintf(fp, "%d", *((uint32_t *)val)); + break; + case TSDB_DATA_TYPE_BIGINT: fprintf(fp, "%"PRId64"", *((int64_t *)val)); break; + case TSDB_DATA_TYPE_UBIGINT: + fprintf(fp, "%"PRId64"", *((uint64_t *)val)); + break; + case TSDB_DATA_TYPE_FLOAT: fprintf(fp, "%.5f", GET_FLOAT_VAL(val)); break; @@ -3460,7 +3607,23 @@ static char* generateTagValuesForStb(SSuperTable* stbInfo, int64_t tableSeq) { } else if (0 == strncasecmp(stbInfo->tags[i].dataType, "timestamp", strlen("timestamp"))) { dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, - "%"PRId64",", rand_bigint()); + "%"PRId64",", rand_ubigint()); + } else if (0 == strncasecmp(stbInfo->tags[i].dataType, + "utinyint", strlen("utinyint"))) { + dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, + "%d,", rand_utinyint()); + } else if (0 == strncasecmp(stbInfo->tags[i].dataType, + "usmallint", strlen("usmallint"))) { + dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, + "%d,", rand_usmallint()); + } else if (0 == strncasecmp(stbInfo->tags[i].dataType, + "uint", strlen("uint"))) { + dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, + "%d,", rand_uint()); + } else if (0 == strncasecmp(stbInfo->tags[i].dataType, + "ubigint", strlen("ubigint"))) { + dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, + "%"PRId64",", rand_ubigint()); } else { errorPrint2("No support data type: %s\n", stbInfo->tags[i].dataType); tmfree(dataBuf); @@ -3490,18 +3653,22 @@ static int calcRowLen(SSuperTable* superTbls) { break; case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: lenOfOneRow += INT_BUFF_LEN; break; case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: lenOfOneRow += BIGINT_BUFF_LEN; break; case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT: lenOfOneRow += SMALLINT_BUFF_LEN; break; case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: lenOfOneRow += TINYINT_BUFF_LEN; break; @@ -3532,27 +3699,41 @@ static int calcRowLen(SSuperTable* superTbls) { int tagIndex; int lenOfTagOfOneRow = 0; for (tagIndex = 0; tagIndex < superTbls->tagCount; tagIndex++) { - char* dataType = superTbls->tags[tagIndex].dataType; - - if (strcasecmp(dataType, "BINARY") == 0) { + char * dataType = superTbls->tags[tagIndex].dataType; + switch (superTbls->tags[tagIndex].data_type) + { + case TSDB_DATA_TYPE_BINARY: lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + 3; - } else if (strcasecmp(dataType, "NCHAR") == 0) { + break; + case TSDB_DATA_TYPE_NCHAR: lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + 3; - } else if (strcasecmp(dataType, "INT") == 0) { + break; + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + INT_BUFF_LEN; - } else if (strcasecmp(dataType, "BIGINT") == 0) { + break; + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + BIGINT_BUFF_LEN; - } else if (strcasecmp(dataType, "SMALLINT") == 0) { + break; + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT: lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + SMALLINT_BUFF_LEN; - } else if (strcasecmp(dataType, "TINYINT") == 0) { + break; + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + TINYINT_BUFF_LEN; - } else if (strcasecmp(dataType, "BOOL") == 0) { + break; + case TSDB_DATA_TYPE_BOOL: lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + BOOL_BUFF_LEN; - } else if (strcasecmp(dataType, "FLOAT") == 0) { + break; + case TSDB_DATA_TYPE_FLOAT: lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + FLOAT_BUFF_LEN; - } else if (strcasecmp(dataType, "DOUBLE") == 0) { + break; + case TSDB_DATA_TYPE_DOUBLE: lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + DOUBLE_BUFF_LEN; - } else { + break; + default: errorPrint2("get error tag type : %s\n", dataType); exit(EXIT_FAILURE); } @@ -3685,40 +3866,60 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, tstrncpy(superTbls->tags[tagIndex].field, (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX], fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes); - tstrncpy(superTbls->tags[tagIndex].dataType, - (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], - min(DATATYPE_BUFF_LEN, - fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); - if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "INT", strlen("INT"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_INT; - } else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "TINYINT", strlen("TINYINT"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_TINYINT; - } else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "SMALLINT", strlen("SMALLINT"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_SMALLINT; - } else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "BIGINT", strlen("BIGINT"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_BIGINT; - } else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "FLOAT", strlen("FLOAT"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_FLOAT; - } else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "DOUBLE", strlen("DOUBLE"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_DOUBLE; - } else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "BINARY", strlen("BINARY"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_BINARY; - } else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "NCHAR", strlen("NCHAR"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_NCHAR; - } else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "BOOL", strlen("BOOL"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_BOOL; - } else if (0 == strncasecmp(superTbls->tags[tagIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "TIMESTAMP", strlen("TIMESTAMP"))) { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_TIMESTAMP; + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "TINYINT UNSIGNED", strlen("TINYINT UNSIGNED"))) { + superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_UTINYINT; + tstrncpy(superTbls->tags[tagIndex].dataType,"UTINYINT", + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "SMALLINT UNSIGNED", strlen("SMALLINT UNSIGNED"))) { + superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_USMALLINT; + tstrncpy(superTbls->tags[tagIndex].dataType,"USMALLINT", + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "INT UNSIGNED", strlen("INT UNSIGNED"))) { + superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_UINT; + tstrncpy(superTbls->tags[tagIndex].dataType,"UINT", + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); + }else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "BIGINT UNSIGNED", strlen("BIGINT UNSIGNED"))) { + superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_UBIGINT; + tstrncpy(superTbls->tags[tagIndex].dataType,"UBIGINT", + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); } else { superTbls->tags[tagIndex].data_type = TSDB_DATA_TYPE_NULL; } @@ -3728,46 +3929,78 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, (char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX], min(NOTE_BUFF_LEN, fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes) + 1); + if (strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) + { + tstrncpy(superTbls->tags[tagIndex].dataType, + (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); + } tagIndex++; } else { tstrncpy(superTbls->columns[columnIndex].field, (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX], fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes); - tstrncpy(superTbls->columns[columnIndex].dataType, - (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], - min(DATATYPE_BUFF_LEN, - fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); - if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, - "INT", strlen("INT"))) { + + if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "INT", strlen("INT")) && + strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_INT; - } else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, - "TINYINT", strlen("TINYINT"))) { + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "TINYINT", strlen("TINYINT")) && + strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_TINYINT; - } else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, - "SMALLINT", strlen("SMALLINT"))) { + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "SMALLINT", strlen("SMALLINT")) && + strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_SMALLINT; - } else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, - "BIGINT", strlen("BIGINT"))) { + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "BIGINT", strlen("BIGINT")) && + strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_BIGINT; - } else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "FLOAT", strlen("FLOAT"))) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_FLOAT; - } else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "DOUBLE", strlen("DOUBLE"))) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_DOUBLE; - } else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "BINARY", strlen("BINARY"))) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_BINARY; - } else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "NCHAR", strlen("NCHAR"))) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_NCHAR; - } else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "BOOL", strlen("BOOL"))) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_BOOL; - } else if (0 == strncasecmp(superTbls->columns[columnIndex].dataType, + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "TIMESTAMP", strlen("TIMESTAMP"))) { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_TIMESTAMP; + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "TINYINT UNSIGNED", strlen("TINYINT UNSIGNED"))) { + superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_UTINYINT; + tstrncpy(superTbls->columns[columnIndex].dataType,"UTINYINT", + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "SMALLINT UNSIGNED", strlen("SMALLINT UNSIGNED"))) { + superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_USMALLINT; + tstrncpy(superTbls->columns[columnIndex].dataType,"USMALLINT", + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "INT UNSIGNED", strlen("INT UNSIGNED"))) { + superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_UINT; + tstrncpy(superTbls->columns[columnIndex].dataType,"UINT", + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); + } else if (0 == strncasecmp((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + "BIGINT UNSIGNED", strlen("BIGINT UNSIGNED"))) { + superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_UBIGINT; + tstrncpy(superTbls->columns[columnIndex].dataType,"UBIGINT", + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); } else { superTbls->columns[columnIndex].data_type = TSDB_DATA_TYPE_NULL; } @@ -3777,6 +4010,13 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, (char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX], min(NOTE_BUFF_LEN, fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes) + 1); + + if (strstr((char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], "UNSIGNED") == NULL) { + tstrncpy(superTbls->columns[columnIndex].dataType, + (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], + min(DATATYPE_BUFF_LEN, + fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); + } columnIndex++; } @@ -3901,6 +4141,30 @@ static int createSuperTable( lenOfOneRow += TIMESTAMP_BUFF_LEN; break; + case TSDB_DATA_TYPE_UTINYINT: + len += snprintf(cols + len, COL_BUFFER_LEN - len, ",C%d %s", + colIndex, "TINYINT UNSIGNED"); + lenOfOneRow += TINYINT_BUFF_LEN; + break; + + case TSDB_DATA_TYPE_USMALLINT: + len += snprintf(cols + len, COL_BUFFER_LEN - len, ",C%d %s", + colIndex, "SMALLINT UNSIGNED"); + lenOfOneRow += SMALLINT_BUFF_LEN; + break; + + case TSDB_DATA_TYPE_UINT: + len += snprintf(cols + len, COL_BUFFER_LEN - len, ",C%d %s", + colIndex, "INT UNSIGNED"); + lenOfOneRow += INT_BUFF_LEN; + break; + + case TSDB_DATA_TYPE_UBIGINT: + len += snprintf(cols + len, COL_BUFFER_LEN - len, ",C%d %s", + colIndex, "BIGINT UNSIGNED"); + lenOfOneRow += BIGINT_BUFF_LEN; + break; + default: taos_close(taos); free(command); @@ -3991,6 +4255,22 @@ static int createSuperTable( len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len, "T%d %s,", tagIndex, "DOUBLE"); lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + DOUBLE_BUFF_LEN; + } else if (strcasecmp(dataType, "UTINYINT") == 0) { + len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len, + "T%d %s,", tagIndex, "TINYINT UNSIGNED"); + lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + TINYINT_BUFF_LEN; + } else if (strcasecmp(dataType, "USMALLINT") == 0) { + len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len, + "T%d %s,", tagIndex, "SMALLINT UNSIGNED"); + lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + SMALLINT_BUFF_LEN; + } else if (strcasecmp(dataType, "UINT") == 0) { + len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len, + "T%d %s,", tagIndex, "INT UNSIGNED"); + lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + INT_BUFF_LEN; + } else if (strcasecmp(dataType, "UBIGINT") == 0) { + len += snprintf(tags + len, TSDB_MAX_TAGS_LEN - len, + "T%d %s,", tagIndex, "BIGINT UNSIGNED"); + lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + BIGINT_BUFF_LEN; } else { taos_close(taos); free(command); @@ -4146,19 +4426,17 @@ int createDatabasesAndStables(char *command) { errorPrint("create super table %"PRIu64" failed!\n\n", j); continue; } - } - - ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName, + } else { + ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName, &g_Dbs.db[i].superTbls[j]); - if (0 != ret) { - errorPrint2("\nget super table %s.%s info failed!\n\n", - g_Dbs.db[i].dbName, g_Dbs.db[i].superTbls[j].stbName); - continue; + if (0 != ret) { + errorPrint2("\nget super table %s.%s info failed!\n\n", + g_Dbs.db[i].dbName, g_Dbs.db[i].superTbls[j].stbName); + continue; + } } - validStbCount ++; } - g_Dbs.db[i].superTblCount = validStbCount; } @@ -4651,6 +4929,18 @@ static bool getColumnAndTagTypeFromInsertJsonFile( } else if (0 == strncasecmp(superTbls->columns[c].dataType, "TIMESTAMP", strlen("TIMESTAMP"))) { superTbls->columns[c].data_type = TSDB_DATA_TYPE_TIMESTAMP; + } else if (0 == strncasecmp(superTbls->columns[c].dataType, + "UTINYINT", strlen("UTINYINT"))) { + superTbls->columns[c].data_type = TSDB_DATA_TYPE_UTINYINT; + } else if (0 == strncasecmp(superTbls->columns[c].dataType, + "USMALLINT", strlen("USMALLINT"))) { + superTbls->columns[c].data_type = TSDB_DATA_TYPE_USMALLINT; + } else if (0 == strncasecmp(superTbls->columns[c].dataType, + "UINT", strlen("UINT"))) { + superTbls->columns[c].data_type = TSDB_DATA_TYPE_UINT; + } else if (0 == strncasecmp(superTbls->columns[c].dataType, + "UBIGINT", strlen("UBIGINT"))) { + superTbls->columns[c].data_type = TSDB_DATA_TYPE_UBIGINT; } else { superTbls->columns[c].data_type = TSDB_DATA_TYPE_NULL; } @@ -4756,6 +5046,18 @@ static bool getColumnAndTagTypeFromInsertJsonFile( } else if (0 == strncasecmp(superTbls->tags[t].dataType, "TIMESTAMP", strlen("TIMESTAMP"))) { superTbls->tags[t].data_type = TSDB_DATA_TYPE_TIMESTAMP; + } else if (0 == strncasecmp(superTbls->tags[t].dataType, + "UTINYINT", strlen("UTINYINT"))) { + superTbls->tags[t].data_type = TSDB_DATA_TYPE_UTINYINT; + } else if (0 == strncasecmp(superTbls->tags[t].dataType, + "USMALLINT", strlen("USMALLINT"))) { + superTbls->tags[t].data_type = TSDB_DATA_TYPE_USMALLINT; + } else if (0 == strncasecmp(superTbls->tags[t].dataType, + "UINT", strlen("UINT"))) { + superTbls->tags[t].data_type = TSDB_DATA_TYPE_UINT; + } else if (0 == strncasecmp(superTbls->tags[t].dataType, + "UBIGINT", strlen("UBIGINT"))) { + superTbls->tags[t].data_type = TSDB_DATA_TYPE_UBIGINT; } else { superTbls->tags[t].data_type = TSDB_DATA_TYPE_NULL; } @@ -6173,9 +6475,22 @@ static int64_t generateStbRowData( tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, INT_BUFF_LEN)); break; + case TSDB_DATA_TYPE_UINT: + tmp = rand_uint_str(); + tmpLen = strlen(tmp); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, INT_BUFF_LEN)); + break; + case TSDB_DATA_TYPE_BIGINT: tmp = rand_bigint_str(); - tstrncpy(pstr + dataLen, tmp, BIGINT_BUFF_LEN); + tmpLen = strlen(tmp); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, BIGINT_BUFF_LEN)); + break; + + case TSDB_DATA_TYPE_UBIGINT: + tmp = rand_ubigint_str(); + tmpLen = strlen(tmp); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, BIGINT_BUFF_LEN)); break; case TSDB_DATA_TYPE_FLOAT: @@ -6189,38 +6504,49 @@ static int64_t generateStbRowData( tmp = rand_float_str(); } tmpLen = strlen(tmp); - tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, FLOAT_BUFF_LEN)); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, FLOAT_BUFF_LEN)); break; case TSDB_DATA_TYPE_DOUBLE: tmp = rand_double_str(); tmpLen = strlen(tmp); - tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, DOUBLE_BUFF_LEN)); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, DOUBLE_BUFF_LEN)); break; case TSDB_DATA_TYPE_SMALLINT: tmp = rand_smallint_str(); tmpLen = strlen(tmp); - tstrncpy(pstr + dataLen, tmp, - min(tmpLen + 1, SMALLINT_BUFF_LEN)); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, SMALLINT_BUFF_LEN)); + break; + + case TSDB_DATA_TYPE_USMALLINT: + tmp = rand_usmallint_str(); + tmpLen = strlen(tmp); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, SMALLINT_BUFF_LEN)); break; case TSDB_DATA_TYPE_TINYINT: tmp = rand_tinyint_str(); tmpLen = strlen(tmp); - tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, TINYINT_BUFF_LEN)); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, TINYINT_BUFF_LEN)); + break; + + case TSDB_DATA_TYPE_UTINYINT: + tmp = rand_utinyint_str(); + tmpLen = strlen(tmp); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, TINYINT_BUFF_LEN)); break; case TSDB_DATA_TYPE_BOOL: tmp = rand_bool_str(); tmpLen = strlen(tmp); - tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, BOOL_BUFF_LEN)); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, BOOL_BUFF_LEN)); break; case TSDB_DATA_TYPE_TIMESTAMP: tmp = rand_bigint_str(); tmpLen = strlen(tmp); - tstrncpy(pstr + dataLen, tmp, min(tmpLen +1, BIGINT_BUFF_LEN)); + tstrncpy(pstr + dataLen, tmp, min(tmpLen + 1, BIGINT_BUFF_LEN)); break; case TSDB_DATA_TYPE_NULL: @@ -6231,9 +6557,8 @@ static int64_t generateStbRowData( stbInfo->columns[i].dataType); exit(EXIT_FAILURE); } - if (tmp) { - dataLen += strlen(tmp); + dataLen += tmpLen; } } @@ -6241,7 +6566,7 @@ static int64_t generateStbRowData( return 0; } - tstrncpy(pstr + dataLen, ")", 2); + dataLen += snprintf(pstr + dataLen, 2, ")"); verbosePrint("%s() LN%d, dataLen:%"PRId64"\n", __func__, __LINE__, dataLen); verbosePrint("%s() LN%d, recBuf:\n\t%s\n", __func__, __LINE__, recBuf); @@ -6318,6 +6643,22 @@ static int64_t generateData(char *recBuf, char *data_type, free(s); break; + case TSDB_DATA_TYPE_UTINYINT: + pstr += sprintf(pstr, ",%d", rand_utinyint() ); + break; + + case TSDB_DATA_TYPE_USMALLINT: + pstr += sprintf(pstr, ",%d", rand_usmallint()); + break; + + case TSDB_DATA_TYPE_UINT: + pstr += sprintf(pstr, ",%d", rand_uint()); + break; + + case TSDB_DATA_TYPE_UBIGINT: + pstr += sprintf(pstr, ",%"PRId64"", rand_ubigint()); + break; + case TSDB_DATA_TYPE_NULL: break; @@ -6376,7 +6717,7 @@ static int generateSampleFromRand( case TSDB_DATA_TYPE_NCHAR: dataLen = (columns)?columns[c].dataLen:g_args.binwidth; - rand_string(data, dataLen); + rand_string(data, dataLen - 1); pos += sprintf(buff + pos, "%s,", data); break; @@ -6389,10 +6730,18 @@ static int generateSampleFromRand( pos += sprintf(buff + pos, "%s,", tmp); break; + case TSDB_DATA_TYPE_UINT: + pos += sprintf(buff + pos, "%s,", rand_uint_str()); + break; + case TSDB_DATA_TYPE_BIGINT: pos += sprintf(buff + pos, "%s,", rand_bigint_str()); break; + case TSDB_DATA_TYPE_UBIGINT: + pos += sprintf(buff + pos, "%s,", rand_ubigint_str()); + break; + case TSDB_DATA_TYPE_FLOAT: if (g_args.demo_mode) { if (c == 0) { @@ -6414,10 +6763,18 @@ static int generateSampleFromRand( pos += sprintf(buff + pos, "%s,", rand_smallint_str()); break; + case TSDB_DATA_TYPE_USMALLINT: + pos += sprintf(buff + pos, "%s,", rand_usmallint_str()); + break; + case TSDB_DATA_TYPE_TINYINT: pos += sprintf(buff + pos, "%s,", rand_tinyint_str()); break; + case TSDB_DATA_TYPE_UTINYINT: + pos += sprintf(buff + pos, "%s,", rand_utinyint_str()); + break; + case TSDB_DATA_TYPE_BOOL: pos += sprintf(buff + pos, "%s,", rand_bool_str()); break; @@ -6941,13 +7298,17 @@ static int32_t prepareStmtBindArrayByType( char *value) { int32_t *bind_int; + uint32_t *bind_uint; int64_t *bind_bigint; + uint64_t *bind_ubigint; float *bind_float; double *bind_double; int8_t *bind_bool; int64_t *bind_ts2; int16_t *bind_smallint; + uint16_t *bind_usmallint; int8_t *bind_tinyint; + uint8_t *bind_utinyint; switch(data_type) { case TSDB_DATA_TYPE_BINARY: @@ -7012,6 +7373,22 @@ static int32_t prepareStmtBindArrayByType( bind->length = &bind->buffer_length; bind->is_null = NULL; break; + + case TSDB_DATA_TYPE_UINT: + bind_uint = malloc(sizeof(uint32_t)); + assert(bind_uint); + + if (value) { + *bind_uint = atoi(value); + } else { + *bind_uint = rand_int(); + } + bind->buffer_type = TSDB_DATA_TYPE_UINT; + bind->buffer_length = sizeof(uint32_t); + bind->buffer = bind_uint; + bind->length = &bind->buffer_length; + bind->is_null = NULL; + break; case TSDB_DATA_TYPE_BIGINT: bind_bigint = malloc(sizeof(int64_t)); @@ -7029,6 +7406,22 @@ static int32_t prepareStmtBindArrayByType( bind->is_null = NULL; break; + case TSDB_DATA_TYPE_UBIGINT: + bind_ubigint = malloc(sizeof(uint64_t)); + assert(bind_ubigint); + + if (value) { + *bind_ubigint = atoll(value); + } else { + *bind_ubigint = rand_bigint(); + } + bind->buffer_type = TSDB_DATA_TYPE_UBIGINT; + bind->buffer_length = sizeof(uint64_t); + bind->buffer = bind_ubigint; + bind->length = &bind->buffer_length; + bind->is_null = NULL; + break; + case TSDB_DATA_TYPE_FLOAT: bind_float = malloc(sizeof(float)); assert(bind_float); @@ -7077,6 +7470,22 @@ static int32_t prepareStmtBindArrayByType( bind->is_null = NULL; break; + case TSDB_DATA_TYPE_USMALLINT: + bind_usmallint = malloc(sizeof(uint16_t)); + assert(bind_usmallint); + + if (value) { + *bind_usmallint = (uint16_t)atoi(value); + } else { + *bind_usmallint = rand_smallint(); + } + bind->buffer_type = TSDB_DATA_TYPE_SMALLINT; + bind->buffer_length = sizeof(uint16_t); + bind->buffer = bind_usmallint; + bind->length = &bind->buffer_length; + bind->is_null = NULL; + break; + case TSDB_DATA_TYPE_TINYINT: bind_tinyint = malloc(sizeof(int8_t)); assert(bind_tinyint); @@ -7093,6 +7502,22 @@ static int32_t prepareStmtBindArrayByType( bind->is_null = NULL; break; + case TSDB_DATA_TYPE_UTINYINT: + bind_utinyint = malloc(sizeof(uint8_t)); + assert(bind_utinyint); + + if (value) { + *bind_utinyint = (int8_t)atoi(value); + } else { + *bind_utinyint = rand_tinyint(); + } + bind->buffer_type = TSDB_DATA_TYPE_UTINYINT; + bind->buffer_length = sizeof(uint8_t); + bind->buffer = bind_utinyint; + bind->length = &bind->buffer_length; + bind->is_null = NULL; + break; + case TSDB_DATA_TYPE_BOOL: bind_bool = malloc(sizeof(int8_t)); assert(bind_bool); @@ -7167,11 +7592,15 @@ static int32_t prepareStmtBindArrayByTypeForRand( char *value) { int32_t *bind_int; + uint32_t *bind_uint; int64_t *bind_bigint; + uint64_t *bind_ubigint; float *bind_float; double *bind_double; int16_t *bind_smallint; + uint16_t *bind_usmallint; int8_t *bind_tinyint; + uint8_t *bind_utinyint; int8_t *bind_bool; int64_t *bind_ts2; @@ -7241,6 +7670,23 @@ static int32_t prepareStmtBindArrayByTypeForRand( *ptr += bind->buffer_length; break; + case TSDB_DATA_TYPE_UINT: + bind_uint = (uint32_t *)*ptr; + + if (value) { + *bind_uint = atoi(value); + } else { + *bind_uint = rand_int(); + } + bind->buffer_type = TSDB_DATA_TYPE_UINT; + bind->buffer_length = sizeof(uint32_t); + bind->buffer = bind_uint; + bind->length = &bind->buffer_length; + bind->is_null = NULL; + + *ptr += bind->buffer_length; + break; + case TSDB_DATA_TYPE_BIGINT: bind_bigint = (int64_t *)*ptr; @@ -7258,6 +7704,23 @@ static int32_t prepareStmtBindArrayByTypeForRand( *ptr += bind->buffer_length; break; + case TSDB_DATA_TYPE_UBIGINT: + bind_ubigint = (uint64_t *)*ptr; + + if (value) { + *bind_ubigint = atoll(value); + } else { + *bind_ubigint = rand_bigint(); + } + bind->buffer_type = TSDB_DATA_TYPE_UBIGINT; + bind->buffer_length = sizeof(uint64_t); + bind->buffer = bind_ubigint; + bind->length = &bind->buffer_length; + bind->is_null = NULL; + + *ptr += bind->buffer_length; + break; + case TSDB_DATA_TYPE_FLOAT: bind_float = (float *)*ptr; @@ -7309,6 +7772,23 @@ static int32_t prepareStmtBindArrayByTypeForRand( *ptr += bind->buffer_length; break; + case TSDB_DATA_TYPE_USMALLINT: + bind_usmallint = (uint16_t *)*ptr; + + if (value) { + *bind_usmallint = (uint16_t)atoi(value); + } else { + *bind_usmallint = rand_smallint(); + } + bind->buffer_type = TSDB_DATA_TYPE_USMALLINT; + bind->buffer_length = sizeof(uint16_t); + bind->buffer = bind_usmallint; + bind->length = &bind->buffer_length; + bind->is_null = NULL; + + *ptr += bind->buffer_length; + break; + case TSDB_DATA_TYPE_TINYINT: bind_tinyint = (int8_t *)*ptr; @@ -7326,6 +7806,23 @@ static int32_t prepareStmtBindArrayByTypeForRand( *ptr += bind->buffer_length; break; + case TSDB_DATA_TYPE_UTINYINT: + bind_utinyint = (uint8_t *)*ptr; + + if (value) { + *bind_utinyint = (uint8_t)atoi(value); + } else { + *bind_utinyint = rand_tinyint(); + } + bind->buffer_type = TSDB_DATA_TYPE_UTINYINT; + bind->buffer_length = sizeof(uint8_t); + bind->buffer = bind_utinyint; + bind->length = &bind->buffer_length; + bind->is_null = NULL; + + *ptr += bind->buffer_length; + break; + case TSDB_DATA_TYPE_BOOL: bind_bool = (int8_t *)*ptr; @@ -7656,7 +8153,7 @@ UNUSED_FUNC static int32_t prepareStbStmtRand( } #if STMT_BIND_PARAM_BATCH == 1 -static int execBindParamBatch( +static int execStbBindParamBatch( threadInfo *pThreadInfo, char *tableName, int64_t tableSeq, @@ -7670,7 +8167,9 @@ static int execBindParamBatch( TAOS_STMT *stmt = pThreadInfo->stmt; SSuperTable *stbInfo = pThreadInfo->stbInfo; - uint32_t columnCount = (stbInfo)?pThreadInfo->stbInfo->columnCount:g_args.columnCount; + assert(stbInfo); + + uint32_t columnCount = pThreadInfo->stbInfo->columnCount; uint32_t thisBatch = MAX_SAMPLES - (*pSamplePos); @@ -7695,104 +8194,101 @@ static int execBindParamBatch( param->buffer = pThreadInfo->bind_ts_array; } else { - data_type = (stbInfo)?stbInfo->columns[c-1].data_type:g_args.data_type[c-1]; + data_type = stbInfo->columns[c-1].data_type; char *tmpP; switch(data_type) { case TSDB_DATA_TYPE_BINARY: + param->buffer_length = + stbInfo->columns[c-1].dataLen; + + tmpP = + (char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray + +sizeof(char*)*(c-1))); + + verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%"PRIxPTR" position=%"PRId64"\n", + __func__, __LINE__, tmpP, *pSamplePos, param->buffer_length, + (*pSamplePos) * param->buffer_length); + + param->buffer = (void *)(tmpP + *pSamplePos * param->buffer_length); + break; + case TSDB_DATA_TYPE_NCHAR: param->buffer_length = - ((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth); + stbInfo->columns[c-1].dataLen; tmpP = (char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray +sizeof(char*)*(c-1))); - verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%d position=%"PRId64"\n", - __func__, __LINE__, tmpP, *pSamplePos, - (((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth)), - (*pSamplePos) * - (((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth))); + verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%"PRIxPTR" position=%"PRId64"\n", + __func__, __LINE__, tmpP, *pSamplePos, param->buffer_length, + (*pSamplePos) * param->buffer_length); - param->buffer = (void *)(tmpP + *pSamplePos * - (((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth)) - ); + param->buffer = (void *)(tmpP + *pSamplePos * param->buffer_length); break; case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: param->buffer_length = sizeof(int32_t); - param->buffer = (stbInfo)? + param->buffer = (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) - + stbInfo->columns[c-1].dataLen * (*pSamplePos)): - (void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1)) - + sizeof(int32_t)*(*pSamplePos)); + + stbInfo->columns[c-1].dataLen * (*pSamplePos)); break; case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: param->buffer_length = sizeof(int8_t); - param->buffer = (stbInfo)? + param->buffer = (void *)((uintptr_t)*(uintptr_t*)( stbInfo->sampleBindBatchArray +sizeof(char*)*(c-1)) - + stbInfo->columns[c-1].dataLen*(*pSamplePos)): - (void *)((uintptr_t)*(uintptr_t*)( - g_sampleBindBatchArray+sizeof(char*)*(c-1)) - + sizeof(int8_t)*(*pSamplePos)); + + stbInfo->columns[c-1].dataLen*(*pSamplePos)); break; case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT: param->buffer_length = sizeof(int16_t); - param->buffer = (stbInfo)? + param->buffer = (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) - + stbInfo->columns[c-1].dataLen * (*pSamplePos)): - (void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1)) - + sizeof(int16_t)*(*pSamplePos)); + + stbInfo->columns[c-1].dataLen * (*pSamplePos)); break; case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: param->buffer_length = sizeof(int64_t); - param->buffer = (stbInfo)? + param->buffer = (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) - + stbInfo->columns[c-1].dataLen * (*pSamplePos)): - (void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1)) - + sizeof(int64_t)*(*pSamplePos)); + + stbInfo->columns[c-1].dataLen * (*pSamplePos)); break; case TSDB_DATA_TYPE_BOOL: param->buffer_length = sizeof(int8_t); - param->buffer = (stbInfo)? + param->buffer = (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) - + stbInfo->columns[c-1].dataLen * (*pSamplePos)): - (void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1)) - + sizeof(int8_t)*(*pSamplePos)); + + stbInfo->columns[c-1].dataLen * (*pSamplePos)); break; case TSDB_DATA_TYPE_FLOAT: param->buffer_length = sizeof(float); - param->buffer = (stbInfo)? + param->buffer = (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) - + stbInfo->columns[c-1].dataLen * (*pSamplePos)): - (void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1)) - + sizeof(float)*(*pSamplePos)); + + stbInfo->columns[c-1].dataLen * (*pSamplePos)); break; case TSDB_DATA_TYPE_DOUBLE: param->buffer_length = sizeof(double); - param->buffer = (stbInfo)? + param->buffer = (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) - + stbInfo->columns[c-1].dataLen * (*pSamplePos)): - (void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1)) - + sizeof(double)*(*pSamplePos)); + + stbInfo->columns[c-1].dataLen * (*pSamplePos)); break; case TSDB_DATA_TYPE_TIMESTAMP: param->buffer_length = sizeof(int64_t); - param->buffer = (stbInfo)? + param->buffer = (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) - + stbInfo->columns[c-1].dataLen * (*pSamplePos)): - (void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1)) - + sizeof(int64_t)*(*pSamplePos)); + + stbInfo->columns[c-1].dataLen * (*pSamplePos)); break; default: @@ -7813,7 +8309,7 @@ static int execBindParamBatch( if (param->buffer_type == TSDB_DATA_TYPE_NCHAR) { param->length[b] = strlen( (char *)param->buffer + b * - ((stbInfo)?stbInfo->columns[c].dataLen:g_args.binwidth) + stbInfo->columns[c].dataLen ); } else { param->length[b] = param->buffer_length; @@ -7897,24 +8393,28 @@ static int parseSamplefileToStmtBatch( switch(data_type) { case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: tmpP = calloc(1, sizeof(int) * MAX_SAMPLES); assert(tmpP); *(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP; break; case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: tmpP = calloc(1, sizeof(int8_t) * MAX_SAMPLES); assert(tmpP); *(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP; break; case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT: tmpP = calloc(1, sizeof(int16_t) * MAX_SAMPLES); assert(tmpP); *(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP; break; case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: tmpP = calloc(1, sizeof(int64_t) * MAX_SAMPLES); assert(tmpP); *(uintptr_t*)(sampleBindBatchArray+ sizeof(uintptr_t*)*c) = (uintptr_t)tmpP; @@ -7993,6 +8493,7 @@ static int parseSamplefileToStmtBatch( switch(data_type) { case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: *((int32_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray +sizeof(char*)*c)+sizeof(int32_t)*i)) = atoi(tmpStr); @@ -8011,18 +8512,21 @@ static int parseSamplefileToStmtBatch( break; case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: *((int8_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray +sizeof(char*)*c)+sizeof(int8_t)*i)) = (int8_t)atoi(tmpStr); break; case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT: *((int16_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray +sizeof(char*)*c)+sizeof(int16_t)*i)) = (int16_t)atoi(tmpStr); break; case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: *((int64_t*)((uintptr_t)*(uintptr_t*)(sampleBindBatchArray +sizeof(char*)*c)+sizeof(int64_t)*i)) = (int64_t)atol(tmpStr); @@ -8360,7 +8864,7 @@ static int32_t prepareStbStmt( } #if STMT_BIND_PARAM_BATCH == 1 - return execBindParamBatch( + return execStbBindParamBatch( pThreadInfo, tableName, tableSeq, @@ -10048,15 +10552,18 @@ static void startMultiThreadInsertData(int threads, char* db_name, } } - fprintf(stderr, "insert delay, avg: %10.2fms, max: %10.2fms, min: %10.2fms\n\n", - (double)avgDelay/1000.0, - (double)maxDelay/1000.0, - (double)minDelay/1000.0); - if (g_fpOfInsertResult) { - fprintf(g_fpOfInsertResult, "insert delay, avg:%10.2fms, max: %10.2fms, min: %10.2fms\n\n", - (double)avgDelay/1000.0, - (double)maxDelay/1000.0, - (double)minDelay/1000.0); + if (minDelay != UINT64_MAX) { + fprintf(stderr, "insert delay, avg: %10.2fms, max: %10.2fms, min: %10.2fms\n\n", + (double)avgDelay/1000.0, + (double)maxDelay/1000.0, + (double)minDelay/1000.0); + + if (g_fpOfInsertResult) { + fprintf(g_fpOfInsertResult, "insert delay, avg:%10.2fms, max: %10.2fms, min: %10.2fms\n\n", + (double)avgDelay/1000.0, + (double)maxDelay/1000.0, + (double)minDelay/1000.0); + } } //taos_close(taos); @@ -10065,11 +10572,10 @@ static void startMultiThreadInsertData(int threads, char* db_name, free(infos); } -static void *readTable(void *sarg) { -#if 1 +static void *queryNtableAggrFunc(void *sarg) { threadInfo *pThreadInfo = (threadInfo *)sarg; TAOS *taos = pThreadInfo->taos; - setThreadName("readTable"); + setThreadName("queryNtableAggrFunc"); char *command = calloc(1, BUFFER_SIZE); assert(command); @@ -10092,10 +10598,20 @@ static void *readTable(void *sarg) { int64_t ntables = pThreadInfo->ntables; // pThreadInfo->end_table_to - pThreadInfo->start_table_from + 1; int64_t totalData = insertRows * ntables; - bool do_aggreFunc = g_Dbs.do_aggreFunc; + bool aggr_func = g_Dbs.aggr_func; + + char **aggreFunc; + int n; - int n = do_aggreFunc ? (sizeof(g_aggreFunc) / sizeof(g_aggreFunc[0])) : 2; - if (!do_aggreFunc) { + if (g_args.demo_mode) { + aggreFunc = g_aggreFuncDemo; + n = aggr_func?(sizeof(g_aggreFuncDemo) / sizeof(g_aggreFuncDemo[0])) : 2; + } else { + aggreFunc = g_aggreFunc; + n = aggr_func?(sizeof(g_aggreFunc) / sizeof(g_aggreFunc[0])) : 2; + } + + if (!aggr_func) { printf("\nThe first field is either Binary or Bool. Aggregation functions are not supported.\n"); } printf("%"PRId64" records:\n", totalData); @@ -10106,9 +10622,11 @@ static void *readTable(void *sarg) { uint64_t count = 0; for (int64_t i = 0; i < ntables; i++) { sprintf(command, "SELECT %s FROM %s%"PRId64" WHERE ts>= %" PRIu64, - g_aggreFunc[j], tb_prefix, i, startTime); + aggreFunc[j], tb_prefix, i, startTime); - double t = taosGetTimestampMs(); + double t = taosGetTimestampUs(); + debugPrint("%s() LN%d, sql command: %s\n", + __func__, __LINE__, command); TAOS_RES *pSql = taos_query(taos, command); int32_t code = taos_errno(pSql); @@ -10125,29 +10643,27 @@ static void *readTable(void *sarg) { count++; } - t = taosGetTimestampMs() - t; + t = taosGetTimestampUs() - t; totalT += t; taos_free_result(pSql); } fprintf(fp, "|%10s | %"PRId64" | %12.2f | %10.2f |\n", - g_aggreFunc[j][0] == '*' ? " * " : g_aggreFunc[j], totalData, - (double)(ntables * insertRows) / totalT, totalT * 1000); - printf("select %10s took %.6f second(s)\n", g_aggreFunc[j], totalT * 1000); + aggreFunc[j][0] == '*' ? " * " : aggreFunc[j], totalData, + (double)(ntables * insertRows) / totalT, totalT / 1000000); + printf("select %10s took %.6f second(s)\n", aggreFunc[j], totalT / 1000000); } fprintf(fp, "\n"); fclose(fp); free(command); -#endif return NULL; } -static void *readMetric(void *sarg) { -#if 1 +static void *queryStableAggrFunc(void *sarg) { threadInfo *pThreadInfo = (threadInfo *)sarg; TAOS *taos = pThreadInfo->taos; - setThreadName("readMetric"); + setThreadName("queryStableAggrFunc"); char *command = calloc(1, BUFFER_SIZE); assert(command); @@ -10161,12 +10677,23 @@ static void *readMetric(void *sarg) { int64_t insertRows = pThreadInfo->stbInfo->insertRows; int64_t ntables = pThreadInfo->ntables; // pThreadInfo->end_table_to - pThreadInfo->start_table_from + 1; int64_t totalData = insertRows * ntables; - bool do_aggreFunc = g_Dbs.do_aggreFunc; + bool aggr_func = g_Dbs.aggr_func; - int n = do_aggreFunc ? (sizeof(g_aggreFunc) / sizeof(g_aggreFunc[0])) : 2; - if (!do_aggreFunc) { + char **aggreFunc; + int n; + + if (g_args.demo_mode) { + aggreFunc = g_aggreFuncDemo; + n = aggr_func?(sizeof(g_aggreFuncDemo) / sizeof(g_aggreFuncDemo[0])) : 2; + } else { + aggreFunc = g_aggreFunc; + n = aggr_func?(sizeof(g_aggreFunc) / sizeof(g_aggreFunc[0])) : 2; + } + + if (!aggr_func) { printf("\nThe first field is either Binary or Bool. Aggregation functions are not supported.\n"); } + printf("%"PRId64" records:\n", totalData); fprintf(fp, "Querying On %"PRId64" records:\n", totalData); @@ -10178,18 +10705,29 @@ static void *readMetric(void *sarg) { for (int64_t i = 1; i <= m; i++) { if (i == 1) { - sprintf(tempS, "t1 = %"PRId64"", i); + if (g_args.demo_mode) { + sprintf(tempS, "groupid = %"PRId64"", i); + } else { + sprintf(tempS, "t0 = %"PRId64"", i); + } } else { - sprintf(tempS, " or t1 = %"PRId64" ", i); + if (g_args.demo_mode) { + sprintf(tempS, " or groupid = %"PRId64" ", i); + } else { + sprintf(tempS, " or t0 = %"PRId64" ", i); + } } strncat(condition, tempS, COND_BUF_LEN - 1); - sprintf(command, "SELECT %s FROM meters WHERE %s", g_aggreFunc[j], condition); + sprintf(command, "SELECT %s FROM meters WHERE %s", aggreFunc[j], condition); printf("Where condition: %s\n", condition); + + debugPrint("%s() LN%d, sql command: %s\n", + __func__, __LINE__, command); fprintf(fp, "%s\n", command); - double t = taosGetTimestampMs(); + double t = taosGetTimestampUs(); TAOS_RES *pSql = taos_query(taos, command); int32_t code = taos_errno(pSql); @@ -10206,11 +10744,11 @@ static void *readMetric(void *sarg) { while(taos_fetch_row(pSql) != NULL) { count++; } - t = taosGetTimestampMs() - t; + t = taosGetTimestampUs() - t; fprintf(fp, "| Speed: %12.2f(per s) | Latency: %.4f(ms) |\n", - ntables * insertRows / (t * 1000.0), t); - printf("select %10s took %.6f second(s)\n\n", g_aggreFunc[j], t * 1000.0); + ntables * insertRows / (t / 1000), t); + printf("select %10s took %.6f second(s)\n\n", aggreFunc[j], t / 1000000); taos_free_result(pSql); } @@ -10218,7 +10756,7 @@ static void *readMetric(void *sarg) { } fclose(fp); free(command); -#endif + return NULL; } @@ -11225,9 +11763,8 @@ static void setParaFromArg() { tstrncpy(g_Dbs.resultFile, g_args.output_file, MAX_FILE_NAME_LEN); g_Dbs.use_metric = g_args.use_metric; - g_Dbs.insert_only = g_args.insert_only; - g_Dbs.do_aggreFunc = true; + g_Dbs.aggr_func = g_args.aggr_func; char dataString[TSDB_MAX_BYTES_PER_ROW]; char *data_type = g_args.data_type; @@ -11238,7 +11775,7 @@ static void setParaFromArg() { if ((data_type[0] == TSDB_DATA_TYPE_BINARY) || (data_type[0] == TSDB_DATA_TYPE_BOOL) || (data_type[0] == TSDB_DATA_TYPE_NCHAR)) { - g_Dbs.do_aggreFunc = false; + g_Dbs.aggr_func = false; } if (g_args.use_metric) { @@ -11420,7 +11957,7 @@ static void testMetaFile() { } } -static void queryResult() { +static void queryAggrFunc() { // query data pthread_t read_id; @@ -11429,7 +11966,6 @@ static void queryResult() { pThreadInfo->start_time = DEFAULT_START_TIME; // 2017-07-14 10:40:00.000 pThreadInfo->start_table_from = 0; - //pThreadInfo->do_aggreFunc = g_Dbs.do_aggreFunc; if (g_args.use_metric) { pThreadInfo->ntables = g_Dbs.db[0].superTbls[0].childTblCount; pThreadInfo->end_table_to = g_Dbs.db[0].superTbls[0].childTblCount - 1; @@ -11458,9 +11994,9 @@ static void queryResult() { tstrncpy(pThreadInfo->filePath, g_Dbs.resultFile, MAX_FILE_NAME_LEN); if (!g_Dbs.use_metric) { - pthread_create(&read_id, NULL, readTable, pThreadInfo); + pthread_create(&read_id, NULL, queryNtableAggrFunc, pThreadInfo); } else { - pthread_create(&read_id, NULL, readMetric, pThreadInfo); + pthread_create(&read_id, NULL, queryStableAggrFunc, pThreadInfo); } pthread_join(read_id, NULL); taos_close(pThreadInfo->taos); @@ -11482,8 +12018,9 @@ static void testCmdLine() { g_args.test_mode = INSERT_TEST; insertTestProcess(); - if (false == g_Dbs.insert_only) - queryResult(); + if (g_Dbs.aggr_func) { + queryAggrFunc(); + } } int main(int argc, char *argv[]) { diff --git a/src/kit/taosdump/CMakeLists.txt b/src/kit/taosdump/CMakeLists.txt index 51f4748eab462c8e883e83cd5923f38dd7fb9b5a..75ce520c2e6bd4fd24e25b6297c7f99cc7fdfe75 100644 --- a/src/kit/taosdump/CMakeLists.txt +++ b/src/kit/taosdump/CMakeLists.txt @@ -6,12 +6,67 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(. SRC) +FIND_PACKAGE(Git) +IF(GIT_FOUND) + EXECUTE_PROCESS( + COMMAND ${GIT_EXECUTABLE} log --pretty=oneline -n 1 ${CMAKE_CURRENT_LIST_DIR}/taosdump.c + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE TAOSDUMP_COMMIT_SHA1 + ) + IF ("${TAOSDUMP_COMMIT_SHA1}" STREQUAL "") + SET(TAOSDUMP_COMMIT_SHA1 "unknown") + ELSE () + STRING(SUBSTRING "${TAOSDUMP_COMMIT_SHA1}" 0 7 TAOSDUMP_COMMIT_SHA1) + STRING(STRIP "${TAOSDUMP_COMMIT_SHA1}" TAOSDUMP_COMMIT_SHA1) + ENDIF () + EXECUTE_PROCESS( + COMMAND ${GIT_EXECUTABLE} status -z -s ${CMAKE_CURRENT_LIST_DIR}/taosdump.c + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE TAOSDUMP_STATUS + ) + IF (TD_LINUX) + EXECUTE_PROCESS( + COMMAND bash "-c" "echo '${TAOSDUMP_STATUS}' | awk '{print $1}'" + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE TAOSDUMP_STATUS + ) + ENDIF (TD_LINUX) +ELSE() + MESSAGE("Git not found") + SET(TAOSDUMP_COMMIT_SHA1 "unknown") + SET(TAOSDUMP_STATUS "unknown") +ENDIF (GIT_FOUND) + +MESSAGE("taosdump's latest commit in short is:" ${TAOSDUMP_COMMIT_SHA1}) +STRING(STRIP "${TAOSDUMP_STATUS}" TAOSDUMP_STATUS) + +IF (TAOSDUMP_STATUS MATCHES "M") + SET(TAOSDUMP_STATUS "modified") +ELSE() + SET(TAOSDUMP_STATUS "") +ENDIF () + +MESSAGE("taosdump's status is:" ${TAOSDUMP_STATUS}) + +ADD_DEFINITIONS(-DTAOSDUMP_COMMIT_SHA1="${TAOSDUMP_COMMIT_SHA1}") +ADD_DEFINITIONS(-DTAOSDUMP_STATUS="${TAOSDUMP_STATUS}") + +MESSAGE("VERNUMBER is:" ${VERNUMBER}) +IF ("${VERNUMBER}" STREQUAL "") + SET(TD_VERSION_NUMBER "TDengine-version-unknown") +ELSE() + SET(TD_VERSION_NUMBER ${VERNUMBER}) +ENDIF () +MESSAGE("TD_VERSION_NUMBER is:" ${TD_VERSION_NUMBER}) +ADD_DEFINITIONS(-DTD_VERNUMBER="${TD_VERSION_NUMBER}") + IF (TD_LINUX) ADD_EXECUTABLE(taosdump ${SRC}) IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(taosdump taos_static) + TARGET_LINK_LIBRARIES(taosdump taos_static cJson) ELSE () - TARGET_LINK_LIBRARIES(taosdump taos) + TARGET_LINK_LIBRARIES(taosdump taos cJson) ENDIF () ENDIF () @@ -19,8 +74,8 @@ IF (TD_DARWIN) # missing for macosx # ADD_EXECUTABLE(taosdump ${SRC}) # IF (TD_SOMODE_STATIC) - # TARGET_LINK_LIBRARIES(taosdump taos_static) + # TARGET_LINK_LIBRARIES(taosdump taos_static cJson) # ELSE () - # TARGET_LINK_LIBRARIES(taosdump taos) + # TARGET_LINK_LIBRARIES(taosdump taos cJson) # ENDIF () ENDIF () diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index ef9e584978f12e636bccca28689062388ffd595c..b0235a7dcaaecb8e9f9a2ea651358380f26cd42b 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -25,7 +25,6 @@ #include "tsclient.h" #include "tsdb.h" #include "tutil.h" -#include #define TSDB_SUPPORT_NANOSECOND 1 @@ -60,7 +59,14 @@ typedef struct { fprintf(stderr, "VERB: "fmt, __VA_ARGS__); } while(0) #define errorPrint(fmt, ...) \ - do { fprintf(stderr, "\033[31m"); fprintf(stderr, "ERROR: "fmt, __VA_ARGS__); fprintf(stderr, "\033[0m"); } while(0) + do { fprintf(stderr, "\033[31m"); \ + fprintf(stderr, "ERROR: "fmt, __VA_ARGS__); \ + fprintf(stderr, "\033[0m"); } while(0) + +#define okPrint(fmt, ...) \ + do { fprintf(stderr, "\033[32m"); \ + fprintf(stderr, "OK: "fmt, __VA_ARGS__); \ + fprintf(stderr, "\033[0m"); } while(0) static bool isStringNumber(char *input) { @@ -113,7 +119,7 @@ enum _show_tables_index { TSDB_MAX_SHOW_TABLES }; -// ---------------------------------- DESCRIBE METRIC CONFIGURE ------------------------------ +// ---------------------------------- DESCRIBE STABLE CONFIGURE ------------------------------ enum _describe_table_index { TSDB_DESCRIBE_METRIC_FIELD_INDEX, TSDB_DESCRIBE_METRIC_TYPE_INDEX, @@ -141,10 +147,28 @@ extern char version[]; #define DB_PRECISION_LEN 8 #define DB_STATUS_LEN 16 +typedef struct { + char name[TSDB_TABLE_NAME_LEN]; + bool belongStb; + char stable[TSDB_TABLE_NAME_LEN]; +} TableInfo; + +typedef struct { + char name[TSDB_TABLE_NAME_LEN]; + char stable[TSDB_TABLE_NAME_LEN]; +} TableRecord; + +typedef struct { + bool isStable; + int64_t dumpNtbCount; + TableRecord **dumpNtbInfos; + TableRecord tableRecord; +} TableRecordInfo; + typedef struct { char name[TSDB_DB_NAME_LEN]; char create_time[32]; - int32_t ntables; + int64_t ntables; int32_t vgroups; int16_t replica; int16_t quorum; @@ -164,28 +188,22 @@ typedef struct { char precision[DB_PRECISION_LEN]; // time resolution int8_t update; char status[DB_STATUS_LEN]; + int64_t dumpTbCount; + TableRecordInfo **dumpTbInfos; } SDbInfo; -typedef struct { - char name[TSDB_TABLE_NAME_LEN]; - char metric[TSDB_TABLE_NAME_LEN]; -} STableRecord; - -typedef struct { - bool isMetric; - STableRecord tableRecord; -} STableRecordInfo; - typedef struct { pthread_t threadID; int32_t threadIndex; int32_t totalThreads; char dbName[TSDB_DB_NAME_LEN]; - int precision; - void *taosCon; + char stbName[TSDB_TABLE_NAME_LEN]; + int precision; + TAOS *taos; int64_t rowsOfDumpOut; int64_t tablesOfDumpOut; -} SThreadParaObj; + int64_t tableFrom; +} threadInfo; typedef struct { int64_t totalRowsOfDumpOut; @@ -197,6 +215,7 @@ typedef struct { static int64_t g_totalDumpOutRows = 0; SDbInfo **g_dbInfos = NULL; +TableInfo *g_tablesList = NULL; const char *argp_program_version = version; const char *argp_program_bug_address = ""; @@ -210,7 +229,7 @@ static char doc[] = ""; /* to force a line-break, e.g.\n<-- here."; */ /* A description of the arguments we accept. */ -static char args_doc[] = "dbname [tbname ...]\n--databases dbname ...\n--all-databases\n-i inpath\n-o outpath"; +static char args_doc[] = "dbname [tbname ...]\n--databases db1,db2,... \n--all-databases\n-i inpath\n-o outpath"; /* Keys for options without short-options. */ #define OPT_ABORT 1 /* –abort */ @@ -239,7 +258,7 @@ static struct argp_option options[] = { {"encode", 'e', "ENCODE", 0, "Input file encoding.", 1}, // dump unit options {"all-databases", 'A', 0, 0, "Dump all databases.", 2}, - {"databases", 'D', 0, 0, "Dump assigned databases", 2}, + {"databases", 'D', "DATABASES", 0, "Dump inputed databases. Use comma to seprate databases\' name.", 2}, {"allow-sys", 'a', 0, 0, "Allow to dump sys database", 2}, // dump format options {"schemaonly", 's', 0, 0, "Only dump schema.", 2}, @@ -255,6 +274,8 @@ static struct argp_option options[] = { {0} }; +#define HUMAN_TIME_LEN 28 + /* Used by main to communicate with parse_opt. */ typedef struct arguments { // connection option @@ -272,14 +293,15 @@ typedef struct arguments { // dump unit option bool all_databases; bool databases; + char *databasesSeq; // dump format option bool schemaonly; bool with_property; bool avro; int64_t start_time; - char humanStartTime[28]; + char humanStartTime[HUMAN_TIME_LEN]; int64_t end_time; - char humanEndTime[28]; + char humanEndTime[HUMAN_TIME_LEN]; char precision[8]; int32_t data_batch; @@ -290,13 +312,13 @@ typedef struct arguments { int32_t thread_num; int abort; char **arg_list; - int arg_list_len; - bool isDumpIn; - bool debug_print; - bool verbose_print; - bool performance_print; + int arg_list_len; + bool isDumpIn; + bool debug_print; + bool verbose_print; + bool performance_print; - int dbCount; + int dumpDbCount; } SArguments; /* Our argp parser. */ @@ -311,25 +333,21 @@ static int taosDumpOut(); static int taosDumpIn(); static void taosDumpCreateDbClause(SDbInfo *dbInfo, bool isDumpProperty, FILE *fp); -static int taosDumpDb(SDbInfo *dbInfo, FILE *fp, TAOS *taosCon); -static int32_t taosDumpStable(char *table, FILE *fp, TAOS* taosCon, - char* dbName); -static void taosDumpCreateTableClause(STableDef *tableDes, int numOfCols, +//static int taosDumpDb(SDbInfo *dbInfo, FILE *fp, TAOS *taos); +static int dumpStable(char *table, FILE *fp, TAOS* taos, + SDbInfo *dbInfo); +static int taosDumpCreateTableClause(STableDef *tableDes, int numOfCols, FILE *fp, char* dbName); -static void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, +static void taosDumpCreateMTableClause(STableDef *tableDes, char *stable, int numOfCols, FILE *fp, char* dbName); -static int32_t taosDumpTable(char *tbName, char *metric, - FILE *fp, TAOS* taosCon, char* dbName, int precision); -static int taosDumpTableData(FILE *fp, char *tbName, - TAOS* taosCon, char* dbName, +static int64_t taosDumpTable(char *tbName, char *stable, + FILE *fp, TAOS* taos, char* dbName, int precision); +static int64_t taosDumpTableData(FILE *fp, char *tbName, + TAOS* taos, char* dbName, int precision, char *jsonAvroSchema); static int taosCheckParam(struct arguments *arguments); static void taosFreeDbInfos(); -static void taosStartDumpOutWorkThreads( - int32_t numOfThread, - char *dbName, - int precision); struct arguments g_args = { // connection option @@ -348,10 +366,11 @@ struct arguments g_args = { "./dump_result.txt", NULL, // dump unit option - false, - false, + false, // all_databases + false, // databases + NULL, // databasesSeq // dump format option - false, // schemeonly + false, // schemaonly true, // with_property false, // avro format -INT64_MAX + 1, // start_time @@ -372,16 +391,64 @@ struct arguments g_args = { false, // debug_print false, // verbose_print false, // performance_print - 0, // dbCount + 0, // dumpDbCount }; +// get taosdump commit number version +#ifndef TAOSDUMP_COMMIT_SHA1 +#define TAOSDUMP_COMMIT_SHA1 "unknown" +#endif + +#ifndef TD_VERNUMBER +#define TD_VERNUMBER "unknown" +#endif + +#ifndef TAOSDUMP_STATUS +#define TAOSDUMP_STATUS "unknown" +#endif + +static void printVersion() { + char tdengine_ver[] = TD_VERNUMBER; + char taosdump_ver[] = TAOSDUMP_COMMIT_SHA1; + char taosdump_status[] = TAOSDUMP_STATUS; + + if (strlen(taosdump_status) == 0) { + printf("taosdump version %s-%s\n", + tdengine_ver, taosdump_ver); + } else { + printf("taosdump version %s-%s, status:%s\n", + tdengine_ver, taosdump_ver, taosdump_status); + } +} + +UNUSED_FUNC void errorWrongValue(char *program, char *wrong_arg, char *wrong_value) +{ + fprintf(stderr, "%s %s: %s is an invalid value\n", program, wrong_arg, wrong_value); + fprintf(stderr, "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); +} + +static void errorUnrecognized(char *program, char *wrong_arg) +{ + fprintf(stderr, "%s: unrecognized options '%s'\n", program, wrong_arg); + fprintf(stderr, "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); +} + +static void errorPrintReqArg(char *program, char *wrong_arg) +{ + fprintf(stderr, + "%s: option requires an argument -- '%s'\n", + program, wrong_arg); + fprintf(stderr, + "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); +} + static void errorPrintReqArg2(char *program, char *wrong_arg) { fprintf(stderr, "%s: option requires a number argument '-%s'\n", program, wrong_arg); fprintf(stderr, - "Try `taosdump --help' or `taosdump --usage' for more information.\n"); + "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); } static void errorPrintReqArg3(char *program, char *wrong_arg) @@ -390,7 +457,7 @@ static void errorPrintReqArg3(char *program, char *wrong_arg) "%s: option '%s' requires an argument\n", program, wrong_arg); fprintf(stderr, - "Try `taosdump --help' or `taosdump --usage' for more information.\n"); + "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); } /* Parse a single option. */ @@ -526,66 +593,29 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { } static int queryDbImpl(TAOS *taos, char *command) { - int i; TAOS_RES *res = NULL; int32_t code = -1; - for (i = 0; i < 5; i++) { - if (NULL != res) { - taos_free_result(res); - res = NULL; - } - - res = taos_query(taos, command); - code = taos_errno(res); - if (0 == code) { - break; - } + if (NULL != res) { + taos_free_result(res); + res = NULL; } + res = taos_query(taos, command); + code = taos_errno(res); + if (code != 0) { - errorPrint("Failed to run <%s>, reason: %s\n", command, taos_errstr(res)); + errorPrint("Failed to run <%s>, reason: %s\n", + command, taos_errstr(res)); taos_free_result(res); //taos_close(taos); - return -1; + return code; } taos_free_result(res); return 0; } -UNUSED_FUNC static void parse_precision_first( - int argc, char *argv[], SArguments *arguments) { - for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "-C") == 0) { - if (NULL == argv[i+1]) { - errorPrint("%s need a valid value following!\n", argv[i]); - exit(-1); - } - char *tmp = strdup(argv[i+1]); - if (tmp == NULL) { - errorPrint("%s() LN%d, strdup() cannot allocate memory\n", - __func__, __LINE__); - exit(-1); - } - if ((0 != strncasecmp(tmp, "ms", strlen("ms"))) - && (0 != strncasecmp(tmp, "us", strlen("us"))) -#if TSDB_SUPPORT_NANOSECOND == 1 - && (0 != strncasecmp(tmp, "ns", strlen("ns"))) -#endif - ) { - // - errorPrint("input precision: %s is invalid value\n", tmp); - free(tmp); - exit(-1); - } - tstrncpy(g_args.precision, tmp, - min(DB_PRECISION_LEN, strlen(tmp) + 1)); - free(tmp); - } - } -} - static void parse_args( int argc, char *argv[], SArguments *arguments) { @@ -611,8 +641,40 @@ static void parse_args( } else if (strcmp(argv[i], "-PP") == 0) { arguments->performance_print = true; strcpy(argv[i], ""); - } else if (strcmp(argv[i], "-A") == 0) { + } else if ((strcmp(argv[i], "-A") == 0) + || (0 == strncmp( + argv[i], "--all-database", + strlen("--all-database")))) { g_args.all_databases = true; + } else if ((strncmp(argv[i], "-D", strlen("-D")) == 0) + || (0 == strncmp( + argv[i], "--database", + strlen("--database")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "D"); + exit(EXIT_FAILURE); + } + arguments->databasesSeq = argv[++i]; + } else if (0 == strncmp(argv[i], "--databases=", strlen("--databases="))) { + arguments->databasesSeq = (char *)(argv[i] + strlen("--databases=")); + } else if (0 == strncmp(argv[i], "-D", strlen("-D"))) { + arguments->databasesSeq = (char *)(argv[i] + strlen("-D")); + } else if (strlen("--databases") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--databases"); + exit(EXIT_FAILURE); + } + arguments->databasesSeq = argv[++i]; + } else { + errorUnrecognized(argv[0], argv[i]); + exit(EXIT_FAILURE); + } + g_args.databases = true; + } else if (0 == strncmp(argv[i], "--version", strlen("--version")) || + 0 == strncmp(argv[i], "-V", strlen("-V"))) { + printVersion(); + exit(EXIT_SUCCESS); } else { continue; } @@ -623,9 +685,9 @@ static void parse_args( static void copyHumanTimeToArg(char *timeStr, bool isStartTime) { if (isStartTime) - strcpy(g_args.humanStartTime, timeStr); + tstrncpy(g_args.humanStartTime, timeStr, HUMAN_TIME_LEN); else - strcpy(g_args.humanEndTime, timeStr); + tstrncpy(g_args.humanEndTime, timeStr, HUMAN_TIME_LEN); } static void copyTimestampToArg(char *timeStr, bool isStartTime) @@ -661,6 +723,8 @@ static void parse_timestamp( } else { copyTimestampToArg(tmp, isStartTime); } + + free(tmp); } } } @@ -686,535 +750,627 @@ static int getPrecisionByString(char *precision) return -1; } -/* -static void parse_timestamp( - int argc, char *argv[], SArguments *arguments) { - for (int i = 1; i < argc; i++) { - if ((strcmp(argv[i], "-S") == 0) - || (strcmp(argv[i], "-E") == 0)) { - if (NULL == argv[i+1]) { - errorPrint("%s need a valid value following!\n", argv[i]); - exit(-1); - } - char *tmp = strdup(argv[i+1]); - if (NULL == tmp) { - errorPrint("%s() LN%d, strdup() cannot allocate memory\n", - __func__, __LINE__); - exit(-1); - } +static void taosFreeDbInfos() { + if (g_dbInfos == NULL) return; + for (int i = 0; i < g_args.dumpDbCount; i++) + tfree(g_dbInfos[i]); + tfree(g_dbInfos); +} - int64_t tmpEpoch; - if (strchr(tmp, ':') && strchr(tmp, '-')) { - strcpy(g_args.humanStartTime, tmp) - int32_t timePrec; - if (0 == strncasecmp(arguments->precision, - "ms", strlen("ms"))) { - timePrec = TSDB_TIME_PRECISION_MILLI; - } else if (0 == strncasecmp(arguments->precision, - "us", strlen("us"))) { - timePrec = TSDB_TIME_PRECISION_MICRO; -#if TSDB_SUPPORT_NANOSECOND == 1 - } else if (0 == strncasecmp(arguments->precision, - "ns", strlen("ns"))) { - timePrec = TSDB_TIME_PRECISION_NANO; -#endif - } else { - errorPrint("Invalid time precision: %s", - arguments->precision); - free(tmp); - return; - } +// check table is normal table or super table +static int taosGetTableRecordInfo( + char *dbName, + char *table, TableRecordInfo *pTableRecordInfo, TAOS *taos) { + TAOS_ROW row = NULL; + bool isSet = false; + TAOS_RES *result = NULL; - if (TSDB_CODE_SUCCESS != taosParseTime( - tmp, &tmpEpoch, strlen(tmp), - timePrec, 0)) { - errorPrint("Input %s, end time error!\n", tmp); - free(tmp); - return; - } - } else { - tstrncpy(arguments->precision, "n/a", strlen("n/a") + 1); - tmpEpoch = atoll(tmp); - } + memset(pTableRecordInfo, 0, sizeof(TableRecordInfo)); - sprintf(argv[i+1], "%"PRId64"", tmpEpoch); - debugPrint("%s() LN%d, tmp is: %s, argv[%d]: %s\n", - __func__, __LINE__, tmp, i, argv[i]); - free(tmp); - } + char command[COMMAND_SIZE]; + + sprintf(command, "USE %s", dbName); + result = taos_query(taos, command); + int32_t code = taos_errno(result); + if (code != 0) { + errorPrint("invalid database %s, reason: %s\n", + dbName, taos_errstr(result)); + return 0; } -} -*/ -int main(int argc, char *argv[]) { - static char verType[32] = {0}; - sprintf(verType, "version: %s\n", version); - argp_program_version = verType; + sprintf(command, "SHOW TABLES LIKE \'%s\'", table); - int ret = 0; - /* Parse our arguments; every option seen by parse_opt will be - reflected in arguments. */ - if (argc > 1) { -// parse_precision_first(argc, argv, &g_args); - parse_timestamp(argc, argv, &g_args); - parse_args(argc, argv, &g_args); + result = taos_query(taos, command); + code = taos_errno(result); + + if (code != 0) { + errorPrint("%s() LN%d, failed to run command <%s>. reason: %s\n", + __func__, __LINE__, command, taos_errstr(result)); + taos_free_result(result); + return -1; } - argp_parse(&argp, argc, argv, 0, 0, &g_args); + TAOS_FIELD *fields = taos_fetch_fields(result); - if (g_args.abort) { -#ifndef _ALPINE - error(10, 0, "ABORTED"); -#else - abort(); -#endif + while ((row = taos_fetch_row(result)) != NULL) { + isSet = true; + pTableRecordInfo->isStable = false; + tstrncpy(pTableRecordInfo->tableRecord.name, + (char *)row[TSDB_SHOW_TABLES_NAME_INDEX], + min(TSDB_TABLE_NAME_LEN, + fields[TSDB_SHOW_TABLES_NAME_INDEX].bytes + 1)); + tstrncpy(pTableRecordInfo->tableRecord.stable, + (char *)row[TSDB_SHOW_TABLES_METRIC_INDEX], + min(TSDB_TABLE_NAME_LEN, + fields[TSDB_SHOW_TABLES_METRIC_INDEX].bytes + 1)); + break; } - printf("====== arguments config ======\n"); - { - printf("host: %s\n", g_args.host); - printf("user: %s\n", g_args.user); - printf("password: %s\n", g_args.password); - printf("port: %u\n", g_args.port); - printf("mysqlFlag: %d\n", g_args.mysqlFlag); - printf("outpath: %s\n", g_args.outpath); - printf("inpath: %s\n", g_args.inpath); - printf("resultFile: %s\n", g_args.resultFile); - printf("encode: %s\n", g_args.encode); - printf("all_databases: %s\n", g_args.all_databases?"true":"false"); - printf("databases: %d\n", g_args.databases); - printf("schemaonly: %s\n", g_args.schemaonly?"true":"false"); - printf("with_property: %s\n", g_args.with_property?"true":"false"); - printf("avro format: %s\n", g_args.avro?"true":"false"); - printf("start_time: %" PRId64 "\n", g_args.start_time); - printf("human readable start time: %s \n", g_args.humanStartTime); - printf("end_time: %" PRId64 "\n", g_args.end_time); - printf("human readable end time: %s \n", g_args.humanEndTime); - printf("precision: %s\n", g_args.precision); - printf("data_batch: %d\n", g_args.data_batch); - printf("max_sql_len: %d\n", g_args.max_sql_len); - printf("table_batch: %d\n", g_args.table_batch); - printf("thread_num: %d\n", g_args.thread_num); - printf("allow_sys: %d\n", g_args.allow_sys); - printf("abort: %d\n", g_args.abort); - printf("isDumpIn: %d\n", g_args.isDumpIn); - printf("arg_list_len: %d\n", g_args.arg_list_len); - printf("debug_print: %d\n", g_args.debug_print); + taos_free_result(result); + result = NULL; - for (int32_t i = 0; i < g_args.arg_list_len; i++) { - printf("arg_list[%d]: %s\n", i, g_args.arg_list[i]); - } + if (isSet) { + return 0; } - printf("==============================\n"); - if (taosCheckParam(&g_args) < 0) { - exit(EXIT_FAILURE); + + sprintf(command, "SHOW STABLES LIKE \'%s\'", table); + + result = taos_query(taos, command); + code = taos_errno(result); + + if (code != 0) { + errorPrint("%s() LN%d, failed to run command <%s>. reason: %s\n", + __func__, __LINE__, command, taos_errstr(result)); + taos_free_result(result); + return -1; } - g_fpOfResult = fopen(g_args.resultFile, "a"); - if (NULL == g_fpOfResult) { - errorPrint("Failed to open %s for save result\n", g_args.resultFile); - exit(-1); - }; + while ((row = taos_fetch_row(result)) != NULL) { + isSet = true; + pTableRecordInfo->isStable = true; + tstrncpy(pTableRecordInfo->tableRecord.stable, table, + TSDB_TABLE_NAME_LEN); + break; + } - fprintf(g_fpOfResult, "#############################################################################\n"); - fprintf(g_fpOfResult, "============================== arguments config =============================\n"); - { - fprintf(g_fpOfResult, "host: %s\n", g_args.host); - fprintf(g_fpOfResult, "user: %s\n", g_args.user); - fprintf(g_fpOfResult, "password: %s\n", g_args.password); - fprintf(g_fpOfResult, "port: %u\n", g_args.port); - fprintf(g_fpOfResult, "mysqlFlag: %d\n", g_args.mysqlFlag); - fprintf(g_fpOfResult, "outpath: %s\n", g_args.outpath); - fprintf(g_fpOfResult, "inpath: %s\n", g_args.inpath); - fprintf(g_fpOfResult, "resultFile: %s\n", g_args.resultFile); - fprintf(g_fpOfResult, "encode: %s\n", g_args.encode); - fprintf(g_fpOfResult, "all_databases: %s\n", g_args.all_databases?"true":"false"); - fprintf(g_fpOfResult, "databases: %d\n", g_args.databases); - fprintf(g_fpOfResult, "schemaonly: %s\n", g_args.schemaonly?"true":"false"); - fprintf(g_fpOfResult, "with_property: %s\n", g_args.with_property?"true":"false"); - fprintf(g_fpOfResult, "avro format: %s\n", g_args.avro?"true":"false"); - fprintf(g_fpOfResult, "start_time: %" PRId64 "\n", g_args.start_time); - fprintf(g_fpOfResult, "human readable start time: %s \n", g_args.humanStartTime); - fprintf(g_fpOfResult, "end_time: %" PRId64 "\n", g_args.end_time); - fprintf(g_fpOfResult, "human readable end time: %s \n", g_args.humanEndTime); - fprintf(g_fpOfResult, "precision: %s\n", g_args.precision); - fprintf(g_fpOfResult, "data_batch: %d\n", g_args.data_batch); - fprintf(g_fpOfResult, "max_sql_len: %d\n", g_args.max_sql_len); - fprintf(g_fpOfResult, "table_batch: %d\n", g_args.table_batch); - fprintf(g_fpOfResult, "thread_num: %d\n", g_args.thread_num); - fprintf(g_fpOfResult, "allow_sys: %d\n", g_args.allow_sys); - fprintf(g_fpOfResult, "abort: %d\n", g_args.abort); - fprintf(g_fpOfResult, "isDumpIn: %d\n", g_args.isDumpIn); - fprintf(g_fpOfResult, "arg_list_len: %d\n", g_args.arg_list_len); + taos_free_result(result); + result = NULL; - for (int32_t i = 0; i < g_args.arg_list_len; i++) { - fprintf(g_fpOfResult, "arg_list[%d]: %s\n", i, g_args.arg_list[i]); - } + if (isSet) { + return 0; } + errorPrint("%s() LN%d, invalid table/stable %s\n", + __func__, __LINE__, table); + return -1; +} - g_numOfCores = (int32_t)sysconf(_SC_NPROCESSORS_ONLN); +static int inDatabasesSeq( + char *name, + int len) +{ + if (strstr(g_args.databasesSeq, ",") == NULL) { + if (0 == strncmp(g_args.databasesSeq, name, len)) { + return 0; + } + } else { + char *dupSeq = strdup(g_args.databasesSeq); + char *running = dupSeq; + char *dbname = strsep(&running, ","); + while (dbname) { + if (0 == strncmp(dbname, name, len)) { + tfree(dupSeq); + return 0; + } - time_t tTime = time(NULL); - struct tm tm = *localtime(&tTime); + dbname = strsep(&running, ","); + } - if (g_args.isDumpIn) { - fprintf(g_fpOfResult, "============================== DUMP IN ============================== \n"); - fprintf(g_fpOfResult, "# DumpIn start time: %d-%02d-%02d %02d:%02d:%02d\n", - tm.tm_year + 1900, tm.tm_mon + 1, - tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - if (taosDumpIn() < 0) { - ret = -1; + } + + return -1; +} + +static int getDumpDbCount() +{ + int count = 0; + + TAOS *taos = NULL; + TAOS_RES *result = NULL; + char *command = "show databases"; + TAOS_ROW row; + + /* Connect to server */ + taos = taos_connect(g_args.host, g_args.user, g_args.password, + NULL, g_args.port); + if (NULL == taos) { + errorPrint("Failed to connect to TDengine server %s\n", g_args.host); + return 0; + } + + result = taos_query(taos, command); + int32_t code = taos_errno(result); + + if (0 != code) { + errorPrint("%s() LN%d, failed to run command <%s>, reason: %s\n", + __func__, __LINE__, command, taos_errstr(result)); + return 0; + } + + TAOS_FIELD *fields = taos_fetch_fields(result); + + while ((row = taos_fetch_row(result)) != NULL) { + // sys database name : 'log', but subsequent version changed to 'log' + if ((strncasecmp(row[TSDB_SHOW_DB_NAME_INDEX], "log", + fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) + && (!g_args.allow_sys)) { + continue; } - } else { - fprintf(g_fpOfResult, "============================== DUMP OUT ============================== \n"); - fprintf(g_fpOfResult, "# DumpOut start time: %d-%02d-%02d %02d:%02d:%02d\n", - tm.tm_year + 1900, tm.tm_mon + 1, - tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - if (taosDumpOut() < 0) { - ret = -1; - } else { - fprintf(g_fpOfResult, "\n============================== TOTAL STATISTICS ============================== \n"); - fprintf(g_fpOfResult, "# total database count: %d\n", - g_resultStatistics.totalDatabasesOfDumpOut); - fprintf(g_fpOfResult, "# total super table count: %d\n", - g_resultStatistics.totalSuperTblsOfDumpOut); - fprintf(g_fpOfResult, "# total child table count: %"PRId64"\n", - g_resultStatistics.totalChildTblsOfDumpOut); - fprintf(g_fpOfResult, "# total row count: %"PRId64"\n", - g_resultStatistics.totalRowsOfDumpOut); + + if (g_args.databases) { // input multi dbs + if (inDatabasesSeq( + (char *)row[TSDB_SHOW_DB_NAME_INDEX], + fields[TSDB_SHOW_DB_NAME_INDEX].bytes) != 0) + continue; + } else if (!g_args.all_databases) { // only input one db + if (strncasecmp(g_args.arg_list[0], + (char *)row[TSDB_SHOW_DB_NAME_INDEX], + fields[TSDB_SHOW_DB_NAME_INDEX].bytes) != 0) + continue; } + + count++; } - fprintf(g_fpOfResult, "\n"); - fclose(g_fpOfResult); + if (count == 0) { + errorPrint("%d databases valid to dump\n", count); + } - return ret; + return count; } -static void taosFreeDbInfos() { - if (g_dbInfos == NULL) return; - for (int i = 0; i < g_args.dbCount; i++) - tfree(g_dbInfos[i]); - tfree(g_dbInfos); -} +static int64_t dumpNormalTableWithoutStb(TAOS *taos, SDbInfo *dbInfo, char *ntbName) +{ + int64_t count = 0; -// check table is normal table or super table -static int taosGetTableRecordInfo( - char *table, STableRecordInfo *pTableRecordInfo, TAOS *taosCon) { - TAOS_ROW row = NULL; - bool isSet = false; - TAOS_RES *result = NULL; + char tmpBuf[4096] = {0}; + FILE *fp = NULL; - memset(pTableRecordInfo, 0, sizeof(STableRecordInfo)); + if (g_args.outpath[0] != 0) { + sprintf(tmpBuf, "%s/%s.%s.sql", + g_args.outpath, dbInfo->name, ntbName); + } else { + sprintf(tmpBuf, "%s.%s.sql", + dbInfo->name, ntbName); + } - char* tempCommand = (char *)malloc(COMMAND_SIZE); - if (tempCommand == NULL) { - errorPrint("%s() LN%d, failed to allocate memory\n", - __func__, __LINE__); + fp = fopen(tmpBuf, "w"); + if (fp == NULL) { + errorPrint("%s() LN%d, failed to open file %s\n", + __func__, __LINE__, tmpBuf); return -1; } - sprintf(tempCommand, "show tables like %s", table); + count = taosDumpTable(ntbName, NULL, + fp, taos, dbInfo->name, getPrecisionByString(dbInfo->precision)); - result = taos_query(taosCon, tempCommand); - int32_t code = taos_errno(result); + fclose(fp); + return count; +} - if (code != 0) { - errorPrint("%s() LN%d, failed to run command %s\n", - __func__, __LINE__, tempCommand); - free(tempCommand); - taos_free_result(result); - return -1; +static int64_t dumpNormalTable(FILE *fp, TAOS *taos, char *dbName, char *tbName, + char *stbName, + int precision) +{ + int64_t count = 0; + count = taosDumpTable(tbName, stbName, + fp, taos, dbName, precision); + + return count; +} + +static void *dumpNtbOfDb(void *arg) { + threadInfo *pThreadInfo = (threadInfo *)arg; + + debugPrint("dump table from = \t%"PRId64"\n", pThreadInfo->tableFrom); + debugPrint("dump table count = \t%"PRId64"\n", + pThreadInfo->tablesOfDumpOut); + + FILE *fp = NULL; + char tmpBuf[4096] = {0}; + + if (g_args.outpath[0] != 0) { + sprintf(tmpBuf, "%s/%s.%d.sql", + g_args.outpath, pThreadInfo->dbName, pThreadInfo->threadIndex); + } else { + sprintf(tmpBuf, "%s.%d.sql", + pThreadInfo->dbName, pThreadInfo->threadIndex); } - TAOS_FIELD *fields = taos_fetch_fields(result); + fp = fopen(tmpBuf, "w"); - while ((row = taos_fetch_row(result)) != NULL) { - isSet = true; - pTableRecordInfo->isMetric = false; - tstrncpy(pTableRecordInfo->tableRecord.name, - (char *)row[TSDB_SHOW_TABLES_NAME_INDEX], - min(TSDB_TABLE_NAME_LEN, - fields[TSDB_SHOW_TABLES_NAME_INDEX].bytes + 1)); - tstrncpy(pTableRecordInfo->tableRecord.metric, - (char *)row[TSDB_SHOW_TABLES_METRIC_INDEX], - min(TSDB_TABLE_NAME_LEN, - fields[TSDB_SHOW_TABLES_METRIC_INDEX].bytes + 1)); - break; + if (fp == NULL) { + errorPrint("%s() LN%d, failed to open file %s\n", + __func__, __LINE__, tmpBuf); + return NULL; } - taos_free_result(result); - result = NULL; + for (int64_t i = 0; i < pThreadInfo->tablesOfDumpOut; i++) { + debugPrint("[%d] No.\t%"PRId64" table name: %s\n", + pThreadInfo->threadIndex, i, + ((TableInfo *)(g_tablesList + pThreadInfo->tableFrom+i))->name); + dumpNormalTable(fp, + pThreadInfo->taos, + pThreadInfo->dbName, + ((TableInfo *)(g_tablesList + pThreadInfo->tableFrom+i))->name, + ((TableInfo *)(g_tablesList + pThreadInfo->tableFrom+i))->stable, + pThreadInfo->precision); + } - if (isSet) { - free(tempCommand); - return 0; + fclose(fp); + + return NULL; +} + +static void *dumpNormalTablesOfStb(void *arg) { + threadInfo *pThreadInfo = (threadInfo *)arg; + + debugPrint("dump table from = \t%"PRId64"\n", pThreadInfo->tableFrom); + debugPrint("dump table count = \t%"PRId64"\n", pThreadInfo->tablesOfDumpOut); + + char command[COMMAND_SIZE]; + + sprintf(command, "SELECT TBNAME FROM %s.%s LIMIT %"PRId64" OFFSET %"PRId64"", + pThreadInfo->dbName, pThreadInfo->stbName, + pThreadInfo->tablesOfDumpOut, pThreadInfo->tableFrom); + + TAOS_RES *res = taos_query(pThreadInfo->taos, command); + int32_t code = taos_errno(res); + if (code) { + errorPrint("%s() LN%d, failed to run command <%s>. reason: %s\n", + __func__, __LINE__, command, taos_errstr(res)); + taos_free_result(res); + return NULL; } - sprintf(tempCommand, "show stables like %s", table); + FILE *fp = NULL; + char tmpBuf[4096] = {0}; - result = taos_query(taosCon, tempCommand); - code = taos_errno(result); + if (g_args.outpath[0] != 0) { + sprintf(tmpBuf, "%s/%s.%d.sql", + g_args.outpath, pThreadInfo->dbName, pThreadInfo->threadIndex); + } else { + sprintf(tmpBuf, "%s.%d.sql", + pThreadInfo->dbName, pThreadInfo->threadIndex); + } - if (code != 0) { - errorPrint("%s() LN%d, failed to run command %s\n", - __func__, __LINE__, tempCommand); - free(tempCommand); - taos_free_result(result); - return -1; + fp = fopen(tmpBuf, "w"); + + if (fp == NULL) { + errorPrint("%s() LN%d, failed to open file %s\n", + __func__, __LINE__, tmpBuf); + return NULL; } - while ((row = taos_fetch_row(result)) != NULL) { - isSet = true; - pTableRecordInfo->isMetric = true; - tstrncpy(pTableRecordInfo->tableRecord.metric, table, - TSDB_TABLE_NAME_LEN); - break; + TAOS_ROW row = NULL; + int64_t i = 0; + while((row = taos_fetch_row(res)) != NULL) { + debugPrint("[%d] sub table %"PRId64": name: %s\n", + pThreadInfo->threadIndex, i++, (char *)row[TSDB_SHOW_TABLES_NAME_INDEX]); + + dumpNormalTable(fp, + pThreadInfo->taos, + pThreadInfo->dbName, + (char *)row[TSDB_SHOW_TABLES_NAME_INDEX], + (char *)row[TSDB_SHOW_TABLES_METRIC_INDEX], + pThreadInfo->precision); } - taos_free_result(result); - result = NULL; + fclose(fp); + return NULL; +} - if (isSet) { - free(tempCommand); +static int64_t dumpNtbOfDbByThreads( + SDbInfo *dbInfo, + int64_t ntbCount) +{ + if (ntbCount <= 0) { return 0; } - errorPrint("%s() LN%d, invalid table/metric %s\n", - __func__, __LINE__, table); - free(tempCommand); - return -1; -} + int threads = g_args.thread_num; + + int64_t a = ntbCount / threads; + if (a < 1) { + threads = ntbCount; + a = 1; + } + + assert(threads); + int64_t b = ntbCount % threads; + + threadInfo *infos = calloc(1, threads * sizeof(threadInfo)); + pthread_t *pids = calloc(1, threads * sizeof(pthread_t)); + assert(pids); + assert(infos); -static int32_t taosSaveAllNormalTableToTempFile(TAOS *taosCon, char*meter, - char* metric, int* fd) { - STableRecord tableRecord; + for (int64_t i = 0; i < threads; i++) { + threadInfo *pThreadInfo = infos + i; + pThreadInfo->taos = taos_connect( + g_args.host, + g_args.user, + g_args.password, + dbInfo->name, + g_args.port + ); + if (NULL == pThreadInfo->taos) { + errorPrint("%s() LN%d, Failed to connect to TDengine, reason: %s\n", + __func__, + __LINE__, + taos_errstr(NULL)); + free(pids); + free(infos); - if (-1 == *fd) { - *fd = open(".tables.tmp.0", - O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH); - if (*fd == -1) { - errorPrint("%s() LN%d, failed to open temp file: .tables.tmp.0\n", - __func__, __LINE__); return -1; } + + pThreadInfo->threadIndex = i; + pThreadInfo->tablesOfDumpOut = (itableFrom = (i==0)?0: + ((threadInfo *)(infos + i - 1))->tableFrom + + ((threadInfo *)(infos + i - 1))->tablesOfDumpOut; + strcpy(pThreadInfo->dbName, dbInfo->name); + pThreadInfo->precision = getPrecisionByString(dbInfo->precision); + + pthread_create(pids + i, NULL, dumpNtbOfDb, pThreadInfo); + } + + for (int64_t i = 0; i < threads; i++) { + pthread_join(pids[i], NULL); } - memset(&tableRecord, 0, sizeof(STableRecord)); - tstrncpy(tableRecord.name, meter, TSDB_TABLE_NAME_LEN); - tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN); + for (int64_t i = 0; i < threads; i++) { + threadInfo *pThreadInfo = infos + i; + taos_close(pThreadInfo->taos); + } + + free(pids); + free(infos); - taosWrite(*fd, &tableRecord, sizeof(STableRecord)); return 0; } -static int32_t taosSaveTableOfMetricToTempFile( - TAOS *taosCon, char* metric, - int32_t* totalNumOfThread) { - TAOS_ROW row; - int fd = -1; - STableRecord tableRecord; +static int64_t getNtbCountOfStb(TAOS *taos, char *dbName, char *stbName) +{ + int64_t count = 0; - char* tmpCommand = (char *)malloc(COMMAND_SIZE); - if (tmpCommand == NULL) { - errorPrint("%s() LN%d, failed to allocate memory\n", __func__, __LINE__); - return -1; - } + char command[COMMAND_SIZE]; - sprintf(tmpCommand, "select tbname from %s", metric); + sprintf(command, "SELECT COUNT(TBNAME) FROM %s.%s", dbName, stbName); - TAOS_RES *res = taos_query(taosCon, tmpCommand); + TAOS_RES *res = taos_query(taos, command); int32_t code = taos_errno(res); if (code != 0) { - errorPrint("%s() LN%d, failed to run command %s\n", - __func__, __LINE__, tmpCommand); - free(tmpCommand); + errorPrint("%s() LN%d, failed to run command <%s>. reason: %s\n", + __func__, __LINE__, command, taos_errstr(res)); taos_free_result(res); return -1; } - free(tmpCommand); - char tmpBuf[MAX_FILE_NAME_LEN]; - memset(tmpBuf, 0, MAX_FILE_NAME_LEN); - sprintf(tmpBuf, ".select-tbname.tmp"); - fd = open(tmpBuf, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH); - if (fd == -1) { - errorPrint("%s() LN%d, failed to open temp file: %s\n", - __func__, __LINE__, tmpBuf); - taos_free_result(res); - return -1; - } + TAOS_ROW row = NULL; - TAOS_FIELD *fields = taos_fetch_fields(res); + if ((row = taos_fetch_row(res)) != NULL) { + count = *(int64_t*)row[TSDB_SHOW_TABLES_NAME_INDEX]; + } - int32_t numOfTable = 0; - while ((row = taos_fetch_row(res)) != NULL) { + return count; +} - memset(&tableRecord, 0, sizeof(STableRecord)); - tstrncpy(tableRecord.name, (char *)row[0], fields[0].bytes); - tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN); +static int64_t dumpNtbOfStbByThreads( + TAOS *taos, + SDbInfo *dbInfo, char *stbName) +{ + int64_t ntbCount = getNtbCountOfStb(taos, dbInfo->name, stbName); - taosWrite(fd, &tableRecord, sizeof(STableRecord)); - numOfTable++; + if (ntbCount <= 0) { + return 0; } - taos_free_result(res); - lseek(fd, 0, SEEK_SET); - int maxThreads = g_args.thread_num; - int tableOfPerFile ; - if (numOfTable <= g_args.thread_num) { - tableOfPerFile = 1; - maxThreads = numOfTable; - } else { - tableOfPerFile = numOfTable / g_args.thread_num; - if (0 != numOfTable % g_args.thread_num) { - tableOfPerFile += 1; - } - } + int threads = g_args.thread_num; - char* tblBuf = (char*)calloc(1, tableOfPerFile * sizeof(STableRecord)); - if (NULL == tblBuf){ - errorPrint("%s() LN%d, failed to calloc %" PRIzu "\n", - __func__, __LINE__, tableOfPerFile * sizeof(STableRecord)); - close(fd); - return -1; + int64_t a = ntbCount / threads; + if (a < 1) { + threads = ntbCount; + a = 1; } - int32_t numOfThread = *totalNumOfThread; - int subFd = -1; - for (; numOfThread <= maxThreads; numOfThread++) { - memset(tmpBuf, 0, MAX_FILE_NAME_LEN); - sprintf(tmpBuf, ".tables.tmp.%d", numOfThread); - subFd = open(tmpBuf, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH); - if (subFd == -1) { - errorPrint("%s() LN%d, failed to open temp file: %s\n", - __func__, __LINE__, tmpBuf); - for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) { - sprintf(tmpBuf, ".tables.tmp.%d", loopCnt); - (void)remove(tmpBuf); - } - sprintf(tmpBuf, ".select-tbname.tmp"); - (void)remove(tmpBuf); - free(tblBuf); - close(fd); + assert(threads); + int64_t b = ntbCount % threads; + + pthread_t *pids = calloc(1, threads * sizeof(pthread_t)); + threadInfo *infos = calloc(1, threads * sizeof(threadInfo)); + assert(pids); + assert(infos); + + for (int64_t i = 0; i < threads; i++) { + threadInfo *pThreadInfo = infos + i; + pThreadInfo->taos = taos_connect( + g_args.host, + g_args.user, + g_args.password, + dbInfo->name, + g_args.port + ); + if (NULL == pThreadInfo->taos) { + errorPrint("%s() LN%d, Failed to connect to TDengine, reason: %s\n", + __func__, + __LINE__, + taos_errstr(NULL)); + free(pids); + free(infos); + return -1; } - // read tableOfPerFile for fd, write to subFd - ssize_t readLen = read(fd, tblBuf, tableOfPerFile * sizeof(STableRecord)); - if (readLen <= 0) { - close(subFd); - break; - } - taosWrite(subFd, tblBuf, readLen); - close(subFd); + pThreadInfo->threadIndex = i; + pThreadInfo->tablesOfDumpOut = (itableFrom = (i==0)?0: + ((threadInfo *)(infos + i - 1))->tableFrom + + ((threadInfo *)(infos + i - 1))->tablesOfDumpOut; + strcpy(pThreadInfo->dbName, dbInfo->name); + pThreadInfo->precision = getPrecisionByString(dbInfo->precision); + + strcpy(pThreadInfo->stbName, stbName); + pthread_create(pids + i, NULL, dumpNormalTablesOfStb, pThreadInfo); + } + + for (int64_t i = 0; i < threads; i++) { + pthread_join(pids[i], NULL); } - sprintf(tmpBuf, ".select-tbname.tmp"); - (void)remove(tmpBuf); - if (fd >= 0) { - close(fd); - fd = -1; + int64_t records = 0; + for (int64_t i = 0; i < threads; i++) { + threadInfo *pThreadInfo = infos + i; + records += pThreadInfo->rowsOfDumpOut; + taos_close(pThreadInfo->taos); } - *totalNumOfThread = numOfThread; + free(pids); + free(infos); - free(tblBuf); - return 0; + return records; } -static int getDbCount() +static int64_t dumpCreateSTableClauseOfDb( + SDbInfo *dbInfo, FILE *fp) { - int count; + TAOS *taos = taos_connect(g_args.host, + g_args.user, g_args.password, dbInfo->name, g_args.port); + if (NULL == taos) { + errorPrint( + "Failed to connect to TDengine server %s by specified database %s\n", + g_args.host, dbInfo->name); + return 0; + } - TAOS *taos = NULL; - TAOS_RES *result = NULL; - char *command = NULL; TAOS_ROW row; + char command[COMMAND_SIZE] = {0}; - command = (char *)malloc(COMMAND_SIZE); - if (command == NULL) { - errorPrint("%s() LN%d, failed to allocate command buffer\n", __func__, __LINE__); - return 0; + sprintf(command, "SHOW %s.STABLES", dbInfo->name); + + TAOS_RES* res = taos_query(taos, command); + int32_t code = taos_errno(res); + if (code != 0) { + errorPrint("%s() LN%d, failed to run command <%s>, reason: %s\n", + __func__, __LINE__, command, taos_errstr(res)); + taos_free_result(res); + taos_close(taos); + exit(-1); } - /* Connect to server */ - taos = taos_connect(g_args.host, g_args.user, g_args.password, - NULL, g_args.port); + int64_t superTblCnt = 0; + while ((row = taos_fetch_row(res)) != NULL) { + if (0 == dumpStable(row[TSDB_SHOW_TABLES_NAME_INDEX], fp, taos, dbInfo)) { + superTblCnt ++; + } + } + + taos_free_result(res); + + fprintf(g_fpOfResult, + "# super table counter: %"PRId64"\n", + superTblCnt); + g_resultStatistics.totalSuperTblsOfDumpOut += superTblCnt; + + taos_close(taos); + + return superTblCnt; +} + +static int64_t dumpNTablesOfDb(SDbInfo *dbInfo) +{ + TAOS *taos = taos_connect(g_args.host, + g_args.user, g_args.password, dbInfo->name, g_args.port); if (NULL == taos) { - errorPrint("Failed to connect to TDengine server %s\n", g_args.host); - free(command); + errorPrint( + "Failed to connect to TDengine server %s by specified database %s\n", + g_args.host, dbInfo->name); return 0; } - sprintf(command, "show databases"); + char command[COMMAND_SIZE]; + TAOS_RES *result; + int32_t code; + + sprintf(command, "USE %s", dbInfo->name); result = taos_query(taos, command); - int32_t code = taos_errno(result); + code = taos_errno(result); + if (code != 0) { + errorPrint("invalid database %s, reason: %s\n", + dbInfo->name, taos_errstr(result)); + taos_close(taos); + return 0; + } - if (0 != code) { - errorPrint("%s() LN%d, failed to run command: %s, reason: %s\n", - __func__, __LINE__, command, taos_errstr(result)); - free(command); + sprintf(command, "SHOW TABLES"); + result = taos_query(taos, command); + code = taos_errno(result); + if (code != 0) { + errorPrint("Failed to show %s\'s tables, reason: %s\n", + dbInfo->name, taos_errstr(result)); + taos_close(taos); return 0; } - TAOS_FIELD *fields = taos_fetch_fields(result); + g_tablesList = calloc(1, dbInfo->ntables * sizeof(TableInfo)); - while ((row = taos_fetch_row(result)) != NULL) { - // sys database name : 'log', but subsequent version changed to 'log' - if ((strncasecmp(row[TSDB_SHOW_DB_NAME_INDEX], "log", - fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) - && (!g_args.allow_sys)) { - continue; - } + TAOS_ROW row; + int64_t count = 0; + while(NULL != (row = taos_fetch_row(result))) { + debugPrint("%s() LN%d, No.\t%"PRId64" table name: %s\n", + __func__, __LINE__, + count, (char *)row[TSDB_SHOW_TABLES_NAME_INDEX]); + tstrncpy(((TableInfo *)(g_tablesList + count))->name, + (char *)row[TSDB_SHOW_TABLES_NAME_INDEX], TSDB_TABLE_NAME_LEN); + char *stbName = (char *) row[TSDB_SHOW_TABLES_METRIC_INDEX]; + if (stbName) { + tstrncpy(((TableInfo *)(g_tablesList + count))->stable, + (char *)row[TSDB_SHOW_TABLES_METRIC_INDEX], TSDB_TABLE_NAME_LEN); + ((TableInfo *)(g_tablesList + count))->belongStb = true; + } + count ++; + } + taos_close(taos); - if (g_args.databases) { // input multi dbs - for (int i = 0; g_args.arg_list[i]; i++) { - if (strncasecmp(g_args.arg_list[i], - (char *)row[TSDB_SHOW_DB_NAME_INDEX], - fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) - goto _dump_db_point; - } - continue; - } else if (!g_args.all_databases) { // only input one db - if (strncasecmp(g_args.arg_list[0], - (char *)row[TSDB_SHOW_DB_NAME_INDEX], - fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) - goto _dump_db_point; - else - continue; - } + int64_t records = dumpNtbOfDbByThreads(dbInfo, count); -_dump_db_point: + free(g_tablesList); + g_tablesList = NULL; - count++; + return records; +} - if (g_args.databases) { - if (count > g_args.arg_list_len) break; +static int64_t dumpWholeDatabase(SDbInfo *dbInfo, FILE *fp) +{ + taosDumpCreateDbClause(dbInfo, g_args.with_property, fp); - } else if (!g_args.all_databases) { - if (count >= 1) break; - } - } + fprintf(g_fpOfResult, "\n#### database: %s\n", + dbInfo->name); + g_resultStatistics.totalDatabasesOfDumpOut++; - if (count == 0) { - errorPrint("%d databases valid to dump\n", count); - } + dumpCreateSTableClauseOfDb(dbInfo, fp); - free(command); - return count; + return dumpNTablesOfDb(dbInfo); } static int taosDumpOut() { TAOS *taos = NULL; TAOS_RES *result = NULL; - char *command = NULL; TAOS_ROW row; FILE *fp = NULL; int32_t count = 0; - STableRecordInfo tableRecordInfo; + TableRecordInfo tableRecordInfo; char tmpBuf[4096] = {0}; if (g_args.outpath[0] != 0) { @@ -1230,25 +1386,24 @@ static int taosDumpOut() { return -1; } - g_args.dbCount = getDbCount(); + g_args.dumpDbCount = getDumpDbCount(); + debugPrint("%s() LN%d, dump db count: %d\n", + __func__, __LINE__, g_args.dumpDbCount); - if (0 == g_args.dbCount) { - errorPrint("%d databases valid to dump\n", g_args.dbCount); + if (0 == g_args.dumpDbCount) { + errorPrint("%d databases valid to dump\n", g_args.dumpDbCount); + fclose(fp); return -1; } - g_dbInfos = (SDbInfo **)calloc(g_args.dbCount, sizeof(SDbInfo *)); + g_dbInfos = (SDbInfo **)calloc(g_args.dumpDbCount, sizeof(SDbInfo *)); if (g_dbInfos == NULL) { errorPrint("%s() LN%d, failed to allocate memory\n", __func__, __LINE__); goto _exit_failure; } - command = (char *)malloc(COMMAND_SIZE); - if (command == NULL) { - errorPrint("%s() LN%d, failed to allocate memory\n", __func__, __LINE__); - goto _exit_failure; - } + char command[COMMAND_SIZE]; /* Connect to server */ taos = taos_connect(g_args.host, g_args.user, g_args.password, @@ -1268,7 +1423,7 @@ static int taosDumpOut() { int32_t code = taos_errno(result); if (code != 0) { - errorPrint("%s() LN%d, failed to run command: %s, reason: %s\n", + errorPrint("%s() LN%d, failed to run command <%s>, reason: %s\n", __func__, __LINE__, command, taos_errstr(result)); goto _exit_failure; } @@ -1284,24 +1439,18 @@ static int taosDumpOut() { } if (g_args.databases) { // input multi dbs - for (int i = 0; g_args.arg_list[i]; i++) { - if (strncasecmp(g_args.arg_list[i], - (char *)row[TSDB_SHOW_DB_NAME_INDEX], - fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) - goto _dump_db_point; + if (inDatabasesSeq( + (char *)row[TSDB_SHOW_DB_NAME_INDEX], + fields[TSDB_SHOW_DB_NAME_INDEX].bytes) != 0) { + continue; } - continue; } else if (!g_args.all_databases) { // only input one db if (strncasecmp(g_args.arg_list[0], (char *)row[TSDB_SHOW_DB_NAME_INDEX], - fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) - goto _dump_db_point; - else + fields[TSDB_SHOW_DB_NAME_INDEX].bytes) != 0) continue; } -_dump_db_point: - g_dbInfos[count] = (SDbInfo *)calloc(1, sizeof(SDbInfo)); if (g_dbInfos[count] == NULL) { errorPrint("%s() LN%d, failed to allocate %"PRIu64" memory\n", @@ -1309,41 +1458,59 @@ _dump_db_point: goto _exit_failure; } + okPrint("%s exists\n", (char *)row[TSDB_SHOW_DB_NAME_INDEX]); tstrncpy(g_dbInfos[count]->name, (char *)row[TSDB_SHOW_DB_NAME_INDEX], - min(TSDB_DB_NAME_LEN, fields[TSDB_SHOW_DB_NAME_INDEX].bytes + 1)); + min(TSDB_DB_NAME_LEN, + fields[TSDB_SHOW_DB_NAME_INDEX].bytes + 1)); if (g_args.with_property) { - g_dbInfos[count]->ntables = *((int32_t *)row[TSDB_SHOW_DB_NTABLES_INDEX]); - g_dbInfos[count]->vgroups = *((int32_t *)row[TSDB_SHOW_DB_VGROUPS_INDEX]); - g_dbInfos[count]->replica = *((int16_t *)row[TSDB_SHOW_DB_REPLICA_INDEX]); - g_dbInfos[count]->quorum = *((int16_t *)row[TSDB_SHOW_DB_QUORUM_INDEX]); - g_dbInfos[count]->days = *((int16_t *)row[TSDB_SHOW_DB_DAYS_INDEX]); - - tstrncpy(g_dbInfos[count]->keeplist, (char *)row[TSDB_SHOW_DB_KEEP_INDEX], + g_dbInfos[count]->ntables = + *((int32_t *)row[TSDB_SHOW_DB_NTABLES_INDEX]); + g_dbInfos[count]->vgroups = + *((int32_t *)row[TSDB_SHOW_DB_VGROUPS_INDEX]); + g_dbInfos[count]->replica = + *((int16_t *)row[TSDB_SHOW_DB_REPLICA_INDEX]); + g_dbInfos[count]->quorum = + *((int16_t *)row[TSDB_SHOW_DB_QUORUM_INDEX]); + g_dbInfos[count]->days = + *((int16_t *)row[TSDB_SHOW_DB_DAYS_INDEX]); + + tstrncpy(g_dbInfos[count]->keeplist, + (char *)row[TSDB_SHOW_DB_KEEP_INDEX], min(32, fields[TSDB_SHOW_DB_KEEP_INDEX].bytes + 1)); //g_dbInfos[count]->daysToKeep = *((int16_t *)row[TSDB_SHOW_DB_KEEP_INDEX]); //g_dbInfos[count]->daysToKeep1; //g_dbInfos[count]->daysToKeep2; - g_dbInfos[count]->cache = *((int32_t *)row[TSDB_SHOW_DB_CACHE_INDEX]); - g_dbInfos[count]->blocks = *((int32_t *)row[TSDB_SHOW_DB_BLOCKS_INDEX]); - g_dbInfos[count]->minrows = *((int32_t *)row[TSDB_SHOW_DB_MINROWS_INDEX]); - g_dbInfos[count]->maxrows = *((int32_t *)row[TSDB_SHOW_DB_MAXROWS_INDEX]); - g_dbInfos[count]->wallevel = *((int8_t *)row[TSDB_SHOW_DB_WALLEVEL_INDEX]); - g_dbInfos[count]->fsync = *((int32_t *)row[TSDB_SHOW_DB_FSYNC_INDEX]); - g_dbInfos[count]->comp = (int8_t)(*((int8_t *)row[TSDB_SHOW_DB_COMP_INDEX])); - g_dbInfos[count]->cachelast = (int8_t)(*((int8_t *)row[TSDB_SHOW_DB_CACHELAST_INDEX])); + g_dbInfos[count]->cache = + *((int32_t *)row[TSDB_SHOW_DB_CACHE_INDEX]); + g_dbInfos[count]->blocks = + *((int32_t *)row[TSDB_SHOW_DB_BLOCKS_INDEX]); + g_dbInfos[count]->minrows = + *((int32_t *)row[TSDB_SHOW_DB_MINROWS_INDEX]); + g_dbInfos[count]->maxrows = + *((int32_t *)row[TSDB_SHOW_DB_MAXROWS_INDEX]); + g_dbInfos[count]->wallevel = + *((int8_t *)row[TSDB_SHOW_DB_WALLEVEL_INDEX]); + g_dbInfos[count]->fsync = + *((int32_t *)row[TSDB_SHOW_DB_FSYNC_INDEX]); + g_dbInfos[count]->comp = + (int8_t)(*((int8_t *)row[TSDB_SHOW_DB_COMP_INDEX])); + g_dbInfos[count]->cachelast = + (int8_t)(*((int8_t *)row[TSDB_SHOW_DB_CACHELAST_INDEX])); tstrncpy(g_dbInfos[count]->precision, (char *)row[TSDB_SHOW_DB_PRECISION_INDEX], DB_PRECISION_LEN); - g_dbInfos[count]->update = *((int8_t *)row[TSDB_SHOW_DB_UPDATE_INDEX]); + g_dbInfos[count]->update = + *((int8_t *)row[TSDB_SHOW_DB_UPDATE_INDEX]); } count++; if (g_args.databases) { - if (count > g_args.arg_list_len) break; - + if (count > g_args.dumpDbCount) + break; } else if (!g_args.all_databases) { - if (count >= 1) break; + if (count >= 1) + break; } } @@ -1352,94 +1519,52 @@ _dump_db_point: goto _exit_failure; } - if (g_args.databases || g_args.all_databases) { // case: taosdump --databases dbx dby ... OR taosdump --all-databases + if (g_args.databases || g_args.all_databases) { // case: taosdump --databases dbx,dby ... OR taosdump --all-databases for (int i = 0; i < count; i++) { - taosDumpDb(g_dbInfos[i], fp, taos); + int64_t records = 0; + records = dumpWholeDatabase(g_dbInfos[i], fp); + if (records >= 0) { + okPrint("Database %s dumped\n", g_dbInfos[i]->name); + g_totalDumpOutRows += records; + } } } else { - if (g_args.arg_list_len == 1) { // case: taosdump - taosDumpDb(g_dbInfos[0], fp, taos); - } else { // case: taosdump tablex tabley ... + if (1 == g_args.arg_list_len) { + int64_t records = dumpWholeDatabase(g_dbInfos[0], fp); + if (records >= 0) { + okPrint("Database %s dumped\n", g_dbInfos[0]->name); + g_totalDumpOutRows += records; + } + } else { taosDumpCreateDbClause(g_dbInfos[0], g_args.with_property, fp); - fprintf(g_fpOfResult, "\n#### database: %s\n", - g_dbInfos[0]->name); - g_resultStatistics.totalDatabasesOfDumpOut++; - - sprintf(command, "use %s", g_dbInfos[0]->name); + } - result = taos_query(taos, command); - code = taos_errno(result); - if (code != 0) { - errorPrint("invalid database %s\n", g_dbInfos[0]->name); - goto _exit_failure; + int superTblCnt = 0 ; + for (int i = 1; g_args.arg_list[i]; i++) { + if (taosGetTableRecordInfo(g_dbInfos[0]->name, + g_args.arg_list[i], + &tableRecordInfo, taos) < 0) { + errorPrint("input the invalid table %s\n", + g_args.arg_list[i]); + continue; } - fprintf(fp, "USE %s;\n\n", g_dbInfos[0]->name); - - int32_t totalNumOfThread = 1; // 0: all normal table into .tables.tmp.0 - int normalTblFd = -1; - int32_t retCode; - int superTblCnt = 0 ; - for (int i = 1; g_args.arg_list[i]; i++) { - if (taosGetTableRecordInfo(g_args.arg_list[i], - &tableRecordInfo, taos) < 0) { - errorPrint("input the invalid table %s\n", - g_args.arg_list[i]); - continue; - } - - if (tableRecordInfo.isMetric) { // dump all table of this metric - int ret = taosDumpStable( - tableRecordInfo.tableRecord.metric, - fp, taos, g_dbInfos[0]->name); - if (0 == ret) { - superTblCnt++; - } - retCode = taosSaveTableOfMetricToTempFile( - taos, tableRecordInfo.tableRecord.metric, - &totalNumOfThread); - } else { - if (tableRecordInfo.tableRecord.metric[0] != '\0') { // dump this sub table and it's metric - int ret = taosDumpStable( - tableRecordInfo.tableRecord.metric, - fp, taos, g_dbInfos[0]->name); - if (0 == ret) { - superTblCnt++; - } - } - retCode = taosSaveAllNormalTableToTempFile( - taos, tableRecordInfo.tableRecord.name, - tableRecordInfo.tableRecord.metric, &normalTblFd); - } - - if (retCode < 0) { - if (-1 != normalTblFd){ - taosClose(normalTblFd); - } - goto _clean_tmp_file; + int64_t records = 0; + if (tableRecordInfo.isStable) { // dump all table of this stable + int ret = dumpStable( + tableRecordInfo.tableRecord.stable, + fp, taos, g_dbInfos[0]); + if (ret >= 0) { + superTblCnt++; + records = dumpNtbOfStbByThreads(taos, g_dbInfos[0], g_args.arg_list[i]); } + } else { + records = dumpNormalTableWithoutStb(taos, g_dbInfos[0], g_args.arg_list[i]); } - // TODO: save dump super table into result_output.txt - fprintf(g_fpOfResult, "# super table counter: %d\n", - superTblCnt); - g_resultStatistics.totalSuperTblsOfDumpOut += superTblCnt; - - if (-1 != normalTblFd){ - taosClose(normalTblFd); - } - - // start multi threads to dumpout - - taosStartDumpOutWorkThreads(totalNumOfThread, - g_dbInfos[0]->name, - getPrecisionByString(g_dbInfos[0]->precision)); - - char tmpFileName[MAX_FILE_NAME_LEN]; -_clean_tmp_file: - for (int loopCnt = 0; loopCnt < totalNumOfThread; loopCnt++) { - sprintf(tmpFileName, ".tables.tmp.%d", loopCnt); - remove(tmpFileName); + if (records >= 0) { + okPrint("table: %s dumped\n", g_args.arg_list[i]); + g_totalDumpOutRows += records; } } } @@ -1448,7 +1573,6 @@ _clean_tmp_file: fclose(fp); taos_close(taos); taos_free_result(result); - tfree(command); taosFreeDbInfos(); fprintf(stderr, "dump out rows: %" PRId64 "\n", g_totalDumpOutRows); return 0; @@ -1457,7 +1581,6 @@ _exit_failure: fclose(fp); taos_close(taos); taos_free_result(result); - tfree(command); taosFreeDbInfos(); errorPrint("dump out rows: %" PRId64 "\n", g_totalDumpOutRows); return -1; @@ -1465,18 +1588,18 @@ _exit_failure: static int taosGetTableDes( char* dbName, char *table, - STableDef *stableDes, TAOS* taosCon, bool isSuperTable) { + STableDef *stableDes, TAOS* taos, bool isSuperTable) { TAOS_ROW row = NULL; TAOS_RES* res = NULL; - int count = 0; + int colCount = 0; char sqlstr[COMMAND_SIZE]; sprintf(sqlstr, "describe %s.%s;", dbName, table); - res = taos_query(taosCon, sqlstr); + res = taos_query(taos, sqlstr); int32_t code = taos_errno(res); if (code != 0) { - errorPrint("%s() LN%d, failed to run command <%s>, reason:%s\n", + errorPrint("%s() LN%d, failed to run command <%s>, reason: %s\n", __func__, __LINE__, sqlstr, taos_errstr(res)); taos_free_result(res); return -1; @@ -1486,41 +1609,41 @@ static int taosGetTableDes( tstrncpy(stableDes->name, table, TSDB_TABLE_NAME_LEN); while ((row = taos_fetch_row(res)) != NULL) { - tstrncpy(stableDes->cols[count].field, + tstrncpy(stableDes->cols[colCount].field, (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX], min(TSDB_COL_NAME_LEN + 1, fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes + 1)); - tstrncpy(stableDes->cols[count].type, + tstrncpy(stableDes->cols[colCount].type, (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], min(16, fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes + 1)); - stableDes->cols[count].length = + stableDes->cols[colCount].length = *((int *)row[TSDB_DESCRIBE_METRIC_LENGTH_INDEX]); - tstrncpy(stableDes->cols[count].note, + tstrncpy(stableDes->cols[colCount].note, (char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX], min(COL_NOTE_LEN, fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes + 1)); - count++; + colCount++; } taos_free_result(res); res = NULL; if (isSuperTable) { - return count; + return colCount; } // if child-table have tag, using select tagName from table to get tagValue - for (int i = 0 ; i < count; i++) { + for (int i = 0 ; i < colCount; i++) { if (strcmp(stableDes->cols[i].note, "TAG") != 0) continue; sprintf(sqlstr, "select %s from %s.%s", stableDes->cols[i].field, dbName, table); - res = taos_query(taosCon, sqlstr); + res = taos_query(taos, sqlstr); code = taos_errno(res); if (code != 0) { - errorPrint("%s() LN%d, failed to run command <%s>, reason:%s\n", + errorPrint("%s() LN%d, failed to run command <%s>, reason: %s\n", __func__, __LINE__, sqlstr, taos_errstr(res)); taos_free_result(res); return -1; @@ -1536,7 +1659,7 @@ static int taosGetTableDes( return -1; } - if (row[0] == NULL) { + if (row[TSDB_SHOW_TABLES_NAME_INDEX] == NULL) { sprintf(stableDes->cols[i].note, "%s", "NULL"); taos_free_result(res); res = NULL; @@ -1549,32 +1672,33 @@ static int taosGetTableDes( switch (fields[0].type) { case TSDB_DATA_TYPE_BOOL: sprintf(stableDes->cols[i].note, "%d", - ((((int32_t)(*((char *)row[0]))) == 1) ? 1 : 0)); + ((((int32_t)(*((char *)row[TSDB_SHOW_TABLES_NAME_INDEX]))) == 1) ? 1 : 0)); break; case TSDB_DATA_TYPE_TINYINT: - sprintf(stableDes->cols[i].note, "%d", *((int8_t *)row[0])); + sprintf(stableDes->cols[i].note, "%d", + *((int8_t *)row[TSDB_SHOW_TABLES_NAME_INDEX])); break; case TSDB_DATA_TYPE_SMALLINT: - sprintf(stableDes->cols[i].note, "%d", *((int16_t *)row[0])); + sprintf(stableDes->cols[i].note, "%d", *((int16_t *)row[TSDB_SHOW_TABLES_NAME_INDEX])); break; case TSDB_DATA_TYPE_INT: - sprintf(stableDes->cols[i].note, "%d", *((int32_t *)row[0])); + sprintf(stableDes->cols[i].note, "%d", *((int32_t *)row[TSDB_SHOW_TABLES_NAME_INDEX])); break; case TSDB_DATA_TYPE_BIGINT: - sprintf(stableDes->cols[i].note, "%" PRId64 "", *((int64_t *)row[0])); + sprintf(stableDes->cols[i].note, "%" PRId64 "", *((int64_t *)row[TSDB_SHOW_TABLES_NAME_INDEX])); break; case TSDB_DATA_TYPE_FLOAT: - sprintf(stableDes->cols[i].note, "%f", GET_FLOAT_VAL(row[0])); + sprintf(stableDes->cols[i].note, "%f", GET_FLOAT_VAL(row[TSDB_SHOW_TABLES_NAME_INDEX])); break; case TSDB_DATA_TYPE_DOUBLE: - sprintf(stableDes->cols[i].note, "%f", GET_DOUBLE_VAL(row[0])); + sprintf(stableDes->cols[i].note, "%f", GET_DOUBLE_VAL(row[TSDB_SHOW_TABLES_NAME_INDEX])); break; case TSDB_DATA_TYPE_BINARY: { memset(stableDes->cols[i].note, 0, sizeof(stableDes->cols[i].note)); stableDes->cols[i].note[0] = '\''; char tbuf[COL_NOTE_LEN]; - converStringToReadable((char *)row[0], length[0], tbuf, COL_NOTE_LEN); + converStringToReadable((char *)row[TSDB_SHOW_TABLES_NAME_INDEX], length[0], tbuf, COL_NOTE_LEN); char* pstr = stpcpy(&(stableDes->cols[i].note[1]), tbuf); *(pstr++) = '\''; break; @@ -1583,18 +1707,18 @@ static int taosGetTableDes( { memset(stableDes->cols[i].note, 0, sizeof(stableDes->cols[i].note)); char tbuf[COL_NOTE_LEN-2]; // need reserve 2 bytes for ' ' - convertNCharToReadable((char *)row[0], length[0], tbuf, COL_NOTE_LEN); + convertNCharToReadable((char *)row[TSDB_SHOW_TABLES_NAME_INDEX], length[0], tbuf, COL_NOTE_LEN); sprintf(stableDes->cols[i].note, "\'%s\'", tbuf); break; } case TSDB_DATA_TYPE_TIMESTAMP: - sprintf(stableDes->cols[i].note, "%" PRId64 "", *(int64_t *)row[0]); + sprintf(stableDes->cols[i].note, "%" PRId64 "", *(int64_t *)row[TSDB_SHOW_TABLES_NAME_INDEX]); #if 0 if (!g_args.mysqlFlag) { - sprintf(tableDes->cols[i].note, "%" PRId64 "", *(int64_t *)row[0]); + sprintf(tableDes->cols[i].note, "%" PRId64 "", *(int64_t *)row[TSDB_SHOW_TABLES_NAME_INDEX]); } else { char buf[64] = "\0"; - int64_t ts = *((int64_t *)row[0]); + int64_t ts = *((int64_t *)row[TSDB_SHOW_TABLES_NAME_INDEX]); time_t tt = (time_t)(ts / 1000); struct tm *ptm = localtime(&tt); strftime(buf, 64, "%y-%m-%d %H:%M:%S", ptm); @@ -1602,499 +1726,137 @@ static int taosGetTableDes( } #endif break; - default: - break; - } - - taos_free_result(res); - res = NULL; - } - - return count; -} - -static int convertSchemaToAvroSchema(STableDef *stableDes, char **avroSchema) -{ - errorPrint("%s() LN%d TODO: covert table schema to avro schema\n", - __func__, __LINE__); - return 0; -} - -static int32_t taosDumpTable( - char *tbName, char *metric, - FILE *fp, TAOS* taosCon, char* dbName, int precision) { - int count = 0; - - STableDef *tableDes = (STableDef *)calloc(1, sizeof(STableDef) - + sizeof(SColDes) * TSDB_MAX_COLUMNS); - - if (metric != NULL && metric[0] != '\0') { // dump table schema which is created by using super table - /* - count = taosGetTableDes(metric, tableDes, taosCon); - - if (count < 0) { - free(tableDes); - return -1; - } - - taosDumpCreateTableClause(tableDes, count, fp); - - memset(tableDes, 0, sizeof(STableDef) + sizeof(SColDes) * TSDB_MAX_COLUMNS); - */ - - count = taosGetTableDes(dbName, tbName, tableDes, taosCon, false); - - if (count < 0) { - free(tableDes); - return -1; - } - - // create child-table using super-table - taosDumpCreateMTableClause(tableDes, metric, count, fp, dbName); - - } else { // dump table definition - count = taosGetTableDes(dbName, tbName, tableDes, taosCon, false); - - if (count < 0) { - free(tableDes); - return -1; - } - - // create normal-table or super-table - taosDumpCreateTableClause(tableDes, count, fp, dbName); - } - - char *jsonAvroSchema = NULL; - if (g_args.avro) { - convertSchemaToAvroSchema(tableDes, &jsonAvroSchema); - } - - free(tableDes); - - int32_t ret = 0; - if (!g_args.schemaonly) { - ret = taosDumpTableData(fp, tbName, taosCon, dbName, precision, - jsonAvroSchema); - } - - return ret; -} - -static void taosDumpCreateDbClause( - SDbInfo *dbInfo, bool isDumpProperty, FILE *fp) { - char sqlstr[TSDB_MAX_SQL_LEN] = {0}; - - char *pstr = sqlstr; - pstr += sprintf(pstr, "CREATE DATABASE IF NOT EXISTS %s ", dbInfo->name); - if (isDumpProperty) { - pstr += sprintf(pstr, - "REPLICA %d QUORUM %d DAYS %d KEEP %s CACHE %d BLOCKS %d MINROWS %d MAXROWS %d FSYNC %d CACHELAST %d COMP %d PRECISION '%s' UPDATE %d", - dbInfo->replica, dbInfo->quorum, dbInfo->days, - dbInfo->keeplist, - dbInfo->cache, - dbInfo->blocks, dbInfo->minrows, dbInfo->maxrows, - dbInfo->fsync, - dbInfo->cachelast, - dbInfo->comp, dbInfo->precision, dbInfo->update); - } - - pstr += sprintf(pstr, ";"); - fprintf(fp, "%s\n\n", sqlstr); -} - -static void* taosDumpOutWorkThreadFp(void *arg) -{ - SThreadParaObj *pThread = (SThreadParaObj*)arg; - STableRecord tableRecord; - int fd; - - setThreadName("dumpOutWorkThrd"); - - char tmpBuf[4096] = {0}; - sprintf(tmpBuf, ".tables.tmp.%d", pThread->threadIndex); - fd = open(tmpBuf, O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH); - if (fd == -1) { - errorPrint("%s() LN%d, failed to open temp file: %s\n", - __func__, __LINE__, tmpBuf); - return NULL; - } - - FILE *fp = NULL; - memset(tmpBuf, 0, 4096); - - if (g_args.outpath[0] != 0) { - sprintf(tmpBuf, "%s/%s.tables.%d.sql", - g_args.outpath, pThread->dbName, pThread->threadIndex); - } else { - sprintf(tmpBuf, "%s.tables.%d.sql", - pThread->dbName, pThread->threadIndex); - } - - fp = fopen(tmpBuf, "w"); - if (fp == NULL) { - errorPrint("%s() LN%d, failed to open file %s\n", - __func__, __LINE__, tmpBuf); - close(fd); - return NULL; - } - - memset(tmpBuf, 0, 4096); - sprintf(tmpBuf, "use %s", pThread->dbName); - - TAOS_RES* tmpResult = taos_query(pThread->taosCon, tmpBuf); - int32_t code = taos_errno(tmpResult); - if (code != 0) { - errorPrint("%s() LN%d, invalid database %s. reason: %s\n", - __func__, __LINE__, pThread->dbName, taos_errstr(tmpResult)); - taos_free_result(tmpResult); - fclose(fp); - close(fd); - return NULL; - } - -#if 0 - int fileNameIndex = 1; - int tablesInOneFile = 0; -#endif - int64_t lastRowsPrint = 5000000; - fprintf(fp, "USE %s;\n\n", pThread->dbName); - while (1) { - ssize_t readLen = read(fd, &tableRecord, sizeof(STableRecord)); - if (readLen <= 0) break; - - int ret = taosDumpTable( - tableRecord.name, tableRecord.metric, - fp, pThread->taosCon, pThread->dbName, - pThread->precision); - if (ret >= 0) { - // TODO: sum table count and table rows by self - pThread->tablesOfDumpOut++; - pThread->rowsOfDumpOut += ret; - - if (pThread->rowsOfDumpOut >= lastRowsPrint) { - printf(" %"PRId64 " rows already be dumpout from database %s\n", - pThread->rowsOfDumpOut, pThread->dbName); - lastRowsPrint += 5000000; - } - -#if 0 - tablesInOneFile++; - if (tablesInOneFile >= g_args.table_batch) { - fclose(fp); - tablesInOneFile = 0; - - memset(tmpBuf, 0, 4096); - if (g_args.outpath[0] != 0) { - sprintf(tmpBuf, "%s/%s.tables.%d-%d.sql", - g_args.outpath, pThread->dbName, - pThread->threadIndex, fileNameIndex); - } else { - sprintf(tmpBuf, "%s.tables.%d-%d.sql", - pThread->dbName, pThread->threadIndex, fileNameIndex); - } - fileNameIndex++; - - fp = fopen(tmpBuf, "w"); - if (fp == NULL) { - errorPrint("%s() LN%d, failed to open file %s\n", - __func__, __LINE__, tmpBuf); - close(fd); - taos_free_result(tmpResult); - return NULL; - } - } -#endif - } - } - - taos_free_result(tmpResult); - close(fd); - fclose(fp); - - return NULL; -} - -static void taosStartDumpOutWorkThreads(int32_t numOfThread, char *dbName, int precision) -{ - pthread_attr_t thattr; - SThreadParaObj *threadObj = - (SThreadParaObj *)calloc(numOfThread, sizeof(SThreadParaObj)); - - if (threadObj == NULL) { - errorPrint("%s() LN%d, memory allocation failed!\n", - __func__, __LINE__); - return; - } - - for (int t = 0; t < numOfThread; ++t) { - SThreadParaObj *pThread = threadObj + t; - pThread->rowsOfDumpOut = 0; - pThread->tablesOfDumpOut = 0; - pThread->threadIndex = t; - pThread->totalThreads = numOfThread; - tstrncpy(pThread->dbName, dbName, TSDB_DB_NAME_LEN); - pThread->precision = precision; - pThread->taosCon = taos_connect(g_args.host, g_args.user, g_args.password, - NULL, g_args.port); - if (pThread->taosCon == NULL) { - errorPrint("Failed to connect to TDengine server %s\n", g_args.host); - free(threadObj); - return; - } - pthread_attr_init(&thattr); - pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); - - if (pthread_create(&(pThread->threadID), &thattr, - taosDumpOutWorkThreadFp, - (void*)pThread) != 0) { - errorPrint("%s() LN%d, thread:%d failed to start\n", - __func__, __LINE__, pThread->threadIndex); - exit(-1); - } - } - - for (int32_t t = 0; t < numOfThread; ++t) { - pthread_join(threadObj[t].threadID, NULL); - } - - // TODO: sum all thread dump table count and rows of per table, then save into result_output.txt - int64_t totalRowsOfDumpOut = 0; - int64_t totalChildTblsOfDumpOut = 0; - for (int32_t t = 0; t < numOfThread; ++t) { - totalChildTblsOfDumpOut += threadObj[t].tablesOfDumpOut; - totalRowsOfDumpOut += threadObj[t].rowsOfDumpOut; - } - - fprintf(g_fpOfResult, "# child table counter: %"PRId64"\n", - totalChildTblsOfDumpOut); - fprintf(g_fpOfResult, "# row counter: %"PRId64"\n", - totalRowsOfDumpOut); - g_resultStatistics.totalChildTblsOfDumpOut += totalChildTblsOfDumpOut; - g_resultStatistics.totalRowsOfDumpOut += totalRowsOfDumpOut; - free(threadObj); -} - -static int32_t taosDumpStable(char *table, FILE *fp, - TAOS* taosCon, char* dbName) { - - uint64_t sizeOfTableDes = - (uint64_t)(sizeof(STableDef) + sizeof(SColDes) * TSDB_MAX_COLUMNS); - STableDef *stableDes = (STableDef *)calloc(1, sizeOfTableDes); - if (NULL == stableDes) { - errorPrint("%s() LN%d, failed to allocate %"PRIu64" memory\n", - __func__, __LINE__, sizeOfTableDes); - exit(-1); - } - - int count = taosGetTableDes(dbName, table, stableDes, taosCon, true); - - if (count < 0) { - free(stableDes); - errorPrint("%s() LN%d, failed to get stable[%s] schema\n", - __func__, __LINE__, table); - exit(-1); - } - - taosDumpCreateTableClause(stableDes, count, fp, dbName); - - free(stableDes); - return 0; -} - -static int32_t taosDumpCreateSuperTableClause(TAOS* taosCon, char* dbName, FILE *fp) -{ - TAOS_ROW row; - int fd = -1; - STableRecord tableRecord; - char sqlstr[TSDB_MAX_SQL_LEN] = {0}; - - sprintf(sqlstr, "show %s.stables", dbName); - - TAOS_RES* res = taos_query(taosCon, sqlstr); - int32_t code = taos_errno(res); - if (code != 0) { - errorPrint("%s() LN%d, failed to run command <%s>, reason: %s\n", - __func__, __LINE__, sqlstr, taos_errstr(res)); - taos_free_result(res); - exit(-1); - } - - TAOS_FIELD *fields = taos_fetch_fields(res); - - char tmpFileName[MAX_FILE_NAME_LEN]; - memset(tmpFileName, 0, MAX_FILE_NAME_LEN); - sprintf(tmpFileName, ".stables.tmp"); - fd = open(tmpFileName, O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH); - if (fd == -1) { - errorPrint("%s() LN%d, failed to open temp file: %s\n", - __func__, __LINE__, tmpFileName); - taos_free_result(res); - (void)remove(".stables.tmp"); - exit(-1); - } - - while ((row = taos_fetch_row(res)) != NULL) { - memset(&tableRecord, 0, sizeof(STableRecord)); - tstrncpy(tableRecord.name, (char *)row[TSDB_SHOW_TABLES_NAME_INDEX], - min(TSDB_TABLE_NAME_LEN, - fields[TSDB_SHOW_TABLES_NAME_INDEX].bytes + 1)); - taosWrite(fd, &tableRecord, sizeof(STableRecord)); - } - - taos_free_result(res); - (void)lseek(fd, 0, SEEK_SET); - - int superTblCnt = 0; - while (1) { - ssize_t readLen = read(fd, &tableRecord, sizeof(STableRecord)); - if (readLen <= 0) break; - - int ret = taosDumpStable(tableRecord.name, fp, taosCon, dbName); - if (0 == ret) { - superTblCnt++; + default: + break; } - } - // TODO: save dump super table into result_output.txt - fprintf(g_fpOfResult, "# super table counter: %d\n", superTblCnt); - g_resultStatistics.totalSuperTblsOfDumpOut += superTblCnt; + taos_free_result(res); + res = NULL; + } - close(fd); - (void)remove(".stables.tmp"); + return colCount; +} +static int convertSchemaToAvroSchema(STableDef *stableDes, char **avroSchema) +{ + errorPrint("%s() LN%d TODO: covert table schema to avro schema\n", + __func__, __LINE__); return 0; } +static int64_t taosDumpTable( + char *tbName, char *stable, + FILE *fp, TAOS* taos, char* dbName, int precision) { + int colCount = 0; -static int taosDumpDb(SDbInfo *dbInfo, FILE *fp, TAOS *taosCon) { - TAOS_ROW row; - int fd = -1; - STableRecord tableRecord; + STableDef *tableDes = (STableDef *)calloc(1, sizeof(STableDef) + + sizeof(SColDes) * TSDB_MAX_COLUMNS); - taosDumpCreateDbClause(dbInfo, g_args.with_property, fp); + if (stable != NULL && stable[0] != '\0') { // dump table schema which is created by using super table + /* + colCount = taosGetTableDes(stable, tableDes, taos); - fprintf(g_fpOfResult, "\n#### database: %s\n", - dbInfo->name); - g_resultStatistics.totalDatabasesOfDumpOut++; + if (count < 0) { + free(tableDes); + return -1; + } - char sqlstr[TSDB_MAX_SQL_LEN] = {0}; + taosDumpCreateTableClause(tableDes, count, fp); - fprintf(fp, "USE %s;\n\n", dbInfo->name); + memset(tableDes, 0, sizeof(STableDef) + sizeof(SColDes) * TSDB_MAX_COLUMNS); + */ - (void)taosDumpCreateSuperTableClause(taosCon, dbInfo->name, fp); + colCount = taosGetTableDes(dbName, tbName, tableDes, taos, false); - sprintf(sqlstr, "show %s.tables", dbInfo->name); + if (colCount < 0) { + free(tableDes); + return -1; + } - TAOS_RES* res = taos_query(taosCon, sqlstr); - int code = taos_errno(res); - if (code != 0) { - errorPrint("%s() LN%d, failed to run command <%s>, reason:%s\n", - __func__, __LINE__, sqlstr, taos_errstr(res)); - taos_free_result(res); - return -1; + // create child-table using super-table + taosDumpCreateMTableClause(tableDes, stable, colCount, fp, dbName); + + } else { // dump table definition + colCount = taosGetTableDes(dbName, tbName, tableDes, taos, false); + + if (colCount < 0) { + free(tableDes); + return -1; + } + + // create normal-table or super-table + taosDumpCreateTableClause(tableDes, colCount, fp, dbName); } - char tmpBuf[MAX_FILE_NAME_LEN]; - memset(tmpBuf, 0, MAX_FILE_NAME_LEN); - sprintf(tmpBuf, ".show-tables.tmp"); - fd = open(tmpBuf, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH); - if (fd == -1) { - errorPrint("%s() LN%d, failed to open temp file: %s\n", - __func__, __LINE__, tmpBuf); - taos_free_result(res); - return -1; + char *jsonAvroSchema = NULL; + if (g_args.avro) { + convertSchemaToAvroSchema(tableDes, &jsonAvroSchema); } - TAOS_FIELD *fields = taos_fetch_fields(res); + free(tableDes); - int32_t numOfTable = 0; - while ((row = taos_fetch_row(res)) != NULL) { - memset(&tableRecord, 0, sizeof(STableRecord)); - tstrncpy(tableRecord.name, (char *)row[TSDB_SHOW_TABLES_NAME_INDEX], - min(TSDB_TABLE_NAME_LEN, - fields[TSDB_SHOW_TABLES_NAME_INDEX].bytes + 1)); - tstrncpy(tableRecord.metric, (char *)row[TSDB_SHOW_TABLES_METRIC_INDEX], - min(TSDB_TABLE_NAME_LEN, - fields[TSDB_SHOW_TABLES_METRIC_INDEX].bytes + 1)); + int64_t ret = 0; + if (!g_args.schemaonly) { + ret = taosDumpTableData(fp, tbName, taos, dbName, precision, + jsonAvroSchema); + } - taosWrite(fd, &tableRecord, sizeof(STableRecord)); + return ret; +} - numOfTable++; - } - taos_free_result(res); - lseek(fd, 0, SEEK_SET); +static void taosDumpCreateDbClause( + SDbInfo *dbInfo, bool isDumpProperty, FILE *fp) { + char sqlstr[TSDB_MAX_SQL_LEN] = {0}; - int maxThreads = g_args.thread_num; - int tableOfPerFile ; - if (numOfTable <= g_args.thread_num) { - tableOfPerFile = 1; - maxThreads = numOfTable; - } else { - tableOfPerFile = numOfTable / g_args.thread_num; - if (0 != numOfTable % g_args.thread_num) { - tableOfPerFile += 1; - } + char *pstr = sqlstr; + pstr += sprintf(pstr, "CREATE DATABASE IF NOT EXISTS %s ", dbInfo->name); + if (isDumpProperty) { + pstr += sprintf(pstr, + "REPLICA %d QUORUM %d DAYS %d KEEP %s CACHE %d BLOCKS %d MINROWS %d MAXROWS %d FSYNC %d CACHELAST %d COMP %d PRECISION '%s' UPDATE %d", + dbInfo->replica, dbInfo->quorum, dbInfo->days, + dbInfo->keeplist, + dbInfo->cache, + dbInfo->blocks, dbInfo->minrows, dbInfo->maxrows, + dbInfo->fsync, + dbInfo->cachelast, + dbInfo->comp, dbInfo->precision, dbInfo->update); } - char* tblBuf = (char*)calloc(1, tableOfPerFile * sizeof(STableRecord)); - if (NULL == tblBuf){ - errorPrint("failed to calloc %" PRIzu "\n", - tableOfPerFile * sizeof(STableRecord)); - close(fd); - return -1; - } + pstr += sprintf(pstr, ";"); + fprintf(fp, "%s\n\n", sqlstr); +} - int32_t numOfThread = 0; - int subFd = -1; - for (numOfThread = 0; numOfThread < maxThreads; numOfThread++) { - memset(tmpBuf, 0, MAX_FILE_NAME_LEN); - sprintf(tmpBuf, ".tables.tmp.%d", numOfThread); - subFd = open(tmpBuf, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH); - if (subFd == -1) { - errorPrint("%s() LN%d, failed to open temp file: %s\n", - __func__, __LINE__, tmpBuf); - for (int32_t loopCnt = 0; loopCnt < numOfThread; loopCnt++) { - sprintf(tmpBuf, ".tables.tmp.%d", loopCnt); - (void)remove(tmpBuf); - } - sprintf(tmpBuf, ".show-tables.tmp"); - (void)remove(tmpBuf); - free(tblBuf); - close(fd); - return -1; - } +static int dumpStable(char *stbName, FILE *fp, + TAOS* taos, SDbInfo *dbInfo) +{ - // read tableOfPerFile for fd, write to subFd - ssize_t readLen = read(fd, tblBuf, tableOfPerFile * sizeof(STableRecord)); - if (readLen <= 0) { - close(subFd); - break; - } - taosWrite(subFd, tblBuf, readLen); - close(subFd); + uint64_t sizeOfTableDes = + (uint64_t)(sizeof(STableDef) + sizeof(SColDes) * TSDB_MAX_COLUMNS); + + STableDef *stableDes = (STableDef *)calloc(1, sizeOfTableDes); + if (NULL == stableDes) { + errorPrint("%s() LN%d, failed to allocate %"PRIu64" memory\n", + __func__, __LINE__, sizeOfTableDes); + exit(-1); } - sprintf(tmpBuf, ".show-tables.tmp"); - (void)remove(tmpBuf); + int colCount = taosGetTableDes(dbInfo->name, + stbName, stableDes, taos, true); - if (fd >= 0) { - close(fd); - fd = -1; + if (colCount < 0) { + free(stableDes); + errorPrint("%s() LN%d, failed to get stable[%s] schema\n", + __func__, __LINE__, stbName); + exit(-1); } - // start multi threads to dumpout - taosStartDumpOutWorkThreads(numOfThread, dbInfo->name, - getPrecisionByString(dbInfo->precision)); - for (int loopCnt = 0; loopCnt < numOfThread; loopCnt++) { - sprintf(tmpBuf, ".tables.tmp.%d", loopCnt); - (void)remove(tmpBuf); - } + taosDumpCreateTableClause(stableDes, colCount, fp, dbInfo->name); + free(stableDes); - free(tblBuf); return 0; } -static void taosDumpCreateTableClause(STableDef *tableDes, int numOfCols, +static int taosDumpCreateTableClause(STableDef *tableDes, int numOfCols, FILE *fp, char* dbName) { int counter = 0; int count_temp = 0; @@ -2141,10 +1903,11 @@ static void taosDumpCreateTableClause(STableDef *tableDes, int numOfCols, pstr += sprintf(pstr, ");"); - fprintf(fp, "%s\n\n", sqlstr); + debugPrint("%s() LN%d, write string: %s\n", __func__, __LINE__, sqlstr); + return fprintf(fp, "%s\n\n", sqlstr); } -static void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, +static void taosDumpCreateMTableClause(STableDef *tableDes, char *stable, int numOfCols, FILE *fp, char* dbName) { int counter = 0; int count_temp = 0; @@ -2161,7 +1924,7 @@ static void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, pstr += sprintf(tmpBuf, "CREATE TABLE IF NOT EXISTS %s.%s USING %s.%s TAGS (", - dbName, tableDes->name, dbName, metric); + dbName, tableDes->name, dbName, stable); for (; counter < numOfCols; counter++) { if (tableDes->cols[counter].note[0] != '\0') break; @@ -2361,8 +2124,8 @@ static int64_t writeResultToSql(TAOS_RES *res, FILE *fp, char *dbName, char *tbN return 0; } -static int taosDumpTableData(FILE *fp, char *tbName, - TAOS* taosCon, char* dbName, int precision, +static int64_t taosDumpTableData(FILE *fp, char *tbName, + TAOS* taos, char* dbName, int precision, char *jsonAvroSchema) { int64_t totalRows = 0; @@ -2395,7 +2158,7 @@ static int taosDumpTableData(FILE *fp, char *tbName, "select * from %s.%s where _c0 >= %" PRId64 " and _c0 <= %" PRId64 " order by _c0 asc;", dbName, tbName, start_time, end_time); - TAOS_RES* res = taos_query(taosCon, sqlstr); + TAOS_RES* res = taos_query(taos, sqlstr); int32_t code = taos_errno(res); if (code != 0) { errorPrint("failed to run command %s, reason: %s\n", @@ -2426,12 +2189,6 @@ static int taosCheckParam(struct arguments *arguments) { return -1; } - if (g_args.arg_list_len == 0) { - if ((!g_args.all_databases) && (!g_args.isDumpIn)) { - errorPrint("%s", "taosdump requires parameters for database and operation\n"); - return -1; - } - } /* if (g_args.isDumpIn && (strcmp(g_args.outpath, DEFAULT_DUMP_FILE) != 0)) { fprintf(stderr, "duplicate parameter input and output file path\n"); @@ -2837,7 +2594,7 @@ static int taosDumpInOneFile(TAOS* taos, FILE* fp, char* fcharset, static void* taosDumpInWorkThreadFp(void *arg) { - SThreadParaObj *pThread = (SThreadParaObj*)arg; + threadInfo *pThread = (threadInfo*)arg; setThreadName("dumpInWorkThrd"); for (int32_t f = 0; f < g_tsSqlFileNum; ++f) { @@ -2849,7 +2606,7 @@ static void* taosDumpInWorkThreadFp(void *arg) } fprintf(stderr, ", Success Open input file: %s\n", SQLFileName); - taosDumpInOneFile(pThread->taosCon, fp, g_tsCharset, g_args.encode, SQLFileName); + taosDumpInOneFile(pThread->taos, fp, g_tsCharset, g_args.encode, SQLFileName); } } @@ -2859,15 +2616,15 @@ static void* taosDumpInWorkThreadFp(void *arg) static void taosStartDumpInWorkThreads() { pthread_attr_t thattr; - SThreadParaObj *pThread; + threadInfo *pThread; int32_t totalThreads = g_args.thread_num; if (totalThreads > g_tsSqlFileNum) { totalThreads = g_tsSqlFileNum; } - SThreadParaObj *threadObj = (SThreadParaObj *)calloc( - totalThreads, sizeof(SThreadParaObj)); + threadInfo *threadObj = (threadInfo *)calloc( + totalThreads, sizeof(threadInfo)); if (NULL == threadObj) { errorPrint("%s() LN%d, memory allocation failed\n", __func__, __LINE__); @@ -2877,9 +2634,9 @@ static void taosStartDumpInWorkThreads() pThread = threadObj + t; pThread->threadIndex = t; pThread->totalThreads = totalThreads; - pThread->taosCon = taos_connect(g_args.host, g_args.user, g_args.password, + pThread->taos = taos_connect(g_args.host, g_args.user, g_args.password, NULL, g_args.port); - if (pThread->taosCon == NULL) { + if (pThread->taos == NULL) { errorPrint("Failed to connect to TDengine server %s\n", g_args.host); free(threadObj); return; @@ -2900,7 +2657,7 @@ static void taosStartDumpInWorkThreads() } for (int t = 0; t < totalThreads; ++t) { - taos_close(threadObj[t].taosCon); + taos_close(threadObj[t].taos); } free(threadObj); } @@ -2950,3 +2707,154 @@ static int taosDumpIn() { return 0; } +int main(int argc, char *argv[]) { + static char verType[32] = {0}; + sprintf(verType, "version: %s\n", version); + argp_program_version = verType; + + int ret = 0; + /* Parse our arguments; every option seen by parse_opt will be + reflected in arguments. */ + if (argc > 1) { +// parse_precision_first(argc, argv, &g_args); + parse_timestamp(argc, argv, &g_args); + parse_args(argc, argv, &g_args); + } + + argp_parse(&argp, argc, argv, 0, 0, &g_args); + + if (g_args.abort) { +#ifndef _ALPINE + error(10, 0, "ABORTED"); +#else + abort(); +#endif + } + + printf("====== arguments config ======\n"); + { + printf("host: %s\n", g_args.host); + printf("user: %s\n", g_args.user); + printf("password: %s\n", g_args.password); + printf("port: %u\n", g_args.port); + printf("mysqlFlag: %d\n", g_args.mysqlFlag); + printf("outpath: %s\n", g_args.outpath); + printf("inpath: %s\n", g_args.inpath); + printf("resultFile: %s\n", g_args.resultFile); + printf("encode: %s\n", g_args.encode); + printf("all_databases: %s\n", g_args.all_databases?"true":"false"); + printf("databases: %d\n", g_args.databases); + printf("databasesSeq: %s\n", g_args.databasesSeq); + printf("schemaonly: %s\n", g_args.schemaonly?"true":"false"); + printf("with_property: %s\n", g_args.with_property?"true":"false"); + printf("avro format: %s\n", g_args.avro?"true":"false"); + printf("start_time: %" PRId64 "\n", g_args.start_time); + printf("human readable start time: %s \n", g_args.humanStartTime); + printf("end_time: %" PRId64 "\n", g_args.end_time); + printf("human readable end time: %s \n", g_args.humanEndTime); + printf("precision: %s\n", g_args.precision); + printf("data_batch: %d\n", g_args.data_batch); + printf("max_sql_len: %d\n", g_args.max_sql_len); + printf("table_batch: %d\n", g_args.table_batch); + printf("thread_num: %d\n", g_args.thread_num); + printf("allow_sys: %d\n", g_args.allow_sys); + printf("abort: %d\n", g_args.abort); + printf("isDumpIn: %d\n", g_args.isDumpIn); + printf("arg_list_len: %d\n", g_args.arg_list_len); + printf("debug_print: %d\n", g_args.debug_print); + + for (int32_t i = 0; i < g_args.arg_list_len; i++) { + printf("arg_list[%d]: %s\n", i, g_args.arg_list[i]); + } + } + printf("==============================\n"); + if (taosCheckParam(&g_args) < 0) { + exit(EXIT_FAILURE); + } + + g_fpOfResult = fopen(g_args.resultFile, "a"); + if (NULL == g_fpOfResult) { + errorPrint("Failed to open %s for save result\n", g_args.resultFile); + exit(-1); + }; + + fprintf(g_fpOfResult, "#############################################################################\n"); + fprintf(g_fpOfResult, "============================== arguments config =============================\n"); + { + fprintf(g_fpOfResult, "host: %s\n", g_args.host); + fprintf(g_fpOfResult, "user: %s\n", g_args.user); + fprintf(g_fpOfResult, "password: %s\n", g_args.password); + fprintf(g_fpOfResult, "port: %u\n", g_args.port); + fprintf(g_fpOfResult, "mysqlFlag: %d\n", g_args.mysqlFlag); + fprintf(g_fpOfResult, "outpath: %s\n", g_args.outpath); + fprintf(g_fpOfResult, "inpath: %s\n", g_args.inpath); + fprintf(g_fpOfResult, "resultFile: %s\n", g_args.resultFile); + fprintf(g_fpOfResult, "encode: %s\n", g_args.encode); + fprintf(g_fpOfResult, "all_databases: %s\n", g_args.all_databases?"true":"false"); + fprintf(g_fpOfResult, "databases: %d\n", g_args.databases); + fprintf(g_fpOfResult, "databasesSeq: %s\n", g_args.databasesSeq); + fprintf(g_fpOfResult, "schemaonly: %s\n", g_args.schemaonly?"true":"false"); + fprintf(g_fpOfResult, "with_property: %s\n", g_args.with_property?"true":"false"); + fprintf(g_fpOfResult, "avro format: %s\n", g_args.avro?"true":"false"); + fprintf(g_fpOfResult, "start_time: %" PRId64 "\n", g_args.start_time); + fprintf(g_fpOfResult, "human readable start time: %s \n", g_args.humanStartTime); + fprintf(g_fpOfResult, "end_time: %" PRId64 "\n", g_args.end_time); + fprintf(g_fpOfResult, "human readable end time: %s \n", g_args.humanEndTime); + fprintf(g_fpOfResult, "precision: %s\n", g_args.precision); + fprintf(g_fpOfResult, "data_batch: %d\n", g_args.data_batch); + fprintf(g_fpOfResult, "max_sql_len: %d\n", g_args.max_sql_len); + fprintf(g_fpOfResult, "table_batch: %d\n", g_args.table_batch); + fprintf(g_fpOfResult, "thread_num: %d\n", g_args.thread_num); + fprintf(g_fpOfResult, "allow_sys: %d\n", g_args.allow_sys); + fprintf(g_fpOfResult, "abort: %d\n", g_args.abort); + fprintf(g_fpOfResult, "isDumpIn: %d\n", g_args.isDumpIn); + fprintf(g_fpOfResult, "arg_list_len: %d\n", g_args.arg_list_len); + + for (int32_t i = 0; i < g_args.arg_list_len; i++) { + fprintf(g_fpOfResult, "arg_list[%d]: %s\n", i, g_args.arg_list[i]); + } + } + + g_numOfCores = (int32_t)sysconf(_SC_NPROCESSORS_ONLN); + + time_t tTime = time(NULL); + struct tm tm = *localtime(&tTime); + + if (g_args.isDumpIn) { + fprintf(g_fpOfResult, "============================== DUMP IN ============================== \n"); + fprintf(g_fpOfResult, "# DumpIn start time: %d-%02d-%02d %02d:%02d:%02d\n", + tm.tm_year + 1900, tm.tm_mon + 1, + tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + if (taosDumpIn() < 0) { + ret = -1; + } + } else { + fprintf(g_fpOfResult, "============================== DUMP OUT ============================== \n"); + fprintf(g_fpOfResult, "# DumpOut start time: %d-%02d-%02d %02d:%02d:%02d\n", + tm.tm_year + 1900, tm.tm_mon + 1, + tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + if (taosDumpOut() < 0) { + ret = -1; + } else { + fprintf(g_fpOfResult, "\n============================== TOTAL STATISTICS ============================== \n"); + fprintf(g_fpOfResult, "# total database count: %d\n", + g_resultStatistics.totalDatabasesOfDumpOut); + fprintf(g_fpOfResult, "# total super table count: %d\n", + g_resultStatistics.totalSuperTblsOfDumpOut); + fprintf(g_fpOfResult, "# total child table count: %"PRId64"\n", + g_resultStatistics.totalChildTblsOfDumpOut); + fprintf(g_fpOfResult, "# total row count: %"PRId64"\n", + g_resultStatistics.totalRowsOfDumpOut); + } + } + + fprintf(g_fpOfResult, "\n"); + fclose(g_fpOfResult); + + if (g_tablesList) { + free(g_tablesList); + } + + return ret; +} + diff --git a/src/os/src/linux/linuxEnv.c b/src/os/src/linux/linuxEnv.c index 650a45aae42c8d2dfba63d8f4e7e6ec35b385ae8..35ca64d79f8b7a883014fd6ca980300ede22d6e2 100644 --- a/src/os/src/linux/linuxEnv.c +++ b/src/os/src/linux/linuxEnv.c @@ -32,6 +32,13 @@ void osInit() { strcpy(tsDataDir, "/var/lib/tq"); strcpy(tsLogDir, "/var/log/tq"); strcpy(tsScriptDir, "/etc/tq"); +#elif (_TD_PRO_ == true) + if (configDir[0] == 0) { + strcpy(configDir, "/etc/ProDB"); + } + strcpy(tsDataDir, "/var/lib/ProDB"); + strcpy(tsLogDir, "/var/log/ProDB"); + strcpy(tsScriptDir, "/etc/ProDB"); #else if (configDir[0] == 0) { strcpy(configDir, "/etc/taos"); diff --git a/src/os/src/windows/wEnv.c b/src/os/src/windows/wEnv.c index b35cb8f040aec5ff4b4fb12665d0842e72958ba1..6f46bb43c75ff2c9735fc53a11bce585c1c213f6 100644 --- a/src/os/src/windows/wEnv.c +++ b/src/os/src/windows/wEnv.c @@ -39,6 +39,14 @@ void osInit() { strcpy(tsDataDir, "C:/TQ/data"); strcpy(tsLogDir, "C:/TQ/log"); strcpy(tsScriptDir, "C:/TQ/script"); +#elif (_TD_PRO_ == true) + if (configDir[0] == 0) { + strcpy(configDir, "C:/ProDB/cfg"); + } + strcpy(tsVnodeDir, "C:/ProDB/data"); + strcpy(tsDataDir, "C:/ProDB/data"); + strcpy(tsLogDir, "C:/ProDB/log"); + strcpy(tsScriptDir, "C:/ProDB/script"); #else if (configDir[0] == 0) { strcpy(configDir, "C:/TDengine/cfg"); diff --git a/src/os/tests/CMakeLists.txt b/src/os/tests/CMakeLists.txt index 3c477641899994bf34237e93122c3d83f0365fad..9ec5076b7201b2d5ed9b2b6eb682eea7d6a83827 100644 --- a/src/os/tests/CMakeLists.txt +++ b/src/os/tests/CMakeLists.txt @@ -17,5 +17,5 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) ADD_EXECUTABLE(osTest ${SOURCE_LIST}) - TARGET_LINK_LIBRARIES(osTest taos os tutil common gtest pthread) + TARGET_LINK_LIBRARIES(osTest taos os cJson tutil common gtest pthread) ENDIF() diff --git a/src/query/inc/qAggMain.h b/src/query/inc/qAggMain.h index d4116fbfb2daec9b47c4a891c3c886728e6ca515..4f7821708c3e9b3c3d0eb975125e1ad12c5f82a4 100644 --- a/src/query/inc/qAggMain.h +++ b/src/query/inc/qAggMain.h @@ -70,14 +70,14 @@ extern "C" { #define TSDB_FUNC_DERIVATIVE 32 #define TSDB_FUNC_BLKINFO 33 - -#define TSDB_FUNC_HISTOGRAM 34 -#define TSDB_FUNC_HLL 35 -#define TSDB_FUNC_MODE 36 -#define TSDB_FUNC_SAMPLE 37 -#define TSDB_FUNC_CEIL 38 -#define TSDB_FUNC_FLOOR 39 -#define TSDB_FUNC_ROUND 40 +#define TSDB_FUNC_CEIL 34 +#define TSDB_FUNC_FLOOR 35 +#define TSDB_FUNC_ROUND 36 + +#define TSDB_FUNC_HISTOGRAM 37 +#define TSDB_FUNC_HLL 38 +#define TSDB_FUNC_MODE 39 +#define TSDB_FUNC_SAMPLE 40 #define TSDB_FUNC_MAVG 41 #define TSDB_FUNC_CSUM 42 @@ -88,6 +88,7 @@ extern "C" { #define TSDB_FUNCSTATE_OF 0x10u // outer forward #define TSDB_FUNCSTATE_NEED_TS 0x20u // timestamp is required during query processing #define TSDB_FUNCSTATE_SELECTIVITY 0x40u // selectivity functions, can exists along with tag columns +#define TSDB_FUNCSTATE_SCALAR 0x80u #define TSDB_BASE_FUNC_SO TSDB_FUNCSTATE_SO | TSDB_FUNCSTATE_STREAM | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_OF #define TSDB_BASE_FUNC_MO TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STREAM | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_OF diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 19ca8e7ed8867f32c9625fe66ad4c04d64bc98e7..82f4f34a57c7d6d10a021fb2e426ff83cb3604e6 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -264,7 +264,7 @@ typedef struct SQueryAttr { SOrderedPrjQueryInfo prjInfo; // limit value for each vgroup, only available in global order projection query. SSingleColumnFilterInfo* pFilterInfo; - SFilterInfo *pFilters; + void *pFilters; void* tsdb; SMemRef memRef; @@ -399,7 +399,6 @@ typedef struct SQueryParam { char *sql; char *tagCond; char *colCond; - char *tbnameCond; char *prevResult; SArray *pTableIdList; SSqlExpr **pExpr; @@ -407,7 +406,7 @@ typedef struct SQueryParam { SExprInfo *pExprs; SExprInfo *pSecExprs; - SFilterInfo *pFilters; + void *pFilters; SColIndex *pGroupColIndex; SColumnInfo *pTagColumnInfo; @@ -417,6 +416,11 @@ typedef struct SQueryParam { SUdfInfo *pUdfInfo; } SQueryParam; +typedef struct SColumnDataParam{ + int32_t numOfCols; + SArray* pDataBlock; +} SColumnDataParam; + typedef struct STableScanInfo { void *pQueryHandle; int32_t numOfBlocks; @@ -640,11 +644,11 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp int32_t createIndirectQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t numOfOutput, SExprInfo **pExprInfo, SSqlExpr **pExpr, SExprInfo *prevExpr, SUdfInfo *pUdfInfo); -int32_t createQueryFilter(char *data, uint16_t len, SFilterInfo** pFilters); +int32_t createQueryFilter(char *data, uint16_t len, void** pFilters); SGroupbyExpr *createGroupbyExprFromMsg(SQueryTableMsg *pQueryMsg, SColIndex *pColIndex, int32_t *code); SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SGroupbyExpr *pGroupbyExpr, SExprInfo *pExprs, - SExprInfo *pSecExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols, SFilterInfo* pFilters, int32_t vgId, char* sql, uint64_t qId, SUdfInfo* pUdfInfo); + SExprInfo *pSecExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols, void* pFilters, int32_t vgId, char* sql, uint64_t qId, SUdfInfo* pUdfInfo); int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, void* sourceOptr, SQInfo* pQInfo, SQueryParam* param, char* start, int32_t prevResultLen, void* merger); @@ -684,5 +688,6 @@ void freeQueryAttr(SQueryAttr *pQuery); int32_t getMaximumIdleDurationSec(); void doInvokeUdf(SUdfInfo* pUdfInfo, SQLFunctionCtx *pCtx, int32_t idx, int32_t type); +int32_t getColumnDataFromId(void *param, int32_t id, void **data); #endif // TDENGINE_QEXECUTOR_H diff --git a/src/query/inc/qFilter.h b/src/query/inc/qFilter.h index af45b816f9e6725579403069843295895cf57cc8..c34a56cc1cd6e135947eee897f87d060880f15c7 100644 --- a/src/query/inc/qFilter.h +++ b/src/query/inc/qFilter.h @@ -83,6 +83,12 @@ enum { RANGE_TYPE_MR_CTX = 3, }; +enum { + FI_ACTION_NO_NEED = 1, + FI_ACTION_CONTINUE, + FI_ACTION_STOP, +}; + typedef struct OptrStr { uint16_t optr; char *str; @@ -106,6 +112,7 @@ typedef struct SFilterColRange { typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const void *, __compar_fn_t); typedef int32_t(*filter_desc_compare_func)(const void *, const void *); typedef bool(*filter_exec_func)(void *, int32_t, int8_t**, SDataStatis *, int16_t); +typedef int32_t (*filer_get_col_from_id)(void *, int32_t, void **); typedef struct SFilterRangeCompare { int64_t s; @@ -323,14 +330,16 @@ typedef struct SFilterInfo { #define FILTER_EMPTY_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_EMPTY) -extern int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t options); +extern int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options); extern bool filterExecute(SFilterInfo *info, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols); -extern int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDataBlock); +extern int32_t filterSetColFieldData(SFilterInfo *info, void *param, filer_get_col_from_id fp); extern int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win); extern int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *gotNchar); extern int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo); extern void filterFreeInfo(SFilterInfo *info); extern bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t numOfCols, int32_t numOfRows); +extern int32_t filterIsIndexedColumnQuery(SFilterInfo* info, int32_t idxId, bool *res); +extern int32_t filterGetIndexedColumnInfo(SFilterInfo* info, char** val, int32_t *order, int32_t *flag); #ifdef __cplusplus } diff --git a/src/query/inc/qTableMeta.h b/src/query/inc/qTableMeta.h index 746c5f8569ac98c465e8283a2401e27c18cadcc4..948a1ae91e01331c4f566ac5089485f717fc5632 100644 --- a/src/query/inc/qTableMeta.h +++ b/src/query/inc/qTableMeta.h @@ -38,12 +38,6 @@ typedef struct SJoinInfo { } SJoinInfo; typedef struct STagCond { - // relation between tbname list and query condition, including : TK_AND or TK_OR - int16_t relType; - - // tbname query condition, only support tbname query condition on one table - SCond tbnameCond; - // join condition, only support two tables join currently SJoinInfo joinInfo; @@ -93,6 +87,7 @@ typedef struct STableMetaInfo { SName name; char aliasName[TSDB_TABLE_NAME_LEN]; // alias name of table specified in query sql SArray *tagColList; // SArray, involved tag columns + int32_t joinTagNum; } STableMetaInfo; struct SQInfo; // global merge operator @@ -100,7 +95,7 @@ struct SQueryAttr; // query object typedef struct STableFilter { uint64_t uid; - SFilterInfo info; + void *info; } STableFilter; typedef struct SQueryInfo { diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index c0c6d7a1404dbef6bdb00bd676a30fcfc908671a..1fd682aebd6ac7899ca0a88f6a4744cd4ebbb006 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -179,7 +179,9 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI if (functionId == TSDB_FUNC_TS || functionId == TSDB_FUNC_TS_DUMMY || functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_DIFF || functionId == TSDB_FUNC_PRJ || functionId == TSDB_FUNC_TAGPRJ || - functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_INTERP) { + functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_INTERP || functionId == TSDB_FUNC_CEIL || + functionId == TSDB_FUNC_FLOOR || functionId == TSDB_FUNC_ROUND) + { *type = (int16_t)dataType; *bytes = (int16_t)dataBytes; @@ -405,7 +407,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI // TODO use hash table int32_t isValidFunction(const char* name, int32_t len) { - for(int32_t i = 0; i <= TSDB_FUNC_BLKINFO; ++i) { + for(int32_t i = 0; i <= TSDB_FUNC_ROUND; ++i) { int32_t nameLen = (int32_t) strlen(aAggs[i].name); if (len != nameLen) { continue; @@ -4256,6 +4258,231 @@ void blockinfo_func_finalizer(SQLFunctionCtx* pCtx) { doFinalizer(pCtx); } +#define CFR_SET_VAL(type, data, pCtx, func, i, step, notNullElems) \ + do { \ + type *pData = (type *) data; \ + type *pOutput = (type *) pCtx->pOutput; \ + \ + for (; i < pCtx->size && i >= 0; i += step) { \ + if (pCtx->hasNull && isNull((const char*) &pData[i], pCtx->inputType)) { \ + continue; \ + } \ + \ + *pOutput++ = (type) func((double) pData[i]); \ + \ + notNullElems++; \ + } \ + } while (0) + +#define CFR_SET_VAL_DOUBLE(data, pCtx, func, i, step, notNullElems) \ + do { \ + double *pData = (double *) data; \ + double *pOutput = (double *) pCtx->pOutput; \ + \ + for (; i < pCtx->size && i >= 0; i += step) { \ + if (pCtx->hasNull && isNull((const char*) &pData[i], pCtx->inputType)) { \ + continue; \ + } \ + \ + SET_DOUBLE_VAL(pOutput, func(pData[i])); \ + pOutput++; \ + \ + notNullElems++; \ + } \ + } while (0) + +static void ceil_function(SQLFunctionCtx *pCtx) { + void *data = GET_INPUT_DATA_LIST(pCtx); + + int32_t notNullElems = 0; + + int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order); + int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1; + + switch (pCtx->inputType) { + case TSDB_DATA_TYPE_INT: { + CFR_SET_VAL(int32_t, data, pCtx, ceil, i, step, notNullElems); + break; + }; + case TSDB_DATA_TYPE_UINT: { + CFR_SET_VAL(uint32_t, data, pCtx, ceil, i, step, notNullElems); + break; + }; + case TSDB_DATA_TYPE_BIGINT: { + CFR_SET_VAL(int64_t, data, pCtx, ceil, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + CFR_SET_VAL(uint64_t, data, pCtx, ceil, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + CFR_SET_VAL_DOUBLE(data, pCtx, ceil, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + CFR_SET_VAL(float, data, pCtx, ceil, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + CFR_SET_VAL(int16_t, data, pCtx, ceil, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + CFR_SET_VAL(uint16_t, data, pCtx, ceil, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_TINYINT: { + CFR_SET_VAL(int8_t, data, pCtx, ceil, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + CFR_SET_VAL(uint8_t, data, pCtx, ceil, i, step, notNullElems); + break; + } + default: + qError("error input type"); + } + + if (notNullElems <= 0) { + /* + * current block may be null value + */ + assert(pCtx->hasNull); + } else { + GET_RES_INFO(pCtx)->numOfRes += notNullElems; + } +} + +static void floor_function(SQLFunctionCtx *pCtx) { + void *data = GET_INPUT_DATA_LIST(pCtx); + + int32_t notNullElems = 0; + + int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order); + int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1; + + switch (pCtx->inputType) { + case TSDB_DATA_TYPE_INT: { + CFR_SET_VAL(int32_t, data, pCtx, floor, i, step, notNullElems); + break; + }; + case TSDB_DATA_TYPE_UINT: { + CFR_SET_VAL(uint32_t, data, pCtx, floor, i, step, notNullElems); + break; + }; + case TSDB_DATA_TYPE_BIGINT: { + CFR_SET_VAL(int64_t, data, pCtx, floor, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + CFR_SET_VAL(uint64_t, data, pCtx, floor, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + CFR_SET_VAL_DOUBLE(data, pCtx, floor, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + CFR_SET_VAL(float, data, pCtx, floor, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + CFR_SET_VAL(int16_t, data, pCtx, floor, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + CFR_SET_VAL(uint16_t, data, pCtx, floor, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_TINYINT: { + CFR_SET_VAL(int8_t, data, pCtx, floor, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + CFR_SET_VAL(uint8_t, data, pCtx, floor, i, step, notNullElems); + break; + } + default: + qError("error input type"); + } + + if (notNullElems <= 0) { + /* + * current block may be null value + */ + assert(pCtx->hasNull); + } else { + GET_RES_INFO(pCtx)->numOfRes += notNullElems; + } +} + +static void round_function(SQLFunctionCtx *pCtx) { + void *data = GET_INPUT_DATA_LIST(pCtx); + + int32_t notNullElems = 0; + + int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order); + int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1; + + switch (pCtx->inputType) { + case TSDB_DATA_TYPE_INT: { + CFR_SET_VAL(int32_t, data, pCtx, round, i, step, notNullElems); + break; + }; + case TSDB_DATA_TYPE_UINT: { + CFR_SET_VAL(uint32_t, data, pCtx, round, i, step, notNullElems); + break; + }; + case TSDB_DATA_TYPE_BIGINT: { + CFR_SET_VAL(int64_t, data, pCtx, round, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + CFR_SET_VAL(uint64_t, data, pCtx, round, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + CFR_SET_VAL_DOUBLE(data, pCtx, round, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + CFR_SET_VAL(float, data, pCtx, round, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + CFR_SET_VAL(int16_t, data, pCtx, round, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + CFR_SET_VAL(uint16_t, data, pCtx, round, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_TINYINT: { + CFR_SET_VAL(int8_t, data, pCtx, round, i, step, notNullElems); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + CFR_SET_VAL(uint8_t, data, pCtx, round, i, step, notNullElems); + break; + } + default: + qError("error input type"); + } + + if (notNullElems <= 0) { + /* + * current block may be null value + */ + assert(pCtx->hasNull); + } else { + GET_RES_INFO(pCtx)->numOfRes += notNullElems; + } +} + +#undef CFR_SET_VAL +#undef CFR_SET_VAL_DOUBLE + ///////////////////////////////////////////////////////////////////////////////////////////// /* * function compatible list. @@ -4274,8 +4501,8 @@ int32_t functionCompatList[] = { 4, -1, -1, 1, 1, 1, 1, 1, 1, -1, // tag, colprj, tagprj, arithmetic, diff, first_dist, last_dist, stddev_dst, interp rate irate 1, 1, 1, 1, -1, 1, 1, 1, 5, 1, 1, - // tid_tag, derivative, blk_info - 6, 8, 7, + // tid_tag, derivative, blk_info,ceil, floor, round + 6, 8, 7, 1, 1, 1 }; SAggFunctionInfo aAggs[] = {{ @@ -4678,7 +4905,7 @@ SAggFunctionInfo aAggs[] = {{ dataBlockRequired, }, { - // 33 + // 33 "_block_dist", // return table id and the corresponding tags for join match and subscribe TSDB_FUNC_BLKINFO, TSDB_FUNC_BLKINFO, @@ -4688,4 +4915,40 @@ SAggFunctionInfo aAggs[] = {{ blockinfo_func_finalizer, block_func_merge, dataBlockRequired, + }, + { + // 34 + "ceil", + TSDB_FUNC_CEIL, + TSDB_FUNC_CEIL, + TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SCALAR, + function_setup, + ceil_function, + doFinalizer, + noop1, + dataBlockRequired + }, + { + // 35 + "floor", + TSDB_FUNC_FLOOR, + TSDB_FUNC_FLOOR, + TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SCALAR, + function_setup, + floor_function, + doFinalizer, + noop1, + dataBlockRequired + }, + { + // 36 + "round", + TSDB_FUNC_ROUND, + TSDB_FUNC_ROUND, + TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SCALAR, + function_setup, + round_function, + doFinalizer, + noop1, + dataBlockRequired }}; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 54a5423219c8822e42c20a1d9a0d392913f8fdef..982996d70d6e8c05c45425e737b57a08daf331c9 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -405,6 +405,25 @@ static bool isSelectivityWithTagsQuery(SQLFunctionCtx *pCtx, int32_t numOfOutput return (numOfSelectivity > 0 && hasTags); } +static bool isScalarWithTagsQuery(SQLFunctionCtx *pCtx, int32_t numOfOutput) { + bool hasTags = false; + int32_t numOfScalar = 0; + + for (int32_t i = 0; i < numOfOutput; ++i) { + int32_t functId = pCtx[i].functionId; + if (functId == TSDB_FUNC_TAG_DUMMY || functId == TSDB_FUNC_TS_DUMMY) { + hasTags = true; + continue; + } + + if ((aAggs[functId].status & TSDB_FUNCSTATE_SCALAR) != 0) { + numOfScalar++; + } + } + + return (numOfScalar > 0 && hasTags); +} + static bool isProjQuery(SQueryAttr *pQueryAttr) { for (int32_t i = 0; i < pQueryAttr->numOfOutput; ++i) { int32_t functId = pQueryAttr->pExpr1[i].base.functionId; @@ -1939,7 +1958,7 @@ void setBlockStatisInfo(SQLFunctionCtx *pCtx, SSDataBlock* pSDataBlock, SColInde // set the output buffer for the selectivity + tag query static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) { - if (!isSelectivityWithTagsQuery(pCtx, numOfOutput)) { + if (!isSelectivityWithTagsQuery(pCtx, numOfOutput) && !isScalarWithTagsQuery(pCtx, numOfOutput)) { return TSDB_CODE_SUCCESS; } @@ -1958,7 +1977,7 @@ static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) { if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { tagLen += pCtx[i].outputBytes; pTagCtx[num++] = &pCtx[i]; - } else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) { + } else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0 || (aAggs[functionId].status & TSDB_FUNCSTATE_SCALAR) != 0) { p = &pCtx[i]; } else if (functionId == TSDB_FUNC_TS || functionId == TSDB_FUNC_TAG) { // tag function may be the group by tag column @@ -2950,6 +2969,10 @@ void filterRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSingleColumnFilterInf } if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) { + if (i < (numOfRows - 1)) { + all = false; + } + break; } } @@ -2991,11 +3014,15 @@ void filterColRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSDataBlock* pBlock p[offset] = true; } - if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) { + if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) { + if (i < (numOfRows - 1)) { + all = false; + } + break; } } - + // save the cursor status pRuntimeEnv->current->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf); } else { @@ -3057,6 +3084,22 @@ void doSetFilterColumnInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFi } } +FORCE_INLINE int32_t getColumnDataFromId(void *param, int32_t id, void **data) { + int32_t numOfCols = ((SColumnDataParam *)param)->numOfCols; + SArray* pDataBlock = ((SColumnDataParam *)param)->pDataBlock; + + for (int32_t j = 0; j < numOfCols; ++j) { + SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, j); + if (id == pColInfo->info.colId) { + *data = pColInfo->pData; + break; + } + } + + return TSDB_CODE_SUCCESS; +} + + int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) { *status = BLK_DATA_NO_NEEDED; @@ -3211,7 +3254,8 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa } if (pQueryAttr->pFilters != NULL) { - filterSetColFieldData(pQueryAttr->pFilters, pBlock->info.numOfCols, pBlock->pDataBlock); + SColumnDataParam param = {.numOfCols = pBlock->info.numOfCols, .pDataBlock = pBlock->pDataBlock}; + filterSetColFieldData(pQueryAttr->pFilters, ¶m, getColumnDataFromId); } if (pQueryAttr->pFilters != NULL || pRuntimeEnv->pTsBuf != NULL) { @@ -7498,7 +7542,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { pQueryMsg->order = htons(pQueryMsg->order); pQueryMsg->orderColId = htons(pQueryMsg->orderColId); pQueryMsg->queryType = htonl(pQueryMsg->queryType); - pQueryMsg->tagNameRelType = htons(pQueryMsg->tagNameRelType); pQueryMsg->numOfCols = htons(pQueryMsg->numOfCols); pQueryMsg->numOfOutput = htons(pQueryMsg->numOfOutput); @@ -7513,7 +7556,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { pQueryMsg->tsBuf.tsOrder = htonl(pQueryMsg->tsBuf.tsOrder); pQueryMsg->numOfTags = htonl(pQueryMsg->numOfTags); - pQueryMsg->tbnameCondLen = htonl(pQueryMsg->tbnameCondLen); pQueryMsg->secondStageOutput = htonl(pQueryMsg->secondStageOutput); pQueryMsg->sqlstrLen = htonl(pQueryMsg->sqlstrLen); pQueryMsg->prevResultLen = htonl(pQueryMsg->prevResultLen); @@ -7757,17 +7799,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { pMsg += pQueryMsg->prevResultLen; } - if (pQueryMsg->tbnameCondLen > 0) { - param->tbnameCond = calloc(1, pQueryMsg->tbnameCondLen + 1); - if (param->tbnameCond == NULL) { - code = TSDB_CODE_QRY_OUT_OF_MEMORY; - goto _cleanup; - } - - strncpy(param->tbnameCond, pMsg, pQueryMsg->tbnameCondLen); - pMsg += pQueryMsg->tbnameCondLen; - } - //skip ts buf if ((pQueryMsg->tsBuf.tsOffset + pQueryMsg->tsBuf.tsLen) > 0) { pMsg = (char *)pQueryMsg + pQueryMsg->tsBuf.tsOffset + pQueryMsg->tsBuf.tsLen; @@ -8148,7 +8179,7 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp return TSDB_CODE_SUCCESS; } -int32_t createQueryFilter(char *data, uint16_t len, SFilterInfo** pFilters) { +int32_t createQueryFilter(char *data, uint16_t len, void** pFilters) { tExprNode* expr = NULL; TRY(TSDB_MAX_TAG_CONDITIONS) { @@ -8402,7 +8433,7 @@ FORCE_INLINE bool checkQIdEqual(void *qHandle, uint64_t qId) { } SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, SExprInfo* pExprs, - SExprInfo* pSecExprs, STableGroupInfo* pTableGroupInfo, SColumnInfo* pTagCols, SFilterInfo* pFilters, int32_t vgId, + SExprInfo* pSecExprs, STableGroupInfo* pTableGroupInfo, SColumnInfo* pTagCols, void* pFilters, int32_t vgId, char* sql, uint64_t qId, SUdfInfo* pUdfInfo) { int16_t numOfCols = pQueryMsg->numOfCols; int16_t numOfOutput = pQueryMsg->numOfOutput; diff --git a/src/query/src/qFilter.c b/src/query/src/qFilter.c index 5e8ff126d1510cd32446d695d5c8d698aa32d1b9..c7a7ea963d5635c76030d2199ac99a60924d99a7 100644 --- a/src/query/src/qFilter.c +++ b/src/query/src/qFilter.c @@ -28,14 +28,14 @@ OptrStr gOptrStr[] = { {TSDB_RELATION_GREATER_EQUAL, ">="}, {TSDB_RELATION_NOT_EQUAL, "!="}, {TSDB_RELATION_LIKE, "like"}, - {TSDB_RELATION_MATCH, "match"}, - {TSDB_RELATION_MATCH, "nmatch"}, {TSDB_RELATION_ISNULL, "is null"}, {TSDB_RELATION_NOTNULL, "not null"}, {TSDB_RELATION_IN, "in"}, {TSDB_RELATION_AND, "and"}, {TSDB_RELATION_OR, "or"}, - {TSDB_RELATION_NOT, "not"} + {TSDB_RELATION_NOT, "not"}, + {TSDB_RELATION_MATCH, "match"}, + {TSDB_RELATION_NMATCH, "nmatch"}, }; static FORCE_INLINE int32_t filterFieldColDescCompare(const void *desc1, const void *desc2) { @@ -937,7 +937,7 @@ int32_t filterAddUnitToGroup(SFilterGroup *group, uint16_t unitIdx) { return TSDB_CODE_SUCCESS; } -int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint32_t tType) { +int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint32_t tType, bool tolower) { SBufferReader br = tbufInitReader(buf, len, false); uint32_t sType = tbufReadUint32(&br); SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(tType), true, false); @@ -1113,6 +1113,10 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3 } t = varDataLen(tmp); pvar = varDataVal(tmp); + + if (tolower) { + strntolower_s(pvar, pvar, (int32_t)t); + } break; } case TSDB_DATA_TYPE_NCHAR: { @@ -1157,7 +1161,7 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g if (tree->_node.optr == TSDB_RELATION_IN && (!IS_VAR_DATA_TYPE(type))) { void *data = NULL; - filterConvertSetFromBinary((void **)&data, var->pz, var->nLen, type); + filterConvertSetFromBinary((void **)&data, var->pz, var->nLen, type, false); CHK_LRET(data == NULL, TSDB_CODE_QRY_APP_ERROR, "failed to convert in param"); if (taosHashGetSize((SHashObj *)data) <= 0) { @@ -1484,19 +1488,6 @@ _return: return code; } -#if 0 -int32_t filterInitUnitFunc(SFilterInfo *info) { - for (uint16_t i = 0; i < info->unitNum; ++i) { - SFilterUnit* unit = &info->units[i]; - - info->cunits[i].func = getComparFunc(FILTER_UNIT_DATA_TYPE(unit), unit->compare.optr); - } - - return TSDB_CODE_SUCCESS; -} -#endif - - void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) { if (qDebugFlag & DEBUG_DEBUG) { CHK_LRETV(info == NULL, "%s - FilterInfo: EMPTY", msg); @@ -1811,7 +1802,10 @@ int32_t filterInitValFieldData(SFilterInfo *info) { } if (unit->compare.optr == TSDB_RELATION_IN) { - filterConvertSetFromBinary((void **)&fi->data, var->pz, var->nLen, type); + SSchema *sch = FILTER_UNIT_COL_DESC(info, unit); + bool tolower = (sch->colId == -1) ? true : false; + + filterConvertSetFromBinary((void **)&fi->data, var->pz, var->nLen, type, tolower); CHK_LRET(fi->data == NULL, TSDB_CODE_QRY_APP_ERROR, "failed to convert in param"); FILTER_SET_FLAG(fi->flag, FLD_DATA_IS_HASH); @@ -2544,8 +2538,6 @@ int32_t filterPostProcessRange(SFilterInfo *info) { int32_t filterGenerateComInfo(SFilterInfo *info) { - uint16_t n = 0; - info->cunits = malloc(info->unitNum * sizeof(*info->cunits)); info->blkUnitRes = malloc(sizeof(*info->blkUnitRes) * info->unitNum); info->blkUnits = malloc(sizeof(*info->blkUnits) * (info->unitNum + 1) * info->groupNum); @@ -2573,24 +2565,6 @@ int32_t filterGenerateComInfo(SFilterInfo *info) { info->cunits[i].dataSize = FILTER_UNIT_COL_SIZE(info, unit); info->cunits[i].dataType = FILTER_UNIT_DATA_TYPE(unit); } - - uint16_t cgroupNum = info->groupNum + 1; - - for (uint16_t i = 0; i < info->groupNum; ++i) { - cgroupNum += info->groups[i].unitNum; - } - - info->cgroups = malloc(cgroupNum * sizeof(*info->cgroups)); - - for (uint16_t i = 0; i < info->groupNum; ++i) { - info->cgroups[n++] = info->groups[i].unitNum; - - for (uint16_t m = 0; m < info->groups[i].unitNum; ++m) { - info->cgroups[n++] = info->groups[i].unitIdxs[m]; - } - } - - info->cgroups[n] = 0; return TSDB_CODE_SUCCESS; } @@ -2664,10 +2638,12 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SDataStatis *pDataStatis, int32_t SDataStatis* pDataBlockst = &pDataStatis[index]; void *minVal, *maxVal; + float minv = 0; + float maxv = 0; if (cunit->dataType == TSDB_DATA_TYPE_FLOAT) { - float minv = (float)(*(double *)(&pDataBlockst->min)); - float maxv = (float)(*(double *)(&pDataBlockst->max)); + minv = (float)(*(double *)(&pDataBlockst->min)); + maxv = (float)(*(double *)(&pDataBlockst->max)); minVal = &minv; maxVal = &maxv; @@ -2786,8 +2762,10 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, bool all = true; uint16_t *unitIdx = NULL; - *p = calloc(numOfRows, sizeof(int8_t)); - + if (*p == NULL) { + *p = calloc(numOfRows, sizeof(int8_t)); + } + for (int32_t i = 0; i < numOfRows; ++i) { //FILTER_UNIT_CLR_F(info); @@ -2889,12 +2867,14 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, return all; } - *p = calloc(numOfRows, sizeof(int8_t)); + if (*p == NULL) { + *p = calloc(numOfRows, sizeof(int8_t)); + } for (int32_t i = 0; i < numOfRows; ++i) { uint16_t uidx = info->groups[0].unitIdxs[0]; void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i; - (*p)[i] = isNull(colData, info->cunits[uidx].dataType); + (*p)[i] = ((colData == NULL) || isNull(colData, info->cunits[uidx].dataType)); if ((*p)[i] == 0) { all = false; } @@ -2910,12 +2890,14 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows return all; } - *p = calloc(numOfRows, sizeof(int8_t)); - + if (*p == NULL) { + *p = calloc(numOfRows, sizeof(int8_t)); + } + for (int32_t i = 0; i < numOfRows; ++i) { uint16_t uidx = info->groups[0].unitIdxs[0]; void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i; - (*p)[i] = !isNull(colData, info->cunits[uidx].dataType); + (*p)[i] = ((colData != NULL) && !isNull(colData, info->cunits[uidx].dataType)); if ((*p)[i] == 0) { all = false; } @@ -2938,10 +2920,12 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataSta return all; } - *p = calloc(numOfRows, sizeof(int8_t)); + if (*p == NULL) { + *p = calloc(numOfRows, sizeof(int8_t)); + } for (int32_t i = 0; i < numOfRows; ++i) { - if (isNull(colData, info->cunits[0].dataType)) { + if (colData == NULL || isNull(colData, info->cunits[0].dataType)) { all = false; colData += dataSize; continue; @@ -2966,13 +2950,16 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) { return all; } - - *p = calloc(numOfRows, sizeof(int8_t)); + + if (*p == NULL) { + *p = calloc(numOfRows, sizeof(int8_t)); + } for (int32_t i = 0; i < numOfRows; ++i) { uint16_t uidx = info->groups[0].unitIdxs[0]; void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i; - if (isNull(colData, info->cunits[uidx].dataType)) { + if (colData == NULL || isNull(colData, info->cunits[uidx].dataType)) { + (*p)[i] = 0; all = false; continue; } @@ -2996,8 +2983,10 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis * return all; } - *p = calloc(numOfRows, sizeof(int8_t)); - + if (*p == NULL) { + *p = calloc(numOfRows, sizeof(int8_t)); + } + for (int32_t i = 0; i < numOfRows; ++i) { //FILTER_UNIT_CLR_F(info); @@ -3013,7 +3002,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis * //} else { uint8_t optr = cunit->optr; - if (isNull(colData, cunit->dataType)) { + if (colData == NULL || isNull(colData, cunit->dataType)) { (*p)[i] = optr == TSDB_RELATION_ISNULL ? true : false; } else { if (optr == TSDB_RELATION_NOTNULL) { @@ -3132,7 +3121,7 @@ _return: return TSDB_CODE_SUCCESS; } -int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDataBlock) { +int32_t filterSetColFieldData(SFilterInfo *info, void *param, filer_get_col_from_id fp) { CHK_LRET(info == NULL, TSDB_CODE_QRY_APP_ERROR, "info NULL"); CHK_LRET(info->fields[FLD_TYPE_COLUMN].num <= 0, TSDB_CODE_QRY_APP_ERROR, "no column fileds"); @@ -3143,15 +3132,8 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat for (uint16_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; SSchema* sch = fi->desc; - - for (int32_t j = 0; j < numOfCols; ++j) { - SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, j); - if (sch->colId == pColInfo->info.colId) { - fi->data = pColInfo->pData; - - break; - } - } + + (*fp)(param, sch->colId, &fi->data); } filterUpdateComUnits(info); @@ -3160,7 +3142,7 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat } -int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t options) { +int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) { int32_t code = TSDB_CODE_SUCCESS; SFilterInfo *info = NULL; @@ -3197,8 +3179,6 @@ int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t option taosArrayDestroy(group); return code; } - - //ERR_JRET(filterInitUnitFunc(info)); } info->unitRes = malloc(info->unitNum * sizeof(*info->unitRes)); @@ -3257,30 +3237,35 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num break; } - if ((pDataStatis[index].numOfNull <= 0) && (ctx->isnull && !ctx->notnull && !ctx->isrange)) { - ret = false; - break; - } - - // all data in current column are NULL, no need to check its boundary value - if (pDataStatis[index].numOfNull == numOfRows) { - - // if isNULL query exists, load the null data column - if ((ctx->notnull || ctx->isrange) && (!ctx->isnull)) { + if (pDataStatis[index].numOfNull <= 0) { + if (ctx->isnull && !ctx->notnull && !ctx->isrange) { ret = false; break; } + } else if (pDataStatis[index].numOfNull > 0) { + if (pDataStatis[index].numOfNull == numOfRows) { + if ((ctx->notnull || ctx->isrange) && (!ctx->isnull)) { + ret = false; + break; + } - continue; + continue; + } else { + if (ctx->isnull) { + continue; + } + } } SDataStatis* pDataBlockst = &pDataStatis[index]; SFilterRangeNode *r = ctx->rs; + float minv = 0; + float maxv = 0; if (ctx->type == TSDB_DATA_TYPE_FLOAT) { - float minv = (float)(*(double *)(&pDataBlockst->min)); - float maxv = (float)(*(double *)(&pDataBlockst->max)); + minv = (float)(*(double *)(&pDataBlockst->min)); + maxv = (float)(*(double *)(&pDataBlockst->max)); minVal = &minv; maxVal = &maxv; @@ -3441,6 +3426,52 @@ int32_t filterFreeNcharColumns(SFilterInfo* info) { return TSDB_CODE_SUCCESS; } +int32_t filterIsIndexedColumnQuery(SFilterInfo* info, int32_t idxId, bool *res) { + CHK_LRET(info == NULL, TSDB_CODE_QRY_APP_ERROR, "null parameter"); + + CHK_JMP(info->fields[FLD_TYPE_COLUMN].num > 1 || info->fields[FLD_TYPE_COLUMN].num <= 0); + + CHK_JMP(info->unitNum > 1 || info->unitNum <= 0); + + CHK_JMP(FILTER_GET_COL_FIELD_ID(FILTER_GET_COL_FIELD(info, 0)) != idxId); + + int32_t optr = FILTER_UNIT_OPTR(info->units); + + CHK_JMP(optr == TSDB_RELATION_LIKE || optr == TSDB_RELATION_IN || optr == TSDB_RELATION_MATCH + || optr == TSDB_RELATION_ISNULL || optr == TSDB_RELATION_NOTNULL); + + *res = true; + + return TSDB_CODE_SUCCESS; + +_return: + *res = false; + + return TSDB_CODE_SUCCESS; +} + + +int32_t filterGetIndexedColumnInfo(SFilterInfo* info, char** val, int32_t *order, int32_t *flag) { + SFilterComUnit *cunit = info->cunits; + uint8_t optr = cunit->optr; + + *val = cunit->valData; + *order = TSDB_ORDER_ASC; + + if (optr == TSDB_RELATION_LESS || optr == TSDB_RELATION_LESS_EQUAL) { + *order = TSDB_ORDER_DESC; + } + + if (optr == TSDB_RELATION_NOT_EQUAL) { + *order = TSDB_ORDER_ASC|TSDB_ORDER_DESC; + } + + if (cunit->valData2 == cunit->valData && optr != TSDB_RELATION_EQUAL) { + FILTER_SET_FLAG(*flag, FI_ACTION_NO_NEED); + } + + return TSDB_CODE_SUCCESS; +} diff --git a/src/query/src/qPlan.c b/src/query/src/qPlan.c index 1988fc9df7710f15770ca8a9994542d9f4bc8c66..abfa20714b333754478e5c48b9265f839b05a4b1 100644 --- a/src/query/src/qPlan.c +++ b/src/query/src/qPlan.c @@ -645,6 +645,12 @@ SArray* createExecOperatorPlan(SQueryAttr* pQueryAttr) { } else { op = OP_Project; taosArrayPush(plan, &op); + + if (pQueryAttr->pExpr2 != NULL) { + op = OP_Project; + taosArrayPush(plan, &op); + } + if (pQueryAttr->distinct) { op = OP_Distinct; taosArrayPush(plan, &op); diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index 1460fbdc0fd0324da28bf1161c34c564584258cd..c6e6eddce7d8f56095d5d78f4d1f84ed1d4f3c97 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -53,7 +53,6 @@ static void freeqinfoFn(void *qhandle) { void freeParam(SQueryParam *param) { tfree(param->sql); tfree(param->tagCond); - tfree(param->tbnameCond); tfree(param->pTableIdList); taosArrayDestroy(param->pOperator); tfree(param->pExprs); @@ -140,7 +139,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi qDebug("qmsg:%p query stable, uid:%"PRIu64", tid:%d", pQueryMsg, id->uid, id->tid); code = tsdbQuerySTableByTagCond(tsdb, id->uid, pQueryMsg->window.skey, param.tagCond, pQueryMsg->tagCondLen, - pQueryMsg->tagNameRelType, param.tbnameCond, &tableGroupInfo, param.pGroupColIndex, numOfGroupByCols); + &tableGroupInfo, param.pGroupColIndex, numOfGroupByCols); if (code != TSDB_CODE_SUCCESS) { qError("qmsg:%p failed to query stable, reason: %s", pQueryMsg, tstrerror(code)); diff --git a/src/query/tests/CMakeLists.txt b/src/query/tests/CMakeLists.txt index 349d511f1570e3df835494ebd4e3e86d7795c873..8c4b9c2e6a2e9a5f6835baf411ecc94e6889fcbe 100644 --- a/src/query/tests/CMakeLists.txt +++ b/src/query/tests/CMakeLists.txt @@ -18,7 +18,7 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) ADD_EXECUTABLE(queryTest ${SOURCE_LIST}) - TARGET_LINK_LIBRARIES(queryTest taos query gtest pthread) + TARGET_LINK_LIBRARIES(queryTest taos cJson query gtest pthread) ENDIF() SET_SOURCE_FILES_PROPERTIES(./astTest.cpp PROPERTIES COMPILE_FLAGS -w) diff --git a/src/tsdb/CMakeLists.txt b/src/tsdb/CMakeLists.txt index c5b77df5a25f9f0b1e9294228520f171b9befddd..efbed6f0a6e8218c3a0b46d2913f6a792bf48ce4 100644 --- a/src/tsdb/CMakeLists.txt +++ b/src/tsdb/CMakeLists.txt @@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(tsdb ${SRC}) TARGET_LINK_LIBRARIES(tsdb tfs common tutil) diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 54526a9eefaa39ba4695f9564994dee54646da88..c72c8556b8007639dc80bd0be86510250a6a75bf 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -25,6 +25,7 @@ #include "tlosertree.h" #include "tsdbint.h" #include "texpr.h" +#include "qFilter.h" #define EXTRA_BYTES 2 #define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) @@ -167,6 +168,7 @@ static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SM static void* doFreeColumnInfoData(SArray* pColumnInfoData); static void* destroyTableCheckInfo(SArray* pTableCheckInfo); static bool tsdbGetExternalRow(TsdbQueryHandleT pHandle); +static int32_t tsdbQueryTableList(STable* pTable, SArray* pRes, void* filterInfo); static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) { pBlockLoadInfo->slot = -1; @@ -2691,21 +2693,6 @@ static int32_t getAllTableList(STable* pSuperTable, SArray* list) { return TSDB_CODE_SUCCESS; } -static void destroyHelper(void* param) { - if (param == NULL) { - return; - } - - tQueryInfo* pInfo = (tQueryInfo*)param; - if (pInfo->optr != TSDB_RELATION_IN) { - tfree(pInfo->q); - } else { - taosHashCleanup((SHashObj *)(pInfo->q)); - } - - free(param); -} - static bool loadBlockOfActiveTable(STsdbQueryHandle* pQueryHandle) { if (pQueryHandle->checkFiles) { // check if the query range overlaps with the file data block @@ -3644,109 +3631,8 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC return pTableGroup; } -static bool tableFilterFp(const void* pNode, void* param) { - tQueryInfo* pInfo = (tQueryInfo*) param; - - STable* pTable = (STable*)(SL_GET_NODE_DATA((SSkipListNode*)pNode)); - - char* val = NULL; - if (pInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) { - val = (char*) TABLE_NAME(pTable); - } else { - val = tdGetKVRowValOfCol(pTable->tagVal, pInfo->sch.colId); - } - - if (pInfo->optr == TSDB_RELATION_ISNULL || pInfo->optr == TSDB_RELATION_NOTNULL) { - if (pInfo->optr == TSDB_RELATION_ISNULL) { - return (val == NULL) || isNull(val, pInfo->sch.type); - } else if (pInfo->optr == TSDB_RELATION_NOTNULL) { - return (val != NULL) && (!isNull(val, pInfo->sch.type)); - } - } else if (pInfo->optr == TSDB_RELATION_IN) { - int type = pInfo->sch.type; - if (type == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_TIMESTAMP) { - int64_t v; - GET_TYPED_DATA(v, int64_t, pInfo->sch.type, val); - return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v)); - } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { - uint64_t v; - GET_TYPED_DATA(v, uint64_t, pInfo->sch.type, val); - return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v)); - } - else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) { - double v; - GET_TYPED_DATA(v, double, pInfo->sch.type, val); - return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v)); - } else if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR){ - return NULL != taosHashGet((SHashObj *)pInfo->q, varDataVal(val), varDataLen(val)); - } - - } - - int32_t ret = 0; - if (val == NULL) { //the val is possible to be null, so check it out carefully - ret = -1; // val is missing in table tags value pairs - } else { - ret = pInfo->compare(val, pInfo->q); - } - - switch (pInfo->optr) { - case TSDB_RELATION_EQUAL: { - return ret == 0; - } - case TSDB_RELATION_NOT_EQUAL: { - return ret != 0; - } - case TSDB_RELATION_GREATER_EQUAL: { - return ret >= 0; - } - case TSDB_RELATION_GREATER: { - return ret > 0; - } - case TSDB_RELATION_LESS_EQUAL: { - return ret <= 0; - } - case TSDB_RELATION_LESS: { - return ret < 0; - } - case TSDB_RELATION_LIKE: { - return ret == 0; - } - case TSDB_RELATION_MATCH: { - return ret == 0; - } - case TSDB_RELATION_NMATCH: { - return ret == 0; - } - case TSDB_RELATION_IN: { - return ret == 1; - } - - default: - assert(false); - } - - return true; -} - -static void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param); - -static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) { - // query according to the expression tree - SExprTraverseSupp supp = { - .nodeFilterFn = (__result_filter_fn_t) tableFilterFp, - .setupInfoFn = filterPrepare, - .pExtInfo = pSTable->tagSchema, - }; - - getTableListfromSkipList(pExpr, pSTable->pIndex, pRes, &supp); - tExprTreeDestroy(pExpr, destroyHelper); - return TSDB_CODE_SUCCESS; -} - -int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, const char* pTagCond, size_t len, - int16_t tagNameRelType, const char* tbnameCond, STableGroupInfo* pGroupInfo, - SColIndex* pColIndex, int32_t numOfCols) { +int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, const char* pTagCond, size_t len, + STableGroupInfo* pGroupInfo, SColIndex* pColIndex, int32_t numOfCols) { if (tsdbRLockRepoMeta(tsdb) < 0) goto _error; STable* pTable = tsdbGetTableByUid(tsdbGetMeta(tsdb), uid); @@ -3772,7 +3658,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons STSchema* pTagSchema = tsdbGetTableTagSchema(pTable); // no tags and tbname condition, all child tables of this stable are involved - if (tbnameCond == NULL && (pTagCond == NULL || len == 0)) { + if (pTagCond == NULL || len == 0) { int32_t ret = getAllTableList(pTable, res); if (ret != TSDB_CODE_SUCCESS) { tsdbUnlockRepoMeta(tsdb); @@ -3794,25 +3680,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons tExprNode* expr = NULL; TRY(TSDB_MAX_TAG_CONDITIONS) { - expr = exprTreeFromTableName(tbnameCond); - if (expr == NULL) { - expr = exprTreeFromBinary(pTagCond, len); - } else { - CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, expr, NULL); - tExprNode* tagExpr = exprTreeFromBinary(pTagCond, len); - if (tagExpr != NULL) { - CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, tagExpr, NULL); - tExprNode* tbnameExpr = expr; - expr = calloc(1, sizeof(tExprNode)); - if (expr == NULL) { - THROW( TSDB_CODE_TDB_OUT_OF_MEMORY ); - } - expr->nodeType = TSQL_NODE_EXPR; - expr->_node.optr = (uint8_t)tagNameRelType; - expr->_node.pLeft = tagExpr; - expr->_node.pRight = tbnameExpr; - } - } + expr = exprTreeFromBinary(pTagCond, len); CLEANUP_EXECUTE(); } CATCH( code ) { @@ -3824,7 +3692,20 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons // TODO: more error handling } END_TRY - doQueryTableList(pTable, res, expr); + void *filterInfo = NULL; + + ret = filterInitFromTree(expr, &filterInfo, 0); + if (ret != TSDB_CODE_SUCCESS) { + terrno = ret; + goto _error; + } + + tsdbQueryTableList(pTable, res, filterInfo); + + filterFreeInfo(filterInfo); + + tExprTreeDestroy(expr, NULL); + pGroupInfo->numOfTables = (uint32_t)taosArrayGetSize(res); pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey); @@ -4008,259 +3889,115 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) { pGroupList->numOfTables = 0; } -static void applyFilterToSkipListNode(SSkipList *pSkipList, tExprNode *pExpr, SArray *pResult, SExprTraverseSupp *param) { - SSkipListIterator* iter = tSkipListCreateIter(pSkipList); - - // Scan each node in the skiplist by using iterator - while (tSkipListIterNext(iter)) { - SSkipListNode *pNode = tSkipListIterGet(iter); - if (exprTreeApplyFilter(pExpr, pNode, param)) { - taosArrayPush(pResult, &(SL_GET_NODE_DATA(pNode))); - } - } - - tSkipListDestroyIter(iter); -} -typedef struct { - char* v; - int32_t optr; -} SEndPoint; - -typedef struct { - SEndPoint* start; - SEndPoint* end; -} SQueryCond; - -// todo check for malloc failure -static int32_t setQueryCond(tQueryInfo *queryColInfo, SQueryCond* pCond) { - int32_t optr = queryColInfo->optr; - - if (optr == TSDB_RELATION_GREATER || optr == TSDB_RELATION_GREATER_EQUAL || - optr == TSDB_RELATION_EQUAL || optr == TSDB_RELATION_NOT_EQUAL) { - pCond->start = calloc(1, sizeof(SEndPoint)); - pCond->start->optr = queryColInfo->optr; - pCond->start->v = queryColInfo->q; - } else if (optr == TSDB_RELATION_LESS || optr == TSDB_RELATION_LESS_EQUAL) { - pCond->end = calloc(1, sizeof(SEndPoint)); - pCond->end->optr = queryColInfo->optr; - pCond->end->v = queryColInfo->q; - } else if (optr == TSDB_RELATION_IN) { - pCond->start = calloc(1, sizeof(SEndPoint)); - pCond->start->optr = queryColInfo->optr; - pCond->start->v = queryColInfo->q; - } else if (optr == TSDB_RELATION_LIKE) { - assert(0); - } else if (optr == TSDB_RELATION_MATCH) { - assert(0); - } else if (optr == TSDB_RELATION_NMATCH) { - assert(0); +static FORCE_INLINE int32_t tsdbGetTagDataFromId(void *param, int32_t id, void **data) { + STable* pTable = (STable*)(SL_GET_NODE_DATA((SSkipListNode *)param)); + + if (id == TSDB_TBNAME_COLUMN_INDEX) { + *data = TABLE_NAME(pTable); + } else { + *data = tdGetKVRowValOfCol(pTable->tagVal, id); } return TSDB_CODE_SUCCESS; } -static void queryIndexedColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* result) { - SSkipListIterator* iter = NULL; - - SQueryCond cond = {0}; - if (setQueryCond(pQueryInfo, &cond) != TSDB_CODE_SUCCESS) { - //todo handle error - } - - if (cond.start != NULL) { - iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->type, TSDB_ORDER_ASC); - } else { - iter = tSkipListCreateIterFromVal(pSkipList, (char*)(cond.end ? cond.end->v: NULL), pSkipList->type, TSDB_ORDER_DESC); - } - - if (cond.start != NULL) { - int32_t optr = cond.start->optr; - - if (optr == TSDB_RELATION_EQUAL) { // equals - while(tSkipListIterNext(iter)) { - SSkipListNode* pNode = tSkipListIterGet(iter); - - int32_t ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v); - if (ret != 0) { - break; - } - - STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; - taosArrayPush(result, &info); - } - } else if (optr == TSDB_RELATION_GREATER || optr == TSDB_RELATION_GREATER_EQUAL) { // greater equal - bool comp = true; - int32_t ret = 0; - - while(tSkipListIterNext(iter)) { - SSkipListNode* pNode = tSkipListIterGet(iter); - - if (comp) { - ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v); - assert(ret >= 0); - } - - if (ret == 0 && optr == TSDB_RELATION_GREATER) { - continue; - } else { - STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; - taosArrayPush(result, &info); - comp = false; - } - } - } else if (optr == TSDB_RELATION_NOT_EQUAL) { // not equal - bool comp = true; - - while(tSkipListIterNext(iter)) { - SSkipListNode* pNode = tSkipListIterGet(iter); - comp = comp && (pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v) == 0); - if (comp) { - continue; - } - - STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; - taosArrayPush(result, &info); - } - tSkipListDestroyIter(iter); - comp = true; - iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->type, TSDB_ORDER_DESC); - while(tSkipListIterNext(iter)) { - SSkipListNode* pNode = tSkipListIterGet(iter); - comp = comp && (pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v) == 0); - if (comp) { - continue; - } - - STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; - taosArrayPush(result, &info); - } +static void queryIndexedColumn(SSkipList* pSkipList, void* filterInfo, SArray* res) { + SSkipListIterator* iter = NULL; + char *startVal = NULL; + int32_t order = 0; + int32_t inRange = 0; + int32_t flag = 0; + bool all = false; + int8_t *addToResult = NULL; - } else if (optr == TSDB_RELATION_IN) { - while(tSkipListIterNext(iter)) { - SSkipListNode* pNode = tSkipListIterGet(iter); + filterGetIndexedColumnInfo(filterInfo, &startVal, &order, &flag); - int32_t ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v); - if (ret != 0) { - break; - } + tsdbDebug("filter index column start, order:%d, flag:%d", order, flag); - STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; - taosArrayPush(result, &info); - } - + while (order) { + if (FILTER_GET_FLAG(order, TSDB_ORDER_ASC)) { + iter = tSkipListCreateIterFromVal(pSkipList, startVal, pSkipList->type, TSDB_ORDER_ASC); + FILTER_CLR_FLAG(order, TSDB_ORDER_ASC); } else { - assert(0); + iter = tSkipListCreateIterFromVal(pSkipList, startVal, pSkipList->type, TSDB_ORDER_DESC); + FILTER_CLR_FLAG(order, TSDB_ORDER_DESC); } - } else { - int32_t optr = cond.end ? cond.end->optr : TSDB_RELATION_INVALID; - if (optr == TSDB_RELATION_LESS || optr == TSDB_RELATION_LESS_EQUAL) { - bool comp = true; - int32_t ret = 0; - - while (tSkipListIterNext(iter)) { - SSkipListNode *pNode = tSkipListIterGet(iter); - - if (comp) { - ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.end->v); - assert(ret <= 0); - } + + while (tSkipListIterNext(iter)) { + SSkipListNode *pNode = tSkipListIterGet(iter); - if (ret == 0 && optr == TSDB_RELATION_LESS) { - continue; - } else { - STableKeyInfo info = {.pTable = (void *)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; - taosArrayPush(result, &info); - comp = false; // no need to compare anymore - } + if (inRange == 0 || !FILTER_GET_FLAG(flag, FI_ACTION_NO_NEED)) { + tsdbDebug("filter index column, filter it"); + filterSetColFieldData(filterInfo, pNode, tsdbGetTagDataFromId); + all = filterExecute(filterInfo, 1, &addToResult, NULL, 0); } - } else { - assert(pQueryInfo->optr == TSDB_RELATION_ISNULL || pQueryInfo->optr == TSDB_RELATION_NOTNULL); + + char *pData = SL_GET_NODE_DATA(pNode); - while (tSkipListIterNext(iter)) { - SSkipListNode *pNode = tSkipListIterGet(iter); + tsdbDebug("filter index column, table:%s, result:%d", ((STable *)pData)->name->data, all); - bool isnull = isNull(SL_GET_NODE_KEY(pSkipList, pNode), pQueryInfo->sch.type); - if ((pQueryInfo->optr == TSDB_RELATION_ISNULL && isnull) || - (pQueryInfo->optr == TSDB_RELATION_NOTNULL && (!isnull))) { - STableKeyInfo info = {.pTable = (void *)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; - taosArrayPush(result, &info); - } + if (all || (addToResult && *addToResult)) { + STableKeyInfo info = {.pTable = (void*)pData, .lastKey = TSKEY_INITIAL_VAL}; + taosArrayPush(res, &info); + inRange = 1; + } else if (inRange){ + break; } } + + inRange = 0; + + tfree(addToResult); + tSkipListDestroyIter(iter); } - free(cond.start); - free(cond.end); - tSkipListDestroyIter(iter); + tsdbDebug("filter index column end"); } -static void queryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* res, __result_filter_fn_t filterFp) { +static void queryIndexlessColumn(SSkipList* pSkipList, void* filterInfo, SArray* res) { SSkipListIterator* iter = tSkipListCreateIter(pSkipList); + int8_t *addToResult = NULL; while (tSkipListIterNext(iter)) { - bool addToResult = false; SSkipListNode *pNode = tSkipListIterGet(iter); + filterSetColFieldData(filterInfo, pNode, tsdbGetTagDataFromId); + char *pData = SL_GET_NODE_DATA(pNode); - tstr *name = (tstr*) tsdbGetTableName((void*) pData); - - // todo speed up by using hash - if (pQueryInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) { - if (pQueryInfo->optr == TSDB_RELATION_IN) { - addToResult = pQueryInfo->compare(name, pQueryInfo->q); - } else if (pQueryInfo->optr == TSDB_RELATION_LIKE || - pQueryInfo->optr == TSDB_RELATION_MATCH || - pQueryInfo->optr == TSDB_RELATION_NMATCH) { - addToResult = !pQueryInfo->compare(name, pQueryInfo->q); - } - } else { - addToResult = filterFp(pNode, pQueryInfo); - } - if (addToResult) { + bool all = filterExecute(filterInfo, 1, &addToResult, NULL, 0); + + if (all || (addToResult && *addToResult)) { STableKeyInfo info = {.pTable = (void*)pData, .lastKey = TSKEY_INITIAL_VAL}; taosArrayPush(res, &info); - } + } } + tfree(addToResult); + tSkipListDestroyIter(iter); } -// Apply the filter expression to each node in the skiplist to acquire the qualified nodes in skip list -void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param) { - if (pExpr == NULL) { - return; - } - - tExprNode *pLeft = pExpr->_node.pLeft; - tExprNode *pRight = pExpr->_node.pRight; - // column project - if (pLeft->nodeType != TSQL_NODE_EXPR && pRight->nodeType != TSQL_NODE_EXPR) { - assert(pLeft->nodeType == TSQL_NODE_COL && (pRight->nodeType == TSQL_NODE_VALUE || pRight->nodeType == TSQL_NODE_DUMMY)); - - param->setupInfoFn(pExpr, param->pExtInfo); +static int32_t tsdbQueryTableList(STable* pTable, SArray* pRes, void* filterInfo) { + STSchema* pTSSchema = pTable->tagSchema; + bool indexQuery = false; + SSkipList *pSkipList = pTable->pIndex; + + filterIsIndexedColumnQuery(filterInfo, pTSSchema->columns->colId, &indexQuery); + + if (indexQuery) { + queryIndexedColumn(pSkipList, filterInfo, pRes); + } else { + queryIndexlessColumn(pSkipList, filterInfo, pRes); + } - tQueryInfo *pQueryInfo = pExpr->_node.info; - if (pQueryInfo->indexed && (pQueryInfo->optr != TSDB_RELATION_LIKE - && pQueryInfo->optr != TSDB_RELATION_MATCH && pQueryInfo->optr != TSDB_RELATION_NMATCH - && pQueryInfo->optr != TSDB_RELATION_IN)) { - queryIndexedColumn(pSkipList, pQueryInfo, result); - } else { - queryIndexlessColumn(pSkipList, pQueryInfo, result, param->nodeFilterFn); - } + return TSDB_CODE_SUCCESS; +} - return; - } - // The value of hasPK is always 0. - uint8_t weight = pLeft->_node.hasPK + pRight->_node.hasPK; - assert(weight == 0 && pSkipList != NULL && taosArrayGetSize(result) == 0); - //apply the hierarchical filter expression to every node in skiplist to find the qualified nodes - applyFilterToSkipListNode(pSkipList, pExpr, result, param); -} diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index cf8977ce06c898fcdee8d21eedf5ed8d0f47f263..2ba4b964c04b0a1ca9f883cd619aae2b7fcbe1d7 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define TSDB_CFG_MAX_NUM 123 +#define TSDB_CFG_MAX_NUM 124 #define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_VALUE_LEN 41 @@ -89,6 +89,7 @@ void taosDumpGlobalCfg(); void taosInitConfigOption(SGlobalCfg cfg); SGlobalCfg * taosGetConfigOption(const char *option); +bool taosReadConfigOption(const char *option, char *value, char *value2, char *value3, int8_t cfgStatus, int8_t sourceType); #ifdef __cplusplus } diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 482dd8a6a15d1c7bf6aca76159b95b71ef244dd2..179fbd05a5a8f5ddfb28b68130f87e26ed4e522f 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -233,14 +233,20 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat int32_t i = 0; int32_t j = 0; + int32_t o = 0; + int32_t m = 0; while ((c = patterStr[i++]) != 0) { if (c == pInfo->matchAll) { /* Match "*" */ while ((c = patterStr[i++]) == pInfo->matchAll || c == pInfo->matchOne) { - if (c == pInfo->matchOne && (j > size || str[j++] == 0)) { - // empty string, return not match - return TSDB_PATTERN_NOWILDCARDMATCH; + if (c == pInfo->matchOne) { + if (j > size || str[j++] == 0) { + // empty string, return not match + return TSDB_PATTERN_NOWILDCARDMATCH; + } else { + ++o; + } } } @@ -249,9 +255,10 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat } char next[3] = {toupper(c), tolower(c), 0}; + m = o; while (1) { - size_t n = strcspn(str, next); - str += n; + size_t n = strcspn(str + m, next); + str += m + n; if (str[0] == 0 || (n >= size)) { break; @@ -261,12 +268,14 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat if (ret != TSDB_PATTERN_NOMATCH) { return ret; } + m = 0; } return TSDB_PATTERN_NOWILDCARDMATCH; } c1 = str[j++]; - + ++o; + if (j <= size) { if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; } if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) { @@ -292,7 +301,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c if (c == matchAll) { /* Match "%" */ while ((c = patterStr[i++]) == matchAll || c == matchOne) { - if (c == matchOne && (j > size || str[j++] == 0)) { + if (c == matchOne && (j >= size || str[j++] == 0)) { return TSDB_PATTERN_NOWILDCARDMATCH; } } diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index 5a3dc3f9bcdee41f974e48f22b27beb2a1eb5a35..9ce6876fd6d2c555acf5450a9128f787ccd300c8 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -26,6 +26,11 @@ SGlobalCfg tsGlobalConfig[TSDB_CFG_MAX_NUM] = {{0}}; int32_t tsGlobalConfigNum = 0; +#define ATOI_JUDGE if ( !value && strcmp(input_value, "0") != 0) { \ + uError("atoi error, input value:%s",input_value); \ + return false; \ + } + static char *tsGlobalUnit[] = { " ", "(%)", @@ -44,12 +49,14 @@ char *tsCfgStatusStr[] = { "program argument list" }; -static void taosReadFloatConfig(SGlobalCfg *cfg, char *input_value) { +static bool taosReadFloatConfig(SGlobalCfg *cfg, char *input_value) { float value = (float)atof(input_value); + ATOI_JUDGE float *option = (float *)cfg->ptr; if (value < cfg->minValue || value > cfg->maxValue) { uError("config option:%s, input value:%s, out of range[%f, %f], use default value:%f", cfg->option, input_value, cfg->minValue, cfg->maxValue, *option); + return false; } else { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { *option = value; @@ -57,16 +64,20 @@ static void taosReadFloatConfig(SGlobalCfg *cfg, char *input_value) { } else { uWarn("config option:%s, input value:%s, is configured by %s, use %f", cfg->option, input_value, tsCfgStatusStr[cfg->cfgStatus], *option); + return false; } } + return true; } -static void taosReadDoubleConfig(SGlobalCfg *cfg, char *input_value) { +static bool taosReadDoubleConfig(SGlobalCfg *cfg, char *input_value) { double value = atof(input_value); + ATOI_JUDGE double *option = (double *)cfg->ptr; if (value < cfg->minValue || value > cfg->maxValue) { uError("config option:%s, input value:%s, out of range[%f, %f], use default value:%f", cfg->option, input_value, cfg->minValue, cfg->maxValue, *option); + return false; } else { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { *option = value; @@ -74,17 +85,21 @@ static void taosReadDoubleConfig(SGlobalCfg *cfg, char *input_value) { } else { uWarn("config option:%s, input value:%s, is configured by %s, use %f", cfg->option, input_value, tsCfgStatusStr[cfg->cfgStatus], *option); + return false; } } + return true; } -static void taosReadInt32Config(SGlobalCfg *cfg, char *input_value) { +static bool taosReadInt32Config(SGlobalCfg *cfg, char *input_value) { int32_t value = atoi(input_value); + ATOI_JUDGE int32_t *option = (int32_t *)cfg->ptr; if (value < cfg->minValue || value > cfg->maxValue) { uError("config option:%s, input value:%s, out of range[%f, %f], use default value:%d", cfg->option, input_value, cfg->minValue, cfg->maxValue, *option); + return false; } else { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { *option = value; @@ -92,16 +107,20 @@ static void taosReadInt32Config(SGlobalCfg *cfg, char *input_value) { } else { uWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, input_value, tsCfgStatusStr[cfg->cfgStatus], *option); + return false; } } + return true; } -static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) { +static bool taosReadInt16Config(SGlobalCfg *cfg, char *input_value) { int32_t value = atoi(input_value); + ATOI_JUDGE int16_t *option = (int16_t *)cfg->ptr; if (value < cfg->minValue || value > cfg->maxValue) { uError("config option:%s, input value:%s, out of range[%f, %f], use default value:%d", cfg->option, input_value, cfg->minValue, cfg->maxValue, *option); + return false; } else { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { *option = (int16_t)value; @@ -109,16 +128,20 @@ static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) { } else { uWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, input_value, tsCfgStatusStr[cfg->cfgStatus], *option); + return false; } } + return true; } -static void taosReadUInt16Config(SGlobalCfg *cfg, char *input_value) { +static bool taosReadUInt16Config(SGlobalCfg *cfg, char *input_value) { int32_t value = atoi(input_value); + ATOI_JUDGE uint16_t *option = (uint16_t *)cfg->ptr; if (value < cfg->minValue || value > cfg->maxValue) { uError("config option:%s, input value:%s, out of range[%f, %f], use default value:%d", cfg->option, input_value, cfg->minValue, cfg->maxValue, *option); + return false; } else { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { *option = (uint16_t)value; @@ -126,16 +149,20 @@ static void taosReadUInt16Config(SGlobalCfg *cfg, char *input_value) { } else { uWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, input_value, tsCfgStatusStr[cfg->cfgStatus], *option); + return false; } } + return true; } -static void taosReadInt8Config(SGlobalCfg *cfg, char *input_value) { +static bool taosReadInt8Config(SGlobalCfg *cfg, char *input_value) { int32_t value = atoi(input_value); + ATOI_JUDGE int8_t *option = (int8_t *)cfg->ptr; if (value < cfg->minValue || value > cfg->maxValue) { uError("config option:%s, input value:%s, out of range[%f, %f], use default value:%d", cfg->option, input_value, cfg->minValue, cfg->maxValue, *option); + return false; } else { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { *option = (int8_t)value; @@ -143,8 +170,10 @@ static void taosReadInt8Config(SGlobalCfg *cfg, char *input_value) { } else { uWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, input_value, tsCfgStatusStr[cfg->cfgStatus], *option); + return false; } } + return true; } static bool taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { @@ -191,12 +220,13 @@ static bool taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { return true; } -static void taosReadIpStrConfig(SGlobalCfg *cfg, char *input_value) { +static bool taosReadIpStrConfig(SGlobalCfg *cfg, char *input_value) { uint32_t value = taosInetAddr(input_value); char * option = (char *)cfg->ptr; if (value == INADDR_NONE) { uError("config option:%s, input value:%s, is not a valid ip address, use default value:%s", cfg->option, input_value, option); + return false; } else { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { strncpy(option, input_value, cfg->ptrLength); @@ -204,16 +234,19 @@ static void taosReadIpStrConfig(SGlobalCfg *cfg, char *input_value) { } else { uWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, input_value, tsCfgStatusStr[cfg->cfgStatus], option); + return false; } } + return true; } -static void taosReadStringConfig(SGlobalCfg *cfg, char *input_value) { +static bool taosReadStringConfig(SGlobalCfg *cfg, char *input_value) { int length = (int) strlen(input_value); char *option = (char *)cfg->ptr; if (length <= 0 || length > cfg->ptrLength) { uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s", cfg->option, input_value, cfg->ptrLength, option); + return false; } else { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { strncpy(option, input_value, cfg->ptrLength); @@ -221,8 +254,10 @@ static void taosReadStringConfig(SGlobalCfg *cfg, char *input_value) { } else { uWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, input_value, tsCfgStatusStr[cfg->cfgStatus], option); + return false; } } + return true; } static void taosReadLogOption(char *option, char *value) { @@ -258,51 +293,59 @@ SGlobalCfg *taosGetConfigOption(const char *option) { return NULL; } -static void taosReadConfigOption(const char *option, char *value, char *value2, char *value3) { +bool taosReadConfigOption(const char *option, char *value, char *value2, char *value3, + int8_t cfgStatus, int8_t sourceType) { + bool ret = false; for (int i = 0; i < tsGlobalConfigNum; ++i) { SGlobalCfg *cfg = tsGlobalConfig + i; if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_CONFIG)) continue; + if (sourceType != 0 && !(cfg->cfgType & sourceType)) continue; if (strcasecmp(cfg->option, option) != 0) continue; switch (cfg->valType) { case TAOS_CFG_VTYPE_INT8: - taosReadInt8Config(cfg, value); + ret = taosReadInt8Config(cfg, value); break; case TAOS_CFG_VTYPE_INT16: - taosReadInt16Config(cfg, value); + ret = taosReadInt16Config(cfg, value); break; case TAOS_CFG_VTYPE_INT32: - taosReadInt32Config(cfg, value); + ret = taosReadInt32Config(cfg, value); break; case TAOS_CFG_VTYPE_UINT16: - taosReadUInt16Config(cfg, value); + ret = taosReadUInt16Config(cfg, value); break; case TAOS_CFG_VTYPE_FLOAT: - taosReadFloatConfig(cfg, value); + ret = taosReadFloatConfig(cfg, value); break; case TAOS_CFG_VTYPE_DOUBLE: - taosReadDoubleConfig(cfg, value); + ret = taosReadDoubleConfig(cfg, value); break; case TAOS_CFG_VTYPE_STRING: - taosReadStringConfig(cfg, value); + ret = taosReadStringConfig(cfg, value); break; case TAOS_CFG_VTYPE_IPSTR: - taosReadIpStrConfig(cfg, value); + ret = taosReadIpStrConfig(cfg, value); break; case TAOS_CFG_VTYPE_DIRECTORY: - taosReadDirectoryConfig(cfg, value); + ret = taosReadDirectoryConfig(cfg, value); break; case TAOS_CFG_VTYPE_DATA_DIRCTORY: if (taosReadDirectoryConfig(cfg, value)) { - taosReadDataDirCfg(value, value2, value3); + taosReadDataDirCfg(value, value2, value3); + ret = true; } + ret = false; break; default: uError("config option:%s, input value:%s, can't be recognized", option, value); - break; + ret = false; + } + if(ret && cfgStatus == TAOS_CFG_CSTATUS_OPTION){ + cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION; } - break; } + return ret; } void taosInitConfigOption(SGlobalCfg cfg) { @@ -336,6 +379,9 @@ void taosReadGlobalLogCfg() { #elif (_TD_TQ_ == true) printf("configDir:%s not there, use default value: /etc/tq", configDir); strcpy(configDir, "/etc/tq"); + #elif (_TD_PRO_ == true) + printf("configDir:%s not there, use default value: /etc/ProDB", configDir); + strcpy(configDir, "/etc/ProDB"); #else printf("configDir:%s not there, use default value: /etc/taos", configDir); strcpy(configDir, "/etc/taos"); @@ -437,7 +483,7 @@ bool taosReadGlobalCfg() { if (vlen3 != 0) value3[vlen3] = 0; } - taosReadConfigOption(option, value, value2, value3); + taosReadConfigOption(option, value, value2, value3, TAOS_CFG_CSTATUS_FILE, 0); } fclose(fp); @@ -560,4 +606,4 @@ void taosDumpGlobalCfg() { taosDumpCfg(cfg); } -} +} \ No newline at end of file diff --git a/src/util/src/terror.c b/src/util/src/terror.c index e3d022a6b0a4a929b6c06b2c305fb71b6980a865..404d4ad0c18944826abebf6d0e73c573dbe54756 100644 --- a/src/util/src/terror.c +++ b/src/util/src/terror.c @@ -118,6 +118,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_COLUMN_LENGTH, "Invalid column length TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DUP_TAG_NAMES, "duplicated tag names") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON, "Invalid JSON format") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_TYPE, "Invalid JSON data type") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_JSON_CONFIG, "Invalid JSON configuration") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_VALUE_OUT_OF_RANGE, "Value out of range") // mnode diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index 1ce3eadf58432337511d0d600848ad334b96fc91..0d335ca2664ffee75a79144b97181a5b625df66d 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -85,6 +85,8 @@ int64_t dbgWSize = 0; char tsLogDir[TSDB_FILENAME_LEN] = "/var/log/power"; #elif (_TD_TQ_ == true) char tsLogDir[TSDB_FILENAME_LEN] = "/var/log/tq"; +#elif (_TD_PRO_ == true) +char tsLogDir[TSDB_FILENAME_LEN] = "/var/log/ProDB"; #else char tsLogDir[PATH_MAX] = "/var/log/taos"; #endif diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 28e8d3f012dd4d6b4b12f2a01132b00a2ae7225c..c886c6d2fe332380e9f519bfc1133d3d5b4106fa 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -1033,9 +1033,9 @@ void verify_telnet_insert(TAOS* taos) { /* metric */ char* lines0[] = { - "stb0_0 1626006833639000000ns 4i8 host=\"host0\",interface=\"eth0\"", - "stb0_1 1626006833639000000ns 4i8 host=\"host0\",interface=\"eth0\"", - "stb0_2 1626006833639000000ns 4i8 host=\"host0\",interface=\"eth0\"", + "stb0_0 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", + "stb0_1 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", + "stb0_2 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", }; code = taos_insert_telnet_lines(taos, lines0, 3); if (code) { @@ -1057,7 +1057,7 @@ void verify_telnet_insert(TAOS* taos) { } /* metric value */ - //tinyin + //tinyint char* lines2_0[] = { "stb2_0 1626006833651ms -127i8 host=\"host0\"", "stb2_0 1626006833652ms 127i8 host=\"host0\"" @@ -1090,9 +1090,10 @@ void verify_telnet_insert(TAOS* taos) { //bigint char* lines2_3[] = { "stb2_3 1626006833651ms -9223372036854775807i64 host=\"host0\"", - "stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"" + "stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"", + "stb2_3 1626006833662ms 9223372036854775807 host=\"host0\"" }; - code = taos_insert_telnet_lines(taos, lines2_3, 2); + code = taos_insert_telnet_lines(taos, lines2_3, 3); if (code) { printf("lines2_3 code: %d, %s.\n", code, tstrerror(code)); } @@ -1107,11 +1108,10 @@ void verify_telnet_insert(TAOS* taos) { "stb2_4 1626006833660ms -3.4e10f32 host=\"host0\"", "stb2_4 1626006833670ms 3.4E+2f32 host=\"host0\"", "stb2_4 1626006833680ms -3.4e-2f32 host=\"host0\"", - "stb2_4 1626006833690ms 3.15 host=\"host0\"", "stb2_4 1626006833700ms 3.4E38f32 host=\"host0\"", "stb2_4 1626006833710ms -3.4E38f32 host=\"host0\"" }; - code = taos_insert_telnet_lines(taos, lines2_4, 11); + code = taos_insert_telnet_lines(taos, lines2_4, 10); if (code) { printf("lines2_4 code: %d, %s.\n", code, tstrerror(code)); } @@ -1127,9 +1127,10 @@ void verify_telnet_insert(TAOS* taos) { "stb2_5 1626006833670ms 3.4E+2f64 host=\"host0\"", "stb2_5 1626006833680ms -3.4e-2f64 host=\"host0\"", "stb2_5 1626006833690ms 1.7E308f64 host=\"host0\"", - "stb2_5 1626006833700ms -1.7E308f64 host=\"host0\"" + "stb2_5 1626006833700ms -1.7E308f64 host=\"host0\"", + "stb2_5 1626006833710ms 3.15 host=\"host0\"" }; - code = taos_insert_telnet_lines(taos, lines2_5, 10); + code = taos_insert_telnet_lines(taos, lines2_5, 11); if (code) { printf("lines2_5 code: %d, %s.\n", code, tstrerror(code)); } @@ -1166,7 +1167,7 @@ void verify_telnet_insert(TAOS* taos) { //nchar char* lines2_8[] = { "stb2_8 1626006833610ms L\"nchar_val数值一\" host=\"host0\"", - "stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\"", + "stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\"" }; code = taos_insert_telnet_lines(taos, lines2_8, 2); if (code) { @@ -1176,8 +1177,8 @@ void verify_telnet_insert(TAOS* taos) { /* tags */ //tag value types char* lines3_0[] = { - "stb3_0 1626006833610ms 1 t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=3.4E38f32,t6=1.7E308f64,t7=true,t8=\"binary_val_1\",t9=L\"标签值1\"", - "stb3_0 1626006833610ms 2 t1=-127i8,t2=-32767i16,t3=-2147483647i32,t4=-9223372036854775807i64,t5=-3.4E38f32,t6=-1.7E308f64,t7=false,t8=\"binary_val_2\",t9=L\"标签值2\"" + "stb3_0 1626006833610ms 1 t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=3.4E38f32 t6=1.7E308f64 t7=true t8=\"binary_val_1\" t9=L\"标签值1\"", + "stb3_0 1626006833610ms 2 t1=-127i8 t2=-32767i16 t3=-2147483647i32 t4=-9223372036854775807i64 t5=-3.4E38f32 t6=-1.7E308f64 t7=false t8=\"binary_val_2\" t9=L\"标签值2\"" }; code = taos_insert_telnet_lines(taos, lines3_0, 2); if (code) { @@ -1186,9 +1187,9 @@ void verify_telnet_insert(TAOS* taos) { //tag ID as child table name char* lines3_1[] = { - "stb3_1 1626006833610ms 1 id=\"child_table1\",host=\"host1\"", - "stb3_1 1626006833610ms 2 host=\"host2\",iD=\"child_table2\"", - "stb3_1 1626006833610ms 3 ID=\"child_table3\",host=\"host3\"" + "stb3_1 1626006833610ms 1 id=\"child_table1\" host=\"host1\"", + "stb3_1 1626006833610ms 2 host=\"host2\" iD=\"child_table2\"", + "stb3_1 1626006833610ms 3 ID=\"child_table3\" host=\"host3\"" }; code = taos_insert_telnet_lines(taos, lines3_1, 3); if (code) { diff --git a/tests/examples/c/clientcfgtest-taosd.c b/tests/examples/c/clientcfgtest-taosd.c new file mode 100644 index 0000000000000000000000000000000000000000..fbfbd8935a34481c23e806bbe461882ed9a10437 --- /dev/null +++ b/tests/examples/c/clientcfgtest-taosd.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include +#include "os.h" +#include "taosdef.h" +#include "taoserror.h" +#include "tconfig.h" +#include "tglobal.h" +#include "tulog.h" +#include "tsocket.h" +#include "tutil.h" +extern SGlobalCfg *taosGetConfigOption(const char *option) ; +int main( int argc, char *argv[]){ + + printf("start to test\n"); + + //case1: + //Test config to wrong type + const char config1[128] = "{\"cache\":\"4\"}";//input the parameter which want to be configured + taos_set_config(config1); //configure the parameter + + SGlobalCfg *cfg1 ; + + cfg1 = taosGetConfigOption("cache");//check the option result + if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config cache to '4'success!\n"); + else + printf("config cache failure!\n"); + return 0 ; + +} diff --git a/tests/examples/c/clientcfgtest-wrongjson.c b/tests/examples/c/clientcfgtest-wrongjson.c new file mode 100644 index 0000000000000000000000000000000000000000..eecb5dae6d27c213731afdea005af3fc265dd47f --- /dev/null +++ b/tests/examples/c/clientcfgtest-wrongjson.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include +#include "os.h" +#include "taosdef.h" +#include "taoserror.h" +#include "tconfig.h" +#include "tglobal.h" +#include "tulog.h" +#include "tsocket.h" +#include "tutil.h" +extern SGlobalCfg *taosGetConfigOption(const char *option) ; +int main( int argc, char *argv[]){ + + printf("start to test\n"); + + //case1: + //Test config with wrong JSON + //The result is failure + const char config1[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\135\"}";//input the parameter which want to be configured + taos_set_config(config1); //configure the parameter + + SGlobalCfg *cfg1 ; + cfg1 = taosGetConfigOption("firstEp");//check the option result + if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config firstEp 'BCC-2:6030'success!\n"); + else + printf("config firstEp failure!\n"); + SGlobalCfg *cfg2 ; + cfg2 = taosGetConfigOption("debugFlag");//check the option result + if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config debugFlag '135'success!\n"); + else + printf("config debugFlag failure!\n"); + + + //case2: + //repair the JSON and try again + //The result is success + const char config2[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\"135\"}";//input the parameter which want to be configured + taos_set_config(config2); //configure the parameter + + SGlobalCfg *cfg3 ; + + cfg3 = taosGetConfigOption("firstEp");//check the option result + if(cfg3->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config firstEp 'BCC-2:6030'success!\n"); + else + printf("config firstEp failure!\n"); + + SGlobalCfg *cfg4 ; + + cfg4 = taosGetConfigOption("debugFlag");//check the option result + if(cfg4->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config debugFlag '135'success!\n"); + else + printf("config debugFlag failure!\n"); + return 0 ; + +} diff --git a/tests/examples/c/clientcfgtest-wrongtype.c b/tests/examples/c/clientcfgtest-wrongtype.c new file mode 100644 index 0000000000000000000000000000000000000000..d88cbeebe8e5114ed4836e77b9494de1cc54aba8 --- /dev/null +++ b/tests/examples/c/clientcfgtest-wrongtype.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include "os.h" +#include "taosdef.h" +#include "taoserror.h" +#include "tconfig.h" +#include "tglobal.h" +#include "tulog.h" +#include "tsocket.h" +#include "tutil.h" +extern SGlobalCfg *taosGetConfigOption(const char *option) ; +int main( int argc, char *argv[]){ + + printf("start to test\n"); + + //case1: + //Test config to wrong type + //The result is failure + const char config1[128] = "{\"debugFlag\":\"9999999999999999999999999\"}";//input the parameter which want to be configured + taos_set_config(config1); //configure the parameter + + SGlobalCfg *cfg1 ; + + cfg1 = taosGetConfigOption("debugFlag");//check the option result + if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config debugFlag '9999999999999999999999999\n"); + else + printf("config debugFlag failure!\n"); + + //case2: + //Try again with right parameter + //The result is failure + const char config2[128] = "{\"debugFlag\":\"135\"}";//input the parameter which want to be configured + taos_set_config(config2); //configure the parameter + + SGlobalCfg *cfg2 ; + + cfg2 = taosGetConfigOption("debugFlag");//check the option result + if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config debugflag '135'success!\n"); + else + printf("config debugflag failure!\n"); + return 0 ; + +} diff --git a/tests/examples/c/clientcfgtest-wrongvalue.c b/tests/examples/c/clientcfgtest-wrongvalue.c new file mode 100644 index 0000000000000000000000000000000000000000..f0d44a47f62696d14844ea12276b74da7d0ff408 --- /dev/null +++ b/tests/examples/c/clientcfgtest-wrongvalue.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +#include "os.h" +#include "taosdef.h" +#include "taoserror.h" +#include "tconfig.h" +#include "tglobal.h" +#include "tulog.h" +#include "tsocket.h" +#include "tutil.h" +extern SGlobalCfg *taosGetConfigOption(const char *option) ; +int main( int argc, char *argv[]){ + + printf("start to test\n"); + + //case1: + //Test config to wrong type + const char config1[128] = "{\"rpcTimer\":\"0\"}";//input the parameter which want to be configured + taos_set_config(config1); //configure the parameter + + SGlobalCfg *cfg1 ; + + cfg1 = taosGetConfigOption("rpcTimer");//check the option result + if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config rpcTimer to '0'success!\n"); + else + printf("config rpcTimer failure!\n"); + + //case2: + //Try again with right parameter + const char config2[128] = "{\"rpcTimer\":\"400\"}";//input the parameter which want to be configured + taos_set_config(config2); //configure the parameter + + SGlobalCfg *cfg2 ; + + cfg2 = taosGetConfigOption("rpcTimer");//check the option result + if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config rpcTimer '400'success!\n"); + else + printf("config rpcTimer failure!\n"); + return 0 ; + +} diff --git a/tests/examples/c/clientcfgtest.c b/tests/examples/c/clientcfgtest.c new file mode 100644 index 0000000000000000000000000000000000000000..5f8f51cdb1156a25544273fc6419f65b86ea4ecc --- /dev/null +++ b/tests/examples/c/clientcfgtest.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include "os.h" +#include "taosdef.h" +#include "taoserror.h" +#include "tconfig.h" +#include "tglobal.h" +#include "tulog.h" +#include "tsocket.h" +#include "tutil.h" +extern SGlobalCfg *taosGetConfigOption(const char *option) ; +int main( int argc, char *argv[]){ + + printf("start to test\n"); + + //case1: + //Test config firstEp success + const char config1[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\"135\"}";//input the parameter which want to be configured + taos_set_config(config1); //configure the parameter + + SGlobalCfg *cfg1 ; + + cfg1 = taosGetConfigOption("firstEp");//check the option result + if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config firstEp 'BCC-2:6030'success!\n"); + else + printf("config firstEp failure!\n"); + + + SGlobalCfg *cfg2 ; + + cfg2 = taosGetConfigOption("debugFlag");//check the option result + if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config debugFlag '135' success!\n"); + else + printf("config debugFlag failure!\n"); + //case2: + //Test config only useful at the first time + //The result is failure + const char config2[128] = "{\"fqdn\":\"BCC-3\"}";//input the parameter which want to be configured + taos_set_config(config2); //configure the parameter + + SGlobalCfg *cfg3 ; + + cfg2 = taosGetConfigOption("fqdn");//check the option result + if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success + printf("config fqdn to 'BCC-3'success!\n"); + else + printf("config fqdn failure!\n"); + return 0 ; + +} diff --git a/tests/examples/c/makefile b/tests/examples/c/makefile index c85eb4adc515e5fb4e875b8e8e955222bc09190e..768cceaec7cab39606647b702f87c7a2f36aa473 100644 --- a/tests/examples/c/makefile +++ b/tests/examples/c/makefile @@ -7,7 +7,8 @@ LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt CFLAGS = -O3 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion \ -Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \ -Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 \ - -I../../../deps/cJson/inc + -I../../../deps/cJson/inc -I../../../src/os/inc -I../../../src/inc \ + -I../../../src/util/inc -I../../../src/common/inc all: $(TARGET) exe: @@ -17,6 +18,12 @@ exe: gcc $(CFLAGS) ./stream.c -o $(ROOT)stream $(LFLAGS) gcc $(CFLAGS) ./subscribe.c -o $(ROOT)subscribe $(LFLAGS) gcc $(CFLAGS) ./apitest.c -o $(ROOT)apitest $(LFLAGS) + gcc $(CFLAGS) ./clientcfgtest.c -o $(ROOT)clientcfgtest $(LFLAGS) + gcc $(CFLAGS) ./clientcfgtest-wrongtype.c -o $(ROOT)clientcfgtest-wrongtype $(LFLAGS) + gcc $(CFLAGS) ./clientcfgtest-wrongjson.c -o $(ROOT)clientcfgtest-wrongjson $(LFLAGS) + gcc $(CFLAGS) ./clientcfgtest-wrongvalue.c -o $(ROOT)clientcfgtest-wrongvalue $(LFLAGS) + gcc $(CFLAGS) ./clientcfgtest-taosd.c -o $(ROOT)clientcfgtest-taosd $(LFLAGS) + clean: rm $(ROOT)asyncdemo @@ -26,3 +33,9 @@ clean: rm $(ROOT)stream rm $(ROOT)subscribe rm $(ROOT)apitest + rm $(ROOT)clientcfgtest + rm $(ROOT)clientcfgtest-wrongtype + rm $(ROOT)clientcfgtest-wrongjson + rm $(ROOT)clientcfgtest-wrongvalue + rm $(ROOT)clientcfgtest-taosd + diff --git a/tests/pytest/crash_gen/valgrind_taos.supp b/tests/pytest/crash_gen/valgrind_taos.supp index ec44a85d5b29c0471db64b0362126804ae73adec..8c35778018b9c34789f862f6a728e487694357f4 100644 --- a/tests/pytest/crash_gen/valgrind_taos.supp +++ b/tests/pytest/crash_gen/valgrind_taos.supp @@ -18109,3 +18109,108 @@ fun:_PyEval_EvalCodeWithName fun:_PyFunction_Vectorcall } +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_and_cache_attr + fun:lib_getattr + fun:PyObject_GetAttr + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName + fun:PyEval_EvalCode + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_and_cache_attr + fun:lib_getattr + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_my_Py_InitModule + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__constant_time + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:lib_build_cpython_func.isra.87 + fun:lib_build_and_cache_attr + fun:lib_getattr + fun:PyObject_GetAttr + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault + fun:_PyFunction_Vectorcall + fun:_PyEval_EvalFrameDefault + obj:/usr/bin/python3.8 + fun:_PyEval_EvalFrameDefault +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_my_Py_InitModule + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__openssl + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault + fun:_PyEval_EvalCodeWithName +} +{ + + Memcheck:Leak + match-leak-kinds: definite + fun:malloc + fun:_PyObject_GC_New + fun:ffi_internal_new + fun:b_init_cffi_1_0_external_module + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyObject_CallMethod + fun:PyInit__constant_time + fun:_PyImport_LoadDynamicModuleWithSpec + obj:/usr/bin/python3.8 + obj:/usr/bin/python3.8 + fun:PyVectorcall_Call + fun:_PyEval_EvalFrameDefault +} \ No newline at end of file diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 3df42cbf33580d3b035ac1f5917372eb1c8f5924..b8bb94b26d5117cb9e99468dfa94155ca70c4193 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -273,6 +273,7 @@ python3 ./test.py -f query/queryCnameDisplay.py # python3 ./test.py -f query/operator_cost.py # python3 ./test.py -f query/long_where_query.py python3 test.py -f query/nestedQuery/queryWithSpread.py +python3 ./test.py -f query/bug6586.py #stream python3 ./test.py -f stream/metric_1.py @@ -359,6 +360,9 @@ python3 ./test.py -f functions/queryTestCases.py python3 ./test.py -f functions/function_stateWindow.py python3 ./test.py -f functions/function_derivative.py python3 ./test.py -f functions/function_irate.py +python3 ./test.py -f functions/function_ceil.py +python3 ./test.py -f functions/function_floor.py +python3 ./test.py -f functions/function_round.py python3 ./test.py -f insert/unsignedInt.py python3 ./test.py -f insert/unsignedBigint.py @@ -388,7 +392,7 @@ python3 test.py -f alter/alter_cacheLastRow.py python3 ./test.py -f query/querySession.py python3 test.py -f alter/alter_create_exception.py python3 ./test.py -f insert/flushwhiledrop.py -python3 ./test.py -f insert/schemalessInsert.py +#python3 ./test.py -f insert/schemalessInsert.py python3 ./test.py -f alter/alterColMultiTimes.py python3 ./test.py -f query/queryWildcardLength.py python3 ./test.py -f query/queryTbnameUpperLower.py diff --git a/tests/pytest/functions/function_ceil.py b/tests/pytest/functions/function_ceil.py new file mode 100644 index 0000000000000000000000000000000000000000..9197b0eec45a2154c2345a5b2fc469e54b1e41f9 --- /dev/null +++ b/tests/pytest/functions/function_ceil.py @@ -0,0 +1,1518 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def randomInt(self): + return random.randint(-2147483647, 2147483647) + + def randomUInt(self): + return random.randint(0, 4294967294) + + def randomBigint(self): + return random.randint(-2**63 + 1, 2**63 - 1) + + def randomUBigint(self): + return random.randint(0, 18446744073709551614) + + def randomDouble(self): + return random.random() + + def randomNchar(self): + return random.choice('abcdefghijklmnopqrstuvwxyz') + + def randomSmallint(self): + return random.randint(-32767, 32767) + + def randomUSmallint(self): + return random.randint(0, 65534) + + def randomTinyint(self): + return random.randint(-127, 127) + + def randomUTinyint(self): + return random.randint(0, 254) + + def run(self): + select_command = [ + "ceil(ts)", + "ceil(timestamp_col)", + "ceil(int_col)", + "ceil(bigint_col)", + "ceil(float_col)", + "ceil(double_col)", + "ceil(binary_col)", + "ceil(smallint_col)", + "ceil(tinyint_col)", + "ceil(bool_col)", + "ceil(nchar_col)", + "ceil(uint_col)", + "ceil(ubigint_col)", + "ceil(usmallint_col)", + "ceil(utinyint_col)", + "ceil(timestamp_tag)", + "ceil(int_tag)", + "ceil(bigint_tag)", + "ceil(float_tag)", + "ceil(double_tag)", + "ceil(binary_tag)", + "ceil(smallint_tag)", + "ceil(tinyint_tag)", + "ceil(bool_tag)", + "ceil(nchar_tag)", + "ceil(uint_tag)", + "ceil(ubigint_tag)", + "ceil(usmallint_tag)", + "ceil(utinyint_tag)", + "count(ceil(int_col))", + "count(ceil(bigint_col))", + "count(ceil(float_col))", + "count(ceil(double_col))", + "count(ceil(smallint_col))", + "count(ceil(tinyint_col))", + "count(ceil(uint_col))", + "count(ceil(ubigint_col))", + "count(ceil(usmallint_col))", + "count(ceil(utinyint_col))", + "avg(ceil(int_col))", + "avg(ceil(bigint_col))", + "avg(ceil(float_col))", + "avg(ceil(double_col))", + "avg(ceil(smallint_col))", + "avg(ceil(tinyint_col))", + "avg(ceil(uint_col))", + "avg(ceil(ubigint_col))", + "avg(ceil(usmallint_col))", + "avg(ceil(utinyint_col))", + "twa(ceil(int_col))", + "twa(ceil(bigint_col))", + "twa(ceil(float_col))", + "twa(ceil(double_col))", + "twa(ceil(smallint_col))", + "twa(ceil(tinyint_col))", + "twa(ceil(uint_col))", + "twa(ceil(ubigint_col))", + "twa(ceil(usmallint_col))", + "twa(ceil(utinyint_col))", + "sum(ceil(int_col))", + "sum(ceil(bigint_col))", + "sum(ceil(float_col))", + "sum(ceil(double_col))", + "sum(ceil(smallint_col))", + "sum(ceil(tinyint_col))", + "sum(ceil(uint_col))", + "sum(ceil(ubigint_col))", + "sum(ceil(usmallint_col))", + "sum(ceil(utinyint_col))", + "stddev(ceil(int_col))", + "stddev(ceil(bigint_col))", + "stddev(ceil(float_col))", + "stddev(ceil(double_col))", + "stddev(ceil(smallint_col))", + "stddev(ceil(tinyint_col))", + "stddev(ceil(uint_col))", + "stddev(ceil(ubigint_col))", + "stddev(ceil(usmallint_col))", + "stddev(ceil(utinyint_col))", + "irate(ceil(int_col))", + "irate(ceil(bigint_col))", + "irate(ceil(float_col))", + "irate(ceil(double_col))", + "irate(ceil(smallint_col))", + "irate(ceil(tinyint_col))", + "irate(ceil(uint_col))", + "irate(ceil(ubigint_col))", + "irate(ceil(usmallint_col))", + "irate(ceil(utinyint_col))", + "leastsquares(ceil(int_col), 1, 1)", + "leastsquares(ceil(bigint_col), 1, 1)", + "leastsquares(ceil(float_col), 1, 1)", + "leastsquares(ceil(double_col), 1, 1)", + "leastsquares(ceil(smallint_col), 1, 1)", + "leastsquares(ceil(tinyint_col), 1, 1)", + "leastsquares(ceil(uint_col), 1, 1)", + "leastsquares(ceil(ubigint_col), 1, 1)", + "leastsquares(ceil(usmallint_col), 1, 1)", + "leastsquares(ceil(utinyint_col), 1, 1)", + "min(ceil(int_col))", + "min(ceil(bigint_col))", + "min(ceil(float_col))", + "min(ceil(double_col))", + "min(ceil(smallint_col))", + "min(ceil(tinyint_col))", + "min(ceil(uint_col))", + "min(ceil(ubigint_col))", + "min(ceil(usmallint_col))", + "min(ceil(utinyint_col))", + "max(ceil(int_col))", + "max(ceil(bigint_col))", + "max(ceil(float_col))", + "max(ceil(double_col))", + "max(ceil(smallint_col))", + "max(ceil(tinyint_col))", + "max(ceil(uint_col))", + "max(ceil(ubigint_col))", + "max(ceil(usmallint_col))", + "max(ceil(utinyint_col))", + "first(ceil(int_col))", + "first(ceil(bigint_col))", + "first(ceil(float_col))", + "first(ceil(double_col))", + "first(ceil(smallint_col))", + "first(ceil(tinyint_col))", + "first(ceil(uint_col))", + "first(ceil(ubigint_col))", + "first(ceil(usmallint_col))", + "first(ceil(utinyint_col))", + "last(ceil(int_col))", + "last(ceil(bigint_col))", + "last(ceil(float_col))", + "last(ceil(double_col))", + "last(ceil(smallint_col))", + "last(ceil(tinyint_col))", + "last(ceil(uint_col))", + "last(ceil(ubigint_col))", + "last(ceil(usmallint_col))", + "last(ceil(utinyint_col))", + "top(ceil(int_col), 1)", + "top(ceil(bigint_col), 1)", + "top(ceil(float_col), 1)", + "top(ceil(double_col), 1)", + "top(ceil(smallint_col), 1)", + "top(ceil(tinyint_col), 1)", + "top(ceil(uint_col), 1)", + "top(ceil(ubigint_col), 1)", + "top(ceil(usmallint_col), 1)", + "top(ceil(utinyint_col), 1)", + "bottom(ceil(int_col), 1)", + "bottom(ceil(bigint_col), 1)", + "bottom(ceil(float_col), 1)", + "bottom(ceil(double_col), 1)", + "bottom(ceil(smallint_col), 1)", + "bottom(ceil(tinyint_col), 1)", + "bottom(ceil(uint_col), 1)", + "bottom(ceil(ubigint_col), 1)", + "bottom(ceil(usmallint_col), 1)", + "bottom(ceil(utinyint_col), 1)", + "percentile(ceil(int_col), 20)", + "percentile(ceil(bigint_col), 20)", + "percentile(ceil(float_col), 20)", + "percentile(ceil(double_col), 20)", + "percentile(ceil(smallint_col), 20)", + "percentile(ceil(tinyint_col), 20)", + "percentile(ceil(uint_col), 20)", + "percentile(ceil(ubigint_col), 20)", + "percentile(ceil(usmallint_col), 20)", + "percentile(ceil(utinyint_col), 20)", + "apercentile(ceil(int_col), 20)", + "apercentile(ceil(bigint_col), 20)", + "apercentile(ceil(float_col), 20)", + "apercentile(ceil(double_col), 20)", + "apercentile(ceil(smallint_col), 20)", + "apercentile(ceil(tinyint_col), 20)", + "apercentile(ceil(uint_col), 20)", + "apercentile(ceil(ubigint_col), 20)", + "apercentile(ceil(usmallint_col), 20)", + "apercentile(ceil(utinyint_col), 20)", + "last_row(ceil(int_col))", + "last_row(ceil(bigint_col))", + "last_row(ceil(float_col))", + "last_row(ceil(double_col))", + "last_row(ceil(smallint_col))", + "last_row(ceil(tinyint_col))", + "last_row(ceil(uint_col))", + "last_row(ceil(ubigint_col))", + "last_row(ceil(usmallint_col))", + "last_row(ceil(utinyint_col))", + "interp(ceil(int_col))", + "interp(ceil(bigint_col))", + "interp(ceil(float_col))", + "interp(ceil(double_col))", + "interp(ceil(smallint_col))", + "interp(ceil(tinyint_col))", + "interp(ceil(uint_col))", + "interp(ceil(ubigint_col))", + "interp(ceil(usmallint_col))", + "interp(ceil(utinyint_col))", + "diff(ceil(int_col))", + "diff(ceil(bigint_col))", + "diff(ceil(float_col))", + "diff(ceil(double_col))", + "diff(ceil(smallint_col))", + "diff(ceil(tinyint_col))", + "diff(ceil(uint_col))", + "diff(ceil(ubigint_col))", + "diff(ceil(usmallint_col))", + "diff(ceil(utinyint_col))", + "spread(ceil(int_col))", + "spread(ceil(bigint_col))", + "spread(ceil(float_col))", + "spread(ceil(double_col))", + "spread(ceil(smallint_col))", + "spread(ceil(tinyint_col))", + "spread(ceil(uint_col))", + "spread(ceil(ubigint_col))", + "spread(ceil(usmallint_col))", + "spread(ceil(utinyint_col))", + "derivative(ceil(int_col), 1s, 0)", + "derivative(ceil(bigint_col), 1s, 0)", + "derivative(ceil(float_col), 1s, 0)", + "derivative(ceil(double_col), 1s, 0)", + "derivative(ceil(smallint_col), 1s, 0)", + "derivative(ceil(tinyint_col), 1s, 0)", + "derivative(ceil(uint_col), 1s, 0)", + "derivative(ceil(ubigint_col), 1s, 0)", + "derivative(ceil(usmallint_col), 1s, 0)", + "derivative(ceil(utinyint_col), 1s, 0)", + "ceil(int_col) - ceil(int_col)", + "ceil(bigint_col) - ceil(bigint_col)", + "ceil(float_col) - ceil(float_col)", + "ceil(double_col) - ceil(double_col)", + "ceil(smallint_col) - ceil(smallint_col)", + "ceil(tinyint_col) - ceil(tinyint_col)", + "ceil(uint_col) - ceil(uint_col)", + "ceil(ubigint_col) - ceil(ubigint_col)", + "ceil(usmallint_col) - ceil(usmallint_col)", + "ceil(utinyint_col) - ceil(utinyint_col)", + "ceil(int_col) / ceil(int_col)", + "ceil(bigint_col) / ceil(bigint_col)", + "ceil(float_col) / ceil(float_col)", + "ceil(double_col) / ceil(double_col)", + "ceil(smallint_col) / ceil(smallint_col)", + "ceil(tinyint_col) / ceil(tinyint_col)", + "ceil(uint_col) / ceil(uint_col)", + "ceil(ubigint_col) / ceil(ubigint_col)", + "ceil(usmallint_col) / ceil(usmallint_col)", + "ceil(utinyint_col) / ceil(utinyint_col)", + "ceil(int_col) * ceil(int_col)", + "ceil(bigint_col) * ceil(bigint_col)", + "ceil(float_col) * ceil(float_col)", + "ceil(double_col) * ceil(double_col)", + "ceil(smallint_col) * ceil(smallint_col)", + "ceil(tinyint_col) * ceil(tinyint_col)", + "ceil(uint_col) * ceil(uint_col)", + "ceil(ubigint_col) * ceil(ubigint_col)", + "ceil(usmallint_col) * ceil(usmallint_col)", + "ceil(utinyint_col) * ceil(utinyint_col)", + "ceil(count(ts))", + "ceil(count(timestamp_col))", + "ceil(count(int_col))", + "ceil(count(bigint_col))", + "ceil(count(float_col))", + "ceil(count(double_col))", + "ceil(count(binary_col))", + "ceil(count(smallint_col))", + "ceil(count(tinyint_col))", + "ceil(count(bool_col))", + "ceil(count(nchar_col))", + "ceil(count(uint_col))", + "ceil(count(ubigint_col))", + "ceil(count(usmallint_col))", + "ceil(count(utinyint_col))", + "ceil(count(timestamp_tag))", + "ceil(count(int_tag))", + "ceil(count(bigint_tag))", + "ceil(count(float_tag))", + "ceil(count(double_tag))", + "ceil(count(binary_tag))", + "ceil(count(smallint_tag))", + "ceil(count(tinyint_tag))", + "ceil(count(bool_tag))", + "ceil(count(nchar_tag))", + "ceil(count(uint_tag))", + "ceil(count(ubigint_tag))", + "ceil(count(usmallint_tag))", + "ceil(count(utinyint_tag))", + "ceil(avg(ts))", + "ceil(avg(timestamp_col))", + "ceil(avg(int_col))", + "ceil(avg(bigint_col))", + "ceil(avg(float_col))", + "ceil(avg(double_col))", + "ceil(avg(binary_col))", + "ceil(avg(smallint_col))", + "ceil(avg(tinyint_col))", + "ceil(avg(bool_col))", + "ceil(avg(nchar_col))", + "ceil(avg(uint_col))", + "ceil(avg(ubigint_col))", + "ceil(avg(usmallint_col))", + "ceil(avg(utinyint_col))", + "ceil(avg(timestamp_tag))", + "ceil(avg(int_tag))", + "ceil(avg(bigint_tag))", + "ceil(avg(float_tag))", + "ceil(avg(double_tag))", + "ceil(avg(binary_tag))", + "ceil(avg(smallint_tag))", + "ceil(avg(tinyint_tag))", + "ceil(avg(bool_tag))", + "ceil(avg(nchar_tag))", + "ceil(avg(uint_tag))", + "ceil(avg(ubigint_tag))", + "ceil(avg(usmallint_tag))", + "ceil(avg(utinyint_tag))", + "ceil(twa(ts))", + "ceil(twa(timestamp_col))", + "ceil(twa(int_col))", + "ceil(twa(bigint_col))", + "ceil(twa(float_col))", + "ceil(twa(double_col))", + "ceil(twa(binary_col))", + "ceil(twa(smallint_col))", + "ceil(twa(tinyint_col))", + "ceil(twa(bool_col))", + "ceil(twa(nchar_col))", + "ceil(twa(uint_col))", + "ceil(twa(ubigint_col))", + "ceil(twa(usmallint_col))", + "ceil(twa(utinyint_col))", + "ceil(twa(timestamp_tag))", + "ceil(twa(int_tag))", + "ceil(twa(bigint_tag))", + "ceil(twa(float_tag))", + "ceil(twa(double_tag))", + "ceil(twa(binary_tag))", + "ceil(twa(smallint_tag))", + "ceil(twa(tinyint_tag))", + "ceil(twa(bool_tag))", + "ceil(twa(nchar_tag))", + "ceil(twa(uint_tag))", + "ceil(twa(ubigint_tag))", + "ceil(twa(usmallint_tag))", + "ceil(twa(utinyint_tag))", + "ceil(sum(ts))", + "ceil(sum(timestamp_col))", + "ceil(sum(int_col))", + "ceil(sum(bigint_col))", + "ceil(sum(float_col))", + "ceil(sum(double_col))", + "ceil(sum(binary_col))", + "ceil(sum(smallint_col))", + "ceil(sum(tinyint_col))", + "ceil(sum(bool_col))", + "ceil(sum(nchar_col))", + "ceil(sum(uint_col))", + "ceil(sum(ubigint_col))", + "ceil(sum(usmallint_col))", + "ceil(sum(utinyint_col))", + "ceil(sum(timestamp_tag))", + "ceil(sum(int_tag))", + "ceil(sum(bigint_tag))", + "ceil(sum(float_tag))", + "ceil(sum(double_tag))", + "ceil(sum(binary_tag))", + "ceil(sum(smallint_tag))", + "ceil(sum(tinyint_tag))", + "ceil(sum(bool_tag))", + "ceil(sum(nchar_tag))", + "ceil(sum(uint_tag))", + "ceil(sum(ubigint_tag))", + "ceil(sum(usmallint_tag))", + "ceil(sum(utinyint_tag))", + "ceil(stddev(ts))", + "ceil(stddev(timestamp_col))", + "ceil(stddev(int_col))", + "ceil(stddev(bigint_col))", + "ceil(stddev(float_col))", + "ceil(stddev(double_col))", + "ceil(stddev(binary_col))", + "ceil(stddev(smallint_col))", + "ceil(stddev(tinyint_col))", + "ceil(stddev(bool_col))", + "ceil(stddev(nchar_col))", + "ceil(stddev(uint_col))", + "ceil(stddev(ubigint_col))", + "ceil(stddev(usmallint_col))", + "ceil(stddev(utinyint_col))", + "ceil(stddev(timestamp_tag))", + "ceil(stddev(int_tag))", + "ceil(stddev(bigint_tag))", + "ceil(stddev(float_tag))", + "ceil(stddev(double_tag))", + "ceil(stddev(binary_tag))", + "ceil(stddev(smallint_tag))", + "ceil(stddev(tinyint_tag))", + "ceil(stddev(bool_tag))", + "ceil(stddev(nchar_tag))", + "ceil(stddev(uint_tag))", + "ceil(stddev(ubigint_tag))", + "ceil(stddev(usmallint_tag))", + "ceil(stddev(utinyint_tag))", + "ceil(leastsquares(ts, 1, 1))", + "ceil(leastsquares(timestamp_col, 1, 1))", + "ceil(leastsquares(int_col, 1, 1))", + "ceil(leastsquares(bigint_col, 1, 1))", + "ceil(leastsquares(float_col, 1, 1))", + "ceil(leastsquares(double_col, 1, 1))", + "ceil(leastsquares(binary_col, 1, 1))", + "ceil(leastsquares(smallint_col, 1, 1))", + "ceil(leastsquares(tinyint_col, 1, 1))", + "ceil(leastsquares(bool_col, 1, 1))", + "ceil(leastsquares(nchar_col, 1, 1))", + "ceil(leastsquares(uint_col, 1, 1))", + "ceil(leastsquares(ubigint_col, 1, 1))", + "ceil(leastsquares(usmallint_col, 1, 1))", + "ceil(leastsquares(utinyint_col, 1, 1))", + "ceil(leastsquares(timestamp_tag, 1, 1))", + "ceil(leastsquares(int_tag, 1, 1))", + "ceil(leastsquares(bigint_tag, 1, 1))", + "ceil(leastsquares(float_tag, 1, 1))", + "ceil(leastsquares(double_tag, 1, 1))", + "ceil(leastsquares(binary_tag, 1, 1))", + "ceil(leastsquares(smallint_tag, 1, 1))", + "ceil(leastsquares(tinyint_tag, 1, 1))", + "ceil(leastsquares(bool_tag, 1, 1))", + "ceil(leastsquares(nchar_tag, 1, 1))", + "ceil(leastsquares(uint_tag, 1, 1))", + "ceil(leastsquares(ubigint_tag, 1, 1))", + "ceil(leastsquares(usmallint_tag, 1, 1))", + "ceil(leastsquares(utinyint_tag, 1, 1))", + "ceil(irate(ts))", + "ceil(irate(timestamp_col))", + "ceil(irate(int_col))", + "ceil(irate(bigint_col))", + "ceil(irate(float_col))", + "ceil(irate(double_col))", + "ceil(irate(binary_col))", + "ceil(irate(smallint_col))", + "ceil(irate(tinyint_col))", + "ceil(irate(bool_col))", + "ceil(irate(nchar_col))", + "ceil(irate(uint_col))", + "ceil(irate(ubigint_col))", + "ceil(irate(usmallint_col))", + "ceil(irate(utinyint_col))", + "ceil(irate(timestamp_tag))", + "ceil(irate(int_tag))", + "ceil(irate(bigint_tag))", + "ceil(irate(float_tag))", + "ceil(irate(double_tag))", + "ceil(irate(binary_tag))", + "ceil(irate(smallint_tag))", + "ceil(irate(tinyint_tag))", + "ceil(irate(bool_tag))", + "ceil(irate(nchar_tag))", + "ceil(irate(uint_tag))", + "ceil(irate(ubigint_tag))", + "ceil(irate(usmallint_tag))", + "ceil(irate(utinyint_tag))", + "ceil(min(ts))", + "ceil(min(timestamp_col))", + "ceil(min(int_col))", + "ceil(min(bigint_col))", + "ceil(min(float_col))", + "ceil(min(double_col))", + "ceil(min(binary_col))", + "ceil(min(smallint_col))", + "ceil(min(tinyint_col))", + "ceil(min(bool_col))", + "ceil(min(nchar_col))", + "ceil(min(uint_col))", + "ceil(min(ubigint_col))", + "ceil(min(usmallint_col))", + "ceil(min(utinyint_col))", + "ceil(min(timestamp_tag))", + "ceil(min(int_tag))", + "ceil(min(bigint_tag))", + "ceil(min(float_tag))", + "ceil(min(double_tag))", + "ceil(min(binary_tag))", + "ceil(min(smallint_tag))", + "ceil(min(tinyint_tag))", + "ceil(min(bool_tag))", + "ceil(min(nchar_tag))", + "ceil(min(uint_tag))", + "ceil(min(ubigint_tag))", + "ceil(min(usmallint_tag))", + "ceil(min(utinyint_tag))", + "ceil(max(ts))", + "ceil(max(timestamp_col))", + "ceil(max(int_col))", + "ceil(max(bigint_col))", + "ceil(max(float_col))", + "ceil(max(double_col))", + "ceil(max(binary_col))", + "ceil(max(smallint_col))", + "ceil(max(tinyint_col))", + "ceil(max(bool_col))", + "ceil(max(nchar_col))", + "ceil(max(uint_col))", + "ceil(max(ubigint_col))", + "ceil(max(usmallint_col))", + "ceil(max(utinyint_col))", + "ceil(max(timestamp_tag))", + "ceil(max(int_tag))", + "ceil(max(bigint_tag))", + "ceil(max(float_tag))", + "ceil(max(double_tag))", + "ceil(max(binary_tag))", + "ceil(max(smallint_tag))", + "ceil(max(tinyint_tag))", + "ceil(max(bool_tag))", + "ceil(max(nchar_tag))", + "ceil(max(uint_tag))", + "ceil(max(ubigint_tag))", + "ceil(max(usmallint_tag))", + "ceil(max(utinyint_tag))", + "ceil(first(ts))", + "ceil(first(timestamp_col))", + "ceil(first(int_col))", + "ceil(first(bigint_col))", + "ceil(first(float_col))", + "ceil(first(double_col))", + "ceil(first(binary_col))", + "ceil(first(smallint_col))", + "ceil(first(tinyint_col))", + "ceil(first(bool_col))", + "ceil(first(nchar_col))", + "ceil(first(uint_col))", + "ceil(first(ubigint_col))", + "ceil(first(usmallint_col))", + "ceil(first(utinyint_col))", + "ceil(first(timestamp_tag))", + "ceil(first(int_tag))", + "ceil(first(bigint_tag))", + "ceil(first(float_tag))", + "ceil(first(double_tag))", + "ceil(first(binary_tag))", + "ceil(first(smallint_tag))", + "ceil(first(tinyint_tag))", + "ceil(first(bool_tag))", + "ceil(first(nchar_tag))", + "ceil(first(uint_tag))", + "ceil(first(ubigint_tag))", + "ceil(first(usmallint_tag))", + "ceil(first(utinyint_tag))", + "ceil(last(ts))", + "ceil(last(timestamp_col))", + "ceil(last(int_col))", + "ceil(last(bigint_col))", + "ceil(last(float_col))", + "ceil(last(double_col))", + "ceil(last(binary_col))", + "ceil(last(smallint_col))", + "ceil(last(tinyint_col))", + "ceil(last(bool_col))", + "ceil(last(nchar_col))", + "ceil(last(uint_col))", + "ceil(last(ubigint_col))", + "ceil(last(usmallint_col))", + "ceil(last(utinyint_col))", + "ceil(last(timestamp_tag))", + "ceil(last(int_tag))", + "ceil(last(bigint_tag))", + "ceil(last(float_tag))", + "ceil(last(double_tag))", + "ceil(last(binary_tag))", + "ceil(last(smallint_tag))", + "ceil(last(tinyint_tag))", + "ceil(last(bool_tag))", + "ceil(last(nchar_tag))", + "ceil(last(uint_tag))", + "ceil(last(ubigint_tag))", + "ceil(last(usmallint_tag))", + "ceil(last(utinyint_tag))", + "ceil(top(ts, 1))", + "ceil(top(timestamp_col, 1))", + "ceil(top(int_col, 1))", + "ceil(top(bigint_col, 1))", + "ceil(top(float_col, 1))", + "ceil(top(double_col, 1))", + "ceil(top(binary_col, 1))", + "ceil(top(smallint_col, 1))", + "ceil(top(tinyint_col, 1))", + "ceil(top(bool_col, 1))", + "ceil(top(nchar_col, 1))", + "ceil(top(uint_col, 1))", + "ceil(top(ubigint_col, 1))", + "ceil(top(usmallint_col, 1))", + "ceil(top(utinyint_col, 1))", + "ceil(top(timestamp_tag, 1))", + "ceil(top(int_tag, 1))", + "ceil(top(bigint_tag, 1))", + "ceil(top(float_tag, 1))", + "ceil(top(double_tag, 1))", + "ceil(top(binary_tag, 1))", + "ceil(top(smallint_tag, 1))", + "ceil(top(tinyint_tag, 1))", + "ceil(top(bool_tag, 1))", + "ceil(top(nchar_tag, 1))", + "ceil(top(uint_tag, 1))", + "ceil(top(ubigint_tag, 1))", + "ceil(top(usmallint_tag, 1))", + "ceil(top(utinyint_tag, 1))", + "ceil(bottom(ts, 1))", + "ceil(bottom(timestamp_col, 1))", + "ceil(bottom(int_col, 1))", + "ceil(bottom(bigint_col, 1))", + "ceil(bottom(float_col, 1))", + "ceil(bottom(double_col, 1))", + "ceil(bottom(binary_col, 1))", + "ceil(bottom(smallint_col, 1))", + "ceil(bottom(tinyint_col, 1))", + "ceil(bottom(bool_col, 1))", + "ceil(bottom(nchar_col, 1))", + "ceil(bottom(uint_col, 1))", + "ceil(bottom(ubigint_col, 1))", + "ceil(bottom(usmallint_col, 1))", + "ceil(bottom(utinyint_col, 1))", + "ceil(bottom(timestamp_tag, 1))", + "ceil(bottom(int_tag, 1))", + "ceil(bottom(bigint_tag, 1))", + "ceil(bottom(float_tag, 1))", + "ceil(bottom(double_tag, 1))", + "ceil(bottom(binary_tag, 1))", + "ceil(bottom(smallint_tag, 1))", + "ceil(bottom(tinyint_tag, 1))", + "ceil(bottom(bool_tag, 1))", + "ceil(bottom(nchar_tag, 1))", + "ceil(bottom(uint_tag, 1))", + "ceil(bottom(ubigint_tag, 1))", + "ceil(bottom(usmallint_tag, 1))", + "ceil(bottom(utinyint_tag, 1))", + "ceil(percentile(ts, 1))", + "ceil(percentile(timestamp_col, 1))", + "ceil(percentile(int_col, 1))", + "ceil(percentile(bigint_col, 1))", + "ceil(percentile(float_col, 1))", + "ceil(percentile(double_col, 1))", + "ceil(percentile(binary_col, 1))", + "ceil(percentile(smallint_col, 1))", + "ceil(percentile(tinyint_col, 1))", + "ceil(percentile(bool_col, 1))", + "ceil(percentile(nchar_col, 1))", + "ceil(percentile(uint_col, 1))", + "ceil(percentile(ubigint_col, 1))", + "ceil(percentile(usmallint_col, 1))", + "ceil(percentile(utinyint_col, 1))", + "ceil(percentile(timestamp_tag, 1))", + "ceil(percentile(int_tag, 1))", + "ceil(percentile(bigint_tag, 1))", + "ceil(percentile(float_tag, 1))", + "ceil(percentile(double_tag, 1))", + "ceil(percentile(binary_tag, 1))", + "ceil(percentile(smallint_tag, 1))", + "ceil(percentile(tinyint_tag, 1))", + "ceil(percentile(bool_tag, 1))", + "ceil(percentile(nchar_tag, 1))", + "ceil(percentile(uint_tag, 1))", + "ceil(percentile(ubigint_tag, 1))", + "ceil(percentile(usmallint_tag, 1))", + "ceil(percentile(utinyint_tag, 1))", + "ceil(apercentile(ts, 1))", + "ceil(apercentile(timestamp_col, 1))", + "ceil(apercentile(int_col, 1))", + "ceil(apercentile(bigint_col, 1))", + "ceil(apercentile(float_col, 1))", + "ceil(apercentile(double_col, 1))", + "ceil(apercentile(binary_col, 1))", + "ceil(apercentile(smallint_col, 1))", + "ceil(apercentile(tinyint_col, 1))", + "ceil(apercentile(bool_col, 1))", + "ceil(apercentile(nchar_col, 1))", + "ceil(apercentile(uint_col, 1))", + "ceil(apercentile(ubigint_col, 1))", + "ceil(apercentile(usmallint_col, 1))", + "ceil(apercentile(utinyint_col, 1))", + "ceil(apercentile(timestamp_tag, 1))", + "ceil(apercentile(int_tag, 1))", + "ceil(apercentile(bigint_tag, 1))", + "ceil(apercentile(float_tag, 1))", + "ceil(apercentile(double_tag, 1))", + "ceil(apercentile(binary_tag, 1))", + "ceil(apercentile(smallint_tag, 1))", + "ceil(apercentile(tinyint_tag, 1))", + "ceil(apercentile(bool_tag, 1))", + "ceil(apercentile(nchar_tag, 1))", + "ceil(apercentile(uint_tag, 1))", + "ceil(apercentile(ubigint_tag, 1))", + "ceil(apercentile(usmallint_tag, 1))", + "ceil(apercentile(utinyint_tag, 1))", + "ceil(last_row(ts))", + "ceil(last_row(timestamp_col))", + "ceil(last_row(int_col))", + "ceil(last_row(bigint_col))", + "ceil(last_row(float_col))", + "ceil(last_row(double_col))", + "ceil(last_row(binary_col))", + "ceil(last_row(smallint_col))", + "ceil(last_row(tinyint_col))", + "ceil(last_row(bool_col))", + "ceil(last_row(nchar_col))", + "ceil(last_row(uint_col))", + "ceil(last_row(ubigint_col))", + "ceil(last_row(usmallint_col))", + "ceil(last_row(utinyint_col))", + "ceil(last_row(timestamp_tag))", + "ceil(last_row(int_tag))", + "ceil(last_row(bigint_tag))", + "ceil(last_row(float_tag))", + "ceil(last_row(double_tag))", + "ceil(last_row(binary_tag))", + "ceil(last_row(smallint_tag))", + "ceil(last_row(tinyint_tag))", + "ceil(last_row(bool_tag))", + "ceil(last_row(nchar_tag))", + "ceil(last_row(uint_tag))", + "ceil(last_row(ubigint_tag))", + "ceil(last_row(usmallint_tag))", + "ceil(last_row(utinyint_tag))", + "ceil(interp(ts))", + "ceil(interp(timestamp_col))", + "ceil(interp(int_col))", + "ceil(interp(bigint_col))", + "ceil(interp(float_col))", + "ceil(interp(double_col))", + "ceil(interp(binary_col))", + "ceil(interp(smallint_col))", + "ceil(interp(tinyint_col))", + "ceil(interp(bool_col))", + "ceil(interp(nchar_col))", + "ceil(interp(uint_col))", + "ceil(interp(ubigint_col))", + "ceil(interp(usmallint_col))", + "ceil(interp(utinyint_col))", + "ceil(interp(timestamp_tag))", + "ceil(interp(int_tag))", + "ceil(interp(bigint_tag))", + "ceil(interp(float_tag))", + "ceil(interp(double_tag))", + "ceil(interp(binary_tag))", + "ceil(interp(smallint_tag))", + "ceil(interp(tinyint_tag))", + "ceil(interp(bool_tag))", + "ceil(interp(nchar_tag))", + "ceil(interp(uint_tag))", + "ceil(interp(ubigint_tag))", + "ceil(interp(usmallint_tag))", + "ceil(interp(utinyint_tag))", + "ceil(diff(ts))", + "ceil(diff(timestamp_col))", + "ceil(diff(int_col))", + "ceil(diff(bigint_col))", + "ceil(diff(float_col))", + "ceil(diff(double_col))", + "ceil(diff(binary_col))", + "ceil(diff(smallint_col))", + "ceil(diff(tinyint_col))", + "ceil(diff(bool_col))", + "ceil(diff(nchar_col))", + "ceil(diff(uint_col))", + "ceil(diff(ubigint_col))", + "ceil(diff(usmallint_col))", + "ceil(diff(utinyint_col))", + "ceil(diff(timestamp_tag))", + "ceil(diff(int_tag))", + "ceil(diff(bigint_tag))", + "ceil(diff(float_tag))", + "ceil(diff(double_tag))", + "ceil(diff(binary_tag))", + "ceil(diff(smallint_tag))", + "ceil(diff(tinyint_tag))", + "ceil(diff(bool_tag))", + "ceil(diff(nchar_tag))", + "ceil(diff(uint_tag))", + "ceil(diff(ubigint_tag))", + "ceil(diff(usmallint_tag))", + "ceil(diff(utinyint_tag))", + "ceil(spread(ts))", + "ceil(spread(timestamp_col))", + "ceil(spread(int_col))", + "ceil(spread(bigint_col))", + "ceil(spread(float_col))", + "ceil(spread(double_col))", + "ceil(spread(binary_col))", + "ceil(spread(smallint_col))", + "ceil(spread(tinyint_col))", + "ceil(spread(bool_col))", + "ceil(spread(nchar_col))", + "ceil(spread(uint_col))", + "ceil(spread(ubigint_col))", + "ceil(spread(usmallint_col))", + "ceil(spread(utinyint_col))", + "ceil(spread(timestamp_tag))", + "ceil(spread(int_tag))", + "ceil(spread(bigint_tag))", + "ceil(spread(float_tag))", + "ceil(spread(double_tag))", + "ceil(spread(binary_tag))", + "ceil(spread(smallint_tag))", + "ceil(spread(tinyint_tag))", + "ceil(spread(bool_tag))", + "ceil(spread(nchar_tag))", + "ceil(spread(uint_tag))", + "ceil(spread(ubigint_tag))", + "ceil(spread(usmallint_tag))", + "ceil(spread(utinyint_tag))", + "ceil(derivative(ts, 1s, 0))", + "ceil(derivative(timestamp_col, 1s, 0))", + "ceil(derivative(int_col, 1s, 0))", + "ceil(derivative(bigint_col, 1s, 0))", + "ceil(derivative(float_col, 1s, 0))", + "ceil(derivative(double_col, 1s, 0))", + "ceil(derivative(binary_col, 1s, 0))", + "ceil(derivative(smallint_col, 1s, 0))", + "ceil(derivative(tinyint_col, 1s, 0))", + "ceil(derivative(bool_col, 1s, 0))", + "ceil(derivative(nchar_col, 1s, 0))", + "ceil(derivative(uint_col, 1s, 0))", + "ceil(derivative(ubigint_col, 1s, 0))", + "ceil(derivative(usmallint_col, 1s, 0))", + "ceil(derivative(utinyint_col, 1s, 0))", + "ceil(derivative(timestamp_tag, 1s, 0))", + "ceil(derivative(int_tag, 1s, 0))", + "ceil(derivative(bigint_tag, 1s, 0))", + "ceil(derivative(float_tag, 1s, 0))", + "ceil(derivative(double_tag, 1s, 0))", + "ceil(derivative(binary_tag, 1s, 0))", + "ceil(derivative(smallint_tag, 1s, 0))", + "ceil(derivative(tinyint_tag, 1s, 0))", + "ceil(derivative(bool_tag, 1s, 0))", + "ceil(derivative(nchar_tag, 1s, 0))", + "ceil(derivative(uint_tag, 1s, 0))", + "ceil(derivative(ubigint_tag, 1s, 0))", + "ceil(derivative(usmallint_tag, 1s, 0))", + "ceil(derivative(utinyint_tag, 1s, 0))", + "ceil(ts + ts)", + "ceil(timestamp_col + timestamp_col)", + "ceil(int_col + int_col)", + "ceil(bigint_col + bigint_col)", + "ceil(float_col + float_col)", + "ceil(double_col + double_col)", + "ceil(binary_col + binary_col)", + "ceil(smallint_col + smallint_col)", + "ceil(tinyint_col + tinyint_col)", + "ceil(bool_col + bool_col)", + "ceil(nchar_col + nchar_col)", + "ceil(uint_col + uint_col)", + "ceil(ubigint_col + ubigint_col)", + "ceil(usmallint_col + usmallint_col)", + "ceil(utinyint_col + utinyint_col)", + "ceil(timestamp_tag + timestamp_tag)", + "ceil(int_tag + int_tag)", + "ceil(bigint_tag + bigint_tag)", + "ceil(float_tag + float_tag)", + "ceil(double_tag + double_tag)", + "ceil(binary_tag + binary_tag)", + "ceil(smallint_tag + smallint_tag)", + "ceil(tinyint_tag + tinyint_tag)", + "ceil(bool_tag + bool_tag)", + "ceil(nchar_tag + nchar_tag)", + "ceil(uint_tag + uint_tag)", + "ceil(ubigint_tag + ubigint_tag)", + "ceil(usmallint_tag + usmallint_tag)", + "ceil(utinyint_tag + utinyint_tag)", + "ceil(ts - ts)", + "ceil(timestamp_col - timestamp_col)", + "ceil(int_col - int_col)", + "ceil(bigint_col - bigint_col)", + "ceil(float_col - float_col)", + "ceil(double_col - double_col)", + "ceil(binary_col - binary_col)", + "ceil(smallint_col - smallint_col)", + "ceil(tinyint_col - tinyint_col)", + "ceil(bool_col - bool_col)", + "ceil(nchar_col - nchar_col)", + "ceil(uint_col - uint_col)", + "ceil(ubigint_col - ubigint_col)", + "ceil(usmallint_col - usmallint_col)", + "ceil(utinyint_col - utinyint_col)", + "ceil(timestamp_tag - timestamp_tag)", + "ceil(int_tag - int_tag)", + "ceil(bigint_tag - bigint_tag)", + "ceil(float_tag - float_tag)", + "ceil(double_tag - double_tag)", + "ceil(binary_tag - binary_tag)", + "ceil(smallint_tag - smallint_tag)", + "ceil(tinyint_tag - tinyint_tag)", + "ceil(bool_tag - bool_tag)", + "ceil(nchar_tag - nchar_tag)", + "ceil(uint_tag - uint_tag)", + "ceil(ubigint_tag - ubigint_tag)", + "ceil(usmallint_tag - usmallint_tag)", + "ceil(utinyint_tag - utinyint_tag)", + "ceil(ts * ts)", + "ceil(timestamp_col * timestamp_col)", + "ceil(int_col * int_col)", + "ceil(bigint_col * bigint_col)", + "ceil(float_col * float_col)", + "ceil(double_col * double_col)", + "ceil(binary_col * binary_col)", + "ceil(smallint_col * smallint_col)", + "ceil(tinyint_col * tinyint_col)", + "ceil(bool_col * bool_col)", + "ceil(nchar_col * nchar_col)", + "ceil(uint_col * uint_col)", + "ceil(ubigint_col * ubigint_col)", + "ceil(usmallint_col * usmallint_col)", + "ceil(utinyint_col * utinyint_col)", + "ceil(timestamp_tag * timestamp_tag)", + "ceil(int_tag * int_tag)", + "ceil(bigint_tag * bigint_tag)", + "ceil(float_tag * float_tag)", + "ceil(double_tag * double_tag)", + "ceil(binary_tag * binary_tag)", + "ceil(smallint_tag * smallint_tag)", + "ceil(tinyint_tag * tinyint_tag)", + "ceil(bool_tag * bool_tag)", + "ceil(nchar_tag * nchar_tag)", + "ceil(uint_tag * uint_tag)", + "ceil(ubigint_tag * ubigint_tag)", + "ceil(usmallint_tag * usmallint_tag)", + "ceil(utinyint_tag * utinyint_tag)", + "ceil(ts / ts)", + "ceil(timestamp_col / timestamp_col)", + "ceil(int_col / int_col)", + "ceil(bigint_col / bigint_col)", + "ceil(float_col / float_col)", + "ceil(double_col / double_col)", + "ceil(binary_col / binary_col)", + "ceil(smallint_col / smallint_col)", + "ceil(tinyint_col / tinyint_col)", + "ceil(bool_col / bool_col)", + "ceil(nchar_col / nchar_col)", + "ceil(uint_col / uint_col)", + "ceil(ubigint_col / ubigint_col)", + "ceil(usmallint_col / usmallint_col)", + "ceil(utinyint_col / utinyint_col)", + "ceil(timestamp_tag / timestamp_tag)", + "ceil(int_tag / int_tag)", + "ceil(bigint_tag / bigint_tag)", + "ceil(float_tag / float_tag)", + "ceil(double_tag / double_tag)", + "ceil(binary_tag / binary_tag)", + "ceil(smallint_tag / smallint_tag)", + "ceil(tinyint_tag / tinyint_tag)", + "ceil(bool_tag / bool_tag)", + "ceil(nchar_tag / nchar_tag)", + "ceil(uint_tag / uint_tag)", + "ceil(ubigint_tag / ubigint_tag)", + "ceil(usmallint_tag / usmallint_tag)", + "ceil(utinyint_tag / utinyint_tag)", + "int_col, ceil(int_col), int_col", + "bigint_col, ceil(bigint_col), bigint_col", + "float_col, ceil(float_col), float_col", + "double_col, ceil(double_col), double_col", + "smallint_col, ceil(smallint_col), smallint_col", + "tinyint_col, ceil(tinyint_col), tinyint_col", + "uint_col, ceil(uint_col), uint_col", + "ubigint_col, ceil(ubigint_col), ubigint_col", + "usmallint_col, ceil(usmallint_col), usmallint_col", + "utinyint_col, ceil(utinyint_col), utinyint_col", + "count(int_col), ceil(int_col), count(int_col)", + "count(bigint_col), ceil(bigint_col), count(bigint_col)", + "count(float_col), ceil(float_col), count(float_col)", + "count(double_col), ceil(double_col), count(double_col)", + "count(smallint_col), ceil(smallint_col), count(smallint_col)", + "count(tinyint_col), ceil(tinyint_col), count(tinyint_col)", + "count(uint_col), ceil(uint_col), count(uint_col)", + "count(ubigint_col), ceil(ubigint_col), count(ubigint_col)", + "count(usmallint_col), ceil(usmallint_col), count(usmallint_col)", + "count(utinyint_col), ceil(utinyint_col), count(utinyint_col)", + "avg(int_col), ceil(int_col), avg(int_col)", + "avg(bigint_col), ceil(bigint_col), avg(bigint_col)", + "avg(float_col), ceil(float_col), avg(float_col)", + "avg(double_col), ceil(double_col), avg(double_col)", + "avg(smallint_col), ceil(smallint_col), avg(smallint_col)", + "avg(tinyint_col), ceil(tinyint_col), avg(tinyint_col)", + "avg(uint_col), ceil(uint_col), avg(uint_col)", + "avg(ubigint_col), ceil(ubigint_col), avg(ubigint_col)", + "avg(usmallint_col), ceil(usmallint_col), avg(usmallint_col)", + "avg(utinyint_col), ceil(utinyint_col), avg(utinyint_col)", + "twa(int_col), ceil(int_col), twa(int_col)", + "twa(bigint_col), ceil(bigint_col), twa(bigint_col)", + "twa(float_col), ceil(float_col), twa(float_col)", + "twa(double_col), ceil(double_col), twa(double_col)", + "twa(smallint_col), ceil(smallint_col), twa(smallint_col)", + "twa(tinyint_col), ceil(tinyint_col), twa(tinyint_col)", + "twa(uint_col), ceil(uint_col), twa(uint_col)", + "twa(ubigint_col), ceil(ubigint_col), twa(ubigint_col)", + "twa(usmallint_col), ceil(usmallint_col), twa(usmallint_col)", + "twa(utinyint_col), ceil(utinyint_col), twa(utinyint_col)", + "sum(int_col), ceil(int_col), sum(int_col)", + "sum(bigint_col), ceil(bigint_col), sum(bigint_col)", + "sum(float_col), ceil(float_col), sum(float_col)", + "sum(double_col), ceil(double_col), sum(double_col)", + "sum(smallint_col), ceil(smallint_col), sum(smallint_col)", + "sum(tinyint_col), ceil(tinyint_col), sum(tinyint_col)", + "sum(uint_col), ceil(uint_col), sum(uint_col)", + "sum(ubigint_col), ceil(ubigint_col), sum(ubigint_col)", + "sum(usmallint_col), ceil(usmallint_col), sum(usmallint_col)", + "sum(utinyint_col), ceil(utinyint_col), sum(utinyint_col)", + "stddev(int_col), ceil(int_col), stddev(int_col)", + "stddev(bigint_col), ceil(bigint_col), stddev(bigint_col)", + "stddev(float_col), ceil(float_col), stddev(float_col)", + "stddev(double_col), ceil(double_col), stddev(double_col)", + "stddev(smallint_col), ceil(smallint_col), stddev(smallint_col)", + "stddev(tinyint_col), ceil(tinyint_col), stddev(tinyint_col)", + "stddev(uint_col), ceil(uint_col), stddev(uint_col)", + "stddev(ubigint_col), ceil(ubigint_col), stddev(ubigint_col)", + "stddev(usmallint_col), ceil(usmallint_col), stddev(usmallint_col)", + "stddev(utinyint_col), ceil(utinyint_col), stddev(utinyint_col)", + "irate(int_col), ceil(int_col), irate(int_col)", + "irate(bigint_col), ceil(bigint_col), irate(bigint_col)", + "irate(float_col), ceil(float_col), irate(float_col)", + "irate(double_col), ceil(double_col), irate(double_col)", + "irate(smallint_col), ceil(smallint_col), irate(smallint_col)", + "irate(tinyint_col), ceil(tinyint_col), irate(tinyint_col)", + "irate(uint_col), ceil(uint_col), irate(uint_col)", + "irate(ubigint_col), ceil(ubigint_col), irate(ubigint_col)", + "irate(usmallint_col), ceil(usmallint_col), irate(usmallint_col)", + "irate(utinyint_col), ceil(utinyint_col), irate(utinyint_col)", + "min(int_col), ceil(int_col), min(int_col)", + "min(bigint_col), ceil(bigint_col), min(bigint_col)", + "min(float_col), ceil(float_col), min(float_col)", + "min(double_col), ceil(double_col), min(double_col)", + "min(smallint_col), ceil(smallint_col), min(smallint_col)", + "min(tinyint_col), ceil(tinyint_col), min(tinyint_col)", + "min(uint_col), ceil(uint_col), min(uint_col)", + "min(ubigint_col), ceil(ubigint_col), min(ubigint_col)", + "min(usmallint_col), ceil(usmallint_col), min(usmallint_col)", + "min(utinyint_col), ceil(utinyint_col), min(utinyint_col)", + "max(int_col), ceil(int_col), max(int_col)", + "max(bigint_col), ceil(bigint_col), max(bigint_col)", + "max(float_col), ceil(float_col), max(float_col)", + "max(double_col), ceil(double_col), max(double_col)", + "max(smallint_col), ceil(smallint_col), max(smallint_col)", + "max(tinyint_col), ceil(tinyint_col), max(tinyint_col)", + "max(uint_col), ceil(uint_col), max(uint_col)", + "max(ubigint_col), ceil(ubigint_col), max(ubigint_col)", + "max(usmallint_col), ceil(usmallint_col), max(usmallint_col)", + "max(utinyint_col), ceil(utinyint_col), max(utinyint_col)", + "first(int_col), ceil(int_col), first(int_col)", + "first(bigint_col), ceil(bigint_col), first(bigint_col)", + "first(float_col), ceil(float_col), first(float_col)", + "first(double_col), ceil(double_col), first(double_col)", + "first(smallint_col), ceil(smallint_col), first(smallint_col)", + "first(tinyint_col), ceil(tinyint_col), first(tinyint_col)", + "first(uint_col), ceil(uint_col), first(uint_col)", + "first(ubigint_col), ceil(ubigint_col), first(ubigint_col)", + "first(usmallint_col), ceil(usmallint_col), first(usmallint_col)", + "first(utinyint_col), ceil(utinyint_col), first(utinyint_col)", + "last(int_col), ceil(int_col), last(int_col)", + "last(bigint_col), ceil(bigint_col), last(bigint_col)", + "last(float_col), ceil(float_col), last(float_col)", + "last(double_col), ceil(double_col), last(double_col)", + "last(smallint_col), ceil(smallint_col), last(smallint_col)", + "last(tinyint_col), ceil(tinyint_col), last(tinyint_col)", + "last(uint_col), ceil(uint_col), last(uint_col)", + "last(ubigint_col), ceil(ubigint_col), last(ubigint_col)", + "last(usmallint_col), ceil(usmallint_col), last(usmallint_col)", + "last(utinyint_col), ceil(utinyint_col), last(utinyint_col)", + "last_row(int_col), ceil(int_col), last_row(int_col)", + "last_row(bigint_col), ceil(bigint_col), last_row(bigint_col)", + "last_row(float_col), ceil(float_col), last_row(float_col)", + "last_row(double_col), ceil(double_col), last_row(double_col)", + "last_row(smallint_col), ceil(smallint_col), last_row(smallint_col)", + "last_row(tinyint_col), ceil(tinyint_col), last_row(tinyint_col)", + "last_row(uint_col), ceil(uint_col), last_row(uint_col)", + "last_row(ubigint_col), ceil(ubigint_col), last_row(ubigint_col)", + "last_row(usmallint_col), ceil(usmallint_col), last_row(usmallint_col)", + "last_row(utinyint_col), ceil(utinyint_col), last_row(utinyint_col)", + "interp(int_col), ceil(int_col), interp(int_col)", + "interp(bigint_col), ceil(bigint_col), interp(bigint_col)", + "interp(float_col), ceil(float_col), interp(float_col)", + "interp(double_col), ceil(double_col), interp(double_col)", + "interp(smallint_col), ceil(smallint_col), interp(smallint_col)", + "interp(tinyint_col), ceil(tinyint_col), interp(tinyint_col)", + "interp(uint_col), ceil(uint_col), interp(uint_col)", + "interp(ubigint_col), ceil(ubigint_col), interp(ubigint_col)", + "interp(usmallint_col), ceil(usmallint_col), interp(usmallint_col)", + "interp(utinyint_col), ceil(utinyint_col), interp(utinyint_col)", + "diff(int_col), ceil(int_col), diff(int_col)", + "diff(bigint_col), ceil(bigint_col), diff(bigint_col)", + "diff(float_col), ceil(float_col), diff(float_col)", + "diff(double_col), ceil(double_col), diff(double_col)", + "diff(smallint_col), ceil(smallint_col), diff(smallint_col)", + "diff(tinyint_col), ceil(tinyint_col), diff(tinyint_col)", + "diff(uint_col), ceil(uint_col), diff(uint_col)", + "diff(ubigint_col), ceil(ubigint_col), diff(ubigint_col)", + "diff(usmallint_col), ceil(usmallint_col), diff(usmallint_col)", + "diff(utinyint_col), ceil(utinyint_col), diff(utinyint_col)", + "spread(int_col), ceil(int_col), spread(int_col)", + "spread(bigint_col), ceil(bigint_col), spread(bigint_col)", + "spread(float_col), ceil(float_col), spread(float_col)", + "spread(double_col), ceil(double_col), spread(double_col)", + "spread(smallint_col), ceil(smallint_col), spread(smallint_col)", + "spread(tinyint_col), ceil(tinyint_col), spread(tinyint_col)", + "spread(uint_col), ceil(uint_col), spread(uint_col)", + "spread(ubigint_col), ceil(ubigint_col), spread(ubigint_col)", + "spread(usmallint_col), ceil(usmallint_col), spread(usmallint_col)", + "spread(utinyint_col), ceil(utinyint_col), spread(utinyint_col)", + "leastsquares(int_col, 1, 1), ceil(int_col), leastsquares(int_col, 1, 1)", + "leastsquares(bigint_col, 1, 1), ceil(bigint_col), leastsquares(bigint_col, 1, 1)", + "leastsquares(float_col, 1, 1), ceil(float_col), leastsquares(float_col, 1, 1)", + "leastsquares(double_col, 1, 1), ceil(double_col), leastsquares(double_col, 1, 1)", + "leastsquares(smallint_col, 1, 1), ceil(smallint_col), leastsquares(smallint_col, 1, 1)", + "leastsquares(tinyint_col, 1, 1), ceil(tinyint_col), leastsquares(tinyint_col, 1, 1)", + "leastsquares(uint_col, 1, 1), ceil(uint_col), leastsquares(uint_col, 1, 1)", + "leastsquares(ubigint_col, 1, 1), ceil(ubigint_col), leastsquares(ubigint_col, 1, 1)", + "leastsquares(usmallint_col, 1, 1), ceil(usmallint_col), leastsquares(usmallint_col, 1, 1)", + "leastsquares(utinyint_col, 1, 1), ceil(utinyint_col), leastsquares(utinyint_col, 1, 1)", + "top(int_col, 1), ceil(int_col), top(int_col, 1)", + "top(bigint_col, 1), ceil(bigint_col), top(bigint_col, 1)", + "top(float_col, 1), ceil(float_col), top(float_col, 1)", + "top(double_col, 1), ceil(double_col), top(double_col, 1)", + "top(smallint_col, 1), ceil(smallint_col), top(smallint_col, 1)", + "top(tinyint_col, 1), ceil(tinyint_col), top(tinyint_col, 1)", + "top(uint_col, 1), ceil(uint_col), top(uint_col, 1)", + "top(ubigint_col, 1), ceil(ubigint_col), top(ubigint_col, 1)", + "top(usmallint_col, 1), ceil(usmallint_col), top(usmallint_col, 1)", + "top(utinyint_col, 1), ceil(utinyint_col), top(utinyint_col, 1)", + "bottom(int_col, 1), ceil(int_col), bottom(int_col, 1)", + "bottom(bigint_col, 1), ceil(bigint_col), bottom(bigint_col, 1)", + "bottom(float_col, 1), ceil(float_col), bottom(float_col, 1)", + "bottom(double_col, 1), ceil(double_col), bottom(double_col, 1)", + "bottom(smallint_col, 1), ceil(smallint_col), bottom(smallint_col, 1)", + "bottom(tinyint_col, 1), ceil(tinyint_col), bottom(tinyint_col, 1)", + "bottom(uint_col, 1), ceil(uint_col), bottom(uint_col, 1)", + "bottom(ubigint_col, 1), ceil(ubigint_col), bottom(ubigint_col, 1)", + "bottom(usmallint_col, 1), ceil(usmallint_col), bottom(usmallint_col, 1)", + "bottom(utinyint_col, 1), ceil(utinyint_col), bottom(utinyint_col, 1)", + "percentile(int_col, 1), ceil(int_col), percentile(int_col, 1)", + "percentile(bigint_col, 1), ceil(bigint_col), percentile(bigint_col, 1)", + "percentile(float_col, 1), ceil(float_col), percentile(float_col, 1)", + "percentile(double_col, 1), ceil(double_col), percentile(double_col, 1)", + "percentile(smallint_col, 1), ceil(smallint_col), percentile(smallint_col, 1)", + "percentile(tinyint_col, 1), ceil(tinyint_col), percentile(tinyint_col, 1)", + "percentile(uint_col, 1), ceil(uint_col), percentile(uint_col, 1)", + "percentile(ubigint_col, 1), ceil(ubigint_col), percentile(ubigint_col, 1)", + "percentile(usmallint_col, 1), ceil(usmallint_col), percentile(usmallint_col, 1)", + "percentile(utinyint_col, 1), ceil(utinyint_col), percentile(utinyint_col, 1)", + "apercentile(int_col, 1), ceil(int_col), apercentile(int_col, 1)", + "apercentile(bigint_col, 1), ceil(bigint_col), apercentile(bigint_col, 1)", + "apercentile(float_col, 1), ceil(float_col), apercentile(float_col, 1)", + "apercentile(double_col, 1), ceil(double_col), apercentile(double_col, 1)", + "apercentile(smallint_col, 1), ceil(smallint_col), apercentile(smallint_col, 1)", + "apercentile(tinyint_col, 1), ceil(tinyint_col), apercentile(tinyint_col, 1)", + "apercentile(uint_col, 1), ceil(uint_col), apercentile(uint_col, 1)", + "apercentile(ubigint_col, 1), ceil(ubigint_col), apercentile(ubigint_col, 1)", + "apercentile(usmallint_col, 1), ceil(usmallint_col), apercentile(usmallint_col, 1)", + "apercentile(utinyint_col, 1), ceil(utinyint_col), apercentile(utinyint_col, 1)", + "derivative(int_col, 1s, 0), ceil(int_col), derivative(int_col, 1s, 0)", + "derivative(bigint_col, 1s, 0), ceil(bigint_col), derivative(bigint_col, 1s, 0)", + "derivative(float_col, 1s, 0), ceil(float_col), derivative(float_col, 1s, 0)", + "derivative(double_col, 1s, 0), ceil(double_col), derivative(double_col, 1s, 0)", + "derivative(smallint_col, 1s, 0), ceil(smallint_col), derivative(smallint_col, 1s, 0)", + "derivative(tinyint_col, 1s, 0), ceil(tinyint_col), derivative(tinyint_col, 1s, 0)", + "derivative(uint_col, 1s, 0), ceil(uint_col), derivative(uint_col, 1s, 0)", + "derivative(ubigint_col, 1s, 0), ceil(ubigint_col), derivative(ubigint_col, 1s, 0)", + "derivative(usmallint_col, 1s, 0), ceil(usmallint_col), derivative(usmallint_col, 1s, 0)", + "derivative(utinyint_col, 1s, 0), ceil(utinyint_col), derivative(utinyint_col, 1s, 0)", + "1, ceil(int_col), 1", + "1, ceil(bigint_col), 1", + "1, ceil(float_col), 1", + "1, ceil(double_col), 1", + "1, ceil(smallint_col), 1", + "1, ceil(tinyint_col), 1", + "1, ceil(uint_col), 1", + "1, ceil(ubigint_col), 1", + "1, ceil(usmallint_col), 1", + "1, ceil(utinyint_col), 1", + "ceil(int_col) as anyName", + "ceil(bigint_col) as anyName", + "ceil(float_col) as anyName", + "ceil(double_col) as anyName", + "ceil(smallint_col) as anyName", + "ceil(tinyint_col) as anyName", + "ceil(uint_col) as anyName", + "ceil(ubigint_col) as anyName", + "ceil(usmallint_col) as anyName", + "ceil(utinyint_col) as anyName", + "distinct ceil(int_col)", + "distinct ceil(bigint_col)", + "distinct ceil(float_col)", + "distinct ceil(double_col)", + "distinct ceil(smallint_col)", + "distinct ceil(tinyint_col)", + "distinct ceil(uint_col)", + "distinct ceil(ubigint_col)", + "distinct ceil(usmallint_col)", + "distinct ceil(utinyint_col)", + ] + simple_select_command = [ + "ceil(super.int_col)", + "ceil(super.bigint_col)", + "ceil(super.float_col)", + "ceil(super.double_col)", + "ceil(super.smallint_col)", + "ceil(super.tinyint_col)", + "ceil(super.uint_col)", + "ceil(super.ubigint_col)", + "ceil(super.usmallint_col)", + "ceil(super.utinyint_col)", + "ceil(t1.int_col)", + "ceil(t1.bigint_col)", + "ceil(t1.float_col)", + "ceil(t1.double_col)", + "ceil(t1.smallint_col)", + "ceil(t1.tinyint_col)", + "ceil(t1.uint_col)", + "ceil(t1.ubigint_col)", + "ceil(t1.usmallint_col)", + "ceil(t1.utinyint_col)", + ] + from_command = [" from super", " from t1"] + advance_from_command = [ + " from super", " from t1", + " from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag" + ] + filter_command = [ + "", " session(ts, 1s)", " state_window(int_col)", " interval (1s)", + " interval (1s) sliding (1s)", " group by (ts)" + ] + fill_command = [ + "", " fill(prev)", " fill(next)", " fill(null)", " fill(1)", + " fill(linear)" + ] + tdSql.prepare() + tdSql.execute( + "create stable super (ts timestamp, timestamp_col timestamp, int_col int, bigint_col bigint, float_col float,\ + double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ + uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ + float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + ) + tdSql.execute( + "create stable superb (ts timestamp, timestamp_col timestamp, int_col int, bigint_col bigint, float_col float,\ + double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ + uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ + float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + ) + tdSql.execute( + "create table t1 using super tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomBigint(), self.randomDouble(), self.randomDouble(), + self.randomNchar(), self.randomSmallint(), self.randomTinyint(), + self.randomNchar(), self.randomUInt(), self.randomUBigint(), + self.randomUSmallint(), self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215892, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215893, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215894, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "create table t2 using superb tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomBigint(), self.randomDouble(), self.randomDouble(), + self.randomNchar(), self.randomSmallint(), self.randomTinyint(), + self.randomNchar(), self.randomUInt(), self.randomUBigint(), + self.randomUSmallint(), self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215892, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215893, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215894, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + + for s in range(len(select_command)): + for f in range(len(from_command)): + sql = "select " + select_command[s] + from_command[f] + if (select_command[s] == "ceil(int_col)"\ + or select_command[s] == "ceil(bigint_col)"\ + or select_command[s] == "ceil(smallint_col)" \ + or select_command[s] == "ceil(float_col)"\ + or select_command[s] == "ceil(double_col)"\ + or select_command[s] == "ceil(tinyint_col)"\ + or select_command[s] == "ceil(uint_col)"\ + or select_command[s] == "ceil(ubigint_col)"\ + or select_command[s] == "ceil(usmallint_col)"\ + or select_command[s] == "ceil(utinyint_col)"\ + or select_command[s] == "1, ceil(int_col), 1"\ + or select_command[s] == "1, ceil(bigint_col), 1"\ + or select_command[s] == "1, ceil(float_col), 1"\ + or select_command[s] == "1, ceil(double_col), 1"\ + or select_command[s] == "1, ceil(smallint_col), 1"\ + or select_command[s] == "1, ceil(tinyint_col), 1"\ + or select_command[s] == "1, ceil(uint_col), 1"\ + or select_command[s] == "1, ceil(ubigint_col), 1"\ + or select_command[s] == "1, ceil(usmallint_col), 1"\ + or select_command[s] == "1, ceil(utinyint_col), 1"\ + or select_command[s] == "int_col, ceil(int_col), int_col"\ + or select_command[s] == "bigint_col, ceil(bigint_col), bigint_col"\ + or select_command[s] == "float_col, ceil(float_col), float_col"\ + or select_command[s] == "double_col, ceil(double_col), double_col"\ + or select_command[s] == "smallint_col, ceil(smallint_col), smallint_col"\ + or select_command[s] == "tinyint_col, ceil(tinyint_col), tinyint_col"\ + or select_command[s] == "uint_col, ceil(uint_col), uint_col"\ + or select_command[s] == "ubigint_col, ceil(ubigint_col), ubigint_col"\ + or select_command[s] == "usmallint_col, ceil(usmallint_col), usmallint_col"\ + or select_command[s] == "utinyint_col, ceil(utinyint_col), utinyint_col"\ + or select_command[s] == "ceil(int_col) as anyName"\ + or select_command[s] == "ceil(bigint_col) as anyName"\ + or select_command[s] == "ceil(float_col) as anyName"\ + or select_command[s] == "ceil(double_col) as anyName"\ + or select_command[s] == "ceil(smallint_col) as anyName"\ + or select_command[s] == "ceil(tinyint_col) as anyName"\ + or select_command[s] == "ceil(uint_col) as anyName"\ + or select_command[s] == "ceil(ubigint_col) as anyName"\ + or select_command[s] == "ceil(usmallint_col) as anyName"\ + or select_command[s] == "ceil(utinyint_col) as anyName"\ + or select_command[s] == "ceil(int_col) + ceil(int_col)"\ + or select_command[s] == "ceil(bigint_col) + ceil(bigint_col)"\ + or select_command[s] == "ceil(float_col) + ceil(float_col)"\ + or select_command[s] == "ceil(double_col) + ceil(double_col)"\ + or select_command[s] == "ceil(smallint_col) + ceil(smallint_col)"\ + or select_command[s] == "ceil(tinyint_col) + ceil(tinyint_col)"\ + or select_command[s] == "ceil(uint_col) + ceil(uint_col)"\ + or select_command[s] == "ceil(ubigint_col) + ceil(ubigint_col)"\ + or select_command[s] == "ceil(usmallint_col) + ceil(usmallint_col)"\ + or select_command[s] == "ceil(utinyint_col) + ceil(utinyint_col)"\ + or select_command[s] == "ceil(int_col) + ceil(int_col)"\ + or select_command[s] == "ceil(bigint_col) + ceil(bigint_col)"\ + or select_command[s] == "ceil(float_col) + ceil(float_col)"\ + or select_command[s] == "ceil(double_col) + ceil(double_col)"\ + or select_command[s] == "ceil(smallint_col) + ceil(smallint_col)"\ + or select_command[s] == "ceil(tinyint_col) + ceil(tinyint_col)"\ + or select_command[s] == "ceil(uint_col) + ceil(uint_col)"\ + or select_command[s] == "ceil(ubigint_col) + ceil(ubigint_col)"\ + or select_command[s] == "ceil(usmallint_col) + ceil(usmallint_col)"\ + or select_command[s] == "ceil(utinyint_col) + cei(utinyint_col)"\ + or select_command[s] == "ceil(int_col) - ceil(int_col)"\ + or select_command[s] == "ceil(bigint_col) - ceil(bigint_col)"\ + or select_command[s] == "ceil(float_col) - ceil(float_col)"\ + or select_command[s] == "ceil(double_col) - ceil(double_col)"\ + or select_command[s] == "ceil(smallint_col) - ceil(smallint_col)"\ + or select_command[s] == "ceil(tinyint_col) - ceil(tinyint_col)"\ + or select_command[s] == "ceil(uint_col) - ceil(uint_col)"\ + or select_command[s] == "ceil(ubigint_col) - ceil(ubigint_col)"\ + or select_command[s] == "ceil(usmallint_col) - ceil(usmallint_col)"\ + or select_command[s] == "ceil(utinyint_col) - ceil(utinyint_col)"\ + or select_command[s] == "ceil(int_col) * ceil(int_col)"\ + or select_command[s] == "ceil(bigint_col) * ceil(bigint_col)"\ + or select_command[s] == "ceil(float_col) * ceil(float_col)"\ + or select_command[s] == "ceil(double_col) * ceil(double_col)"\ + or select_command[s] == "ceil(smallint_col) * ceil(smallint_col)"\ + or select_command[s] == "ceil(tinyint_col) * ceil(tinyint_col)"\ + or select_command[s] == "ceil(uint_col) * ceil(uint_col)"\ + or select_command[s] == "ceil(ubigint_col) * ceil(ubigint_col)"\ + or select_command[s] == "ceil(usmallint_col) * ceil(usmallint_col)"\ + or select_command[s] == "ceil(utinyint_col) * ceil(utinyint_col)"\ + or select_command[s] == "ceil(int_col) / ceil(int_col)"\ + or select_command[s] == "ceil(bigint_col) / ceil(bigint_col)"\ + or select_command[s] == "ceil(float_col) / ceil(float_col)"\ + or select_command[s] == "ceil(double_col) / ceil(double_col)"\ + or select_command[s] == "ceil(smallint_col) / ceil(smallint_col)"\ + or select_command[s] == "ceil(tinyint_col) / ceil(tinyint_col)"\ + or select_command[s] == "ceil(uint_col) / ceil(uint_col)"\ + or select_command[s] == "ceil(ubigint_col) / ceil(ubigint_col)"\ + or select_command[s] == "ceil(usmallint_col) / ceil(usmallint_col)"\ + or select_command[s] == "ceil(utinyint_col) / ceil(utinyint_col)"): + tdSql.query(sql) + else: + tdSql.error(sql) + for sim in range(len(simple_select_command)): + for fr in range(len(advance_from_command)): + for filter in range(len(filter_command)): + for fill in range(len(fill_command)): + sql = "select " + simple_select_command[ + sim] + advance_from_command[fr] + filter_command[ + filter] + fill_command[fill] + if sql == "select ceil(t1.int_col) from t1"\ + or sql == "select ceil(super.int_col) from super"\ + or sql == "select ceil(t1.bigint_col) from t1"\ + or sql == "select ceil(super.bigint_col) from super"\ + or sql == "select ceil(t1.smallint_col) from t1"\ + or sql == "select ceil(super.smallint_col) from super"\ + or sql == "select ceil(t1.tinyint_col) from t1"\ + or sql == "select ceil(super.tinyint_col) from super"\ + or sql == "select ceil(t1.float_col) from t1"\ + or sql == "select ceil(super.float_col) from super"\ + or sql == "select ceil(t1.double_col) from t1"\ + or sql == "select ceil(super.double_col) from super"\ + or sql == "select ceil(t1.uint_col) from t1"\ + or sql == "select ceil(super.uint_col) from super"\ + or sql == "select ceil(t1.ubigint_col) from t1"\ + or sql == "select ceil(super.ubigint_col) from super"\ + or sql == "select ceil(t1.usmallint_col) from t1"\ + or sql == "select ceil(super.usmallint_col) from super"\ + or sql == "select ceil(t1.utinyint_col) from t1"\ + or sql == "select ceil(super.utinyint_col) from super"\ + or sql == "select ceil(super.int_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select ceil(super.bigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select ceil(super.smallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select ceil(super.tinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select ceil(super.float_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select ceil(super.double_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select ceil(super.uint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select ceil(super.ubigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select ceil(super.usmallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select ceil(super.utinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag": + tdSql.query(sql) + else: + tdSql.error(sql) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_floor.py b/tests/pytest/functions/function_floor.py new file mode 100644 index 0000000000000000000000000000000000000000..305e3b798a74376766a14cd824ded617db3cc8a2 --- /dev/null +++ b/tests/pytest/functions/function_floor.py @@ -0,0 +1,1518 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def randomInt(self): + return random.randint(-2147483647, 2147483647) + + def randomUInt(self): + return random.randint(0, 4294967294) + + def randomBigint(self): + return random.randint(-2**63 + 1, 2**63 - 1) + + def randomUBigint(self): + return random.randint(0, 18446744073709551614) + + def randomDouble(self): + return random.random() + + def randomNchar(self): + return random.choice('abcdefghijklmnopqrstuvwxyz') + + def randomSmallint(self): + return random.randint(-32767, 32767) + + def randomUSmallint(self): + return random.randint(0, 65534) + + def randomTinyint(self): + return random.randint(-127, 127) + + def randomUTinyint(self): + return random.randint(0, 254) + + def run(self): + select_command = [ + "floor(ts)", + "floor(timestamp_col)", + "floor(int_col)", + "floor(bigint_col)", + "floor(float_col)", + "floor(double_col)", + "floor(binary_col)", + "floor(smallint_col)", + "floor(tinyint_col)", + "floor(bool_col)", + "floor(nchar_col)", + "floor(uint_col)", + "floor(ubigint_col)", + "floor(usmallint_col)", + "floor(utinyint_col)", + "floor(timestamp_tag)", + "floor(int_tag)", + "floor(bigint_tag)", + "floor(float_tag)", + "floor(double_tag)", + "floor(binary_tag)", + "floor(smallint_tag)", + "floor(tinyint_tag)", + "floor(bool_tag)", + "floor(nchar_tag)", + "floor(uint_tag)", + "floor(ubigint_tag)", + "floor(usmallint_tag)", + "floor(utinyint_tag)", + "count(floor(int_col))", + "count(floor(bigint_col))", + "count(floor(float_col))", + "count(floor(double_col))", + "count(floor(smallint_col))", + "count(floor(tinyint_col))", + "count(floor(uint_col))", + "count(floor(ubigint_col))", + "count(floor(usmallint_col))", + "count(floor(utinyint_col))", + "avg(floor(int_col))", + "avg(floor(bigint_col))", + "avg(floor(float_col))", + "avg(floor(double_col))", + "avg(floor(smallint_col))", + "avg(floor(tinyint_col))", + "avg(floor(uint_col))", + "avg(floor(ubigint_col))", + "avg(floor(usmallint_col))", + "avg(floor(utinyint_col))", + "twa(floor(int_col))", + "twa(floor(bigint_col))", + "twa(floor(float_col))", + "twa(floor(double_col))", + "twa(floor(smallint_col))", + "twa(floor(tinyint_col))", + "twa(floor(uint_col))", + "twa(floor(ubigint_col))", + "twa(floor(usmallint_col))", + "twa(floor(utinyint_col))", + "sum(floor(int_col))", + "sum(floor(bigint_col))", + "sum(floor(float_col))", + "sum(floor(double_col))", + "sum(floor(smallint_col))", + "sum(floor(tinyint_col))", + "sum(floor(uint_col))", + "sum(floor(ubigint_col))", + "sum(floor(usmallint_col))", + "sum(floor(utinyint_col))", + "stddev(floor(int_col))", + "stddev(floor(bigint_col))", + "stddev(floor(float_col))", + "stddev(floor(double_col))", + "stddev(floor(smallint_col))", + "stddev(floor(tinyint_col))", + "stddev(floor(uint_col))", + "stddev(floor(ubigint_col))", + "stddev(floor(usmallint_col))", + "stddev(floor(utinyint_col))", + "irate(floor(int_col))", + "irate(floor(bigint_col))", + "irate(floor(float_col))", + "irate(floor(double_col))", + "irate(floor(smallint_col))", + "irate(floor(tinyint_col))", + "irate(floor(uint_col))", + "irate(floor(ubigint_col))", + "irate(floor(usmallint_col))", + "irate(floor(utinyint_col))", + "leastsquares(floor(int_col), 1, 1)", + "leastsquares(floor(bigint_col), 1, 1)", + "leastsquares(floor(float_col), 1, 1)", + "leastsquares(floor(double_col), 1, 1)", + "leastsquares(floor(smallint_col), 1, 1)", + "leastsquares(floor(tinyint_col), 1, 1)", + "leastsquares(floor(uint_col), 1, 1)", + "leastsquares(floor(ubigint_col), 1, 1)", + "leastsquares(floor(usmallint_col), 1, 1)", + "leastsquares(floor(utinyint_col), 1, 1)", + "min(floor(int_col))", + "min(floor(bigint_col))", + "min(floor(float_col))", + "min(floor(double_col))", + "min(floor(smallint_col))", + "min(floor(tinyint_col))", + "min(floor(uint_col))", + "min(floor(ubigint_col))", + "min(floor(usmallint_col))", + "min(floor(utinyint_col))", + "max(floor(int_col))", + "max(floor(bigint_col))", + "max(floor(float_col))", + "max(floor(double_col))", + "max(floor(smallint_col))", + "max(floor(tinyint_col))", + "max(floor(uint_col))", + "max(floor(ubigint_col))", + "max(floor(usmallint_col))", + "max(floor(utinyint_col))", + "first(floor(int_col))", + "first(floor(bigint_col))", + "first(floor(float_col))", + "first(floor(double_col))", + "first(floor(smallint_col))", + "first(floor(tinyint_col))", + "first(floor(uint_col))", + "first(floor(ubigint_col))", + "first(floor(usmallint_col))", + "first(floor(utinyint_col))", + "last(floor(int_col))", + "last(floor(bigint_col))", + "last(floor(float_col))", + "last(floor(double_col))", + "last(floor(smallint_col))", + "last(floor(tinyint_col))", + "last(floor(uint_col))", + "last(floor(ubigint_col))", + "last(floor(usmallint_col))", + "last(floor(utinyint_col))", + "top(floor(int_col), 1)", + "top(floor(bigint_col), 1)", + "top(floor(float_col), 1)", + "top(floor(double_col), 1)", + "top(floor(smallint_col), 1)", + "top(floor(tinyint_col), 1)", + "top(floor(uint_col), 1)", + "top(floor(ubigint_col), 1)", + "top(floor(usmallint_col), 1)", + "top(floor(utinyint_col), 1)", + "bottom(floor(int_col), 1)", + "bottom(floor(bigint_col), 1)", + "bottom(floor(float_col), 1)", + "bottom(floor(double_col), 1)", + "bottom(floor(smallint_col), 1)", + "bottom(floor(tinyint_col), 1)", + "bottom(floor(uint_col), 1)", + "bottom(floor(ubigint_col), 1)", + "bottom(floor(usmallint_col), 1)", + "bottom(floor(utinyint_col), 1)", + "percentile(floor(int_col), 20)", + "percentile(floor(bigint_col), 20)", + "percentile(floor(float_col), 20)", + "percentile(floor(double_col), 20)", + "percentile(floor(smallint_col), 20)", + "percentile(floor(tinyint_col), 20)", + "percentile(floor(uint_col), 20)", + "percentile(floor(ubigint_col), 20)", + "percentile(floor(usmallint_col), 20)", + "percentile(floor(utinyint_col), 20)", + "apercentile(floor(int_col), 20)", + "apercentile(floor(bigint_col), 20)", + "apercentile(floor(float_col), 20)", + "apercentile(floor(double_col), 20)", + "apercentile(floor(smallint_col), 20)", + "apercentile(floor(tinyint_col), 20)", + "apercentile(floor(uint_col), 20)", + "apercentile(floor(ubigint_col), 20)", + "apercentile(floor(usmallint_col), 20)", + "apercentile(floor(utinyint_col), 20)", + "last_row(floor(int_col))", + "last_row(floor(bigint_col))", + "last_row(floor(float_col))", + "last_row(floor(double_col))", + "last_row(floor(smallint_col))", + "last_row(floor(tinyint_col))", + "last_row(floor(uint_col))", + "last_row(floor(ubigint_col))", + "last_row(floor(usmallint_col))", + "last_row(floor(utinyint_col))", + "interp(floor(int_col))", + "interp(floor(bigint_col))", + "interp(floor(float_col))", + "interp(floor(double_col))", + "interp(floor(smallint_col))", + "interp(floor(tinyint_col))", + "interp(floor(uint_col))", + "interp(floor(ubigint_col))", + "interp(floor(usmallint_col))", + "interp(floor(utinyint_col))", + "diff(floor(int_col))", + "diff(floor(bigint_col))", + "diff(floor(float_col))", + "diff(floor(double_col))", + "diff(floor(smallint_col))", + "diff(floor(tinyint_col))", + "diff(floor(uint_col))", + "diff(floor(ubigint_col))", + "diff(floor(usmallint_col))", + "diff(floor(utinyint_col))", + "spread(floor(int_col))", + "spread(floor(bigint_col))", + "spread(floor(float_col))", + "spread(floor(double_col))", + "spread(floor(smallint_col))", + "spread(floor(tinyint_col))", + "spread(floor(uint_col))", + "spread(floor(ubigint_col))", + "spread(floor(usmallint_col))", + "spread(floor(utinyint_col))", + "derivative(floor(int_col), 1s, 0)", + "derivative(floor(bigint_col), 1s, 0)", + "derivative(floor(float_col), 1s, 0)", + "derivative(floor(double_col), 1s, 0)", + "derivative(floor(smallint_col), 1s, 0)", + "derivative(floor(tinyint_col), 1s, 0)", + "derivative(floor(uint_col), 1s, 0)", + "derivative(floor(ubigint_col), 1s, 0)", + "derivative(floor(usmallint_col), 1s, 0)", + "derivative(floor(utinyint_col), 1s, 0)", + "floor(int_col) - floor(int_col)", + "floor(bigint_col) - floor(bigint_col)", + "floor(float_col) - floor(float_col)", + "floor(double_col) - floor(double_col)", + "floor(smallint_col) - floor(smallint_col)", + "floor(tinyint_col) - floor(tinyint_col)", + "floor(uint_col) - floor(uint_col)", + "floor(ubigint_col) - floor(ubigint_col)", + "floor(usmallint_col) - floor(usmallint_col)", + "floor(utinyint_col) - floor(utinyint_col)", + "floor(int_col) / floor(int_col)", + "floor(bigint_col) / floor(bigint_col)", + "floor(float_col) / floor(float_col)", + "floor(double_col) / floor(double_col)", + "floor(smallint_col) / floor(smallint_col)", + "floor(tinyint_col) / floor(tinyint_col)", + "floor(uint_col) / floor(uint_col)", + "floor(ubigint_col) / floor(ubigint_col)", + "floor(usmallint_col) / floor(usmallint_col)", + "floor(utinyint_col) / floor(utinyint_col)", + "floor(int_col) * floor(int_col)", + "floor(bigint_col) * floor(bigint_col)", + "floor(float_col) * floor(float_col)", + "floor(double_col) * floor(double_col)", + "floor(smallint_col) * floor(smallint_col)", + "floor(tinyint_col) * floor(tinyint_col)", + "floor(uint_col) * floor(uint_col)", + "floor(ubigint_col) * floor(ubigint_col)", + "floor(usmallint_col) * floor(usmallint_col)", + "floor(utinyint_col) * floor(utinyint_col)", + "floor(count(ts))", + "floor(count(timestamp_col))", + "floor(count(int_col))", + "floor(count(bigint_col))", + "floor(count(float_col))", + "floor(count(double_col))", + "floor(count(binary_col))", + "floor(count(smallint_col))", + "floor(count(tinyint_col))", + "floor(count(bool_col))", + "floor(count(nchar_col))", + "floor(count(uint_col))", + "floor(count(ubigint_col))", + "floor(count(usmallint_col))", + "floor(count(utinyint_col))", + "floor(count(timestamp_tag))", + "floor(count(int_tag))", + "floor(count(bigint_tag))", + "floor(count(float_tag))", + "floor(count(double_tag))", + "floor(count(binary_tag))", + "floor(count(smallint_tag))", + "floor(count(tinyint_tag))", + "floor(count(bool_tag))", + "floor(count(nchar_tag))", + "floor(count(uint_tag))", + "floor(count(ubigint_tag))", + "floor(count(usmallint_tag))", + "floor(count(utinyint_tag))", + "floor(avg(ts))", + "floor(avg(timestamp_col))", + "floor(avg(int_col))", + "floor(avg(bigint_col))", + "floor(avg(float_col))", + "floor(avg(double_col))", + "floor(avg(binary_col))", + "floor(avg(smallint_col))", + "floor(avg(tinyint_col))", + "floor(avg(bool_col))", + "floor(avg(nchar_col))", + "floor(avg(uint_col))", + "floor(avg(ubigint_col))", + "floor(avg(usmallint_col))", + "floor(avg(utinyint_col))", + "floor(avg(timestamp_tag))", + "floor(avg(int_tag))", + "floor(avg(bigint_tag))", + "floor(avg(float_tag))", + "floor(avg(double_tag))", + "floor(avg(binary_tag))", + "floor(avg(smallint_tag))", + "floor(avg(tinyint_tag))", + "floor(avg(bool_tag))", + "floor(avg(nchar_tag))", + "floor(avg(uint_tag))", + "floor(avg(ubigint_tag))", + "floor(avg(usmallint_tag))", + "floor(avg(utinyint_tag))", + "floor(twa(ts))", + "floor(twa(timestamp_col))", + "floor(twa(int_col))", + "floor(twa(bigint_col))", + "floor(twa(float_col))", + "floor(twa(double_col))", + "floor(twa(binary_col))", + "floor(twa(smallint_col))", + "floor(twa(tinyint_col))", + "floor(twa(bool_col))", + "floor(twa(nchar_col))", + "floor(twa(uint_col))", + "floor(twa(ubigint_col))", + "floor(twa(usmallint_col))", + "floor(twa(utinyint_col))", + "floor(twa(timestamp_tag))", + "floor(twa(int_tag))", + "floor(twa(bigint_tag))", + "floor(twa(float_tag))", + "floor(twa(double_tag))", + "floor(twa(binary_tag))", + "floor(twa(smallint_tag))", + "floor(twa(tinyint_tag))", + "floor(twa(bool_tag))", + "floor(twa(nchar_tag))", + "floor(twa(uint_tag))", + "floor(twa(ubigint_tag))", + "floor(twa(usmallint_tag))", + "floor(twa(utinyint_tag))", + "floor(sum(ts))", + "floor(sum(timestamp_col))", + "floor(sum(int_col))", + "floor(sum(bigint_col))", + "floor(sum(float_col))", + "floor(sum(double_col))", + "floor(sum(binary_col))", + "floor(sum(smallint_col))", + "floor(sum(tinyint_col))", + "floor(sum(bool_col))", + "floor(sum(nchar_col))", + "floor(sum(uint_col))", + "floor(sum(ubigint_col))", + "floor(sum(usmallint_col))", + "floor(sum(utinyint_col))", + "floor(sum(timestamp_tag))", + "floor(sum(int_tag))", + "floor(sum(bigint_tag))", + "floor(sum(float_tag))", + "floor(sum(double_tag))", + "floor(sum(binary_tag))", + "floor(sum(smallint_tag))", + "floor(sum(tinyint_tag))", + "floor(sum(bool_tag))", + "floor(sum(nchar_tag))", + "floor(sum(uint_tag))", + "floor(sum(ubigint_tag))", + "floor(sum(usmallint_tag))", + "floor(sum(utinyint_tag))", + "floor(stddev(ts))", + "floor(stddev(timestamp_col))", + "floor(stddev(int_col))", + "floor(stddev(bigint_col))", + "floor(stddev(float_col))", + "floor(stddev(double_col))", + "floor(stddev(binary_col))", + "floor(stddev(smallint_col))", + "floor(stddev(tinyint_col))", + "floor(stddev(bool_col))", + "floor(stddev(nchar_col))", + "floor(stddev(uint_col))", + "floor(stddev(ubigint_col))", + "floor(stddev(usmallint_col))", + "floor(stddev(utinyint_col))", + "floor(stddev(timestamp_tag))", + "floor(stddev(int_tag))", + "floor(stddev(bigint_tag))", + "floor(stddev(float_tag))", + "floor(stddev(double_tag))", + "floor(stddev(binary_tag))", + "floor(stddev(smallint_tag))", + "floor(stddev(tinyint_tag))", + "floor(stddev(bool_tag))", + "floor(stddev(nchar_tag))", + "floor(stddev(uint_tag))", + "floor(stddev(ubigint_tag))", + "floor(stddev(usmallint_tag))", + "floor(stddev(utinyint_tag))", + "floor(leastsquares(ts, 1, 1))", + "floor(leastsquares(timestamp_col, 1, 1))", + "floor(leastsquares(int_col, 1, 1))", + "floor(leastsquares(bigint_col, 1, 1))", + "floor(leastsquares(float_col, 1, 1))", + "floor(leastsquares(double_col, 1, 1))", + "floor(leastsquares(binary_col, 1, 1))", + "floor(leastsquares(smallint_col, 1, 1))", + "floor(leastsquares(tinyint_col, 1, 1))", + "floor(leastsquares(bool_col, 1, 1))", + "floor(leastsquares(nchar_col, 1, 1))", + "floor(leastsquares(uint_col, 1, 1))", + "floor(leastsquares(ubigint_col, 1, 1))", + "floor(leastsquares(usmallint_col, 1, 1))", + "floor(leastsquares(utinyint_col, 1, 1))", + "floor(leastsquares(timestamp_tag, 1, 1))", + "floor(leastsquares(int_tag, 1, 1))", + "floor(leastsquares(bigint_tag, 1, 1))", + "floor(leastsquares(float_tag, 1, 1))", + "floor(leastsquares(double_tag, 1, 1))", + "floor(leastsquares(binary_tag, 1, 1))", + "floor(leastsquares(smallint_tag, 1, 1))", + "floor(leastsquares(tinyint_tag, 1, 1))", + "floor(leastsquares(bool_tag, 1, 1))", + "floor(leastsquares(nchar_tag, 1, 1))", + "floor(leastsquares(uint_tag, 1, 1))", + "floor(leastsquares(ubigint_tag, 1, 1))", + "floor(leastsquares(usmallint_tag, 1, 1))", + "floor(leastsquares(utinyint_tag, 1, 1))", + "floor(irate(ts))", + "floor(irate(timestamp_col))", + "floor(irate(int_col))", + "floor(irate(bigint_col))", + "floor(irate(float_col))", + "floor(irate(double_col))", + "floor(irate(binary_col))", + "floor(irate(smallint_col))", + "floor(irate(tinyint_col))", + "floor(irate(bool_col))", + "floor(irate(nchar_col))", + "floor(irate(uint_col))", + "floor(irate(ubigint_col))", + "floor(irate(usmallint_col))", + "floor(irate(utinyint_col))", + "floor(irate(timestamp_tag))", + "floor(irate(int_tag))", + "floor(irate(bigint_tag))", + "floor(irate(float_tag))", + "floor(irate(double_tag))", + "floor(irate(binary_tag))", + "floor(irate(smallint_tag))", + "floor(irate(tinyint_tag))", + "floor(irate(bool_tag))", + "floor(irate(nchar_tag))", + "floor(irate(uint_tag))", + "floor(irate(ubigint_tag))", + "floor(irate(usmallint_tag))", + "floor(irate(utinyint_tag))", + "floor(min(ts))", + "floor(min(timestamp_col))", + "floor(min(int_col))", + "floor(min(bigint_col))", + "floor(min(float_col))", + "floor(min(double_col))", + "floor(min(binary_col))", + "floor(min(smallint_col))", + "floor(min(tinyint_col))", + "floor(min(bool_col))", + "floor(min(nchar_col))", + "floor(min(uint_col))", + "floor(min(ubigint_col))", + "floor(min(usmallint_col))", + "floor(min(utinyint_col))", + "floor(min(timestamp_tag))", + "floor(min(int_tag))", + "floor(min(bigint_tag))", + "floor(min(float_tag))", + "floor(min(double_tag))", + "floor(min(binary_tag))", + "floor(min(smallint_tag))", + "floor(min(tinyint_tag))", + "floor(min(bool_tag))", + "floor(min(nchar_tag))", + "floor(min(uint_tag))", + "floor(min(ubigint_tag))", + "floor(min(usmallint_tag))", + "floor(min(utinyint_tag))", + "floor(max(ts))", + "floor(max(timestamp_col))", + "floor(max(int_col))", + "floor(max(bigint_col))", + "floor(max(float_col))", + "floor(max(double_col))", + "floor(max(binary_col))", + "floor(max(smallint_col))", + "floor(max(tinyint_col))", + "floor(max(bool_col))", + "floor(max(nchar_col))", + "floor(max(uint_col))", + "floor(max(ubigint_col))", + "floor(max(usmallint_col))", + "floor(max(utinyint_col))", + "floor(max(timestamp_tag))", + "floor(max(int_tag))", + "floor(max(bigint_tag))", + "floor(max(float_tag))", + "floor(max(double_tag))", + "floor(max(binary_tag))", + "floor(max(smallint_tag))", + "floor(max(tinyint_tag))", + "floor(max(bool_tag))", + "floor(max(nchar_tag))", + "floor(max(uint_tag))", + "floor(max(ubigint_tag))", + "floor(max(usmallint_tag))", + "floor(max(utinyint_tag))", + "floor(first(ts))", + "floor(first(timestamp_col))", + "floor(first(int_col))", + "floor(first(bigint_col))", + "floor(first(float_col))", + "floor(first(double_col))", + "floor(first(binary_col))", + "floor(first(smallint_col))", + "floor(first(tinyint_col))", + "floor(first(bool_col))", + "floor(first(nchar_col))", + "floor(first(uint_col))", + "floor(first(ubigint_col))", + "floor(first(usmallint_col))", + "floor(first(utinyint_col))", + "floor(first(timestamp_tag))", + "floor(first(int_tag))", + "floor(first(bigint_tag))", + "floor(first(float_tag))", + "floor(first(double_tag))", + "floor(first(binary_tag))", + "floor(first(smallint_tag))", + "floor(first(tinyint_tag))", + "floor(first(bool_tag))", + "floor(first(nchar_tag))", + "floor(first(uint_tag))", + "floor(first(ubigint_tag))", + "floor(first(usmallint_tag))", + "floor(first(utinyint_tag))", + "floor(last(ts))", + "floor(last(timestamp_col))", + "floor(last(int_col))", + "floor(last(bigint_col))", + "floor(last(float_col))", + "floor(last(double_col))", + "floor(last(binary_col))", + "floor(last(smallint_col))", + "floor(last(tinyint_col))", + "floor(last(bool_col))", + "floor(last(nchar_col))", + "floor(last(uint_col))", + "floor(last(ubigint_col))", + "floor(last(usmallint_col))", + "floor(last(utinyint_col))", + "floor(last(timestamp_tag))", + "floor(last(int_tag))", + "floor(last(bigint_tag))", + "floor(last(float_tag))", + "floor(last(double_tag))", + "floor(last(binary_tag))", + "floor(last(smallint_tag))", + "floor(last(tinyint_tag))", + "floor(last(bool_tag))", + "floor(last(nchar_tag))", + "floor(last(uint_tag))", + "floor(last(ubigint_tag))", + "floor(last(usmallint_tag))", + "floor(last(utinyint_tag))", + "floor(top(ts, 1))", + "floor(top(timestamp_col, 1))", + "floor(top(int_col, 1))", + "floor(top(bigint_col, 1))", + "floor(top(float_col, 1))", + "floor(top(double_col, 1))", + "floor(top(binary_col, 1))", + "floor(top(smallint_col, 1))", + "floor(top(tinyint_col, 1))", + "floor(top(bool_col, 1))", + "floor(top(nchar_col, 1))", + "floor(top(uint_col, 1))", + "floor(top(ubigint_col, 1))", + "floor(top(usmallint_col, 1))", + "floor(top(utinyint_col, 1))", + "floor(top(timestamp_tag, 1))", + "floor(top(int_tag, 1))", + "floor(top(bigint_tag, 1))", + "floor(top(float_tag, 1))", + "floor(top(double_tag, 1))", + "floor(top(binary_tag, 1))", + "floor(top(smallint_tag, 1))", + "floor(top(tinyint_tag, 1))", + "floor(top(bool_tag, 1))", + "floor(top(nchar_tag, 1))", + "floor(top(uint_tag, 1))", + "floor(top(ubigint_tag, 1))", + "floor(top(usmallint_tag, 1))", + "floor(top(utinyint_tag, 1))", + "floor(bottom(ts, 1))", + "floor(bottom(timestamp_col, 1))", + "floor(bottom(int_col, 1))", + "floor(bottom(bigint_col, 1))", + "floor(bottom(float_col, 1))", + "floor(bottom(double_col, 1))", + "floor(bottom(binary_col, 1))", + "floor(bottom(smallint_col, 1))", + "floor(bottom(tinyint_col, 1))", + "floor(bottom(bool_col, 1))", + "floor(bottom(nchar_col, 1))", + "floor(bottom(uint_col, 1))", + "floor(bottom(ubigint_col, 1))", + "floor(bottom(usmallint_col, 1))", + "floor(bottom(utinyint_col, 1))", + "floor(bottom(timestamp_tag, 1))", + "floor(bottom(int_tag, 1))", + "floor(bottom(bigint_tag, 1))", + "floor(bottom(float_tag, 1))", + "floor(bottom(double_tag, 1))", + "floor(bottom(binary_tag, 1))", + "floor(bottom(smallint_tag, 1))", + "floor(bottom(tinyint_tag, 1))", + "floor(bottom(bool_tag, 1))", + "floor(bottom(nchar_tag, 1))", + "floor(bottom(uint_tag, 1))", + "floor(bottom(ubigint_tag, 1))", + "floor(bottom(usmallint_tag, 1))", + "floor(bottom(utinyint_tag, 1))", + "floor(percentile(ts, 1))", + "floor(percentile(timestamp_col, 1))", + "floor(percentile(int_col, 1))", + "floor(percentile(bigint_col, 1))", + "floor(percentile(float_col, 1))", + "floor(percentile(double_col, 1))", + "floor(percentile(binary_col, 1))", + "floor(percentile(smallint_col, 1))", + "floor(percentile(tinyint_col, 1))", + "floor(percentile(bool_col, 1))", + "floor(percentile(nchar_col, 1))", + "floor(percentile(uint_col, 1))", + "floor(percentile(ubigint_col, 1))", + "floor(percentile(usmallint_col, 1))", + "floor(percentile(utinyint_col, 1))", + "floor(percentile(timestamp_tag, 1))", + "floor(percentile(int_tag, 1))", + "floor(percentile(bigint_tag, 1))", + "floor(percentile(float_tag, 1))", + "floor(percentile(double_tag, 1))", + "floor(percentile(binary_tag, 1))", + "floor(percentile(smallint_tag, 1))", + "floor(percentile(tinyint_tag, 1))", + "floor(percentile(bool_tag, 1))", + "floor(percentile(nchar_tag, 1))", + "floor(percentile(uint_tag, 1))", + "floor(percentile(ubigint_tag, 1))", + "floor(percentile(usmallint_tag, 1))", + "floor(percentile(utinyint_tag, 1))", + "floor(apercentile(ts, 1))", + "floor(apercentile(timestamp_col, 1))", + "floor(apercentile(int_col, 1))", + "floor(apercentile(bigint_col, 1))", + "floor(apercentile(float_col, 1))", + "floor(apercentile(double_col, 1))", + "floor(apercentile(binary_col, 1))", + "floor(apercentile(smallint_col, 1))", + "floor(apercentile(tinyint_col, 1))", + "floor(apercentile(bool_col, 1))", + "floor(apercentile(nchar_col, 1))", + "floor(apercentile(uint_col, 1))", + "floor(apercentile(ubigint_col, 1))", + "floor(apercentile(usmallint_col, 1))", + "floor(apercentile(utinyint_col, 1))", + "floor(apercentile(timestamp_tag, 1))", + "floor(apercentile(int_tag, 1))", + "floor(apercentile(bigint_tag, 1))", + "floor(apercentile(float_tag, 1))", + "floor(apercentile(double_tag, 1))", + "floor(apercentile(binary_tag, 1))", + "floor(apercentile(smallint_tag, 1))", + "floor(apercentile(tinyint_tag, 1))", + "floor(apercentile(bool_tag, 1))", + "floor(apercentile(nchar_tag, 1))", + "floor(apercentile(uint_tag, 1))", + "floor(apercentile(ubigint_tag, 1))", + "floor(apercentile(usmallint_tag, 1))", + "floor(apercentile(utinyint_tag, 1))", + "floor(last_row(ts))", + "floor(last_row(timestamp_col))", + "floor(last_row(int_col))", + "floor(last_row(bigint_col))", + "floor(last_row(float_col))", + "floor(last_row(double_col))", + "floor(last_row(binary_col))", + "floor(last_row(smallint_col))", + "floor(last_row(tinyint_col))", + "floor(last_row(bool_col))", + "floor(last_row(nchar_col))", + "floor(last_row(uint_col))", + "floor(last_row(ubigint_col))", + "floor(last_row(usmallint_col))", + "floor(last_row(utinyint_col))", + "floor(last_row(timestamp_tag))", + "floor(last_row(int_tag))", + "floor(last_row(bigint_tag))", + "floor(last_row(float_tag))", + "floor(last_row(double_tag))", + "floor(last_row(binary_tag))", + "floor(last_row(smallint_tag))", + "floor(last_row(tinyint_tag))", + "floor(last_row(bool_tag))", + "floor(last_row(nchar_tag))", + "floor(last_row(uint_tag))", + "floor(last_row(ubigint_tag))", + "floor(last_row(usmallint_tag))", + "floor(last_row(utinyint_tag))", + "floor(interp(ts))", + "floor(interp(timestamp_col))", + "floor(interp(int_col))", + "floor(interp(bigint_col))", + "floor(interp(float_col))", + "floor(interp(double_col))", + "floor(interp(binary_col))", + "floor(interp(smallint_col))", + "floor(interp(tinyint_col))", + "floor(interp(bool_col))", + "floor(interp(nchar_col))", + "floor(interp(uint_col))", + "floor(interp(ubigint_col))", + "floor(interp(usmallint_col))", + "floor(interp(utinyint_col))", + "floor(interp(timestamp_tag))", + "floor(interp(int_tag))", + "floor(interp(bigint_tag))", + "floor(interp(float_tag))", + "floor(interp(double_tag))", + "floor(interp(binary_tag))", + "floor(interp(smallint_tag))", + "floor(interp(tinyint_tag))", + "floor(interp(bool_tag))", + "floor(interp(nchar_tag))", + "floor(interp(uint_tag))", + "floor(interp(ubigint_tag))", + "floor(interp(usmallint_tag))", + "floor(interp(utinyint_tag))", + "floor(diff(ts))", + "floor(diff(timestamp_col))", + "floor(diff(int_col))", + "floor(diff(bigint_col))", + "floor(diff(float_col))", + "floor(diff(double_col))", + "floor(diff(binary_col))", + "floor(diff(smallint_col))", + "floor(diff(tinyint_col))", + "floor(diff(bool_col))", + "floor(diff(nchar_col))", + "floor(diff(uint_col))", + "floor(diff(ubigint_col))", + "floor(diff(usmallint_col))", + "floor(diff(utinyint_col))", + "floor(diff(timestamp_tag))", + "floor(diff(int_tag))", + "floor(diff(bigint_tag))", + "floor(diff(float_tag))", + "floor(diff(double_tag))", + "floor(diff(binary_tag))", + "floor(diff(smallint_tag))", + "floor(diff(tinyint_tag))", + "floor(diff(bool_tag))", + "floor(diff(nchar_tag))", + "floor(diff(uint_tag))", + "floor(diff(ubigint_tag))", + "floor(diff(usmallint_tag))", + "floor(diff(utinyint_tag))", + "floor(spread(ts))", + "floor(spread(timestamp_col))", + "floor(spread(int_col))", + "floor(spread(bigint_col))", + "floor(spread(float_col))", + "floor(spread(double_col))", + "floor(spread(binary_col))", + "floor(spread(smallint_col))", + "floor(spread(tinyint_col))", + "floor(spread(bool_col))", + "floor(spread(nchar_col))", + "floor(spread(uint_col))", + "floor(spread(ubigint_col))", + "floor(spread(usmallint_col))", + "floor(spread(utinyint_col))", + "floor(spread(timestamp_tag))", + "floor(spread(int_tag))", + "floor(spread(bigint_tag))", + "floor(spread(float_tag))", + "floor(spread(double_tag))", + "floor(spread(binary_tag))", + "floor(spread(smallint_tag))", + "floor(spread(tinyint_tag))", + "floor(spread(bool_tag))", + "floor(spread(nchar_tag))", + "floor(spread(uint_tag))", + "floor(spread(ubigint_tag))", + "floor(spread(usmallint_tag))", + "floor(spread(utinyint_tag))", + "floor(derivative(ts, 1s, 0))", + "floor(derivative(timestamp_col, 1s, 0))", + "floor(derivative(int_col, 1s, 0))", + "floor(derivative(bigint_col, 1s, 0))", + "floor(derivative(float_col, 1s, 0))", + "floor(derivative(double_col, 1s, 0))", + "floor(derivative(binary_col, 1s, 0))", + "floor(derivative(smallint_col, 1s, 0))", + "floor(derivative(tinyint_col, 1s, 0))", + "floor(derivative(bool_col, 1s, 0))", + "floor(derivative(nchar_col, 1s, 0))", + "floor(derivative(uint_col, 1s, 0))", + "floor(derivative(ubigint_col, 1s, 0))", + "floor(derivative(usmallint_col, 1s, 0))", + "floor(derivative(utinyint_col, 1s, 0))", + "floor(derivative(timestamp_tag, 1s, 0))", + "floor(derivative(int_tag, 1s, 0))", + "floor(derivative(bigint_tag, 1s, 0))", + "floor(derivative(float_tag, 1s, 0))", + "floor(derivative(double_tag, 1s, 0))", + "floor(derivative(binary_tag, 1s, 0))", + "floor(derivative(smallint_tag, 1s, 0))", + "floor(derivative(tinyint_tag, 1s, 0))", + "floor(derivative(bool_tag, 1s, 0))", + "floor(derivative(nchar_tag, 1s, 0))", + "floor(derivative(uint_tag, 1s, 0))", + "floor(derivative(ubigint_tag, 1s, 0))", + "floor(derivative(usmallint_tag, 1s, 0))", + "floor(derivative(utinyint_tag, 1s, 0))", + "floor(ts + ts)", + "floor(timestamp_col + timestamp_col)", + "floor(int_col + int_col)", + "floor(bigint_col + bigint_col)", + "floor(float_col + float_col)", + "floor(double_col + double_col)", + "floor(binary_col + binary_col)", + "floor(smallint_col + smallint_col)", + "floor(tinyint_col + tinyint_col)", + "floor(bool_col + bool_col)", + "floor(nchar_col + nchar_col)", + "floor(uint_col + uint_col)", + "floor(ubigint_col + ubigint_col)", + "floor(usmallint_col + usmallint_col)", + "floor(utinyint_col + utinyint_col)", + "floor(timestamp_tag + timestamp_tag)", + "floor(int_tag + int_tag)", + "floor(bigint_tag + bigint_tag)", + "floor(float_tag + float_tag)", + "floor(double_tag + double_tag)", + "floor(binary_tag + binary_tag)", + "floor(smallint_tag + smallint_tag)", + "floor(tinyint_tag + tinyint_tag)", + "floor(bool_tag + bool_tag)", + "floor(nchar_tag + nchar_tag)", + "floor(uint_tag + uint_tag)", + "floor(ubigint_tag + ubigint_tag)", + "floor(usmallint_tag + usmallint_tag)", + "floor(utinyint_tag + utinyint_tag)", + "floor(ts - ts)", + "floor(timestamp_col - timestamp_col)", + "floor(int_col - int_col)", + "floor(bigint_col - bigint_col)", + "floor(float_col - float_col)", + "floor(double_col - double_col)", + "floor(binary_col - binary_col)", + "floor(smallint_col - smallint_col)", + "floor(tinyint_col - tinyint_col)", + "floor(bool_col - bool_col)", + "floor(nchar_col - nchar_col)", + "floor(uint_col - uint_col)", + "floor(ubigint_col - ubigint_col)", + "floor(usmallint_col - usmallint_col)", + "floor(utinyint_col - utinyint_col)", + "floor(timestamp_tag - timestamp_tag)", + "floor(int_tag - int_tag)", + "floor(bigint_tag - bigint_tag)", + "floor(float_tag - float_tag)", + "floor(double_tag - double_tag)", + "floor(binary_tag - binary_tag)", + "floor(smallint_tag - smallint_tag)", + "floor(tinyint_tag - tinyint_tag)", + "floor(bool_tag - bool_tag)", + "floor(nchar_tag - nchar_tag)", + "floor(uint_tag - uint_tag)", + "floor(ubigint_tag - ubigint_tag)", + "floor(usmallint_tag - usmallint_tag)", + "floor(utinyint_tag - utinyint_tag)", + "floor(ts * ts)", + "floor(timestamp_col * timestamp_col)", + "floor(int_col * int_col)", + "floor(bigint_col * bigint_col)", + "floor(float_col * float_col)", + "floor(double_col * double_col)", + "floor(binary_col * binary_col)", + "floor(smallint_col * smallint_col)", + "floor(tinyint_col * tinyint_col)", + "floor(bool_col * bool_col)", + "floor(nchar_col * nchar_col)", + "floor(uint_col * uint_col)", + "floor(ubigint_col * ubigint_col)", + "floor(usmallint_col * usmallint_col)", + "floor(utinyint_col * utinyint_col)", + "floor(timestamp_tag * timestamp_tag)", + "floor(int_tag * int_tag)", + "floor(bigint_tag * bigint_tag)", + "floor(float_tag * float_tag)", + "floor(double_tag * double_tag)", + "floor(binary_tag * binary_tag)", + "floor(smallint_tag * smallint_tag)", + "floor(tinyint_tag * tinyint_tag)", + "floor(bool_tag * bool_tag)", + "floor(nchar_tag * nchar_tag)", + "floor(uint_tag * uint_tag)", + "floor(ubigint_tag * ubigint_tag)", + "floor(usmallint_tag * usmallint_tag)", + "floor(utinyint_tag * utinyint_tag)", + "floor(ts / ts)", + "floor(timestamp_col / timestamp_col)", + "floor(int_col / int_col)", + "floor(bigint_col / bigint_col)", + "floor(float_col / float_col)", + "floor(double_col / double_col)", + "floor(binary_col / binary_col)", + "floor(smallint_col / smallint_col)", + "floor(tinyint_col / tinyint_col)", + "floor(bool_col / bool_col)", + "floor(nchar_col / nchar_col)", + "floor(uint_col / uint_col)", + "floor(ubigint_col / ubigint_col)", + "floor(usmallint_col / usmallint_col)", + "floor(utinyint_col / utinyint_col)", + "floor(timestamp_tag / timestamp_tag)", + "floor(int_tag / int_tag)", + "floor(bigint_tag / bigint_tag)", + "floor(float_tag / float_tag)", + "floor(double_tag / double_tag)", + "floor(binary_tag / binary_tag)", + "floor(smallint_tag / smallint_tag)", + "floor(tinyint_tag / tinyint_tag)", + "floor(bool_tag / bool_tag)", + "floor(nchar_tag / nchar_tag)", + "floor(uint_tag / uint_tag)", + "floor(ubigint_tag / ubigint_tag)", + "floor(usmallint_tag / usmallint_tag)", + "floor(utinyint_tag / utinyint_tag)", + "int_col, floor(int_col), int_col", + "bigint_col, floor(bigint_col), bigint_col", + "float_col, floor(float_col), float_col", + "double_col, floor(double_col), double_col", + "smallint_col, floor(smallint_col), smallint_col", + "tinyint_col, floor(tinyint_col), tinyint_col", + "uint_col, floor(uint_col), uint_col", + "ubigint_col, floor(ubigint_col), ubigint_col", + "usmallint_col, floor(usmallint_col), usmallint_col", + "utinyint_col, floor(utinyint_col), utinyint_col", + "count(int_col), floor(int_col), count(int_col)", + "count(bigint_col), floor(bigint_col), count(bigint_col)", + "count(float_col), floor(float_col), count(float_col)", + "count(double_col), floor(double_col), count(double_col)", + "count(smallint_col), floor(smallint_col), count(smallint_col)", + "count(tinyint_col), floor(tinyint_col), count(tinyint_col)", + "count(uint_col), floor(uint_col), count(uint_col)", + "count(ubigint_col), floor(ubigint_col), count(ubigint_col)", + "count(usmallint_col), floor(usmallint_col), count(usmallint_col)", + "count(utinyint_col), floor(utinyint_col), count(utinyint_col)", + "avg(int_col), floor(int_col), avg(int_col)", + "avg(bigint_col), floor(bigint_col), avg(bigint_col)", + "avg(float_col), floor(float_col), avg(float_col)", + "avg(double_col), floor(double_col), avg(double_col)", + "avg(smallint_col), floor(smallint_col), avg(smallint_col)", + "avg(tinyint_col), floor(tinyint_col), avg(tinyint_col)", + "avg(uint_col), floor(uint_col), avg(uint_col)", + "avg(ubigint_col), floor(ubigint_col), avg(ubigint_col)", + "avg(usmallint_col), floor(usmallint_col), avg(usmallint_col)", + "avg(utinyint_col), floor(utinyint_col), avg(utinyint_col)", + "twa(int_col), floor(int_col), twa(int_col)", + "twa(bigint_col), floor(bigint_col), twa(bigint_col)", + "twa(float_col), floor(float_col), twa(float_col)", + "twa(double_col), floor(double_col), twa(double_col)", + "twa(smallint_col), floor(smallint_col), twa(smallint_col)", + "twa(tinyint_col), floor(tinyint_col), twa(tinyint_col)", + "twa(uint_col), floor(uint_col), twa(uint_col)", + "twa(ubigint_col), floor(ubigint_col), twa(ubigint_col)", + "twa(usmallint_col), floor(usmallint_col), twa(usmallint_col)", + "twa(utinyint_col), floor(utinyint_col), twa(utinyint_col)", + "sum(int_col), floor(int_col), sum(int_col)", + "sum(bigint_col), floor(bigint_col), sum(bigint_col)", + "sum(float_col), floor(float_col), sum(float_col)", + "sum(double_col), floor(double_col), sum(double_col)", + "sum(smallint_col), floor(smallint_col), sum(smallint_col)", + "sum(tinyint_col), floor(tinyint_col), sum(tinyint_col)", + "sum(uint_col), floor(uint_col), sum(uint_col)", + "sum(ubigint_col), floor(ubigint_col), sum(ubigint_col)", + "sum(usmallint_col), floor(usmallint_col), sum(usmallint_col)", + "sum(utinyint_col), floor(utinyint_col), sum(utinyint_col)", + "stddev(int_col), floor(int_col), stddev(int_col)", + "stddev(bigint_col), floor(bigint_col), stddev(bigint_col)", + "stddev(float_col), floor(float_col), stddev(float_col)", + "stddev(double_col), floor(double_col), stddev(double_col)", + "stddev(smallint_col), floor(smallint_col), stddev(smallint_col)", + "stddev(tinyint_col), floor(tinyint_col), stddev(tinyint_col)", + "stddev(uint_col), floor(uint_col), stddev(uint_col)", + "stddev(ubigint_col), floor(ubigint_col), stddev(ubigint_col)", + "stddev(usmallint_col), floor(usmallint_col), stddev(usmallint_col)", + "stddev(utinyint_col), floor(utinyint_col), stddev(utinyint_col)", + "irate(int_col), floor(int_col), irate(int_col)", + "irate(bigint_col), floor(bigint_col), irate(bigint_col)", + "irate(float_col), floor(float_col), irate(float_col)", + "irate(double_col), floor(double_col), irate(double_col)", + "irate(smallint_col), floor(smallint_col), irate(smallint_col)", + "irate(tinyint_col), floor(tinyint_col), irate(tinyint_col)", + "irate(uint_col), floor(uint_col), irate(uint_col)", + "irate(ubigint_col), floor(ubigint_col), irate(ubigint_col)", + "irate(usmallint_col), floor(usmallint_col), irate(usmallint_col)", + "irate(utinyint_col), floor(utinyint_col), irate(utinyint_col)", + "min(int_col), floor(int_col), min(int_col)", + "min(bigint_col), floor(bigint_col), min(bigint_col)", + "min(float_col), floor(float_col), min(float_col)", + "min(double_col), floor(double_col), min(double_col)", + "min(smallint_col), floor(smallint_col), min(smallint_col)", + "min(tinyint_col), floor(tinyint_col), min(tinyint_col)", + "min(uint_col), floor(uint_col), min(uint_col)", + "min(ubigint_col), floor(ubigint_col), min(ubigint_col)", + "min(usmallint_col), floor(usmallint_col), min(usmallint_col)", + "min(utinyint_col), floor(utinyint_col), min(utinyint_col)", + "max(int_col), floor(int_col), max(int_col)", + "max(bigint_col), floor(bigint_col), max(bigint_col)", + "max(float_col), floor(float_col), max(float_col)", + "max(double_col), floor(double_col), max(double_col)", + "max(smallint_col), floor(smallint_col), max(smallint_col)", + "max(tinyint_col), floor(tinyint_col), max(tinyint_col)", + "max(uint_col), floor(uint_col), max(uint_col)", + "max(ubigint_col), floor(ubigint_col), max(ubigint_col)", + "max(usmallint_col), floor(usmallint_col), max(usmallint_col)", + "max(utinyint_col), floor(utinyint_col), max(utinyint_col)", + "first(int_col), floor(int_col), first(int_col)", + "first(bigint_col), floor(bigint_col), first(bigint_col)", + "first(float_col), floor(float_col), first(float_col)", + "first(double_col), floor(double_col), first(double_col)", + "first(smallint_col), floor(smallint_col), first(smallint_col)", + "first(tinyint_col), floor(tinyint_col), first(tinyint_col)", + "first(uint_col), floor(uint_col), first(uint_col)", + "first(ubigint_col), floor(ubigint_col), first(ubigint_col)", + "first(usmallint_col), floor(usmallint_col), first(usmallint_col)", + "first(utinyint_col), floor(utinyint_col), first(utinyint_col)", + "last(int_col), floor(int_col), last(int_col)", + "last(bigint_col), floor(bigint_col), last(bigint_col)", + "last(float_col), floor(float_col), last(float_col)", + "last(double_col), floor(double_col), last(double_col)", + "last(smallint_col), floor(smallint_col), last(smallint_col)", + "last(tinyint_col), floor(tinyint_col), last(tinyint_col)", + "last(uint_col), floor(uint_col), last(uint_col)", + "last(ubigint_col), floor(ubigint_col), last(ubigint_col)", + "last(usmallint_col), floor(usmallint_col), last(usmallint_col)", + "last(utinyint_col), floor(utinyint_col), last(utinyint_col)", + "last_row(int_col), floor(int_col), last_row(int_col)", + "last_row(bigint_col), floor(bigint_col), last_row(bigint_col)", + "last_row(float_col), floor(float_col), last_row(float_col)", + "last_row(double_col), floor(double_col), last_row(double_col)", + "last_row(smallint_col), floor(smallint_col), last_row(smallint_col)", + "last_row(tinyint_col), floor(tinyint_col), last_row(tinyint_col)", + "last_row(uint_col), floor(uint_col), last_row(uint_col)", + "last_row(ubigint_col), floor(ubigint_col), last_row(ubigint_col)", + "last_row(usmallint_col), floor(usmallint_col), last_row(usmallint_col)", + "last_row(utinyint_col), floor(utinyint_col), last_row(utinyint_col)", + "interp(int_col), floor(int_col), interp(int_col)", + "interp(bigint_col), floor(bigint_col), interp(bigint_col)", + "interp(float_col), floor(float_col), interp(float_col)", + "interp(double_col), floor(double_col), interp(double_col)", + "interp(smallint_col), floor(smallint_col), interp(smallint_col)", + "interp(tinyint_col), floor(tinyint_col), interp(tinyint_col)", + "interp(uint_col), floor(uint_col), interp(uint_col)", + "interp(ubigint_col), floor(ubigint_col), interp(ubigint_col)", + "interp(usmallint_col), floor(usmallint_col), interp(usmallint_col)", + "interp(utinyint_col), floor(utinyint_col), interp(utinyint_col)", + "diff(int_col), floor(int_col), diff(int_col)", + "diff(bigint_col), floor(bigint_col), diff(bigint_col)", + "diff(float_col), floor(float_col), diff(float_col)", + "diff(double_col), floor(double_col), diff(double_col)", + "diff(smallint_col), floor(smallint_col), diff(smallint_col)", + "diff(tinyint_col), floor(tinyint_col), diff(tinyint_col)", + "diff(uint_col), floor(uint_col), diff(uint_col)", + "diff(ubigint_col), floor(ubigint_col), diff(ubigint_col)", + "diff(usmallint_col), floor(usmallint_col), diff(usmallint_col)", + "diff(utinyint_col), floor(utinyint_col), diff(utinyint_col)", + "spread(int_col), floor(int_col), spread(int_col)", + "spread(bigint_col), floor(bigint_col), spread(bigint_col)", + "spread(float_col), floor(float_col), spread(float_col)", + "spread(double_col), floor(double_col), spread(double_col)", + "spread(smallint_col), floor(smallint_col), spread(smallint_col)", + "spread(tinyint_col), floor(tinyint_col), spread(tinyint_col)", + "spread(uint_col), floor(uint_col), spread(uint_col)", + "spread(ubigint_col), floor(ubigint_col), spread(ubigint_col)", + "spread(usmallint_col), floor(usmallint_col), spread(usmallint_col)", + "spread(utinyint_col), floor(utinyint_col), spread(utinyint_col)", + "leastsquares(int_col, 1, 1), floor(int_col), leastsquares(int_col, 1, 1)", + "leastsquares(bigint_col, 1, 1), floor(bigint_col), leastsquares(bigint_col, 1, 1)", + "leastsquares(float_col, 1, 1), floor(float_col), leastsquares(float_col, 1, 1)", + "leastsquares(double_col, 1, 1), floor(double_col), leastsquares(double_col, 1, 1)", + "leastsquares(smallint_col, 1, 1), floor(smallint_col), leastsquares(smallint_col, 1, 1)", + "leastsquares(tinyint_col, 1, 1), floor(tinyint_col), leastsquares(tinyint_col, 1, 1)", + "leastsquares(uint_col, 1, 1), floor(uint_col), leastsquares(uint_col, 1, 1)", + "leastsquares(ubigint_col, 1, 1), floor(ubigint_col), leastsquares(ubigint_col, 1, 1)", + "leastsquares(usmallint_col, 1, 1), floor(usmallint_col), leastsquares(usmallint_col, 1, 1)", + "leastsquares(utinyint_col, 1, 1), floor(utinyint_col), leastsquares(utinyint_col, 1, 1)", + "top(int_col, 1), floor(int_col), top(int_col, 1)", + "top(bigint_col, 1), floor(bigint_col), top(bigint_col, 1)", + "top(float_col, 1), floor(float_col), top(float_col, 1)", + "top(double_col, 1), floor(double_col), top(double_col, 1)", + "top(smallint_col, 1), floor(smallint_col), top(smallint_col, 1)", + "top(tinyint_col, 1), floor(tinyint_col), top(tinyint_col, 1)", + "top(uint_col, 1), floor(uint_col), top(uint_col, 1)", + "top(ubigint_col, 1), floor(ubigint_col), top(ubigint_col, 1)", + "top(usmallint_col, 1), floor(usmallint_col), top(usmallint_col, 1)", + "top(utinyint_col, 1), floor(utinyint_col), top(utinyint_col, 1)", + "bottom(int_col, 1), floor(int_col), bottom(int_col, 1)", + "bottom(bigint_col, 1), floor(bigint_col), bottom(bigint_col, 1)", + "bottom(float_col, 1), floor(float_col), bottom(float_col, 1)", + "bottom(double_col, 1), floor(double_col), bottom(double_col, 1)", + "bottom(smallint_col, 1), floor(smallint_col), bottom(smallint_col, 1)", + "bottom(tinyint_col, 1), floor(tinyint_col), bottom(tinyint_col, 1)", + "bottom(uint_col, 1), floor(uint_col), bottom(uint_col, 1)", + "bottom(ubigint_col, 1), floor(ubigint_col), bottom(ubigint_col, 1)", + "bottom(usmallint_col, 1), floor(usmallint_col), bottom(usmallint_col, 1)", + "bottom(utinyint_col, 1), floor(utinyint_col), bottom(utinyint_col, 1)", + "percentile(int_col, 1), floor(int_col), percentile(int_col, 1)", + "percentile(bigint_col, 1), floor(bigint_col), percentile(bigint_col, 1)", + "percentile(float_col, 1), floor(float_col), percentile(float_col, 1)", + "percentile(double_col, 1), floor(double_col), percentile(double_col, 1)", + "percentile(smallint_col, 1), floor(smallint_col), percentile(smallint_col, 1)", + "percentile(tinyint_col, 1), floor(tinyint_col), percentile(tinyint_col, 1)", + "percentile(uint_col, 1), floor(uint_col), percentile(uint_col, 1)", + "percentile(ubigint_col, 1), floor(ubigint_col), percentile(ubigint_col, 1)", + "percentile(usmallint_col, 1), floor(usmallint_col), percentile(usmallint_col, 1)", + "percentile(utinyint_col, 1), floor(utinyint_col), percentile(utinyint_col, 1)", + "apercentile(int_col, 1), floor(int_col), apercentile(int_col, 1)", + "apercentile(bigint_col, 1), floor(bigint_col), apercentile(bigint_col, 1)", + "apercentile(float_col, 1), floor(float_col), apercentile(float_col, 1)", + "apercentile(double_col, 1), floor(double_col), apercentile(double_col, 1)", + "apercentile(smallint_col, 1), floor(smallint_col), apercentile(smallint_col, 1)", + "apercentile(tinyint_col, 1), floor(tinyint_col), apercentile(tinyint_col, 1)", + "apercentile(uint_col, 1), floor(uint_col), apercentile(uint_col, 1)", + "apercentile(ubigint_col, 1), floor(ubigint_col), apercentile(ubigint_col, 1)", + "apercentile(usmallint_col, 1), floor(usmallint_col), apercentile(usmallint_col, 1)", + "apercentile(utinyint_col, 1), floor(utinyint_col), apercentile(utinyint_col, 1)", + "derivative(int_col, 1s, 0), floor(int_col), derivative(int_col, 1s, 0)", + "derivative(bigint_col, 1s, 0), floor(bigint_col), derivative(bigint_col, 1s, 0)", + "derivative(float_col, 1s, 0), floor(float_col), derivative(float_col, 1s, 0)", + "derivative(double_col, 1s, 0), floor(double_col), derivative(double_col, 1s, 0)", + "derivative(smallint_col, 1s, 0), floor(smallint_col), derivative(smallint_col, 1s, 0)", + "derivative(tinyint_col, 1s, 0), floor(tinyint_col), derivative(tinyint_col, 1s, 0)", + "derivative(uint_col, 1s, 0), floor(uint_col), derivative(uint_col, 1s, 0)", + "derivative(ubigint_col, 1s, 0), floor(ubigint_col), derivative(ubigint_col, 1s, 0)", + "derivative(usmallint_col, 1s, 0), floor(usmallint_col), derivative(usmallint_col, 1s, 0)", + "derivative(utinyint_col, 1s, 0), floor(utinyint_col), derivative(utinyint_col, 1s, 0)", + "1, floor(int_col), 1", + "1, floor(bigint_col), 1", + "1, floor(float_col), 1", + "1, floor(double_col), 1", + "1, floor(smallint_col), 1", + "1, floor(tinyint_col), 1", + "1, floor(uint_col), 1", + "1, floor(ubigint_col), 1", + "1, floor(usmallint_col), 1", + "1, floor(utinyint_col), 1", + "floor(int_col) as anyName", + "floor(bigint_col) as anyName", + "floor(float_col) as anyName", + "floor(double_col) as anyName", + "floor(smallint_col) as anyName", + "floor(tinyint_col) as anyName", + "floor(uint_col) as anyName", + "floor(ubigint_col) as anyName", + "floor(usmallint_col) as anyName", + "floor(utinyint_col) as anyName", + "distinct floor(int_col)", + "distinct floor(bigint_col)", + "distinct floor(float_col)", + "distinct floor(double_col)", + "distinct floor(smallint_col)", + "distinct floor(tinyint_col)", + "distinct floor(uint_col)", + "distinct floor(ubigint_col)", + "distinct floor(usmallint_col)", + "distinct floor(utinyint_col)", + ] + simple_select_command = [ + "floor(super.int_col)", + "floor(super.bigint_col)", + "floor(super.float_col)", + "floor(super.double_col)", + "floor(super.smallint_col)", + "floor(super.tinyint_col)", + "floor(super.uint_col)", + "floor(super.ubigint_col)", + "floor(super.usmallint_col)", + "floor(super.utinyint_col)", + "floor(t1.int_col)", + "floor(t1.bigint_col)", + "floor(t1.float_col)", + "floor(t1.double_col)", + "floor(t1.smallint_col)", + "floor(t1.tinyint_col)", + "floor(t1.uint_col)", + "floor(t1.ubigint_col)", + "floor(t1.usmallint_col)", + "floor(t1.utinyint_col)", + ] + from_command = [" from super", " from t1"] + advance_from_command = [ + " from super", " from t1", + " from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag" + ] + filter_command = [ + "", " session(ts, 1s)", " state_window(int_col)", " interval (1s)", + " interval (1s) sliding (1s)", " group by (ts)" + ] + fill_command = [ + "", " fill(prev)", " fill(next)", " fill(null)", " fill(1)", + " fill(linear)" + ] + tdSql.prepare() + tdSql.execute( + "create stable super (ts timestamp, timestamp_col timestamp, int_col int, bigint_col bigint, float_col float,\ + double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ + uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ + float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + ) + tdSql.execute( + "create stable superb (ts timestamp, timestamp_col timestamp, int_col int, bigint_col bigint, float_col float,\ + double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ + uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ + float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + ) + tdSql.execute( + "create table t1 using super tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomBigint(), self.randomDouble(), self.randomDouble(), + self.randomNchar(), self.randomSmallint(), self.randomTinyint(), + self.randomNchar(), self.randomUInt(), self.randomUBigint(), + self.randomUSmallint(), self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215892, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215893, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215894, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "create table t2 using superb tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomBigint(), self.randomDouble(), self.randomDouble(), + self.randomNchar(), self.randomSmallint(), self.randomTinyint(), + self.randomNchar(), self.randomUInt(), self.randomUBigint(), + self.randomUSmallint(), self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215892, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215893, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215894, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + + for s in range(len(select_command)): + for f in range(len(from_command)): + sql = "select " + select_command[s] + from_command[f] + if (select_command[s] == "floor(int_col)"\ + or select_command[s] == "floor(bigint_col)"\ + or select_command[s] == "floor(smallint_col)" \ + or select_command[s] == "floor(float_col)"\ + or select_command[s] == "floor(double_col)"\ + or select_command[s] == "floor(tinyint_col)"\ + or select_command[s] == "floor(uint_col)"\ + or select_command[s] == "floor(ubigint_col)"\ + or select_command[s] == "floor(usmallint_col)"\ + or select_command[s] == "floor(utinyint_col)"\ + or select_command[s] == "1, floor(int_col), 1"\ + or select_command[s] == "1, floor(bigint_col), 1"\ + or select_command[s] == "1, floor(float_col), 1"\ + or select_command[s] == "1, floor(double_col), 1"\ + or select_command[s] == "1, floor(smallint_col), 1"\ + or select_command[s] == "1, floor(tinyint_col), 1"\ + or select_command[s] == "1, floor(uint_col), 1"\ + or select_command[s] == "1, floor(ubigint_col), 1"\ + or select_command[s] == "1, floor(usmallint_col), 1"\ + or select_command[s] == "1, floor(utinyint_col), 1"\ + or select_command[s] == "int_col, floor(int_col), int_col"\ + or select_command[s] == "bigint_col, floor(bigint_col), bigint_col"\ + or select_command[s] == "float_col, floor(float_col), float_col"\ + or select_command[s] == "double_col, floor(double_col), double_col"\ + or select_command[s] == "smallint_col, floor(smallint_col), smallint_col"\ + or select_command[s] == "tinyint_col, floor(tinyint_col), tinyint_col"\ + or select_command[s] == "uint_col, floor(uint_col), uint_col"\ + or select_command[s] == "ubigint_col, floor(ubigint_col), ubigint_col"\ + or select_command[s] == "usmallint_col, floor(usmallint_col), usmallint_col"\ + or select_command[s] == "utinyint_col, floor(utinyint_col), utinyint_col"\ + or select_command[s] == "floor(int_col) as anyName"\ + or select_command[s] == "floor(bigint_col) as anyName"\ + or select_command[s] == "floor(float_col) as anyName"\ + or select_command[s] == "floor(double_col) as anyName"\ + or select_command[s] == "floor(smallint_col) as anyName"\ + or select_command[s] == "floor(tinyint_col) as anyName"\ + or select_command[s] == "floor(uint_col) as anyName"\ + or select_command[s] == "floor(ubigint_col) as anyName"\ + or select_command[s] == "floor(usmallint_col) as anyName"\ + or select_command[s] == "floor(utinyint_col) as anyName"\ + or select_command[s] == "floor(int_col) + floor(int_col)"\ + or select_command[s] == "floor(bigint_col) + floor(bigint_col)"\ + or select_command[s] == "floor(float_col) + floor(float_col)"\ + or select_command[s] == "floor(double_col) + floor(double_col)"\ + or select_command[s] == "floor(smallint_col) + floor(smallint_col)"\ + or select_command[s] == "floor(tinyint_col) + floor(tinyint_col)"\ + or select_command[s] == "floor(uint_col) + floor(uint_col)"\ + or select_command[s] == "floor(ubigint_col) + floor(ubigint_col)"\ + or select_command[s] == "floor(usmallint_col) + floor(usmallint_col)"\ + or select_command[s] == "floor(utinyint_col) + floor(utinyint_col)"\ + or select_command[s] == "floor(int_col) + floor(int_col)"\ + or select_command[s] == "floor(bigint_col) + floor(bigint_col)"\ + or select_command[s] == "floor(float_col) + floor(float_col)"\ + or select_command[s] == "floor(double_col) + floor(double_col)"\ + or select_command[s] == "floor(smallint_col) + floor(smallint_col)"\ + or select_command[s] == "floor(tinyint_col) + floor(tinyint_col)"\ + or select_command[s] == "floor(uint_col) + floor(uint_col)"\ + or select_command[s] == "floor(ubigint_col) + floor(ubigint_col)"\ + or select_command[s] == "floor(usmallint_col) + floor(usmallint_col)"\ + or select_command[s] == "floor(utinyint_col) + cei(utinyint_col)"\ + or select_command[s] == "floor(int_col) - floor(int_col)"\ + or select_command[s] == "floor(bigint_col) - floor(bigint_col)"\ + or select_command[s] == "floor(float_col) - floor(float_col)"\ + or select_command[s] == "floor(double_col) - floor(double_col)"\ + or select_command[s] == "floor(smallint_col) - floor(smallint_col)"\ + or select_command[s] == "floor(tinyint_col) - floor(tinyint_col)"\ + or select_command[s] == "floor(uint_col) - floor(uint_col)"\ + or select_command[s] == "floor(ubigint_col) - floor(ubigint_col)"\ + or select_command[s] == "floor(usmallint_col) - floor(usmallint_col)"\ + or select_command[s] == "floor(utinyint_col) - floor(utinyint_col)"\ + or select_command[s] == "floor(int_col) * floor(int_col)"\ + or select_command[s] == "floor(bigint_col) * floor(bigint_col)"\ + or select_command[s] == "floor(float_col) * floor(float_col)"\ + or select_command[s] == "floor(double_col) * floor(double_col)"\ + or select_command[s] == "floor(smallint_col) * floor(smallint_col)"\ + or select_command[s] == "floor(tinyint_col) * floor(tinyint_col)"\ + or select_command[s] == "floor(uint_col) * floor(uint_col)"\ + or select_command[s] == "floor(ubigint_col) * floor(ubigint_col)"\ + or select_command[s] == "floor(usmallint_col) * floor(usmallint_col)"\ + or select_command[s] == "floor(utinyint_col) * floor(utinyint_col)"\ + or select_command[s] == "floor(int_col) / floor(int_col)"\ + or select_command[s] == "floor(bigint_col) / floor(bigint_col)"\ + or select_command[s] == "floor(float_col) / floor(float_col)"\ + or select_command[s] == "floor(double_col) / floor(double_col)"\ + or select_command[s] == "floor(smallint_col) / floor(smallint_col)"\ + or select_command[s] == "floor(tinyint_col) / floor(tinyint_col)"\ + or select_command[s] == "floor(uint_col) / floor(uint_col)"\ + or select_command[s] == "floor(ubigint_col) / floor(ubigint_col)"\ + or select_command[s] == "floor(usmallint_col) / floor(usmallint_col)"\ + or select_command[s] == "floor(utinyint_col) / floor(utinyint_col)"): + tdSql.query(sql) + else: + tdSql.error(sql) + for sim in range(len(simple_select_command)): + for fr in range(len(advance_from_command)): + for filter in range(len(filter_command)): + for fill in range(len(fill_command)): + sql = "select " + simple_select_command[ + sim] + advance_from_command[fr] + filter_command[ + filter] + fill_command[fill] + if sql == "select floor(t1.int_col) from t1"\ + or sql == "select floor(super.int_col) from super"\ + or sql == "select floor(t1.bigint_col) from t1"\ + or sql == "select floor(super.bigint_col) from super"\ + or sql == "select floor(t1.smallint_col) from t1"\ + or sql == "select floor(super.smallint_col) from super"\ + or sql == "select floor(t1.tinyint_col) from t1"\ + or sql == "select floor(super.tinyint_col) from super"\ + or sql == "select floor(t1.float_col) from t1"\ + or sql == "select floor(super.float_col) from super"\ + or sql == "select floor(t1.double_col) from t1"\ + or sql == "select floor(super.double_col) from super"\ + or sql == "select floor(t1.uint_col) from t1"\ + or sql == "select floor(super.uint_col) from super"\ + or sql == "select floor(t1.ubigint_col) from t1"\ + or sql == "select floor(super.ubigint_col) from super"\ + or sql == "select floor(t1.usmallint_col) from t1"\ + or sql == "select floor(super.usmallint_col) from super"\ + or sql == "select floor(t1.utinyint_col) from t1"\ + or sql == "select floor(super.utinyint_col) from super"\ + or sql == "select floor(super.int_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select floor(super.bigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select floor(super.smallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select floor(super.tinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select floor(super.float_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select floor(super.double_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select floor(super.uint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select floor(super.ubigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select floor(super.usmallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select floor(super.utinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag": + tdSql.query(sql) + else: + tdSql.error(sql) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/function_round.py b/tests/pytest/functions/function_round.py new file mode 100644 index 0000000000000000000000000000000000000000..93cace49ad8d16c6491584ed530b3dff07ef6fe4 --- /dev/null +++ b/tests/pytest/functions/function_round.py @@ -0,0 +1,1518 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def randomInt(self): + return random.randint(-2147483647, 2147483647) + + def randomUInt(self): + return random.randint(0, 4294967294) + + def randomBigint(self): + return random.randint(-2**63 + 1, 2**63 - 1) + + def randomUBigint(self): + return random.randint(0, 18446744073709551614) + + def randomDouble(self): + return random.random() + + def randomNchar(self): + return random.choice('abcdefghijklmnopqrstuvwxyz') + + def randomSmallint(self): + return random.randint(-32767, 32767) + + def randomUSmallint(self): + return random.randint(0, 65534) + + def randomTinyint(self): + return random.randint(-127, 127) + + def randomUTinyint(self): + return random.randint(0, 254) + + def run(self): + select_command = [ + "round(ts)", + "round(timestamp_col)", + "round(int_col)", + "round(bigint_col)", + "round(float_col)", + "round(double_col)", + "round(binary_col)", + "round(smallint_col)", + "round(tinyint_col)", + "round(bool_col)", + "round(nchar_col)", + "round(uint_col)", + "round(ubigint_col)", + "round(usmallint_col)", + "round(utinyint_col)", + "round(timestamp_tag)", + "round(int_tag)", + "round(bigint_tag)", + "round(float_tag)", + "round(double_tag)", + "round(binary_tag)", + "round(smallint_tag)", + "round(tinyint_tag)", + "round(bool_tag)", + "round(nchar_tag)", + "round(uint_tag)", + "round(ubigint_tag)", + "round(usmallint_tag)", + "round(utinyint_tag)", + "count(round(int_col))", + "count(round(bigint_col))", + "count(round(float_col))", + "count(round(double_col))", + "count(round(smallint_col))", + "count(round(tinyint_col))", + "count(round(uint_col))", + "count(round(ubigint_col))", + "count(round(usmallint_col))", + "count(round(utinyint_col))", + "avg(round(int_col))", + "avg(round(bigint_col))", + "avg(round(float_col))", + "avg(round(double_col))", + "avg(round(smallint_col))", + "avg(round(tinyint_col))", + "avg(round(uint_col))", + "avg(round(ubigint_col))", + "avg(round(usmallint_col))", + "avg(round(utinyint_col))", + "twa(round(int_col))", + "twa(round(bigint_col))", + "twa(round(float_col))", + "twa(round(double_col))", + "twa(round(smallint_col))", + "twa(round(tinyint_col))", + "twa(round(uint_col))", + "twa(round(ubigint_col))", + "twa(round(usmallint_col))", + "twa(round(utinyint_col))", + "sum(round(int_col))", + "sum(round(bigint_col))", + "sum(round(float_col))", + "sum(round(double_col))", + "sum(round(smallint_col))", + "sum(round(tinyint_col))", + "sum(round(uint_col))", + "sum(round(ubigint_col))", + "sum(round(usmallint_col))", + "sum(round(utinyint_col))", + "stddev(round(int_col))", + "stddev(round(bigint_col))", + "stddev(round(float_col))", + "stddev(round(double_col))", + "stddev(round(smallint_col))", + "stddev(round(tinyint_col))", + "stddev(round(uint_col))", + "stddev(round(ubigint_col))", + "stddev(round(usmallint_col))", + "stddev(round(utinyint_col))", + "irate(round(int_col))", + "irate(round(bigint_col))", + "irate(round(float_col))", + "irate(round(double_col))", + "irate(round(smallint_col))", + "irate(round(tinyint_col))", + "irate(round(uint_col))", + "irate(round(ubigint_col))", + "irate(round(usmallint_col))", + "irate(round(utinyint_col))", + "leastsquares(round(int_col), 1, 1)", + "leastsquares(round(bigint_col), 1, 1)", + "leastsquares(round(float_col), 1, 1)", + "leastsquares(round(double_col), 1, 1)", + "leastsquares(round(smallint_col), 1, 1)", + "leastsquares(round(tinyint_col), 1, 1)", + "leastsquares(round(uint_col), 1, 1)", + "leastsquares(round(ubigint_col), 1, 1)", + "leastsquares(round(usmallint_col), 1, 1)", + "leastsquares(round(utinyint_col), 1, 1)", + "min(round(int_col))", + "min(round(bigint_col))", + "min(round(float_col))", + "min(round(double_col))", + "min(round(smallint_col))", + "min(round(tinyint_col))", + "min(round(uint_col))", + "min(round(ubigint_col))", + "min(round(usmallint_col))", + "min(round(utinyint_col))", + "max(round(int_col))", + "max(round(bigint_col))", + "max(round(float_col))", + "max(round(double_col))", + "max(round(smallint_col))", + "max(round(tinyint_col))", + "max(round(uint_col))", + "max(round(ubigint_col))", + "max(round(usmallint_col))", + "max(round(utinyint_col))", + "first(round(int_col))", + "first(round(bigint_col))", + "first(round(float_col))", + "first(round(double_col))", + "first(round(smallint_col))", + "first(round(tinyint_col))", + "first(round(uint_col))", + "first(round(ubigint_col))", + "first(round(usmallint_col))", + "first(round(utinyint_col))", + "last(round(int_col))", + "last(round(bigint_col))", + "last(round(float_col))", + "last(round(double_col))", + "last(round(smallint_col))", + "last(round(tinyint_col))", + "last(round(uint_col))", + "last(round(ubigint_col))", + "last(round(usmallint_col))", + "last(round(utinyint_col))", + "top(round(int_col), 1)", + "top(round(bigint_col), 1)", + "top(round(float_col), 1)", + "top(round(double_col), 1)", + "top(round(smallint_col), 1)", + "top(round(tinyint_col), 1)", + "top(round(uint_col), 1)", + "top(round(ubigint_col), 1)", + "top(round(usmallint_col), 1)", + "top(round(utinyint_col), 1)", + "bottom(round(int_col), 1)", + "bottom(round(bigint_col), 1)", + "bottom(round(float_col), 1)", + "bottom(round(double_col), 1)", + "bottom(round(smallint_col), 1)", + "bottom(round(tinyint_col), 1)", + "bottom(round(uint_col), 1)", + "bottom(round(ubigint_col), 1)", + "bottom(round(usmallint_col), 1)", + "bottom(round(utinyint_col), 1)", + "percentile(round(int_col), 20)", + "percentile(round(bigint_col), 20)", + "percentile(round(float_col), 20)", + "percentile(round(double_col), 20)", + "percentile(round(smallint_col), 20)", + "percentile(round(tinyint_col), 20)", + "percentile(round(uint_col), 20)", + "percentile(round(ubigint_col), 20)", + "percentile(round(usmallint_col), 20)", + "percentile(round(utinyint_col), 20)", + "apercentile(round(int_col), 20)", + "apercentile(round(bigint_col), 20)", + "apercentile(round(float_col), 20)", + "apercentile(round(double_col), 20)", + "apercentile(round(smallint_col), 20)", + "apercentile(round(tinyint_col), 20)", + "apercentile(round(uint_col), 20)", + "apercentile(round(ubigint_col), 20)", + "apercentile(round(usmallint_col), 20)", + "apercentile(round(utinyint_col), 20)", + "last_row(round(int_col))", + "last_row(round(bigint_col))", + "last_row(round(float_col))", + "last_row(round(double_col))", + "last_row(round(smallint_col))", + "last_row(round(tinyint_col))", + "last_row(round(uint_col))", + "last_row(round(ubigint_col))", + "last_row(round(usmallint_col))", + "last_row(round(utinyint_col))", + "interp(round(int_col))", + "interp(round(bigint_col))", + "interp(round(float_col))", + "interp(round(double_col))", + "interp(round(smallint_col))", + "interp(round(tinyint_col))", + "interp(round(uint_col))", + "interp(round(ubigint_col))", + "interp(round(usmallint_col))", + "interp(round(utinyint_col))", + "diff(round(int_col))", + "diff(round(bigint_col))", + "diff(round(float_col))", + "diff(round(double_col))", + "diff(round(smallint_col))", + "diff(round(tinyint_col))", + "diff(round(uint_col))", + "diff(round(ubigint_col))", + "diff(round(usmallint_col))", + "diff(round(utinyint_col))", + "spread(round(int_col))", + "spread(round(bigint_col))", + "spread(round(float_col))", + "spread(round(double_col))", + "spread(round(smallint_col))", + "spread(round(tinyint_col))", + "spread(round(uint_col))", + "spread(round(ubigint_col))", + "spread(round(usmallint_col))", + "spread(round(utinyint_col))", + "derivative(round(int_col), 1s, 0)", + "derivative(round(bigint_col), 1s, 0)", + "derivative(round(float_col), 1s, 0)", + "derivative(round(double_col), 1s, 0)", + "derivative(round(smallint_col), 1s, 0)", + "derivative(round(tinyint_col), 1s, 0)", + "derivative(round(uint_col), 1s, 0)", + "derivative(round(ubigint_col), 1s, 0)", + "derivative(round(usmallint_col), 1s, 0)", + "derivative(round(utinyint_col), 1s, 0)", + "round(int_col) - round(int_col)", + "round(bigint_col) - round(bigint_col)", + "round(float_col) - round(float_col)", + "round(double_col) - round(double_col)", + "round(smallint_col) - round(smallint_col)", + "round(tinyint_col) - round(tinyint_col)", + "round(uint_col) - round(uint_col)", + "round(ubigint_col) - round(ubigint_col)", + "round(usmallint_col) - round(usmallint_col)", + "round(utinyint_col) - round(utinyint_col)", + "round(int_col) / round(int_col)", + "round(bigint_col) / round(bigint_col)", + "round(float_col) / round(float_col)", + "round(double_col) / round(double_col)", + "round(smallint_col) / round(smallint_col)", + "round(tinyint_col) / round(tinyint_col)", + "round(uint_col) / round(uint_col)", + "round(ubigint_col) / round(ubigint_col)", + "round(usmallint_col) / round(usmallint_col)", + "round(utinyint_col) / round(utinyint_col)", + "round(int_col) * round(int_col)", + "round(bigint_col) * round(bigint_col)", + "round(float_col) * round(float_col)", + "round(double_col) * round(double_col)", + "round(smallint_col) * round(smallint_col)", + "round(tinyint_col) * round(tinyint_col)", + "round(uint_col) * round(uint_col)", + "round(ubigint_col) * round(ubigint_col)", + "round(usmallint_col) * round(usmallint_col)", + "round(utinyint_col) * round(utinyint_col)", + "round(count(ts))", + "round(count(timestamp_col))", + "round(count(int_col))", + "round(count(bigint_col))", + "round(count(float_col))", + "round(count(double_col))", + "round(count(binary_col))", + "round(count(smallint_col))", + "round(count(tinyint_col))", + "round(count(bool_col))", + "round(count(nchar_col))", + "round(count(uint_col))", + "round(count(ubigint_col))", + "round(count(usmallint_col))", + "round(count(utinyint_col))", + "round(count(timestamp_tag))", + "round(count(int_tag))", + "round(count(bigint_tag))", + "round(count(float_tag))", + "round(count(double_tag))", + "round(count(binary_tag))", + "round(count(smallint_tag))", + "round(count(tinyint_tag))", + "round(count(bool_tag))", + "round(count(nchar_tag))", + "round(count(uint_tag))", + "round(count(ubigint_tag))", + "round(count(usmallint_tag))", + "round(count(utinyint_tag))", + "round(avg(ts))", + "round(avg(timestamp_col))", + "round(avg(int_col))", + "round(avg(bigint_col))", + "round(avg(float_col))", + "round(avg(double_col))", + "round(avg(binary_col))", + "round(avg(smallint_col))", + "round(avg(tinyint_col))", + "round(avg(bool_col))", + "round(avg(nchar_col))", + "round(avg(uint_col))", + "round(avg(ubigint_col))", + "round(avg(usmallint_col))", + "round(avg(utinyint_col))", + "round(avg(timestamp_tag))", + "round(avg(int_tag))", + "round(avg(bigint_tag))", + "round(avg(float_tag))", + "round(avg(double_tag))", + "round(avg(binary_tag))", + "round(avg(smallint_tag))", + "round(avg(tinyint_tag))", + "round(avg(bool_tag))", + "round(avg(nchar_tag))", + "round(avg(uint_tag))", + "round(avg(ubigint_tag))", + "round(avg(usmallint_tag))", + "round(avg(utinyint_tag))", + "round(twa(ts))", + "round(twa(timestamp_col))", + "round(twa(int_col))", + "round(twa(bigint_col))", + "round(twa(float_col))", + "round(twa(double_col))", + "round(twa(binary_col))", + "round(twa(smallint_col))", + "round(twa(tinyint_col))", + "round(twa(bool_col))", + "round(twa(nchar_col))", + "round(twa(uint_col))", + "round(twa(ubigint_col))", + "round(twa(usmallint_col))", + "round(twa(utinyint_col))", + "round(twa(timestamp_tag))", + "round(twa(int_tag))", + "round(twa(bigint_tag))", + "round(twa(float_tag))", + "round(twa(double_tag))", + "round(twa(binary_tag))", + "round(twa(smallint_tag))", + "round(twa(tinyint_tag))", + "round(twa(bool_tag))", + "round(twa(nchar_tag))", + "round(twa(uint_tag))", + "round(twa(ubigint_tag))", + "round(twa(usmallint_tag))", + "round(twa(utinyint_tag))", + "round(sum(ts))", + "round(sum(timestamp_col))", + "round(sum(int_col))", + "round(sum(bigint_col))", + "round(sum(float_col))", + "round(sum(double_col))", + "round(sum(binary_col))", + "round(sum(smallint_col))", + "round(sum(tinyint_col))", + "round(sum(bool_col))", + "round(sum(nchar_col))", + "round(sum(uint_col))", + "round(sum(ubigint_col))", + "round(sum(usmallint_col))", + "round(sum(utinyint_col))", + "round(sum(timestamp_tag))", + "round(sum(int_tag))", + "round(sum(bigint_tag))", + "round(sum(float_tag))", + "round(sum(double_tag))", + "round(sum(binary_tag))", + "round(sum(smallint_tag))", + "round(sum(tinyint_tag))", + "round(sum(bool_tag))", + "round(sum(nchar_tag))", + "round(sum(uint_tag))", + "round(sum(ubigint_tag))", + "round(sum(usmallint_tag))", + "round(sum(utinyint_tag))", + "round(stddev(ts))", + "round(stddev(timestamp_col))", + "round(stddev(int_col))", + "round(stddev(bigint_col))", + "round(stddev(float_col))", + "round(stddev(double_col))", + "round(stddev(binary_col))", + "round(stddev(smallint_col))", + "round(stddev(tinyint_col))", + "round(stddev(bool_col))", + "round(stddev(nchar_col))", + "round(stddev(uint_col))", + "round(stddev(ubigint_col))", + "round(stddev(usmallint_col))", + "round(stddev(utinyint_col))", + "round(stddev(timestamp_tag))", + "round(stddev(int_tag))", + "round(stddev(bigint_tag))", + "round(stddev(float_tag))", + "round(stddev(double_tag))", + "round(stddev(binary_tag))", + "round(stddev(smallint_tag))", + "round(stddev(tinyint_tag))", + "round(stddev(bool_tag))", + "round(stddev(nchar_tag))", + "round(stddev(uint_tag))", + "round(stddev(ubigint_tag))", + "round(stddev(usmallint_tag))", + "round(stddev(utinyint_tag))", + "round(leastsquares(ts, 1, 1))", + "round(leastsquares(timestamp_col, 1, 1))", + "round(leastsquares(int_col, 1, 1))", + "round(leastsquares(bigint_col, 1, 1))", + "round(leastsquares(float_col, 1, 1))", + "round(leastsquares(double_col, 1, 1))", + "round(leastsquares(binary_col, 1, 1))", + "round(leastsquares(smallint_col, 1, 1))", + "round(leastsquares(tinyint_col, 1, 1))", + "round(leastsquares(bool_col, 1, 1))", + "round(leastsquares(nchar_col, 1, 1))", + "round(leastsquares(uint_col, 1, 1))", + "round(leastsquares(ubigint_col, 1, 1))", + "round(leastsquares(usmallint_col, 1, 1))", + "round(leastsquares(utinyint_col, 1, 1))", + "round(leastsquares(timestamp_tag, 1, 1))", + "round(leastsquares(int_tag, 1, 1))", + "round(leastsquares(bigint_tag, 1, 1))", + "round(leastsquares(float_tag, 1, 1))", + "round(leastsquares(double_tag, 1, 1))", + "round(leastsquares(binary_tag, 1, 1))", + "round(leastsquares(smallint_tag, 1, 1))", + "round(leastsquares(tinyint_tag, 1, 1))", + "round(leastsquares(bool_tag, 1, 1))", + "round(leastsquares(nchar_tag, 1, 1))", + "round(leastsquares(uint_tag, 1, 1))", + "round(leastsquares(ubigint_tag, 1, 1))", + "round(leastsquares(usmallint_tag, 1, 1))", + "round(leastsquares(utinyint_tag, 1, 1))", + "round(irate(ts))", + "round(irate(timestamp_col))", + "round(irate(int_col))", + "round(irate(bigint_col))", + "round(irate(float_col))", + "round(irate(double_col))", + "round(irate(binary_col))", + "round(irate(smallint_col))", + "round(irate(tinyint_col))", + "round(irate(bool_col))", + "round(irate(nchar_col))", + "round(irate(uint_col))", + "round(irate(ubigint_col))", + "round(irate(usmallint_col))", + "round(irate(utinyint_col))", + "round(irate(timestamp_tag))", + "round(irate(int_tag))", + "round(irate(bigint_tag))", + "round(irate(float_tag))", + "round(irate(double_tag))", + "round(irate(binary_tag))", + "round(irate(smallint_tag))", + "round(irate(tinyint_tag))", + "round(irate(bool_tag))", + "round(irate(nchar_tag))", + "round(irate(uint_tag))", + "round(irate(ubigint_tag))", + "round(irate(usmallint_tag))", + "round(irate(utinyint_tag))", + "round(min(ts))", + "round(min(timestamp_col))", + "round(min(int_col))", + "round(min(bigint_col))", + "round(min(float_col))", + "round(min(double_col))", + "round(min(binary_col))", + "round(min(smallint_col))", + "round(min(tinyint_col))", + "round(min(bool_col))", + "round(min(nchar_col))", + "round(min(uint_col))", + "round(min(ubigint_col))", + "round(min(usmallint_col))", + "round(min(utinyint_col))", + "round(min(timestamp_tag))", + "round(min(int_tag))", + "round(min(bigint_tag))", + "round(min(float_tag))", + "round(min(double_tag))", + "round(min(binary_tag))", + "round(min(smallint_tag))", + "round(min(tinyint_tag))", + "round(min(bool_tag))", + "round(min(nchar_tag))", + "round(min(uint_tag))", + "round(min(ubigint_tag))", + "round(min(usmallint_tag))", + "round(min(utinyint_tag))", + "round(max(ts))", + "round(max(timestamp_col))", + "round(max(int_col))", + "round(max(bigint_col))", + "round(max(float_col))", + "round(max(double_col))", + "round(max(binary_col))", + "round(max(smallint_col))", + "round(max(tinyint_col))", + "round(max(bool_col))", + "round(max(nchar_col))", + "round(max(uint_col))", + "round(max(ubigint_col))", + "round(max(usmallint_col))", + "round(max(utinyint_col))", + "round(max(timestamp_tag))", + "round(max(int_tag))", + "round(max(bigint_tag))", + "round(max(float_tag))", + "round(max(double_tag))", + "round(max(binary_tag))", + "round(max(smallint_tag))", + "round(max(tinyint_tag))", + "round(max(bool_tag))", + "round(max(nchar_tag))", + "round(max(uint_tag))", + "round(max(ubigint_tag))", + "round(max(usmallint_tag))", + "round(max(utinyint_tag))", + "round(first(ts))", + "round(first(timestamp_col))", + "round(first(int_col))", + "round(first(bigint_col))", + "round(first(float_col))", + "round(first(double_col))", + "round(first(binary_col))", + "round(first(smallint_col))", + "round(first(tinyint_col))", + "round(first(bool_col))", + "round(first(nchar_col))", + "round(first(uint_col))", + "round(first(ubigint_col))", + "round(first(usmallint_col))", + "round(first(utinyint_col))", + "round(first(timestamp_tag))", + "round(first(int_tag))", + "round(first(bigint_tag))", + "round(first(float_tag))", + "round(first(double_tag))", + "round(first(binary_tag))", + "round(first(smallint_tag))", + "round(first(tinyint_tag))", + "round(first(bool_tag))", + "round(first(nchar_tag))", + "round(first(uint_tag))", + "round(first(ubigint_tag))", + "round(first(usmallint_tag))", + "round(first(utinyint_tag))", + "round(last(ts))", + "round(last(timestamp_col))", + "round(last(int_col))", + "round(last(bigint_col))", + "round(last(float_col))", + "round(last(double_col))", + "round(last(binary_col))", + "round(last(smallint_col))", + "round(last(tinyint_col))", + "round(last(bool_col))", + "round(last(nchar_col))", + "round(last(uint_col))", + "round(last(ubigint_col))", + "round(last(usmallint_col))", + "round(last(utinyint_col))", + "round(last(timestamp_tag))", + "round(last(int_tag))", + "round(last(bigint_tag))", + "round(last(float_tag))", + "round(last(double_tag))", + "round(last(binary_tag))", + "round(last(smallint_tag))", + "round(last(tinyint_tag))", + "round(last(bool_tag))", + "round(last(nchar_tag))", + "round(last(uint_tag))", + "round(last(ubigint_tag))", + "round(last(usmallint_tag))", + "round(last(utinyint_tag))", + "round(top(ts, 1))", + "round(top(timestamp_col, 1))", + "round(top(int_col, 1))", + "round(top(bigint_col, 1))", + "round(top(float_col, 1))", + "round(top(double_col, 1))", + "round(top(binary_col, 1))", + "round(top(smallint_col, 1))", + "round(top(tinyint_col, 1))", + "round(top(bool_col, 1))", + "round(top(nchar_col, 1))", + "round(top(uint_col, 1))", + "round(top(ubigint_col, 1))", + "round(top(usmallint_col, 1))", + "round(top(utinyint_col, 1))", + "round(top(timestamp_tag, 1))", + "round(top(int_tag, 1))", + "round(top(bigint_tag, 1))", + "round(top(float_tag, 1))", + "round(top(double_tag, 1))", + "round(top(binary_tag, 1))", + "round(top(smallint_tag, 1))", + "round(top(tinyint_tag, 1))", + "round(top(bool_tag, 1))", + "round(top(nchar_tag, 1))", + "round(top(uint_tag, 1))", + "round(top(ubigint_tag, 1))", + "round(top(usmallint_tag, 1))", + "round(top(utinyint_tag, 1))", + "round(bottom(ts, 1))", + "round(bottom(timestamp_col, 1))", + "round(bottom(int_col, 1))", + "round(bottom(bigint_col, 1))", + "round(bottom(float_col, 1))", + "round(bottom(double_col, 1))", + "round(bottom(binary_col, 1))", + "round(bottom(smallint_col, 1))", + "round(bottom(tinyint_col, 1))", + "round(bottom(bool_col, 1))", + "round(bottom(nchar_col, 1))", + "round(bottom(uint_col, 1))", + "round(bottom(ubigint_col, 1))", + "round(bottom(usmallint_col, 1))", + "round(bottom(utinyint_col, 1))", + "round(bottom(timestamp_tag, 1))", + "round(bottom(int_tag, 1))", + "round(bottom(bigint_tag, 1))", + "round(bottom(float_tag, 1))", + "round(bottom(double_tag, 1))", + "round(bottom(binary_tag, 1))", + "round(bottom(smallint_tag, 1))", + "round(bottom(tinyint_tag, 1))", + "round(bottom(bool_tag, 1))", + "round(bottom(nchar_tag, 1))", + "round(bottom(uint_tag, 1))", + "round(bottom(ubigint_tag, 1))", + "round(bottom(usmallint_tag, 1))", + "round(bottom(utinyint_tag, 1))", + "round(percentile(ts, 1))", + "round(percentile(timestamp_col, 1))", + "round(percentile(int_col, 1))", + "round(percentile(bigint_col, 1))", + "round(percentile(float_col, 1))", + "round(percentile(double_col, 1))", + "round(percentile(binary_col, 1))", + "round(percentile(smallint_col, 1))", + "round(percentile(tinyint_col, 1))", + "round(percentile(bool_col, 1))", + "round(percentile(nchar_col, 1))", + "round(percentile(uint_col, 1))", + "round(percentile(ubigint_col, 1))", + "round(percentile(usmallint_col, 1))", + "round(percentile(utinyint_col, 1))", + "round(percentile(timestamp_tag, 1))", + "round(percentile(int_tag, 1))", + "round(percentile(bigint_tag, 1))", + "round(percentile(float_tag, 1))", + "round(percentile(double_tag, 1))", + "round(percentile(binary_tag, 1))", + "round(percentile(smallint_tag, 1))", + "round(percentile(tinyint_tag, 1))", + "round(percentile(bool_tag, 1))", + "round(percentile(nchar_tag, 1))", + "round(percentile(uint_tag, 1))", + "round(percentile(ubigint_tag, 1))", + "round(percentile(usmallint_tag, 1))", + "round(percentile(utinyint_tag, 1))", + "round(apercentile(ts, 1))", + "round(apercentile(timestamp_col, 1))", + "round(apercentile(int_col, 1))", + "round(apercentile(bigint_col, 1))", + "round(apercentile(float_col, 1))", + "round(apercentile(double_col, 1))", + "round(apercentile(binary_col, 1))", + "round(apercentile(smallint_col, 1))", + "round(apercentile(tinyint_col, 1))", + "round(apercentile(bool_col, 1))", + "round(apercentile(nchar_col, 1))", + "round(apercentile(uint_col, 1))", + "round(apercentile(ubigint_col, 1))", + "round(apercentile(usmallint_col, 1))", + "round(apercentile(utinyint_col, 1))", + "round(apercentile(timestamp_tag, 1))", + "round(apercentile(int_tag, 1))", + "round(apercentile(bigint_tag, 1))", + "round(apercentile(float_tag, 1))", + "round(apercentile(double_tag, 1))", + "round(apercentile(binary_tag, 1))", + "round(apercentile(smallint_tag, 1))", + "round(apercentile(tinyint_tag, 1))", + "round(apercentile(bool_tag, 1))", + "round(apercentile(nchar_tag, 1))", + "round(apercentile(uint_tag, 1))", + "round(apercentile(ubigint_tag, 1))", + "round(apercentile(usmallint_tag, 1))", + "round(apercentile(utinyint_tag, 1))", + "round(last_row(ts))", + "round(last_row(timestamp_col))", + "round(last_row(int_col))", + "round(last_row(bigint_col))", + "round(last_row(float_col))", + "round(last_row(double_col))", + "round(last_row(binary_col))", + "round(last_row(smallint_col))", + "round(last_row(tinyint_col))", + "round(last_row(bool_col))", + "round(last_row(nchar_col))", + "round(last_row(uint_col))", + "round(last_row(ubigint_col))", + "round(last_row(usmallint_col))", + "round(last_row(utinyint_col))", + "round(last_row(timestamp_tag))", + "round(last_row(int_tag))", + "round(last_row(bigint_tag))", + "round(last_row(float_tag))", + "round(last_row(double_tag))", + "round(last_row(binary_tag))", + "round(last_row(smallint_tag))", + "round(last_row(tinyint_tag))", + "round(last_row(bool_tag))", + "round(last_row(nchar_tag))", + "round(last_row(uint_tag))", + "round(last_row(ubigint_tag))", + "round(last_row(usmallint_tag))", + "round(last_row(utinyint_tag))", + "round(interp(ts))", + "round(interp(timestamp_col))", + "round(interp(int_col))", + "round(interp(bigint_col))", + "round(interp(float_col))", + "round(interp(double_col))", + "round(interp(binary_col))", + "round(interp(smallint_col))", + "round(interp(tinyint_col))", + "round(interp(bool_col))", + "round(interp(nchar_col))", + "round(interp(uint_col))", + "round(interp(ubigint_col))", + "round(interp(usmallint_col))", + "round(interp(utinyint_col))", + "round(interp(timestamp_tag))", + "round(interp(int_tag))", + "round(interp(bigint_tag))", + "round(interp(float_tag))", + "round(interp(double_tag))", + "round(interp(binary_tag))", + "round(interp(smallint_tag))", + "round(interp(tinyint_tag))", + "round(interp(bool_tag))", + "round(interp(nchar_tag))", + "round(interp(uint_tag))", + "round(interp(ubigint_tag))", + "round(interp(usmallint_tag))", + "round(interp(utinyint_tag))", + "round(diff(ts))", + "round(diff(timestamp_col))", + "round(diff(int_col))", + "round(diff(bigint_col))", + "round(diff(float_col))", + "round(diff(double_col))", + "round(diff(binary_col))", + "round(diff(smallint_col))", + "round(diff(tinyint_col))", + "round(diff(bool_col))", + "round(diff(nchar_col))", + "round(diff(uint_col))", + "round(diff(ubigint_col))", + "round(diff(usmallint_col))", + "round(diff(utinyint_col))", + "round(diff(timestamp_tag))", + "round(diff(int_tag))", + "round(diff(bigint_tag))", + "round(diff(float_tag))", + "round(diff(double_tag))", + "round(diff(binary_tag))", + "round(diff(smallint_tag))", + "round(diff(tinyint_tag))", + "round(diff(bool_tag))", + "round(diff(nchar_tag))", + "round(diff(uint_tag))", + "round(diff(ubigint_tag))", + "round(diff(usmallint_tag))", + "round(diff(utinyint_tag))", + "round(spread(ts))", + "round(spread(timestamp_col))", + "round(spread(int_col))", + "round(spread(bigint_col))", + "round(spread(float_col))", + "round(spread(double_col))", + "round(spread(binary_col))", + "round(spread(smallint_col))", + "round(spread(tinyint_col))", + "round(spread(bool_col))", + "round(spread(nchar_col))", + "round(spread(uint_col))", + "round(spread(ubigint_col))", + "round(spread(usmallint_col))", + "round(spread(utinyint_col))", + "round(spread(timestamp_tag))", + "round(spread(int_tag))", + "round(spread(bigint_tag))", + "round(spread(float_tag))", + "round(spread(double_tag))", + "round(spread(binary_tag))", + "round(spread(smallint_tag))", + "round(spread(tinyint_tag))", + "round(spread(bool_tag))", + "round(spread(nchar_tag))", + "round(spread(uint_tag))", + "round(spread(ubigint_tag))", + "round(spread(usmallint_tag))", + "round(spread(utinyint_tag))", + "round(derivative(ts, 1s, 0))", + "round(derivative(timestamp_col, 1s, 0))", + "round(derivative(int_col, 1s, 0))", + "round(derivative(bigint_col, 1s, 0))", + "round(derivative(float_col, 1s, 0))", + "round(derivative(double_col, 1s, 0))", + "round(derivative(binary_col, 1s, 0))", + "round(derivative(smallint_col, 1s, 0))", + "round(derivative(tinyint_col, 1s, 0))", + "round(derivative(bool_col, 1s, 0))", + "round(derivative(nchar_col, 1s, 0))", + "round(derivative(uint_col, 1s, 0))", + "round(derivative(ubigint_col, 1s, 0))", + "round(derivative(usmallint_col, 1s, 0))", + "round(derivative(utinyint_col, 1s, 0))", + "round(derivative(timestamp_tag, 1s, 0))", + "round(derivative(int_tag, 1s, 0))", + "round(derivative(bigint_tag, 1s, 0))", + "round(derivative(float_tag, 1s, 0))", + "round(derivative(double_tag, 1s, 0))", + "round(derivative(binary_tag, 1s, 0))", + "round(derivative(smallint_tag, 1s, 0))", + "round(derivative(tinyint_tag, 1s, 0))", + "round(derivative(bool_tag, 1s, 0))", + "round(derivative(nchar_tag, 1s, 0))", + "round(derivative(uint_tag, 1s, 0))", + "round(derivative(ubigint_tag, 1s, 0))", + "round(derivative(usmallint_tag, 1s, 0))", + "round(derivative(utinyint_tag, 1s, 0))", + "round(ts + ts)", + "round(timestamp_col + timestamp_col)", + "round(int_col + int_col)", + "round(bigint_col + bigint_col)", + "round(float_col + float_col)", + "round(double_col + double_col)", + "round(binary_col + binary_col)", + "round(smallint_col + smallint_col)", + "round(tinyint_col + tinyint_col)", + "round(bool_col + bool_col)", + "round(nchar_col + nchar_col)", + "round(uint_col + uint_col)", + "round(ubigint_col + ubigint_col)", + "round(usmallint_col + usmallint_col)", + "round(utinyint_col + utinyint_col)", + "round(timestamp_tag + timestamp_tag)", + "round(int_tag + int_tag)", + "round(bigint_tag + bigint_tag)", + "round(float_tag + float_tag)", + "round(double_tag + double_tag)", + "round(binary_tag + binary_tag)", + "round(smallint_tag + smallint_tag)", + "round(tinyint_tag + tinyint_tag)", + "round(bool_tag + bool_tag)", + "round(nchar_tag + nchar_tag)", + "round(uint_tag + uint_tag)", + "round(ubigint_tag + ubigint_tag)", + "round(usmallint_tag + usmallint_tag)", + "round(utinyint_tag + utinyint_tag)", + "round(ts - ts)", + "round(timestamp_col - timestamp_col)", + "round(int_col - int_col)", + "round(bigint_col - bigint_col)", + "round(float_col - float_col)", + "round(double_col - double_col)", + "round(binary_col - binary_col)", + "round(smallint_col - smallint_col)", + "round(tinyint_col - tinyint_col)", + "round(bool_col - bool_col)", + "round(nchar_col - nchar_col)", + "round(uint_col - uint_col)", + "round(ubigint_col - ubigint_col)", + "round(usmallint_col - usmallint_col)", + "round(utinyint_col - utinyint_col)", + "round(timestamp_tag - timestamp_tag)", + "round(int_tag - int_tag)", + "round(bigint_tag - bigint_tag)", + "round(float_tag - float_tag)", + "round(double_tag - double_tag)", + "round(binary_tag - binary_tag)", + "round(smallint_tag - smallint_tag)", + "round(tinyint_tag - tinyint_tag)", + "round(bool_tag - bool_tag)", + "round(nchar_tag - nchar_tag)", + "round(uint_tag - uint_tag)", + "round(ubigint_tag - ubigint_tag)", + "round(usmallint_tag - usmallint_tag)", + "round(utinyint_tag - utinyint_tag)", + "round(ts * ts)", + "round(timestamp_col * timestamp_col)", + "round(int_col * int_col)", + "round(bigint_col * bigint_col)", + "round(float_col * float_col)", + "round(double_col * double_col)", + "round(binary_col * binary_col)", + "round(smallint_col * smallint_col)", + "round(tinyint_col * tinyint_col)", + "round(bool_col * bool_col)", + "round(nchar_col * nchar_col)", + "round(uint_col * uint_col)", + "round(ubigint_col * ubigint_col)", + "round(usmallint_col * usmallint_col)", + "round(utinyint_col * utinyint_col)", + "round(timestamp_tag * timestamp_tag)", + "round(int_tag * int_tag)", + "round(bigint_tag * bigint_tag)", + "round(float_tag * float_tag)", + "round(double_tag * double_tag)", + "round(binary_tag * binary_tag)", + "round(smallint_tag * smallint_tag)", + "round(tinyint_tag * tinyint_tag)", + "round(bool_tag * bool_tag)", + "round(nchar_tag * nchar_tag)", + "round(uint_tag * uint_tag)", + "round(ubigint_tag * ubigint_tag)", + "round(usmallint_tag * usmallint_tag)", + "round(utinyint_tag * utinyint_tag)", + "round(ts / ts)", + "round(timestamp_col / timestamp_col)", + "round(int_col / int_col)", + "round(bigint_col / bigint_col)", + "round(float_col / float_col)", + "round(double_col / double_col)", + "round(binary_col / binary_col)", + "round(smallint_col / smallint_col)", + "round(tinyint_col / tinyint_col)", + "round(bool_col / bool_col)", + "round(nchar_col / nchar_col)", + "round(uint_col / uint_col)", + "round(ubigint_col / ubigint_col)", + "round(usmallint_col / usmallint_col)", + "round(utinyint_col / utinyint_col)", + "round(timestamp_tag / timestamp_tag)", + "round(int_tag / int_tag)", + "round(bigint_tag / bigint_tag)", + "round(float_tag / float_tag)", + "round(double_tag / double_tag)", + "round(binary_tag / binary_tag)", + "round(smallint_tag / smallint_tag)", + "round(tinyint_tag / tinyint_tag)", + "round(bool_tag / bool_tag)", + "round(nchar_tag / nchar_tag)", + "round(uint_tag / uint_tag)", + "round(ubigint_tag / ubigint_tag)", + "round(usmallint_tag / usmallint_tag)", + "round(utinyint_tag / utinyint_tag)", + "int_col, round(int_col), int_col", + "bigint_col, round(bigint_col), bigint_col", + "float_col, round(float_col), float_col", + "double_col, round(double_col), double_col", + "smallint_col, round(smallint_col), smallint_col", + "tinyint_col, round(tinyint_col), tinyint_col", + "uint_col, round(uint_col), uint_col", + "ubigint_col, round(ubigint_col), ubigint_col", + "usmallint_col, round(usmallint_col), usmallint_col", + "utinyint_col, round(utinyint_col), utinyint_col", + "count(int_col), round(int_col), count(int_col)", + "count(bigint_col), round(bigint_col), count(bigint_col)", + "count(float_col), round(float_col), count(float_col)", + "count(double_col), round(double_col), count(double_col)", + "count(smallint_col), round(smallint_col), count(smallint_col)", + "count(tinyint_col), round(tinyint_col), count(tinyint_col)", + "count(uint_col), round(uint_col), count(uint_col)", + "count(ubigint_col), round(ubigint_col), count(ubigint_col)", + "count(usmallint_col), round(usmallint_col), count(usmallint_col)", + "count(utinyint_col), round(utinyint_col), count(utinyint_col)", + "avg(int_col), round(int_col), avg(int_col)", + "avg(bigint_col), round(bigint_col), avg(bigint_col)", + "avg(float_col), round(float_col), avg(float_col)", + "avg(double_col), round(double_col), avg(double_col)", + "avg(smallint_col), round(smallint_col), avg(smallint_col)", + "avg(tinyint_col), round(tinyint_col), avg(tinyint_col)", + "avg(uint_col), round(uint_col), avg(uint_col)", + "avg(ubigint_col), round(ubigint_col), avg(ubigint_col)", + "avg(usmallint_col), round(usmallint_col), avg(usmallint_col)", + "avg(utinyint_col), round(utinyint_col), avg(utinyint_col)", + "twa(int_col), round(int_col), twa(int_col)", + "twa(bigint_col), round(bigint_col), twa(bigint_col)", + "twa(float_col), round(float_col), twa(float_col)", + "twa(double_col), round(double_col), twa(double_col)", + "twa(smallint_col), round(smallint_col), twa(smallint_col)", + "twa(tinyint_col), round(tinyint_col), twa(tinyint_col)", + "twa(uint_col), round(uint_col), twa(uint_col)", + "twa(ubigint_col), round(ubigint_col), twa(ubigint_col)", + "twa(usmallint_col), round(usmallint_col), twa(usmallint_col)", + "twa(utinyint_col), round(utinyint_col), twa(utinyint_col)", + "sum(int_col), round(int_col), sum(int_col)", + "sum(bigint_col), round(bigint_col), sum(bigint_col)", + "sum(float_col), round(float_col), sum(float_col)", + "sum(double_col), round(double_col), sum(double_col)", + "sum(smallint_col), round(smallint_col), sum(smallint_col)", + "sum(tinyint_col), round(tinyint_col), sum(tinyint_col)", + "sum(uint_col), round(uint_col), sum(uint_col)", + "sum(ubigint_col), round(ubigint_col), sum(ubigint_col)", + "sum(usmallint_col), round(usmallint_col), sum(usmallint_col)", + "sum(utinyint_col), round(utinyint_col), sum(utinyint_col)", + "stddev(int_col), round(int_col), stddev(int_col)", + "stddev(bigint_col), round(bigint_col), stddev(bigint_col)", + "stddev(float_col), round(float_col), stddev(float_col)", + "stddev(double_col), round(double_col), stddev(double_col)", + "stddev(smallint_col), round(smallint_col), stddev(smallint_col)", + "stddev(tinyint_col), round(tinyint_col), stddev(tinyint_col)", + "stddev(uint_col), round(uint_col), stddev(uint_col)", + "stddev(ubigint_col), round(ubigint_col), stddev(ubigint_col)", + "stddev(usmallint_col), round(usmallint_col), stddev(usmallint_col)", + "stddev(utinyint_col), round(utinyint_col), stddev(utinyint_col)", + "irate(int_col), round(int_col), irate(int_col)", + "irate(bigint_col), round(bigint_col), irate(bigint_col)", + "irate(float_col), round(float_col), irate(float_col)", + "irate(double_col), round(double_col), irate(double_col)", + "irate(smallint_col), round(smallint_col), irate(smallint_col)", + "irate(tinyint_col), round(tinyint_col), irate(tinyint_col)", + "irate(uint_col), round(uint_col), irate(uint_col)", + "irate(ubigint_col), round(ubigint_col), irate(ubigint_col)", + "irate(usmallint_col), round(usmallint_col), irate(usmallint_col)", + "irate(utinyint_col), round(utinyint_col), irate(utinyint_col)", + "min(int_col), round(int_col), min(int_col)", + "min(bigint_col), round(bigint_col), min(bigint_col)", + "min(float_col), round(float_col), min(float_col)", + "min(double_col), round(double_col), min(double_col)", + "min(smallint_col), round(smallint_col), min(smallint_col)", + "min(tinyint_col), round(tinyint_col), min(tinyint_col)", + "min(uint_col), round(uint_col), min(uint_col)", + "min(ubigint_col), round(ubigint_col), min(ubigint_col)", + "min(usmallint_col), round(usmallint_col), min(usmallint_col)", + "min(utinyint_col), round(utinyint_col), min(utinyint_col)", + "max(int_col), round(int_col), max(int_col)", + "max(bigint_col), round(bigint_col), max(bigint_col)", + "max(float_col), round(float_col), max(float_col)", + "max(double_col), round(double_col), max(double_col)", + "max(smallint_col), round(smallint_col), max(smallint_col)", + "max(tinyint_col), round(tinyint_col), max(tinyint_col)", + "max(uint_col), round(uint_col), max(uint_col)", + "max(ubigint_col), round(ubigint_col), max(ubigint_col)", + "max(usmallint_col), round(usmallint_col), max(usmallint_col)", + "max(utinyint_col), round(utinyint_col), max(utinyint_col)", + "first(int_col), round(int_col), first(int_col)", + "first(bigint_col), round(bigint_col), first(bigint_col)", + "first(float_col), round(float_col), first(float_col)", + "first(double_col), round(double_col), first(double_col)", + "first(smallint_col), round(smallint_col), first(smallint_col)", + "first(tinyint_col), round(tinyint_col), first(tinyint_col)", + "first(uint_col), round(uint_col), first(uint_col)", + "first(ubigint_col), round(ubigint_col), first(ubigint_col)", + "first(usmallint_col), round(usmallint_col), first(usmallint_col)", + "first(utinyint_col), round(utinyint_col), first(utinyint_col)", + "last(int_col), round(int_col), last(int_col)", + "last(bigint_col), round(bigint_col), last(bigint_col)", + "last(float_col), round(float_col), last(float_col)", + "last(double_col), round(double_col), last(double_col)", + "last(smallint_col), round(smallint_col), last(smallint_col)", + "last(tinyint_col), round(tinyint_col), last(tinyint_col)", + "last(uint_col), round(uint_col), last(uint_col)", + "last(ubigint_col), round(ubigint_col), last(ubigint_col)", + "last(usmallint_col), round(usmallint_col), last(usmallint_col)", + "last(utinyint_col), round(utinyint_col), last(utinyint_col)", + "last_row(int_col), round(int_col), last_row(int_col)", + "last_row(bigint_col), round(bigint_col), last_row(bigint_col)", + "last_row(float_col), round(float_col), last_row(float_col)", + "last_row(double_col), round(double_col), last_row(double_col)", + "last_row(smallint_col), round(smallint_col), last_row(smallint_col)", + "last_row(tinyint_col), round(tinyint_col), last_row(tinyint_col)", + "last_row(uint_col), round(uint_col), last_row(uint_col)", + "last_row(ubigint_col), round(ubigint_col), last_row(ubigint_col)", + "last_row(usmallint_col), round(usmallint_col), last_row(usmallint_col)", + "last_row(utinyint_col), round(utinyint_col), last_row(utinyint_col)", + "interp(int_col), round(int_col), interp(int_col)", + "interp(bigint_col), round(bigint_col), interp(bigint_col)", + "interp(float_col), round(float_col), interp(float_col)", + "interp(double_col), round(double_col), interp(double_col)", + "interp(smallint_col), round(smallint_col), interp(smallint_col)", + "interp(tinyint_col), round(tinyint_col), interp(tinyint_col)", + "interp(uint_col), round(uint_col), interp(uint_col)", + "interp(ubigint_col), round(ubigint_col), interp(ubigint_col)", + "interp(usmallint_col), round(usmallint_col), interp(usmallint_col)", + "interp(utinyint_col), round(utinyint_col), interp(utinyint_col)", + "diff(int_col), round(int_col), diff(int_col)", + "diff(bigint_col), round(bigint_col), diff(bigint_col)", + "diff(float_col), round(float_col), diff(float_col)", + "diff(double_col), round(double_col), diff(double_col)", + "diff(smallint_col), round(smallint_col), diff(smallint_col)", + "diff(tinyint_col), round(tinyint_col), diff(tinyint_col)", + "diff(uint_col), round(uint_col), diff(uint_col)", + "diff(ubigint_col), round(ubigint_col), diff(ubigint_col)", + "diff(usmallint_col), round(usmallint_col), diff(usmallint_col)", + "diff(utinyint_col), round(utinyint_col), diff(utinyint_col)", + "spread(int_col), round(int_col), spread(int_col)", + "spread(bigint_col), round(bigint_col), spread(bigint_col)", + "spread(float_col), round(float_col), spread(float_col)", + "spread(double_col), round(double_col), spread(double_col)", + "spread(smallint_col), round(smallint_col), spread(smallint_col)", + "spread(tinyint_col), round(tinyint_col), spread(tinyint_col)", + "spread(uint_col), round(uint_col), spread(uint_col)", + "spread(ubigint_col), round(ubigint_col), spread(ubigint_col)", + "spread(usmallint_col), round(usmallint_col), spread(usmallint_col)", + "spread(utinyint_col), round(utinyint_col), spread(utinyint_col)", + "leastsquares(int_col, 1, 1), round(int_col), leastsquares(int_col, 1, 1)", + "leastsquares(bigint_col, 1, 1), round(bigint_col), leastsquares(bigint_col, 1, 1)", + "leastsquares(float_col, 1, 1), round(float_col), leastsquares(float_col, 1, 1)", + "leastsquares(double_col, 1, 1), round(double_col), leastsquares(double_col, 1, 1)", + "leastsquares(smallint_col, 1, 1), round(smallint_col), leastsquares(smallint_col, 1, 1)", + "leastsquares(tinyint_col, 1, 1), round(tinyint_col), leastsquares(tinyint_col, 1, 1)", + "leastsquares(uint_col, 1, 1), round(uint_col), leastsquares(uint_col, 1, 1)", + "leastsquares(ubigint_col, 1, 1), round(ubigint_col), leastsquares(ubigint_col, 1, 1)", + "leastsquares(usmallint_col, 1, 1), round(usmallint_col), leastsquares(usmallint_col, 1, 1)", + "leastsquares(utinyint_col, 1, 1), round(utinyint_col), leastsquares(utinyint_col, 1, 1)", + "top(int_col, 1), round(int_col), top(int_col, 1)", + "top(bigint_col, 1), round(bigint_col), top(bigint_col, 1)", + "top(float_col, 1), round(float_col), top(float_col, 1)", + "top(double_col, 1), round(double_col), top(double_col, 1)", + "top(smallint_col, 1), round(smallint_col), top(smallint_col, 1)", + "top(tinyint_col, 1), round(tinyint_col), top(tinyint_col, 1)", + "top(uint_col, 1), round(uint_col), top(uint_col, 1)", + "top(ubigint_col, 1), round(ubigint_col), top(ubigint_col, 1)", + "top(usmallint_col, 1), round(usmallint_col), top(usmallint_col, 1)", + "top(utinyint_col, 1), round(utinyint_col), top(utinyint_col, 1)", + "bottom(int_col, 1), round(int_col), bottom(int_col, 1)", + "bottom(bigint_col, 1), round(bigint_col), bottom(bigint_col, 1)", + "bottom(float_col, 1), round(float_col), bottom(float_col, 1)", + "bottom(double_col, 1), round(double_col), bottom(double_col, 1)", + "bottom(smallint_col, 1), round(smallint_col), bottom(smallint_col, 1)", + "bottom(tinyint_col, 1), round(tinyint_col), bottom(tinyint_col, 1)", + "bottom(uint_col, 1), round(uint_col), bottom(uint_col, 1)", + "bottom(ubigint_col, 1), round(ubigint_col), bottom(ubigint_col, 1)", + "bottom(usmallint_col, 1), round(usmallint_col), bottom(usmallint_col, 1)", + "bottom(utinyint_col, 1), round(utinyint_col), bottom(utinyint_col, 1)", + "percentile(int_col, 1), round(int_col), percentile(int_col, 1)", + "percentile(bigint_col, 1), round(bigint_col), percentile(bigint_col, 1)", + "percentile(float_col, 1), round(float_col), percentile(float_col, 1)", + "percentile(double_col, 1), round(double_col), percentile(double_col, 1)", + "percentile(smallint_col, 1), round(smallint_col), percentile(smallint_col, 1)", + "percentile(tinyint_col, 1), round(tinyint_col), percentile(tinyint_col, 1)", + "percentile(uint_col, 1), round(uint_col), percentile(uint_col, 1)", + "percentile(ubigint_col, 1), round(ubigint_col), percentile(ubigint_col, 1)", + "percentile(usmallint_col, 1), round(usmallint_col), percentile(usmallint_col, 1)", + "percentile(utinyint_col, 1), round(utinyint_col), percentile(utinyint_col, 1)", + "apercentile(int_col, 1), round(int_col), apercentile(int_col, 1)", + "apercentile(bigint_col, 1), round(bigint_col), apercentile(bigint_col, 1)", + "apercentile(float_col, 1), round(float_col), apercentile(float_col, 1)", + "apercentile(double_col, 1), round(double_col), apercentile(double_col, 1)", + "apercentile(smallint_col, 1), round(smallint_col), apercentile(smallint_col, 1)", + "apercentile(tinyint_col, 1), round(tinyint_col), apercentile(tinyint_col, 1)", + "apercentile(uint_col, 1), round(uint_col), apercentile(uint_col, 1)", + "apercentile(ubigint_col, 1), round(ubigint_col), apercentile(ubigint_col, 1)", + "apercentile(usmallint_col, 1), round(usmallint_col), apercentile(usmallint_col, 1)", + "apercentile(utinyint_col, 1), round(utinyint_col), apercentile(utinyint_col, 1)", + "derivative(int_col, 1s, 0), round(int_col), derivative(int_col, 1s, 0)", + "derivative(bigint_col, 1s, 0), round(bigint_col), derivative(bigint_col, 1s, 0)", + "derivative(float_col, 1s, 0), round(float_col), derivative(float_col, 1s, 0)", + "derivative(double_col, 1s, 0), round(double_col), derivative(double_col, 1s, 0)", + "derivative(smallint_col, 1s, 0), round(smallint_col), derivative(smallint_col, 1s, 0)", + "derivative(tinyint_col, 1s, 0), round(tinyint_col), derivative(tinyint_col, 1s, 0)", + "derivative(uint_col, 1s, 0), round(uint_col), derivative(uint_col, 1s, 0)", + "derivative(ubigint_col, 1s, 0), round(ubigint_col), derivative(ubigint_col, 1s, 0)", + "derivative(usmallint_col, 1s, 0), round(usmallint_col), derivative(usmallint_col, 1s, 0)", + "derivative(utinyint_col, 1s, 0), round(utinyint_col), derivative(utinyint_col, 1s, 0)", + "1, round(int_col), 1", + "1, round(bigint_col), 1", + "1, round(float_col), 1", + "1, round(double_col), 1", + "1, round(smallint_col), 1", + "1, round(tinyint_col), 1", + "1, round(uint_col), 1", + "1, round(ubigint_col), 1", + "1, round(usmallint_col), 1", + "1, round(utinyint_col), 1", + "round(int_col) as anyName", + "round(bigint_col) as anyName", + "round(float_col) as anyName", + "round(double_col) as anyName", + "round(smallint_col) as anyName", + "round(tinyint_col) as anyName", + "round(uint_col) as anyName", + "round(ubigint_col) as anyName", + "round(usmallint_col) as anyName", + "round(utinyint_col) as anyName", + "distinct round(int_col)", + "distinct round(bigint_col)", + "distinct round(float_col)", + "distinct round(double_col)", + "distinct round(smallint_col)", + "distinct round(tinyint_col)", + "distinct round(uint_col)", + "distinct round(ubigint_col)", + "distinct round(usmallint_col)", + "distinct round(utinyint_col)", + ] + simple_select_command = [ + "round(super.int_col)", + "round(super.bigint_col)", + "round(super.float_col)", + "round(super.double_col)", + "round(super.smallint_col)", + "round(super.tinyint_col)", + "round(super.uint_col)", + "round(super.ubigint_col)", + "round(super.usmallint_col)", + "round(super.utinyint_col)", + "round(t1.int_col)", + "round(t1.bigint_col)", + "round(t1.float_col)", + "round(t1.double_col)", + "round(t1.smallint_col)", + "round(t1.tinyint_col)", + "round(t1.uint_col)", + "round(t1.ubigint_col)", + "round(t1.usmallint_col)", + "round(t1.utinyint_col)", + ] + from_command = [" from super", " from t1"] + advance_from_command = [ + " from super", " from t1", + " from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag" + ] + filter_command = [ + "", " session(ts, 1s)", " state_window(int_col)", " interval (1s)", + " interval (1s) sliding (1s)", " group by (ts)" + ] + fill_command = [ + "", " fill(prev)", " fill(next)", " fill(null)", " fill(1)", + " fill(linear)" + ] + tdSql.prepare() + tdSql.execute( + "create stable super (ts timestamp, timestamp_col timestamp, int_col int, bigint_col bigint, float_col float,\ + double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ + uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ + float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + ) + tdSql.execute( + "create stable superb (ts timestamp, timestamp_col timestamp, int_col int, bigint_col bigint, float_col float,\ + double_col double, binary_col binary(8), smallint_col smallint, tinyint_col tinyint, bool_col bool, nchar_col nchar(8), \ + uint_col int unsigned, ubigint_col bigint unsigned, usmallint_col smallint unsigned, utinyint_col tinyint unsigned) tags (int_tag int, bigint_tag bigint, \ + float_tag float, double_tag double, binary_tag binary(8), smallint_tag smallint, tinyint_tag tinyint, bool_tag bool, nchar_tag nchar(8),\ + uint_tag int unsigned, ubigint_tag bigint unsigned, usmallint_tag smallint unsigned, utinyint_tag tinyint unsigned)" + ) + tdSql.execute( + "create table t1 using super tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomBigint(), self.randomDouble(), self.randomDouble(), + self.randomNchar(), self.randomSmallint(), self.randomTinyint(), + self.randomNchar(), self.randomUInt(), self.randomUBigint(), + self.randomUSmallint(), self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215892, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215893, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t1 values (1629796215894, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "create table t2 using superb tags (1, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomBigint(), self.randomDouble(), self.randomDouble(), + self.randomNchar(), self.randomSmallint(), self.randomTinyint(), + self.randomNchar(), self.randomUInt(), self.randomUBigint(), + self.randomUSmallint(), self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215891, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215892, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215893, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 1, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + tdSql.execute( + "insert into t2 values (1629796215894, 1629796215891, %d, %d, %f, %f, '%s', %d, %d, 0, '%s', %d, %d, %d, %d)" + % (self.randomInt(), self.randomBigint(), self.randomDouble(), + self.randomDouble(), self.randomNchar(), self.randomSmallint(), + self.randomTinyint(), self.randomNchar(), self.randomUInt(), + self.randomUBigint(), self.randomUSmallint(), + self.randomUTinyint())) + + for s in range(len(select_command)): + for f in range(len(from_command)): + sql = "select " + select_command[s] + from_command[f] + if (select_command[s] == "round(int_col)"\ + or select_command[s] == "round(bigint_col)"\ + or select_command[s] == "round(smallint_col)" \ + or select_command[s] == "round(float_col)"\ + or select_command[s] == "round(double_col)"\ + or select_command[s] == "round(tinyint_col)"\ + or select_command[s] == "round(uint_col)"\ + or select_command[s] == "round(ubigint_col)"\ + or select_command[s] == "round(usmallint_col)"\ + or select_command[s] == "round(utinyint_col)"\ + or select_command[s] == "1, round(int_col), 1"\ + or select_command[s] == "1, round(bigint_col), 1"\ + or select_command[s] == "1, round(float_col), 1"\ + or select_command[s] == "1, round(double_col), 1"\ + or select_command[s] == "1, round(smallint_col), 1"\ + or select_command[s] == "1, round(tinyint_col), 1"\ + or select_command[s] == "1, round(uint_col), 1"\ + or select_command[s] == "1, round(ubigint_col), 1"\ + or select_command[s] == "1, round(usmallint_col), 1"\ + or select_command[s] == "1, round(utinyint_col), 1"\ + or select_command[s] == "int_col, round(int_col), int_col"\ + or select_command[s] == "bigint_col, round(bigint_col), bigint_col"\ + or select_command[s] == "float_col, round(float_col), float_col"\ + or select_command[s] == "double_col, round(double_col), double_col"\ + or select_command[s] == "smallint_col, round(smallint_col), smallint_col"\ + or select_command[s] == "tinyint_col, round(tinyint_col), tinyint_col"\ + or select_command[s] == "uint_col, round(uint_col), uint_col"\ + or select_command[s] == "ubigint_col, round(ubigint_col), ubigint_col"\ + or select_command[s] == "usmallint_col, round(usmallint_col), usmallint_col"\ + or select_command[s] == "utinyint_col, round(utinyint_col), utinyint_col"\ + or select_command[s] == "round(int_col) as anyName"\ + or select_command[s] == "round(bigint_col) as anyName"\ + or select_command[s] == "round(float_col) as anyName"\ + or select_command[s] == "round(double_col) as anyName"\ + or select_command[s] == "round(smallint_col) as anyName"\ + or select_command[s] == "round(tinyint_col) as anyName"\ + or select_command[s] == "round(uint_col) as anyName"\ + or select_command[s] == "round(ubigint_col) as anyName"\ + or select_command[s] == "round(usmallint_col) as anyName"\ + or select_command[s] == "round(utinyint_col) as anyName"\ + or select_command[s] == "round(int_col) + round(int_col)"\ + or select_command[s] == "round(bigint_col) + round(bigint_col)"\ + or select_command[s] == "round(float_col) + round(float_col)"\ + or select_command[s] == "round(double_col) + round(double_col)"\ + or select_command[s] == "round(smallint_col) + round(smallint_col)"\ + or select_command[s] == "round(tinyint_col) + round(tinyint_col)"\ + or select_command[s] == "round(uint_col) + round(uint_col)"\ + or select_command[s] == "round(ubigint_col) + round(ubigint_col)"\ + or select_command[s] == "round(usmallint_col) + round(usmallint_col)"\ + or select_command[s] == "round(utinyint_col) + round(utinyint_col)"\ + or select_command[s] == "round(int_col) + round(int_col)"\ + or select_command[s] == "round(bigint_col) + round(bigint_col)"\ + or select_command[s] == "round(float_col) + round(float_col)"\ + or select_command[s] == "round(double_col) + round(double_col)"\ + or select_command[s] == "round(smallint_col) + round(smallint_col)"\ + or select_command[s] == "round(tinyint_col) + round(tinyint_col)"\ + or select_command[s] == "round(uint_col) + round(uint_col)"\ + or select_command[s] == "round(ubigint_col) + round(ubigint_col)"\ + or select_command[s] == "round(usmallint_col) + round(usmallint_col)"\ + or select_command[s] == "round(utinyint_col) + cei(utinyint_col)"\ + or select_command[s] == "round(int_col) - round(int_col)"\ + or select_command[s] == "round(bigint_col) - round(bigint_col)"\ + or select_command[s] == "round(float_col) - round(float_col)"\ + or select_command[s] == "round(double_col) - round(double_col)"\ + or select_command[s] == "round(smallint_col) - round(smallint_col)"\ + or select_command[s] == "round(tinyint_col) - round(tinyint_col)"\ + or select_command[s] == "round(uint_col) - round(uint_col)"\ + or select_command[s] == "round(ubigint_col) - round(ubigint_col)"\ + or select_command[s] == "round(usmallint_col) - round(usmallint_col)"\ + or select_command[s] == "round(utinyint_col) - round(utinyint_col)"\ + or select_command[s] == "round(int_col) * round(int_col)"\ + or select_command[s] == "round(bigint_col) * round(bigint_col)"\ + or select_command[s] == "round(float_col) * round(float_col)"\ + or select_command[s] == "round(double_col) * round(double_col)"\ + or select_command[s] == "round(smallint_col) * round(smallint_col)"\ + or select_command[s] == "round(tinyint_col) * round(tinyint_col)"\ + or select_command[s] == "round(uint_col) * round(uint_col)"\ + or select_command[s] == "round(ubigint_col) * round(ubigint_col)"\ + or select_command[s] == "round(usmallint_col) * round(usmallint_col)"\ + or select_command[s] == "round(utinyint_col) * round(utinyint_col)"\ + or select_command[s] == "round(int_col) / round(int_col)"\ + or select_command[s] == "round(bigint_col) / round(bigint_col)"\ + or select_command[s] == "round(float_col) / round(float_col)"\ + or select_command[s] == "round(double_col) / round(double_col)"\ + or select_command[s] == "round(smallint_col) / round(smallint_col)"\ + or select_command[s] == "round(tinyint_col) / round(tinyint_col)"\ + or select_command[s] == "round(uint_col) / round(uint_col)"\ + or select_command[s] == "round(ubigint_col) / round(ubigint_col)"\ + or select_command[s] == "round(usmallint_col) / round(usmallint_col)"\ + or select_command[s] == "round(utinyint_col) / round(utinyint_col)"): + tdSql.query(sql) + else: + tdSql.error(sql) + for sim in range(len(simple_select_command)): + for fr in range(len(advance_from_command)): + for filter in range(len(filter_command)): + for fill in range(len(fill_command)): + sql = "select " + simple_select_command[ + sim] + advance_from_command[fr] + filter_command[ + filter] + fill_command[fill] + if sql == "select round(t1.int_col) from t1"\ + or sql == "select round(super.int_col) from super"\ + or sql == "select round(t1.bigint_col) from t1"\ + or sql == "select round(super.bigint_col) from super"\ + or sql == "select round(t1.smallint_col) from t1"\ + or sql == "select round(super.smallint_col) from super"\ + or sql == "select round(t1.tinyint_col) from t1"\ + or sql == "select round(super.tinyint_col) from super"\ + or sql == "select round(t1.float_col) from t1"\ + or sql == "select round(super.float_col) from super"\ + or sql == "select round(t1.double_col) from t1"\ + or sql == "select round(super.double_col) from super"\ + or sql == "select round(t1.uint_col) from t1"\ + or sql == "select round(super.uint_col) from super"\ + or sql == "select round(t1.ubigint_col) from t1"\ + or sql == "select round(super.ubigint_col) from super"\ + or sql == "select round(t1.usmallint_col) from t1"\ + or sql == "select round(super.usmallint_col) from super"\ + or sql == "select round(t1.utinyint_col) from t1"\ + or sql == "select round(super.utinyint_col) from super"\ + or sql == "select round(super.int_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select round(super.bigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select round(super.smallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select round(super.tinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select round(super.float_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select round(super.double_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select round(super.uint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select round(super.ubigint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select round(super.usmallint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag"\ + or sql == "select round(super.utinyint_col) from super, superb where super.ts = superb.ts and super.int_tag = superb.int_tag": + tdSql.query(sql) + else: + tdSql.error(sql) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/functions/queryTestCases.py b/tests/pytest/functions/queryTestCases.py index 1311ad6b3c83e1d4a0ec6fdf73a707a44bd5297c..a20b89d47c5fc09d032e72335edb9544eb50e0aa 100644 --- a/tests/pytest/functions/queryTestCases.py +++ b/tests/pytest/functions/queryTestCases.py @@ -15,6 +15,7 @@ import sys import subprocess import random import math +import numpy as np from util.log import * from util.cases import * @@ -57,16 +58,33 @@ class TDTestCase: def td3690(self): tdLog.printNoPrefix("==========TD-3690==========") + + tdSql.prepare() + + tdSql.execute("show variables") + res_off = tdSql.cursor.fetchall() + resList = np.array(res_off) + index = np.where(resList == "offlineThreshold") + index_value = np.dstack((index[0])).squeeze() tdSql.query("show variables") - tdSql.checkData(53, 1, 864000) + tdSql.checkData(index_value, 1, 864000) def td4082(self): tdLog.printNoPrefix("==========TD-4082==========") + + tdSql.prepare() + cfgfile = self.getCfgFile() max_compressMsgSize = 100000000 + tdSql.execute("show variables") + res_com = tdSql.cursor.fetchall() + rescomlist = np.array(res_com) + cpms_index = np.where(rescomlist == "compressMsgSize") + index_value = np.dstack((cpms_index[0])).squeeze() + tdSql.query("show variables") - tdSql.checkData(26, 1, -1) + tdSql.checkData(index_value, 1, -1) tdSql.query("show dnodes") index = tdSql.getData(0, 0) @@ -80,7 +98,7 @@ class TDTestCase: tdDnodes.start(index) tdSql.query("show variables") - tdSql.checkData(26, 1, 100000000) + tdSql.checkData(index_value, 1, 100000000) tdDnodes.stop(index) cmd = f"sed -i '$s/{max_compressMsgSize}/{max_compressMsgSize+10}/g' {cfgfile} " @@ -91,7 +109,7 @@ class TDTestCase: tdDnodes.start(index) tdSql.query("show variables") - tdSql.checkData(26, 1, -1) + tdSql.checkData(index_value, 1, -1) tdDnodes.stop(index) cmd = f"sed -i '$d' {cfgfile}" @@ -104,8 +122,12 @@ class TDTestCase: def td4097(self): tdLog.printNoPrefix("==========TD-4097==========") + tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db1") + tdDnodes.stop(1) + tdDnodes.start(1) + tdSql.execute("create database if not exists db keep 3650") tdSql.execute("create database if not exists db1 keep 3650") tdSql.execute("create database if not exists new keep 3650") @@ -267,10 +289,22 @@ class TDTestCase: # keep ~ [days,365000] tdSql.execute("drop database if exists db") tdSql.execute("create database if not exists db") + + tdSql.execute("show variables") + res_kp = tdSql.cursor.fetchall() + resList = np.array(res_kp) + keep_index = np.where(resList == "keep") + index_value = np.dstack((keep_index[0])).squeeze() + tdSql.query("show variables") - tdSql.checkData(38, 1, 3650) + tdSql.checkData(index_value, 1, 3650) + tdSql.query("show databases") - tdSql.checkData(0,7,"3650,3650,3650") + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + tdSql.checkData(0, 7, "3650,3650,3650") + else: + tdSql.checkData(0, 7, 3650) days = tdSql.getData(0, 6) tdSql.error("alter database db keep 3650001") @@ -289,14 +323,22 @@ class TDTestCase: tdSql.execute("alter database db keep 36500") tdSql.query("show databases") - tdSql.checkData(0, 7, "3650,3650,36500") + if ("community" in selfPath): + tdSql.checkData(0, 7, "36500,36500,36500") + else: + tdSql.checkData(0, 7, 36500) + tdSql.execute("drop database if exists db") tdSql.execute("create database if not exists db1") tdSql.query("show databases") - tdSql.checkData(0, 7, "3650,3650,3650") + if ("community" in selfPath): + tdSql.checkData(0, 7, "3650,3650,3650") + else: + tdSql.checkData(0, 7, 3650) + tdSql.query("show variables") - tdSql.checkData(38, 1, 3650) + tdSql.checkData(index_value, 1, 3650) tdSql.execute("alter database db1 keep 365") tdSql.execute("drop database if exists db1") @@ -552,7 +594,7 @@ class TDTestCase: tdSql.execute("use db") tdSql.execute("create stable db.stb1 (ts timestamp, c1 int) tags(t0 tinyint, t1 int)") tdSql.execute("create stable db.stb2 (ts timestamp, c1 int) tags(t0 binary(16), t1 binary(16))") - numtab=2000000 + numtab=20000 for i in range(numtab): sql = f"create table db.t{i} using db.stb1 tags({i%128}, {100+i})" tdSql.execute(sql) @@ -698,9 +740,7 @@ class TDTestCase: tdSql.query(f"select distinct c1 c2, c2 c3 from t1 where c1 <{tbnum}") tdSql.checkRows(3) tdSql.error("select distinct c1, c2 from stb1 order by ts") - #tdSql.checkRows(tbnum*3+1) tdSql.error("select distinct c1, c2 from t1 order by ts") - #tdSql.checkRows(4) tdSql.error("select distinct c1, ts from stb1 group by c2") tdSql.error("select distinct c1, ts from t1 group by c2") tdSql.error("select distinct c1, max(c2) from stb1 ") @@ -729,7 +769,7 @@ class TDTestCase: tdSql.query(f"select distinct c1,c2 from (select * from t1 where c1 < {tbnum}) ") tdSql.checkRows(3) tdSql.query(f"select distinct c1,c2 from (select * from stb1 where t2 !=0 and t2 != 1) ") - tdSql.checkRows(4) + tdSql.checkRows(0) tdSql.error("select distinct c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ") tdSql.error("select c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ") tdSql.query("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 ) where c1 < 4") @@ -975,6 +1015,84 @@ class TDTestCase: tdSql.error("select ts as t, bottom(t1, 3) from t1 order by c3") + tdSql.error("select ts as t, top(c1, 0) from t1") + tdSql.query("select ts as t, top(c1, 5) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, top(c1, 5) from stb1") + tdSql.checkRows(5) + tdSql.query("select ts as t, top(c1, 5) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.query("select ts as t, top(c1, 8) from t1") + tdSql.checkRows(6) + tdSql.query("select ts as t, top(c2, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, top(c3, 5) from t1") + tdSql.error("select ts as t, top(c4, 5) from t1") + tdSql.query("select ts as t, top(c5, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, top(c6, 5) from t1") + tdSql.error("select ts as t, top(c5, 8) as b from t1 order by b") + tdSql.error("select ts as t, top(t1, 1) from t1") + tdSql.error("select ts as t, top(t1, 1) from stb1") + tdSql.error("select ts as t, top(t1, 3) from stb1 order by c3") + tdSql.error("select ts as t, top(t1, 3) from t1 order by c3") + + tdDnodes.stop(1) + tdDnodes.start(1) + + tdSql.query("select ts as t, diff(c1) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, diff(c1) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.checkCols(4) + tdSql.query("select ts as t, diff(c1) from t1") + tdSql.query("select ts as t, diff(c1) from t1") + tdSql.error("select ts as t, diff(c1) from stb1") + tdSql.query("select ts as t, diff(c2) from t1") + tdSql.checkRows(5) + tdSql.error("select ts as t, diff(c3) from t1") + tdSql.error("select ts as t, diff(c4) from t1") + tdSql.query("select ts as t, diff(c5) from t1") + tdSql.checkRows(5) + tdSql.error("select ts as t, diff(c6) from t1") + tdSql.error("select ts as t, diff(t1) from t1") + tdSql.error("select ts as t, diff(c1, c2) from t1") + + tdSql.error("select ts as t, bottom(c1, 0) from t1") + tdSql.query("select ts as t, bottom(c1, 5) from t1") + tdSql.checkRows(5) + tdSql.checkCols(3) + for i in range(5): + data=tdSql.getData(i, 0) + tdSql.checkData(i, 1, data) + tdSql.query("select ts as t, bottom(c1, 5) from stb1") + tdSql.checkRows(5) + tdSql.query("select ts as t, bottom(c1, 5) from stb1 group by tbname") + tdSql.checkRows(500) + tdSql.query("select ts as t, bottom(c1, 8) from t1") + tdSql.checkRows(6) + tdSql.query("select ts as t, bottom(c2, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, bottom(c3, 5) from t1") + tdSql.error("select ts as t, bottom(c4, 5) from t1") + tdSql.query("select ts as t, bottom(c5, 8) from t1") + tdSql.checkRows(6) + tdSql.error("select ts as t, bottom(c6, 5) from t1") + tdSql.error("select ts as t, bottom(c5, 8) as b from t1 order by b") + tdSql.error("select ts as t, bottom(t1, 1) from t1") + tdSql.error("select ts as t, bottom(t1, 1) from stb1") + tdSql.error("select ts as t, bottom(t1, 3) from stb1 order by c3") + tdSql.error("select ts as t, bottom(t1, 3) from t1 order by c3") + + tdSql.error("select ts as t, top(c1, 0) from t1") tdSql.query("select ts as t, top(c1, 5) from t1") tdSql.checkRows(5) @@ -1011,15 +1129,15 @@ class TDTestCase: # self.td4082() # self.td4288() # self.td4724() - # self.td5798() # self.td5935() - self.td6068() + # self.td6068() # develop branch - # self.td4097() - # self.td4889() + self.td4097() + self.td4889() + self.td5798() # self.td5168() - # self.td5433() + self.td5433() def stop(self): tdSql.close() diff --git a/tests/pytest/import_merge/import_update_0.py b/tests/pytest/import_merge/import_update_0.py index 71f33c56704fdead8df07583dd105b00eb9e4a23..66e0d7d14420251a227e5f0c2bacec219273d032 100644 --- a/tests/pytest/import_merge/import_update_0.py +++ b/tests/pytest/import_merge/import_update_0.py @@ -55,7 +55,7 @@ class TDTestCase: tdSql.execute('''drop database if exists test_updata_0 ;''') # update 0 不更新 ; update 1 覆盖更新 ;update 2 合并更新 tdLog.info("========== test database updata = 0 ==========") - tdSql.execute('''create database test_updata_0 update 0 minrows 10 maxrows 200 ;''') + tdSql.execute('''create database test_updata_0 update 0 minrows 10 maxrows 200 keep 36500;''') tdSql.execute('''use test_updata_0;''') tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, diff --git a/tests/pytest/import_merge/import_update_1.py b/tests/pytest/import_merge/import_update_1.py index e72de2eb236a4190ec12fcc1315da849d5f21235..7edfd610c2e6eac6588ae78f81c939118845973d 100644 --- a/tests/pytest/import_merge/import_update_1.py +++ b/tests/pytest/import_merge/import_update_1.py @@ -55,7 +55,7 @@ class TDTestCase: tdSql.execute('''drop database if exists test_updata_1 ;''') # update 0 不更新 ; update 1 覆盖更新 ;update 2 合并更新 tdLog.info("========== test database updata = 1 ==========") - tdSql.execute('''create database test_updata_1 update 1 minrows 10 maxrows 200 ;''') + tdSql.execute('''create database test_updata_1 update 1 minrows 10 maxrows 200 keep 36500;''') tdSql.execute('''use test_updata_1;''') tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, diff --git a/tests/pytest/import_merge/import_update_2.py b/tests/pytest/import_merge/import_update_2.py index cfa3dbd26c0a0edfbd64d3d34b1bfa6ed23a266a..a0efe31ab25f68a898a124e0be22c369fedabf7f 100644 --- a/tests/pytest/import_merge/import_update_2.py +++ b/tests/pytest/import_merge/import_update_2.py @@ -55,7 +55,7 @@ class TDTestCase: tdSql.execute('''drop database if exists test_updata_2 ;''') # update 0 不更新 ; update 1 覆盖更新 ;update 2 合并更新 tdLog.info("========== test database updata = 2 ==========") - tdSql.execute('''create database test_updata_2 update 2 minrows 10 maxrows 200 ;''') + tdSql.execute('''create database test_updata_2 update 2 minrows 10 maxrows 200 keep 36500;''') tdSql.execute('''use test_updata_2;''') tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, diff --git a/tests/pytest/insert/insertJSONPayload.py b/tests/pytest/insert/insertJSONPayload.py index 30f34446a93237f9b7b610efc9b1b5507ba09f4a..88b03cf3f526a380a97acf2a45b86a2c64b66069 100644 --- a/tests/pytest/insert/insertJSONPayload.py +++ b/tests/pytest/insert/insertJSONPayload.py @@ -31,6 +31,27 @@ class TDTestCase: ### Default format ### + ### metric ### + print("============= step0 : test metric ================") + payload = ''' + { + "metric": ".stb.0.", + "timestamp": 1626006833610123, + "value": 10, + "tags": { + "t1": true, + "t2": false, + "t3": 10, + "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" + } + } + ''' + code = self._conn.insert_json_payload(payload) + print("insert_json_payload result {}".format(code)) + + tdSql.query("describe _stb_0_") + tdSql.checkRows(6) + ### metric value ### print("============= step1 : test metric value types ================") payload = ''' @@ -50,7 +71,7 @@ class TDTestCase: print("insert_json_payload result {}".format(code)) tdSql.query("describe stb0_0") - tdSql.checkData(1, 1, "FLOAT") + tdSql.checkData(1, 1, "BIGINT") payload = ''' { @@ -107,12 +128,52 @@ class TDTestCase: print("insert_json_payload result {}".format(code)) tdSql.query("describe stb0_3") - tdSql.checkData(1, 1, "NCHAR") + tdSql.checkData(1, 1, "BINARY") - ### timestamp 0 ### payload = ''' { "metric": "stb0_4", + "timestamp": 1626006833610123, + "value": 3.14, + "tags": { + "t1": true, + "t2": false, + "t3": 10, + "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" + } + } + ''' + code = self._conn.insert_json_payload(payload) + print("insert_json_payload result {}".format(code)) + + tdSql.query("describe stb0_4") + tdSql.checkData(1, 1, "DOUBLE") + + payload = ''' + { + "metric": "stb0_5", + "timestamp": 1626006833610123, + "value": 3.14E-2, + "tags": { + "t1": true, + "t2": false, + "t3": 10, + "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" + } + } + ''' + code = self._conn.insert_json_payload(payload) + print("insert_json_payload result {}".format(code)) + + tdSql.query("describe stb0_5") + tdSql.checkData(1, 1, "DOUBLE") + + + print("============= step2 : test timestamp ================") + ### timestamp 0 ### + payload = ''' + { + "metric": "stb0_6", "timestamp": 0, "value": 123, "tags": { @@ -127,14 +188,15 @@ class TDTestCase: print("insert_json_payload result {}".format(code)) + print("============= step3 : test tags ================") ### ID ### payload = ''' { - "metric": "stb0_5", + "metric": "stb0_7", "timestamp": 0, "value": 123, "tags": { - "ID": "tb0_5", + "ID": "tb0_7", "t1": true, "iD": "tb000", "t2": false, @@ -147,10 +209,60 @@ class TDTestCase: code = self._conn.insert_json_payload(payload) print("insert_json_payload result {}".format(code)) - tdSql.query("select tbname from stb0_5") - tdSql.checkData(0, 0, "tb0_5") + tdSql.query("select tbname from stb0_7") + tdSql.checkData(0, 0, "tb0_7") + + ### Default tag numeric types ### + payload = ''' + { + "metric": "stb0_8", + "timestamp": 0, + "value": 123, + "tags": { + "t1": 123 + } + } + ''' + code = self._conn.insert_json_payload(payload) + print("insert_json_payload result {}".format(code)) + + tdSql.query("describe stb0_8") + tdSql.checkData(2, 1, "BIGINT") + + payload = ''' + { + "metric": "stb0_9", + "timestamp": 0, + "value": 123, + "tags": { + "t1": 123.00 + } + } + ''' + code = self._conn.insert_json_payload(payload) + print("insert_json_payload result {}".format(code)) + + tdSql.query("describe stb0_9") + tdSql.checkData(2, 1, "DOUBLE") + + payload = ''' + { + "metric": "stb0_10", + "timestamp": 0, + "value": 123, + "tags": { + "t1": 123E-1 + } + } + ''' + code = self._conn.insert_json_payload(payload) + print("insert_json_payload result {}".format(code)) + + tdSql.query("describe stb0_10") + tdSql.checkData(2, 1, "DOUBLE") ### Nested format ### + print("============= step4 : test nested format ================") ### timestamp ### #seconds payload = ''' diff --git a/tests/pytest/insert/insertTelnetLines.py b/tests/pytest/insert/insertTelnetLines.py index 8ebb6bd3df4bcd4abfbb8c42cf5024fe066fcce3..b47a74249bbad57ef758e886c513a7eea78b7634 100644 --- a/tests/pytest/insert/insertTelnetLines.py +++ b/tests/pytest/insert/insertTelnetLines.py @@ -33,16 +33,17 @@ class TDTestCase: ### metric ### print("============= step1 : test metric ================") lines0 = [ - "stb0_0 1626006833639000000ns 4i8 host=\"host0\",interface=\"eth0\"", - "stb0_1 1626006833639000000ns 4i8 host=\"host0\",interface=\"eth0\"", - "stb0_2 1626006833639000000ns 4i8 host=\"host0\",interface=\"eth0\"", + "stb0_0 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", + "stb0_1 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", + "stb0_2 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", + ".stb0.3. 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"", ] code = self._conn.insert_telnet_lines(lines0) print("insert_telnet_lines result {}".format(code)) tdSql.query("show stables") - tdSql.checkRows(3) + tdSql.checkRows(4) tdSql.query("describe stb0_0") tdSql.checkRows(4) @@ -53,6 +54,9 @@ class TDTestCase: tdSql.query("describe stb0_2") tdSql.checkRows(4) + tdSql.query("describe _stb0_3_") + tdSql.checkRows(4) + ### timestamp ### print("============= step2 : test timestamp ================") lines1 = [ @@ -122,14 +126,15 @@ class TDTestCase: #bigint lines2_3 = [ "stb2_3 1626006833651ms -9223372036854775807i64 host=\"host0\"", - "stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"" + "stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\"", + "stb2_3 1626006833662ms 9223372036854775807 host=\"host0\"" ] code = self._conn.insert_telnet_lines(lines2_3) print("insert_telnet_lines result {}".format(code)) tdSql.query("select * from stb2_3") - tdSql.checkRows(2) + tdSql.checkRows(3) tdSql.query("describe stb2_3") tdSql.checkRows(3) @@ -145,7 +150,6 @@ class TDTestCase: "stb2_4 1626006833660ms -3.4e10f32 host=\"host0\"", "stb2_4 1626006833670ms 3.4E+2f32 host=\"host0\"", "stb2_4 1626006833680ms -3.4e-2f32 host=\"host0\"", - "stb2_4 1626006833690ms 3.15 host=\"host0\"", "stb2_4 1626006833700ms 3.4E38f32 host=\"host0\"", "stb2_4 1626006833710ms -3.4E38f32 host=\"host0\"" ] @@ -154,7 +158,7 @@ class TDTestCase: print("insert_telnet_lines result {}".format(code)) tdSql.query("select * from stb2_4") - tdSql.checkRows(11) + tdSql.checkRows(10) tdSql.query("describe stb2_4") tdSql.checkRows(3) @@ -171,14 +175,15 @@ class TDTestCase: "stb2_5 1626006833670ms 3.4E+2f64 host=\"host0\"", "stb2_5 1626006833680ms -3.4e-2f64 host=\"host0\"", "stb2_5 1626006833690ms 1.7E308f64 host=\"host0\"", - "stb2_5 1626006833700ms -1.7E308f64 host=\"host0\"" + "stb2_5 1626006833700ms -1.7E308f64 host=\"host0\"", + "stb2_5 1626006833710ms 3.15 host=\"host0\"" ] code = self._conn.insert_telnet_lines(lines2_5) print("insert_telnet_lines result {}".format(code)) tdSql.query("select * from stb2_5") - tdSql.checkRows(10) + tdSql.checkRows(11) tdSql.query("describe stb2_5") tdSql.checkRows(3) @@ -245,8 +250,8 @@ class TDTestCase: print("============= step3 : test tags ================") #tag value types lines3_0 = [ - "stb3_0 1626006833610ms 1 t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=3.4E38f32,t6=1.7E308f64,t7=true,t8=\"binary_val_1\",t9=L\"标签值1\"", - "stb3_0 1626006833610ms 2 t1=-127i8,t2=-32767i16,t3=-2147483647i32,t4=-9223372036854775807i64,t5=-3.4E38f32,t6=-1.7E308f64,t7=false,t8=\"binary_val_2\",t9=L\"标签值2\"" + "stb3_0 1626006833610ms 1 t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=3.4E38f32 t6=1.7E308f64 t7=true t8=\"binary_val_1\" t9=L\"标签值1\"", + "stb3_0 1626006833610ms 2 t1=-127i8 t2=-32767i16 t3=-2147483647i32 t4=-9223372036854775807i64 t5=-3.4E38f32 t6=-1.7E308f64 t7=false t8=\"binary_val_2\" t9=L\"标签值2\"" ] code = self._conn.insert_telnet_lines(lines3_0) @@ -288,9 +293,9 @@ class TDTestCase: #tag ID as child table name lines3_1 = [ - "stb3_1 1626006833610ms 1 id=\"child_table1\",host=\"host1\"", - "stb3_1 1626006833610ms 2 host=\"host2\",iD=\"child_table2\"", - "stb3_1 1626006833610ms 3 ID=\"child_table3\",host=\"host3\"" + "stb3_1 1626006833610ms 1 id=\"child_table1\" host=\"host1\"", + "stb3_1 1626006833610ms 2 host=\"host2\" iD=\"child_table2\"", + "stb3_1 1626006833610ms 3 ID=\"child_table3\" host=\"host3\"" ] code = self._conn.insert_telnet_lines(lines3_1) diff --git a/tests/pytest/insert/openTsdbTelnetLinesInsert.py b/tests/pytest/insert/openTsdbTelnetLinesInsert.py index 25518437e102c985b4d84887b1806f9e341c86d6..26d25941950602978334da0234aa40ce3d4a6c3b 100644 --- a/tests/pytest/insert/openTsdbTelnetLinesInsert.py +++ b/tests/pytest/insert/openTsdbTelnetLinesInsert.py @@ -13,9 +13,8 @@ import traceback import random -from taos.error import LinesError +from taos.error import TelnetLinesError import time -from copy import deepcopy import numpy as np from util.log import * from util.cases import * @@ -39,13 +38,13 @@ class TDTestCase: tdSql.execute(f'use {name}') def timeTrans(self, time_value): - if time_value.endswith("ns"): + if time_value.lower().endswith("ns"): ts = int(''.join(list(filter(str.isdigit, time_value))))/1000000000 - elif time_value.endswith("us") or time_value.isdigit() and int(time_value) != 0: + elif time_value.lower().endswith("us") or time_value.isdigit() and int(time_value) != 0: ts = int(''.join(list(filter(str.isdigit, time_value))))/1000000 - elif time_value.endswith("ms"): + elif time_value.lower().endswith("ms"): ts = int(''.join(list(filter(str.isdigit, time_value))))/1000 - elif time_value.endswith("s") and list(time_value)[-1] not in "num": + elif time_value.lower().endswith("s") and list(time_value)[-1] not in "num": ts = int(''.join(list(filter(str.isdigit, time_value))))/1 elif int(time_value) == 0: ts = time.time() @@ -68,43 +67,49 @@ class TDTestCase: return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) def getTdTypeValue(self, value): - if value.endswith("i8"): + if value.lower().endswith("i8"): td_type = "TINYINT" td_tag_value = ''.join(list(value)[:-2]) - elif value.endswith("i16"): + elif value.lower().endswith("i16"): td_type = "SMALLINT" td_tag_value = ''.join(list(value)[:-3]) - elif value.endswith("i32"): + elif value.lower().endswith("i32"): td_type = "INT" td_tag_value = ''.join(list(value)[:-3]) - elif value.endswith("i64"): + elif value.lower().endswith("i64"): td_type = "BIGINT" td_tag_value = ''.join(list(value)[:-3]) - elif value.endswith("u64"): + elif value.lower().endswith("u64"): td_type = "BIGINT UNSIGNED" td_tag_value = ''.join(list(value)[:-3]) - elif value.endswith("f32"): + elif value.lower().endswith("f32"): td_type = "FLOAT" td_tag_value = ''.join(list(value)[:-3]) td_tag_value = '{}'.format(np.float32(td_tag_value)) - elif value.endswith("f64"): + elif value.lower().endswith("f64"): td_type = "DOUBLE" td_tag_value = ''.join(list(value)[:-3]) - elif value.startswith('L"'): + elif value.lower().startswith('l"'): td_type = "NCHAR" td_tag_value = ''.join(list(value)[2:-1]) elif value.startswith('"') and value.endswith('"'): td_type = "BINARY" td_tag_value = ''.join(list(value)[1:-1]) - elif value.lower() == "t" or value == "true" or value == "True" or value == "TRUE": + elif value.lower() == "t" or value.lower() == "true": td_type = "BOOL" td_tag_value = "True" - elif value.lower() == "f" or value == "false" or value == "False" or value == "FALSE": + elif value.lower() == "f" or value.lower() == "false": td_type = "BOOL" td_tag_value = "False" - else: - td_type = "FLOAT" + elif value.isdigit(): + td_type = "BIGINT" td_tag_value = value + else: + td_type = "DOUBLE" + if "e" in value.lower(): + td_tag_value = str(float(value)) + else: + td_tag_value = value return td_type, td_tag_value def typeTrans(self, type_list): @@ -137,9 +142,7 @@ class TDTestCase: def inputHandle(self, input_sql): input_sql_split_list = input_sql.split(" ") stb_name = input_sql_split_list[0] - - #'stb2_5 1626006833610ms 3f64 host="host0"', - stb_tag_list = input_sql_split_list[3].split(',') + stb_tag_list = input_sql_split_list[3:] stb_col_value = input_sql_split_list[2] ts_value = self.timeTrans(input_sql_split_list[1]) @@ -190,7 +193,7 @@ class TDTestCase: t8="L\"ncharTagValue\"", ts="1626006833639000000ns", id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_double_tag=None, t_add_tag=None, t_mul_tag=None, t_multi_tag=None, c_blank_tag=None, t_blank_tag=None, - chinese_tag=None, multi_field_tag=None): + chinese_tag=None, multi_field_tag=None, point_trans_tag=None): if stb_name == "": stb_name = tdCom.getLongName(len=6, mode="letters") if tb_name == "": @@ -203,31 +206,33 @@ class TDTestCase: id = "ID" else: id = "id" - sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8}' + sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}\" t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}' if id_noexist_tag is not None: - sql_seq = f'{stb_name} {ts} {value} t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8}' + sql_seq = f'{stb_name} {ts} {value} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}' if t_add_tag is not None: - sql_seq = f'{stb_name} {ts} {value} t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t9={t8}' + sql_seq = f'{stb_name} {ts} {value} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8} t9={t8}' if id_change_tag is not None: - sql_seq = f'{stb_name} {ts} {value} t0={t0},{id}=\"{tb_name}\",t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8}' + sql_seq = f'{stb_name} {ts} {value} t0={t0} {id}=\"{tb_name}\" t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}' if id_double_tag is not None: - sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}_1\",t0={t0},t1={t1},{id}=\"{tb_name}_2\",t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8}' + sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}_1\" t0={t0} t1={t1} {id}=\"{tb_name}_2\" t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}' if t_add_tag is not None: - sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8},t11={t1},t10={t8}' + sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}\" t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8} t11={t1} t10={t8}' if t_mul_tag is not None: - sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6}' + sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}\" t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6}' if id_noexist_tag is not None: - sql_seq = f'{stb_name} {ts} {value} t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6}' + sql_seq = f'{stb_name} {ts} {value} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6}' if t_multi_tag is not None: - sql_seq = f'{stb_name} {ts} {value},{value} {id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6}' + sql_seq = f'{stb_name} {ts} {value} {value} {id}=\"{tb_name}\" t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6}' if c_blank_tag is not None: - sql_seq = f'{stb_name} {ts} {id}=\"{tb_name}\",t0={t0},t1={t1},t2={t2},t3={t3},t4={t4},t5={t5},t6={t6},t7={t7},t8={t8}' + sql_seq = f'{stb_name} {ts} {id}=\"{tb_name}\" t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}' if t_blank_tag is not None: sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}\"' if chinese_tag is not None: - sql_seq = f'{stb_name} {ts} L"涛思数据" t0={t0},t1=L"涛思数据"' + sql_seq = f'{stb_name} {ts} L"涛思数据" t0={t0} t1=L"涛思数据"' if multi_field_tag is not None: - sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}\",t0={t0} t1={t1}' + sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}\" t0={t0} {value}' + if point_trans_tag is not None: + sql_seq = f'point.trans.test {ts} {value} t0={t0}' return sql_seq, stb_name def genMulTagColStr(self, genType, count=1): @@ -239,7 +244,7 @@ class TDTestCase: if genType == "tag": for i in range(0, count): if i < (count-1): - tag_str += f't{i}=f,' + tag_str += f't{i}=f ' else: tag_str += f't{i}=f' return tag_str @@ -253,7 +258,7 @@ class TDTestCase: tag_str = self.genMulTagColStr("tag", tag_count) col_str = self.genMulTagColStr("col") ts = "1626006833640000000ns" - long_sql = stb_name + ' ' + ts + ' ' + col_str + ' ' + f'id=\"{tb_name}\"' + ',' + tag_str + long_sql = stb_name + ' ' + ts + ' ' + col_str + ' ' + f'id=\"{tb_name}\"' + ' ' + tag_str return long_sql, stb_name def getNoIdTbName(self, stb_name): @@ -299,7 +304,6 @@ class TDTestCase: tdSql.checkEqual(res_field_list_without_ts, expect_list[1]) for i in range(len(res_type_list)): tdSql.checkEqual(res_type_list[i], expect_list[2][i]) - # tdSql.checkEqual(res_type_list, expect_list[2]) def initCheckCase(self): """ @@ -328,19 +332,16 @@ class TDTestCase: binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"' ''' tdCom.cleanTb() - binary_symbols = '"aaa"' - # binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"' + binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"' nchar_symbols = f'L{binary_symbols}' input_sql1, stb_name1 = self.genFullTypeSql(value=binary_symbols, t7=binary_symbols, t8=nchar_symbols) - - # input_sql2, stb_name2 = self.genFullTypeSql(value=nchar_symbols, t7=binary_symbols, t8=nchar_symbols) + input_sql2, stb_name2 = self.genFullTypeSql(value=nchar_symbols, t7=binary_symbols, t8=nchar_symbols) self.resCmp(input_sql1, stb_name1) - # self.resCmp(input_sql2, stb_name2) + self.resCmp(input_sql2, stb_name2) def tsCheckCase(self): """ test ts list --> ["1626006833639000000ns", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022"] - # ! us级时间戳都为0时,数据库中查询显示,但python接口拿到的结果不显示 .000000的情况请确认,目前修改时间处理代码可以通过 """ tdCom.cleanTb() ts_list = ["1626006833639000000ns", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022", 0] @@ -393,9 +394,10 @@ class TDTestCase: tdCom.cleanTb() try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass - + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) + def idIllegalNameCheckCase(self): """ test illegal id name @@ -407,8 +409,9 @@ class TDTestCase: input_sql = self.genFullTypeSql(tb_name=f"\"aaa{i}bbb\"")[0] try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) def idStartWithNumCheckCase(self): """ @@ -418,8 +421,9 @@ class TDTestCase: input_sql = self.genFullTypeSql(tb_name=f"\"1aaabbb\"")[0] try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) def nowTsCheckCase(self): """ @@ -429,8 +433,9 @@ class TDTestCase: input_sql = self.genFullTypeSql(ts="now")[0] try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) def dateFormatTsCheckCase(self): """ @@ -440,8 +445,9 @@ class TDTestCase: input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0] try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) def illegalTsCheckCase(self): """ @@ -451,8 +457,9 @@ class TDTestCase: input_sql = self.genFullTypeSql(ts="16260068336390us19")[0] try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) def tagValueLengthCheckCase(self): """ @@ -467,8 +474,9 @@ class TDTestCase: input_sql = self.genFullTypeSql(t1=t1)[0] try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) #i16 for t2 in ["-32767i16", "32767i16"]: @@ -478,8 +486,9 @@ class TDTestCase: input_sql = self.genFullTypeSql(t2=t2)[0] try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) #i32 for t3 in ["-2147483647i32", "2147483647i32"]: @@ -489,8 +498,9 @@ class TDTestCase: input_sql = self.genFullTypeSql(t3=t3)[0] try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) #i64 for t4 in ["-9223372036854775807i64", "9223372036854775807i64"]: @@ -500,8 +510,9 @@ class TDTestCase: input_sql = self.genFullTypeSql(t4=t4)[0] try: self._conn.insert_telnet_lines([input_sql]) - except LinesError: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) # f32 for t5 in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: @@ -513,7 +524,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) @@ -527,32 +538,31 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) # binary stb_name = tdCom.getLongName(7, "letters") - input_sql = f'{stb_name} 1626006833639000000ns t t0=t,t1="{tdCom.getLongName(16374, "letters")}"' + input_sql = f'{stb_name} 1626006833639000000ns t t0=t t1="{tdCom.getLongName(16374, "letters")}"' self._conn.insert_telnet_lines([input_sql]) - input_sql = f'{stb_name} 1626006833639000000ns t t0=t,t1="{tdCom.getLongName(16375, "letters")}"' + input_sql = f'{stb_name} 1626006833639000000ns t t0=t t1="{tdCom.getLongName(16375, "letters")}"' try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: - pass - + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) # nchar # * legal nchar could not be larger than 16374/4 stb_name = tdCom.getLongName(7, "letters") - input_sql = f'{stb_name} 1626006833639000000ns t t0=t,t1=L"{tdCom.getLongName(4093, "letters")}"' + input_sql = f'{stb_name} 1626006833639000000ns t t0=t t1=L"{tdCom.getLongName(4093, "letters")}"' self._conn.insert_telnet_lines([input_sql]) - input_sql = f'{stb_name} 1626006833639000000ns t t0=t,t1=L"{tdCom.getLongName(4094, "letters")}"' + input_sql = f'{stb_name} 1626006833639000000ns t t0=t t1=L"{tdCom.getLongName(4094, "letters")}"' try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) def colValueLengthCheckCase(self): @@ -570,7 +580,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) # i16 tdCom.cleanTb() @@ -583,7 +593,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) # i32 @@ -597,7 +607,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) # i64 @@ -611,7 +621,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) # f32 @@ -626,7 +636,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) # f64 @@ -641,7 +651,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) # # binary @@ -655,7 +665,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) # nchar @@ -670,7 +680,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) def tagColIllegalValueCheckCase(self): @@ -681,18 +691,10 @@ class TDTestCase: tdCom.cleanTb() # bool for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]: - input_sql1 = self.genFullTypeSql(t0=i)[0] - try: - self._conn.insert_telnet_lines([input_sql1]) - raise Exception("should not reach here") - except LinesError as err: - tdSql.checkNotEqual(err.errno, 0) - input_sql2 = self.genFullTypeSql(value=i)[0] - try: - self._conn.insert_telnet_lines([input_sql2]) - raise Exception("should not reach here") - except LinesError as err: - tdSql.checkNotEqual(err.errno, 0) + input_sql1, stb_name = self.genFullTypeSql(t0=i) + self.resCmp(input_sql1, stb_name) + input_sql2, stb_name = self.genFullTypeSql(value=i) + self.resCmp(input_sql2, stb_name) # i8 i16 i32 i64 f32 f64 for input_sql in [ @@ -706,7 +708,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) # check binary and nchar blank @@ -717,17 +719,39 @@ class TDTestCase: for input_sql in [input_sql1, input_sql2, input_sql3, input_sql4]: try: self._conn.insert_telnet_lines([input_sql]) - except LinesError as err: - pass + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) # check accepted binary and nchar symbols # # * ~!@#$¥%^&*()-+={}|[]、「」:; for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): input_sql1 = f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns "abc{symbol}aaa" t0=t' - input_sql2 = f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns t t0=t,t1="abc{symbol}aaa"' + input_sql2 = f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns t t0=t t1="abc{symbol}aaa"' self._conn.insert_telnet_lines([input_sql1]) self._conn.insert_telnet_lines([input_sql2]) - + + def blankCheckCase(self): + ''' + check blank case + ''' + tdCom.cleanTb() + input_sql_list = [f'{tdCom.getLongName(7, "letters")} {tdCom.getLongName(7, "letters")} 1626006833639000000ns "abcaaa" t0=t', + f'{tdCom.getLongName(7, "letters")} 16260068336 39000000ns L"bcdaaa" t1=f', + f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns t t0="abc aaa"', + f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns t t0=L"abc aaa"', + f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns "abc aaa" t0=L"abcaaa"', + f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns L"abc aaa" t0=L"abcaaa"', + f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns L"abaaa" t0=L"abcaaa1"', + f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns L"abaaa" t0=L"abcaaa2"', + f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns L"abaaa" t0=t t1="abc t2="taa""', + f'{tdCom.getLongName(7, "letters")} 1626006833639000000ns L"abaaa" t0=L"abcaaa3"'] + for input_sql in input_sql_list: + try: + self._conn.insert_telnet_lines([input_sql]) + raise Exception("should not reach here") + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) def duplicateIdTagColInsertCheckCase(self): """ @@ -738,7 +762,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql_id]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) input_sql = self.genFullTypeSql()[0] @@ -746,7 +770,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql_tag]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) ##### stb exist ##### @@ -762,7 +786,6 @@ class TDTestCase: self.resCmp(input_sql, stb_name, condition='where tbname like "t_%"') tdSql.query(f"select * from {stb_name}") tdSql.checkRows(2) - # TODO cover other case def duplicateInsertExistCheckCase(self): """ @@ -857,21 +880,21 @@ class TDTestCase: stb_name = tdCom.getLongName(7, "letters") tb_name = f'{stb_name}_1' - input_sql = f'{stb_name} 1626006833639000000ns f id="{tb_name}",t0=t' + input_sql = f'{stb_name} 1626006833639000000ns f id="{tb_name}" t0=t' self._conn.insert_telnet_lines([input_sql]) # * 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} 1626006833639000000ns f t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(5, "letters")}"' + input_sql = f'{stb_name} 1626006833639000000ns f t0=t t1="{tdCom.getLongName(16374, "letters")}" t2="{tdCom.getLongName(5, "letters")}"' self._conn.insert_telnet_lines([input_sql]) tdSql.query(f"select * from {stb_name}") tdSql.checkRows(2) - input_sql = f'{stb_name} 1626006833639000000ns f t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(6, "letters")}"' + input_sql = f'{stb_name} 1626006833639000000ns f t0=t t1="{tdCom.getLongName(16374, "letters")}" t2="{tdCom.getLongName(6, "letters")}"' try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError: - pass + except TelnetLinesError as err: + tdSql.checkNotEqual(err.errno, 0) tdSql.query(f"select * from {stb_name}") tdSql.checkRows(2) @@ -883,19 +906,19 @@ class TDTestCase: tdCom.cleanTb() stb_name = tdCom.getLongName(7, "letters") tb_name = f'{stb_name}_1' - input_sql = f'{stb_name} 1626006833639000000ns f id="{tb_name}",t0=t' + input_sql = f'{stb_name} 1626006833639000000ns f id="{tb_name}" t0=t' self._conn.insert_telnet_lines([input_sql]) # * legal nchar could not be larger than 16374/4 - input_sql = f'{stb_name} 1626006833639000000ns f t0=t,t1=L"{tdCom.getLongName(4093, "letters")}",t2=L"{tdCom.getLongName(1, "letters")}"' + input_sql = f'{stb_name} 1626006833639000000ns f t0=t t1=L"{tdCom.getLongName(4093, "letters")}" t2=L"{tdCom.getLongName(1, "letters")}"' self._conn.insert_telnet_lines([input_sql]) tdSql.query(f"select * from {stb_name}") tdSql.checkRows(2) - input_sql = f'{stb_name} 1626006833639000000ns f t0=t,t1=L"{tdCom.getLongName(4093, "letters")}",t2=L"{tdCom.getLongName(2, "letters")}"' + input_sql = f'{stb_name} 1626006833639000000ns f t0=t t1=L"{tdCom.getLongName(4093, "letters")}" t2=L"{tdCom.getLongName(2, "letters")}"' try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) tdSql.query(f"select * from {stb_name}") tdSql.checkRows(2) @@ -908,15 +931,15 @@ class TDTestCase: stb_name = tdCom.getLongName(8, "letters") tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') - lines = ["st123456 1626006833639000000ns 1i64 t1=3i64,t2=4f64,t3=\"t3\"", - "st123456 1626006833640000000ns 2i64 t1=4i64,t3=\"t4\",t2=5f64,t4=5f64", - f'{stb_name} 1626056811823316532ns 3i64 t2=5f64,t3=L\"ste\"', - "stf567890 1626006933640000000ns 4i64 t1=4i64,t3=\"t4\",t2=5f64,t4=5f64", - "st123456 1626006833642000000ns 5i64 t1=4i64,t2=5f64,t3=\"t4\"", - f'{stb_name} 1626056811843316532ns 6i64 t2=5f64,t3=L\"ste2\"', - f'{stb_name} 1626056812843316532ns 7i64 t2=5f64,t3=L\"ste2\"', - "st123456 1626006933640000000ns 8i64 t1=4i64,t3=\"t4\",t2=5f64,t4=5f64", - "st123456 1626006933641000000ns 9i64 t1=4i64,t3=\"t4\",t2=5f64,t4=5f64" + lines = ["st123456 1626006833639000000ns 1i64 t1=3i64 t2=4f64 t3=\"t3\"", + "st123456 1626006833640000000ns 2i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64", + f'{stb_name} 1626056811823316532ns 3i64 t2=5f64 t3=L\"ste\"', + "stf567890 1626006933640000000ns 4i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64", + "st123456 1626006833642000000ns 5i64 t1=4i64 t2=5f64 t3=\"t4\"", + f'{stb_name} 1626056811843316532ns 6i64 t2=5f64 t3=L\"ste2\"', + f'{stb_name} 1626056812843316532ns 7i64 t2=5f64 t3=L\"ste2\"', + "st123456 1626006933640000000ns 8i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64", + "st123456 1626006933641000000ns 9i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64" ] self._conn.insert_telnet_lines(lines) tdSql.query('show stables') @@ -939,7 +962,7 @@ class TDTestCase: sql_list.append(input_sql) self._conn.insert_telnet_lines(sql_list) tdSql.query('show tables') - tdSql.checkRows(1000) + tdSql.checkRows(count) def batchErrorInsertCheckCase(self): """ @@ -947,12 +970,12 @@ class TDTestCase: """ tdCom.cleanTb() stb_name = tdCom.getLongName(8, "letters") - lines = ["st123456 1626006833639000000ns 3i64 t1=3i64,t2=4f64,t3=\"t3\"", - f"{stb_name} 1626056811823316532ns tRue t2=5f64,t3=L\"ste\""] + lines = ["st123456 1626006833639000000ns 3i 64 t1=3i64 t2=4f64 t3=\"t3\"", + f"{stb_name} 1626056811823316532ns tRue t2=5f64 t3=L\"ste\""] try: self._conn.insert_telnet_lines(lines) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) def multiColsInsertCheckCase(self): @@ -964,7 +987,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) def blankColInsertCheckCase(self): @@ -976,7 +999,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) def blankTagInsertCheckCase(self): @@ -988,7 +1011,7 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) def chineseCheckCase(self): @@ -1008,24 +1031,45 @@ class TDTestCase: try: self._conn.insert_telnet_lines([input_sql]) raise Exception("should not reach here") - except LinesError as err: + except TelnetLinesError as err: tdSql.checkNotEqual(err.errno, 0) def errorTypeCheckCase(self): stb_name = tdCom.getLongName(8, "letters") - input_sql_list = [f'{stb_name} 0 "hkgjiwdj" t0=f,t1=127I8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vozamcts",t8=L"ncharTagValue"', \ - f'{stb_name} 0 "hkgjiwdj" t0=f,t1=127i8,t2=32767I16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vozamcts",t8=L"ncharTagValue"', \ - f'{stb_name} 0 "hkgjiwdj" t0=f,t1=127i8,t2=32767i16,t3=2147483647I32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vozamcts",t8=L"ncharTagValue"', \ - f'{stb_name} 0 "hkgjiwdj" t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807I64,t5=11.12345f32,t6=22.123456789f64,t7="vozamcts",t8=L"ncharTagValue"', \ - f'{stb_name} 0 "hkgjiwdj" t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345F32,t6=22.123456789f64,t7="vozamcts",t8=L"ncharTagValue"', \ - f'{stb_name} 0 "hkgjiwdj" t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789F64,t7="vozamcts",t8=L"ncharTagValue"', \ - f'{stb_name} 1626006833639000000NS "hkgjiwdj" t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vozamcts",t8=L"ncharTagValue"'] + input_sql_list = [f'{stb_name}_1 1626006833639000000Ns "hkgjiwdj" t0=f t1=127I8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_2 1626006833639000001nS "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_3 1626006833639000002NS "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_4 1626006833639019Us "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647I32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_5 1626006833639018uS "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807I64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_6 1626006833639017US "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807I64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_7 1626006833640Ms "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789F64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_8 1626006833641mS "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_9 1626006833642MS "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_10 1626006834S "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=l"ncharTagValue"', \ + f'{stb_name}_11 1626006834S "hkgjiwdj" t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"'] for input_sql in input_sql_list: - try: - self._conn.insert_telnet_lines([input_sql]) - raise Exception("should not reach here") - except LinesError as err: - tdSql.checkNotEqual(err.errno, 0) + stb_name = input_sql.split(" ")[0] + self.resCmp(input_sql, stb_name) + + def pointTransCheckCase(self): + """ + metric value "." trans to "_" + """ + tdCom.cleanTb() + input_sql = self.genFullTypeSql(point_trans_tag=True)[0] + stb_name = input_sql.split(" ")[0].replace(".", "_") + self.resCmp(input_sql, stb_name) + + def defaultTypeCheckCase(self): + stb_name = tdCom.getLongName(8, "letters") + input_sql_list = [f'{stb_name}_1 1626006833639000000Ns 9223372036854775807 t0=f t1=127 t2=32767i16 t3=2147483647i32 t4=9223372036854775807 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_2 1626006834S 22.123456789 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_3 1626006834S 10e5 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=10e5 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_4 1626006834S 10.0e5 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=10.0e5 t7="vozamcts" t8=L"ncharTagValue"', \ + f'{stb_name}_5 1626006834S -10.0e5 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=-10.0e5 t7="vozamcts" t8=L"ncharTagValue"'] + for input_sql in input_sql_list: + stb_name = input_sql.split(" ")[0] + self.resCmp(input_sql, stb_name) def genSqlList(self, count=5, stb_name="", tb_name=""): """ @@ -1166,11 +1210,11 @@ class TDTestCase: tdCom.cleanTb() input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) - s_stb_d_tb_m_tag_list = [(f'{stb_name} 1626006833639000000ns "omfdhyom" t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'yzwswz'), \ - (f'{stb_name} 1626006833639000000ns "vqowydbc" t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'yzwswz'), \ - (f'{stb_name} 1626006833639000000ns "plgkckpv" t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'yzwswz'), \ - (f'{stb_name} 1626006833639000000ns "cujyqvlj" t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'yzwswz'), \ - (f'{stb_name} 1626006833639000000ns "twjxisat" t0=T,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'yzwswz')] + s_stb_d_tb_m_tag_list = [(f'{stb_name} 1626006833639000000ns "omfdhyom" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'), \ + (f'{stb_name} 1626006833639000000ns "vqowydbc" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'), \ + (f'{stb_name} 1626006833639000000ns "plgkckpv" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'), \ + (f'{stb_name} 1626006833639000000ns "cujyqvlj" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'), \ + (f'{stb_name} 1626006833639000000ns "twjxisat" t0=T t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_m_tag_list)) tdSql.query(f"show tables;") tdSql.checkRows(3) @@ -1195,11 +1239,11 @@ class TDTestCase: tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) - s_stb_s_tb_d_ts_list = [(f'{stb_name} 0 "hkgjiwdj" id="{tb_name}",t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vozamcts",t8=L"ncharTagValue"', 'dwpthv'), \ - (f'{stb_name} 0 "rljjrrul" id="{tb_name}",t0=False,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="bmcanhbs",t8=L"ncharTagValue"', 'dwpthv'), \ - (f'{stb_name} 0 "basanglx" id="{tb_name}",t0=False,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="enqkyvmb",t8=L"ncharTagValue"', 'dwpthv'), \ - (f'{stb_name} 0 "clsajzpp" id="{tb_name}",t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="eivaegjk",t8=L"ncharTagValue"', 'dwpthv'), \ - (f'{stb_name} 0 "jitwseso" id="{tb_name}",t0=T,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="yhlwkddq",t8=L"ncharTagValue"', 'dwpthv')] + s_stb_s_tb_d_ts_list = [(f'{stb_name} 0 "hkgjiwdj" id="{tb_name}" t0=f t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', 'dwpthv'), \ + (f'{stb_name} 0 "rljjrrul" id="{tb_name}" t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="bmcanhbs" t8=L"ncharTagValue"', 'dwpthv'), \ + (f'{stb_name} 0 "basanglx" id="{tb_name}" t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="enqkyvmb" t8=L"ncharTagValue"', 'dwpthv'), \ + (f'{stb_name} 0 "clsajzpp" id="{tb_name}" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="eivaegjk" t8=L"ncharTagValue"', 'dwpthv'), \ + (f'{stb_name} 0 "jitwseso" id="{tb_name}" t0=T t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="yhlwkddq" t8=L"ncharTagValue"', 'dwpthv')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_list)) tdSql.query(f"show tables;") tdSql.checkRows(1) @@ -1231,11 +1275,11 @@ class TDTestCase: tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) - s_stb_s_tb_d_ts_a_tag_list = [(f'{stb_name} 0 "clummqfy" id="{tb_name}",t0=False,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="hpxzrdiw",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue"', 'bokaxl'), \ - (f'{stb_name} 0 "yqeztggb" id="{tb_name}",t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="gdtblmrc",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue"', 'bokaxl'), \ - (f'{stb_name} 0 "gbkinqdk" id="{tb_name}",t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="iqniuvco",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue"', 'bokaxl'), \ - (f'{stb_name} 0 "ldxxejbd" id="{tb_name}",t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="vxkipags",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue"', 'bokaxl'), \ - (f'{stb_name} 0 "tlvzwjes" id="{tb_name}",t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="enwrlrtj",t8=L"ncharTagValue",t11=127i8,t10=L"ncharTagValue"', 'bokaxl')] + s_stb_s_tb_d_ts_a_tag_list = [(f'{stb_name} 0 "clummqfy" id="{tb_name}" t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="hpxzrdiw" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl'), \ + (f'{stb_name} 0 "yqeztggb" id="{tb_name}" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="gdtblmrc" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl'), \ + (f'{stb_name} 0 "gbkinqdk" id="{tb_name}" t0=f t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="iqniuvco" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl'), \ + (f'{stb_name} 0 "ldxxejbd" id="{tb_name}" t0=f t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vxkipags" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl'), \ + (f'{stb_name} 0 "tlvzwjes" id="{tb_name}" t0=true t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="enwrlrtj" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_tag_list)) tdSql.query(f"show tables;") tdSql.checkRows(1) @@ -1264,44 +1308,31 @@ class TDTestCase: tdCom.cleanTb() input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) - s_stb_d_tb_d_ts_m_tag_list = [(f'{stb_name} 0 "mnpmtzul" t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'pcppkg'), \ - (f'{stb_name} 0 "zbvwckcd" t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'pcppkg'), \ - (f'{stb_name} 0 "vymcjfwc" t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'pcppkg'), \ - (f'{stb_name} 0 "laumkwfn" t0=False,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'pcppkg'), \ - (f'{stb_name} 0 "nyultzxr" t0=false,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64', 'pcppkg')] + s_stb_d_tb_d_ts_m_tag_list = [(f'{stb_name} 0 "mnpmtzul" t0=f t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \ + (f'{stb_name} 0 "zbvwckcd" t0=True t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \ + (f'{stb_name} 0 "vymcjfwc" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \ + (f'{stb_name} 0 "laumkwfn" t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \ + (f'{stb_name} 0 "nyultzxr" t0=false t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg')] self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_m_tag_list)) tdSql.query(f"show tables;") tdSql.checkRows(3) def test(self): - # input_sql1 = "stb2_5 1626006833610ms 3f64 host=\"host0\",host2=L\"host2\"" - # input_sql2 = "rfasta,id=\"rfasta_1\",t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64 c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64 1626006933640000000ns" try: - input_sql = f'test_nchar 0 L"涛思数据" t0=f,t1=L"涛思数据",t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64' + input_sql = f'test_nchar 0 L"涛思数据" t0=f t1=L"涛思数据" t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64' self._conn.insert_telnet_lines([input_sql]) - # input_sql, stb_name = self.genFullTypeSql() - # self.resCmp(input_sql, stb_name) - except LinesError as err: + except TelnetLinesError as err: print(err.errno) - # self._conn.insert_telnet_lines([input_sql2]) - # input_sql3 = f'abcd,id="cc¥Ec",t0=True,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="ndsfdrum",t8=L"ncharTagValue" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="igwoehkm",c8=L"ncharColValue",c9=7u64 0' - # print(input_sql3) - # input_sql4 = 'hmemeb,id="kilrcrldgf",t0=F,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7="fysodjql",t8=L"ncharTagValue" c0=True,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="waszbfvc",c8=L"ncharColValue",c9=7u64 0' - # code = self._conn.insert_telnet_lines([input_sql3]) - # print(code) - # self._conn.insert_telnet_lines([input_sql4]) def runAll(self): self.initCheckCase() self.boolTypeCheckCase() - # ! leave a bug - #self.symbolsCheckCase() + self.symbolsCheckCase() self.tsCheckCase() self.idSeqCheckCase() self.idUpperCheckCase() self.noIdCheckCase() self.maxColTagCheckCase() - self.idIllegalNameCheckCase() self.idStartWithNumCheckCase() self.nowTsCheckCase() @@ -1310,6 +1341,7 @@ class TDTestCase: self.tagValueLengthCheckCase() self.colValueLengthCheckCase() self.tagColIllegalValueCheckCase() + self.blankCheckCase() self.duplicateIdTagColInsertCheckCase() self.noIdStbExistCheckCase() self.duplicateInsertExistCheckCase() @@ -1319,9 +1351,8 @@ class TDTestCase: self.tagMd5Check() self.tagColBinaryMaxLengthCheckCase() self.tagColNcharMaxLengthCheckCase() - self.batchInsertCheckCase() - self.multiInsertCheckCase(1000) + self.multiInsertCheckCase(10) self.batchErrorInsertCheckCase() self.multiColsInsertCheckCase() self.blankColInsertCheckCase() @@ -1329,32 +1360,31 @@ class TDTestCase: self.chineseCheckCase() self.multiFieldCheckCase() self.errorTypeCheckCase() - # MultiThreads - # self.stbInsertMultiThreadCheckCase() - # self.sStbStbDdataInsertMultiThreadCheckCase() - # self.sStbStbDdataAtInsertMultiThreadCheckCase() - # self.sStbStbDdataMtInsertMultiThreadCheckCase() - # self.sStbDtbDdataInsertMultiThreadCheckCase() - # self.sStbDtbDdataMtInsertMultiThreadCheckCase() - # self.sStbDtbDdataAtInsertMultiThreadCheckCase() - # self.sStbStbDdataDtsInsertMultiThreadCheckCase() - # self.sStbStbDdataDtsMtInsertMultiThreadCheckCase() - # self.sStbStbDdataDtsAtInsertMultiThreadCheckCase() - # self.sStbDtbDdataDtsInsertMultiThreadCheckCase() - # self.sStbDtbDdataDtsMtInsertMultiThreadCheckCase() + self.pointTransCheckCase() + self.defaultTypeCheckCase() + # # MultiThreads + self.stbInsertMultiThreadCheckCase() + self.sStbStbDdataInsertMultiThreadCheckCase() + self.sStbStbDdataAtInsertMultiThreadCheckCase() + self.sStbStbDdataMtInsertMultiThreadCheckCase() + self.sStbDtbDdataInsertMultiThreadCheckCase() + self.sStbDtbDdataMtInsertMultiThreadCheckCase() + self.sStbDtbDdataAtInsertMultiThreadCheckCase() + self.sStbStbDdataDtsInsertMultiThreadCheckCase() + self.sStbStbDdataDtsMtInsertMultiThreadCheckCase() + self.sStbStbDdataDtsAtInsertMultiThreadCheckCase() + self.sStbDtbDdataDtsInsertMultiThreadCheckCase() + self.sStbDtbDdataDtsMtInsertMultiThreadCheckCase() def run(self): print("running {}".format(__file__)) self.createDb() try: - # self.symbolsCheckCase() self.runAll() # self.test() except Exception as err: print(''.join(traceback.format_exception(None, err, err.__traceback__))) raise err - # self.tagColIllegalValueCheckCase() - # self.test() def stop(self): tdSql.close() diff --git a/tests/pytest/query/bug6586.py b/tests/pytest/query/bug6586.py new file mode 100644 index 0000000000000000000000000000000000000000..87d7199dd06a42eed1345311bdfb833ba4cfe93a --- /dev/null +++ b/tests/pytest/query/bug6586.py @@ -0,0 +1,42 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from util.log import * +from util.cases import * +from util.sql import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + # TD-6586 Binary type value return None with python connector + # PR: https://github.com/taosdata/TDengine/pull/7913/files + + tdSql.execute("create database if not exists binary_convertion") + tdSql.execute("use binary_convertion") + tdSql.execute("create stable stb (ts timestamp,value binary(3)) tags (t0 bool,t1 tinyint,t2 smallint,t3 int,t4 bigint,t5 float,t6 double,t7 binary(3),t8 nchar(3))") + tdSql.execute("create table if not exists tb1 using stb(t0,t1,t2,t3,t4,t5,t6,t7,t8) tags (1,127,32767,2147483647,9223372036854775807,11.123450279,22.123456789,'aaa','aaa')") + tdSql.execute("insert into tb1 (ts,value) values (1600000000000, \"aaa\")") + res = tdSql.query('select * from stb', True) + expected_res = [(datetime.datetime(2020, 9, 13, 20, 26, 40), 'aaa', True, 127, 32767, 2147483647, 9223372036854775807, 11.12345027923584, 22.123456789, 'aaa', 'aaa')] + tdSql.checkEqual(res, expected_res) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filterOtherTypes.py b/tests/pytest/query/filterOtherTypes.py index f80552138deb6850a87c63bed0c3f543036e7c17..7d62f2502eaf7ef5e2591adadb1628a618233628 100644 --- a/tests/pytest/query/filterOtherTypes.py +++ b/tests/pytest/query/filterOtherTypes.py @@ -80,10 +80,12 @@ class TDTestCase: tdSql.error("select * from st where tbcol1 like '____'") # > for nchar type on column - tdSql.error("select * from st where tbcol2 > 'taosdata'") + tdSql.query("select * from st where tbcol2 > 'taosdata'") + tdSql.checkRows(10) # >= for nchar type on column - tdSql.error("select * from st where tbcol2 >= 'taosdata'") + tdSql.query("select * from st where tbcol2 >= 'taosdata'") + tdSql.checkRows(10) # = for nchar type on column tdSql.query("select * from st where tbcol2 = 'taosdata1'") @@ -98,10 +100,12 @@ class TDTestCase: tdSql.checkRows(9) # > for nchar type on column - tdSql.error("select * from st where tbcol2 < 'taodata'") + tdSql.query("select * from st where tbcol2 < 'taodata'") + tdSql.checkRows(0) # >= for nchar type on column - tdSql.error("select * from st where tbcol2 <= 'taodata'") + tdSql.query("select * from st where tbcol2 <= 'taodata'") + tdSql.checkRows(0) # % for nchar type on column case 1 tdSql.query("select * from st where tbcol2 like '%'") @@ -140,10 +144,12 @@ class TDTestCase: tdSql.checkRows(10) # > for binary type on column - tdSql.error("select * from st where tbcol3 > '涛思数据'") + tdSql.query("select * from st where tbcol3 > '涛思数据'") + tdSql.checkRows(10) # >= for binary type on column - tdSql.error("select * from st where tbcol3 >= '涛思数据'") + tdSql.query("select * from st where tbcol3 >= '涛思数据'") + tdSql.checkRows(10) # = for binary type on column tdSql.query("select * from st where tbcol3 = '涛思数据1'") @@ -158,10 +164,12 @@ class TDTestCase: tdSql.checkRows(9) # > for binary type on column - tdSql.error("select * from st where tbcol3 < '涛思数据'") + tdSql.query("select * from st where tbcol3 < '涛思数据'") + tdSql.checkRows(0) # >= for binary type on column - tdSql.error("select * from st where tbcol3 <= '涛思数据'") + tdSql.query("select * from st where tbcol3 <= '涛思数据'") + tdSql.checkRows(0) # % for binary type on column case 1 tdSql.query("select * from st where tbcol3 like '%'") diff --git a/tests/pytest/query/isNullTest.py b/tests/pytest/query/isNullTest.py index 7b79679c7d9d9ac4629a69b32acb1a11b61a83c1..f9fbb47715043fb63a51fbb127cb7a889883fafb 100644 --- a/tests/pytest/query/isNullTest.py +++ b/tests/pytest/query/isNullTest.py @@ -66,7 +66,7 @@ class TDTestCase: tdSql.checkData(0, 0, 12) tdSql.query("select count(*) from st where t2 <> '' ") - tdSql.checkData(0, 0, 24) + tdSql.checkData(0, 0, 12) tdSql.query("select count(*) from st where t3 is null") tdSql.checkData(0, 0, 12) @@ -81,7 +81,7 @@ class TDTestCase: tdSql.checkData(0, 0, 12) tdSql.query("select count(*) from st where t3 <> '' ") - tdSql.checkData(0, 0, 24) + tdSql.checkData(0, 0, 12) tdSql.query("select count(*) from st where c1 is not null") tdSql.checkData(0, 0, 30) diff --git a/tests/pytest/query/nestquery_last_row.py b/tests/pytest/query/nestquery_last_row.py index 3c4ada51744f620ca589266113acf1e3d8cfef43..8e9ee540c74569caffa18c209b745cbd70ecc71a 100644 --- a/tests/pytest/query/nestquery_last_row.py +++ b/tests/pytest/query/nestquery_last_row.py @@ -17,6 +17,7 @@ from util.log import tdLog from util.cases import tdCases from util.sql import tdSql import random +import time class TDTestCase: @@ -24,7 +25,8 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - self.ts = 1600000000000 + now = time.time() + self.ts = int(round(now * 1000)) self.num = 10 def run(self): diff --git a/tests/pytest/query/operator_cost.py b/tests/pytest/query/operator_cost.py index 774a1e5f42403a6b5f67678e53be5e07beaccde2..f22cfcd4ec709b1d4440065fab398979afeb3adc 100644 --- a/tests/pytest/query/operator_cost.py +++ b/tests/pytest/query/operator_cost.py @@ -25,7 +25,8 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - self.ts = 1600000000000 + now = time.time() + self.ts = int(round(now * 1000)) self.num = 10 def run(self): diff --git a/tests/pytest/query/queryCnameDisplay.py b/tests/pytest/query/queryCnameDisplay.py index 8864c0e37621c72ad39fb4249749244b1fbe8367..66a7f85120fe13293996d1bd3153b6fe9b1d6a72 100644 --- a/tests/pytest/query/queryCnameDisplay.py +++ b/tests/pytest/query/queryCnameDisplay.py @@ -49,10 +49,11 @@ class TDTestCase: # select as cname with cname_list sql_seq = f'select count(ts) as {cname_list[0]}, sum(pi1) as {cname_list[1]}, avg(pi2) as {cname_list[2]}, count(pf1) as {cname_list[3]}, count(pf2) as {cname_list[4]}, count(ps1) as {cname_list[5]}, min(pi3) as {cname_list[6]}, max(pi4) as {cname_list[7]}, count(pb1) as {cname_list[8]}, count(ps2) as {cname_list[9]} from regular_table_cname_check' - sql_seq_no_as = sql_seq.replace('as ', '') + sql_seq_no_as = sql_seq.replace(' as ', ' ') + print(sql_seq) + print(sql_seq_no_as) res = tdSql.getColNameList(sql_seq) res_no_as = tdSql.getColNameList(sql_seq_no_as) - # cname[1] > 64, it is expected to be equal to 64 cname_list_1_expected = cname_list[1][:-1] cname_list[1] = cname_list_1_expected @@ -79,7 +80,7 @@ class TDTestCase: # select as cname with cname_list sql_seq = f'select count(ts) as {cname_list[0]}, sum(pi1) as {cname_list[1]}, avg(pi2) as {cname_list[2]}, count(pf1) as {cname_list[3]}, count(pf2) as {cname_list[4]}, count(ps1) as {cname_list[5]}, min(pi3) as {cname_list[6]}, max(pi4) as {cname_list[7]}, count(pb1) as {cname_list[8]}, count(ps2) as {cname_list[9]}, count(si1) as {cname_list[10]}, count(si2) as {cname_list[11]}, count(sf1) as {cname_list[12]}, count(sf2) as {cname_list[13]}, count(ss1) as {cname_list[14]}, count(si3) as {cname_list[15]}, count(si4) as {cname_list[16]}, count(sb1) as {cname_list[17]}, count(ss2) as {cname_list[18]} from super_table_cname_check' - sql_seq_no_as = sql_seq.replace('as ', '') + sql_seq_no_as = sql_seq.replace(' as ', ' ') res = tdSql.getColNameList(sql_seq) res_no_as = tdSql.getColNameList(sql_seq_no_as) diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py b/tests/pytest/tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py index dfa829866d945b06d232aeeaba266b11ae229234..ec55acb848352def34e3090e66c4ef392b737ce0 100644 --- a/tests/pytest/tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py @@ -26,7 +26,10 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - self.ts = 1538548685000 + os.system("rm -rf tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py.sql") + + now = time.time() + self.ts = int(round(now * 1000)) self.num = 100 def get_random_string(self, length): @@ -691,7 +694,7 @@ class TDTestCase: tdSql.query("describe table_40") tdSql.checkRows(4096) - os.system("rm -rf tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py.sql") + def stop(self): diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json index 25af3a1041dbcd06319dd6abfeb82fd33240c013..c9c4ae2c1b650da99853d6c82106b3f6ee80d0c0 100755 --- a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json @@ -22,7 +22,7 @@ "cache": 50, "blocks": 8, "precision": "ms", - "keep": 365, + "keep": 36500, "minRows": 100, "maxRows": 4096, "comp":2, diff --git a/tests/pytest/tools/taosdumpTest.py b/tests/pytest/tools/taosdumpTest.py index 0dfc42f331b1a1c59d71268985d6a72d4d652856..628617e27b4af8695b96961441c6b135bdb15416 100644 --- a/tests/pytest/tools/taosdumpTest.py +++ b/tests/pytest/tools/taosdumpTest.py @@ -55,7 +55,7 @@ class TDTestCase: if not os.path.exists("./taosdumptest/tmp1"): os.makedirs("./taosdumptest/tmp1") else: - print("目录存在") + print("directory exists") if not os.path.exists("./taosdumptest/tmp2"): os.makedirs("./taosdumptest/tmp2") diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 35abc4802f9de2080a6b6a166daf833c9cf04578..adf9026e7808dd1fd6715db26f70db56ce339cd5 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -14,7 +14,7 @@ import random import string from util.sql import tdSql - +from util.dnodes import tdDnodes class TDCom: def init(self, conn, logSql): tdSql.init(conn.cursor(), logSql) @@ -47,6 +47,42 @@ class TDCom: chars = ''.join(random.choice(string.ascii_letters.lower() + string.digits) for i in range(len)) return chars + def restartTaosd(self, index=1, db_name="db"): + tdDnodes.stop(index) + tdDnodes.startWithoutSleep(index) + tdSql.execute(f"use {db_name}") + + def typeof(self, variate): + v_type=None + if type(variate) is int: + v_type = "int" + elif type(variate) is str: + v_type = "str" + elif type(variate) is float: + v_type = "float" + elif type(variate) is bool: + v_type = "bool" + elif type(variate) is list: + v_type = "list" + elif type(variate) is tuple: + v_type = "tuple" + elif type(variate) is dict: + v_type = "dict" + elif type(variate) is set: + v_type = "set" + return v_type + + def splitNumLetter(self, input_mix_str): + nums, letters = "", "" + for i in input_mix_str: + if i.isdigit(): + nums += i + elif i.isspace(): + pass + else: + letters += i + return nums, letters + def close(self): self.cursor.close() diff --git a/tests/script/general/compute/ceil.sim b/tests/script/general/compute/ceil.sim new file mode 100644 index 0000000000000000000000000000000000000000..8e8bcd04f003b1b86c8293cdb9a698da24073b38 --- /dev/null +++ b/tests/script/general/compute/ceil.sim @@ -0,0 +1,288 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$tbNum = 2 +$rowNum = 5000 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0 + + $v0 = 5000.0 + $v1 = -5000.1 + $v2 = 5000.2 + $v3 = -5000.3 + $v4 = 5000.4 + $v5 = -5000.5 + $v6 = 5000.6 + $v7 = -5000.7 + $v8 = 5000.8 + $v9 = -5000.9 + + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + $val = $v0 + + if $y == 0 then + $val = $v0 + endi + + if $y == 1 then + $val = $v1 + endi + + if $y == 2 then + $val = $v2 + endi + + if $y == 3 then + $val = $v3 + endi + + if $y == 4 then + $val = $v4 + endi + + if $y == 5 then + $val = $v5 + endi + + if $y == 6 then + $val = $v6 + endi + + if $y == 7 then + $val = $v7 + endi + + if $y == 8 then + $val = $v8 + endi + + if $y == 9 then + $val = $v9 + endi + + $tinyint = $x / 128 + sql insert into $tb values ($ms , $x , $val , $x , $x , $tinyint , $x , $x , $x , $x ) + $x = $x + 1 + $y = $y + 1 + if $y == 10 then + $y = 0 + endi + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select ceil(c2) from $tb +print ===> $data00 +if $data00 != 5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb +print ===> $data10 +if $data10 != -5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb +print ===> $data20 +if $data20 != 5001.00000 then + return -1 +endi +sql select ceil(c2) from $tb +print ===> $data30 +if $data30 != -5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb +print ===> $data40 +if $data40 != 5001.00000 then + return -1 +endi +sql select ceil(c2) from $tb +print ===> $data50 +if $data50 != -5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb +print ===> $data60 +if $data60 != 5001.00000 then + return -1 +endi +sql select ceil(c2) from $tb +print ===> $data70 +if $data70 != -5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb +print ===> $data80 +if $data80 != 5001.00000 then + return -1 +endi +sql select ceil(c2) from $tb +print ===> $data90 +if $data90 != -5000.00000 then + return -1 +endi + +sql select ceil(c5) from $tb +print ===> $data10 +if $data10 != 0 then + return -1 +endi +sql select ts, ceil(c2) from $tb +sql select c2, ceil(c2) from $tb +sql select c2, c3, ceil(c2) from $tb +sql select ts, c2, c3, ceil(c2) from $tb + +sql select ceil(c2), ceil(c6) from $tb + +sql select ts, ceil(c2), ceil(c6) from $tb +sql select c2, ceil(c2), ceil(c6) from $tb +sql select c2, c3, ceil(c2), ceil(c6) from $tb +sql select ts, c2, c3, ceil(c2), ceil(c6) from $tb + +sql select ceil(c2), floor(c2), round(c2) from $tb + +sql select ts, ceil(c2), floor(c2), round(c2) from $tb +sql select c2, ceil(c2), floor(c2), round(c2) from $tb +sql select c2, c3, ceil(c2), floor(c2), round(c2) from $tb +sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $tb + +sql select ts, ceil(c2) from $mt +sql select c2, ceil(c2) from $mt +sql select c2, c3, ceil(c2) from $mt +sql select ts, c2, c3, ceil(c2) from $mt + +sql select ceil(c2), ceil(c6) from $mt + +sql select ts, ceil(c2), ceil(c6) from $mt +sql select c2, ceil(c2), ceil(c6) from $mt +sql select c2, c3, ceil(c2), ceil(c6) from $mt +sql select ts, c2, c3, ceil(c2), ceil(c6) from $mt + +sql select ceil(c2), ceil(c2), round(c2) from $mt + +sql select ts, ceil(c2), floor(c2), round(c2) from $mt +sql select c2, ceil(c2), floor(c2), round(c2) from $mt +sql select c2, c3, ceil(c2), floor(c2), round(c2) from $mt +sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $mt + +sql_error select ceil(c7) from $tb +sql_error select ceil(c8) from $tb +sql_error select ceil(c9) from $tb +sql_error select ceil(ts) from $tb +sql_error select ceil(c2+2) from $tb +sql_error select ceil(c2) from $tb where ts > 0 and ts < now + 100m interval(10m) +sql_error select ceil(ceil(c2)) from $tb +sql_error select ceil(c2) from m_di_tb1 where c2 like '2%' + +print =============== step3 +sql select ceil(c2) from $tb where c2 <= 5001.00000 +print ===> $data00 +if $data00 != 5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 <= 5001.00000 +print ===> $data10 +if $data10 != -5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 <= 5001.00000 +print ===> $data20 +if $data20 != 5001.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 <= 5001.00000 +print ===> $data70 +if $data70 != -5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 <= 5001.00000 +print ===> $data80 +if $data80 != 5001.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 <= 5001.00000 +print ===> $data90 +if $data90 != -5000.00000 then + return -1 +endi + +print =============== step4 +sql select ceil(c2) from $tb where c2 >= -5001.00000 +print ===> $data00 +if $data00 != 5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 >= -5001.00000 +print ===> $data10 +if $data10 != -5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 >= -5001.00000 +print ===> $data20 +if $data20 != 5001.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 >= -5001.00000 +print ===> $data70 +if $data70 != -5000.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 >= -5001.00000 +print ===> $data80 +if $data80 != 5001.00000 then + return -1 +endi +sql select ceil(c2) from $tb where c2 >= -5001.00000 +print ===> $data90 +if $data90 != -5000.00000 then + return -1 +endi + +print =============== step5 +sql select ceil(c1) as b from $tb interval(1m) -x step5 + return -1 +step5: + +print =============== step6 +sql select ceil(c1) as b from $tb where ts < now + 4m interval(1m) -x step6 + return -1 +step6: + +print =============== clear + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/compute/floor.sim b/tests/script/general/compute/floor.sim new file mode 100644 index 0000000000000000000000000000000000000000..0fc14515acd576505dfb48328eda18fabb51e8c5 --- /dev/null +++ b/tests/script/general/compute/floor.sim @@ -0,0 +1,288 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$tbNum = 2 +$rowNum = 10000 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0 + + $v0 = 5000.0 + $v1 = -5000.1 + $v2 = 5000.2 + $v3 = -5000.3 + $v4 = 5000.4 + $v5 = -5000.5 + $v6 = 5000.6 + $v7 = -5000.7 + $v8 = 5000.8 + $v9 = -5000.9 + + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + $val = $v0 + + if $y == 0 then + $val = $v0 + endi + + if $y == 1 then + $val = $v1 + endi + + if $y == 2 then + $val = $v2 + endi + + if $y == 3 then + $val = $v3 + endi + + if $y == 4 then + $val = $v4 + endi + + if $y == 5 then + $val = $v5 + endi + + if $y == 6 then + $val = $v6 + endi + + if $y == 7 then + $val = $v7 + endi + + if $y == 8 then + $val = $v8 + endi + + if $y == 9 then + $val = $v9 + endi + + $tinyint = $x / 128 + sql insert into $tb values ($ms , $x , $val , $x , $x , $tinyint , $x , $x , $x , $x ) + $x = $x + 1 + $y = $y + 1 + if $y == 10 then + $y = 0 + endi + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select floor(c2) from $tb +print ===> $data00 +if $data00 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb +print ===> $data10 +if $data10 != -5001.00000 then + return -1 +endi +sql select floor(c2) from $tb +print ===> $data20 +if $data20 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb +print ===> $data30 +if $data30 != -5001.00000 then + return -1 +endi +sql select floor(c2) from $tb +print ===> $data40 +if $data40 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb +print ===> $data50 +if $data50 != -5001.00000 then + return -1 +endi +sql select floor(c2) from $tb +print ===> $data60 +if $data60 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb +print ===> $data70 +if $data70 != -5001.00000 then + return -1 +endi +sql select floor(c2) from $tb +print ===> $data80 +if $data80 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb +print ===> $data90 +if $data90 != -5001.00000 then + return -1 +endi + +sql select floor(c5) from $tb +print ===> $data10 +if $data10 != 0 then + return -1 +endi +sql select ts, floor(c2) from $tb +sql select c2, floor(c2) from $tb +sql select c2, c3, floor(c2) from $tb +sql select ts, c2, c3, floor(c2) from $tb + +sql select floor(c2), floor(c6) from $tb + +sql select ts, floor(c2), floor(c6) from $tb +sql select c2, floor(c2), floor(c6) from $tb +sql select c2, c3, floor(c2), floor(c6) from $tb +sql select ts, c2, c3, floor(c2), floor(c6) from $tb + +sql select ceil(c2), floor(c2), round(c2) from $tb + +sql select ts, ceil(c2), floor(c2), round(c2) from $tb +sql select c2, ceil(c2), floor(c2), round(c2) from $tb +sql select c2, c3, ceil(c2), floor(c2), round(c2) from $tb +sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $tb + +sql select ts, floor(c2) from $mt +sql select c2, floor(c2) from $mt +sql select c2, c3, floor(c2) from $mt +sql select ts, c2, c3, floor(c2) from $mt + +sql select floor(c2), floor(c6) from $mt + +sql select ts, floor(c2), floor(c6) from $mt +sql select c2, floor(c2), floor(c6) from $mt +sql select c2, c3, floor(c2), floor(c6) from $mt +sql select ts, c2, c3, floor(c2), floor(c6) from $mt + +sql select ceil(c2), floor(c2), round(c2) from $mt + +sql select ts, ceil(c2), floor(c2), round(c2) from $mt +sql select c2, ceil(c2), floor(c2), round(c2) from $mt +sql select c2, c3, ceil(c2), floor(c2), round(c2) from $mt +sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $mt + +sql_error select floor(c7) from $tb +sql_error select floor(c8) from $tb +sql_error select floor(c9) from $tb +sql_error select floor(ts) from $tb +sql_error select floor(c2+2) from $tb +sql_error select floor(c2) from $tb where ts > 0 and ts < now + 100m interval(10m) +sql_error select floor(floor(c2)) from $tb +sql_error select floor(c2) from m_di_tb1 where c2 like '2%' + +print =============== step3 +sql select floor(c2) from $tb where c2 <= 5001.00000 +print ===> $data00 +if $data00 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 <= 5001.00000 +print ===> $data10 +if $data10 != -5001.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 <= 5001.00000 +print ===> $data20 +if $data20 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 <= 5001.00000 +print ===> $data70 +if $data70 != -5001.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 <= 5001.00000 +print ===> $data80 +if $data80 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 <= 5001.00000 +print ===> $data90 +if $data90 != -5001.00000 then + return -1 +endi + +print =============== step4 +sql select floor(c2) from $tb where c2 >= -5001.00000 +print ===> $data00 +if $data00 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 >= -5001.00000 +print ===> $data10 +if $data10 != -5001.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 >= -5001.00000 +print ===> $data20 +if $data20 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 >= -5001.00000 +print ===> $data70 +if $data70 != -5001.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 >= -5001.00000 +print ===> $data80 +if $data80 != 5000.00000 then + return -1 +endi +sql select floor(c2) from $tb where c2 >= -5001.00000 +print ===> $data90 +if $data90 != -5001.00000 then + return -1 +endi + +print =============== step5 +sql select floor(c1) as b from $tb interval(1m) -x step5 + return -1 +step5: + +print =============== step6 +sql select floor(c1) as b from $tb where ts < now + 4m interval(1m) -x step6 + return -1 +step6: + +print =============== clear + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/compute/round.sim b/tests/script/general/compute/round.sim new file mode 100644 index 0000000000000000000000000000000000000000..5e03b47785fc4358e0c4b3a92db7fbc9233d4dbe --- /dev/null +++ b/tests/script/general/compute/round.sim @@ -0,0 +1,288 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_di_db +$tbPrefix = m_di_tb +$mtPrefix = m_di_mt +$tbNum = 2 +$rowNum = 10000 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int) + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + $y = 0 + + $v0 = 5000.0 + $v1 = -5000.1 + $v2 = 5000.2 + $v3 = -5000.3 + $v4 = 5000.4 + $v5 = -5000.5 + $v6 = 5000.6 + $v7 = -5000.7 + $v8 = 5000.8 + $v9 = -5000.9 + + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + $val = $v0 + + if $y == 0 then + $val = $v0 + endi + + if $y == 1 then + $val = $v1 + endi + + if $y == 2 then + $val = $v2 + endi + + if $y == 3 then + $val = $v3 + endi + + if $y == 4 then + $val = $v4 + endi + + if $y == 5 then + $val = $v5 + endi + + if $y == 6 then + $val = $v6 + endi + + if $y == 7 then + $val = $v7 + endi + + if $y == 8 then + $val = $v8 + endi + + if $y == 9 then + $val = $v9 + endi + + $tinyint = $x / 128 + sql insert into $tb values ($ms , $x , $val , $x , $x , $tinyint , $x , $x , $x , $x ) + $x = $x + 1 + $y = $y + 1 + if $y == 10 then + $y = 0 + endi + endw + + $i = $i + 1 +endw + +sleep 100 + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select round(c2) from $tb +print ===> $data00 +if $data00 != 5000.00000 then + return -1 +endi +sql select round(c2) from $tb +print ===> $data10 +if $data10 != -5000.00000 then + return -1 +endi +sql select round(c2) from $tb +print ===> $data20 +if $data20 != 5000.00000 then + return -1 +endi +sql select round(c2) from $tb +print ===> $data30 +if $data30 != -5000.00000 then + return -1 +endi +sql select round(c2) from $tb +print ===> $data40 +if $data40 != 5000.00000 then + return -1 +endi +sql select round(c2) from $tb +print ===> $data50 +if $data50 != -5001.00000 then + return -1 +endi +sql select round(c2) from $tb +print ===> $data60 +if $data60 != 5001.00000 then + return -1 +endi +sql select round(c2) from $tb +print ===> $data70 +if $data70 != -5001.00000 then + return -1 +endi +sql select round(c2) from $tb +print ===> $data80 +if $data80 != 5001.00000 then + return -1 +endi +sql select round(c2) from $tb +print ===> $data90 +if $data90 != -5001.00000 then + return -1 +endi + +sql select round(c5) from $tb +print ===> $data10 +if $data10 != 0 then + return -1 +endi +sql select ts, round(c2) from $tb +sql select c2, round(c2) from $tb +sql select c2, c3, round(c2) from $tb +sql select ts, c2, c3, round(c2) from $tb + +sql select round(c2), round(c6) from $tb + +sql select ts, round(c2), round(c6) from $tb +sql select c2, round(c2), round(c6) from $tb +sql select c2, c3, round(c2), round(c6) from $tb +sql select ts, c2, c3, round(c2), round(c6) from $tb + +sql select ceil(c2), floor(c2), round(c2) from $tb + +sql select ts, ceil(c2), floor(c2), round(c2) from $tb +sql select c2, ceil(c2), floor(c2), round(c2) from $tb +sql select c2, c3, ceil(c2), floor(c2), round(c2) from $tb +sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $tb + +sql select ts, round(c2) from $mt +sql select c2, round(c2) from $mt +sql select c2, c3, round(c2) from $mt +sql select ts, c2, c3, round(c2) from $mt + +sql select round(c2), round(c6) from $mt + +sql select ts, round(c2), round(c6) from $mt +sql select c2, round(c2), round(c6) from $mt +sql select c2, c3, round(c2), round(c6) from $mt +sql select ts, c2, c3, round(c2), round(c6) from $mt + +sql select ceil(c2), floor(c2), round(c2) from $mt + +sql select ts, ceil(c2), floor(c2), round(c2) from $mt +sql select c2, ceil(c2), floor(c2), round(c2) from $mt +sql select c2, c3, ceil(c2), floor(c2), round(c2) from $mt +sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $mt + +sql_error select round(c7) from $tb +sql_error select round(c8) from $tb +sql_error select round(c9) from $tb +sql_error select round(ts) from $tb +sql_error select round(c2+2) from $tb +sql_error select round(c2) from $tb where ts > 0 and ts < now + 100m interval(10m) +sql_error select round(round(c2)) from $tb +sql_error select round(c2) from m_di_tb1 where c2 like '2%' + +print =============== step3 +sql select round(c2) from $tb where c2 <= 5001.00000 +print ===> $data00 +if $data00 != 5000.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 <= 5001.00000 +print ===> $data10 +if $data10 != -5000.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 <= 5001.00000 +print ===> $data20 +if $data20 != 5000.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 <= 5001.00000 +print ===> $data70 +if $data70 != -5001.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 <= 5001.00000 +print ===> $data80 +if $data80 != 5001.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 <= 5001.00000 +print ===> $data90 +if $data90 != -5001.00000 then + return -1 +endi + +print =============== step4 +sql select round(c2) from $tb where c2 >= -5001.00000 +print ===> $data00 +if $data00 != 5000.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 >= -5001.00000 +print ===> $data10 +if $data10 != -5000.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 >= -5001.00000 +print ===> $data20 +if $data20 != 5000.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 >= -5001.00000 +print ===> $data70 +if $data70 != -5001.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 >= -5001.00000 +print ===> $data80 +if $data80 != 5001.00000 then + return -1 +endi +sql select round(c2) from $tb where c2 >= -5001.00000 +print ===> $data90 +if $data90 != -5001.00000 then + return -1 +endi + +print =============== step5 +sql select round(c1) as b from $tb interval(1m) -x step5 + return -1 +step5: + +print =============== step6 +sql select round(c1) as b from $tb where ts < now + 4m interval(1m) -x step6 + return -1 +step6: + +print =============== clear + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/between_and.sim b/tests/script/general/parser/between_and.sim index cdced47cb65aea79618540b57e159b741bf9288a..5db40471d85bcbafbcb6dcaa5912e6cfb9a66bc5 100644 --- a/tests/script/general/parser/between_and.sim +++ b/tests/script/general/parser/between_and.sim @@ -159,7 +159,7 @@ if $data11 != 3 then endi sql_error select * from st2 where f7 between 2.0 and 3.0; -sql_error select * from st2 where f8 between 2.0 and 3.0; -sql_error select * from st2 where f9 between 2.0 and 3.0; +sql select * from st2 where f8 between 2.0 and 3.0; +sql select * from st2 where f9 between 2.0 and 3.0; system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/condition.sim b/tests/script/general/parser/condition.sim index c3aed7e2a3b04c0ca2e27e2e62d92009e8b2fe8e..96cd1e80bd01ad6ffa197ccbe8c58ce6474f3339 100644 --- a/tests/script/general/parser/condition.sim +++ b/tests/script/general/parser/condition.sim @@ -2,7 +2,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1 -system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 6 system sh/cfg.sh -n dnode1 -c cache -v 1 system sh/exec.sh -n dnode1 -s start @@ -135,11 +135,63 @@ while $i < $blockNum $ts0 = $ts0 + 259200000 endw +sql create table stb5 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 timestamp, t2 int, t3 float, t4 bigint, t5 smallint, t6 tinyint, t7 double, t8 bool, t9 binary(100), t10 nchar(10)) + +sql create table tb5_1 using stb5 tags('2021-05-05 18:19:01',1,1.0,1,1,1,1.0,true ,'111111111','1') +sql create table tb5_2 using stb5 tags('2021-05-05 18:19:02',2,2.0,2,2,2,2.0,true ,'222222222','2') +sql create table tb5_3 using stb5 tags('2021-05-05 18:19:03',3,3.0,3,3,3,3.0,false,'333333333','3') +sql create table tb5_4 using stb5 tags('2021-05-05 18:19:04',4,4.0,4,4,4,4.0,false,'444444444','4') +sql create table tb5_5 using stb5 tags('2021-05-05 18:19:05',5,5.0,5,5,5,5.0,true,'555555555','5') +sql create table tb5_6 using stb5 tags('2021-05-05 18:19:06',6,6.0,6,6,6,6.0,true,'666666666','6') +sql create table tb5_7 using stb5 tags(NULL,7,NULL,7,NULL,7,NULL,false,NULL,'7') +sql create table tb5_8 using stb5 tags('2021-05-05 18:19:08',NULL,8.0,NULL,8,NULL,8.0,NULL,'888888888',NULL) + +sql insert into tb5_1 values ('2021-05-05 18:19:00',1,1.0,1,1,1,1.0,true ,'1','1') +sql insert into tb5_1 values ('2021-05-05 18:19:01',2,2.0,2,2,2,2.0,true ,'2','2') +sql insert into tb5_1 values ('2021-05-05 18:19:02',3,3.0,3,3,3,3.0,false,'3','3') +sql insert into tb5_1 values ('2021-05-05 18:19:03',4,4.0,4,4,4,4.0,false,'4','4') +sql insert into tb5_1 values ('2021-05-05 18:19:04',11,11.0,11,11,11,11.0,true ,'11','11') +sql insert into tb5_1 values ('2021-05-05 18:19:05',12,12.0,12,12,12,12.0,true ,'12','12') +sql insert into tb5_1 values ('2021-05-05 18:19:06',13,13.0,13,13,13,13.0,false,'13','13') +sql insert into tb5_1 values ('2021-05-05 18:19:07',14,14.0,14,14,14,14.0,false,'14','14') +sql insert into tb5_2 values ('2021-05-05 18:19:08',21,21.0,21,21,21,21.0,true ,'21','21') +sql insert into tb5_2 values ('2021-05-05 18:19:09',22,22.0,22,22,22,22.0,true ,'22','22') +sql insert into tb5_2 values ('2021-05-05 18:19:10',23,23.0,23,23,23,23.0,false,'23','23') +sql insert into tb5_2 values ('2021-05-05 18:19:11',24,24.0,24,24,24,24.0,false,'24','24') +sql insert into tb5_3 values ('2021-05-05 18:19:12',31,31.0,31,31,31,31.0,true ,'31','31') +sql insert into tb5_3 values ('2021-05-05 18:19:13',32,32.0,32,32,32,32.0,true ,'32','32') +sql insert into tb5_3 values ('2021-05-05 18:19:14',33,33.0,33,33,33,33.0,false,'33','33') +sql insert into tb5_3 values ('2021-05-05 18:19:15',34,34.0,34,34,34,34.0,false,'34','34') +sql insert into tb5_4 values ('2021-05-05 18:19:16',41,41.0,41,41,41,41.0,true ,'41','41') +sql insert into tb5_4 values ('2021-05-05 18:19:17',42,42.0,42,42,42,42.0,true ,'42','42') +sql insert into tb5_4 values ('2021-05-05 18:19:18',43,43.0,43,43,43,43.0,false,'43','43') +sql insert into tb5_4 values ('2021-05-05 18:19:19',44,44.0,44,44,44,44.0,false,'44','44') +sql insert into tb5_5 values ('2021-05-05 18:19:20',51,51.0,51,51,51,51.0,true ,'51','51') +sql insert into tb5_5 values ('2021-05-05 18:19:21',52,52.0,52,52,52,52.0,true ,'52','52') +sql insert into tb5_5 values ('2021-05-05 18:19:22',53,53.0,53,53,53,53.0,false,'53','53') +sql insert into tb5_5 values ('2021-05-05 18:19:23',54,54.0,54,54,54,54.0,false,'54','54') +sql insert into tb5_6 values ('2021-05-05 18:19:24',61,61.0,61,61,61,61.0,true ,'61','61') +sql insert into tb5_6 values ('2021-05-05 18:19:25',62,62.0,62,62,62,62.0,true ,'62','62') +sql insert into tb5_6 values ('2021-05-05 18:19:26',63,63.0,63,63,63,63.0,false,'63','63') +sql insert into tb5_6 values ('2021-05-05 18:19:27',64,64.0,64,64,64,64.0,false,'64','64') +sql insert into tb5_6 values ('2021-05-05 18:19:28',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL) +sql insert into tb5_7 values ('2021-05-05 18:19:29',71,71.0,71,71,71,71.0,true ,'71','71') +sql insert into tb5_7 values ('2021-05-05 18:19:30',72,72.0,72,72,72,72.0,true ,'72','72') +sql insert into tb5_7 values ('2021-05-05 18:19:31',73,73.0,73,73,73,73.0,false,'73','73') +sql insert into tb5_7 values ('2021-05-05 18:19:32',74,74.0,74,74,74,74.0,false,'74','74') +sql insert into tb5_7 values ('2021-05-05 18:19:33',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL) +sql insert into tb5_8 values ('2021-05-05 18:19:34',81,81.0,81,81,81,81.0,true ,'81','81') +sql insert into tb5_8 values ('2021-05-05 18:19:35',82,82.0,82,82,82,82.0,true ,'82','82') +sql insert into tb5_8 values ('2021-05-05 18:19:36',83,83.0,83,83,83,83.0,false,'83','83') +sql insert into tb5_8 values ('2021-05-05 18:19:37',84,84.0,84,84,84,84.0,false,'84','84') +sql insert into tb5_8 values ('2021-05-05 18:19:38',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL) + sleep 100 sql connect run general/parser/condition_query.sim +run general/parser/condition_query2.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT @@ -150,4 +202,90 @@ sql connect sleep 100 run general/parser/condition_query.sim +run general/parser/condition_query2.sim + +sql drop database if exists cdb + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 100 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 1000 +system sh/cfg.sh -n dnode1 -c minTablesPerVnode -v 1000 +system sh/exec.sh -n dnode1 -s start + +sql create database if not exists cdb +sql use cdb +sql create table stba (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int) +sql create table stbb (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 bool) +sql create table stbc (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 float) +sql create table stbd (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 binary(10)) +sql create table stbe (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 nchar(10)) + + +sql create table tba_0 using stba tags(0) +sql create table tba_1 using stba tags(1) +sql create table tba_2 using stba tags(2) +sql create table tba_3 using stba tags(3) +sql create table tba_4 using stba tags(4) +sql create table tba_5 using stba tags(5) +sql create table tba_6 using stba tags(6) +sql create table tba_7 using stba tags(7) +sql create table tba_8 using stba tags(8) +sql create table tba_9 using stba tags(9) + +sql create table tbb_0 using stbb tags(true) +sql create table tbb_1 using stbb tags(false) +sql create table tbb_2 using stbb tags(true) +sql create table tbb_3 using stbb tags(false) +sql create table tbb_4 using stbb tags(true) +sql create table tbb_5 using stbb tags(false) +sql create table tbb_6 using stbb tags(true) +sql create table tbb_7 using stbb tags(false) +sql create table tbb_8 using stbb tags(true) +sql create table tbb_9 using stbb tags(false) + +sql create table tbc_0 using stbc tags(0) +sql create table tbc_1 using stbc tags(1) +sql create table tbc_2 using stbc tags(2) +sql create table tbc_3 using stbc tags(3) +sql create table tbc_4 using stbc tags(4) +sql create table tbc_5 using stbc tags(5) +sql create table tbc_6 using stbc tags(6) +sql create table tbc_7 using stbc tags(7) +sql create table tbc_8 using stbc tags(8) +sql create table tbc_9 using stbc tags(9) + + +sql create table tbd_0 using stbd tags('0000') +sql create table tbd_1 using stbd tags('1111') +sql create table tbd_2 using stbd tags('2222') +sql create table tbd_3 using stbd tags('3333') +sql create table tbd_4 using stbd tags('4444') +sql create table tbd_5 using stbd tags('5555') +sql create table tbd_6 using stbd tags('6666') +sql create table tbd_7 using stbd tags('7777') +sql create table tbd_8 using stbd tags('8888') +sql create table tbd_9 using stbd tags('9999') + +sql create table tbe_0 using stbe tags('0000') +sql create table tbe_1 using stbe tags('1111') +sql create table tbe_2 using stbe tags('2222') +sql create table tbe_3 using stbe tags('3333') +sql create table tbe_4 using stbe tags('4444') +sql create table tbe_5 using stbe tags('5555') +sql create table tbe_6 using stbe tags('6666') +sql create table tbe_7 using stbe tags('7777') +sql create table tbe_8 using stbe tags('8888') +sql create table tbe_9 using stbe tags('9999') + + +run general/parser/condition_query3.sim + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 100 +system sh/exec.sh -n dnode1 -s start + +run general/parser/condition_query3.sim diff --git a/tests/script/general/parser/condition_query.sim b/tests/script/general/parser/condition_query.sim index 8dfa8dae0c9e0c56116cb4132d1e940e99f45d48..bebcbe709f005337795fe1286b34fc264b287cb0 100644 --- a/tests/script/general/parser/condition_query.sim +++ b/tests/script/general/parser/condition_query.sim @@ -1,4 +1,3 @@ - sql use cdb; print "column test" @@ -11,7 +10,7 @@ if $rows != 28 then return -1 endi -sql_error select * from stb1 where c8 > 0 + sql_error select * from stb1 where c7 in (0,2,3,1); sql_error select * from stb1 where c8 in (true); sql_error select * from stb1 where c8 in (1,2); @@ -33,14 +32,119 @@ sql_error select * from stb1 where c4 != 'null'; sql_error select * from stb1 where c5 >= 'null'; sql_error select * from stb1 where c6 <= 'null'; sql_error select * from stb1 where c7 < 'nuLl'; -sql_error select * from stb1 where c8 < 'nuLl'; -sql_error select * from stb1 where c9 > 'nuLl'; +sql_error select * from stb1 where c1 match '.*'; +sql_error select * from stb1 where c2 match '.*'; +sql_error select * from stb1 where c3 match '.*'; +sql_error select * from stb1 where c4 match '.*'; +sql_error select * from stb1 where c5 match '.*'; +sql_error select * from stb1 where c6 match '.*'; +sql_error select * from stb1 where c7 match '.*'; +sql_error select * from stb1 where c9 match '.*'; +sql_error select * from stb1 where ts match '.*'; +sql_error select * from stb1 where c1 nmatch '.*'; +sql_error select * from stb1 where c2 nmatch '.*'; +sql_error select * from stb1 where c3 nmatch '.*'; +sql_error select * from stb1 where c4 nmatch '.*'; +sql_error select * from stb1 where c5 nmatch '.*'; +sql_error select * from stb1 where c6 nmatch '.*'; +sql_error select * from stb1 where c7 nmatch '.*'; +sql_error select * from stb1 where c9 nmatch '.*'; +sql_error select * from stb1 where ts nmatch '.*'; + sql_error select * from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b; sql_error select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 or b.c1 < 60; sql_error select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and ((a.c1 > 50 and a.c1 < 60) or (b.c2 > 60)); sql_error select * from stb1 where 'c2' is null; sql_error select * from stb1 where 'c2' is not null; +sql select * from stb1 where c9 > 'nuLl'; +if $rows != 0 then + return -1 +endi + +sql select * from stb1 where c8 = '22' or c8 >= '62'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:27.000@ then + return -1 +endi + +sql select * from stb1 where c8 < '11'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:03.000@ then + return -1 +endi + +sql select * from stb1 where c8 <> '11'; +if $rows != 27 then + return -1 +endi + + +sql select * from stb1 where c9 > 'nuLl'; +if $rows != 0 then + return -1 +endi + +sql select * from stb1 where c9 > '11' and c9 <= '21'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:05.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:06.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:07.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:08.000@ then + return -1 +endi + +sql select * from stb1 where c9 <= '11' and c9 > '2' and c9 <> 3; +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:03.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:04.000@ then + return -1 +endi + +sql select * from stb1 where c8 > 0 +if $rows != 28 then + return -1 +endi + +sql select * from stb1 where c8 < 'nuLl'; +if $rows != 28 then + return -1 +endi + sql select * from stb1 where c2 > 3.0 or c2 < 60; if $rows != 28 then return -1 @@ -2071,179 +2175,61 @@ if $data20 != @21-07-16 01:00:00.899@ then return -1 endi - -print "ts test" -sql_error select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27' -sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:02.000'; -sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:20.000' and ts != '2021-05-05 18:19:22.000'; -sql_error select * from stb1 where ts2 like '2021-05-05%'; -sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:05.000') and ts > '2021-05-05 18:19:01.000' and ts < '2021-05-05 18:19:27.000'; -sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000') and ts != '2021-05-05 18:19:25.000'; -sql_error select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.000')); -sql_error select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:24.000'; -sql select * from stb1 where ts is null; -if $rows != 0 then - return -1 -endi -sql select * from stb1 where ts is not null and ts is null; -if $rows != 0 then - return -1 -endi - -sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' and ts < '2021-05-05 18:19:10.000'; -if $rows != 0 then - return -1 -endi - -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:02'; -if $rows != 0 then +sql select * from stb1 where c8 > 0; +if $rows != 28 then return -1 endi -sql select * from stb1 where ts is not null; -if $rows != 29 then +sql select * from stb1 where c8 > 1 and c8 <= 21 and c8 < 11 and c8 >= 3; +if $rows != 2 then return -1 endi - -sql select * from stb1 where ts is not null or ts is null; -if $rows != 29 then +if $data00 != @21-05-05 18:19:02.000@ then return -1 endi - -sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:25.000'; -if $rows != 29 then +if $data10 != @21-05-05 18:19:03.000@ then return -1 endi -sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' and ts < '2021-05-05 18:19:26.000'; -if $rows != 1 then - return -1 -endi -if $data00 != @21-05-05 18:19:25.000@ then - return -1 -endi -sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:28.000'; -if $rows != 29 then - return -1 -endi -sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts > '2021-05-05 18:19:27.000'; -if $rows != 4 then - return -1 -endi -if $data00 != @21-05-05 18:19:25.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:26.000@ then +sql select * from stb1 where c8 = 11 or c8 = 12 or c8 is null or c8 in ('13','23') or (c8 like '%4' and c8 like '3_'); +if $rows != 6 then return -1 endi -if $data20 != @21-05-05 18:19:27.000@ then +if $data00 != @21-05-05 18:19:04.000@ then return -1 endi -if $data30 != @21-05-05 18:19:28.000@ then +if $data10 != @21-05-05 18:19:05.000@ then return -1 endi - -sql select ts,c1,c2 from stb1 where ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000' or ts != '2021-05-05 18:19:25.000'; -if $rows != 29 then +if $data20 != @21-05-05 18:19:06.000@ then return -1 endi - -sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts <> '2021-05-05 18:19:25.000'; -if $rows != 29 then +if $data30 != @21-05-05 18:19:10.000@ then return -1 endi - -sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.999') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.999')); -if $rows != 16 then +if $data40 != @21-05-05 18:19:15.000@ then return -1 endi -if $data00 != @21-05-05 18:19:05.000@ then +if $data50 != @21-05-05 18:19:28.000@ then return -1 endi -sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:12.000' and ts <= '2021-05-05 18:19:14.000') or (ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:17.000'); +sql select * from stb1 where c9 >= 3 and c9 <= 33; if $rows != 13 then return -1 endi -if $data00 != @21-05-05 18:19:05.000@ then - return -1 -endi - -sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:01.000' and ts <= '2021-05-05 18:19:08.000'); -if $rows != 10 then - return -1 -endi -if $data00 != @21-05-05 18:19:01.000@ then - return -1 -endi - -sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:06.000') or (ts >= '2021-05-05 18:19:03.000' and ts <= '2021-05-05 18:19:12.000')) and (ts >= '2021-05-05 18:19:10.000'); -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:10.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:11.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:12.000@ then - return -1 -endi -sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:25.000' and ts != '2021-05-05 18:19:18'; -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:26.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:27.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:28.000@ then - return -1 -endi - - -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:25'; -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:26.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:27.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:28.000@ then - return -1 -endi - -sql select * from stb1 where ts < '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:25'; -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:00.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:01.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:02.000@ then - return -1 -endi - -sql select * from stb1 where ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:25'; +sql select * from stb1 where c9 > 22 and c9 <= 38 and c8 < 30 and c8 >= 24; if $rows != 1 then return -1 endi -if $data00 != @21-05-05 18:19:24.000@ then +if $data00 != @21-05-05 18:19:11.000@ then return -1 endi -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:25'; -if $rows != 25 then + +sql select * from stb1 where c9 = 11 or c9 = 12 or c9 is null or c9 in ('13','23') or ((c9 like '%4' or c9 like '3_') and c9 <> 34 and c9 != 44) and c9 < 45 and c9 like '1_'; +if $rows != 6 then return -1 endi if $data00 != @21-05-05 18:19:04.000@ then @@ -2255,485 +2241,104 @@ endi if $data20 != @21-05-05 18:19:06.000@ then return -1 endi - -sql select * from stb1 where ts < '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:25'; -if $rows != 25 then - return -1 -endi -if $data00 != @21-05-05 18:19:00.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:01.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:02.000@ then - return -1 -endi - -sql select * from stb1 where ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25'; -if $rows != 29 then - return -1 -endi -if $data00 != @21-05-05 18:19:00.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:01.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:02.000@ then - return -1 -endi - -sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:26'); -if $rows != 2 then +if $data30 != @21-05-05 18:19:07.000@ then return -1 endi -if $data00 != @21-05-05 18:19:24.000@ then +if $data40 != @21-05-05 18:19:10.000@ then return -1 endi -if $data10 != @21-05-05 18:19:25.000@ then +if $data50 != @21-05-05 18:19:28.000@ then return -1 endi -sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' or ts > '2021-05-05 18:19:26'); +sql select * from stb1 where c8 match '^1.*'; if $rows != 5 then return -1 endi -if $data00 != @21-05-05 18:19:24.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:25.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:26.000@ then - return -1 -endi -if $data30 != @21-05-05 18:19:27.000@ then - return -1 -endi -if $data40 != @21-05-05 18:19:28.000@ then - return -1 -endi - - -sql select * from stb2 where ts2 in ('2021-05-05 18:28:03','2021-05-05 18:28:05','2021-05-05 18:28:08'); -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:02.000@ then +if $data00 != @21-05-05 18:19:00.000@ then return -1 endi if $data10 != @21-05-05 18:19:04.000@ then return -1 endi -if $data20 != @21-05-05 18:19:07.000@ then - return -1 -endi - -sql select * from stb2 where t3 in ('2021-05-05 18:38:38','2021-05-05 18:38:28','2021-05-05 18:38:08') and ts2 in ('2021-05-05 18:28:04','2021-05-05 18:28:04','2021-05-05 18:28:03'); -if $rows != 2 then - return -1 -endi -if $data00 != @21-05-05 18:19:02.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:03.000@ then - return -1 -endi - -sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.ts < '2021-05-05 18:19:03.000' or a.ts >= '2021-05-05 18:19:13.000') and (b.ts >= '2021-05-05 18:19:01.000' and b.ts <= '2021-05-05 18:19:14.000'); -if $rows != 4 then - return -1 -endi -if $data00 != @21-05-05 18:19:01.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:02.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:13.000@ then - return -1 -endi -if $data30 != @21-05-05 18:19:14.000@ then - return -1 -endi - -sql select a.ts,c.ts,b.c1,c.u1,c.u2 from (select * from stb1) a, (select * from stb1) b, (select * from stb2) c where a.ts=b.ts and b.ts=c.ts and a.ts <= '2021-05-05 18:19:12.000' and b.ts >= '2021-05-05 18:19:06.000' and c.ts >= '2021-05-05 18:19:08.000' and c.ts <= '2021-05-05 18:19:11.000' and a.ts != '2021-05-05 18:19:10.000'; -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:08.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:09.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:11.000@ then - return -1 -endi - -sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:06.000' or ts >= '2021-05-05 18:19:13.000') and (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:14.000') and ts != '2021-05-05 18:19:04.000'; -if $rows != 6 then - return -1 -endi -if $data00 != @21-05-05 18:19:02.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:03.000@ then - return -1 -endi if $data20 != @21-05-05 18:19:05.000@ then return -1 endi if $data30 != @21-05-05 18:19:06.000@ then return -1 endi -if $data40 != @21-05-05 18:19:13.000@ then - return -1 -endi -if $data50 != @21-05-05 18:19:14.000@ then +if $data40 != @21-05-05 18:19:07.000@ then return -1 endi -sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:26.000' or ts = '2021-05-05 18:19:26.000') and ts != '2021-05-05 18:19:03.000' and ts != '2021-05-05 18:19:26.000'; -if $rows != 5 then +sql select * from stb1 where c8 match '1.*'; +if $rows != 10 then return -1 endi if $data00 != @21-05-05 18:19:00.000@ then return -1 endi -if $data10 != @21-05-05 18:19:01.000@ then +if $data10 != @21-05-05 18:19:04.000@ then return -1 endi -if $data20 != @21-05-05 18:19:02.000@ then +if $data20 != @21-05-05 18:19:05.000@ then return -1 endi -if $data30 != @21-05-05 18:19:27.000@ then +if $data30 != @21-05-05 18:19:06.000@ then return -1 endi -if $data40 != @21-05-05 18:19:28.000@ then +if $data40 != @21-05-05 18:19:07.000@ then return -1 endi - -print "tbname test" -sql_error select * from stb1 where tbname like '%3' and tbname like '%4'; - -sql select * from stb1 where tbname like 'tb%'; -if $rows != 29 then +if $data50 != @21-05-05 18:19:08.000@ then return -1 endi - -sql select * from stb1 where tbname like '%2'; -if $rows != 4 then +if $data60 != @21-05-05 18:19:12.000@ then return -1 endi -if $data00 != @21-05-05 18:19:08.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:09.000@ then +if $data70 != @21-05-05 18:19:16.000@ then return -1 endi -if $data20 != @21-05-05 18:19:10.000@ then +if $data80 != @21-05-05 18:19:20.000@ then return -1 endi -if $data30 != @21-05-05 18:19:11.000@ then +if $data90 != @21-05-05 18:19:24.000@ then return -1 endi -print "tag test" -sql select * from stb1 where t1 in (1,2) and t1 in (2,3); +sql select * from stb1 where c8 match '1.+'; if $rows != 4 then return -1 endi -if $data00 != @21-05-05 18:19:08.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:09.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:10.000@ then - return -1 -endi -if $data30 != @21-05-05 18:19:11.000@ then - return -1 -endi - -sql select * from stb2 where t1 in (1,2) and t2 in (2) and t3 in ('2021-05-05 18:58:57.000'); -if $rows != 0 then - return -1 -endi - -print "join test" -sql_error select * from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts =tb2_1.ts; -sql select tb1.ts from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.ts < '2021-05-05 18:19:06.000'; -if $rows != 2 then - return -1 -endi if $data00 != @21-05-05 18:19:04.000@ then return -1 endi if $data10 != @21-05-05 18:19:05.000@ then return -1 endi -sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.u1 < 5; -if $rows != 2 then - return -1 -endi -if $data00 != @21-05-05 18:19:04.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:06.000@ then - return -1 -endi - -sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts >= '2021-05-05 18:19:03.000' and tb1.c7=false and tb2_1.u3>4; -if $rows != 2 then - return -1 -endi -if $data00 != @21-05-05 18:19:03.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:07.000@ then - return -1 -endi - -sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4; -if $rows != 9 then - return -1 -endi -if $data00 != @21-05-05 18:19:00.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:01.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:02.000@ then - return -1 -endi -if $data30 != @21-05-05 18:19:03.000@ then - return -1 -endi -if $data40 != @21-05-05 18:19:04.000@ then - return -1 -endi -if $data50 != @21-05-05 18:19:05.000@ then - return -1 -endi -if $data60 != @21-05-05 18:19:06.000@ then - return -1 -endi -if $data70 != @21-05-05 18:19:07.000@ then - return -1 -endi -if $data80 != @21-05-05 18:19:11.000@ then - return -1 -endi - -sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 and stb1.c1 > 2 and stb2.u1 <=4; -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:02.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:04.000@ then - return -1 -endi if $data20 != @21-05-05 18:19:06.000@ then return -1 endi - -print "column&ts test" -sql_error select count(*) from stb1 where ts > 0 or c1 > 0; -sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:20.000' and (c1 > 23 or c1 < 14) and c7 in (true) and c8 like '%2'; -if $rows != 3 then - return -1 -endi -if $data00 != @21-05-05 18:19:05.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:13.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:17.000@ then - return -1 -endi - -print "column&tbname test" -sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0; -sql select * from stb1 where tbname like '%3' and c6 < 34 and c5 != 33 and c4 > 31; -if $rows != 1 then - return -1 -endi -if $data00 != @21-05-05 18:19:13.000@ then +if $data30 != @21-05-05 18:19:07.000@ then return -1 endi -print "column&tag test" -sql_error select * from stb1 where t1 > 0 or c1 > 0 -sql_error select * from stb1 where c1 > 0 or t1 > 0 -sql_error select * from stb1 where t1 > 0 or c1 > 0 or t1 > 1 -sql_error select * from stb1 where c1 > 0 or t1 > 0 or c1 > 1 -sql_error select * from stb1 where t1 > 0 and c1 > 0 or t1 > 1 -sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 -sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 -sql_error select * from stb1 where t1 > 0 or t1 > 0 and c1 > 1 -sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or (t1 > 1 and c1 > 3) -sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or t1 > 1 -sql_error select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.t1=b.t1; - -sql select * from stb1 where c1 < 63 and t1 > 5 -if $rows != 2 then - return -1 -endi -if $data00 != @21-05-05 18:19:24.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:25.000@ then - return -1 -endi -sql select * from stb1 where t1 > 3 and t1 < 5 and c1 != 42 and c1 != 44; -if $rows != 2 then - return -1 -endi -if $data00 != @21-05-05 18:19:16.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:18.000@ then - return -1 -endi -sql select * from stb1 where t1 > 1 and c1 > 21 and t1 < 3 and c1 < 24 and t1 != 3 and c1 != 23; -if $rows != 1 then - return -1 -endi -if $data00 != @21-05-05 18:19:09.000@ then - return -1 -endi -sql select * from stb1 where c1 > 1 and (t1 > 3 or t1 < 2) and (c2 > 2 and c2 < 62 and t1 != 4) and (t1 > 2 and t1 < 6) and c7 = true and c8 like '%2'; -if $rows != 1 then - return -1 -endi -if $data00 != @21-05-05 18:19:21.000@ then +sql select * from stb1 where c8 nmatch '^1.*'; +if $rows != 23 then return -1 endi -sql select * from stb1 where c1!=31 and c1 !=32 and c1 <> 63 and c1 <>1 and c1 <> 21 and c1 <> 2 and c7 <> true and c8 <> '3' and c9 <> '4' and c2<>13 and c3 <> 23 and c4 <> 33 and c5 <> 34 and c6 <> 43 and c2 <> 53 and t1 <> 5 and t2 <>4; +sql select ts,c8 from stb1 where c8 nmatch '[2345]+'; if $rows != 3 then return -1 endi -if $data00 != @21-05-05 18:19:07.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:11.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:27.000@ then - return -1 -endi - - -print "column&join test" -sql_error select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.c1 > 0; - - -print "ts&tbname test" -sql_error select count(*) from stb1 where ts > 0 or tbname like 'tb%'; - -print "ts&tag test" -sql_error select count(*) from stb1 where ts > 0 or t1 > 0; - -sql select * from stb2 where t1!=1 and t2=2 and t3 in ('2021-05-05 18:58:58.000') and ts < '2021-05-05 18:19:13.000'; -if $rows != 2 then - return -1 -endi -if $data00 != @21-05-05 18:19:11.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:12.000@ then - return -1 -endi - -print "ts&join test" -sql_error select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts > 0; -sql select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts and (tb1.ts > '2021-05-05 18:19:05.000' or tb1.ts < '2021-05-05 18:19:03.000' or tb1.ts > 0); - - -print "tbname&tag test" -sql select * from stb1 where tbname like 'tb%' and (t1=1 or t2=2 or t3=3) and t1 > 2; -if $rows != 4 then - return -1 -endi -if $data00 != @21-05-05 18:19:12.000@ then - return -1 -endi -if $data10 != @21-05-05 18:19:13.000@ then - return -1 -endi -if $data20 != @21-05-05 18:19:14.000@ then - return -1 -endi -if $data30 != @21-05-05 18:19:15.000@ then - return -1 -endi - -print "tbname&join test" - -print "tag&join test" - - - - - -print "column&ts&tbname test" -sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0 or ts > 0; - -print "column&ts&tag test" -sql_error select count(*) from stb1 where t1 > 0 or c1 > 0 or ts > 0; -sql_error select count(*) from stb1 where c1 > 0 or t1 > 0 or ts > 0; - -sql select * from stb1 where (t1 > 0 or t1 > 2 ) and ts > '2021-05-05 18:19:10.000' and (c1 > 1 or c1 > 3) and (c6 > 40 or c6 < 30) and (c8 like '%3' or c8 like '_4') and (c9 like '1%' or c9 like '6%' or (c9 like '%3' and c9 != '23')) and ts > '2021-05-05 18:19:22.000' and ts <= '2021-05-05 18:19:26.000'; -if $rows != 1 then - return -1 -endi -if $data00 != @21-05-05 18:19:26.000@ then +if $data00 != @21-05-05 18:19:00.000@ then return -1 endi -sql select * from stb1 where ts > '2021-05-05 18:19:00.000' and c1 > 2 and t1 != 1 and c2 >= 23 and t2 >= 3 and c3 < 63 and c7 = false and t3 > 3 and t3 < 6 and c8 like '4%' and ts < '2021-05-05 18:19:19.000' and c2 > 40 and c3 != 42; -if $rows != 1 then +if $data10 != @21-05-05 18:19:04.000@ then return -1 endi -if $data00 != @21-05-05 18:19:18.000@ then +if $data20 != @21-05-05 18:19:24.000@ then return -1 endi -print "column&ts&join test" - -print "column&tbname&tag test" -sql_error select count(*) from stb1 where c1 > 0 or tbname in ('tb1') or t1 > 0; - -print "column&tbname&join test" -print "column&tag&join test" -print "ts&tbname&tag test" -sql_error select count(*) from stb1 where ts > 0 or tbname in ('tb1') or t1 > 0; - -print "ts&tbname&join test" -print "ts&tag&join test" -print "tbname&tag&join test" - - - - -print "column&ts&tbname&tag test" -sql_error select * from stb1 where (tbname like 'tb%' or ts > '2021-05-05 18:19:01.000') and (t1 > 5 or t1 < 4) and c1 > 0; -sql_error select * from stb1 where (ts > '2021-05-05 18:19:01.000') and (ts > '2021-05-05 18:19:02.000' or t1 > 3) and (t1 > 5 or t1 < 4) and c1 > 0; -sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:20.000' and col > 0 and t1 > 0; - - -print "column&ts&tbname&join test" -print "column&ts&tag&join test" -print "column&tbname&tag&join test" -print "ts&tbname&tag&join test" - - -print "column&ts&tbname&tag&join test" -#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/condition_query2.sim b/tests/script/general/parser/condition_query2.sim new file mode 100644 index 0000000000000000000000000000000000000000..513bb9900ba2e40a165cc6d76cdaf88a46fb00e5 --- /dev/null +++ b/tests/script/general/parser/condition_query2.sim @@ -0,0 +1,2345 @@ +sql use cdb; + +print "ts test" +sql_error select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27' +sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:02.000'; +sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:20.000' and ts != '2021-05-05 18:19:22.000'; +sql_error select * from stb1 where ts2 like '2021-05-05%'; +sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:05.000') and ts > '2021-05-05 18:19:01.000' and ts < '2021-05-05 18:19:27.000'; +sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000') and ts != '2021-05-05 18:19:25.000'; +sql_error select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.000')); +sql_error select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:24.000'; +sql_error select tbname,ts,t1,t2 from stb5 where t1 > ''; + +sql select * from stb1 where ts is null; +if $rows != 0 then + return -1 +endi +sql select * from stb1 where ts is not null and ts is null; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' and ts < '2021-05-05 18:19:10.000'; +if $rows != 0 then + return -1 +endi + +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:02'; +if $rows != 0 then + return -1 +endi + +sql select * from stb1 where ts is not null; +if $rows != 29 then + return -1 +endi + +sql select * from stb1 where ts is not null or ts is null; +if $rows != 29 then + return -1 +endi + +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:25.000'; +if $rows != 29 then + return -1 +endi + +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' and ts < '2021-05-05 18:19:26.000'; +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-05 18:19:25.000@ then + return -1 +endi +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:28.000'; +if $rows != 29 then + return -1 +endi +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts > '2021-05-05 18:19:27.000'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:28.000@ then + return -1 +endi + +sql select ts,c1,c2 from stb1 where ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000' or ts != '2021-05-05 18:19:25.000'; +if $rows != 29 then + return -1 +endi + +sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts <> '2021-05-05 18:19:25.000'; +if $rows != 29 then + return -1 +endi + +sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.999') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.999')); +if $rows != 16 then + return -1 +endi +if $data00 != @21-05-05 18:19:05.000@ then + return -1 +endi + +sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:12.000' and ts <= '2021-05-05 18:19:14.000') or (ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:17.000'); +if $rows != 13 then + return -1 +endi +if $data00 != @21-05-05 18:19:05.000@ then + return -1 +endi + +sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:01.000' and ts <= '2021-05-05 18:19:08.000'); +if $rows != 10 then + return -1 +endi +if $data00 != @21-05-05 18:19:01.000@ then + return -1 +endi + +sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:06.000') or (ts >= '2021-05-05 18:19:03.000' and ts <= '2021-05-05 18:19:12.000')) and (ts >= '2021-05-05 18:19:10.000'); +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:12.000@ then + return -1 +endi + +sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:25.000' and ts != '2021-05-05 18:19:18'; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:28.000@ then + return -1 +endi + + +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:25'; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:28.000@ then + return -1 +endi + +sql select * from stb1 where ts < '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:25'; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi + +sql select * from stb1 where ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:25'; +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-05 18:19:24.000@ then + return -1 +endi + +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:25'; +if $rows != 25 then + return -1 +endi +if $data00 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:05.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:06.000@ then + return -1 +endi + +sql select * from stb1 where ts < '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:25'; +if $rows != 25 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi + +sql select * from stb1 where ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25'; +if $rows != 29 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi + +sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:26'); +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:25.000@ then + return -1 +endi + +sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' or ts > '2021-05-05 18:19:26'); +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:28.000@ then + return -1 +endi + + +sql select * from stb2 where ts2 in ('2021-05-05 18:28:03','2021-05-05 18:28:05','2021-05-05 18:28:08'); +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:07.000@ then + return -1 +endi + +sql select * from stb2 where t3 in ('2021-05-05 18:38:38','2021-05-05 18:38:28','2021-05-05 18:38:08') and ts2 in ('2021-05-05 18:28:04','2021-05-05 18:28:04','2021-05-05 18:28:03'); +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:03.000@ then + return -1 +endi + +sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.ts < '2021-05-05 18:19:03.000' or a.ts >= '2021-05-05 18:19:13.000') and (b.ts >= '2021-05-05 18:19:01.000' and b.ts <= '2021-05-05 18:19:14.000'); +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:14.000@ then + return -1 +endi + +sql select a.ts,c.ts,b.c1,c.u1,c.u2 from (select * from stb1) a, (select * from stb1) b, (select * from stb2) c where a.ts=b.ts and b.ts=c.ts and a.ts <= '2021-05-05 18:19:12.000' and b.ts >= '2021-05-05 18:19:06.000' and c.ts >= '2021-05-05 18:19:08.000' and c.ts <= '2021-05-05 18:19:11.000' and a.ts != '2021-05-05 18:19:10.000'; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:11.000@ then + return -1 +endi + +sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:06.000' or ts >= '2021-05-05 18:19:13.000') and (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:14.000') and ts != '2021-05-05 18:19:04.000'; +if $rows != 6 then + return -1 +endi +if $data00 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:03.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:05.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:06.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:14.000@ then + return -1 +endi + +sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:26.000' or ts = '2021-05-05 18:19:26.000') and ts != '2021-05-05 18:19:03.000' and ts != '2021-05-05 18:19:26.000'; +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:28.000@ then + return -1 +endi + +print "tbname test" +sql select tbname from stb1; +if $rows != 6 then + return -1 +endi + +sql select * from stb1 where tbname like '%3' and tbname like '%4'; +if $rows != 0 then + return -1 +endi + +sql select * from stb1 where tbname like 'tb%'; +if $rows != 29 then + return -1 +endi + +sql select * from stb1 where tbname like '%2'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:11.000@ then + return -1 +endi + +sql select tbname from stb1 where tbname = 'tb1'; +if $rows != 1 then + return -1 +endi +if $data00 != tb1 then + return -1 +endi + +sql select tbname from stb1 where tbname = 'tb1' or tbname = 'tb3'; +if $rows != 2 then + return -1 +endi +if $data00 != tb1 then + return -1 +endi +if $data10 != tb3 then + return -1 +endi + +sql select tbname from stb1 where tbname <> 'tb1'; +if $rows != 5 then + return -1 +endi +if $data00 != tb2 then + return -1 +endi +if $data10 != tb3 then + return -1 +endi +if $data20 != tb4 then + return -1 +endi +if $data30 != tb5 then + return -1 +endi +if $data40 != tb6 then + return -1 +endi + +sql select tbname from stb1 where tbname <> 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; +if $rows != 6 then + return -1 +endi +if $data00 != tb1 then + return -1 +endi +if $data10 != tb2 then + return -1 +endi +if $data20 != tb3 then + return -1 +endi +if $data30 != tb4 then + return -1 +endi +if $data40 != tb5 then + return -1 +endi +if $data50 != tb6 then + return -1 +endi + +sql select tbname from stb1 where tbname > 'tba'; +if $rows != 0 then + return -1 +endi + +sql select tbname from stb1 where tbname > 'tb2' and tbname <= 'tb5'; +if $rows != 3 then + return -1 +endi +if $data00 != tb3 then + return -1 +endi +if $data10 != tb4 then + return -1 +endi +if $data20 != tb5 then + return -1 +endi + +sql select tbname from stb1 where tbname >= 'tb5' or tbname <= 'tb2'; +if $rows != 4 then + return -1 +endi +if $data00 != tb1 then + return -1 +endi +if $data10 != tb2 then + return -1 +endi +if $data20 != tb5 then + return -1 +endi +if $data30 != tb6 then + return -1 +endi + +sql select tbname from stb1 where tbname is null; +if $rows != 0 then + return -1 +endi + + +sql select tbname from stb1 where tbname is not null; +if $rows != 6 then + return -1 +endi +if $data00 != tb1 then + return -1 +endi +if $data10 != tb2 then + return -1 +endi +if $data20 != tb3 then + return -1 +endi +if $data30 != tb4 then + return -1 +endi +if $data40 != tb5 then + return -1 +endi +if $data50 != tb6 then + return -1 +endi + +sql select tbname from stb1 where tbname in ('tb2','tb6'); +if $rows != 2 then + return -1 +endi +if $data00 != tb2 then + return -1 +endi +if $data10 != tb6 then + return -1 +endi + +sql select tbname from stb1 where tbname is not null and (tbname in ('tb2','tb6') or tbname like '%3'); +if $rows != 3 then + return -1 +endi +if $data00 != tb2 then + return -1 +endi +if $data10 != tb3 then + return -1 +endi +if $data20 != tb6 then + return -1 +endi + +sql select tbname from stb1 where (tbname like '%5' and tbname like 'tb%'); +if $rows != 1 then + return -1 +endi +if $data00 != tb5 then + return -1 +endi + +sql select * from stb1 where tbname = 'tb5' and tbname <> 'tb5'; +if $rows != 0 then + return -1 +endi + +sql select * from stb1 where tbname = 'tb5' and tbname <> 'tb4'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:20.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:23.000@ then + return -1 +endi + +sql select *,tbname from stb1 where tbname between 'tb2' and 'tb3'; +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:15.000@ then + return -1 +endi + +sql select ts,c1,t9,t10,tbname from stb5 where tbname match '^3'; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,t9,t10,tbname from stb5 where tbname match 'tb.?_[34]'; +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:15.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:16.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:17.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:18.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:19.000@ then + return -1 +endi + +sql select ts,c1,t9,t10,tbname from stb5 where tbname nmatch '[123467]+'; +if $rows != 9 then + return -1 +endi +if $data00 != @21-05-05 18:19:20.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:23.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:35.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:36.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:37.000@ then + return -1 +endi +if $data80 != @21-05-05 18:19:38.000@ then + return -1 +endi + +sql select ts,c1,t9,t10,tbname from stb5 where tbname in ('tb5_1', 'TB5_2'); +if $rows != 12 then + return -1 +endi + +sql select ts,c1,t9,t10,tbname from stb5 where tbname in ('tb5_1', 'TB5_2') or tbname in ('tb5_3'); +if $rows != 16 then + return -1 +endi + +sql select ts,c1,t9,t10,tbname from stb5 where tbname in ('tb5_1', 'TB5_2') and tbname in ('tb5_2'); +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:11.000@ then + return -1 +endi +print "tag test" +sql_error select * from stb5 where t1 match '.*'; +sql_error select * from stb5 where t2 match '.*'; +sql_error select * from stb5 where t3 match '.*'; +sql_error select * from stb5 where t4 match '.*'; +sql_error select * from stb5 where t5 match '.*'; +sql_error select * from stb5 where t6 match '.*'; +sql_error select * from stb5 where t7 match '.*'; +sql_error select * from stb5 where t8 match '.*'; +sql_error select * from stb5 where t10 match '.*'; +sql_error select * from tb1 where t1 in (1,2) and t1 in (2,3); + +sql select * from stb1 where t1 in (1,2) and t1 in (2,3); +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:11.000@ then + return -1 +endi + +sql select * from stb1 where t1 in (1,2) or t1 in (2,3); +if $rows != 16 then + return -1 +endi + +sql select * from stb2 where t1 in (1,2) and t2 in (2) and t3 in ('2021-05-05 18:58:57.000'); +if $rows != 0 then + return -1 +endi + +sql select *,t1 from stb5 where t1 > 0; +if $rows != 34 then + return -1 +endi + +sql select ts,c1,t1 from stb5 where ((t1 > 0 and t1 <= '2021-05-05 18:19:02.000') or (t1 >'2021-05-05 18:19:03.000' and t1 < '2021-05-05 18:19:06.000')) and t1 != '2021-05-05 18:19:04.000' and t1 is not null; +if $rows != 16 then + return -1 +endi + +sql select ts,c1,t1 from stb5 where ((t1 > 0 and t1 <= '2021-05-05 18:19:02.000') or (t1 >'2021-05-05 18:19:03.000' and t1 < '2021-05-05 18:19:06.000')) and t1 != '2021-05-05 18:19:04.000' and t1 is null; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,t1 from stb5 where (((t1 > 0 and t1 <= '2021-05-05 18:19:02.000') or (t1 >'2021-05-05 18:19:03.000' and t1 < '2021-05-05 18:19:06.000')) and t1 != '2021-05-05 18:19:04.000') or t1 is null; +if $rows != 21 then + return -1 +endi + +sql select ts,c1,t2 from stb5 where t2 > 0 or t2 is null; +if $rows != 39 then + return -1 +endi + +sql select ts,c1,t2 from stb5 where (((t2 > 5 or t2 is null or t2 < 3) and t2 != 6) or t2 in (4, 3)) and t2 <= 3 and t2 >= 2; +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:15.000@ then + return -1 +endi + +sql select ts,c1,t2 from stb5 where t2 > 5.5; +if $rows != 10 then + return -1 +endi +if $data00 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:28.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:29.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:30.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:31.000@ then + return -1 +endi +if $data80 != @21-05-05 18:19:32.000@ then + return -1 +endi +if $data90 != @21-05-05 18:19:33.000@ then + return -1 +endi + +sql select ts,c1,t2 from stb5 where t2 >= 5.5; +if $rows != 14 then + return -1 +endi + +sql select ts,c1,t3,t4,t5,t6,t7 from stb5 where t3 is null or t4 is null; +if $rows != 10 then + return -1 +endi +if $data00 != @21-05-05 18:19:29.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:30.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:31.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:32.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:33.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:35.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:36.000@ then + return -1 +endi +if $data80 != @21-05-05 18:19:37.000@ then + return -1 +endi +if $data90 != @21-05-05 18:19:38.000@ then + return -1 +endi + +sql select ts,c1,t3,t4,t5,t6,t7 from stb5 where t3 is null or t4 is null or t5 <= 1 or t6 in (2,3) or t7 < 5; +if $rows != 30 then + return -1 +endi + +sql select ts,c1,t8,t9 from stb5 where t8 = true; +if $rows != 21 then + return -1 +endi +sql select ts,c1,t8,t9 from stb5 where t8 <> true; +if $rows != 13 then + return -1 +endi + +sql select ts,c1,t8,t9 from stb5 where t8 = false; +if $rows != 13 then + return -1 +endi + +sql select ts,c1,t8,t9 from stb5 where t8 in (true, false); +if $rows != 34 then + return -1 +endi + +sql select ts,c1,t8,t9 from stb5 where t8 in (true, false) or t8 is null; +if $rows != 39 then + return -1 +endi + +sql select ts,c1,t8,t9 from stb5 where t8 in (true) and t8 is not null; +if $rows != 21 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 > '12'; +if $rows != 34 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 = '11'; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 <> '111111111'; +if $rows != 26 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 = '111111111'; +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:03.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:05.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:06.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:07.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 >= '888888888'; +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:35.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:36.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:37.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:38.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 > '222222222' and t9 < '444444444'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:15.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 > '0000000000' and t9 < '999999999'; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 like '_1'; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 like '%1'; +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:03.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:05.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:06.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:07.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where (t9 like '%1' or t9 in ('222222222','444444444')) and t9 is null; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 is null; +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:29.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:30.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:31.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:32.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:33.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 is not null; +if $rows != 34 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 is not null and t9 is null; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 like '_%' and t10 between 5 and 6; +if $rows != 9 then + return -1 +endi +if $data00 != @21-05-05 18:19:20.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:23.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data80 != @21-05-05 18:19:28.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t10 is not null; +if $rows != 34 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t10 is null; +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:35.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:36.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:37.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:38.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t10 is not null and t10 like '%__'; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t10 is not null and t10 like '%_%'; +if $rows != 34 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t10 is not null and t10 like '%%_%%'; +if $rows != 34 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t10 is not null and t10 like '%_%%%_'; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t10 like '_' and t10 between 2 and 3; +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:15.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t10 in ('a','3','bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') or t10 in (''); +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:15.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t10 is null or (t10 > 1 and t10 < 7 and t10 in ('3','4','5') and t10 != 4 and t10 like '3'); +if $rows != 9 then + return -1 +endi +if $data00 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:15.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:35.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:36.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:37.000@ then + return -1 +endi +if $data80 != @21-05-05 18:19:38.000@ then + return -1 +endi + +sql select ts,c1,t8,t9,t10 from stb5 where (t10 is null or t9 is null) and t8 is null; +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:35.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:36.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:37.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:38.000@ then + return -1 +endi + +sql select ts,c1,t8,t9,t10 from stb5 where t10 between 3 and 7 and t9 between '' and '00000000000' and t9 like '_________' and (t10 like '3%'or t10 like '%4'); +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:15.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:16.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:17.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:18.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:19.000@ then + return -1 +endi + +sql select ts,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10 from stb5 where t1 is not null and t2 between 2 and 7 and t3 in (2, 4,6) and t8 != false and t9 > '111111111' and t10 <= 5; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:11.000@ then + return -1 +endi + +sql select * from stb5 where t1 <> 1; +if $rows != 34 then + return -1 +endi + +sql select t1,ts,c1 from stb5 where t1 <> '2021-05-05 18:19:01.000' +if $rows != 26 then + return -1 +endi + +sql select t1,ts,c1 from stb5 where t1 <> '2021-05-05 18:19:01.000' and t1 <> '2021-05-05 18:19:08.000'; +if $rows != 21 then + return -1 +endi + +sql select t1,ts,c1 from stb5 where t1 > '2021-05-05 18:19:02.000'; +if $rows != 22 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 match '1.+'; +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:03.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:05.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:06.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:07.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 match '[3-9]'; +if $rows != 22 then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 match '8.*'; +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:35.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:36.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:37.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:38.000@ then + return -1 +endi + +sql select ts,c1,t9,t10 from stb5 where t9 nmatch '^[12345]*\$'; +if $rows != 10 then + return -1 +endi +if $data00 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:28.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:35.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:36.000@ then + return -1 +endi +if $data80 != @21-05-05 18:19:37.000@ then + return -1 +endi +if $data90 != @21-05-05 18:19:38.000@ then + return -1 +endi + +print "join test" +sql_error select * from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts =tb2_1.ts; +sql select tb1.ts from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.ts < '2021-05-05 18:19:06.000'; +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:05.000@ then + return -1 +endi +sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.u1 < 5; +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:06.000@ then + return -1 +endi + +sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts >= '2021-05-05 18:19:03.000' and tb1.c7=false and tb2_1.u3>4; +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:03.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:07.000@ then + return -1 +endi + +sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4; +if $rows != 9 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:03.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:05.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:06.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:07.000@ then + return -1 +endi +if $data80 != @21-05-05 18:19:11.000@ then + return -1 +endi + +sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 and stb1.c1 > 2 and stb2.u1 <=4; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:06.000@ then + return -1 +endi + +sql select stb1.ts,stb1.t1,stb1.c1,stb5.c2 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb1.c1 between 20 and 50 and (stb5.c2 > 22 and stb5.c2 < 33)); +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:13.000@ then + return -1 +endi + +sql select stb1.ts,stb1.t1,stb1.c1,stb5.c2 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts; +if $rows != 29 then + return -1 +endi + +sql select stb1.c1,stb5.c1 from stb1, stb5 where stb1.t1=stb5.t2 and (stb1.c1 > 10 and stb5.c1 < 20) and stb1.ts=stb5.ts ; +if $rows != 4 then + return -1 +endi +if $data00 != 11 then + return -1 +endi +if $data10 != 12 then + return -1 +endi +if $data20 != 13 then + return -1 +endi +if $data30 != 14 then + return -1 +endi + +print "column&ts test" +sql_error select count(*) from stb1 where ts > 0 or c1 > 0; +sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:20.000' and (c1 > 23 or c1 < 14) and c7 in (true) and c8 like '%2'; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:05.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:17.000@ then + return -1 +endi + +print "column&tbname test" +sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0; +sql select * from stb1 where tbname like '%3' and c6 < 34 and c5 != 33 and c4 > 31; +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-05 18:19:13.000@ then + return -1 +endi + +sql select ts,c1,tbname from stb5 where c1 > 30 and tbname > 'tb5_3' and tbname < 'tb5_8' and c1 < 72 and c1 between 44 and 54; +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:19.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:20.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:23.000@ then + return -1 +endi + +sql select ts,c8,tbname from stb5 where (tbname like '%3' or tbname like '%4' or tbname = 'tb5_6') and tbname between 'tb5_2' and 'tb5_7' and (c8 like '3_' or c8 like '_4'); +if $rows != 6 then + return -1 +endi +if $data00 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:15.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:19.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:27.000@ then + return -1 +endi + + +print "column&tag test" +sql_error select * from stb1 where t1 > 0 or c1 > 0 +sql_error select * from stb1 where c1 > 0 or t1 > 0 +sql_error select * from stb1 where t1 > 0 or c1 > 0 or t1 > 1 +sql_error select * from stb1 where c1 > 0 or t1 > 0 or c1 > 1 +sql_error select * from stb1 where t1 > 0 and c1 > 0 or t1 > 1 +sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 +sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1 +sql_error select * from stb1 where t1 > 0 or t1 > 0 and c1 > 1 +sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or (t1 > 1 and c1 > 3) +sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or t1 > 1 +sql_error select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.t1=b.t1; + +sql select * from stb1 where c1 < 63 and t1 > 5 +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:25.000@ then + return -1 +endi +sql select * from stb1 where t1 > 3 and t1 < 5 and c1 != 42 and c1 != 44; +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:16.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:18.000@ then + return -1 +endi +sql select * from stb1 where t1 > 1 and c1 > 21 and t1 < 3 and c1 < 24 and t1 != 3 and c1 != 23; +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-05 18:19:09.000@ then + return -1 +endi +sql select * from stb1 where c1 > 1 and (t1 > 3 or t1 < 2) and (c2 > 2 and c2 < 62 and t1 != 4) and (t1 > 2 and t1 < 6) and c7 = true and c8 like '%2'; +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-05 18:19:21.000@ then + return -1 +endi + +sql select * from stb1 where c1!=31 and c1 !=32 and c1 <> 63 and c1 <>1 and c1 <> 21 and c1 <> 2 and c7 <> true and c8 <> '3' and c9 <> '4' and c2<>13 and c3 <> 23 and c4 <> 33 and c5 <> 34 and c6 <> 43 and c2 <> 53 and t1 <> 5 and t2 <>4; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:07.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:27.000@ then + return -1 +endi + +sql select ts,t1,c1,t2 from stb5 where t1 in ('2021-05-05 18:19:02.000','2021-05-05 18:19:04.000','2021-05-05 18:19:06.000','2021-05-05 18:19:08.000') and c1 is null and t2 is null; +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-05 18:19:38.000@ then + return -1 +endi + +sql select ts,t1,c1,t2 from stb5 where t1 in ('2021-05-05 18:19:02.000','2021-05-05 18:19:04.000','2021-05-05 18:19:06.000','2021-05-05 18:19:08.000') and t2 is not null and ts between '2021-05-05 18:19:10.000' and '2021-05-05 18:19:20.000' and t2 < 3; +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:11.000@ then + return -1 +endi + +sql select ts,t1,c1,t2,tbname,t8,t9 from stb5 where (((t8 != false or t8 is null) and (t9 like '%8' or t9 like '%6') and t2 is not null) or (t8 in (false) and t1 is null)) and (c1 is null or (c1 > 62 and c1 <= 72)); +if $rows != 6 then + return -1 +endi +if $data00 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:28.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:29.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:30.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:33.000@ then + return -1 +endi + +print "column&join test" +sql_error select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.c1 > 0; + +sql select stb5.ts,stb5.c1,stb5.t1,stb5.t8,stb5.t9,stb5.t10 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and (stb5.c1 > 60 or stb5.c1 <= 11 or stb5.c1 is null); +if $rows != 10 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:03.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:04.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data80 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data90 != @21-05-05 18:19:28.000@ then + return -1 +endi + +sql select stb5.ts,stb5.c1,stb5.t1,stb5.t8,stb5.t9,stb5.t10 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and (stb5.c1 > 60 or stb5.c1 <= 11 or stb5.c1 is null or stb5.c2 between 30 and 40) and (stb1.c9 like '%3' or stb1.c8 like '%4') and stb5.c9 like '%3%'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:02.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:15.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:26.000@ then + return -1 +endi + + +print "ts&tbname test" +sql_error select count(*) from stb1 where ts > 0 or tbname like 'tb%'; +sql_error select tbname,ts,c1,tbname from stb5 where tbname like '%' and tbname between '' and 'tb5_3' and ts between '2021-05-05 18:19:05.000' and '2021-05-05 18:19:10.000' and ts <> '2021-05-05 18:19:07.000'; + +sql select tbname,ts,c1,tbname from stb5 where (tbname like '%5' or tbname like '%8') and ts between '2021-05-05 18:19:21.000' and '2021-05-05 18:19:35.000'; +if $rows != 5 then + return -1 +endi +if $data01 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data11 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data21 != @21-05-05 18:19:23.000@ then + return -1 +endi +if $data31 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data41 != @21-05-05 18:19:35.000@ then + return -1 +endi + +sql select tbname,ts,c1,tbname from stb5 where tbname like '%' and tbname between '' and 'tb5_3' and ts between '2021-05-05 18:19:10.000' and '2021-05-05 18:19:05.000'; +if $rows != 0 then + return -1 +endi + +sql select tbname,ts,c1,tbname from stb5 where tbname like '%' and tbname between '' and 'tb5_3' and ts between '2021-05-05 18:19:05.000' and '2021-05-05 18:19:10.000' and ts <> '2021-05-05 18:19:05.000' and ts != '2021-05-05 18:19:10.000' order by ts desc; +if $rows != 4 then + return -1 +endi +if $data01 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data11 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data21 != @21-05-05 18:19:07.000@ then + return -1 +endi +if $data31 != @21-05-05 18:19:06.000@ then + return -1 +endi + + +print "ts&tag test" +sql_error select count(*) from stb1 where ts > 0 or t1 > 0; + +sql select * from stb2 where t1!=1 and t2=2 and t3 in ('2021-05-05 18:58:58.000') and ts < '2021-05-05 18:19:13.000'; +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:12.000@ then + return -1 +endi + +sql select t1,ts,c1,t1,t2 from stb5 where (t1 > 1 or t1 is null or t2 is null) and (t1 in ('2021-05-05 18:19:02.000','2021-05-05 18:19:04.000') or t1 is null) and t2 >= 4 order by ts; +if $rows != 9 then + return -1 +endi +if $data01 != @21-05-05 18:19:16.000@ then + return -1 +endi +if $data11 != @21-05-05 18:19:17.000@ then + return -1 +endi +if $data21 != @21-05-05 18:19:18.000@ then + return -1 +endi +if $data31 != @21-05-05 18:19:19.000@ then + return -1 +endi +if $data41 != @21-05-05 18:19:29.000@ then + return -1 +endi +if $data51 != @21-05-05 18:19:30.000@ then + return -1 +endi +if $data61 != @21-05-05 18:19:31.000@ then + return -1 +endi +if $data71 != @21-05-05 18:19:32.000@ then + return -1 +endi +if $data81 != @21-05-05 18:19:33.000@ then + return -1 +endi + +print "ts&join test" +sql_error select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts > 0; +sql_error select stb1.tbname,stb5.tbname,stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb1.ts = '2021-05-05 18:19:10.000' or stb1.ts = '2021-05-05 18:19:11.000'); + +sql select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts and (tb1.ts > '2021-05-05 18:19:05.000' or tb1.ts < '2021-05-05 18:19:03.000' or tb1.ts > 0) and tb1.ts between '0' and '2021-05-05 18:19:04.000' and tb2_1.ts < '2021-05-05 18:19:03.000'; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:00.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:01.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:02.000@ then + return -1 +endi + +sql select stb1.tbname,stb5.tbname,stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb1.ts = '2021-05-05 18:19:10.000' or stb1.ts <= '2021-05-05 18:19:11.000') and stb5.ts > '2021-05-05 18:19:05.000' and stb5.ts != '2021-05-05 18:19:11.000'; +if $rows != 5 then + return -1 +endi +if $data02 != @21-05-05 18:19:06.000@ then + return -1 +endi +if $data12 != @21-05-05 18:19:07.000@ then + return -1 +endi +if $data22 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data32 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data42 != @21-05-05 18:19:10.000@ then + return -1 +endi + + +print "tbname&tag test" +sql select * from stb1 where tbname like 'tb%' and (t1=1 or t2=2 or t3=3) and t1 > 2; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:15.000@ then + return -1 +endi + +sql select ts,t1,c1,t2,tbname,t8,t9 from stb5 where tbname = 'tb5_1' or t1 = '2021-05-05 18:19:02.000'; +if $rows != 12 then + return -1 +endi + +sql select ts,t1,c1,t2,tbname,t8,t9 from stb5 where t1 = '2021-05-05 18:19:02.000' or tbname = 'tb5_1'; +if $rows != 12 then + return -1 +endi + +sql select t2,t1,t2,t3,t4,t8 from stb5 where t2 > 1 and t2 < 3 or t3 >= 1 and t3 <=1 or t8 in (false); +if $rows != 5 then + return -1 +endi + +sql select tbname,ts,c1,t1,t2,t3,t8 from stb5 where (t2 > 1 and t2 < 3 or t3 >= 1 and t3 <=1 or t8 in (false) or tbname like 'tb5_8' or tbname in ('tb5_5')) and tbname < 'tb5_3' and t3 > 1.0 and ts < '2021-05-05 18:19:10.000'; +if $rows != 2 then + return -1 +endi + + +print "tbname&join test" +sql select stb1.tbname,stb5.tbname,stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.tbname < 'tb4' and (stb5.tbname like 'tb5_3' or stb5.tbname = 'tb5_1') and stb5.tbname like '%____%_%'; +if $rows != 12 then + return -1 +endi + +sql select stb1.tbname,stb5.tbname,stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.tbname < 'tb4' and (stb5.tbname like 'tb5_3' or stb5.tbname = 'tb5_1') and stb5.tbname like '%____%_%_'; +if $rows != 0 then + return -1 +endi + + +print "tag&join test" +sql select stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.t1 >= -1 and stb1.t1 < 100 and stb1.t1 in (1,2,3,5,6) and stb1.t1 <> 3 and stb1.t1 <= 5 and stb1.t1 >=2; +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:20.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:23.000@ then + return -1 +endi + +sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb5.t1 >'2021-05-05 18:19:01.000'; +if $rows != 21 then + return -1 +endi + +sql select stb1.ts,stb1.c1,stb1.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t9 like '_%_______5555%55_'; +if $rows != 0 then + return -1 +endi + +sql select stb1.ts,stb1.c1,stb1.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t9 like '%_%__55%%%%55%55'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:20.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:23.000@ then + return -1 +endi + + +print "column&ts&tbname test" +sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0 or ts > 0; + +sql select * from stb5 where tbname > '' and (tbname like '%8') and tbname is null; +if $rows != 0 then + return -1 +endi + +sql select ts,c1,ts,c1,ts,c1,c8 from stb5 where tbname > '' and (tbname like '%8' or tbname like '%3') and tbname is not null and tbname in ('tb5_2','tb5_8') and tbname < 'aaaaaaaaaaa' and ts <= 1620209977000 and (c9 like '_3' or c9 <> '82'); +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:34.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:36.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:37.000@ then + return -1 +endi + + +print "column&ts&tag test" +sql_error select count(*) from stb1 where t1 > 0 or c1 > 0 or ts > 0; +sql_error select count(*) from stb1 where c1 > 0 or t1 > 0 or ts > 0; + +sql select * from stb1 where (t1 > 0 or t1 > 2 ) and ts > '2021-05-05 18:19:10.000' and (c1 > 1 or c1 > 3) and (c6 > 40 or c6 < 30) and (c8 like '%3' or c8 like '_4') and (c9 like '1%' or c9 like '6%' or (c9 like '%3' and c9 != '23')) and ts > '2021-05-05 18:19:22.000' and ts <= '2021-05-05 18:19:26.000'; +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-05 18:19:26.000@ then + return -1 +endi +sql select * from stb1 where ts > '2021-05-05 18:19:00.000' and c1 > 2 and t1 != 1 and c2 >= 23 and t2 >= 3 and c3 < 63 and c7 = false and t3 > 3 and t3 < 6 and c8 like '4%' and ts < '2021-05-05 18:19:19.000' and c2 > 40 and c3 != 42; +if $rows != 1 then + return -1 +endi +if $data00 != @21-05-05 18:19:18.000@ then + return -1 +endi + + +print "column&ts&join test" +sql select stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.ts > '2021-05-05 18:19:09.000' and stb5.ts < '2021-05-05 18:19:25.000' and stb1.c9 like '%4'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:15.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:19.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:23.000@ then + return -1 +endi + +print "column&tbname&tag test" +sql_error select count(*) from stb1 where c1 > 0 or tbname in ('tb1') or t1 > 0; + +sql select * from stb5 where c1 > 10 and tbname in ('tb5_2','tb5_3','tb5_4') and t9 like '%4'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:16.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:17.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:18.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:19.000@ then + return -1 +endi + + +print "column&tbname&join test" +sql select stb1.ts,stb1.c1,stb5.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb5.c1 > 10 or stb5.c1 is null) and stb5.tbname in ('tb5_2','tb5_3','tb5_6') and (stb5.c1 < 24 or stb5.c1 is null); +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:28.000@ then + return -1 +endi + +sql select stb1.ts,stb1.c1,stb5.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb5.c1 > 10 or stb5.c1 is null) and stb5.tbname in ('tb5_2', 'tb5_3','tb5_6') and (stb5.c1 < 24 or stb5.c1 is null) and stb5.c1 is not null; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi + + +print "column&tag&join test" +sql select stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.t1 >= -1 and stb1.t1 < 100 and stb1.t1 in (1,2,3,5,6) and stb1.t1 <> 3 and stb1.t1 <= 5 and stb1.t1 >=2 and stb1.c1 >= 22 and stb1.c1 <= 53 and stb1.c1 in (23,24,50,54,21); +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:11.000@ then + return -1 +endi + +sql select stb1.ts,stb1.t3,stb1.tbname,stb1.c1,stb5.tbname from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.t2 > 1; +if $rows != 21 then + return -1 +endi + +sql select stb1.ts,stb1.t3,stb1.tbname,stb1.c1,stb5.t9,stb1.t2 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.t2 between 2 and 5 and (stb5.t9 like '%2' or stb5.t9 like '%3') and stb1.ts < '2021-05-05 18:19:14.000' and stb5.ts > '2021-05-05 18:19:09.000'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:13.000@ then + return -1 +endi + + +print "ts&tbname&tag test" +sql_error select count(*) from stb1 where ts > 0 or tbname in ('tb1') or t1 > 0; + +sql select tbname,ts,t1,t2 from stb5 where ts > 0 and ts between '2021-05-05 18:19:06.001' and '2021-05-05 18:19:30.000' and (tbname='tb5_6' or tbname in ('tb5_1')) and t1 > '2021-05-05 18:19:01.000'; +if $rows != 5 then + return -1 +endi +if $data01 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data11 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data21 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data31 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data41 != @21-05-05 18:19:28.000@ then + return -1 +endi + +print "ts&tbname&join test" + +sql_error select stb1.ts,stb1.c1,stb5.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.tbname in ('tb5_2', 'tb5_3','tb5_6') and stb5.ts < 1111111111111111111111; + +sql select stb1.ts,stb1.c1,stb5.c1,stb1.t1,stb1.tbname from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.tbname in ('tb5_2', 'tb5_3','tb5_6') and stb5.ts < 11111111111111111 and (stb1.tbname like '%6' or stb1.tbname in ('tb2')) and stb1.ts between '2021-05-05 18:19:10.000' and '2021-05-05 18:19:26.000'; +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:26.000@ then + return -1 +endi + +print "ts&tag&join test" +sql select stb1.ts,stb1.c1,stb5.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t1 > '2021-05-05 18:19:02.000' and stb5.t1 between '2021-05-05 18:19:05.000' and '2021-05-05 18:19:06.000' and stb5.ts between '2021-05-05 18:19:23.000' and '2021-05-05 18:19:25.000'; +if $rows != 3 then + return -1 +endi +if $data00 != @21-05-05 18:19:23.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:25.000@ then + return -1 +endi + + +print "tbname&tag&join test" +sql select stb1.ts,stb1.c1,stb5.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t1 > '2021-05-05 18:19:01.000' and stb5.t1 between '2021-05-05 18:19:00.000' and '2021-05-05 18:19:06.000' and (stb5.tbname like '%3' or stb5.tbname like '%2'); +if $rows != 8 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:10.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:14.000@ then + return -1 +endi +if $data70 != @21-05-05 18:19:15.000@ then + return -1 +endi + +print "column&ts&tbname&tag test" +sql_error select * from stb1 where (tbname like 'tb%' or ts > '2021-05-05 18:19:01.000') and (t1 > 5 or t1 < 4) and c1 > 0; +sql_error select * from stb1 where (ts > '2021-05-05 18:19:01.000') and (ts > '2021-05-05 18:19:02.000' or t1 > 3) and (t1 > 5 or t1 < 4) and c1 > 0; +sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:20.000' and col > 0 and t1 > 0; + +sql select t4,tbname,ts,c1 from stb5 where ((tbname like '%4') or t4 >= 6) and ts between '2021-05-05 18:19:20.000' and '2021-05-05 18:19:30.000' and (c1 is null or c1 >= 62 and c1 <= 71); +if $rows != 5 then + return -1 +endi +if $data02 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data12 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data22 != @21-05-05 18:19:27.000@ then + return -1 +endi +if $data32 != @21-05-05 18:19:28.000@ then + return -1 +endi +if $data42 != @21-05-05 18:19:29.000@ then + return -1 +endi + +print "column&ts&tbname&join test" + +sql select stb1.ts,stb1.c1,stb5.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t1 > '2021-05-05 18:19:01.000' and stb5.t1 between '2021-05-05 18:19:00.000' and '2021-05-05 18:19:06.000' and (stb5.tbname like '%3' or stb5.tbname like '%2') and stb1.ts between '2021-05-05 18:19:09.000' and '2021-05-05 18:19:14.000' and stb1.c1 > 23; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:11.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:12.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:13.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:14.000@ then + return -1 +endi + +print "column&ts&tag&join test" +sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb5.t8 = true and stb5.t7< 3.0000 and stb5.ts > '2021-05-05 18:19:02.000' and stb5.c1 between 10 and 22 and stb5.t1 >'2021-05-05 18:19:01.000'; +if $rows != 2 then + return -1 +endi +if $data00 != @21-05-05 18:19:08.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:09.000@ then + return -1 +endi + +print "column&tbname&tag&join test" +sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.c1 > 11 and (stb5.tbname like '%3' or stb5.tbname like '%6' or stb5.tbname = 'tb5_4') and stb5.t7 > 4 and stb5.t8 <> 'false'; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:25.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:26.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:27.000@ then + return -1 +endi + + +print "ts&tbname&tag&join test" +sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.ts between '2021-05-05 18:19:15.000' and '2099-05-05 18:19:15.000' and stb5.tbname in ('tb5_3','tb5_5','tb5_6') and stb5.t1 >= '2021-05-05 18:19:03.000' and stb5.t1 <= '2021-05-05 18:19:08.000' and stb5.ts <='2021-05-05 18:19:25.000'; +if $rows != 7 then + return -1 +endi +if $data00 != @21-05-05 18:19:15.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:20.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:23.000@ then + return -1 +endi +if $data50 != @21-05-05 18:19:24.000@ then + return -1 +endi +if $data60 != @21-05-05 18:19:25.000@ then + return -1 +endi + +print "column&ts&tbname&tag&join test" +sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.ts between '2021-05-05 18:19:15.000' and '2099-05-05 18:19:15.000' and stb5.tbname in ('tb5_3','tb5_5','tb5_6') and stb5.t1 >= '2021-05-05 18:19:03.000' and stb5.t1 <= '2021-05-05 18:19:08.000' and stb5.ts <='2021-05-05 18:19:25.000' and stb1.c1 between 34 and 60; +if $rows != 5 then + return -1 +endi +if $data00 != @21-05-05 18:19:15.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:20.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data40 != @21-05-05 18:19:23.000@ then + return -1 +endi + +sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb5.tbname<>'tb5_1' and stb5.t1 <> '2021-05-05 18:19:02.000' and stb1.ts > '2021-05-05 18:19:12.000' and stb5.c1 != 32 and stb5.t6 > 3 and stb5.t7 < 6 and stb5.t8 <> false; +if $rows != 4 then + return -1 +endi +if $data00 != @21-05-05 18:19:20.000@ then + return -1 +endi +if $data10 != @21-05-05 18:19:21.000@ then + return -1 +endi +if $data20 != @21-05-05 18:19:22.000@ then + return -1 +endi +if $data30 != @21-05-05 18:19:23.000@ then + return -1 +endi + + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/condition_query3.sim b/tests/script/general/parser/condition_query3.sim new file mode 100644 index 0000000000000000000000000000000000000000..a88d75f40d2d638e19d356b2f0ef76789c42b2db --- /dev/null +++ b/tests/script/general/parser/condition_query3.sim @@ -0,0 +1,210 @@ +sql use cdb; + +print "index tag test" + +sql select tbname,t1 from stba; +if $rows != 10 then + return -1 +endi + +sql select tbname,t1 from stba where t1 > 2; +if $rows != 7 then + return -1 +endi + +sql select tbname,t1 from stba where t1 >= 4; +if $rows != 6 then + return -1 +endi + +sql select tbname,t1 from stba where t1 >= 3 and t1 <= 6; +if $rows != 4 then + return -1 +endi + +sql select tbname,t1 from stba where t1 = 3; +if $rows != 1 then + return -1 +endi + +sql select tbname,t1 from stba where t1 <> 6; +if $rows != 9 then + return -1 +endi + +sql select tbname,t1 from stba where t1 < 6; +if $rows != 6 then + return -1 +endi + +sql select tbname,t1 from stba where t1 < 6 and t1 >= 2; +if $rows != 4 then + return -1 +endi + +sql select tbname,t1 from stba where t1 is null; +if $rows != 0 then + return -1 +endi +sql select tbname,t1 from stba where t1 is not null; +if $rows != 10 then + return -1 +endi + +sql_error select tbname,t1 from stbb where t1 > true; +sql select tbname,t1 from stbb where t1 = true; +if $rows != 5 then + return -1 +endi + +sql select tbname,t1 from stbb where t1 <> true; +if $rows != 5 then + return -1 +endi + +sql select tbname,t1 from stbb where t1 is null; +if $rows != 0 then + return -1 +endi +sql select tbname,t1 from stbb where t1 is not null; +if $rows != 10 then + return -1 +endi + +sql select tbname,t1 from stbc; +if $rows != 10 then + return -1 +endi + +sql select tbname,t1 from stbc where t1 > 2; +if $rows != 7 then + return -1 +endi + +sql select tbname,t1 from stbc where t1 >= 4; +if $rows != 6 then + return -1 +endi + +sql select tbname,t1 from stbc where t1 >= 3 and t1 <= 6; +if $rows != 4 then + return -1 +endi + +sql select tbname,t1 from stbc where t1 = 3; +if $rows != 1 then + return -1 +endi + +sql select tbname,t1 from stbc where t1 <> 6; +if $rows != 9 then + return -1 +endi + +sql select tbname,t1 from stbc where t1 < 6; +if $rows != 6 then + return -1 +endi + +sql select tbname,t1 from stbc where t1 < 6 and t1 >= 2; +if $rows != 4 then + return -1 +endi + +sql select tbname,t1 from stbc where t1 is null; +if $rows != 0 then + return -1 +endi +sql select tbname,t1 from stbc where t1 is not null; +if $rows != 10 then + return -1 +endi + +sql select tbname,t1 from stbd where t1 > '2222'; +if $rows != 7 then + return -1 +endi + +sql select tbname,t1 from stbd where t1 >= '4444'; +if $rows != 6 then + return -1 +endi + +sql select tbname,t1 from stbd where t1 >= '3333' and t1 <= '6666'; +if $rows != 4 then + return -1 +endi + +sql select tbname,t1 from stbd where t1 = '3333'; +if $rows != 1 then + return -1 +endi + +sql select tbname,t1 from stbd where t1 <> '6666'; +if $rows != 9 then + return -1 +endi + +sql select tbname,t1 from stbd where t1 < '6666'; +if $rows != 6 then + return -1 +endi + +sql select tbname,t1 from stbd where t1 < '6666' and t1 >= '2222'; +if $rows != 4 then + return -1 +endi + +sql select tbname,t1 from stbd where t1 is null; +if $rows != 0 then + return -1 +endi +sql select tbname,t1 from stbd where t1 is not null; +if $rows != 10 then + return -1 +endi +sql select tbname,t1 from stbe where t1 > '2222'; +if $rows != 7 then + return -1 +endi + +sql select tbname,t1 from stbe where t1 >= '4444'; +if $rows != 6 then + return -1 +endi + +sql select tbname,t1 from stbe where t1 >= '3333' and t1 <= '6666'; +if $rows != 4 then + return -1 +endi + +sql select tbname,t1 from stbe where t1 = '3333'; +if $rows != 1 then + return -1 +endi + +sql select tbname,t1 from stbe where t1 <> '6666'; +if $rows != 9 then + return -1 +endi + +sql select tbname,t1 from stbe where t1 < '6666'; +if $rows != 6 then + return -1 +endi + +sql select tbname,t1 from stbe where t1 < '6666' and t1 >= '2222'; +if $rows != 4 then + return -1 +endi + +sql select tbname,t1 from stbe where t1 is null; +if $rows != 0 then + return -1 +endi +sql select tbname,t1 from stbe where t1 is not null; +if $rows != 10 then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/regex.sim b/tests/script/general/parser/regex.sim index eed36018d4c04ec5752e64105d025347982bfcb0..6d87e1cd7c6c6620eabb44e66195aab3cb177494 100644 --- a/tests/script/general/parser/regex.sim +++ b/tests/script/general/parser/regex.sim @@ -79,6 +79,23 @@ if $rows != 1 then return -1 endi +sql select c1b from $st_name where c1b match '\\.\\*' +if $rows != 0 then + return -1 +endi + +sql select c1b from $st_name where c1b match '\\\\' +if $rows != 0 then + return -1 +endi + +sql insert into $ct1_name values(now+3s, '\\this is engine') + +sql select c1b from $st_name where c1b match '\\' +if $rows != 1 then + return -1 +endi + sql_error select c1b from $st_name where c1b match e; sql_error select c1b from $st_name where c1b nmatch e; diff --git a/tests/script/general/parser/tbnameIn_query.sim b/tests/script/general/parser/tbnameIn_query.sim index db27886bbfde744910068b702199e2079d24c7d2..7fa579b9c2c9d1187c8630fd7f1dd17808b396f0 100644 --- a/tests/script/general/parser/tbnameIn_query.sim +++ b/tests/script/general/parser/tbnameIn_query.sim @@ -125,11 +125,10 @@ if $data21 != 2 then return -1 endi -# multiple tbname in is not allowed NOW -sql_error select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc -#if $rows != 4 then -# return -1 -#endi +sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc +if $rows != 0 then + return -1 +endi #if $data00 != $rowNum then # return -1 #endi diff --git a/tests/test-all.sh b/tests/test-all.sh index eea623b27e482d67e0d3e94a27c7f4376449d556..dfd7f49178ac3d9b4fc5437181a10e9f846aabcf 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -11,15 +11,15 @@ tests_dir=`pwd` IN_TDINTERNAL="community" function stopTaosd { - echo "Stop taosd" + echo "Stop taosd" sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` - while [ -n "$PID" ] - do + while [ -n "$PID" ] + do pkill -TERM -x taosd sleep 1 - PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` - done + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done } function dohavecore(){