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..d7192c939780a272acdebc94baf474aeaf0d7a38 100644 --- a/README-CN.md +++ b/README-CN.md @@ -107,6 +107,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..ab9e0348c8547c43bdbcb4df44a88c53429971e3 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,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/00.index/docs.md b/documentation20/cn/00.index/docs.md index eb136715522e34be4a70fe569ca653faf538f4ee..df5a82517183f967aaaeb6767804cefa795301a1 100644 --- a/documentation20/cn/00.index/docs.md +++ b/documentation20/cn/00.index/docs.md @@ -40,7 +40,7 @@ TDengine是一个高效的存储、查询、分析时序大数据的平台,专 * [超级表管理](/taos-sql#super-table):添加、删除、查看、修改超级表 * [标签管理](/taos-sql#tags):增加、删除、修改标签 * [数据写入](/taos-sql#insert):支持单表单条、多条、多表多条写入,支持历史数据写入 -* [数据查询](/taos-sql#select):支持时间段、值过滤、排序、查询结果手动分页等 +* [数据查询](/taos-sql#select):支持时间段、值过滤、排序、嵌套查询、UINON、JOIN、查询结果手动分页等 * [SQL函数](/taos-sql#functions):支持各种聚合函数、选择函数、计算函数,如avg, min, diff等 * [窗口切分聚合](/taos-sql#aggregation):将表中数据按照时间段等方式进行切割后聚合,降维处理 * [边界限制](/taos-sql#limitation):库、表、SQL等边界限制条件 diff --git a/documentation20/cn/01.evaluation/docs.md b/documentation20/cn/01.evaluation/docs.md index edfa7af7e9a24be9a6d6ab1de3591deb48e22b3a..050046645c24e7db58ef2f39683433c3a4b53169 100644 --- a/documentation20/cn/01.evaluation/docs.md +++ b/documentation20/cn/01.evaluation/docs.md @@ -2,28 +2,27 @@ ## TDengine 简介 -TDengine 是涛思数据面对高速增长的物联网大数据市场和技术挑战推出的创新性的大数据处理产品,它不依赖任何第三方软件,也不是优化或包装了一个开源的数据库或流式计算产品,而是在吸取众多传统关系型数据库、NoSQL 数据库、流式计算引擎、消息队列等软件的优点之后自主开发的产品,在时序空间大数据处理上,有着自己独到的优势。 +TDengine 是涛思数据面对高速增长的物联网大数据市场和技术挑战推出的创新性的大数据处理产品,它不依赖任何第三方软件,也不是优化或包装了一个开源的数据库或流式计算产品,而是在吸取众多传统关系型数据库、NoSQL 数据库、流式计算引擎、消息队列等软件的优点之后自主开发的产品,TDengine 在时序空间大数据处理上,有着自己独到的优势。 -TDengine 的模块之一是时序数据库。但除此之外,为减少研发的复杂度、系统维护的难度,TDengine 还提供缓存、消息队列、订阅、流式计算等功能,为物联网、工业互联网大数据的处理提供全栈的技术方案,是一个高效易用的物联网大数据平台。与 Hadoop 等典型的大数据平台相比,它具有如下鲜明的特点: +TDengine 的模块之一是时序数据库。但除此之外,为减少研发的复杂度、系统维护的难度,TDengine 还提供缓存、消息队列、订阅、流式计算等功能,为物联网和工业互联网大数据的处理提供全栈的技术方案,是一个高效易用的物联网大数据平台。与 Hadoop 等典型的大数据平台相比,TDengine 具有如下鲜明的特点: * __10 倍以上的性能提升__:定义了创新的数据存储结构,单核每秒能处理至少 2 万次请求,插入数百万个数据点,读出一千万以上数据点,比现有通用数据库快十倍以上。 -* __硬件或云服务成本降至 1/5__:由于超强性能,计算资源不到通用大数据方案的 1/5;通过列式存储和先进的压缩算法,存储空间不到通用数据库的 1/10。 +* __硬件或云服务成本降至 1/5__:由于超强性能,计算资源不到通用大数据方案的 1/5;通过列式存储和先进的压缩算法,存储占用不到通用数据库的 1/10。 * __全栈时序数据处理引擎__:将数据库、消息队列、缓存、流式计算等功能融为一体,应用无需再集成 Kafka/Redis/HBase/Spark/HDFS 等软件,大幅降低应用开发和维护的复杂度成本。 * __强大的分析功能__:无论是十年前还是一秒钟前的数据,指定时间范围即可查询。数据可在时间轴上或多个设备上进行聚合。即席查询可通过 Shell, Python, R, MATLAB 随时进行。 -* __与第三方工具无缝连接__:不用一行代码,即可与 Telegraf, Grafana, EMQ, HiveMQ, Prometheus, MATLAB, R 等集成。后续将支持 OPC, Hadoop, Spark 等,BI 工具也将无缝连接。 -* __零运维成本、零学习成本__:安装集群简单快捷,无需分库分表,实时备份。类标准 SQL,支持 RESTful,支持 Python/Java/C/C++/C#/Go/Node.js, 与 MySQL 相似,零学习成本。 +* __高可用性和水平扩展__:通过分布式架构和一致性算法,通过多复制和集群特性,TDengine确保了高可用性和水平扩展性以支持关键任务应用程序。 +* __零运维成本、零学习成本__:安装集群简单快捷,无需分库分表,实时备份。类似标准 SQL,支持 RESTful,支持 Python/Java/C/C++/C#/Go/Node.js, 与 MySQL 相似,零学习成本。 +* __核心开源__:除了一些辅助功能外,TDengine的核心是开源的。企业再也不会被数据库绑定了。这使生态更加强大,产品更加稳定,开发者社区更加活跃。 采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。但需要指出的是,因充分利用了物联网时序数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。 ![TDengine技术生态图](page://images/eco_system.png)
图 1. TDengine技术生态图
- ## TDengine 总体适用场景 作为一个 IoT 大数据平台,TDengine 的典型适用场景是在 IoT 范畴,而且用户有一定的数据量。本文后续的介绍主要针对这个范畴里面的系统。范畴之外的系统,比如 CRM,ERP 等,不在本文讨论范围内。 - ### 数据源特点和需求 从数据源角度,设计人员可以从下面几个角度分析 TDengine 在目标应用系统里面的适用性。 @@ -64,4 +63,3 @@ TDengine 的模块之一是时序数据库。但除此之外,为减少研发 |要求系统可靠运行| | | √ | TDengine 的系统架构非常稳定可靠,日常维护也简单便捷,对维护人员的要求简洁明了,最大程度上杜绝人为错误和事故。| |要求运维学习成本可控| | | √ |同上。| |要求市场有大量人才储备| √ | | | TDengine 作为新一代产品,目前人才市场里面有经验的人员还有限。但是学习成本低,我们作为厂家也提供运维的培训和辅助服务。| - 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..b4537adad6f014712911d568a948b81f866b45f4 100644 --- a/documentation20/cn/08.connector/01.java/docs.md +++ b/documentation20/cn/08.connector/01.java/docs.md @@ -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..3167404f8067610f0bf5f74fe41320decdcbcdf0 100644 --- a/documentation20/cn/08.connector/docs.md +++ b/documentation20/cn/08.connector/docs.md @@ -1166,7 +1166,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/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 6e59fef88e3df79c6f223b44fc84e1dc45516b91..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 @@ -129,8 +139,9 @@ SELECT X(c) FROM table/stable; ## UDF 的一些使用限制 在当前版本下,使用 UDF 存在如下这些限制: -1. UDF 不能与系统内建的 SQL 函数混合使用; -2. UDF 只支持以单个数据列作为输入; -3. UDF 只要创建成功,就会被持久化存储到 MNode 节点中; -4. 无法通过 RESTful 接口来创建 UDF; -5. UDF 在 SQL 中定义的函数名,必须与 .so 库文件实现中的接口函数名前缀保持一致,也即必须是 udfNormalFunc 的名称,而且不可与 TDengine 中已有的内建 SQL 函数重名。 +1. 在创建和调用 UDF 时,服务端和客户端都只支持 Linux 操作系统; +2. UDF 不能与系统内建的 SQL 函数混合使用; +3. UDF 只支持以单个数据列作为输入; +4. UDF 只要创建成功,就会被持久化存储到 MNode 节点中; +5. 无法通过 RESTful 接口来创建 UDF; +6. UDF 在 SQL 中定义的函数名,必须与 .so 库文件实现中的接口函数名前缀保持一致,也即必须是 udfNormalFunc 的名称,而且不可与 TDengine 中已有的内建 SQL 函数重名。 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 ecbde8c5776e3bd3735aed2bd64906f8bef1afc1..5b2d0dd974203db1dafe8758e673a2f0970c3f17 100644 --- a/documentation20/en/01.evaluation/docs.md +++ b/documentation20/en/01.evaluation/docs.md @@ -6,17 +6,16 @@ TDengine is an innovative Big Data processing product launched by TAOS Data in t One of the modules of TDengine is the time-series database. However, in addition to this, to reduce the complexity of research and development and the difficulty of system operation, TDengine also provides functions such as caching, message queuing, subscription, stream computing, etc. TDengine provides a full-stack technical solution for the processing of IoT and Industrial Internet BigData. It is an efficient and easy-to-use IoT Big Data platform. Compared with typical Big Data platforms such as Hadoop, TDengine has the following distinct characteristics: -- **Performance improvement over 10 times**: An innovative data storage structure is defined, with each single core can process at least 20,000 requests per second, insert millions of data points, and read more than 10 million data points, which is more than 10 times faster than other existing general database. +- **Performance improvement over 10 times**: An innovative data storage structure is defined, with every single core that can process at least 20,000 requests per second, insert millions of data points, and read more than 10 million data points, which is more than 10 times faster than other existing general database. - **Reduce the cost of hardware or cloud services to 1/5**: Due to its ultra-performance, TDengine’s computing resources consumption is less than 1/5 of other common Big Data solutions; through columnar storage and advanced compression algorithms, the storage consumption is less than 1/10 of other general databases. - **Full-stack time-series data processing engine**: Integrate database, message queue, cache, stream computing, and other functions, and the applications do not need to integrate with software such as Kafka/Redis/HBase/Spark/HDFS, thus greatly reducing the complexity cost of application development and maintenance. -- **Highly Available and Horizontal Scalable **: With the distributed architecture and consistency algorithm, via multi-replication and clustering features, TDengine ensures high availability and horizontal scalability to support the mission-critical applications. +- **Highly Available and Horizontal Scalable**: With the distributed architecture and consistency algorithm, via multi-replication and clustering features, TDengine ensures high availability and horizontal scalability to support mission-critical applications. - **Zero operation cost & zero learning cost**: Installing clusters is simple and quick, with real-time backup built-in, and no need to split libraries or tables. Similar to standard SQL, TDengine can support RESTful, Python/Java/C/C++/C#/Go/Node.js, and similar to MySQL with zero learning cost. -- **Core is Open Sourced:** Except some auxiliary features, the core of TDengine is open sourced. Enterprise won't be locked by the database anymore. Ecosystem is more strong, product is more stable, and developer communities are more active. +- **Core is Open Sourced:** Except for some auxiliary features, the core of TDengine is open-sourced. Enterprise won't be locked by the database anymore. The ecosystem is more strong, products are more stable, and developer communities are more active. 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) -
Figure 1. TDengine Technology Ecosystem
## Overall Scenarios of TDengine @@ -62,4 +61,4 @@ From the perspective of data sources, designers can analyze the applicability of | ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ | | Require system with high-reliability | | | √ | TDengine has a very robust and reliable system architecture to implement simple and convenient daily operation with streamlined experiences for operators, thus human errors and accidents are eliminated to the greatest extent. | | Require controllable operation learning cost | | | √ | As above. | -| Require abundant talent supply | √ | | | As a new-generation product, it’s still difficult to find talents with TDengine experiences from market. However, the learning cost is low. As the vendor, we also provide extensive operation training and counselling services. | \ No newline at end of file +| Require abundant talent supply | √ | | | As a new-generation product, it’s still difficult to find talents with TDengine experiences from the market. However, the learning cost is low. As the vendor, we also provide extensive operation training and counseling services. | diff --git a/documentation20/en/03.architecture/docs.md b/documentation20/en/03.architecture/docs.md index e0a324acad37d3c9e23d73a1f5762651b32e924d..b9e21b1d4c775876c77b2c9ec999639f30bd0c00 100644 --- a/documentation20/en/03.architecture/docs.md +++ b/documentation20/en/03.architecture/docs.md @@ -155,9 +155,7 @@ 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
- - +
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](page://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](page://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](page://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 @@ -419,7 +413,7 @@ 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
+
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..16adf906bea85d538ac408e1c40b18160aceed78 100644 --- a/documentation20/en/08.connector/01.java/docs.md +++ b/documentation20/en/08.connector/01.java/docs.md @@ -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/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/tsclient.h b/src/client/inc/tsclient.h index ff796cdcbf5cdc7a3d9fbc313226cb9e013b0eda..dd4ff7eb57f20cfc8d31328630fbb14b7acf7017 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -567,7 +567,7 @@ static FORCE_INLINE void convertToSKVRow(SMemRow dest, SMemRow src, SSchema *pSc SKVRow kvRow = memRowKvBody(dest); memRowSetType(dest, SMEM_ROW_KV); - memRowSetKvVersion(kvRow, dataRowVersion(dataRow)); + memRowSetKvVersion(dest, dataRowVersion(dataRow)); kvRowSetNCols(kvRow, nBoundCols); kvRowSetLen(kvRow, (TDRowLenT)(TD_KV_ROW_HEAD_SIZE + sizeof(SColIdx) * nBoundCols)); 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/tscParseOpenTSDB.c b/src/client/src/tscParseOpenTSDB.c index 12f8ec84fd301d2d8851e92826cfcb3d860c1ceb..8e0322cab07ba462b7320cef02011b27b18785d5 100644 --- a/src/client/src/tscParseOpenTSDB.c +++ b/src/client/src/tscParseOpenTSDB.c @@ -178,6 +178,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 +214,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; 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/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/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 89de733ba123157f6454fb35b26f06202a2095c4..d80caad88db865d83986e4c19d95603eadde9884 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/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/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 9b3be1556a47b52142f41b84ca385108088a9018..1c346307eea7310ea6d5f469f36acc63f7d8ccbb 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; @@ -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; @@ -7721,6 +8218,7 @@ static int execBindParamBatch( break; case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: param->buffer_length = sizeof(int32_t); param->buffer = (stbInfo)? (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) @@ -7730,6 +8228,7 @@ static int execBindParamBatch( break; case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: param->buffer_length = sizeof(int8_t); param->buffer = (stbInfo)? (void *)((uintptr_t)*(uintptr_t*)( @@ -7742,6 +8241,7 @@ static int execBindParamBatch( break; case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT: param->buffer_length = sizeof(int16_t); param->buffer = (stbInfo)? (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) @@ -7751,6 +8251,7 @@ static int execBindParamBatch( break; case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: param->buffer_length = sizeof(int64_t); param->buffer = (stbInfo)? (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) @@ -7897,24 +8398,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 +8498,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 +8517,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); @@ -10065,11 +10574,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 +10600,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; + + 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; + } - int n = do_aggreFunc ? (sizeof(g_aggreFunc) / sizeof(g_aggreFunc[0])) : 2; - if (!do_aggreFunc) { + 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 +10624,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 +10645,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 +10679,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; + + 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); fprintf(fp, "Querying On %"PRId64" records:\n", totalData); @@ -10178,18 +10707,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 +10746,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 +10758,7 @@ static void *readMetric(void *sarg) { } fclose(fp); free(command); -#endif + return NULL; } @@ -11225,9 +11765,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 +11777,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 +11959,7 @@ static void testMetaFile() { } } -static void queryResult() { +static void queryAggrFunc() { // query data pthread_t read_id; @@ -11429,7 +11968,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 +11996,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 +12020,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..c3c914e96fc096f59aa701d3496455c754356aa8 100644 --- a/src/kit/taosdump/CMakeLists.txt +++ b/src/kit/taosdump/CMakeLists.txt @@ -9,9 +9,9 @@ AUX_SOURCE_DIRECTORY(. SRC) 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 +19,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 fe7616fa174f5af707892cf3d251689a60111ed6..2f5bf8f6d52bb9e4cc8fabdcbaa727b014f88e64 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -60,7 +60,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) { @@ -181,6 +188,7 @@ typedef struct { int32_t threadIndex; int32_t totalThreads; char dbName[TSDB_DB_NAME_LEN]; + int precision; void *taosCon; int64_t rowsOfDumpOut; int64_t tablesOfDumpOut; @@ -209,7 +217,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 */ @@ -238,7 +246,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}, @@ -246,11 +254,6 @@ static struct argp_option options[] = { {"avro", 'v', 0, 0, "Dump apache avro format data file. By default, dump sql command sequence.", 2}, {"start-time", 'S', "START_TIME", 0, "Start time to dump. Either epoch or ISO8601/RFC3339 format is acceptable. ISO8601 format example: 2017-10-01T00:00:00.000+0800 or 2017-10-0100:00:00:000+0800 or '2017-10-01 00:00:00.000+0800'", 4}, {"end-time", 'E', "END_TIME", 0, "End time to dump. Either epoch or ISO8601/RFC3339 format is acceptable. ISO8601 format example: 2017-10-01T00:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 5}, -#if TSDB_SUPPORT_NANOSECOND == 1 - {"precision", 'C', "PRECISION", 0, "Specify precision for converting human-readable time to epoch. Valid value is one of ms, us, and ns. Default is ms.", 6}, -#else - {"precision", 'C', "PRECISION", 0, "Use specified precision to convert human-readable time. Valid value is one of ms and us. Default is ms.", 6}, -#endif {"data-batch", 'B', "DATA_BATCH", 0, "Number of data point per insert statement. Max value is 32766. Default is 1.", 3}, {"max-sql-len", 'L', "SQL_LEN", 0, "Max length of one sql. Default is 65480.", 3}, {"table-batch", 't', "TABLE_BATCH", 0, "Number of table dumpout into one output file. Default is 1.", 3}, @@ -276,13 +279,17 @@ 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]; int64_t end_time; + char humanEndTime[28]; char precision[8]; + int32_t data_batch; int32_t max_sql_len; int32_t table_batch; // num of table which will be dump into one output file. @@ -296,6 +303,8 @@ typedef struct arguments { bool debug_print; bool verbose_print; bool performance_print; + + int dbCount; } SArguments; /* Our argp parser. */ @@ -318,13 +327,17 @@ static void taosDumpCreateTableClause(STableDef *tableDes, int numOfCols, static void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols, FILE *fp, char* dbName); static int32_t taosDumpTable(char *tbName, char *metric, - FILE *fp, TAOS* taosCon, char* dbName); + FILE *fp, TAOS* taosCon, char* dbName, int precision); static int taosDumpTableData(FILE *fp, char *tbName, TAOS* taosCon, char* dbName, + int precision, char *jsonAvroSchema); static int taosCheckParam(struct arguments *arguments); static void taosFreeDbInfos(); -static void taosStartDumpOutWorkThreads(int32_t numOfThread, char *dbName); +static void taosStartDumpOutWorkThreads( + int32_t numOfThread, + char *dbName, + int precision); struct arguments g_args = { // connection option @@ -343,14 +356,17 @@ 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, // start_time + -INT64_MAX + 1, // start_time + {0}, // humanStartTime INT64_MAX, // end_time + {0}, // humanEndTime "ms", // precision 1, // data_batch TSDB_MAX_SQL_LEN, // max_sql_len @@ -364,16 +380,38 @@ struct arguments g_args = { false, // isDumpIn false, // debug_print false, // verbose_print - false // performance_print + false, // performance_print + 0, // dbCount }; +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) @@ -382,7 +420,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. */ @@ -472,12 +510,8 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { break; case 'S': // parse time here. - g_args.start_time = atol(arg); break; case 'E': - g_args.end_time = atol(arg); - break; - case 'C': break; case 'B': g_args.data_batch = atoi(arg); @@ -550,7 +584,7 @@ static int queryDbImpl(TAOS *taos, char *command) { return 0; } -static void parse_precision_first( +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) { @@ -607,8 +641,36 @@ 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 { continue; } @@ -616,6 +678,73 @@ static void parse_args( } } +static void copyHumanTimeToArg(char *timeStr, bool isStartTime) +{ + if (isStartTime) + strcpy(g_args.humanStartTime, timeStr); + else + strcpy(g_args.humanEndTime, timeStr); +} + +static void copyTimestampToArg(char *timeStr, bool isStartTime) +{ + if (isStartTime) + g_args.start_time = atol(timeStr); + else + g_args.end_time = atol(timeStr); +} + +static void parse_timestamp( + int argc, char *argv[], SArguments *arguments) { + for (int i = 1; i < argc; i++) { + char *tmp; + bool isStartTime = false; + bool isEndTime = false; + + if (strcmp(argv[i], "-S") == 0) { + isStartTime = true; + } else if (strcmp(argv[i], "-E") == 0) { + isEndTime = true; + } + + if (isStartTime || isEndTime) { + if (NULL == argv[i+1]) { + errorPrint("%s need a valid value following!\n", argv[i]); + exit(-1); + } + tmp = strdup(argv[i+1]); + + if (strchr(tmp, ':') && strchr(tmp, '-')) { + copyHumanTimeToArg(tmp, isStartTime); + } else { + copyTimestampToArg(tmp, isStartTime); + } + } + } +} + +static int getPrecisionByString(char *precision) +{ + if (0 == strncasecmp(precision, + "ms", 2)) { + return TSDB_TIME_PRECISION_MILLI; + } else if (0 == strncasecmp(precision, + "us", 2)) { + return TSDB_TIME_PRECISION_MICRO; +#if TSDB_SUPPORT_NANOSECOND == 1 + } else if (0 == strncasecmp(precision, + "ns", 2)) { + return TSDB_TIME_PRECISION_NANO; +#endif + } else { + errorPrint("Invalid time precision: %s", + precision); + } + + return -1; +} + +/* static void parse_timestamp( int argc, char *argv[], SArguments *arguments) { for (int i = 1; i < argc; i++) { @@ -634,6 +763,7 @@ static void parse_timestamp( int64_t tmpEpoch; if (strchr(tmp, ':') && strchr(tmp, '-')) { + strcpy(g_args.humanStartTime, tmp) int32_t timePrec; if (0 == strncasecmp(arguments->precision, "ms", strlen("ms"))) { @@ -672,6 +802,7 @@ static void parse_timestamp( } } } +*/ int main(int argc, char *argv[]) { static char verType[32] = {0}; @@ -682,7 +813,7 @@ int main(int argc, char *argv[]) { /* 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_precision_first(argc, argv, &g_args); parse_timestamp(argc, argv, &g_args); parse_args(argc, argv, &g_args); } @@ -710,11 +841,14 @@ int main(int argc, char *argv[]) { 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); @@ -755,11 +889,14 @@ int main(int argc, char *argv[]) { 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); @@ -816,7 +953,8 @@ int main(int argc, char *argv[]) { static void taosFreeDbInfos() { if (g_dbInfos == NULL) return; - for (int i = 0; i < 128; i++) tfree(g_dbInfos[i]); + for (int i = 0; i < g_args.dbCount; i++) + tfree(g_dbInfos[i]); tfree(g_dbInfos); } @@ -1046,6 +1184,90 @@ static int32_t taosSaveTableOfMetricToTempFile( return 0; } +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; + } + + dbname = strsep(&running, ","); + } + + } + + return -1; +} + +static int getDbCount() +{ + 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; + } + + 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++; + } + + if (count == 0) { + errorPrint("%d databases valid to dump\n", count); + } + + return count; +} + static int taosDumpOut() { TAOS *taos = NULL; TAOS_RES *result = NULL; @@ -1070,7 +1292,14 @@ static int taosDumpOut() { return -1; } - g_dbInfos = (SDbInfo **)calloc(128, sizeof(SDbInfo *)); + g_args.dbCount = getDbCount(); + + if (0 == g_args.dbCount) { + errorPrint("%d databases valid to dump\n", g_args.dbCount); + return -1; + } + + g_dbInfos = (SDbInfo **)calloc(g_args.dbCount, sizeof(SDbInfo *)); if (g_dbInfos == NULL) { errorPrint("%s() LN%d, failed to allocate memory\n", __func__, __LINE__); @@ -1117,24 +1346,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", @@ -1142,38 +1365,55 @@ _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])); - - tstrncpy(g_dbInfos[count]->precision, (char *)row[TSDB_SHOW_DB_PRECISION_INDEX], - min(8, fields[TSDB_SHOW_DB_PRECISION_INDEX].bytes + 1)); - //g_dbInfos[count]->precision = *((int8_t *)row[TSDB_SHOW_DB_PRECISION_INDEX]); - g_dbInfos[count]->update = *((int8_t *)row[TSDB_SHOW_DB_UPDATE_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]); } count++; if (g_args.databases) { - if (count > g_args.arg_list_len) break; + if (count > g_args.dbCount) break; } else if (!g_args.all_databases) { if (count >= 1) break; @@ -1190,7 +1430,7 @@ _dump_db_point: taosDumpDb(g_dbInfos[i], fp, taos); } } else { - if (g_args.arg_list_len == 1) { // case: taosdump + if (g_args.dbCount == 1) { // case: taosdump taosDumpDb(g_dbInfos[0], fp, taos); } else { // case: taosdump tablex tabley ... taosDumpCreateDbClause(g_dbInfos[0], g_args.with_property, fp); @@ -1263,8 +1503,10 @@ _dump_db_point: } // start multi threads to dumpout + taosStartDumpOutWorkThreads(totalNumOfThread, - g_dbInfos[0]->name); + g_dbInfos[0]->name, + getPrecisionByString(g_dbInfos[0]->precision)); char tmpFileName[MAX_FILE_NAME_LEN]; _clean_tmp_file: @@ -1453,7 +1695,7 @@ static int convertSchemaToAvroSchema(STableDef *stableDes, char **avroSchema) static int32_t taosDumpTable( char *tbName, char *metric, - FILE *fp, TAOS* taosCon, char* dbName) { + FILE *fp, TAOS* taosCon, char* dbName, int precision) { int count = 0; STableDef *tableDes = (STableDef *)calloc(1, sizeof(STableDef) @@ -1504,7 +1746,7 @@ static int32_t taosDumpTable( int32_t ret = 0; if (!g_args.schemaonly) { - ret = taosDumpTableData(fp, tbName, taosCon, dbName, + ret = taosDumpTableData(fp, tbName, taosCon, dbName, precision, jsonAvroSchema); } @@ -1595,7 +1837,8 @@ static void* taosDumpOutWorkThreadFp(void *arg) int ret = taosDumpTable( tableRecord.name, tableRecord.metric, - fp, pThread->taosCon, pThread->dbName); + fp, pThread->taosCon, pThread->dbName, + pThread->precision); if (ret >= 0) { // TODO: sum table count and table rows by self pThread->tablesOfDumpOut++; @@ -1644,7 +1887,7 @@ static void* taosDumpOutWorkThreadFp(void *arg) return NULL; } -static void taosStartDumpOutWorkThreads(int32_t numOfThread, char *dbName) +static void taosStartDumpOutWorkThreads(int32_t numOfThread, char *dbName, int precision) { pthread_attr_t thattr; SThreadParaObj *threadObj = @@ -1663,6 +1906,7 @@ static void taosStartDumpOutWorkThreads(int32_t numOfThread, char *dbName) 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) { @@ -1912,7 +2156,8 @@ static int taosDumpDb(SDbInfo *dbInfo, FILE *fp, TAOS *taosCon) { } // start multi threads to dumpout - taosStartDumpOutWorkThreads(numOfThread, dbInfo->name); + taosStartDumpOutWorkThreads(numOfThread, dbInfo->name, + getPrecisionByString(dbInfo->precision)); for (int loopCnt = 0; loopCnt < numOfThread; loopCnt++) { sprintf(tmpBuf, ".tables.tmp.%d", loopCnt); (void)remove(tmpBuf); @@ -2190,14 +2435,38 @@ static int64_t writeResultToSql(TAOS_RES *res, FILE *fp, char *dbName, char *tbN } static int taosDumpTableData(FILE *fp, char *tbName, - TAOS* taosCon, char* dbName, + TAOS* taosCon, char* dbName, int precision, char *jsonAvroSchema) { int64_t totalRows = 0; char sqlstr[1024] = {0}; + + int64_t start_time, end_time; + if (strlen(g_args.humanStartTime)) { + if (TSDB_CODE_SUCCESS != taosParseTime( + g_args.humanStartTime, &start_time, strlen(g_args.humanStartTime), + precision, 0)) { + errorPrint("Input %s, time format error!\n", g_args.humanStartTime); + return -1; + } + } else { + start_time = g_args.start_time; + } + + if (strlen(g_args.humanEndTime)) { + if (TSDB_CODE_SUCCESS != taosParseTime( + g_args.humanEndTime, &end_time, strlen(g_args.humanEndTime), + precision, 0)) { + errorPrint("Input %s, time format error!\n", g_args.humanEndTime); + return -1; + } + } else { + end_time = g_args.end_time; + } + sprintf(sqlstr, "select * from %s.%s where _c0 >= %" PRId64 " and _c0 <= %" PRId64 " order by _c0 asc;", - dbName, tbName, g_args.start_time, g_args.end_time); + dbName, tbName, start_time, end_time); TAOS_RES* res = taos_query(taosCon, sqlstr); int32_t code = taos_errno(res); @@ -2230,12 +2499,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"); 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 a804d18b63ae6971cca74e687cf4393d60e19e23..de0ed97db8dbb87db159aeb5dbc6d52885b7ac59 100644 --- a/src/query/inc/qAggMain.h +++ b/src/query/inc/qAggMain.h @@ -68,17 +68,25 @@ extern "C" { #define TSDB_FUNC_IRATE 30 #define TSDB_FUNC_TID_TAG 31 #define TSDB_FUNC_DERIVATIVE 32 -#define TSDB_FUNC_BLKINFO 33 - -#define TSDB_FUNC_CSUM 34 -#define TSDB_FUNC_MAVG 35 -#define TSDB_FUNC_SAMPLE 36 -#define TSDB_FUNC_MODE 37 -#define TSDB_FUNC_CEIL 38 -#define TSDB_FUNC_FLOOR 39 -#define TSDB_FUNC_ROUND 40 -#define TSDB_FUNC_HLL 41 -#define TSDB_FUNC_HISTOGRAM 42 + +#define TSDB_FUNC_CEIL 33 +#define TSDB_FUNC_FLOOR 34 +#define TSDB_FUNC_ROUND 35 + +#define TSDB_FUNC_CSUM 36 + +#define TSDB_FUNC_MAVG 37 + +#define TSDB_FUNC_SAMPLE 38 + +#define TSDB_FUNC_BLKINFO 39 + +/////////////////////////////////////////// +// the following functions is not implemented. +// after implementation, move them before TSDB_FUNC_BLKINFO. also make TSDB_FUNC_BLKINFO the maxium function index +// #define TSDB_FUNC_HISTOGRAM 40 +// #define TSDB_FUNC_HLL 41 +// #define TSDB_FUNC_MODE 42 #define TSDB_FUNCSTATE_SO 0x1u // single output #define TSDB_FUNCSTATE_MO 0x2u // dynamic number of output, not multinumber of output e.g., TOP/BOTTOM @@ -87,6 +95,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 9a95e41336a74a4b07dec8765892bb9f377a5c9c..834257c8e2536cd715b1e0387b1d8c7d8b9af2c6 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; @@ -4256,6 +4258,233 @@ 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 + +////////////////////////////////////////////////////////////////////////////////// + typedef struct { double cumSum; } SCumSumInfo; @@ -4409,6 +4638,9 @@ static void csum_function(SQLFunctionCtx *pCtx) { } } +////////////////////////////////////////////////////////////////////////////////// + + typedef struct { int32_t pos; double sum; @@ -4656,6 +4888,7 @@ static void mavg_function(SQLFunctionCtx *pCtx) { } } + ////////////////////////////////////////////////////////////////////////////////// typedef struct { int32_t notNullElems; @@ -4828,8 +5061,6 @@ static void sample_func_finalizer(SQLFunctionCtx *pCtx) { doFinalizer(pCtx); } -////////////////////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////////////////////////// /* * function compatible list. @@ -4843,13 +5074,13 @@ static void sample_func_finalizer(SQLFunctionCtx *pCtx) { */ int32_t functionCompatList[] = { // count, sum, avg, min, max, stddev, percentile, apercentile, first, last - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - // last_row,top, bottom, spread, twa, leastsqr, ts, ts_dummy, tag_dummy, ts_comp - 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, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + // last_row,top, bottom, spread, twa, leastsqr, ts, ts_dummy, tag_dummy, ts_comp + 4, -1, -1, 1, 1, 1, 1, 1, 1, -1, + // tag, colprj, tagprj, arithm, diff, first_dist, last_dist, stddev_dst, interp rate, irate + 1, 1, 1, 1, -1, 1, 1, 1, 5, 1, 1, + // tid_tag, deriv, ceil, floor, round, csum, mavg, sample, block_info + 6, 8, 1, 1, 1, -1, -1, -1, 7 }; SAggFunctionInfo aAggs[] = {{ @@ -5251,9 +5482,78 @@ SAggFunctionInfo aAggs[] = {{ noop1, dataBlockRequired, }, + {// 33 + "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 + }, + {// 34 + "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 + }, + {// 35 + "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 + }, + { + // 36 + "csum", + TSDB_FUNC_CSUM, + TSDB_FUNC_INVALID_ID, + TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SELECTIVITY, + csum_function_setup, + csum_function, + doFinalizer, + noop1, + dataBlockRequired, + }, + { + // 37 + "mavg", + TSDB_FUNC_MAVG, + TSDB_FUNC_INVALID_ID, + TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SELECTIVITY, + mavg_function_setup, + mavg_function, + doFinalizer, + noop1, + dataBlockRequired, + }, + { + // 38 + "sample", + TSDB_FUNC_SAMPLE, + TSDB_FUNC_INVALID_ID, + TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SELECTIVITY, + sample_function_setup, + sample_function, + sample_func_finalizer, + noop1, + dataBlockRequired, + }, { - // 33 - "_block_dist", // return table id and the corresponding tags for join match and subscribe + // 39 + "_block_dist", TSDB_FUNC_BLKINFO, TSDB_FUNC_BLKINFO, TSDB_FUNCSTATE_SO | TSDB_FUNCSTATE_STABLE, @@ -5263,40 +5563,4 @@ SAggFunctionInfo aAggs[] = {{ block_func_merge, dataBlockRequired, }, - { - // 34 - "csum", - TSDB_FUNC_CSUM, - TSDB_FUNC_INVALID_ID, - TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SELECTIVITY, - csum_function_setup, - csum_function, - doFinalizer, - noop1, - dataBlockRequired, - }, - { - // 35 - "mavg", - TSDB_FUNC_MAVG, - TSDB_FUNC_INVALID_ID, - TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SELECTIVITY, - mavg_function_setup, - mavg_function, - doFinalizer, - noop1, - dataBlockRequired, - }, - { - // 36 - "sample", - TSDB_FUNC_SAMPLE, - TSDB_FUNC_INVALID_ID, - TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SELECTIVITY, - sample_function_setup, - sample_function, - sample_func_finalizer, - 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 da5481dae184b1cc0aa280f9e3d4a952571abfe1..4aab9dff7debc0b0f193e38d77222f1752196c65 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; @@ -2688,21 +2690,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 @@ -3637,109 +3624,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); @@ -3765,7 +3651,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); @@ -3787,25 +3673,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 ) { @@ -3817,7 +3685,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); @@ -4001,259 +3882,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..2c632d4a17f5394dc28df72414948855b89bc001 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -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/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/-g b/tests/examples/c/-g new file mode 100755 index 0000000000000000000000000000000000000000..3909909e8fe531a7b6d35ca315b8277e7270bb02 Binary files /dev/null and b/tests/examples/c/-g differ diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 28e8d3f012dd4d6b4b12f2a01132b00a2ae7225c..03123afb3584ea94417c88e55edd9f8e232b0fe9 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\"" @@ -1176,8 +1176,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 +1186,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..f364eb76fc34ab0975c00dcae2b8348e58b38517 100644 --- a/tests/examples/c/makefile +++ b/tests/examples/c/makefile @@ -17,6 +17,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 +32,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 db846f2bd7a75ce2294df4968c42dc947541b05b..050f1fd060e5ef455881769f39a60e6f59169a53 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -181,7 +181,7 @@ python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoIns python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py -python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdumpTestNanoSupport.py +python3 test.py -f tools/taosdumpTestNanoSupport.py # python3 ./test.py -f tsdb/tsdbComp.py @@ -359,6 +359,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 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/insertTelnetLines.py b/tests/pytest/insert/insertTelnetLines.py index 8ebb6bd3df4bcd4abfbb8c42cf5024fe066fcce3..4041b309a1007c1177f26d28b022f4e314dcf9ba 100644 --- a/tests/pytest/insert/insertTelnetLines.py +++ b/tests/pytest/insert/insertTelnetLines.py @@ -33,9 +33,9 @@ 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\"", ] code = self._conn.insert_telnet_lines(lines0) @@ -245,8 +245,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 +288,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/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-4985/query-limit-offset.json b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json index 265f42036bc5a4e13dc0766b66fccf32924d7185..ad85f9607b72c5d4562266508bfdcf68837c33bd 100644 --- a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.json +++ b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.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/taosdemoAllTest/TD-4985/query-limit-offset.py b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py index 7f551bcefd152007ebab7a1bc7d110468b69115a..5477223aad0262cf2874496481bc5d138fb3d2cf 100644 --- a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py +++ b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py @@ -13,6 +13,7 @@ import sys import os +import time from util.log import * from util.cases import * from util.sql import * @@ -24,6 +25,9 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) + now = time.time() + self.ts = int(round(now * 1000)) + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -50,6 +54,7 @@ class TDTestCase: # insert: create one or mutiple tables per sql and insert multiple rows per sql # test case for https://jira.taosdata.com:18080/browse/TD-4985 + os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql") os.system("%staosdemo -f tools/taosdemoAllTest/TD-4985/query-limit-offset.json -y " % binPath) tdSql.execute("use db") tdSql.query("select count (tbname) from stb0") @@ -57,25 +62,25 @@ class TDTestCase: for i in range(1000): tdSql.execute('''insert into stb00_9999 values(%d, %d, %d,'test99.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.execute('''insert into stb00_8888 values(%d, %d, %d,'test98.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.execute('''insert into stb00_7777 values(%d, %d, %d,'test97.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.execute('''insert into stb00_6666 values(%d, %d, %d,'test96.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.execute('''insert into stb00_5555 values(%d, %d, %d,'test95.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.execute('''insert into stb00_4444 values(%d, %d, %d,'test94.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.execute('''insert into stb00_3333 values(%d, %d, %d,'test93.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.execute('''insert into stb00_2222 values(%d, %d, %d,'test92.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.execute('''insert into stb00_1111 values(%d, %d, %d,'test91.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.execute('''insert into stb00_100 values(%d, %d, %d,'test90.%s')''' - % (1600000000000 + i, i, -10000+i, i)) + % (self.ts + i, i, -10000+i, i)) tdSql.query("select * from stb0 where c2 like 'test99%' ") tdSql.checkRows(1000) tdSql.query("select * from stb0 where tbname like 'stb00_9999' limit 10" ) @@ -176,7 +181,7 @@ class TDTestCase: tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) - os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql") + def stop(self): tdSql.close() 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/tools/taosdemoAllTest/NanoTestCase/taosdumpTestNanoSupport.py b/tests/pytest/tools/taosdumpTestNanoSupport.py similarity index 98% rename from tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdumpTestNanoSupport.py rename to tests/pytest/tools/taosdumpTestNanoSupport.py index a2059ec924ad1e2239c2709bc99dd58fbafa1337..55f1671daaa09b148bb87d661b8bd1248e6cbb3a 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdumpTestNanoSupport.py +++ b/tests/pytest/tools/taosdumpTestNanoSupport.py @@ -136,7 +136,7 @@ class TDTestCase: # dump part data with -S -E os.system( - '%staosdump --databases timedb1 -S 1625068810000000000 -E 1625068860000000000 -C ns -o ./taosdumptest/dumptmp2 ' % + '%staosdump --databases timedb1 -S 1625068810000000000 -E 1625068860000000000 -o ./taosdumptest/dumptmp2 ' % binPath) os.system( '%staosdump --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' % @@ -218,7 +218,7 @@ class TDTestCase: "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) os.system( - '%staosdump --databases timedb1 -S 1625068810000000 -E 1625068860000000 -C us -o ./taosdumptest/dumptmp2 ' % + '%staosdump --databases timedb1 -S 1625068810000000 -E 1625068860000000 -o ./taosdumptest/dumptmp2 ' % binPath) os.system( '%staosdump --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' % @@ -299,7 +299,7 @@ class TDTestCase: "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) os.system( - '%staosdump --databases timedb1 -S 1625068810000 -E 1625068860000 -C ms -o ./taosdumptest/dumptmp2 ' % + '%staosdump --databases timedb1 -S 1625068810000 -E 1625068860000 -o ./taosdumptest/dumptmp2 ' % binPath) os.system( '%staosdump --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' % 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