diff --git a/Jenkinsfile b/Jenkinsfile index ebac32cb241af1a35556262690544f84ca94d9fc..73bb832d8ea4c16d65f6fff88cb8844415c19f9c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,13 +41,10 @@ def pre_test(){ cd ${WKC} git checkout develop - git reset --hard HEAD~10 - git pull - git fetch - git checkout ${CHANGE_BRANCH} - git reset --hard HEAD~10 + git reset --hard HEAD~10 >/dev/null git pull - git merge develop + git fetch origin +refs/pull/${CHANGE_ID}/merge + git checkout -qf FETCH_HEAD cd ${WK} git reset --hard HEAD~10 git checkout develop @@ -87,11 +84,14 @@ pipeline { steps { pre_test() - sh ''' - cd ${WKC}/tests - find pytest -name '*'sql|xargs rm -rf - ./test-all.sh p1 - date''' + timeout(time: 90, unit: 'MINUTES'){ + sh ''' + cd ${WKC}/tests + find pytest -name '*'sql|xargs rm -rf + ./test-all.sh p1 + date''' + } + } } stage('python_2') { @@ -112,12 +112,14 @@ pipeline { } stage('test_b1') { agent{label 'b1'} - steps { - pre_test() - sh ''' - cd ${WKC}/tests - ./test-all.sh b1fq - date''' + steps { + timeout(time: 90, unit: 'MINUTES'){ + pre_test() + sh ''' + cd ${WKC}/tests + ./test-all.sh b1fq + date''' + } } } @@ -137,12 +139,14 @@ pipeline { ./handle_crash_gen_val_log.sh ''' } - sh ''' - date - cd ${WKC}/tests - ./test-all.sh b2fq - date - ''' + timeout(time: 90, unit: 'MINUTES'){ + sh ''' + date + cd ${WKC}/tests + ./test-all.sh b2fq + date + ''' + } } } @@ -157,12 +161,14 @@ pipeline { ./valgrind-test.sh 2>&1 > mem-error-out.log ./handle_val_log.sh ''' - } - sh ''' - date - cd ${WKC}/tests - ./test-all.sh b3fq - date''' + } + timeout(time: 90, unit: 'MINUTES'){ + sh ''' + date + cd ${WKC}/tests + ./test-all.sh b3fq + date''' + } } } diff --git a/cmake/install.inc b/cmake/install.inc index b0e5c71022c7c30fefd79ed62830db6afeb953f2..a5b01f43cb7e8a302a9cf2d6d7ef48ddb8ed944e 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.16-dist.jar DESTINATION connector/jdbc) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.17-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/cmake/version.inc b/cmake/version.inc old mode 100644 new mode 100755 index 0509a5ce1b2d44f4986c734060853b3aa32addac..f9927bf1c61c62dd27123e1c6aec158c4d1c09cf --- a/cmake/version.inc +++ b/cmake/version.inc @@ -16,13 +16,25 @@ ENDIF () IF (DEFINED GITINFO) SET(TD_VER_GIT ${GITINFO}) ELSE () - SET(TD_VER_GIT "community") + execute_process( + COMMAND git log -1 --format=%H + WORKING_DIRECTORY ${TD_COMMUNITY_DIR} + OUTPUT_VARIABLE GIT_COMMITID + ) + string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID}) + SET(TD_VER_GIT ${GIT_COMMITID}) ENDIF () IF (DEFINED GITINFOI) SET(TD_VER_GIT_INTERNAL ${GITINFOI}) ELSE () - SET(TD_VER_GIT_INTERNAL "internal") + execute_process( + COMMAND git log -1 --format=%H + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMITID + ) + string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID}) + SET(TD_VER_GIT_INTERNAL ${GIT_COMMITID}) ENDIF () IF (DEFINED VERDATE) diff --git a/documentation20/webdocs/assets/tdengine-jdbc-connector.png b/documentation20/webdocs/assets/tdengine-jdbc-connector.png new file mode 100644 index 0000000000000000000000000000000000000000..fdf1dd3fcc5ee222c4a8753efa2c95c5257314bf Binary files /dev/null and b/documentation20/webdocs/assets/tdengine-jdbc-connector.png differ diff --git a/documentation20/webdocs/markdowndocs/Getting Started-ch.md b/documentation20/webdocs/markdowndocs/Getting Started-ch.md index b53c014ba64fb203cb8e6943297fe6117034385c..b8b298b9501a43396e134eb1efa9ba6e6a029b79 100644 --- a/documentation20/webdocs/markdowndocs/Getting Started-ch.md +++ b/documentation20/webdocs/markdowndocs/Getting Started-ch.md @@ -179,7 +179,7 @@ taos> select avg(f1), max(f2), min(f3) from test.t10 interval(10s); -## **支持平台列表** +## 支持平台列表 ### TDengine服务器支持的平台列表 diff --git a/documentation20/webdocs/markdowndocs/Queries-ch.md b/documentation20/webdocs/markdowndocs/Queries-ch.md index 960bb39e6323fe590905de62d2a1021adb19d176..839809ccba1914a9d5cfa9005be9f32e94f19924 100644 --- a/documentation20/webdocs/markdowndocs/Queries-ch.md +++ b/documentation20/webdocs/markdowndocs/Queries-ch.md @@ -9,7 +9,7 @@ TDengine 采用 SQL 作为查询语言。应用程序可以通过 C/C++, Java, Go, Python 连接器发送 SQL 语句,用户可以通过 TDengine 提供的命令行(Command Line Interface, CLI)工具 TAOS Shell 手动执行 SQL 即席查询(Ad-Hoc Query)。TDengine 支持如下查询功能: - 单列、多列数据查询 -- 标签和数值的多种过滤条件:\>, \<, =, \<>, like 等 +- 标签和数值的多种过滤条件:>, <, =, <>, like 等 - 聚合结果的分组(Group by)、排序(Order by)、约束输出(Limit/Offset) - 数值列及聚合结果的四则运算 - 时间戳对齐的连接查询(Join Query: 隐式连接)操作 diff --git a/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md b/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md index 946eec53ad9cc14b91870708ca9d9594dcec8671..3333bbc450d2c8883a45c4879bcbfe951003967b 100644 --- a/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md +++ b/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md @@ -58,26 +58,26 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic - **创建数据库** - ```mysql - CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [UPDATE 1]; - ``` - 说明: - - 1) KEEP是该数据库的数据保留多长天数,缺省是3650天(10年),数据库会自动删除超过时限的数据; - - 2) UPDATE 标志数据库支持更新相同时间戳数据; - - 3) 数据库名最大长度为33; - - 4) 一条SQL 语句的最大长度为65480个字符; - - 5) 数据库还有更多与存储相关的配置参数,请参见系统管理。 + ```mysql + CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [UPDATE 1]; + ``` + 说明: + + 1) KEEP是该数据库的数据保留多长天数,缺省是3650天(10年),数据库会自动删除超过时限的数据; + + 2) UPDATE 标志数据库支持更新相同时间戳数据; + + 3) 数据库名最大长度为33; + + 4) 一条SQL 语句的最大长度为65480个字符; + + 5) 数据库还有更多与存储相关的配置参数,请参见系统管理。 - **显示系统当前参数** - ```mysql - SHOW VARIABLES; - ``` + ```mysql + SHOW VARIABLES; + ``` - **使用数据库** @@ -698,13 +698,13 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 ```mysql SELECT TWA(field_name) FROM tb_name WHERE clause; ``` - 功能说明:时间加权平均函数。统计表/超级表中某列在一段时间内的时间加权平均。 + 功能说明:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。 返回结果数据类型:双精度浮点数Double。 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 - 适用于:表、超级表。 + 适用于:表。 - **SUM** ```mysql @@ -743,7 +743,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 - 适用于:表。 + 适用于:表。(从 2.0.15 版本开始,本函数也支持超级表) 示例: ```mysql @@ -1125,11 +1125,8 @@ SELECT function_list FROM stb_name - WHERE语句可以指定查询的起止时间和其他过滤条件 - FILL语句指定某一时间区间数据缺失的情况下的填充模式。填充模式包括以下几种: 1. 不进行填充:NONE(默认填充模式)。 - 2. VALUE填充:固定值填充,此时需要指定填充的数值。例如:fill(value, 1.23)。 - 3. NULL填充:使用NULL填充数据。例如:fill(null)。 - 4. PREV填充:使用前一个非NULL值填充数据。例如:fill(prev)。 说明: @@ -1157,7 +1154,7 @@ SELECT AVG(current), MAX(current), LEASTSQUARES(current, start_val, step_val), P - 数据库名最大长度为32 - 表名最大长度为192,每行数据最大长度16k个字符 - 列名最大长度为64,最多允许1024列,最少需要2列,第一列必须是时间戳 -- 标签最多允许128个,可以0个,标签总长度不超过16k个字符 +- 标签最多允许128个,可以1个,标签总长度不超过16k个字符 - SQL语句最大长度65480个字符,但可通过系统配置参数maxSQLLength修改,最长可配置为1M - 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制 diff --git a/documentation20/webdocs/markdowndocs/administrator-ch.md b/documentation20/webdocs/markdowndocs/administrator-ch.md index 9eee5b2b69cad573f62a1fa4890ff73c43026bd1..a343f7e97079566208b707b36e46b219f26772e2 100644 --- a/documentation20/webdocs/markdowndocs/administrator-ch.md +++ b/documentation20/webdocs/markdowndocs/administrator-ch.md @@ -124,10 +124,10 @@ taosd -C 对于一个应用场景,可能有多种数据特征的数据并存,最佳的设计是将具有相同数据特征的表放在一个库里,这样一个应用有多个库,而每个库可以配置不同的存储参数,从而保证系统有最优的性能。TDengine允许应用在创建库时指定上述存储参数,如果指定,该参数就将覆盖对应的系统配置参数。举例,有下述SQL: ``` - create database demo days 10 cache 32 blocks 8 replica 3; + create database demo days 10 cache 32 blocks 8 replica 3 update 1; ``` -该SQL创建了一个库demo, 每个数据文件存储10天数据,内存块为32兆字节,每个VNODE占用8个内存块,副本数为3,而其他参数与系统配置完全一致。 +该SQL创建了一个库demo, 每个数据文件存储10天数据,内存块为32兆字节,每个VNODE占用8个内存块,副本数为3,允许更新,而其他参数与系统配置完全一致。 TDengine集群中加入一个新的dnode时,涉及集群相关的一些参数必须与已有集群的配置相同,否则不能成功加入到集群中。会进行校验的参数如下: diff --git a/documentation20/webdocs/markdowndocs/advanced features-ch.md b/documentation20/webdocs/markdowndocs/advanced features-ch.md index cdd9ee81048f0968fb02f036b20e003c66835a4c..0ca8428ecee2c5ef162810737f77cb9cf4b9412b 100644 --- a/documentation20/webdocs/markdowndocs/advanced features-ch.md +++ b/documentation20/webdocs/markdowndocs/advanced features-ch.md @@ -197,7 +197,7 @@ select * from meters where ts > now - 1d and current > 10; 且`restart`是 **false**(**0**),用户程序就不会读到之前已经读取的数据了。 `taos_subscribe`的最后一个参数是以毫秒为单位的轮询周期。 -在同步模式下,如过前后两次调用`taos_consume`的时间间隔小于此时间, +在同步模式下,如果前后两次调用`taos_consume`的时间间隔小于此时间, `taos_consume`会阻塞,直到间隔超过此时间。 异步模式下,这个时间是两次调用回调函数的最小时间间隔。 @@ -414,7 +414,7 @@ TDengine通过查询函数向用户提供毫秒级的数据获取能力。直接 TDengine分配固定大小的内存空间作为缓存空间,缓存空间可根据应用的需求和硬件资源配置。通过适当的设置缓存空间,TDengine可以提供极高性能的写入和查询的支持。TDengine中每个虚拟节点(virtual node)创建时分配独立的缓存池。每个虚拟节点管理自己的缓存池,不同虚拟节点间不共享缓存池。每个虚拟节点内部所属的全部表共享该虚拟节点的缓存池。 -TDengine将内存池按块划分进行管理,数据在内存块里按照列式存储。一个vnode的内存池是在vnode创建时按块分配好的,而且每个内存块按照先进先出的原则进行管理。一张表所需要的内存块是从vnode的内存池中进行分配的,块的大小由系统配置参数cache决定。每张表最大内存块的数目由配置参数tblocks决定,每张表平均的内存块的个数由配置参数ablocks决定。因此对于一个vnode, 总的内存大小为: `cache * ablocks * tables`。内存块参数cache不宜过小,一个cache block需要能存储至少几十条以上记录,才会有效率。参数ablocks最小为2,保证每张表平均至少能分配两个内存块。 +TDengine将内存池按块划分进行管理,数据在内存块里是以行(row)的形式存储。一个vnode的内存池是在vnode创建时按块分配好,而且每个内存块按照先进先出的原则进行管理。在创建内存池时,块的大小由系统配置参数cache决定;每个vnode中内存块的数目则由配置参数blocks决定。因此对于一个vnode,总的内存大小为:`cache * blocks`。一个cache block需要保证每张表能存储至少几十条以上记录,才会有效率。 你可以通过函数last_row快速获取一张表或一张超级表的最后一条记录,这样很便于在大屏显示各设备的实时状态或采集值。例如: diff --git a/documentation20/webdocs/markdowndocs/architecture-ch.md b/documentation20/webdocs/markdowndocs/architecture-ch.md index a666f755156906adb9c4d3e8c18e3e4f8679e255..773d8196f26ff414a9546b474713f46bfb0dd5ac 100644 --- a/documentation20/webdocs/markdowndocs/architecture-ch.md +++ b/documentation20/webdocs/markdowndocs/architecture-ch.md @@ -248,7 +248,7 @@ Master Vnode遵循下面的写入流程: 1. Master vnode收到应用的数据插入请求,验证OK,进入下一步; 2. 如果系统配置参数walLevel大于0,vnode将把该请求的原始数据包写入数据库日志文件WAL。如果walLevel设置为2,而且fsync设置为0,TDengine还将WAL数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; 3. 如果有多个副本,vnode将把数据包转发给同一虚拟节点组内slave vnodes, 该转发包带有数据的版本号(version); -4. 写入内存,并加记录加入到skip list; +4. 写入内存,并将记录加入到skip list; 5. Master vnode返回确认信息给应用,表示写入成功。 6. 如果第2,3,4步中任何一步失败,将直接返回错误给应用。 diff --git a/documentation20/webdocs/markdowndocs/cluster-ch.md b/documentation20/webdocs/markdowndocs/cluster-ch.md index f3f6f2b3005e1dc101fce817520a7e96bdfc0e31..f6019b1a5aabdaea095eafc1919c46432ec88c77 100644 --- a/documentation20/webdocs/markdowndocs/cluster-ch.md +++ b/documentation20/webdocs/markdowndocs/cluster-ch.md @@ -225,7 +225,7 @@ SHOW MNODES; ## Arbitrator的使用 -如果副本数为偶数,当一个vnode group里一半vnode不工作时,是无法从中选出master的。同理,一半mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。 +如果副本数为偶数,当一个vnode group里一半vnode不工作时,是无法从中选出master的。同理,一半mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了Arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含Arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到Arbitrator,那么节点B就能正常工作。 -TDengine提供一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。请点击[安装包下载](https://www.taosdata.com/cn/all-downloads/),在TDengine Arbitrator Linux一节中,选择适合的版本下载并安装。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数`-p`可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数时,系统将自动连接配置的arbitrator。如果副本数为奇数,即使配置了arbitrator, 系统也不会去建立连接。 +TDengine提供一个执行程序,名为 tarbitrator,找任何一台Linux服务器运行它即可。请点击[安装包下载](https://www.taosdata.com/cn/all-downloads/),在TDengine Arbitrator Linux一节中,选择适合的版本下载并安装。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数`-p`可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为Arbitrator的End Point。如果该参数配置了,当副本数为偶数时,系统将自动连接配置的Arbitrator。如果副本数为奇数,即使配置了Arbitrator,系统也不会去建立连接。 diff --git a/documentation20/webdocs/markdowndocs/cluster.md b/documentation20/webdocs/markdowndocs/cluster.md deleted file mode 100644 index 8cf7065f72eb7da75a949fd644b00346523c15ed..0000000000000000000000000000000000000000 --- a/documentation20/webdocs/markdowndocs/cluster.md +++ /dev/null @@ -1,146 +0,0 @@ -#集群安装、管理 - -多个taosd的运行实例可以组成一个集群,以保证TDengine的高可靠运行,并提供水平扩展能力。要了解TDengine 2.0的集群管理,需要对集群的基本概念有所了解,请看TDengine 2.0整体架构一章。 - -集群的每个节点是由End Point来唯一标识的,End Point是由FQDN(Fully Qualified Domain Name)外加Port组成,比如 h1.taosdata.com:6030。一般FQDN就是服务器的hostname,可通过Linux命令“hostname"获取。端口是这个节点对外服务的端口号,缺省是6030,但可以通过taos.cfg里配置参数serverPort进行修改。 - -TDengine的集群管理极其简单,除添加和删除节点需要人工干预之外,其他全部是自动完成,最大程度的降低了运维的工作量。本章对集群管理的操作做详细的描述。 - -##安装、创建第一个节点 - -集群是由一个一个dnode组成的,是从一个dnode的创建开始的。创建第一个节点很简单,就按照["立即开始“](https://www.taosdata.com/cn/getting-started/)一章的方法进行安装、启动即可。 - -启动后,请执行taos, 启动taos shell,从shell里执行命令"show dnodes;",如下所示: - ``` -Welcome to the TDengine shell from Linux, Client Version:2.0.0.0 -Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. - -taos> show dnodes; - id | end_point | vnodes | cores | status | role | create_time | -===================================================================================== - 1 | h1.taos.com:6030 | 0 | 2 | ready | any | 2020-07-31 03:49:29.202 | -Query OK, 1 row(s) in set (0.006385s) - -taos> - ``` -上述命令里,可以看到这个刚启动的这个节点的End Point是:h1.taos.com:6030 - -## 安装、创建后续节点 - -将新的节点添加到现有集群,具体有以下几步: - -1. 按照["立即开始“](https://www.taosdata.com/cn/getting-started/)一章的方法进行安装,但不要启动taosd - -2. 如果是使用涛思数据的官方安装包进行安装,在安装结束时,会询问集群的End Port, 输入第一个节点的End Point即可。如果是源码安装,请编辑配置文件taos.cfg(缺省是在/etc/taos/目录),增加一行: - - ``` - firstEp h1.taos.com:6030 - ``` - - 请注意将示例的“h1.taos.com:6030" 替换为你自己第一个节点的End Point - -3. 按照["立即开始“](https://www.taosdata.com/cn/getting-started/)一章的方法启动taosd - -4. 在Linux shell里执行命令"hostname"找出本机的FQDN, 假设为h2.taos.com。如果无法找到,可以查看taosd日志文件taosdlog.0里前面几行日志(一般在/var/log/taos目录),fqdn以及port都会打印出来。 - -5. 在第一个节点,使用CLI程序taos, 登录进TDengine系统, 使用命令: - - ``` - CREATE DNODE "h2.taos.com:6030"; - ``` - - 将新节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。请注意将示例的“h2.taos.com:6030" 替换为你自己第一个节点的End Point - -6. 使用命令 - - ``` - SHOW DNODES; - ``` - - 查看新节点是否被成功加入。 - -按照上述步骤可以源源不断的将新的节点加入到集群。 - -**提示:** - -- firstEp, secondEp这两个参数仅仅在该节点第一次加入集群时有作用,加入集群后,该节点会保存最新的mnode的End Point列表,不再依赖这两个参数。 -- 两个没有配置first, second参数的dnode启动后,会独立运行起来。这个时候,无法将其中一个节点加入到另外一个节点,形成集群。**无法将两个独立的集群合并成为新的集群**。 - -##节点管理 - -###添加节点 -执行CLI程序taos, 使用root账号登录进系统, 执行: -``` -CREATE DNODE "fqdn:port"; -``` -将新节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。一个节点对外服务的fqdn和port可以通过配置文件taos.cfg进行配置,缺省是自动获取。 - -###删除节点 -执行CLI程序taos, 使用root账号登录进TDengine系统,执行: -``` -DROP DNODE "fqdn:port"; -``` -其中fqdn是被删除的节点的FQDN,port是其对外服务器的端口号 - -###查看节点 -执行CLI程序taos,使用root账号登录进TDengine系统,执行: -``` -SHOW DNODES; -``` -它将列出集群中所有的dnode,每个dnode的fqdn:port, 状态(ready, offline等),vnode数目,还未使用的vnode数目等信息。在添加或删除一个节点后,可以使用该命令查看。 - -如果集群配置了Arbitrator,那么它也会在这个节点列表中显示出来,其role列的值会是“arb”。 - -###查看虚拟节点组 - -为充分利用多核技术,并提供scalability,数据需要分片处理。因此TDengine会将一个DB的数据切分成多份,存放在多个vnode里。这些vnode可能分布在多个dnode里,这样就实现了水平扩展。一个vnode仅仅属于一个DB,但一个DB可以有多个vnode。vnode的是mnode根据当前系统资源的情况,自动进行分配的,无需任何人工干预。 - -执行CLI程序taos,使用root账号登录进TDengine系统,执行: -``` -SHOW VGROUPS; -``` -##高可用性 -TDengine通过多副本的机制来提供系统的高可用性。副本数是与DB关联的,一个集群里可以有多个DB,根据运营的需求,每个DB可以配置不同的副本数。创建数据库时,通过参数replica 指定副本数(缺省为1)。如果副本数为1,系统的可靠性无法保证,只要数据所在的节点宕机,就将无法提供服务。集群的节点数必须大于等于副本数,否则创建表时将返回错误“more dnodes are needed"。比如下面的命令将创建副本数为3的数据库demo: -``` -CREATE DATABASE demo replica 3; -``` -一个DB里的数据会被切片分到多个vnode group,vnode group里的vnode数目就是DB的副本数,同一个vnode group里各vnode的数据是完全一致的。为保证高可用性,vnode group里的vnode一定要分布在不同的dnode里(实际部署时,需要在不同的物理机上),只要一个vgroup里超过半数的vnode处于工作状态,这个vgroup就能正常的对外服务。 - -一个dnode里可能有多个DB的数据,因此一个dnode离线时,可能会影响到多个DB。如果一个vnode group里的一半或一半以上的vnode不工作,那么该vnode group就无法对外服务,无法插入或读取数据,这样会影响到它所属的DB的一部分表的d读写操作。 - -因为vnode的引入,无法简单的给出结论:“集群中过半dnode工作,集群就应该工作”。但是对于简单的情形,很好下结论。比如副本数为3,只有三个dnode,那如果仅有一个节点不工作,整个集群还是可以正常工作的,但如果有两个节点不工作,那整个集群就无法正常工作了。 - -##Mnode的高可用 -TDengine集群是由mnode (taosd的一个模块,逻辑节点) 负责管理的,为保证mnode的高可用,可以配置多个mnode副本,副本数由系统配置参数numOfMnodes决定,有效范围为1-3。为保证元数据的强一致性,mnode副本之间是通过同步的方式进行数据复制的。 - -一个集群有多个dnode, 但一个dnode至多运行一个mnode实例。多个dnode情况下,哪个dnode可以作为mnode呢?这是完全由系统根据整个系统资源情况,自动指定的。用户可通过CLI程序taos,在TDengine的console里,执行如下命令: -``` -SHOW MNODES; -``` -来查看mnode列表,该列表将列出mnode所处的dnode的End Point和角色(master, slave, unsynced 或offline)。 -当集群中第一个节点启动时,该节点一定会运行一个mnode实例,否则该dnode无法正常工作,因为一个系统是必须有至少一个mnode的。如果numOfMnodes配置为2,启动第二个dnode时,该dnode也将运行一个mnode实例。 - -为保证mnode服务的高可用性,numOfMnodes必须设置为2或更大。因为mnode保存的元数据必须是强一致的,如果numOfMnodes大于2,复制参数quorum自动设为2,也就是说,至少要保证有两个副本写入数据成功,才通知客户端应用写入成功。 - -##负载均衡 - -有三种情况,将触发负载均衡,而且都无需人工干预。 - -- 当一个新节点添加进集群时,系统将自动触发负载均衡,一些节点上的数据将被自动转移到新节点上,无需任何人工干预。 -- 当一个节点从集群中移除时,系统将自动把该节点上的数据转移到其他节点,无需任何人工干预。 -- 如果一个节点过热(数据量过大),系统将自动进行负载均衡,将该节点的一些vnode自动挪到其他节点。 - -当上述三种情况发生时,系统将启动一各个节点的负载计算,从而决定如何挪动。 - -##节点离线处理 -如果一个节点离线,TDengine集群将自动检测到。有如下两种情况: -- 改节点离线超过一定时间(taos.cfg里配置参数offlineThreshold控制时长),系统将自动把该节点删除,产生系统报警信息,触发负载均衡流程。如果该被删除的节点重现上线时,它将无法加入集群,需要系统管理员重新将其添加进集群才会开始工作。 -- 离线后,在offlineThreshold的时长内重新上线,系统将自动启动数据恢复流程,等数据完全恢复后,该节点将开始正常工作。 - -##Arbitrator的使用 - -如果副本数为偶数,当一个vnode group里一半vnode不工作时,是无法从中选出master的。同理,一半mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。 - -TDengine安装包里带有一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数`-p`可以指定其对外服务的端口号,缺省是6030。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为Arbitrator的End Point。如果该参数配置了,当副本数为偶数时,系统将自动连接配置的Arbitrator。 - -在配置了Arbitrator的情况下,它也会显示在“show dnodes;”指令给出的节点列表中。 diff --git a/documentation20/webdocs/markdowndocs/connector-ch.md b/documentation20/webdocs/markdowndocs/connector-ch.md index da9c2e5a119e56243e517e9de0e248184d3c3c93..bcaabe3c0a48837cc50d1d2f5f212a57c8e5c912 100644 --- a/documentation20/webdocs/markdowndocs/connector-ch.md +++ b/documentation20/webdocs/markdowndocs/connector-ch.md @@ -288,13 +288,6 @@ C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine * res:`taos_query_a`回调时返回的结果集 * fp:回调函数。其参数`param`是用户可定义的传递给回调函数的参数结构体;`numOfRows`是获取到的数据的行数(不是整个查询结果集的函数)。 在回调函数中,应用可以通过调用`taos_fetch_row`前向迭代获取批量记录中每一行记录。读完一块内的所有记录后,应用需要在回调函数中继续调用`taos_fetch_rows_a`获取下一批记录进行处理,直到返回的记录数(numOfRows)为零(结果返回完成)或记录数为负值(查询出错)。 -- `void taos_fetch_row_a(TAOS_RES *res, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), void *param);` - - 异步获取一条记录。其中: - - * res:`taos_query_a`回调时返回的结果集 - * fp:回调函数。其参数`param`是应用提供的一个用于回调的参数。回调时,第三个参数`row`指向一行记录。不同于`taos_fetch_rows_a`,应用无需调用`taos_fetch_row`来获取一行数据,更加简单,但数据提取性能不及批量获取的API。 - TDengine的异步API均采用非阻塞调用模式。应用程序可以用多线程同时打开多张表,并可以同时对每张打开的表进行查询或者插入操作。需要指出的是,**客户端应用必须确保对同一张表的操作完全串行化**,即对同一个表的插入或查询操作未完成时(未返回时),不能够执行第二个插入或查询操作。 ### 参数绑定API diff --git a/documentation20/webdocs/markdowndocs/connector-java-ch.md b/documentation20/webdocs/markdowndocs/connector-java-ch.md index 7ba573d2e44bb3848d13a2f6b7cb81038843a291..b8390e7af50569b62f031c5a3af3020d43b6f98a 100644 --- a/documentation20/webdocs/markdowndocs/connector-java-ch.md +++ b/documentation20/webdocs/markdowndocs/connector-java-ch.md @@ -1,62 +1,62 @@ # Java Connector -Java连接器支持的系统有: -| **CPU类型** | x64(64bit) | | | ARM64 | ARM32 | -| ------------ | ------------ | -------- | -------- | -------- | -------- | -| **OS类型** | Linux | Win64 | Win32 | Linux | Linux | -| **支持与否** | **支持** | **支持** | **支持** | **支持** | **支持** | +TDengine 提供了遵循 JDBC 标准(3.0)API 规范的 `taos-jdbcdriver` 实现,可在 maven 的中央仓库 [Sonatype Repository][1] 搜索下载。 -Java连接器的使用请参见视频教程。 +`taos-jdbcdriver` 的实现包括 2 种形式: JDBC-JNI 和 JDBC-RESTful(taos-jdbcdriver-2.0.17 开始支持 JDBC-RESTful)。 JDBC-JNI 通过调用客户端 libtaos.so(或 taos.dll )的本地方法实现, JDBC-RESTful 则在内部封装了 RESTful 接口实现。 -TDengine 为了方便 Java 应用使用,提供了遵循 JDBC 标准(3.0)API 规范的 `taos-jdbcdriver` 实现。目前可以通过 [Sonatype Repository][1] 搜索并下载。 +![tdengine-connector](../assets/tdengine-jdbc-connector.png) -由于 TDengine 是使用 c 语言开发的,使用 taos-jdbcdriver 驱动包时需要依赖系统对应的本地函数库。 +上图显示了 3 种 Java 应用使用连接器访问 TDengine 的方式: -* libtaos.so - 在 linux 系统中成功安装 TDengine 后,依赖的本地函数库 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。 - -* taos.dll - 在 windows 系统中安装完客户端之后,驱动包依赖的 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。 +* JDBC-JNI:Java 应用在物理节点1(pnode1)上使用 JDBC-JNI 的 API ,直接调用客户端 API(libtaos.so 或 taos.dll)将写入和查询请求发送到位于物理节点2(pnode2)上的 taosd 实例。 +* RESTful:应用将 SQL 发送给位于物理节点2(pnode2)上的 RESTful 连接器,再调用客户端 API(libtaos.so)。 +* JDBC-RESTful:Java 应用通过 JDBC-RESTful 的 API ,将 SQL 封装成一个 RESTful 请求,发送给物理节点2的 RESTful 连接器。 -> 注意:在 windows 环境开发时需要安装 TDengine 对应的 [windows 客户端][14],Linux 服务器安装完 TDengine 之后默认已安装 client,也可以单独安装 [Linux 客户端][15] 连接远程 TDengine Server。 +TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致,但时序空间数据库与关系对象型数据库服务的对象和技术特征存在差异,导致 `taos-jdbcdriver` 与传统的 JDBC driver 也存在一定差异。在使用时需要注意以下几点: -TDengine 的 JDBC 驱动实现尽可能的与关系型数据库驱动保持一致,但时序空间数据库与关系对象型数据库服务的对象和技术特征的差异导致 taos-jdbcdriver 并未完全实现 JDBC 标准规范。在使用时需要注意以下几点: - -* TDengine 不提供针对单条数据记录的删除和修改的操作,驱动中也没有支持相关方法。 -* 由于不支持删除和修改,所以也不支持事务操作。 +* TDengine 目前不支持针对单条数据记录的删除操作。 +* 目前不支持事务操作。 * 目前不支持表间的 union 操作。 -* 目前不支持嵌套查询(nested query),对每个 Connection 的实例,至多只能有一个打开的 ResultSet 实例;如果在 ResultSet还没关闭的情况下执行了新的查询,TSDBJDBCDriver 则会自动关闭上一个 ResultSet。 - -## TAOS-JDBCDriver 版本以及支持的 TDengine 版本和 JDK 版本 - -| taos-jdbcdriver 版本 | TDengine 版本 | JDK 版本 | -| --- | --- | --- | -| 2.0.12 及以上 | 2.0.8.0 及以上 | 1.8.x | -| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x | -| 1.0.3 | 1.6.1.x 及以上 | 1.8.x | -| 1.0.2 | 1.6.1.x 及以上 | 1.8.x | -| 1.0.1 | 1.6.1.x 及以上 | 1.8.x | - -## TDengine DataType 和 Java DataType - -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, TINYINT |java.lang.Short | -| BOOL | java.lang.Boolean | -| BINARY, NCHAR | java.lang.String | - -## 如何获取 TAOS-JDBCDriver +* 目前不支持嵌套查询(nested query)。 +* 对每个 Connection 的实例,至多只能有一个打开的 ResultSet 实例;如果在 ResultSet 还没关闭的情况下执行了新的查询,taos-jdbcdriver 会自动关闭上一个 ResultSet。 + + +## JDBC-JNI和JDBC-RESTful的对比 + + + + + + + + + + + + + + + + + + + + + + + + + + +
对比项JDBC-JNIJDBC-RESTful
支持的操作系统linux、windows全平台
是否需要安装 client需要不需要
server 升级后是否需要升级 client需要不需要
写入性能JDBC-RESTful 是 JDBC-JNI 的 50%~90%
查询性能JDBC-RESTful 与 JDBC-JNI 没有差别
+ + +## 如何获取 taos-jdbcdriver ### maven 仓库 目前 taos-jdbcdriver 已经发布到 [Sonatype Repository][1] 仓库,且各大仓库都已同步。 + * [sonatype][8] * [mvnrepository][9] * [maven.aliyun][10] @@ -67,30 +67,63 @@ maven 项目中使用如下 pom.xml 配置即可: com.taosdata.jdbc taos-jdbcdriver - 2.0.4 + 2.0.17 ``` ### 源码编译打包 -下载 [TDengine][3] 源码之后,进入 taos-jdbcdriver 源码目录 `src/connector/jdbc` 执行 `mvn clean package` 即可生成相应 jar 包。 +下载 [TDengine][3] 源码之后,进入 taos-jdbcdriver 源码目录 `src/connector/jdbc` 执行 `mvn clean package -Dmaven.test.skip=true` 即可生成相应 jar 包。 + -## 使用说明 + +## JDBC的使用说明 ### 获取连接 -#### 通过JdbcUrl获取连接 +#### 指定URL获取连接 + +通过指定URL获取连接,如下所示: + +```java +Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); +String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata"; +Connection conn = DriverManager.getConnection(jdbcUrl); +``` + +以上示例,使用 **JDBC-RESTful** 的 driver,建立了到 hostname 为 taosdemo.com,端口为 6041,数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。 + +使用 JDBC-RESTful 接口,不需要依赖本地函数库。与 JDBC-JNI 相比,仅需要: + +1. driverClass 指定为“com.taosdata.jdbc.rs.RestfulDriver”; +2. jdbcUrl 以“jdbc:TAOS-RS://”开头; +3. 使用 6041 作为连接端口。 + +如果希望获得更好的写入和查询性能,Java 应用可以使用 **JDBC-JNI** 的driver,如下所示: -通过指定的jdbcUrl获取连接,如下所示: ```java Class.forName("com.taosdata.jdbc.TSDBDriver"); String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"; Connection conn = DriverManager.getConnection(jdbcUrl); ``` -以上示例,建立了到hostname为taosdemo.com,端口为6030(TDengine的默认端口),数据库名为test的连接。这个url中指定用户名(user)为root,密码(password)为taosdata。 + +以上示例,使用了 JDBC-JNI 的 driver,建立了到 hostname 为 taosdemo.com,端口为 6030(TDengine 的默认端口),数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。 + +**注意**:使用 JDBC-JNI 的 driver,taos-jdbcdriver 驱动包时需要依赖系统对应的本地函数库。 + +* libtaos.so + 在 linux 系统中成功安装 TDengine 后,依赖的本地函数库 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。 + +* taos.dll + 在 windows 系统中安装完客户端之后,驱动包依赖的 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。 + +> 在 windows 环境开发时需要安装 TDengine 对应的 [windows 客户端][14],Linux 服务器安装完 TDengine 之后默认已安装 client,也可以单独安装 [Linux 客户端][15] 连接远程 TDengine Server。 + +JDBC-JNI 的使用请参见视频教程。 TDengine 的 JDBC URL 规范格式为: -`jdbc:TAOS://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]` +`jdbc:[TAOS|TAOS-RS]://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]` + url中的配置参数如下: * user:登录 TDengine 用户名,默认值 root。 * password:用户登录密码,默认值 taosdata。 @@ -99,13 +132,17 @@ url中的配置参数如下: * locale:客户端语言环境,默认值系统当前 locale。 * timezone:客户端使用的时区,默认值为系统当前时区。 -#### 使用JdbcUrl和Properties获取连接 -除了通过指定的jdbcUrl获取连接,还可以使用Properties指定建立连接时的参数,如下所示: + +#### 指定URL和Properties获取连接 + +除了通过指定的 URL 获取连接,还可以使用 Properties 指定建立连接时的参数,如下所示: ```java public Connection getConn() throws Exception{ Class.forName("com.taosdata.jdbc.TSDBDriver"); + // Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"; + // String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata"; Properties connProps = new Properties(); connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); @@ -114,9 +151,10 @@ public Connection getConn() throws Exception{ return conn; } ``` -以上示例,建立一个到hostname为taosdemo.com,端口为6030,数据库名为test的连接。这个连接在url中指定了用户名(user)为root,密码(password)为taosdata,并在connProps中指定了使用的字符集、语言环境、时区等信息。 -properties中的配置参数如下: +以上示例,建立一个到 hostname 为 taosdemo.com,端口为 6030,数据库名为 test 的连接。注释为使用 JDBC-RESTful 时的方法。这个连接在 url 中指定了用户名(user)为 root,密码(password)为 taosdata,并在 connProps 中指定了使用的字符集、语言环境、时区等信息。 + +properties 中的配置参数如下: * TSDBDriver.PROPERTY_KEY_USER:登录 TDengine 用户名,默认值 root。 * TSDBDriver.PROPERTY_KEY_PASSWORD:用户登录密码,默认值 taosdata。 * TSDBDriver.PROPERTY_KEY_CONFIG_DIR:客户端配置文件目录路径,Linux OS 上默认值 /etc/taos ,Windows OS 上默认值 C:/TDengine/cfg。 @@ -124,10 +162,14 @@ properties中的配置参数如下: * TSDBDriver.PROPERTY_KEY_LOCALE:客户端语言环境,默认值系统当前 locale。 * TSDBDriver.PROPERTY_KEY_TIME_ZONE:客户端使用的时区,默认值为系统当前时区。 + + #### 使用客户端配置文件建立连接 -当使用JDBC连接TDengine集群时,可以使用客户端配置文件,在客户端配置文件中指定集群的firstEp、secondEp参数。 + +当使用 JDBC-JNI 连接 TDengine 集群时,可以使用客户端配置文件,在客户端配置文件中指定集群的 firstEp、secondEp参数。 如下所示: -1. 在java中不指定hostname和port + +1. 在 Java 应用中不指定 hostname 和 port ```java public Connection getConn() throws Exception{ Class.forName("com.taosdata.jdbc.TSDBDriver"); @@ -140,7 +182,7 @@ public Connection getConn() throws Exception{ return conn; } ``` -2. 在配置文件中指定firstEp和secondEp +2. 在配置文件中指定 firstEp 和 secondEp ``` # first fully qualified domain name (FQDN) for TDengine system firstEp cluster_node1:6030 @@ -155,17 +197,19 @@ secondEp cluster_node2:6030 # locale en_US.UTF-8 ``` -以上示例,jdbc会使用客户端的配置文件,建立到hostname为cluster_node1,端口为6030,数据库名为test的连接。当集群中firstEp节点失效时,JDBC会尝试使用secondEp连接集群。 -TDengine中,只要保证firstEp和secondEp中一个节点有效,就可以正常建立到集群的连接。 +以上示例,jdbc 会使用客户端的配置文件,建立到 hostname 为 cluster_node1、端口为 6030、数据库名为 test 的连接。当集群中 firstEp 节点失效时,JDBC 会尝试使用 secondEp 连接集群。 +TDengine 中,只要保证 firstEp 和 secondEp 中一个节点有效,就可以正常建立到集群的连接。 -> 注意:这里的配置文件指的是调用JDBC Connector的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值 C://TDengine/cfg/taos.cfg。 +> 注意:这里的配置文件指的是调用 JDBC Connector 的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值 C://TDengine/cfg/taos.cfg。 #### 配置参数的优先级 -通过以上3种方式获取连接,如果配置参数在url、Properties、客户端配置文件中有重复,则参数的`优先级由高到低`分别如下: + +通过以上 3 种方式获取连接,如果配置参数在 url、Properties、客户端配置文件中有重复,则参数的`优先级由高到低`分别如下: 1. JDBC URL 参数,如上所述,可以在 JDBC URL 的参数中指定。 2. Properties connProps 3. 客户端配置文件 taos.cfg -例如:在url中指定了password为taosdata,在Properties中指定了password为taosdemo,那么,JDBC会使用url中的password建立连接。 + +例如:在 url 中指定了 password 为 taosdata,在 Properties 中指定了 password 为 taosdemo,那么,JDBC 会使用 url 中的 password 建立连接。 > 更多详细配置请参考[客户端配置][13] @@ -183,6 +227,7 @@ stmt.executeUpdate("use db"); // create table stmt.executeUpdate("create table if not exists tb (ts timestamp, temperature int, humidity float)"); ``` + > 注意:如果不使用 `use db` 指定数据库,则后续对表的操作都需要增加数据库名称作为前缀,如 db.tb。 ### 插入数据 @@ -193,6 +238,7 @@ int affectedRows = stmt.executeUpdate("insert into tb values(now, 23, 10.3) (now System.out.println("insert " + affectedRows + " rows."); ``` + > now 为系统内部函数,默认为服务器当前时间。 > `now + 1s` 代表服务器当前时间往后加 1 秒,数字后面代表时间单位:a(毫秒), s(秒), m(分), h(小时), d(天),w(周), n(月), y(年)。 @@ -214,6 +260,7 @@ while(resultSet.next()){ System.out.printf("%s, %d, %s\n", ts, temperature, humidity); } ``` + > 查询和操作关系型数据库一致,使用下标获取返回字段内容时从 1 开始,建议使用字段名称获取。 ### 订阅 @@ -248,7 +295,7 @@ while(true) { } ``` -`consume` 方法返回一个结果集,其中包含从上次 `consume` 到目前为止的所有新数据。请务必按需选择合理的调用 `consume` 的频率(如例子中的`Thread.sleep(1000)`),否则会给服务端造成不必要的压力。 +`consume` 方法返回一个结果集,其中包含从上次 `consume` 到目前为止的所有新数据。请务必按需选择合理的调用 `consume` 的频率(如例子中的 `Thread.sleep(1000)`),否则会给服务端造成不必要的压力。 #### 关闭订阅 @@ -265,8 +312,11 @@ resultSet.close(); stmt.close(); conn.close(); ``` + > `注意务必要将 connection 进行关闭`,否则会出现连接泄露。 + + ## 与连接池使用 **HikariCP** @@ -306,6 +356,7 @@ conn.close(); connection.close(); // put back to conneciton pool } ``` + > 通过 HikariDataSource.getConnection() 获取连接后,使用完成后需要调用 close() 方法,实际上它并不会关闭连接,只是放回连接池中。 > 更多 HikariCP 使用问题请查看[官方说明][5] @@ -356,6 +407,7 @@ public static void main(String[] args) throws Exception { connection.close(); // put back to conneciton pool } ``` + > 更多 druid 使用问题请查看[官方说明][6] **注意事项** @@ -370,10 +422,43 @@ server_status()| Query OK, 1 row(s) in set (0.000141s) ``` + + ## 与框架使用 * Spring JdbcTemplate 中使用 taos-jdbcdriver,可参考 [SpringJdbcTemplate][11] -* Springboot + Mybatis 中使用,可参考 [springbootdemo][12] +* Springboot + Mybatis 中使用,可参考 [springbootdemo + + + +## TAOS-JDBCDriver 版本以及支持的 TDengine 版本和 JDK 版本 + +| taos-jdbcdriver 版本 | TDengine 版本 | JDK 版本 | +| -------------------- | ----------------- | -------- | +| 2.0.12 及以上 | 2.0.8.0 及以上 | 1.8.x | +| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.x | 1.8.x | +| 1.0.3 | 1.6.1.x 及以上 | 1.8.x | +| 1.0.2 | 1.6.1.x 及以上 | 1.8.x | +| 1.0.1 | 1.6.1.x 及以上 | 1.8.x | + + + +## TDengine DataType 和 Java DataType + +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, TINYINT | java.lang.Short | +| BOOL | java.lang.Boolean | +| BINARY, NCHAR | java.lang.String | + + ## 常见问题 @@ -381,7 +466,7 @@ Query OK, 1 row(s) in set (0.000141s) **原因**:程序没有找到依赖的本地函数库 taos。 - **解决方法**:windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,linux 下将建立如下软链 ` ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 + **解决方法**:windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 * java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform @@ -406,3 +491,4 @@ Query OK, 1 row(s) in set (0.000141s) [13]: https://www.taosdata.com/cn/documentation20/administrator/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E9%85%8D%E7%BD%AE [14]: https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client [15]: https://www.taosdata.com/cn/getting-started/#%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B + diff --git a/documentation20/webdocs/markdowndocs/faq-ch.md b/documentation20/webdocs/markdowndocs/faq-ch.md index 79139078c13bda797299b470b417061c61169a10..cd6f0ae08caf19340b6cef9a9428abcb66c97dc6 100644 --- a/documentation20/webdocs/markdowndocs/faq-ch.md +++ b/documentation20/webdocs/markdowndocs/faq-ch.md @@ -85,7 +85,9 @@ TDengine还没有一组专用的validation queries。然而建议你使用系统 ## 9. 我可以删除或更新一条记录吗? -不能。因为TDengine是为联网设备采集的数据设计的,不容许修改。但TDengine提供数据保留策略,只要数据记录超过保留时长,就会被自动删除。 +TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。 + +从 2.0.8.0 开始,TDengine 支持更新已经写入数据的功能。使用更新功能需要在创建数据库时使用 UPDATE 1 参数,之后可以使用 INSERT INTO 命令更新已经写入的相同时间戳数据。UPDATE 参数不支持 ALTER DATABASE 命令修改。没有使用 UPDATE 1 参数创建的数据库,写入相同时间戳的数据不会修改之前的数据,也不会报错。 ## 10. 我怎么创建超过1024列的表? @@ -132,8 +134,3 @@ TDengine是根据hostname唯一标志一台机器的,在数据文件从机器A - 2.0.7.0 及以后的版本,到/var/lib/taos/dnode下,修复dnodeEps.json的dnodeId对应的FQDN,重启。确保机器内所有机器的此文件是完全相同的。 - 1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。 -## 17. TDengine 是否支持删除或更新已经写入的数据? - -TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。 - -从 2.0.8.0 开始,TDengine 支持更新已经写入数据的功能。使用更新功能需要在创建数据库时使用 UPDATE 1 参数,之后可以使用 INSERT INTO 命令更新已经写入的相同时间戳数据。UPDATE 参数不支持 ALTER DATABASE 命令修改。没有使用 UPDATE 1 参数创建的数据库,写入相同时间戳的数据不会修改之前的数据,也不会报错。 \ No newline at end of file diff --git a/documentation20/webdocs/markdowndocs/insert-ch.md b/documentation20/webdocs/markdowndocs/insert-ch.md index 3fa48c1f508bedf7b4000ffe9f7ef8c96e42d606..7d380ac952dce5f57ff259159c33dd9e9b53edf3 100644 --- a/documentation20/webdocs/markdowndocs/insert-ch.md +++ b/documentation20/webdocs/markdowndocs/insert-ch.md @@ -222,7 +222,7 @@ MQTT是一流行的物联网数据传输协议,TDengine 可以很方便的接 ## EMQ Broker 直接写入 -EMQ是一开源的MQTT Broker软件,无需任何代码,只需要在EMQ Dashboard里使用“规则”做简单配置,即可将MQTT的数据直接写入TDengine。EMQ X 支持通过 发送到 Web 服务 的方式保存数据到 TDengine,也在企业版上提供原生的 TDEngine 驱动实现直接保存。详细使用方法请参考EMQ 官方文档。 +EMQ是一开源的MQTT Broker软件,无需任何代码,只需要在EMQ Dashboard里使用“规则”做简单配置,即可将MQTT的数据直接写入TDengine。EMQ X 支持通过 发送到 Web 服务 的方式保存数据到 TDengine,也在企业版上提供原生的 TDengine 驱动实现直接保存。详细使用方法请参考EMQ 官方文档。 ## HiveMQ Broker 直接写入 diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 2908a8a21e503acd96c4d9d3976c9ee67bb86561..73004fe7b722d2fd2c15930f69a38d78aca4220d 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -265,9 +265,6 @@ # maximum display width of binary and nchar fields in the shell. The parts exceeding this limit will be hidden # maxBinaryDisplayWidth 30 -# enable/disable telemetry reporting -# telemetryReporting 1 - # enable/disable stream (continuous query) # stream 1 diff --git a/packaging/docker/Dockerfile b/packaging/docker/Dockerfile index 44ccafd04460c8beef0a4b2f5ae715033328f807..e13cad41204c3f28ed678a664bf7b9b7f5f8715d 100644 --- a/packaging/docker/Dockerfile +++ b/packaging/docker/Dockerfile @@ -1,14 +1,16 @@ -FROM ubuntu:20.04 +FROM ubuntu:18.04 WORKDIR /root -ARG version -RUN echo $version -COPY tdengine.tar.gz /root/ -RUN tar -zxf tdengine.tar.gz -WORKDIR /root/TDengine-server-$version/ -RUN /bin/bash install.sh -e no +ARG pkgFile +ARG dirName +RUN echo ${pkgFile} +RUN echo ${dirName} +COPY ${pkgFile} /root/ +RUN tar -zxf ${pkgFile} +WORKDIR /root/${dirName}/ +RUN /bin/bash install.sh -e no ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib" ENV LANG=en_US.UTF-8 diff --git a/packaging/docker/dockerManifest.sh b/packaging/docker/dockerManifest.sh new file mode 100755 index 0000000000000000000000000000000000000000..ca2c3c66c9875a697b372f73448aa53deb887f68 --- /dev/null +++ b/packaging/docker/dockerManifest.sh @@ -0,0 +1,44 @@ +#!/bin/bash +set -e +#set -x + +# dockerbuild.sh +# -n [version number] +# -p [xxxx] + +# set parameters by default value +verNumber="" +passWord="" + +while getopts "hn:p:" arg +do + case $arg in + n) + #echo "verNumber=$OPTARG" + verNumber=$(echo $OPTARG) + ;; + p) + #echo "passWord=$OPTARG" + passWord=$(echo $OPTARG) + ;; + h) + echo "Usage: `basename $0` -n [version number] " + echo " -p [password for docker hub] " + exit 0 + ;; + ?) #unknow option + echo "unkonw argument" + exit 1 + ;; + esac +done + +echo "verNumber=${verNumber}" + +docker manifest create -a tdengine/tdengine:${verNumber} tdengine/tdengine-amd64:${verNumber} tdengine/tdengine-aarch64:${verNumber} tdengine/tdengine-aarch32:${verNumber} + +docker login -u tdengine -p ${passWord} #replace the docker registry username and password + +docker manifest push tdengine/tdengine:${verNumber} + +# how set latest version ??? diff --git a/packaging/docker/dockerbuild-aarch64.sh b/packaging/docker/dockerbuild-aarch64.sh deleted file mode 100755 index 795eaed5491834cf5601e567440a314d6e1f9629..0000000000000000000000000000000000000000 --- a/packaging/docker/dockerbuild-aarch64.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -x -docker build --rm -f "Dockerfile" -t tdengine/tdengine-aarch64:$1 "." --build-arg version=$1 -docker login -u tdengine -p $2 #replace the docker registry username and password -docker push tdengine/tdengine-aarch64:$1 diff --git a/packaging/docker/dockerbuild.sh b/packaging/docker/dockerbuild.sh index 48e2f7ead63356e8210d03beff2add6796558f5b..b7991465b0940c86ac6d620d498901ab5e1c9ac2 100755 --- a/packaging/docker/dockerbuild.sh +++ b/packaging/docker/dockerbuild.sh @@ -1,5 +1,63 @@ #!/bin/bash -set -x -docker build --rm -f "Dockerfile" -t tdengine/tdengine:$1 "." --build-arg version=$1 -docker login -u tdengine -p $2 #replace the docker registry username and password -docker push tdengine/tdengine:$1 +set -e +#set -x + +# dockerbuild.sh +# -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] +# -f [pkg file] +# -n [version number] +# -p [password for docker hub] + +# set parameters by default value +cpuType=amd64 +verNumber="" +passWord="" +pkgFile="" + +while getopts "hc:n:p:f:" arg +do + case $arg in + c) + #echo "cpuType=$OPTARG" + cpuType=$(echo $OPTARG) + ;; + n) + #echo "verNumber=$OPTARG" + verNumber=$(echo $OPTARG) + ;; + p) + #echo "passWord=$OPTARG" + passWord=$(echo $OPTARG) + ;; + f) + #echo "pkgFile=$OPTARG" + pkgFile=$(echo $OPTARG) + ;; + h) + echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] " + echo " -f [pkg file] " + echo " -n [version number] " + echo " -p [password for docker hub] " + exit 0 + ;; + ?) #unknow option + echo "unkonw argument" + exit 1 + ;; + esac +done + +echo "cpuType=${cpuType} verNumber=${verNumber} pkgFile=${pkgFile} " +echo "$(pwd)" +echo "====NOTES: ${pkgFile} must be in the same directory as dockerbuild.sh====" + +dirName=${pkgFile%-Linux*} +#echo "dirName=${dirName}" + +docker build --rm -f "Dockerfile" -t tdengine/tdengine-${cpuType}:${verNumber} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName} +docker login -u tdengine -p ${passWord} #replace the docker registry username and password +docker push tdengine/tdengine-${cpuType}:${verNumber} + +# set this version to latest version +docker tag tdengine/tdengine-${cpuType}:${verNumber} tdengine/tdengine-${cpuType}:latest +docker push tdengine/tdengine-${cpuType}:latest diff --git a/packaging/docker/dockerbuildi.sh b/packaging/docker/dockerbuildi.sh new file mode 100755 index 0000000000000000000000000000000000000000..a0a954e30fe9c3637abe4d219001235d793466e0 --- /dev/null +++ b/packaging/docker/dockerbuildi.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# + +set -e +#set -x + +# dockerbuild.sh +# -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] +# -n [version number] +# -p [password for docker hub] + +# set parameters by default value +cpuType=aarch64 +verNumber="" +passWord="" + +while getopts "hc:n:p:f:" arg +do + case $arg in + c) + #echo "cpuType=$OPTARG" + cpuType=$(echo $OPTARG) + ;; + n) + #echo "verNumber=$OPTARG" + verNumber=$(echo $OPTARG) + ;; + p) + #echo "passWord=$OPTARG" + passWord=$(echo $OPTARG) + ;; + h) + echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] " + echo " -n [version number] " + echo " -p [password for docker hub] " + exit 0 + ;; + ?) #unknow option + echo "unkonw argument" + exit 1 + ;; + esac +done + +pkgFile=TDengine-server-${verNumber}-Linux-${cpuType}.tar.gz + +echo "cpuType=${cpuType} verNumber=${verNumber} pkgFile=${pkgFile} " + +scriptDir=`pwd` +pkgDir=$scriptDir/../../release/ + +cp -f ${pkgDir}/${pkgFile} . + +./dockerbuild.sh -c ${cpuType} -f ${pkgFile} -n ${verNumber} -p ${passWord} + +rm -f ${pkgFile} diff --git a/packaging/tools/taosd-dump-cfg.gdb b/packaging/tools/taosd-dump-cfg.gdb new file mode 100644 index 0000000000000000000000000000000000000000..9774ccf82283817edea5f49b59e0c6cb6f529577 --- /dev/null +++ b/packaging/tools/taosd-dump-cfg.gdb @@ -0,0 +1,144 @@ +# Usage: +# sudo gdb -x ./taosd-dump-cfg.gdb + +define attach_pidof + if $argc != 1 + help attach_pidof + else + shell echo -e "\ +set \$PID = "$(echo $(pidof $arg0) 0 | cut -d " " -f 1)"\n\ +if \$PID > 0\n\ + attach "$(pidof -s $arg0)"\n\ +else\n\ + print \"Process '"$arg0"' not found\"\n\ +end" > /tmp/gdb.pidof + source /tmp/gdb.pidof + end +end + +document attach_pidof +Attach to process by name +Usage: attach_pidof PROG_NAME +end + +set $TAOS_CFG_VTYPE_INT8 = 0 +set $TAOS_CFG_VTYPE_INT16 = 1 +set $TAOS_CFG_VTYPE_INT32 = 2 +set $TAOS_CFG_VTYPE_FLOAT = 3 +set $TAOS_CFG_VTYPE_STRING = 4 +set $TAOS_CFG_VTYPE_IPSTR = 5 +set $TAOS_CFG_VTYPE_DIRECTORY = 6 + +set $TSDB_CFG_CTYPE_B_CONFIG = 1U +set $TSDB_CFG_CTYPE_B_SHOW = 2U +set $TSDB_CFG_CTYPE_B_LOG = 4U +set $TSDB_CFG_CTYPE_B_CLIENT = 8U +set $TSDB_CFG_CTYPE_B_OPTION = 16U +set $TSDB_CFG_CTYPE_B_NOT_PRINT = 32U + +set $TSDB_CFG_PRINT_LEN = 53 + +define print_blank + if $argc == 1 + set $blank_len = $arg0 + while $blank_len > 0 + printf "%s", " " + set $blank_len = $blank_len - 1 + end + end +end + +define dump_cfg + if $argc != 1 + help dump_cfg + else + set $blen = $TSDB_CFG_PRINT_LEN - (int)strlen($arg0.option) + if $blen < 0 + $blen = 0 + end + #printf "%s: %d\n", "******blen: ", $blen + printf "%s: ", $arg0.option + print_blank $blen + + if $arg0.valType == $TAOS_CFG_VTYPE_INT8 + printf "%d\n", *((int8_t *) $arg0.ptr) + else + if $arg0.valType == $TAOS_CFG_VTYPE_INT16 + printf "%d\n", *((int16_t *) $arg0.ptr) + else + if $arg0.valType == $TAOS_CFG_VTYPE_INT32 + printf "%d\n", *((int32_t *) $arg0.ptr) + else + if $arg0.valType == $TAOS_CFG_VTYPE_FLOAT + printf "%f\n", *((float *) $arg0.ptr) + else + printf "%s\n", $arg0.ptr + end + end + end + end + end +end + +document dump_cfg +Dump a cfg entry +Usage: dump_cfg cfg +end + +set pagination off + +attach_pidof taosd + +set $idx=0 +#print tsGlobalConfigNum +#set $end=$1 +set $end=tsGlobalConfigNum + +p "*=*=*=*=*=*=*=*=*= taos global config:" +#while ($idx .lt. $end) +while ($idx < $end) + # print tsGlobalConfig[$idx].option + set $cfg = tsGlobalConfig[$idx] + set $tsce = tscEmbedded +# p "1" + if ($tsce == 0) + if !($cfg.cfgType & $TSDB_CFG_CTYPE_B_CLIENT) + end + else + if $cfg.cfgType & $TSDB_CFG_CTYPE_B_NOT_PRINT + else + if !($cfg.cfgType & $TSDB_CFG_CTYPE_B_SHOW) + else + dump_cfg $cfg + end + end + end + + set $idx=$idx+1 +end + +set $idx=0 + +p "*=*=*=*=*=*=*=*=*= taos local config:" +while ($idx < $end) + set $cfg = tsGlobalConfig[$idx] + set $tsce = tscEmbedded + if ($tsce == 0) + if !($cfg.cfgType & $TSDB_CFG_CTYPE_B_CLIENT) + end + else + if $cfg.cfgType & $TSDB_CFG_CTYPE_B_NOT_PRINT + else + if ($cfg.cfgType & $TSDB_CFG_CTYPE_B_SHOW) + else + dump_cfg $cfg + end + end + end + + set $idx=$idx+1 +end + +detach + +quit diff --git a/src/balance/src/bnThread.c b/src/balance/src/bnThread.c index 84f8694fca7248abb27529f5e8268dc0e08bf815..3931acd0536dab48e11b63a7cd045c3ede3b3937 100644 --- a/src/balance/src/bnThread.c +++ b/src/balance/src/bnThread.c @@ -56,7 +56,7 @@ int32_t bnInitThread() { pthread_attr_destroy(&thattr); if (ret != 0) { - mError("failed to create balance thread since %s", strerror(errno)); + mError("failed to create balance thread since %s", strerror(ret)); return -1; } diff --git a/src/client/inc/tscLocalMerge.h b/src/client/inc/tscLocalMerge.h index 06176451881b30ebe4c24bfcd478ceeb221a86de..581cd37cbd53cb87847fc5a13c88b03eb797d93a 100644 --- a/src/client/inc/tscLocalMerge.h +++ b/src/client/inc/tscLocalMerge.h @@ -38,7 +38,7 @@ typedef struct SLocalDataSource { tFilePage filePage; } SLocalDataSource; -typedef struct SLocalReducer { +typedef struct SLocalMerger { SLocalDataSource ** pLocalDataSrc; int32_t numOfBuffer; int32_t numOfCompleted; @@ -62,7 +62,7 @@ typedef struct SLocalReducer { bool discard; int32_t offset; // limit offset value bool orderPrjOnSTable; // projection query on stable -} SLocalReducer; +} SLocalMerger; typedef struct SRetrieveSupport { tExtMemBuffer ** pExtMemBuffer; // for build loser tree @@ -89,10 +89,10 @@ int32_t tscFlushTmpBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tF /* * create local reducer to launch the second-stage reduce process at client site */ -void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc, +void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc, SColumnModel *finalModel, SColumnModel *pFFModel, SSqlObj* pSql); -void tscDestroyLocalReducer(SSqlObj *pSql); +void tscDestroyLocalMerger(SSqlObj *pSql); int32_t tscDoLocalMerge(SSqlObj *pSql); diff --git a/src/client/inc/tscSubquery.h b/src/client/inc/tscSubquery.h index 7529891635f47fb4f2b68ede5b48ed5640c8f00a..e1370513ef28b4eb86d4caf8c7b34481f334c512 100644 --- a/src/client/inc/tscSubquery.h +++ b/src/client/inc/tscSubquery.h @@ -47,7 +47,6 @@ void tscLockByThread(int64_t *lockedBy); void tscUnlockByThread(int64_t *lockedBy); - #ifdef __cplusplus } #endif diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 633512e324671821f43e8d07dc3f195f2800eca9..ce623cdc03b6871c989186b52fc221c8609a4811 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -98,20 +98,19 @@ static FORCE_INLINE SQueryInfo* tscGetQueryInfoDetail(SSqlCmd* pCmd, int32_t sub return pCmd->pQueryInfo[subClauseIndex]; } -int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, const char* name, - STableMeta* pTableMeta, STableDataBlocks** dataBlocks); -void tscDestroyDataBlock(STableDataBlocks* pDataBlock); +int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, SName* name, STableMeta* pTableMeta, STableDataBlocks** dataBlocks); +void tscDestroyDataBlock(STableDataBlocks* pDataBlock, bool removeMeta); void tscSortRemoveDataBlockDupRows(STableDataBlocks* dataBuf); SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, int16_t bytes, uint32_t offset); void* tscDestroyBlockArrayList(SArray* pDataBlockList); -void* tscDestroyBlockHashTable(SHashObj* pBlockHashTable); +void* tscDestroyBlockHashTable(SHashObj* pBlockHashTable, bool removeMeta); int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock); int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap); -int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize, const char* tableId, STableMeta* pTableMeta, +int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize, SName* pName, STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList); /** @@ -142,10 +141,6 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo); bool tscIsInsertData(char* sqlstr); -/* use for keep current db info temporarily, for handle table with db prefix */ -// todo remove it -void tscGetDBInfoFromTableFullName(char* tableId, char* db); - int tscAllocPayload(SSqlCmd* pCmd, int size); TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes); @@ -215,8 +210,8 @@ SQueryInfo *tscGetQueryInfoDetailSafely(SSqlCmd *pCmd, int32_t subClauseIndex); void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo); -STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta, - SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables); +STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, SName* name, STableMeta* pTableMeta, + SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables); STableMetaInfo* tscAddEmptyMetaInfo(SQueryInfo *pQueryInfo); int32_t tscAddSubqueryInfo(SSqlCmd *pCmd); @@ -225,7 +220,7 @@ void tscInitQueryInfo(SQueryInfo* pQueryInfo); void tscClearSubqueryInfo(SSqlCmd* pCmd); void tscFreeVgroupTableInfo(SArray* pVgroupTables); -SArray* tscVgroupTableInfoClone(SArray* pVgroupTables); +SArray* tscVgroupTableInfoDup(SArray* pVgroupTables); void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index); void tscVgroupTableCopy(SVgroupTableInfo* info, SVgroupTableInfo* pInfo); @@ -292,7 +287,7 @@ uint32_t tscGetTableMetaSize(STableMeta* pTableMeta); CChildTableMeta* tscCreateChildMeta(STableMeta* pTableMeta); uint32_t tscGetTableMetaMaxSize(); int32_t tscCreateTableMetaFromCChildMeta(STableMeta* pChild, const char* name); -STableMeta* tscTableMetaClone(STableMeta* pTableMeta); +STableMeta* tscTableMetaDup(STableMeta* pTableMeta); void* malloc_throw(size_t size); diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 652e5bdd47b5bfa3adfdb8b8f58e94399c4de810..c1b6b0c2b9a0f1c23b8afecbce61451c9ff68488 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -22,15 +22,15 @@ extern "C" { #include "os.h" +#include "qAggMain.h" #include "taos.h" #include "taosdef.h" #include "taosmsg.h" #include "tarray.h" -#include "tglobal.h" -#include "tsqlfunction.h" -#include "tutil.h" #include "tcache.h" +#include "tglobal.h" #include "tref.h" +#include "tutil.h" #include "qExecutor.h" #include "qSqlparser.h" @@ -39,7 +39,7 @@ extern "C" { // forward declaration struct SSqlInfo; -struct SLocalReducer; +struct SLocalMerger; // data source from sql string or from file enum { @@ -67,7 +67,7 @@ typedef struct CChildTableMeta { int32_t vgId; STableId id; uint8_t tableType; - char sTableName[TSDB_TABLE_FNAME_LEN]; + char sTableName[TSDB_TABLE_FNAME_LEN]; //super table name, not full name } CChildTableMeta; typedef struct STableMeta { @@ -91,7 +91,7 @@ typedef struct STableMetaInfo { * 2. keep the vgroup index for multi-vnode insertion */ int32_t vgroupIndex; - char name[TSDB_TABLE_FNAME_LEN]; // (super) table name + SName name; char aliasName[TSDB_TABLE_NAME_LEN]; // alias name of table specified in query sql SArray *tagColList; // SArray, involved tag columns } STableMetaInfo; @@ -142,7 +142,7 @@ typedef struct SCond { } SCond; typedef struct SJoinNode { - char tableId[TSDB_TABLE_FNAME_LEN]; + char tableName[TSDB_TABLE_FNAME_LEN]; uint64_t uid; int16_t tagColId; } SJoinNode; @@ -176,7 +176,7 @@ typedef struct SParamInfo { } SParamInfo; typedef struct STableDataBlocks { - char tableName[TSDB_TABLE_FNAME_LEN]; + SName tableName; int8_t tsSource; // where does the UNIX timestamp come from, server or client bool ordered; // if current rows are ordered or not int64_t vgId; // virtual group id @@ -254,7 +254,7 @@ typedef struct { int8_t submitSchema; // submit block is built with table schema STagData tagData; // NOTE: pTagData->data is used as a variant length array - char **pTableNameList; // all involved tableMeta list of current insert sql statement. + SName **pTableNameList; // all involved tableMeta list of current insert sql statement. int32_t numOfTables; SHashObj *pTableBlockHashList; // data block for each table @@ -292,7 +292,7 @@ typedef struct { SColumnIndex* pColumnIndex; SArithmeticSupport *pArithSup; // support the arithmetic expression calculation on agg functions - struct SLocalReducer *pLocalReducer; + struct SLocalMerger *pLocalMerger; } SSqlRes; typedef struct STscObj { @@ -317,7 +317,8 @@ typedef struct STscObj { } STscObj; typedef struct SSubqueryState { - int32_t numOfRemain; // the number of remain unfinished subquery + pthread_mutex_t mutex; + int8_t *states; int32_t numOfSub; // the number of total sub-queries uint64_t numOfRetrievedRows; // total number of points in this query } SSubqueryState; @@ -410,7 +411,7 @@ void tscRestoreSQLFuncForSTableQuery(SQueryInfo *pQueryInfo); int32_t tscCreateResPointerInfo(SSqlRes *pRes, SQueryInfo *pQueryInfo); void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo); -void tscResetSqlCmdObj(SSqlCmd *pCmd); +void tscResetSqlCmd(SSqlCmd *pCmd, bool removeMeta); /** * free query result of the sql object @@ -435,7 +436,7 @@ void waitForQueryRsp(void *param, TAOS_RES *tres, int code); void doAsyncQuery(STscObj *pObj, SSqlObj *pSql, __async_cb_func_t fp, void *param, const char *sqlstr, size_t sqlLen); -void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql); +void tscImportDataFromFile(SSqlObj *pSql); void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen); bool tscIsUpdateQuery(SSqlObj* pSql); bool tscHasReachLimitation(SQueryInfo *pQueryInfo, SSqlRes *pRes); diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 4eae2b7a877bee69f1192a9558c4db8d6fb1d596..8e5f621b37d77d41e44ff2cb329e6d6d03d62340 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -351,7 +351,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { if (pCmd->command == TSDB_SQL_SELECT) { tscDebug("%p redo parse sql string and proceed", pSql); pCmd->parseFinished = false; - tscResetSqlCmdObj(pCmd); + tscResetSqlCmd(pCmd, true); code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 599fa8646096da224fc2d77b55f164e0581400ef..4b1ab477304d68d5d52ed02b9b2d2c0121c4ffa6 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -569,10 +569,12 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch } char fullName[TSDB_TABLE_FNAME_LEN * 2] = {0}; - extractDBName(pTableMetaInfo->name, fullName); + tNameGetDbName(&pTableMetaInfo->name, fullName); + extractTableName(pMeta->sTableName, param->sTableName); snprintf(fullName + strlen(fullName), TSDB_TABLE_FNAME_LEN - strlen(fullName), ".%s", param->sTableName); - extractTableName(pTableMetaInfo->name, param->buf); + + strncpy(param->buf, tNameGetTableName(&pTableMetaInfo->name), TSDB_TABLE_NAME_LEN); param->pParentSql = pSql; param->pInterSql = pInterSql; @@ -602,6 +604,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch return TSDB_CODE_TSC_ACTION_IN_PROGRESS; } + static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName, char *ddl) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); @@ -675,8 +678,7 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) { STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); assert(pTableMetaInfo->pTableMeta != NULL); - char tableName[TSDB_TABLE_NAME_LEN] = {0}; - extractTableName(pTableMetaInfo->name, tableName); + const char* tableName = tNameGetTableName(&pTableMetaInfo->name); char *result = (char *)calloc(1, TSDB_MAX_BINARY_LEN); int32_t code = TSDB_CODE_SUCCESS; @@ -712,7 +714,9 @@ static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) { free(pInterSql); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - extractTableName(pTableMetaInfo->name, param->buf); + + strncpy(param->buf, tNameGetTableName(&pTableMetaInfo->name), TSDB_TABLE_NAME_LEN); + param->pParentSql = pSql; param->pInterSql = pInterSql; param->fp = tscRebuildCreateDBStatement; diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c index 6280cc520a9adf7b2d8686455b1524a8b356af83..d1ccc1fbb060e8d697f19d6f18d96ffa445ad2ee 100644 --- a/src/client/src/tscLocalMerge.c +++ b/src/client/src/tscLocalMerge.c @@ -16,7 +16,7 @@ #include "tscLocalMerge.h" #include "tscSubquery.h" #include "os.h" -#include "qAst.h" +#include "texpr.h" #include "tlosertree.h" #include "tscLog.h" #include "tscUtil.h" @@ -56,7 +56,7 @@ int32_t treeComparator(const void *pLeft, const void *pRight, void *param) { } } -static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDescriptor *pDesc) { +static void tscInitSqlContext(SSqlCmd *pCmd, SLocalMerger *pReducer, tOrderDescriptor *pDesc) { /* * the fields and offset attributes in pCmd and pModel may be different due to * merge requirement. So, the final result in pRes structure is formatted in accordance with the pCmd object. @@ -166,7 +166,7 @@ static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) { return pFillCol; } -void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc, +void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc, SColumnModel *finalmodel, SColumnModel *pFFModel, SSqlObj* pSql) { SSqlCmd* pCmd = &pSql->cmd; SSqlRes* pRes = &pSql->res; @@ -212,9 +212,9 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd return; } - size_t size = sizeof(SLocalReducer) + POINTER_BYTES * numOfFlush; + size_t size = sizeof(SLocalMerger) + POINTER_BYTES * numOfFlush; - SLocalReducer *pReducer = (SLocalReducer *) calloc(1, size); + SLocalMerger *pReducer = (SLocalMerger *) calloc(1, size); if (pReducer == NULL) { tscError("%p failed to create local merge structure, out of memory", pSql); @@ -372,7 +372,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd pReducer->offset = (int32_t)pQueryInfo->limit.offset; - pRes->pLocalReducer = pReducer; + pRes->pLocalMerger = pReducer; pRes->numOfGroups = 0; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); @@ -477,13 +477,13 @@ int32_t saveToBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tFilePa return 0; } -void tscDestroyLocalReducer(SSqlObj *pSql) { +void tscDestroyLocalMerger(SSqlObj *pSql) { if (pSql == NULL) { return; } SSqlRes *pRes = &(pSql->res); - if (pRes->pLocalReducer == NULL) { + if (pRes->pLocalMerger == NULL) { return; } @@ -491,14 +491,14 @@ void tscDestroyLocalReducer(SSqlObj *pSql) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); // there is no more result, so we release all allocated resource - SLocalReducer *pLocalReducer = (SLocalReducer *)atomic_exchange_ptr(&pRes->pLocalReducer, NULL); - if (pLocalReducer != NULL) { - pLocalReducer->pFillInfo = taosDestroyFillInfo(pLocalReducer->pFillInfo); + SLocalMerger *pLocalMerge = (SLocalMerger *)atomic_exchange_ptr(&pRes->pLocalMerger, NULL); + if (pLocalMerge != NULL) { + pLocalMerge->pFillInfo = taosDestroyFillInfo(pLocalMerge->pFillInfo); - if (pLocalReducer->pCtx != NULL) { + if (pLocalMerge->pCtx != NULL) { int32_t numOfExprs = (int32_t) tscSqlExprNumOfExprs(pQueryInfo); for (int32_t i = 0; i < numOfExprs; ++i) { - SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[i]; + SQLFunctionCtx *pCtx = &pLocalMerge->pCtx[i]; tVariantDestroy(&pCtx->tag); tfree(pCtx->resultInfo); @@ -508,31 +508,31 @@ void tscDestroyLocalReducer(SSqlObj *pSql) { } } - tfree(pLocalReducer->pCtx); + tfree(pLocalMerge->pCtx); } - tfree(pLocalReducer->prevRowOfInput); + tfree(pLocalMerge->prevRowOfInput); - tfree(pLocalReducer->pTempBuffer); - tfree(pLocalReducer->pResultBuf); + tfree(pLocalMerge->pTempBuffer); + tfree(pLocalMerge->pResultBuf); - if (pLocalReducer->pLoserTree) { - tfree(pLocalReducer->pLoserTree->param); - tfree(pLocalReducer->pLoserTree); + if (pLocalMerge->pLoserTree) { + tfree(pLocalMerge->pLoserTree->param); + tfree(pLocalMerge->pLoserTree); } - tfree(pLocalReducer->pFinalRes); - tfree(pLocalReducer->discardData); + tfree(pLocalMerge->pFinalRes); + tfree(pLocalMerge->discardData); - tscLocalReducerEnvDestroy(pLocalReducer->pExtMemBuffer, pLocalReducer->pDesc, pLocalReducer->resColModel, pLocalReducer->finalModel, - pLocalReducer->numOfVnode); - for (int32_t i = 0; i < pLocalReducer->numOfBuffer; ++i) { - tfree(pLocalReducer->pLocalDataSrc[i]); + tscLocalReducerEnvDestroy(pLocalMerge->pExtMemBuffer, pLocalMerge->pDesc, pLocalMerge->resColModel, pLocalMerge->finalModel, + pLocalMerge->numOfVnode); + for (int32_t i = 0; i < pLocalMerge->numOfBuffer; ++i) { + tfree(pLocalMerge->pLocalDataSrc[i]); } - pLocalReducer->numOfBuffer = 0; - pLocalReducer->numOfCompleted = 0; - free(pLocalReducer); + pLocalMerge->numOfBuffer = 0; + pLocalMerge->numOfCompleted = 0; + free(pLocalMerge); } else { tscDebug("%p already freed or another free function is invoked", pSql); } @@ -604,7 +604,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm } } -bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage *tmpBuffer) { +bool isSameGroup(SSqlCmd *pCmd, SLocalMerger *pReducer, char *pPrev, tFilePage *tmpBuffer) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); // disable merge procedure for column projection query @@ -795,12 +795,12 @@ void tscLocalReducerEnvDestroy(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDe /** * - * @param pLocalReducer + * @param pLocalMerge * @param pOneInterDataSrc * @param treeList * @return the number of remain input source. if ret == 0, all data has been handled */ -int32_t loadNewDataFromDiskFor(SLocalReducer *pLocalReducer, SLocalDataSource *pOneInterDataSrc, +int32_t loadNewDataFromDiskFor(SLocalMerger *pLocalMerge, SLocalDataSource *pOneInterDataSrc, bool *needAdjustLoserTree) { pOneInterDataSrc->rowIdx = 0; pOneInterDataSrc->pageId += 1; @@ -817,17 +817,17 @@ int32_t loadNewDataFromDiskFor(SLocalReducer *pLocalReducer, SLocalDataSource *p #endif *needAdjustLoserTree = true; } else { - pLocalReducer->numOfCompleted += 1; + pLocalMerge->numOfCompleted += 1; pOneInterDataSrc->rowIdx = -1; pOneInterDataSrc->pageId = -1; *needAdjustLoserTree = true; } - return pLocalReducer->numOfBuffer; + return pLocalMerge->numOfBuffer; } -void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *pOneInterDataSrc, +void adjustLoserTreeFromNewData(SLocalMerger *pLocalMerge, SLocalDataSource *pOneInterDataSrc, SLoserTreeInfo *pTree) { /* * load a new data page into memory for intermediate dataset source, @@ -835,7 +835,7 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource * */ bool needToAdjust = true; if (pOneInterDataSrc->filePage.num <= pOneInterDataSrc->rowIdx) { - loadNewDataFromDiskFor(pLocalReducer, pOneInterDataSrc, &needToAdjust); + loadNewDataFromDiskFor(pLocalMerge, pOneInterDataSrc, &needToAdjust); } /* @@ -843,7 +843,7 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource * * if the loser tree is rebuild completed, we do not need to adjust */ if (needToAdjust) { - int32_t leafNodeIdx = pTree->pNode[0].index + pLocalReducer->numOfBuffer; + int32_t leafNodeIdx = pTree->pNode[0].index + pLocalMerge->numOfBuffer; #ifdef _DEBUG_VIEW printf("before adjust:\t"); @@ -860,7 +860,7 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource * } } -void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQueryInfo, SFillInfo *pFillInfo) { +void savePrevRecordAndSetupFillInfo(SLocalMerger *pLocalMerge, SQueryInfo *pQueryInfo, SFillInfo *pFillInfo) { // discard following dataset in the same group and reset the interpolation information STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); @@ -873,28 +873,28 @@ void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQ taosResetFillInfo(pFillInfo, revisedSTime); } - pLocalReducer->discard = true; - pLocalReducer->discardData->num = 0; + pLocalMerge->discard = true; + pLocalMerge->discardData->num = 0; - SColumnModel *pModel = pLocalReducer->pDesc->pColumnModel; - tColModelAppend(pModel, pLocalReducer->discardData, pLocalReducer->prevRowOfInput, 0, 1, 1); + SColumnModel *pModel = pLocalMerge->pDesc->pColumnModel; + tColModelAppend(pModel, pLocalMerge->discardData, pLocalMerge->prevRowOfInput, 0, 1, 1); } -static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer, SQueryInfo* pQueryInfo) { +static void genFinalResWithoutFill(SSqlRes* pRes, SLocalMerger *pLocalMerge, SQueryInfo* pQueryInfo) { assert(pQueryInfo->interval.interval == 0 || pQueryInfo->fillType == TSDB_FILL_NONE); - tFilePage * pBeforeFillData = pLocalReducer->pResultBuf; + tFilePage * pBeforeFillData = pLocalMerge->pResultBuf; - pRes->data = pLocalReducer->pFinalRes; + pRes->data = pLocalMerge->pFinalRes; pRes->numOfRows = (int32_t) pBeforeFillData->num; if (pQueryInfo->limit.offset > 0) { if (pQueryInfo->limit.offset < pRes->numOfRows) { int32_t prevSize = (int32_t) pBeforeFillData->num; - tColModelErase(pLocalReducer->finalModel, pBeforeFillData, prevSize, 0, (int32_t)pQueryInfo->limit.offset - 1); + tColModelErase(pLocalMerge->finalModel, pBeforeFillData, prevSize, 0, (int32_t)pQueryInfo->limit.offset - 1); /* remove the hole in column model */ - tColModelCompact(pLocalReducer->finalModel, pBeforeFillData, prevSize); + tColModelCompact(pLocalMerge->finalModel, pBeforeFillData, prevSize); pRes->numOfRows -= (int32_t) pQueryInfo->limit.offset; pQueryInfo->limit.offset = 0; @@ -907,7 +907,7 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer, if (pRes->numOfRowsGroup >= pQueryInfo->limit.limit && pQueryInfo->limit.limit > 0) { pRes->numOfRows = 0; pBeforeFillData->num = 0; - pLocalReducer->discard = true; + pLocalMerge->discard = true; return; } @@ -923,29 +923,29 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer, pRes->numOfRows -= overflow; pBeforeFillData->num -= overflow; - tColModelCompact(pLocalReducer->finalModel, pBeforeFillData, prevSize); + tColModelCompact(pLocalMerge->finalModel, pBeforeFillData, prevSize); // set remain data to be discarded, and reset the interpolation information - savePrevRecordAndSetupFillInfo(pLocalReducer, pQueryInfo, pLocalReducer->pFillInfo); + savePrevRecordAndSetupFillInfo(pLocalMerge, pQueryInfo, pLocalMerge->pFillInfo); } - memcpy(pRes->data, pBeforeFillData->data, (size_t)(pRes->numOfRows * pLocalReducer->finalModel->rowSize)); + memcpy(pRes->data, pBeforeFillData->data, (size_t)(pRes->numOfRows * pLocalMerge->finalModel->rowSize)); pRes->numOfClauseTotal += pRes->numOfRows; pBeforeFillData->num = 0; } /* - * Note: pRes->pLocalReducer may be null, due to the fact that "tscDestroyLocalReducer" is called + * Note: pRes->pLocalMerge may be null, due to the fact that "tscDestroyLocalMerger" is called * by "interuptHandler" function in shell */ -static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneOutput) { +static void doFillResult(SSqlObj *pSql, SLocalMerger *pLocalMerge, bool doneOutput) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; - tFilePage *pBeforeFillData = pLocalReducer->pResultBuf; + tFilePage *pBeforeFillData = pLocalMerge->pResultBuf; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - SFillInfo *pFillInfo = pLocalReducer->pFillInfo; + SFillInfo *pFillInfo = pLocalMerge->pFillInfo; // todo extract function int64_t actualETime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey; @@ -953,11 +953,11 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO tFilePage **pResPages = malloc(POINTER_BYTES * pQueryInfo->fieldsInfo.numOfOutput); for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); - pResPages[i] = calloc(1, sizeof(tFilePage) + pField->bytes * pLocalReducer->resColModel->capacity); + pResPages[i] = calloc(1, sizeof(tFilePage) + pField->bytes * pLocalMerge->resColModel->capacity); } while (1) { - int64_t newRows = taosFillResultDataBlock(pFillInfo, pResPages, pLocalReducer->resColModel->capacity); + int64_t newRows = taosFillResultDataBlock(pFillInfo, pResPages, pLocalMerge->resColModel->capacity); if (pQueryInfo->limit.offset < newRows) { newRows -= pQueryInfo->limit.offset; @@ -970,7 +970,7 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO } } - pRes->data = pLocalReducer->pFinalRes; + pRes->data = pLocalMerge->pFinalRes; pRes->numOfRows = (int32_t) newRows; pQueryInfo->limit.offset = 0; @@ -985,7 +985,7 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO } // all output in current group are completed - int32_t totalRemainRows = (int32_t)getNumOfResultsAfterFillGap(pFillInfo, actualETime, pLocalReducer->resColModel->capacity); + int32_t totalRemainRows = (int32_t)getNumOfResultsAfterFillGap(pFillInfo, actualETime, pLocalMerge->resColModel->capacity); if (totalRemainRows <= 0) { break; } @@ -1003,7 +1003,7 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO assert(pRes->numOfRows >= 0); /* set remain data to be discarded, and reset the interpolation information */ - savePrevRecordAndSetupFillInfo(pLocalReducer, pQueryInfo, pFillInfo); + savePrevRecordAndSetupFillInfo(pLocalMerge, pQueryInfo, pFillInfo); } int32_t offset = 0; @@ -1025,8 +1025,8 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO tfree(pResPages); } -static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) { - SColumnModel *pColumnModel = pLocalReducer->pDesc->pColumnModel; +static void savePreviousRow(SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) { + SColumnModel *pColumnModel = pLocalMerge->pDesc->pColumnModel; assert(pColumnModel->capacity == 1 && tmpBuffer->num == 1); // copy to previous temp buffer @@ -1034,20 +1034,20 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) SSchema *pSchema = getColumnModelSchema(pColumnModel, i); int16_t offset = getColumnModelOffset(pColumnModel, i); - memcpy(pLocalReducer->prevRowOfInput + offset, tmpBuffer->data + offset, pSchema->bytes); + memcpy(pLocalMerge->prevRowOfInput + offset, tmpBuffer->data + offset, pSchema->bytes); } tmpBuffer->num = 0; - pLocalReducer->hasPrevRow = true; + pLocalMerge->hasPrevRow = true; } -static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, bool needInit) { +static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bool needInit) { // the tag columns need to be set before all functions execution SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); size_t size = tscSqlExprNumOfExprs(pQueryInfo); for (int32_t j = 0; j < size; ++j) { - SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[j]; + SQLFunctionCtx *pCtx = &pLocalMerge->pCtx[j]; // tags/tags_dummy function, the tag field of SQLFunctionCtx is from the input buffer int32_t functionId = pCtx->functionId; @@ -1074,20 +1074,20 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, } for (int32_t j = 0; j < size; ++j) { - int32_t functionId = pLocalReducer->pCtx[j].functionId; + int32_t functionId = pLocalMerge->pCtx[j].functionId; if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { continue; } - aAggs[functionId].mergeFunc(&pLocalReducer->pCtx[j]); + aAggs[functionId].mergeFunc(&pLocalMerge->pCtx[j]); } } -static void handleUnprocessedRow(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) { - if (pLocalReducer->hasUnprocessedRow) { - pLocalReducer->hasUnprocessedRow = false; - doExecuteSecondaryMerge(pCmd, pLocalReducer, true); - savePreviousRow(pLocalReducer, tmpBuffer); +static void handleUnprocessedRow(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) { + if (pLocalMerge->hasUnprocessedRow) { + pLocalMerge->hasUnprocessedRow = false; + doExecuteSecondaryMerge(pCmd, pLocalMerge, true); + savePreviousRow(pLocalMerge, tmpBuffer); } } @@ -1120,7 +1120,7 @@ static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx) * filled with the same result, which is the tags, specified in group by clause * */ -static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLocalReducer *pLocalReducer) { +static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLocalMerger *pLocalMerge) { int32_t maxBufSize = 0; // find the max tags column length to prepare the buffer size_t size = tscSqlExprNumOfExprs(pQueryInfo); @@ -1135,7 +1135,7 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo char *buf = malloc((size_t)maxBufSize); for (int32_t k = 0; k < size; ++k) { - SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[k]; + SQLFunctionCtx *pCtx = &pLocalMerge->pCtx[k]; if (pCtx->functionId != TSDB_FUNC_TAG) { continue; } @@ -1153,20 +1153,20 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo free(buf); } -int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) { +int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge) { size_t size = tscSqlExprNumOfExprs(pQueryInfo); for (int32_t k = 0; k < size; ++k) { - SQLFunctionCtx* pCtx = &pLocalReducer->pCtx[k]; + SQLFunctionCtx* pCtx = &pLocalMerge->pCtx[k]; aAggs[pCtx->functionId].xFinalize(pCtx); } - pLocalReducer->hasPrevRow = false; + pLocalMerge->hasPrevRow = false; - int32_t numOfRes = (int32_t)getNumOfResultLocal(pQueryInfo, pLocalReducer->pCtx); - pLocalReducer->pResultBuf->num += numOfRes; + int32_t numOfRes = (int32_t)getNumOfResultLocal(pQueryInfo, pLocalMerge->pCtx); + pLocalMerge->pResultBuf->num += numOfRes; - fillMultiRowsOfTagsVal(pQueryInfo, numOfRes, pLocalReducer); + fillMultiRowsOfTagsVal(pQueryInfo, numOfRes, pLocalMerge); return numOfRes; } @@ -1177,22 +1177,22 @@ int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) { * results generated by simple aggregation function, we merge them all into one points * *Exception*: column projection query, required no merge procedure */ -bool needToMerge(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) { +bool needToMerge(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) { int32_t ret = 0; // merge all result by default - int16_t functionId = pLocalReducer->pCtx[0].functionId; + int16_t functionId = pLocalMerge->pCtx[0].functionId; // todo opt performance if ((/*functionId == TSDB_FUNC_PRJ || */functionId == TSDB_FUNC_ARITHM) || (tscIsProjectionQueryOnSTable(pQueryInfo, 0))) { // column projection query ret = 1; // disable merge procedure } else { - tOrderDescriptor *pDesc = pLocalReducer->pDesc; + tOrderDescriptor *pDesc = pLocalMerge->pDesc; if (pDesc->orderInfo.numOfCols > 0) { if (pDesc->tsOrder == TSDB_ORDER_ASC) { // asc // todo refactor comparator - ret = compare_a(pLocalReducer->pDesc, 1, 0, pLocalReducer->prevRowOfInput, 1, 0, tmpBuffer->data); + ret = compare_a(pLocalMerge->pDesc, 1, 0, pLocalMerge->prevRowOfInput, 1, 0, tmpBuffer->data); } else { // desc - ret = compare_d(pLocalReducer->pDesc, 1, 0, pLocalReducer->prevRowOfInput, 1, 0, tmpBuffer->data); + ret = compare_d(pLocalMerge->pDesc, 1, 0, pLocalMerge->prevRowOfInput, 1, 0, tmpBuffer->data); } } } @@ -1230,17 +1230,17 @@ static bool saveGroupResultInfo(SSqlObj *pSql) { /** * * @param pSql - * @param pLocalReducer + * @param pLocalMerge * @param noMoreCurrentGroupRes * @return if current group is skipped, return false, and do NOT record it into pRes->numOfGroups */ -bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCurrentGroupRes) { +bool genFinalResults(SSqlObj *pSql, SLocalMerger *pLocalMerge, bool noMoreCurrentGroupRes) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - tFilePage * pResBuf = pLocalReducer->pResultBuf; - SColumnModel *pModel = pLocalReducer->resColModel; + tFilePage * pResBuf = pLocalMerge->pResultBuf; + SColumnModel *pModel = pLocalMerge->resColModel; pRes->code = TSDB_CODE_SUCCESS; @@ -1251,11 +1251,11 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur if (pQueryInfo->slimit.offset > 0) { pRes->numOfRows = 0; pQueryInfo->slimit.offset -= 1; - pLocalReducer->discard = !noMoreCurrentGroupRes; + pLocalMerge->discard = !noMoreCurrentGroupRes; - if (pLocalReducer->discard) { - SColumnModel *pInternModel = pLocalReducer->pDesc->pColumnModel; - tColModelAppend(pInternModel, pLocalReducer->discardData, pLocalReducer->pTempBuffer->data, 0, 1, 1); + if (pLocalMerge->discard) { + SColumnModel *pInternModel = pLocalMerge->pDesc->pColumnModel; + tColModelAppend(pInternModel, pLocalMerge->discardData, pLocalMerge->pTempBuffer->data, 0, 1, 1); } return false; @@ -1264,19 +1264,14 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur tColModelCompact(pModel, pResBuf, pModel->capacity); if (tscIsSecondStageQuery(pQueryInfo)) { - doArithmeticCalculate(pQueryInfo, pResBuf, pModel->rowSize, pLocalReducer->finalModel->rowSize); + doArithmeticCalculate(pQueryInfo, pResBuf, pModel->rowSize, pLocalMerge->finalModel->rowSize); } -#ifdef _DEBUG_VIEW - printf("final result before interpo:\n"); -// tColModelDisplay(pLocalReducer->resColModel, pLocalReducer->pBufForInterpo, pResBuf->num, pResBuf->num); -#endif - // no interval query, no fill operation if (pQueryInfo->interval.interval == 0 || pQueryInfo->fillType == TSDB_FILL_NONE) { - genFinalResWithoutFill(pRes, pLocalReducer, pQueryInfo); + genFinalResWithoutFill(pRes, pLocalMerge, pQueryInfo); } else { - SFillInfo* pFillInfo = pLocalReducer->pFillInfo; + SFillInfo* pFillInfo = pLocalMerge->pFillInfo; if (pFillInfo != NULL) { TSKEY ekey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey; @@ -1284,34 +1279,34 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur taosFillCopyInputDataFromOneFilePage(pFillInfo, pResBuf); } - doFillResult(pSql, pLocalReducer, noMoreCurrentGroupRes); + doFillResult(pSql, pLocalMerge, noMoreCurrentGroupRes); } return true; } -void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {// reset output buffer to the beginning +void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge) {// reset output buffer to the beginning size_t t = tscSqlExprNumOfExprs(pQueryInfo); for (int32_t i = 0; i < t; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); - pLocalReducer->pCtx[i].aOutputBuf = pLocalReducer->pResultBuf->data + pExpr->offset * pLocalReducer->resColModel->capacity; + pLocalMerge->pCtx[i].aOutputBuf = pLocalMerge->pResultBuf->data + pExpr->offset * pLocalMerge->resColModel->capacity; if (pExpr->functionId == TSDB_FUNC_TOP || pExpr->functionId == TSDB_FUNC_BOTTOM || pExpr->functionId == TSDB_FUNC_DIFF) { - pLocalReducer->pCtx[i].ptsOutputBuf = pLocalReducer->pCtx[0].aOutputBuf; + pLocalMerge->pCtx[i].ptsOutputBuf = pLocalMerge->pCtx[0].aOutputBuf; } } - memset(pLocalReducer->pResultBuf, 0, pLocalReducer->nResultBufSize + sizeof(tFilePage)); + memset(pLocalMerge->pResultBuf, 0, pLocalMerge->nResultBufSize + sizeof(tFilePage)); } -static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer *pLocalReducer) { +static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalMerger *pLocalMerge) { // In handling data in other groups, we need to reset the interpolation information for a new group data pRes->numOfRows = 0; pRes->numOfRowsGroup = 0; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - pQueryInfo->limit.offset = pLocalReducer->offset; + pQueryInfo->limit.offset = pLocalMerge->offset; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); @@ -1320,12 +1315,12 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer if (pQueryInfo->fillType != TSDB_FILL_NONE) { TSKEY skey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.skey:pQueryInfo->window.ekey;//MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey); int64_t newTime = taosTimeTruncate(skey, &pQueryInfo->interval, tinfo.precision); - taosResetFillInfo(pLocalReducer->pFillInfo, newTime); + taosResetFillInfo(pLocalMerge->pFillInfo, newTime); } } -static bool isAllSourcesCompleted(SLocalReducer *pLocalReducer) { - return (pLocalReducer->numOfBuffer == pLocalReducer->numOfCompleted); +static bool isAllSourcesCompleted(SLocalMerger *pLocalMerge) { + return (pLocalMerge->numOfBuffer == pLocalMerge->numOfCompleted); } static bool doBuildFilledResultForGroup(SSqlObj *pSql) { @@ -1333,19 +1328,19 @@ static bool doBuildFilledResultForGroup(SSqlObj *pSql) { SSqlRes *pRes = &pSql->res; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - SLocalReducer *pLocalReducer = pRes->pLocalReducer; - SFillInfo *pFillInfo = pLocalReducer->pFillInfo; + SLocalMerger *pLocalMerge = pRes->pLocalMerger; + SFillInfo *pFillInfo = pLocalMerge->pFillInfo; if (pFillInfo != NULL && taosFillHasMoreResults(pFillInfo)) { assert(pQueryInfo->fillType != TSDB_FILL_NONE); - tFilePage *pFinalDataBuf = pLocalReducer->pResultBuf; + tFilePage *pFinalDataBuf = pLocalMerge->pResultBuf; int64_t etime = *(int64_t *)(pFinalDataBuf->data + TSDB_KEYSIZE * (pFillInfo->numOfRows - 1)); // the first column must be the timestamp column - int32_t rows = (int32_t) getNumOfResultsAfterFillGap(pFillInfo, etime, pLocalReducer->resColModel->capacity); + int32_t rows = (int32_t) getNumOfResultsAfterFillGap(pFillInfo, etime, pLocalMerge->resColModel->capacity); if (rows > 0) { // do fill gap - doFillResult(pSql, pLocalReducer, false); + doFillResult(pSql, pLocalMerge, false); } return true; @@ -1358,23 +1353,23 @@ static bool doHandleLastRemainData(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; - SLocalReducer *pLocalReducer = pRes->pLocalReducer; - SFillInfo *pFillInfo = pLocalReducer->pFillInfo; + SLocalMerger *pLocalMerge = pRes->pLocalMerger; + SFillInfo *pFillInfo = pLocalMerge->pFillInfo; - bool prevGroupCompleted = (!pLocalReducer->discard) && pLocalReducer->hasUnprocessedRow; + bool prevGroupCompleted = (!pLocalMerge->discard) && pLocalMerge->hasUnprocessedRow; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - if ((isAllSourcesCompleted(pLocalReducer) && !pLocalReducer->hasPrevRow) || pLocalReducer->pLocalDataSrc[0] == NULL || + if ((isAllSourcesCompleted(pLocalMerge) && !pLocalMerge->hasPrevRow) || pLocalMerge->pLocalDataSrc[0] == NULL || prevGroupCompleted) { // if fillType == TSDB_FILL_NONE, return directly if (pQueryInfo->fillType != TSDB_FILL_NONE && ((pRes->numOfRowsGroup < pQueryInfo->limit.limit && pQueryInfo->limit.limit > 0) || (pQueryInfo->limit.limit < 0))) { int64_t etime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey : pQueryInfo->window.skey; - int32_t rows = (int32_t)getNumOfResultsAfterFillGap(pFillInfo, etime, pLocalReducer->resColModel->capacity); + int32_t rows = (int32_t)getNumOfResultsAfterFillGap(pFillInfo, etime, pLocalMerge->resColModel->capacity); if (rows > 0) { - doFillResult(pSql, pLocalReducer, true); + doFillResult(pSql, pLocalMerge, true); } } @@ -1384,7 +1379,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) { * * No results will be generated and query completed. */ - if (pRes->numOfRows > 0 || (isAllSourcesCompleted(pLocalReducer) && (!pLocalReducer->hasUnprocessedRow))) { + if (pRes->numOfRows > 0 || (isAllSourcesCompleted(pLocalMerge) && (!pLocalMerge->hasUnprocessedRow))) { return true; } @@ -1393,7 +1388,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) { return true; } - resetEnvForNewResultset(pRes, pCmd, pLocalReducer); + resetEnvForNewResultset(pRes, pCmd, pLocalMerge); } return false; @@ -1403,12 +1398,12 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; - SLocalReducer *pLocalReducer = pRes->pLocalReducer; + SLocalMerger *pLocalMerge = pRes->pLocalMerger; SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); size_t size = tscSqlExprNumOfExprs(pQueryInfo); for (int32_t k = 0; k < size; ++k) { - SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[k]; + SQLFunctionCtx *pCtx = &pLocalMerge->pCtx[k]; pCtx->aOutputBuf += pCtx->outputBytes * numOfRes; // set the correct output timestamp column position @@ -1417,7 +1412,7 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) { } } - doExecuteSecondaryMerge(pCmd, pLocalReducer, true); + doExecuteSecondaryMerge(pCmd, pLocalMerge, true); } int32_t tscDoLocalMerge(SSqlObj *pSql) { @@ -1426,14 +1421,18 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { tscResetForNextRetrieve(pRes); - if (pSql->signature != pSql || pRes == NULL || pRes->pLocalReducer == NULL) { // all data has been processed + if (pSql->signature != pSql || pRes == NULL || pRes->pLocalMerger == NULL) { // all data has been processed + if (pRes->code == TSDB_CODE_SUCCESS) { + return pRes->code; + } + tscError("%p local merge abort due to error occurs, code:%s", pSql, tstrerror(pRes->code)); return pRes->code; } - SLocalReducer *pLocalReducer = pRes->pLocalReducer; + SLocalMerger *pLocalMerge = pRes->pLocalMerger; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); - tFilePage *tmpBuffer = pLocalReducer->pTempBuffer; + tFilePage *tmpBuffer = pLocalMerge->pTempBuffer; if (doHandleLastRemainData(pSql)) { return TSDB_CODE_SUCCESS; @@ -1443,24 +1442,24 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { return TSDB_CODE_SUCCESS; } - SLoserTreeInfo *pTree = pLocalReducer->pLoserTree; + SLoserTreeInfo *pTree = pLocalMerge->pLoserTree; // clear buffer - handleUnprocessedRow(pCmd, pLocalReducer, tmpBuffer); - SColumnModel *pModel = pLocalReducer->pDesc->pColumnModel; + handleUnprocessedRow(pCmd, pLocalMerge, tmpBuffer); + SColumnModel *pModel = pLocalMerge->pDesc->pColumnModel; while (1) { - if (isAllSourcesCompleted(pLocalReducer)) { + if (isAllSourcesCompleted(pLocalMerge)) { break; } #ifdef _DEBUG_VIEW printf("chosen data in pTree[0] = %d\n", pTree->pNode[0].index); #endif - assert((pTree->pNode[0].index < pLocalReducer->numOfBuffer) && (pTree->pNode[0].index >= 0) && tmpBuffer->num == 0); + assert((pTree->pNode[0].index < pLocalMerge->numOfBuffer) && (pTree->pNode[0].index >= 0) && tmpBuffer->num == 0); // chosen from loser tree - SLocalDataSource *pOneDataSrc = pLocalReducer->pLocalDataSrc[pTree->pNode[0].index]; + SLocalDataSource *pOneDataSrc = pLocalMerge->pLocalDataSrc[pTree->pNode[0].index]; tColModelAppend(pModel, tmpBuffer, pOneDataSrc->filePage.data, pOneDataSrc->rowIdx, 1, pOneDataSrc->pMemBuffer->pColumnModel->capacity); @@ -1473,76 +1472,76 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { tColModelDisplayEx(pModel, tmpBuffer->data, tmpBuffer->num, pModel->capacity, colInfo); #endif - if (pLocalReducer->discard) { - assert(pLocalReducer->hasUnprocessedRow == false); + if (pLocalMerge->discard) { + assert(pLocalMerge->hasUnprocessedRow == false); /* current record belongs to the same group of previous record, need to discard it */ - if (isSameGroup(pCmd, pLocalReducer, pLocalReducer->discardData->data, tmpBuffer)) { + if (isSameGroup(pCmd, pLocalMerge, pLocalMerge->discardData->data, tmpBuffer)) { tmpBuffer->num = 0; pOneDataSrc->rowIdx += 1; - adjustLoserTreeFromNewData(pLocalReducer, pOneDataSrc, pTree); + adjustLoserTreeFromNewData(pLocalMerge, pOneDataSrc, pTree); // all inputs are exhausted, abort current process - if (isAllSourcesCompleted(pLocalReducer)) { + if (isAllSourcesCompleted(pLocalMerge)) { break; } // data belongs to the same group needs to be discarded continue; } else { - pLocalReducer->discard = false; - pLocalReducer->discardData->num = 0; + pLocalMerge->discard = false; + pLocalMerge->discardData->num = 0; if (saveGroupResultInfo(pSql)) { return TSDB_CODE_SUCCESS; } - resetEnvForNewResultset(pRes, pCmd, pLocalReducer); + resetEnvForNewResultset(pRes, pCmd, pLocalMerge); } } - if (pLocalReducer->hasPrevRow) { - if (needToMerge(pQueryInfo, pLocalReducer, tmpBuffer)) { + if (pLocalMerge->hasPrevRow) { + if (needToMerge(pQueryInfo, pLocalMerge, tmpBuffer)) { // belong to the group of the previous row, continue process it - doExecuteSecondaryMerge(pCmd, pLocalReducer, false); + doExecuteSecondaryMerge(pCmd, pLocalMerge, false); // copy to buffer - savePreviousRow(pLocalReducer, tmpBuffer); + savePreviousRow(pLocalMerge, tmpBuffer); } else { /* * current row does not belong to the group of previous row. * so the processing of previous group is completed. */ - int32_t numOfRes = finalizeRes(pQueryInfo, pLocalReducer); - bool sameGroup = isSameGroup(pCmd, pLocalReducer, pLocalReducer->prevRowOfInput, tmpBuffer); + int32_t numOfRes = finalizeRes(pQueryInfo, pLocalMerge); + bool sameGroup = isSameGroup(pCmd, pLocalMerge, pLocalMerge->prevRowOfInput, tmpBuffer); - tFilePage *pResBuf = pLocalReducer->pResultBuf; + tFilePage *pResBuf = pLocalMerge->pResultBuf; /* * if the previous group does NOT generate any result (pResBuf->num == 0), * continue to process results instead of return results. */ - if ((!sameGroup && pResBuf->num > 0) || (pResBuf->num == pLocalReducer->resColModel->capacity)) { + if ((!sameGroup && pResBuf->num > 0) || (pResBuf->num == pLocalMerge->resColModel->capacity)) { // does not belong to the same group - bool notSkipped = genFinalResults(pSql, pLocalReducer, !sameGroup); + bool notSkipped = genFinalResults(pSql, pLocalMerge, !sameGroup); // this row needs to discard, since it belongs to the group of previous - if (pLocalReducer->discard && sameGroup) { - pLocalReducer->hasUnprocessedRow = false; + if (pLocalMerge->discard && sameGroup) { + pLocalMerge->hasUnprocessedRow = false; tmpBuffer->num = 0; } else { // current row does not belongs to the previous group, so it is not be handled yet. - pLocalReducer->hasUnprocessedRow = true; + pLocalMerge->hasUnprocessedRow = true; } - resetOutputBuf(pQueryInfo, pLocalReducer); + resetOutputBuf(pQueryInfo, pLocalMerge); pOneDataSrc->rowIdx += 1; // here we do not check the return value - adjustLoserTreeFromNewData(pLocalReducer, pOneDataSrc, pTree); + adjustLoserTreeFromNewData(pLocalMerge, pOneDataSrc, pTree); if (pRes->numOfRows == 0) { - handleUnprocessedRow(pCmd, pLocalReducer, tmpBuffer); + handleUnprocessedRow(pCmd, pLocalMerge, tmpBuffer); if (!sameGroup) { /* @@ -1553,7 +1552,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { return TSDB_CODE_SUCCESS; } - resetEnvForNewResultset(pRes, pCmd, pLocalReducer); + resetEnvForNewResultset(pRes, pCmd, pLocalMerge); } } else { /* @@ -1561,7 +1560,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { * We start the process in a new round. */ if (sameGroup) { - handleUnprocessedRow(pCmd, pLocalReducer, tmpBuffer); + handleUnprocessedRow(pCmd, pLocalMerge, tmpBuffer); } } @@ -1573,24 +1572,24 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { } } else { // result buffer is not full doProcessResultInNextWindow(pSql, numOfRes); - savePreviousRow(pLocalReducer, tmpBuffer); + savePreviousRow(pLocalMerge, tmpBuffer); } } } else { - doExecuteSecondaryMerge(pCmd, pLocalReducer, true); - savePreviousRow(pLocalReducer, tmpBuffer); // copy the processed row to buffer + doExecuteSecondaryMerge(pCmd, pLocalMerge, true); + savePreviousRow(pLocalMerge, tmpBuffer); // copy the processed row to buffer } pOneDataSrc->rowIdx += 1; - adjustLoserTreeFromNewData(pLocalReducer, pOneDataSrc, pTree); + adjustLoserTreeFromNewData(pLocalMerge, pOneDataSrc, pTree); } - if (pLocalReducer->hasPrevRow) { - finalizeRes(pQueryInfo, pLocalReducer); + if (pLocalMerge->hasPrevRow) { + finalizeRes(pQueryInfo, pLocalMerge); } - if (pLocalReducer->pResultBuf->num) { - genFinalResults(pSql, pLocalReducer, true); + if (pLocalMerge->pResultBuf->num) { + genFinalResults(pSql, pLocalMerge, true); } return TSDB_CODE_SUCCESS; @@ -1598,8 +1597,8 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen) { SSqlRes *pRes = &pObj->res; - if (pRes->pLocalReducer != NULL) { - tscDestroyLocalReducer(pObj); + if (pRes->pLocalMerger != NULL) { + tscDestroyLocalMerger(pObj); } pRes->qhandle = 1; // hack to pass the safety check in fetch_row function @@ -1607,17 +1606,17 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen) pRes->row = 0; pRes->rspType = 0; // used as a flag to denote if taos_retrieved() has been called yet - pRes->pLocalReducer = (SLocalReducer *)calloc(1, sizeof(SLocalReducer)); + pRes->pLocalMerger = (SLocalMerger *)calloc(1, sizeof(SLocalMerger)); /* * we need one additional byte space * the sprintf function needs one additional space to put '\0' at the end of string */ size_t allocSize = numOfRes * rowLen + sizeof(tFilePage) + 1; - pRes->pLocalReducer->pResultBuf = (tFilePage *)calloc(1, allocSize); + pRes->pLocalMerger->pResultBuf = (tFilePage *)calloc(1, allocSize); - pRes->pLocalReducer->pResultBuf->num = numOfRes; - pRes->data = pRes->pLocalReducer->pResultBuf->data; + pRes->pLocalMerger->pResultBuf->num = numOfRes; + pRes->data = pRes->pLocalMerger->pResultBuf->data; } int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) { diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 0c7af5d4e3d8b61445b25c94cf5eda021ceba3e9..c0a8762180d2198847f6704da6bb28160659b858 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -703,7 +703,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, SParsedDataColI STableDataBlocks *dataBuf = NULL; int32_t ret = tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_DEFAULT_PAYLOAD_SIZE, - sizeof(SSubmitBlk), tinfo.rowSize, pTableMetaInfo->name, pTableMeta, &dataBuf, NULL); + sizeof(SSubmitBlk), tinfo.rowSize, &pTableMetaInfo->name, pTableMeta, &dataBuf, NULL); if (ret != TSDB_CODE_SUCCESS) { return ret; } @@ -813,26 +813,26 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { tscAddEmptyMetaInfo(pQueryInfo); } - STableMetaInfo *pSTableMeterMetaInfo = tscGetMetaInfo(pQueryInfo, STABLE_INDEX); - code = tscSetTableFullName(pSTableMeterMetaInfo, &sToken, pSql); + STableMetaInfo *pSTableMetaInfo = tscGetMetaInfo(pQueryInfo, STABLE_INDEX); + code = tscSetTableFullName(pSTableMetaInfo, &sToken, pSql); if (code != TSDB_CODE_SUCCESS) { return code; } - tstrncpy(pCmd->tagData.name, pSTableMeterMetaInfo->name, sizeof(pCmd->tagData.name)); + tNameExtractFullName(&pSTableMetaInfo->name, pCmd->tagData.name); pCmd->tagData.dataLen = 0; - code = tscGetTableMeta(pSql, pSTableMeterMetaInfo); + code = tscGetTableMeta(pSql, pSTableMetaInfo); if (code != TSDB_CODE_SUCCESS) { return code; } - if (!UTIL_TABLE_IS_SUPER_TABLE(pSTableMeterMetaInfo)) { + if (!UTIL_TABLE_IS_SUPER_TABLE(pSTableMetaInfo)) { return tscInvalidSQLErrMsg(pCmd->payload, "create table only from super table is allowed", sToken.z); } - SSchema *pTagSchema = tscGetTableTagSchema(pSTableMeterMetaInfo->pTableMeta); - STableComInfo tinfo = tscGetTableInfo(pSTableMeterMetaInfo->pTableMeta); + SSchema *pTagSchema = tscGetTableTagSchema(pSTableMetaInfo->pTableMeta); + STableComInfo tinfo = tscGetTableInfo(pSTableMetaInfo->pTableMeta); index = 0; sToken = tStrGetToken(sql, &index, false, 0, NULL); @@ -840,7 +840,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { SParsedDataColInfo spd = {0}; - uint8_t numOfTags = tscGetNumOfTags(pSTableMeterMetaInfo->pTableMeta); + uint8_t numOfTags = tscGetNumOfTags(pSTableMetaInfo->pTableMeta); spd.numOfCols = numOfTags; // if specify some tags column @@ -1036,11 +1036,7 @@ static int32_t validateDataSource(SSqlCmd *pCmd, int8_t type, const char *sql) { } /** - * usage: insert into table1 values() () table2 values()() - * - * @param str - * @param acct - * @param db + * parse insert sql * @param pSql * @return */ @@ -1343,10 +1339,11 @@ int tsParseSql(SSqlObj *pSql, bool initial) { // make a backup as tsParseInsertSql may modify the string char* sqlstr = strdup(pSql->sqlstr); ret = tsParseInsertSql(pSql); - if (sqlstr == NULL || pSql->parseRetry >= 1 || ret != TSDB_CODE_TSC_INVALID_SQL) { + if ((sqlstr == NULL) || (pSql->parseRetry >= 1) || + (ret != TSDB_CODE_TSC_SQL_SYNTAX_ERROR && ret != TSDB_CODE_TSC_INVALID_SQL)) { free(sqlstr); } else { - tscResetSqlCmdObj(pCmd); + tscResetSqlCmd(pCmd, true); free(pSql->sqlstr); pSql->sqlstr = sqlstr; pSql->parseRetry++; @@ -1358,7 +1355,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) { SSqlInfo SQLInfo = qSQLParse(pSql->sqlstr); ret = tscToSQLCmd(pSql, &SQLInfo); if (ret == TSDB_CODE_TSC_INVALID_SQL && pSql->parseRetry == 0 && SQLInfo.type == TSDB_SQL_NULL) { - tscResetSqlCmdObj(pCmd); + tscResetSqlCmd(pCmd, true); pSql->parseRetry++; ret = tscToSQLCmd(pSql, &SQLInfo); } @@ -1406,39 +1403,38 @@ typedef struct SImportFileSupport { FILE *fp; } SImportFileSupport; -static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) { +static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRows) { assert(param != NULL && tres != NULL); + char * tokenBuf = NULL; + size_t n = 0; + ssize_t readLen = 0; + char * line = NULL; + int32_t count = 0; + int32_t maxRows = 0; + FILE * fp = NULL; + SSqlObj *pSql = tres; SSqlCmd *pCmd = &pSql->cmd; - SImportFileSupport *pSupporter = (SImportFileSupport *) param; + SImportFileSupport *pSupporter = (SImportFileSupport *)param; SSqlObj *pParentSql = pSupporter->pSql; - FILE *fp = pSupporter->fp; - - if (taos_errno(pSql) != TSDB_CODE_SUCCESS) { // handle error - assert(taos_errno(pSql) == code); - - do { - if (code == TSDB_CODE_TDB_TABLE_RECONFIGURE) { - assert(pSql->res.numOfRows == 0); - int32_t errc = fseek(fp, 0, SEEK_SET); - if (errc < 0) { - tscError("%p failed to seek SEEK_SET since:%s", pSql, tstrerror(errno)); - } else { - break; - } - } - - taos_free_result(pSql); - tfree(pSupporter); - fclose(fp); - - pParentSql->res.code = code; - tscAsyncResultOnError(pParentSql); - return; - } while (0); + fp = pSupporter->fp; + + int32_t code = pSql->res.code; + + // retry parse data from file and import data from the begining again + if (code == TSDB_CODE_TDB_TABLE_RECONFIGURE) { + assert(pSql->res.numOfRows == 0); + int32_t ret = fseek(fp, 0, SEEK_SET); + if (ret < 0) { + tscError("%p failed to seek SEEK_SET since:%s", pSql, tstrerror(errno)); + code = TAOS_SYSTEM_ERROR(errno); + goto _error; + } + } else if (code != TSDB_CODE_SUCCESS) { + goto _error; } // accumulate the total submit records @@ -1452,28 +1448,32 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) { SParsedDataColInfo spd = {.numOfCols = tinfo.numOfColumns}; tscSetAssignedColumnInfo(&spd, pSchema, tinfo.numOfColumns); - size_t n = 0; - ssize_t readLen = 0; - char * line = NULL; - int32_t count = 0; - int32_t maxRows = 0; - tfree(pCmd->pTableNameList); pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks); if (pCmd->pTableBlockHashList == NULL) { pCmd->pTableBlockHashList = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); + if (pCmd->pTableBlockHashList == NULL) { + code = TSDB_CODE_TSC_OUT_OF_MEMORY; + goto _error; + } } STableDataBlocks *pTableDataBlock = NULL; - int32_t ret = tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, - sizeof(SSubmitBlk), tinfo.rowSize, pTableMetaInfo->name, pTableMeta, &pTableDataBlock, NULL); + int32_t ret = + tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk), + tinfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pTableDataBlock, NULL); if (ret != TSDB_CODE_SUCCESS) { -// return ret; + pParentSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY; + goto _error; } tscAllocateMemIfNeed(pTableDataBlock, tinfo.rowSize, &maxRows); - char *tokenBuf = calloc(1, 4096); + tokenBuf = calloc(1, TSDB_MAX_BYTES_PER_ROW); + if (tokenBuf == NULL) { + code = TSDB_CODE_TSC_OUT_OF_MEMORY; + goto _error; + } while ((readLen = tgetline(&line, &n, fp)) != -1) { if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) { @@ -1501,30 +1501,42 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) { } tfree(tokenBuf); - free(line); + tfree(line); + + pParentSql->res.code = code; + if (code == TSDB_CODE_SUCCESS) { + if (count > 0) { + code = doPackSendDataBlock(pSql, count, pTableDataBlock); + if (code == TSDB_CODE_SUCCESS) { + return; + } else { + goto _error; + } + } else { + taos_free_result(pSql); + tfree(pSupporter); + fclose(fp); - if (count > 0) { - code = doPackSendDataBlock(pSql, count, pTableDataBlock); - if (code != TSDB_CODE_SUCCESS) { - pParentSql->res.code = code; - tscAsyncResultOnError(pParentSql); + pParentSql->fp = pParentSql->fetchFp; + + // all data has been sent to vnode, call user function + int32_t v = (code != TSDB_CODE_SUCCESS) ? code : (int32_t)pParentSql->res.numOfRows; + (*pParentSql->fp)(pParentSql->param, pParentSql, v); return; } + } - } else { - taos_free_result(pSql); - tfree(pSupporter); - fclose(fp); - - pParentSql->fp = pParentSql->fetchFp; +_error: + tfree(tokenBuf); + tfree(line); + taos_free_result(pSql); + tfree(pSupporter); + fclose(fp); - // all data has been sent to vnode, call user function - int32_t v = (pParentSql->res.code != TSDB_CODE_SUCCESS) ? pParentSql->res.code : (int32_t)pParentSql->res.numOfRows; - (*pParentSql->fp)(pParentSql->param, pParentSql, v); - } + tscAsyncResultOnError(pParentSql); } -void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) { +void tscImportDataFromFile(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; if (pCmd->command != TSDB_SQL_INSERT) { return; @@ -1543,12 +1555,11 @@ void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) { tfree(pSupporter); tscAsyncResultOnError(pSql); - return; } pSupporter->pSql = pSql; - pSupporter->fp = fp; + pSupporter->fp = fp; - parseFileSendDataBlock(pSupporter, pNew, 0); + parseFileSendDataBlock(pSupporter, pNew, TSDB_CODE_SUCCESS); } diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 7c69c16b049e45a763118ccd5a43e3ab3337ed46..c5f06a52f342b5726321925c1864d58c41afbeb4 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -707,7 +707,7 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { int32_t ret = tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk), - pTableMeta->tableInfo.rowSize, pTableMetaInfo->name, pTableMeta, &pBlock, NULL); + pTableMeta->tableInfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pBlock, NULL); if (ret != 0) { // todo handle error } @@ -790,7 +790,7 @@ static int insertStmtExecute(STscStmt* stmt) { int32_t ret = tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk), - pTableMeta->tableInfo.rowSize, pTableMetaInfo->name, pTableMeta, &pBlock, NULL); + pTableMeta->tableInfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pBlock, NULL); assert(ret == 0); pBlock->size = sizeof(SSubmitBlk) + pCmd->batchSize * pBlock->rowSize; SSubmitBlk* pBlk = (SSubmitBlk*) pBlock->pData; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 2886c22f5d39d22ca73eb31956eb217351a86584..226de59f460e7a94e8a5f02f23f63225b12cd8ea 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -20,7 +20,7 @@ #include "os.h" #include "ttype.h" -#include "qAst.h" +#include "texpr.h" #include "taos.h" #include "taosmsg.h" #include "tcompare.h" @@ -60,7 +60,7 @@ static int32_t setShowInfo(SSqlObj* pSql, SSqlInfo* pInfo); static char* getAccountId(SSqlObj* pSql); static bool has(SArray* pFieldList, int32_t startIdx, const char* name); -static void getCurrentDBName(SSqlObj* pSql, SStrToken* pDBToken); +static char* getCurrentDBName(SSqlObj* pSql); static bool hasSpecifyDB(SStrToken* pTableName); static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd); static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd); @@ -100,8 +100,8 @@ static int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryI static int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo); static int32_t validateArithmeticSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type); static int32_t validateEp(char* ep); -static int32_t validateDNodeConfig(tDCLSQL* pOptions); -static int32_t validateLocalConfig(tDCLSQL* pOptions); +static int32_t validateDNodeConfig(SMiscInfo* pOptions); +static int32_t validateLocalConfig(SMiscInfo* pOptions); static int32_t validateColumnName(char* name); static int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType); @@ -110,7 +110,7 @@ static bool hasTimestampForPointInterpQuery(SQueryInfo* pQueryInfo); static bool hasNormalColumnFilter(SQueryInfo* pQueryInfo); static int32_t parseLimitClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t index, SQuerySQL* pQuerySql, SSqlObj* pSql); -static int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql); +static int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDbInfo* pCreateDbSql); static int32_t getColumnIndexByName(SSqlCmd* pCmd, const SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex); static int32_t getTableIndexByName(SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex); static int32_t optrToString(tSQLExpr* pExpr, char** exprString); @@ -239,7 +239,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { int32_t code = TSDB_CODE_SUCCESS; if (!pInfo->valid || terrno == TSDB_CODE_TSC_SQL_SYNTAX_ERROR) { terrno = TSDB_CODE_SUCCESS; // clear the error number - return tscSQLSyntaxErrMsg(tscGetErrorMsgPayload(pCmd), NULL, pInfo->pzErrMsg); + return tscSQLSyntaxErrMsg(tscGetErrorMsgPayload(pCmd), NULL, pInfo->msg); } SQueryInfo* pQueryInfo = tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex); @@ -264,36 +264,48 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { case TSDB_SQL_DROP_DB: { const char* msg2 = "invalid name"; const char* msg3 = "param name too long"; + const char* msg4 = "table is not super table"; - SStrToken* pzName = &pInfo->pDCLInfo->a[0]; + SStrToken* pzName = taosArrayGet(pInfo->pMiscInfo->a, 0); if ((pInfo->type != TSDB_SQL_DROP_DNODE) && (tscValidateName(pzName) != TSDB_CODE_SUCCESS)) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } if (pInfo->type == TSDB_SQL_DROP_DB) { - assert(pInfo->pDCLInfo->nTokens == 1); - - code = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), pzName, NULL, NULL); + assert(taosArrayGetSize(pInfo->pMiscInfo->a) == 1); + code = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), pzName); if (code != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } } else if (pInfo->type == TSDB_SQL_DROP_TABLE) { - assert(pInfo->pDCLInfo->nTokens == 1); + assert(taosArrayGetSize(pInfo->pMiscInfo->a) == 1); code = tscSetTableFullName(pTableMetaInfo, pzName, pSql); if(code != TSDB_CODE_SUCCESS) { return code; } + + if (pInfo->pMiscInfo->tableType == TSDB_SUPER_TABLE) { + code = tscGetTableMeta(pSql, pTableMetaInfo); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4); + } + } + } else if (pInfo->type == TSDB_SQL_DROP_DNODE) { pzName->n = strdequote(pzName->z); - strncpy(pTableMetaInfo->name, pzName->z, pzName->n); - } else { // drop user + strncpy(pCmd->payload, pzName->z, pzName->n); + } else { // drop user/account if (pzName->n >= TSDB_USER_LEN) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); } - strncpy(pTableMetaInfo->name, pzName->z, pzName->n); + strncpy(pCmd->payload, pzName->z, pzName->n); } break; @@ -301,13 +313,13 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { case TSDB_SQL_USE_DB: { const char* msg = "invalid db name"; - SStrToken* pToken = &pInfo->pDCLInfo->a[0]; + SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0); if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } - int32_t ret = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), pToken, NULL, NULL); + int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), pToken); if (ret != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } @@ -332,12 +344,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg1 = "invalid db name"; const char* msg2 = "name too long"; - SCreateDBInfo* pCreateDB = &(pInfo->pDCLInfo->dbOpt); + SCreateDbInfo* pCreateDB = &(pInfo->pMiscInfo->dbOpt); if (tscValidateName(&pCreateDB->dbname) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - int32_t ret = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), &(pCreateDB->dbname), NULL, NULL); + int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), &(pCreateDB->dbname)); if (ret != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -349,15 +361,15 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { break; } - case TSDB_SQL_CREATE_DNODE: { // todo hostname + case TSDB_SQL_CREATE_DNODE: { const char* msg = "invalid host name (ip address)"; - if (pInfo->pDCLInfo->nTokens > 1) { + if (taosArrayGetSize(pInfo->pMiscInfo->a) > 1) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } - SStrToken* pIpAddr = &pInfo->pDCLInfo->a[0]; - pIpAddr->n = strdequote(pIpAddr->z); + SStrToken* id = taosArrayGet(pInfo->pMiscInfo->a, 0); + id->n = strdequote(id->z); break; } @@ -367,8 +379,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg2 = "invalid user/account name"; const char* msg3 = "name too long"; - SStrToken* pName = &pInfo->pDCLInfo->user.user; - SStrToken* pPwd = &pInfo->pDCLInfo->user.passwd; + SStrToken* pName = &pInfo->pMiscInfo->user.user; + SStrToken* pPwd = &pInfo->pMiscInfo->user.passwd; if (handlePassword(pCmd, pPwd) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_SQL; @@ -382,7 +394,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } - SCreateAcctSQL* pAcctOpt = &pInfo->pDCLInfo->acctOpt; + SCreateAcctInfo* pAcctOpt = &pInfo->pMiscInfo->acctOpt; if (pAcctOpt->stat.n > 0) { if (pAcctOpt->stat.z[0] == 'r' && pAcctOpt->stat.n == 1) { } else if (pAcctOpt->stat.z[0] == 'w' && pAcctOpt->stat.n == 1) { @@ -397,10 +409,10 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } case TSDB_SQL_DESCRIBE_TABLE: { - SStrToken* pToken = &pInfo->pDCLInfo->a[0]; const char* msg1 = "invalid table name"; const char* msg2 = "table name too long"; + SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0); if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -418,10 +430,10 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { return tscGetTableMeta(pSql, pTableMetaInfo); } case TSDB_SQL_SHOW_CREATE_TABLE: { - SStrToken* pToken = &pInfo->pDCLInfo->a[0]; const char* msg1 = "invalid table name"; const char* msg2 = "table name is too long"; + SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0); if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -439,11 +451,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } case TSDB_SQL_SHOW_CREATE_DATABASE: { const char* msg1 = "invalid database name"; - SStrToken* pToken = &pInfo->pDCLInfo->a[0]; + SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0); if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } + if (pToken->n > TSDB_DB_NAME_LEN) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -455,29 +468,34 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg3 = "invalid dnode ep"; /* validate the ip address */ - tDCLSQL* pDCL = pInfo->pDCLInfo; + SMiscInfo* pMiscInfo = pInfo->pMiscInfo; /* validate the parameter names and options */ - if (validateDNodeConfig(pDCL) != TSDB_CODE_SUCCESS) { + if (validateDNodeConfig(pMiscInfo) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } char* pMsg = pCmd->payload; SCfgDnodeMsg* pCfg = (SCfgDnodeMsg*)pMsg; - pDCL->a[0].n = strdequote(pDCL->a[0].z); - - strncpy(pCfg->ep, pDCL->a[0].z, pDCL->a[0].n); + + SStrToken* t0 = taosArrayGet(pMiscInfo->a, 0); + SStrToken* t1 = taosArrayGet(pMiscInfo->a, 1); + + t0->n = strdequote(t0->z); + strncpy(pCfg->ep, t0->z, t0->n); if (validateEp(pCfg->ep) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); } - strncpy(pCfg->config, pDCL->a[1].z, pDCL->a[1].n); + strncpy(pCfg->config, t1->z, t1->n); + + if (taosArrayGetSize(pMiscInfo->a) == 3) { + SStrToken* t2 = taosArrayGet(pMiscInfo->a, 2); - if (pDCL->nTokens == 3) { - pCfg->config[pDCL->a[1].n] = ' '; // add sep - strncpy(&pCfg->config[pDCL->a[1].n + 1], pDCL->a[2].z, pDCL->a[2].n); + pCfg->config[t1->n] = ' '; // add sep + strncpy(&pCfg->config[t1->n + 1], t2->z, t2->n); } break; @@ -492,7 +510,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { pCmd->command = pInfo->type; - SUserInfo* pUser = &pInfo->pDCLInfo->user; + SUserInfo* pUser = &pInfo->pMiscInfo->user; SStrToken* pName = &pUser->user; SStrToken* pPwd = &pUser->passwd; @@ -536,18 +554,22 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } case TSDB_SQL_CFG_LOCAL: { - tDCLSQL* pDCL = pInfo->pDCLInfo; - const char* msg = "invalid configure options or values"; + SMiscInfo *pMiscInfo = pInfo->pMiscInfo; + const char *msg = "invalid configure options or values"; // validate the parameter names and options - if (validateLocalConfig(pDCL) != TSDB_CODE_SUCCESS) { + if (validateLocalConfig(pMiscInfo) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } - strncpy(pCmd->payload, pDCL->a[0].z, pDCL->a[0].n); - if (pDCL->nTokens == 2) { - pCmd->payload[pDCL->a[0].n] = ' '; // add sep - strncpy(&pCmd->payload[pDCL->a[0].n + 1], pDCL->a[1].z, pDCL->a[1].n); + int32_t numOfToken = (int32_t) taosArrayGetSize(pMiscInfo->a); + SStrToken* t = taosArrayGet(pMiscInfo->a, 0); + SStrToken* t1 = taosArrayGet(pMiscInfo->a, 1); + + strncpy(pCmd->payload, t->z, t->n); + if (numOfToken == 2) { + pCmd->payload[t->n] = ' '; // add sep + strncpy(&pCmd->payload[t->n + 1], t1->z, t1->n); } break; @@ -878,47 +900,51 @@ int32_t parseSlidingClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQu return TSDB_CODE_SUCCESS; } -int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql) { +int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pTableName, SSqlObj* pSql) { const char* msg1 = "name too long"; + const char* msg2 = "acctId too long"; SSqlCmd* pCmd = &pSql->cmd; int32_t code = TSDB_CODE_SUCCESS; - // backup the old name in pTableMetaInfo - char oldName[TSDB_TABLE_FNAME_LEN] = {0}; - tstrncpy(oldName, pTableMetaInfo->name, tListLen(oldName)); + if (hasSpecifyDB(pTableName)) { // db has been specified in sql string so we ignore current db path + code = tNameSetAcctId(&pTableMetaInfo->name, getAccountId(pSql)); + if (code != 0) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + + char name[TSDB_TABLE_FNAME_LEN] = {0}; + strncpy(name, pTableName->z, pTableName->n); - if (hasSpecifyDB(pzTableName)) { // db has been specified in sql string so we ignore current db path - code = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), NULL, pzTableName, NULL); + code = tNameFromString(&pTableMetaInfo->name, name, T_NAME_DB|T_NAME_TABLE); if (code != 0) { - invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } } else { // get current DB name first, and then set it into path - SStrToken t = {0}; - getCurrentDBName(pSql, &t); - if (t.n == 0) { // current database not available or not specified - code = TSDB_CODE_TSC_DB_NOT_SELECTED; - } else { - code = setObjFullName(pTableMetaInfo->name, NULL, &t, pzTableName, NULL); - if (code != 0) { - invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); - } + char* t = getCurrentDBName(pSql); + if (strlen(t) == 0) { + return TSDB_CODE_TSC_DB_NOT_SELECTED; } - } - if (code != TSDB_CODE_SUCCESS) { - return code; - } + code = tNameFromString(&pTableMetaInfo->name, t, T_NAME_ACCT | T_NAME_DB); + if (code != 0) { + return TSDB_CODE_TSC_DB_NOT_SELECTED; + } - /* - * the old name exists and is not equalled to the new name. Release the table meta - * that are corresponding to the old name for the new table name. - */ - if (strlen(oldName) > 0 && strncasecmp(oldName, pTableMetaInfo->name, tListLen(pTableMetaInfo->name)) != 0) { - tscClearTableMetaInfo(pTableMetaInfo); + if (pTableName->n >= TSDB_TABLE_NAME_LEN) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } + + char name[TSDB_TABLE_FNAME_LEN] = {0}; + strncpy(name, pTableName->z, pTableName->n); + + code = tNameFromString(&pTableMetaInfo->name, name, T_NAME_TABLE); + if (code != 0) { + code = invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } } - return TSDB_CODE_SUCCESS; + return code; } static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd) { @@ -1218,9 +1244,8 @@ static bool has(SArray* pFieldList, int32_t startIdx, const char* name) { static char* getAccountId(SSqlObj* pSql) { return pSql->pTscObj->acctId; } -static void getCurrentDBName(SSqlObj* pSql, SStrToken* pDBToken) { - pDBToken->z = pSql->pTscObj->db; - pDBToken->n = (uint32_t)strlen(pSql->pTscObj->db); +static char* getCurrentDBName(SSqlObj* pSql) { + return pSql->pTscObj->db; } /* length limitation, strstr cannot be applied */ @@ -1333,7 +1358,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t int32_t ret = exprTreeFromSqlExpr(pCmd, &pNode, pItem->pNode, pQueryInfo, colList, NULL); if (ret != TSDB_CODE_SUCCESS) { taosArrayDestroy(colList); - tExprTreeDestroy(&pNode, NULL); + tExprTreeDestroy(pNode, NULL); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -1342,9 +1367,9 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t for(int32_t k = 0; k < numOfNode; ++k) { SColIndex* pIndex = taosArrayGet(colList, k); if (TSDB_COL_IS_TAG(pIndex->flag)) { - tExprTreeDestroy(&pNode, NULL); + tExprTreeDestroy(pNode, NULL); taosArrayDestroy(colList); - tExprTreeDestroy(&pNode, NULL); + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); } } @@ -1371,7 +1396,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t tbufCloseWriter(&bw); taosArrayDestroy(colList); - tExprTreeDestroy(&pNode, NULL); + tExprTreeDestroy(pNode, NULL); } else { columnList.num = 0; columnList.ids[0] = (SColumnIndex) {0, 0}; @@ -1403,7 +1428,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t int32_t ret = exprTreeFromSqlExpr(pCmd, &pArithExprInfo->pExpr, pItem->pNode, pQueryInfo, NULL, &pArithExprInfo->uid); if (ret != TSDB_CODE_SUCCESS) { - tExprTreeDestroy(&pArithExprInfo->pExpr, NULL); + tExprTreeDestroy(pArithExprInfo->pExpr, NULL); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), "invalid expression in select clause"); } @@ -2176,6 +2201,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col if (getColumnIndexByName(pCmd, &pParamElem->pNode->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); } + if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6); } @@ -2608,10 +2634,10 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg6 = "pattern string is empty"; /* - * database prefix in pInfo->pDCLInfo->a[0] - * wildcard in like clause in pInfo->pDCLInfo->a[1] + * database prefix in pInfo->pMiscInfo->a[0] + * wildcard in like clause in pInfo->pMiscInfo->a[1] */ - SShowInfo* pShowInfo = &pInfo->pDCLInfo->showOpt; + SShowInfo* pShowInfo = &pInfo->pMiscInfo->showOpt; int16_t showType = pShowInfo->showType; if (showType == TSDB_MGMT_TABLE_TABLE || showType == TSDB_MGMT_TABLE_METRIC || showType == TSDB_MGMT_TABLE_VGROUP) { // db prefix in tagCond, show table conds in payload @@ -2630,7 +2656,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - int32_t ret = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), pDbPrefixToken, NULL, NULL); + int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), pDbPrefixToken); if (ret != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -2675,7 +2701,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) { SSqlCmd* pCmd = &pSql->cmd; pCmd->command = pInfo->type; - SStrToken* idStr = &(pInfo->pDCLInfo->ip); + SStrToken* idStr = &(pInfo->pMiscInfo->id); if (idStr->n > TSDB_KILL_MSG_LEN) { return TSDB_CODE_TSC_INVALID_SQL; } @@ -2910,7 +2936,7 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd) STableMeta* pTableMeta = NULL; SSchema* pSchema = NULL; - SSchema s = tscGetTbnameColumnSchema(); + SSchema s = tGetTbnameColumnSchema(); int32_t tableIndex = COLUMN_INDEX_INITIAL_VAL; @@ -3433,6 +3459,7 @@ static int32_t getColumnQueryCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr* pExpr) { const char* msg1 = "invalid join query condition"; + const char* msg2 = "invalid table name in join query"; const char* msg3 = "type of join columns must be identical"; const char* msg4 = "invalid column name in join condition"; @@ -3458,7 +3485,11 @@ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr* pLeft->uid = pTableMetaInfo->pTableMeta->id.uid; pLeft->tagColId = pTagSchema1->colId; - strcpy(pLeft->tableId, pTableMetaInfo->name); + + int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pLeft->tableName); + if (code != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + } index = (SColumnIndex)COLUMN_INDEX_INITIALIZER; if (getColumnIndexByName(pCmd, &pExpr->pRight->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) { @@ -3470,7 +3501,11 @@ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr* pRight->uid = pTableMetaInfo->pTableMeta->id.uid; pRight->tagColId = pTagSchema2->colId; - strcpy(pRight->tableId, pTableMetaInfo->name); + + code = tNameExtractFullName(&pTableMetaInfo->name, pRight->tableName); + if (code != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); + } if (pTagSchema1->type != pTagSchema2->type) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); @@ -4047,8 +4082,6 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SStringBuilder sb1; memset(&sb1, 0, sizeof(sb1)); taosStringBuilderAppendStringLen(&sb1, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN); - char db[TSDB_TABLE_FNAME_LEN] = {0}; - // remove the duplicated input table names int32_t num = 0; char* tableNameString = taosStringBuilderGetResult(sb, NULL); @@ -4064,7 +4097,8 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, } num = j; - char* name = extractDBName(pTableMetaInfo->name, db); + 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) { @@ -4286,7 +4320,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE doCompactQueryExpr(pExpr); tSqlExprDestroy(p1); - tExprTreeDestroy(&p, NULL); + tExprTreeDestroy(p, NULL); taosArrayDestroy(colList); if (pQueryInfo->tagCond.pCond != NULL && taosArrayGetSize(pQueryInfo->tagCond.pCond) > 0 && !UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { @@ -4507,10 +4541,10 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuery return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } - size_t size = tscNumOfFields(pQueryInfo); + size_t numOfFields = tscNumOfFields(pQueryInfo); if (pQueryInfo->fillVal == NULL) { - pQueryInfo->fillVal = calloc(size, sizeof(int64_t)); + pQueryInfo->fillVal = calloc(numOfFields, sizeof(int64_t)); if (pQueryInfo->fillVal == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } @@ -4520,7 +4554,7 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuery pQueryInfo->fillType = TSDB_FILL_NONE; } else if (strncasecmp(pItem->pVar.pz, "null", 4) == 0 && pItem->pVar.nLen == 4) { pQueryInfo->fillType = TSDB_FILL_NULL; - for (int32_t i = START_INTERPO_COL_IDX; i < size; ++i) { + for (int32_t i = START_INTERPO_COL_IDX; i < numOfFields; ++i) { TAOS_FIELD* pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); setNull((char*)&pQueryInfo->fillVal[i], pField->type, pField->bytes); } @@ -4534,7 +4568,7 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuery pQueryInfo->fillType = TSDB_FILL_SET_VALUE; size_t num = taosArrayGetSize(pFillToken); - if (num == 1) { + if (num == 1) { // no actual value, return with error code return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -4545,11 +4579,11 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuery if (tscIsPointInterpQuery(pQueryInfo)) { startPos = 0; - if (numOfFillVal > size) { - numOfFillVal = (int32_t)size; + if (numOfFillVal > numOfFields) { + numOfFillVal = (int32_t)numOfFields; } } else { - numOfFillVal = (int16_t)((num > (int32_t)size) ? (int32_t)size : num); + numOfFillVal = (int16_t)((num > (int32_t)numOfFields) ? (int32_t)numOfFields : num); } int32_t j = 1; @@ -4569,10 +4603,10 @@ int32_t parseFillClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuery } } - if ((num < size) || ((num - 1 < size) && (tscIsPointInterpQuery(pQueryInfo)))) { + if ((num < numOfFields) || ((num - 1 < numOfFields) && (tscIsPointInterpQuery(pQueryInfo)))) { tVariantListItem* lastItem = taosArrayGetLast(pFillToken); - for (int32_t i = numOfFillVal; i < size; ++i) { + for (int32_t i = numOfFillVal; i < numOfFields; ++i) { TAOS_FIELD* pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); if (pField->type == TSDB_DATA_TYPE_BINARY || pField->type == TSDB_DATA_TYPE_NCHAR) { @@ -4806,11 +4840,12 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg17 = "invalid column name"; const char* msg18 = "primary timestamp column cannot be dropped"; const char* msg19 = "invalid new tag name"; + const char* msg20 = "table is not super table"; int32_t code = TSDB_CODE_SUCCESS; SSqlCmd* pCmd = &pSql->cmd; - SAlterTableSQL* pAlterSQL = pInfo->pAlterInfo; + SAlterTableInfo* pAlterSQL = pInfo->pAlterInfo; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, DEFAULT_TABLE_INDEX); @@ -4831,6 +4866,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; + if (pAlterSQL->tableType == TSDB_SUPER_TABLE && !(UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo))) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg20); + } + if (pAlterSQL->type == TSDB_ALTER_TABLE_ADD_TAG_COLUMN || pAlterSQL->type == TSDB_ALTER_TABLE_DROP_TAG_COLUMN || pAlterSQL->type == TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN) { if (UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) { @@ -5145,8 +5184,10 @@ int32_t validateEp(char* ep) { return TSDB_CODE_SUCCESS; } -int32_t validateDNodeConfig(tDCLSQL* pOptions) { - if (pOptions->nTokens < 2 || pOptions->nTokens > 3) { +int32_t validateDNodeConfig(SMiscInfo* pOptions) { + int32_t numOfToken = (int32_t) taosArrayGetSize(pOptions->a); + + if (numOfToken < 2 || numOfToken > 3) { return TSDB_CODE_TSC_INVALID_SQL; } @@ -5164,9 +5205,9 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { {"cqDebugFlag", 11}, }; - SStrToken* pOptionToken = &pOptions->a[1]; + SStrToken* pOptionToken = taosArrayGet(pOptions->a, 1); - if (pOptions->nTokens == 2) { + if (numOfToken == 2) { // reset log and reset query cache does not need value for (int32_t i = 0; i < tokenLogEnd; ++i) { const SDNodeDynConfOption* pOption = &cfgOptions[i]; @@ -5176,7 +5217,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { } } else if ((strncasecmp(cfgOptions[tokenBalance].name, pOptionToken->z, pOptionToken->n) == 0) && (cfgOptions[tokenBalance].len == pOptionToken->n)) { - SStrToken* pValToken = &pOptions->a[2]; + SStrToken* pValToken = taosArrayGet(pOptions->a, 2); int32_t vnodeId = 0; int32_t dnodeId = 0; strdequote(pValToken->z); @@ -5187,14 +5228,14 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { return TSDB_CODE_SUCCESS; } else if ((strncasecmp(cfgOptions[tokenMonitor].name, pOptionToken->z, pOptionToken->n) == 0) && (cfgOptions[tokenMonitor].len == pOptionToken->n)) { - SStrToken* pValToken = &pOptions->a[2]; + SStrToken* pValToken = taosArrayGet(pOptions->a, 2); int32_t val = strtol(pValToken->z, NULL, 10); if (val != 0 && val != 1) { return TSDB_CODE_TSC_INVALID_SQL; // options value is invalid } return TSDB_CODE_SUCCESS; } else { - SStrToken* pValToken = &pOptions->a[2]; + SStrToken* pValToken = taosArrayGet(pOptions->a, 2); int32_t val = strtol(pValToken->z, NULL, 10); if (val < 0 || val > 256) { @@ -5205,8 +5246,8 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { for (int32_t i = tokenDebugFlag; i < tokenDebugFlagEnd; ++i) { const SDNodeDynConfOption* pOption = &cfgOptions[i]; + // options is valid if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) { - /* options is valid */ return TSDB_CODE_SUCCESS; } } @@ -5215,17 +5256,18 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) { return TSDB_CODE_TSC_INVALID_SQL; } -int32_t validateLocalConfig(tDCLSQL* pOptions) { - if (pOptions->nTokens < 1 || pOptions->nTokens > 2) { +int32_t validateLocalConfig(SMiscInfo* pOptions) { + int32_t numOfToken = (int32_t) taosArrayGetSize(pOptions->a); + if (numOfToken < 1 || numOfToken > 2) { return TSDB_CODE_TSC_INVALID_SQL; } SDNodeDynConfOption LOCAL_DYNAMIC_CFG_OPTIONS[6] = {{"resetLog", 8}, {"rpcDebugFlag", 12}, {"tmrDebugFlag", 12}, {"cDebugFlag", 10}, {"uDebugFlag", 10}, {"debugFlag", 9}}; - SStrToken* pOptionToken = &pOptions->a[0]; + SStrToken* pOptionToken = taosArrayGet(pOptions->a, 0); - if (pOptions->nTokens == 1) { + if (numOfToken == 1) { // reset log does not need value for (int32_t i = 0; i < 1; ++i) { SDNodeDynConfOption* pOption = &LOCAL_DYNAMIC_CFG_OPTIONS[i]; @@ -5234,7 +5276,7 @@ int32_t validateLocalConfig(tDCLSQL* pOptions) { } } } else { - SStrToken* pValToken = &pOptions->a[1]; + SStrToken* pValToken = taosArrayGet(pOptions->a, 1); int32_t val = strtol(pValToken->z, NULL, 10); if (val < 131 || val > 199) { @@ -5386,7 +5428,7 @@ int32_t parseLimitClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t clauseIn return TSDB_CODE_SUCCESS; } -static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) { +static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDbInfo* pCreateDb) { const char* msg = "invalid number of options"; pMsg->daysToKeep = htonl(-1); @@ -5424,7 +5466,7 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* p return TSDB_CODE_SUCCESS; } -static int32_t setTimePrecision(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDbInfo) { +static int32_t setTimePrecision(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDbInfo* pCreateDbInfo) { const char* msg = "invalid time precision"; pMsg->precision = TSDB_TIME_PRECISION_MILLI; // millisecond by default @@ -5448,7 +5490,7 @@ static int32_t setTimePrecision(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo return TSDB_CODE_SUCCESS; } -static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) { +static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDbInfo* pCreateDb) { pMsg->maxTables = htonl(-1); // max tables can not be set anymore pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize); pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks); @@ -5466,7 +5508,7 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) { pMsg->cacheLastRow = pCreateDb->cachelast; } -int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql) { +int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDbInfo* pCreateDbSql) { SCreateDbMsg* pMsg = (SCreateDbMsg *)(pCmd->payload); setCreateDBOption(pMsg, pCreateDbSql); @@ -6227,9 +6269,9 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { } // get table meta from mnode - tstrncpy(pCreateTableInfo->tagdata.name, pStableMetaInfo->name, tListLen(pCreateTableInfo->tagdata.name)); - SArray* pList = pCreateTableInfo->pTagVals; + code = tNameExtractFullName(&pStableMetaInfo->name, pCreateTableInfo->tagdata.name); + SArray* pList = pCreateTableInfo->pTagVals; code = tscGetTableMeta(pSql, pStableMetaInfo); if (code != TSDB_CODE_SUCCESS) { return code; @@ -6307,7 +6349,11 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { return ret; } - pCreateTableInfo->fullname = strndup(pTableMetaInfo->name, TSDB_TABLE_FNAME_LEN); + pCreateTableInfo->fullname = calloc(1, tNameLen(&pTableMetaInfo->name) + 1); + ret = tNameExtractFullName(&pTableMetaInfo->name, pCreateTableInfo->fullname); + if (ret != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); + } } return TSDB_CODE_SUCCESS; @@ -6554,7 +6600,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { // has no table alias name if (memcmp(pTableItem->pz, p1->pVar.pz, p1->pVar.nLen) == 0) { - extractTableName(pTableMetaInfo1->name, pTableMetaInfo1->aliasName); + strncpy(pTableMetaInfo1->aliasName, tNameGetTableName(&pTableMetaInfo1->name), tListLen(pTableMetaInfo->aliasName)); } else { tstrncpy(pTableMetaInfo1->aliasName, p1->pVar.pz, sizeof(pTableMetaInfo1->aliasName)); } diff --git a/src/client/src/tscSchemaUtil.c b/src/client/src/tscSchemaUtil.c index 47c3cd97168f997ff366fa0712b7182558688d31..67352ca71cab03bb9cd2f6b920b97abebbe1420a 100644 --- a/src/client/src/tscSchemaUtil.c +++ b/src/client/src/tscSchemaUtil.c @@ -106,6 +106,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) { pTableMeta->sversion = pTableMetaMsg->sversion; pTableMeta->tversion = pTableMetaMsg->tversion; + tstrncpy(pTableMeta->sTableName, pTableMetaMsg->sTableName, TSDB_TABLE_FNAME_LEN); memcpy(pTableMeta->schema, pTableMetaMsg->schema, schemaSize); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 537e81413fdd74f54d74c1bb887f28498b0b7379..840387656691e0bd0e76908d311b0ac124db5baf 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -309,7 +309,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { return; } - if (pEpSet) { // todo update this + if (pEpSet) { if (!tscEpSetIsEqual(&pSql->epSet, pEpSet)) { if (pCmd->command < TSDB_SQL_MGMT) { tscUpdateVgroupInfo(pSql, pEpSet); @@ -461,16 +461,20 @@ int doProcessSql(SSqlObj *pSql) { } int tscProcessSql(SSqlObj *pSql) { - char *name = NULL; + char name[TSDB_TABLE_FNAME_LEN] = {0}; + SSqlCmd *pCmd = &pSql->cmd; - + uint32_t type = 0; + SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); STableMetaInfo *pTableMetaInfo = NULL; - uint32_t type = 0; if (pQueryInfo != NULL) { pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - name = (pTableMetaInfo != NULL)? pTableMetaInfo->name:NULL; + if (pTableMetaInfo != NULL) { + tNameExtractFullName(&pTableMetaInfo->name, name); + } + type = pQueryInfo->type; // while numOfTables equals to 0, it must be Heartbeat @@ -669,10 +673,11 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char pMsg += sizeof(STableIdInfo); } } - - tscDebug("%p vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), pTableMetaInfo->name, - pTableMeta->id.tid, pTableMeta->id.uid); - + + char n[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, n); + + tscDebug("%p vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), n, pTableMeta->id.tid, pTableMeta->id.uid); return pMsg; } @@ -755,8 +760,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSchema *pColSchema = &pSchema[pCol->colIndex.columnIndex]; if (pCol->colIndex.columnIndex >= tscGetNumOfColumns(pTableMeta) || !isValidDataType(pColSchema->type)) { + char n[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, n); + tscError("%p tid:%d uid:%" PRIu64" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s", - pSql, pTableMeta->id.tid, pTableMeta->id.uid, pTableMetaInfo->name, tscGetNumOfColumns(pTableMeta), pCol->colIndex.columnIndex, + pSql, pTableMeta->id.tid, pTableMeta->id.uid, n, tscGetNumOfColumns(pTableMeta), pCol->colIndex.columnIndex, pColSchema->name); return TSDB_CODE_TSC_INVALID_SQL; } @@ -942,9 +950,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { if ((pCol->colIndex.columnIndex >= numOfTagColumns || pCol->colIndex.columnIndex < -1) || (!isValidDataType(pColSchema->type))) { + char n[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, n); + tscError("%p tid:%d uid:%" PRIu64 " id:%s, tag index out of range, totalCols:%d, numOfTags:%d, index:%d, column name:%s", - pSql, pTableMeta->id.tid, pTableMeta->id.uid, pTableMetaInfo->name, total, numOfTagColumns, - pCol->colIndex.columnIndex, pColSchema->name); + pSql, pTableMeta->id.tid, pTableMeta->id.uid, n, total, numOfTagColumns, pCol->colIndex.columnIndex, pColSchema->name); return TSDB_CODE_TSC_INVALID_SQL; } @@ -1021,7 +1031,8 @@ int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) { assert(pCmd->numOfClause == 1); STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - tstrncpy(pCreateDbMsg->db, pTableMetaInfo->name, sizeof(pCreateDbMsg->db)); + int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pCreateDbMsg->db); + assert(code == TSDB_CODE_SUCCESS); return TSDB_CODE_SUCCESS; } @@ -1035,7 +1046,9 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } SCreateDnodeMsg *pCreate = (SCreateDnodeMsg *)pCmd->payload; - strncpy(pCreate->ep, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n); + + SStrToken* t0 = taosArrayGet(pInfo->pMiscInfo->a, 0); + strncpy(pCreate->ep, t0->z, t0->n); pCmd->msgType = TSDB_MSG_TYPE_CM_CREATE_DNODE; @@ -1052,13 +1065,13 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SCreateAcctMsg *pAlterMsg = (SCreateAcctMsg *)pCmd->payload; - SStrToken *pName = &pInfo->pDCLInfo->user.user; - SStrToken *pPwd = &pInfo->pDCLInfo->user.passwd; + SStrToken *pName = &pInfo->pMiscInfo->user.user; + SStrToken *pPwd = &pInfo->pMiscInfo->user.passwd; strncpy(pAlterMsg->user, pName->z, pName->n); strncpy(pAlterMsg->pass, pPwd->z, pPwd->n); - SCreateAcctSQL *pAcctOpt = &pInfo->pDCLInfo->acctOpt; + SCreateAcctInfo *pAcctOpt = &pInfo->pMiscInfo->acctOpt; pAlterMsg->cfg.maxUsers = htonl(pAcctOpt->maxUsers); pAlterMsg->cfg.maxDbs = htonl(pAcctOpt->maxDbs); @@ -1098,7 +1111,7 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SCreateUserMsg *pAlterMsg = (SCreateUserMsg *)pCmd->payload; - SUserInfo *pUser = &pInfo->pDCLInfo->user; + SUserInfo *pUser = &pInfo->pMiscInfo->user; strncpy(pAlterMsg->user, pUser->user.z, pUser->user.n); pAlterMsg->flag = (int8_t)pUser->type; @@ -1138,8 +1151,11 @@ int32_t tscBuildDropDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SDropDbMsg *pDropDbMsg = (SDropDbMsg*)pCmd->payload; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - tstrncpy(pDropDbMsg->db, pTableMetaInfo->name, sizeof(pDropDbMsg->db)); - pDropDbMsg->ignoreNotExists = pInfo->pDCLInfo->existsCheck ? 1 : 0; + + int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pDropDbMsg->db); + assert(code == TSDB_CODE_SUCCESS && pTableMetaInfo->name.type == TSDB_DB_NAME_T); + + pDropDbMsg->ignoreNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0; pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DB; return TSDB_CODE_SUCCESS; @@ -1156,15 +1172,19 @@ int32_t tscBuildDropTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SCMDropTableMsg *pDropTableMsg = (SCMDropTableMsg*)pCmd->payload; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - strcpy(pDropTableMsg->tableFname, pTableMetaInfo->name); - pDropTableMsg->igNotExists = pInfo->pDCLInfo->existsCheck ? 1 : 0; + tNameExtractFullName(&pTableMetaInfo->name, pDropTableMsg->name); + pDropTableMsg->igNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0; pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_TABLE; return TSDB_CODE_SUCCESS; } int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlCmd *pCmd = &pSql->cmd; + + char dnodeEp[TSDB_EP_LEN] = {0}; + tstrncpy(dnodeEp, pCmd->payload, TSDB_EP_LEN); + pCmd->payloadLen = sizeof(SDropDnodeMsg); if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { tscError("%p failed to malloc for query msg", pSql); @@ -1172,43 +1192,28 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } SDropDnodeMsg * pDrop = (SDropDnodeMsg *)pCmd->payload; - STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - tstrncpy(pDrop->ep, pTableMetaInfo->name, sizeof(pDrop->ep)); + tstrncpy(pDrop->ep, dnodeEp, tListLen(pDrop->ep)); pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DNODE; return TSDB_CODE_SUCCESS; } -int32_t tscBuildDropUserMsg(SSqlObj *pSql, SSqlInfo * UNUSED_PARAM(pInfo)) { +int32_t tscBuildDropUserAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlCmd *pCmd = &pSql->cmd; - pCmd->payloadLen = sizeof(SDropUserMsg); - pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_USER; - - if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { - tscError("%p failed to malloc for query msg", pSql); - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - - SDropUserMsg * pDropMsg = (SDropUserMsg *)pCmd->payload; - STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - tstrncpy(pDropMsg->user, pTableMetaInfo->name, sizeof(pDropMsg->user)); - return TSDB_CODE_SUCCESS; -} + char user[TSDB_USER_LEN] = {0}; + tstrncpy(user, pCmd->payload, TSDB_USER_LEN); -int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) { - SSqlCmd *pCmd = &pSql->cmd; pCmd->payloadLen = sizeof(SDropUserMsg); - pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_ACCT; + pCmd->msgType = (pInfo->type == TSDB_SQL_DROP_USER)? TSDB_MSG_TYPE_CM_DROP_USER:TSDB_MSG_TYPE_CM_DROP_ACCT; if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { tscError("%p failed to malloc for query msg", pSql); return TSDB_CODE_TSC_OUT_OF_MEMORY; } - SDropUserMsg * pDropMsg = (SDropUserMsg *)pCmd->payload; - STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - tstrncpy(pDropMsg->user, pTableMetaInfo->name, sizeof(pDropMsg->user)); + SDropUserMsg *pDropMsg = (SDropUserMsg *)pCmd->payload; + tstrncpy(pDropMsg->user, user, tListLen(user)); return TSDB_CODE_SUCCESS; } @@ -1224,7 +1229,7 @@ int32_t tscBuildUseDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SUseDbMsg *pUseDbMsg = (SUseDbMsg *)pCmd->payload; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - strcpy(pUseDbMsg->db, pTableMetaInfo->name); + tNameExtractFullName(&pTableMetaInfo->name, pUseDbMsg->db); pCmd->msgType = TSDB_MSG_TYPE_CM_USE_DB; return TSDB_CODE_SUCCESS; @@ -1244,14 +1249,14 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SShowMsg *pShowMsg = (SShowMsg *)pCmd->payload; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - size_t nameLen = strlen(pTableMetaInfo->name); - if (nameLen > 0) { - tstrncpy(pShowMsg->db, pTableMetaInfo->name, sizeof(pShowMsg->db)); // prefix is set here - } else { + + if (tNameIsEmpty(&pTableMetaInfo->name)) { tstrncpy(pShowMsg->db, pObj->db, sizeof(pShowMsg->db)); + } else { + tNameGetFullDbName(&pTableMetaInfo->name, pShowMsg->db); } - SShowInfo *pShowInfo = &pInfo->pDCLInfo->showOpt; + SShowInfo *pShowInfo = &pInfo->pMiscInfo->showOpt; pShowMsg->type = pShowInfo->showType; if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) { @@ -1310,12 +1315,12 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) { } int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { - int msgLen = 0; - SSchema * pSchema; - int size = 0; + int msgLen = 0; + int size = 0; + SSchema *pSchema; SSqlCmd *pCmd = &pSql->cmd; - SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); + SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); // Reallocate the payload size @@ -1346,11 +1351,10 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pMsg += sizeof(SCreateTableMsg); SCreatedTableInfo* p = taosArrayGet(list, i); - strcpy(pCreate->tableFname, p->fullname); + strcpy(pCreate->tableName, p->fullname); pCreate->igExists = (p->igExist)? 1 : 0; // use dbinfo from table id without modifying current db info - tscGetDBInfoFromTableFullName(p->fullname, pCreate->db); pMsg = serializeTagData(&p->tagdata, pMsg); int32_t len = (int32_t)(pMsg - (char*) pCreate); @@ -1359,10 +1363,8 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } else { // create (super) table pCreateTableMsg->numOfTables = htonl(1); // only one table will be created - strcpy(pCreateMsg->tableFname, pTableMetaInfo->name); - - // use dbinfo from table id without modifying current db info - tscGetDBInfoFromTableFullName(pTableMetaInfo->name, pCreateMsg->db); + int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pCreateMsg->tableName); + assert(code == 0); SCreateTableSQL *pCreateTable = pInfo->pCreateTableInfo; @@ -1420,7 +1422,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - SAlterTableSQL *pAlterInfo = pInfo->pAlterInfo; + SAlterTableInfo *pAlterInfo = pInfo->pAlterInfo; int size = tscEstimateAlterTableMsgLength(pCmd); if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) { tscError("%p failed to malloc for alter table msg", pSql); @@ -1428,9 +1430,8 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } SAlterTableMsg *pAlterTableMsg = (SAlterTableMsg *)pCmd->payload; - tscGetDBInfoFromTableFullName(pTableMetaInfo->name, pAlterTableMsg->db); - strcpy(pAlterTableMsg->tableFname, pTableMetaInfo->name); + tNameExtractFullName(&pTableMetaInfo->name, pAlterTableMsg->tableFname); pAlterTableMsg->type = htons(pAlterInfo->type); pAlterTableMsg->numOfCols = htons(tscNumOfFields(pQueryInfo)); @@ -1485,7 +1486,7 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SAlterDbMsg *pAlterDbMsg = (SAlterDbMsg* )pCmd->payload; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - tstrncpy(pAlterDbMsg->db, pTableMetaInfo->name, sizeof(pAlterDbMsg->db)); + tNameExtractFullName(&pTableMetaInfo->name, pAlterDbMsg->db); return TSDB_CODE_SUCCESS; } @@ -1623,13 +1624,17 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { - SSqlCmd * pCmd = &pSql->cmd; + SSqlCmd *pCmd = &pSql->cmd; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + STableInfoMsg *pInfoMsg = (STableInfoMsg *)pCmd->payload; + + int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pInfoMsg->tableFname); + if (code != TSDB_CODE_SUCCESS) { + return TSDB_CODE_TSC_INVALID_SQL; + } - STableInfoMsg *pInfoMsg = (STableInfoMsg *)pCmd->payload; - strcpy(pInfoMsg->tableFname, pTableMetaInfo->name); pInfoMsg->createFlag = htons(pSql->cmd.autoCreated ? 1 : 0); char *pMsg = (char *)pInfoMsg + sizeof(STableInfoMsg); @@ -1686,33 +1691,6 @@ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { return 0; } -//static UNUSED_FUNC int32_t tscEstimateMetricMetaMsgSize(SSqlCmd *pCmd) { -//// const int32_t defaultSize = -//// minMsgSize() + sizeof(SSuperTableMetaMsg) + sizeof(SMgmtHead) + sizeof(int16_t) * TSDB_MAX_TAGS; -//// SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); -//// -//// int32_t n = 0; -//// size_t size = taosArrayGetSize(pQueryInfo->tagCond.pCond); -//// for (int32_t i = 0; i < size; ++i) { -//// assert(0); -////// n += strlen(pQueryInfo->tagCond.cond[i].cond); -//// } -//// -//// int32_t tagLen = n * TSDB_NCHAR_SIZE; -//// if (pQueryInfo->tagCond.tbnameCond.cond != NULL) { -//// tagLen += strlen(pQueryInfo->tagCond.tbnameCond.cond) * TSDB_NCHAR_SIZE; -//// } -//// -//// int32_t joinCondLen = (TSDB_TABLE_FNAME_LEN + sizeof(int16_t)) * 2; -//// int32_t elemSize = sizeof(SSuperTableMetaElemMsg) * pQueryInfo->numOfTables; -//// -//// int32_t colSize = pQueryInfo->groupbyExpr.numOfGroupCols*sizeof(SColIndex); -//// -//// int32_t len = tagLen + joinCondLen + elemSize + colSize + defaultSize; -//// -//// return MAX(len, TSDB_DEFAULT_PAYLOAD_SIZE); -//} - int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlCmd *pCmd = &pSql->cmd; @@ -1725,9 +1703,10 @@ int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) { for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, i); - size_t size = sizeof(pTableMetaInfo->name); - tstrncpy(pMsg, pTableMetaInfo->name, size); - pMsg += size; + int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pMsg); + assert(code == TSDB_CODE_SUCCESS); + + pMsg += TSDB_TABLE_FNAME_LEN; } pCmd->msgType = TSDB_MSG_TYPE_CM_STABLE_VGROUP; @@ -1827,7 +1806,6 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { assert(i == 0); } - assert(isValidDataType(pSchema->type)); pSchema++; } @@ -1835,8 +1813,8 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { assert(pTableMetaInfo->pTableMeta == NULL); STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg); - if (!isValidSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfTags)) { - tscError("%p invalid table meta from mnode, name:%s", pSql, pTableMetaInfo->name); + if (!tIsValidSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfTags)) { + tscError("%p invalid table meta from mnode, name:%s", pSql, tNameGetTableName(&pTableMetaInfo->name)); return TSDB_CODE_TSC_INVALID_VALUE; } @@ -1854,11 +1832,19 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { tfree(pSupTableMeta); CChildTableMeta* cMeta = tscCreateChildMeta(pTableMeta); - taosHashPut(tscTableMetaInfo, pTableMetaInfo->name, strlen(pTableMetaInfo->name), cMeta, sizeof(CChildTableMeta)); + + char name[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, name); + + taosHashPut(tscTableMetaInfo, name, strlen(name), cMeta, sizeof(CChildTableMeta)); tfree(cMeta); } else { uint32_t s = tscGetTableMetaSize(pTableMeta); - taosHashPut(tscTableMetaInfo, pTableMetaInfo->name, strlen(pTableMetaInfo->name), pTableMeta, s); + + char name[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, name); + + taosHashPut(tscTableMetaInfo, name, strlen(name), pTableMeta, s); } // update the vgroupInfo if needed @@ -1877,9 +1863,10 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { } } - tscDebug("%p recv table meta, uid:%"PRId64 ", tid:%d, name:%s", pSql, pTableMeta->id.uid, pTableMeta->id.tid, pTableMetaInfo->name); + tscDebug("%p recv table meta, uid:%" PRIu64 ", tid:%d, name:%s", pSql, pTableMeta->id.uid, pTableMeta->id.tid, + tNameGetTableName(&pTableMetaInfo->name)); + free(pTableMeta); - return TSDB_CODE_SUCCESS; } @@ -2174,9 +2161,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) { int tscProcessUseDbRsp(SSqlObj *pSql) { STscObj * pObj = pSql->pTscObj; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0); - - tstrncpy(pObj->db, pTableMetaInfo->name, sizeof(pObj->db)); - return 0; + return tNameExtractFullName(&pTableMetaInfo->name, pObj->db); } int tscProcessDropDbRsp(SSqlObj *pSql) { @@ -2189,18 +2174,22 @@ int tscProcessDropTableRsp(SSqlObj *pSql) { STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0); //The cached tableMeta is expired in this case, so clean it in hash table - taosHashRemove(tscTableMetaInfo, pTableMetaInfo->name, strnlen(pTableMetaInfo->name, TSDB_TABLE_FNAME_LEN)); - tscDebug("%p remove table meta after drop table:%s, numOfRemain:%d", pSql, pTableMetaInfo->name, - (int32_t) taosHashGetSize(tscTableMetaInfo)); + char name[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, name); - assert(pTableMetaInfo->pTableMeta == NULL); + taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN)); + tscDebug("%p remove table meta after drop table:%s, numOfRemain:%d", pSql, name, (int32_t) taosHashGetSize(tscTableMetaInfo)); + + pTableMetaInfo->pTableMeta = NULL; return 0; } int tscProcessAlterTableMsgRsp(SSqlObj *pSql) { STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0); - char* name = pTableMetaInfo->name; + char name[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, name); + tscDebug("%p remove tableMeta in hashMap after alter-table: %s", pSql, name); bool isSuperTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); @@ -2239,6 +2228,8 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) { SSqlRes *pRes = &pSql->res; SSqlCmd *pCmd = &pSql->cmd; + assert(pRes->rspLen >= sizeof(SRetrieveTableRsp)); + SRetrieveTableRsp *pRetrieve = (SRetrieveTableRsp *)pRes->pRsp; if (pRetrieve == NULL) { pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -2319,7 +2310,7 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn STableMetaInfo *pNewMeterMetaInfo = tscAddEmptyMetaInfo(pNewQueryInfo); assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1); - tstrncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, sizeof(pNewMeterMetaInfo->name)); + tNameAssign(&pNewMeterMetaInfo->name, &pTableMetaInfo->name); if (pSql->cmd.autoCreated) { int32_t code = copyTagData(&pNew->cmd.tagData, &pSql->cmd.tagData); @@ -2350,7 +2341,8 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn } int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) { - assert(strlen(pTableMetaInfo->name) != 0); + assert(tIsValidName(&pTableMetaInfo->name)); + tfree(pTableMetaInfo->pTableMeta); uint32_t size = tscGetTableMetaMaxSize(); @@ -2358,15 +2350,18 @@ int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) { pTableMetaInfo->pTableMeta->tableType = -1; pTableMetaInfo->pTableMeta->tableInfo.numOfColumns = -1; - int32_t len = (int32_t) strlen(pTableMetaInfo->name); - taosHashGetClone(tscTableMetaInfo, pTableMetaInfo->name, len, NULL, pTableMetaInfo->pTableMeta, -1); + char name[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, name); + + size_t len = strlen(name); + taosHashGetClone(tscTableMetaInfo, name, len, NULL, pTableMetaInfo->pTableMeta, -1); // TODO resize the tableMeta STableMeta* pMeta = pTableMetaInfo->pTableMeta; if (pMeta->id.uid > 0) { if (pMeta->tableType == TSDB_CHILD_TABLE) { - int32_t code = tscCreateTableMetaFromCChildMeta(pTableMetaInfo->pTableMeta, pTableMetaInfo->name); + int32_t code = tscCreateTableMetaFromCChildMeta(pTableMetaInfo->pTableMeta, name); if (code != TSDB_CODE_SUCCESS) { return getTableMetaFromMnode(pSql, pTableMetaInfo); } @@ -2394,16 +2389,24 @@ int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex); - const char* name = pTableMetaInfo->name; + + char name[TSDB_TABLE_FNAME_LEN] = {0}; + int32_t code = tNameExtractFullName(&pTableMetaInfo->name, name); + if (code != TSDB_CODE_SUCCESS) { + tscError("%p failed to generate the table full name", pSql); + return TSDB_CODE_TSC_INVALID_SQL; + } STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; if (pTableMeta) { tscDebug("%p update table meta:%s, old meta numOfTags:%d, numOfCols:%d, uid:%" PRId64, pSql, name, - tscGetNumOfTags(pTableMeta), tscGetNumOfColumns(pTableMeta), pTableMeta->id.uid); + tscGetNumOfTags(pTableMeta), tscGetNumOfColumns(pTableMeta), pTableMeta->id.uid); } // remove stored tableMeta info in hash table - taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN)); + size_t len = strlen(name); + taosHashRemove(tscTableMetaInfo, name, len); + return getTableMetaFromMnode(pSql, pTableMetaInfo); } @@ -2444,8 +2447,8 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, clauseIndex); for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { STableMetaInfo *pMInfo = tscGetMetaInfo(pQueryInfo, i); - STableMeta* pTableMeta = tscTableMetaClone(pMInfo->pTableMeta); - tscAddTableMetaInfo(pNewQueryInfo, pMInfo->name, pTableMeta, NULL, pMInfo->tagColList, pMInfo->pVgroupTables); + STableMeta* pTableMeta = tscTableMetaDup(pMInfo->pTableMeta); + tscAddTableMetaInfo(pNewQueryInfo, &pMInfo->name, pTableMeta, NULL, pMInfo->tagColList, pMInfo->pVgroupTables); } if ((code = tscAllocPayload(&pNew->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) != TSDB_CODE_SUCCESS) { @@ -2485,8 +2488,8 @@ void tscInitMsgsFp() { tscBuildMsg[TSDB_SQL_ALTER_ACCT] = tscBuildAcctMsg; tscBuildMsg[TSDB_SQL_CREATE_TABLE] = tscBuildCreateTableMsg; - tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropUserMsg; - tscBuildMsg[TSDB_SQL_DROP_ACCT] = tscBuildDropAcctMsg; + tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropUserAcctMsg; + tscBuildMsg[TSDB_SQL_DROP_ACCT] = tscBuildDropUserAcctMsg; tscBuildMsg[TSDB_SQL_DROP_DB] = tscBuildDropDbMsg; tscBuildMsg[TSDB_SQL_DROP_TABLE] = tscBuildDropTableMsg; tscBuildMsg[TSDB_SQL_ALTER_USER] = tscBuildUserMsg; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index a4f2976cad16e962b63ec5543243753cd092276a..6b4d9809454528cc0df29a4a7683aa4223e4d7c5 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -15,7 +15,7 @@ #include "hash.h" #include "os.h" -#include "qAst.h" +#include "texpr.h" #include "tkey.h" #include "tcache.h" #include "tnote.h" @@ -110,6 +110,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa rpcClose(pDnodeConn); free(pObj->tscCorMgmtEpSet); free(pObj); + return NULL; } memcpy(pObj->tscCorMgmtEpSet, &corMgmtEpSet, sizeof(SRpcCorEpSet)); @@ -936,7 +937,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) { static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t tblListLen) { // must before clean the sqlcmd object - tscResetSqlCmdObj(&pSql->cmd); + tscResetSqlCmd(&pSql->cmd, false); SSqlCmd *pCmd = &pSql->cmd; @@ -995,7 +996,8 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t return code; } - if (payloadLen + strlen(pTableMetaInfo->name) + 128 >= pCmd->allocSize) { + int32_t xlen = tNameLen(&pTableMetaInfo->name); + if (payloadLen + xlen + 128 >= pCmd->allocSize) { char *pNewMem = realloc(pCmd->payload, pCmd->allocSize + tblListLen); if (pNewMem == NULL) { code = TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -1008,7 +1010,9 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t pMsg = pCmd->payload; } - payloadLen += sprintf(pMsg + payloadLen, "%s,", pTableMetaInfo->name); + char n[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, n); + payloadLen += sprintf(pMsg + payloadLen, "%s,", n); } *(pMsg + payloadLen) = '\0'; diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index a39fbc94202d3c1940b8631c9f95a38381857946..d787f5b51545dd5c1fe43397d4e9086e4a806ef5 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -104,7 +104,7 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) { // failed to get table Meta or vgroup list, retry in 10sec. if (code == TSDB_CODE_SUCCESS) { tscTansformSQLFuncForSTableQuery(pQueryInfo); - tscDebug("%p stream:%p, start stream query on:%s", pSql, pStream, pTableMetaInfo->name); + tscDebug("%p stream:%p, start stream query on:%s", pSql, pStream, tNameGetTableName(&pTableMetaInfo->name)); pSql->fp = tscProcessStreamQueryCallback; pSql->fetchFp = tscProcessStreamQueryCallback; @@ -191,7 +191,9 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pStream->pSql->cmd, 0, 0); - char* name = pTableMetaInfo->name; + char name[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pTableMetaInfo->name, name); + taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN)); pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList); @@ -291,7 +293,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf pStream->stime += 1; } - tscDebug("%p stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql, pStream, pTableMetaInfo->name, + tscDebug("%p stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql, pStream, tNameGetTableName(&pTableMetaInfo->name), pStream->numOfRes); tfree(pTableMetaInfo->pTableMeta); @@ -556,7 +558,7 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) { taosTmrReset(tscProcessStreamTimer, (int32_t)starttime, pStream, tscTmr, &pStream->pTimer); tscDebug("%p stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql, - pStream, pTableMetaInfo->name, pStream->interval.interval, pStream->interval.sliding, starttime, pSql->sqlstr); + pStream, tNameGetTableName(&pTableMetaInfo->name), pStream->interval.interval, pStream->interval.sliding, starttime, pSql->sqlstr); } void tscSetStreamDestTable(SSqlStream* pStream, const char* dstTable) { diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 2622246111894caf39f3c1c37923d1a7207935b6..aacdf9103e0f127137b164f948bca3363c4fa7a1 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -16,7 +16,7 @@ #include "os.h" -#include "qAst.h" +#include "texpr.h" #include "qTsbuf.h" #include "tcompare.h" #include "tscLog.h" @@ -55,6 +55,58 @@ static void skipRemainValue(STSBuf* pTSBuf, tVariant* tag1) { } } +static void subquerySetState(SSqlObj *pSql, SSubqueryState *subState, int idx, int8_t state) { + assert(idx < subState->numOfSub); + assert(subState->states); + + pthread_mutex_lock(&subState->mutex); + + tscDebug("subquery:%p,%d state set to %d", pSql, idx, state); + + subState->states[idx] = state; + + pthread_mutex_unlock(&subState->mutex); +} + +static bool allSubqueryDone(SSqlObj *pParentSql) { + bool done = true; + SSubqueryState *subState = &pParentSql->subState; + + //lock in caller + + for (int i = 0; i < subState->numOfSub; i++) { + if (0 == subState->states[i]) { + tscDebug("%p subquery:%p,%d is NOT finished, total:%d", pParentSql, pParentSql->pSubs[i], i, subState->numOfSub); + done = false; + break; + } else { + tscDebug("%p subquery:%p,%d is finished, total:%d", pParentSql, pParentSql->pSubs[i], i, subState->numOfSub); + } + } + + return done; +} + +static bool subAndCheckDone(SSqlObj *pSql, SSqlObj *pParentSql, int idx) { + SSubqueryState *subState = &pParentSql->subState; + + assert(idx < subState->numOfSub); + + pthread_mutex_lock(&subState->mutex); + + tscDebug("%p subquery:%p,%d state set to 1", pParentSql, pSql, idx); + + subState->states[idx] = 1; + + bool done = allSubqueryDone(pParentSql); + + pthread_mutex_unlock(&subState->mutex); + + return done; +} + + + static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJoinSupporter* pSupporter2, STimeWindow * win) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); @@ -367,10 +419,6 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { // scan all subquery, if one sub query has only ts, ignore it tscDebug("%p start to launch secondary subqueries, %d out of %d needs to query", pSql, numOfSub, pSql->subState.numOfSub); - //the subqueries that do not actually launch the secondary query to virtual node is set as completed. - SSubqueryState* pState = &pSql->subState; - pState->numOfRemain = numOfSub; - bool success = true; for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { @@ -403,6 +451,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { success = false; break; } + tscClearSubqueryInfo(&pNew->cmd); pSql->pSubs[i] = pNew; @@ -480,10 +529,12 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { } } + subquerySetState(pPrevSub, &pSql->subState, i, 0); + size_t numOfCols = taosArrayGetSize(pQueryInfo->colList); tscDebug("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s", pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pQueryInfo->type, taosArrayGetSize(pQueryInfo->exprList), - numOfCols, pQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name); + numOfCols, pQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name)); } //prepare the subqueries object failed, abort @@ -517,20 +568,25 @@ void freeJoinSubqueryObj(SSqlObj* pSql) { SJoinSupporter* p = pSub->param; tscDestroyJoinSupporter(p); - if (pSub->res.code == TSDB_CODE_SUCCESS) { - taos_free_result(pSub); - } + taos_free_result(pSub); + pSql->pSubs[i] = NULL; } + if (pSql->subState.states) { + pthread_mutex_destroy(&pSql->subState.mutex); + } + + tfree(pSql->subState.states); + + pSql->subState.numOfSub = 0; } -static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) { - assert(pSqlObj->subState.numOfRemain > 0); - - if (atomic_sub_fetch_32(&pSqlObj->subState.numOfRemain, 1) <= 0) { - tscError("%p all subquery return and query failed, global code:%s", pSqlObj, tstrerror(pSqlObj->res.code)); +static void quitAllSubquery(SSqlObj* pSqlSub, SSqlObj* pSqlObj, SJoinSupporter* pSupporter) { + if (subAndCheckDone(pSqlSub, pSqlObj, pSupporter->subqueryIndex)) { + tscError("%p all subquery return and query failed, global code:%s", pSqlObj, tstrerror(pSqlObj->res.code)); freeJoinSubqueryObj(pSqlObj); + return; } //tscDestroyJoinSupporter(pSupporter); @@ -674,7 +730,7 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* "%p subquery:%p tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, ts_comp query to retrieve timestamps, " "numOfExpr:%" PRIzu ", colList:%" PRIzu ", numOfOutputFields:%d, name:%s", pParent, pSql, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pQueryInfo->type, - tscSqlExprNumOfExprs(pQueryInfo), numOfCols, pQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name); + tscSqlExprNumOfExprs(pQueryInfo), numOfCols, pQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name)); tscProcessSql(pSql); } @@ -777,6 +833,15 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); assert(TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY)); + if (pParentSql->res.code != TSDB_CODE_SUCCESS) { + tscError("%p abort query due to other subquery failure. code:%d, global code:%d", pSql, numOfRows, pParentSql->res.code); + quitAllSubquery(pSql, pParentSql, pSupporter); + + tscAsyncResultOnError(pParentSql); + + return; + } + // check for the error code firstly if (taos_errno(pSql) != TSDB_CODE_SUCCESS) { // todo retry if other subqueries are not failed @@ -785,7 +850,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow tscError("%p sub query failed, code:%s, index:%d", pSql, tstrerror(numOfRows), pSupporter->subqueryIndex); pParentSql->res.code = numOfRows; - quitAllSubquery(pParentSql, pSupporter); + quitAllSubquery(pSql, pParentSql, pSupporter); tscAsyncResultOnError(pParentSql); return; @@ -802,7 +867,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow tscError("%p failed to malloc memory", pSql); pParentSql->res.code = TAOS_SYSTEM_ERROR(errno); - quitAllSubquery(pParentSql, pSupporter); + quitAllSubquery(pSql, pParentSql, pSupporter); tscAsyncResultOnError(pParentSql); return; @@ -844,9 +909,10 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow // no data exists in next vnode, mark the query completed // only when there is no subquery exits any more, proceeds to get the intersect of the tuple sets. - if (atomic_sub_fetch_32(&pParentSql->subState.numOfRemain, 1) > 0) { + if (!subAndCheckDone(pSql, pParentSql, pSupporter->subqueryIndex)) { + tscDebug("%p tagRetrieve:%p,%d completed, total:%d", pParentSql, tres, pSupporter->subqueryIndex, pParentSql->subState.numOfSub); return; - } + } SArray *s1 = NULL, *s2 = NULL; int32_t code = getIntersectionOfTableTuple(pQueryInfo, pParentSql, &s1, &s2); @@ -885,14 +951,16 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow tscBuildVgroupTableInfo(pParentSql, pTableMetaInfo2, s2); SSqlObj* psub1 = pParentSql->pSubs[0]; - ((SJoinSupporter*)psub1->param)->pVgroupTables = tscVgroupTableInfoClone(pTableMetaInfo1->pVgroupTables); + ((SJoinSupporter*)psub1->param)->pVgroupTables = tscVgroupTableInfoDup(pTableMetaInfo1->pVgroupTables); SSqlObj* psub2 = pParentSql->pSubs[1]; - ((SJoinSupporter*)psub2->param)->pVgroupTables = tscVgroupTableInfoClone(pTableMetaInfo2->pVgroupTables); + ((SJoinSupporter*)psub2->param)->pVgroupTables = tscVgroupTableInfoDup(pTableMetaInfo2->pVgroupTables); pParentSql->subState.numOfSub = 2; - pParentSql->subState.numOfRemain = pParentSql->subState.numOfSub; - + + memset(pParentSql->subState.states, 0, sizeof(pParentSql->subState.states[0]) * pParentSql->subState.numOfSub); + tscDebug("%p reset all sub states to 0", pParentSql); + for (int32_t m = 0; m < pParentSql->subState.numOfSub; ++m) { SSqlObj* sub = pParentSql->pSubs[m]; issueTSCompQuery(sub, sub->param, pParentSql); @@ -915,6 +983,15 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); assert(!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)); + if (pParentSql->res.code != TSDB_CODE_SUCCESS) { + tscError("%p abort query due to other subquery failure. code:%d, global code:%d", pSql, numOfRows, pParentSql->res.code); + quitAllSubquery(pSql, pParentSql, pSupporter); + + tscAsyncResultOnError(pParentSql); + + return; + } + // check for the error code firstly if (taos_errno(pSql) != TSDB_CODE_SUCCESS) { // todo retry if other subqueries are not failed yet @@ -922,7 +999,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow tscError("%p sub query failed, code:%s, index:%d", pSql, tstrerror(numOfRows), pSupporter->subqueryIndex); pParentSql->res.code = numOfRows; - quitAllSubquery(pParentSql, pSupporter); + quitAllSubquery(pSql, pParentSql, pSupporter); tscAsyncResultOnError(pParentSql); return; @@ -937,7 +1014,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow pParentSql->res.code = TAOS_SYSTEM_ERROR(errno); - quitAllSubquery(pParentSql, pSupporter); + quitAllSubquery(pSql, pParentSql, pSupporter); tscAsyncResultOnError(pParentSql); @@ -955,7 +1032,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow pParentSql->res.code = TAOS_SYSTEM_ERROR(errno); - quitAllSubquery(pParentSql, pSupporter); + quitAllSubquery(pSql, pParentSql, pSupporter); tscAsyncResultOnError(pParentSql); @@ -1009,9 +1086,9 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow return; } - if (atomic_sub_fetch_32(&pParentSql->subState.numOfRemain, 1) > 0) { + if (!subAndCheckDone(pSql, pParentSql, pSupporter->subqueryIndex)) { return; - } + } tscDebug("%p all subquery retrieve ts complete, do ts block intersect", pParentSql); @@ -1049,6 +1126,17 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR SSqlRes* pRes = &pSql->res; SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); + + if (pParentSql->res.code != TSDB_CODE_SUCCESS) { + tscError("%p abort query due to other subquery failure. code:%d, global code:%d", pSql, numOfRows, pParentSql->res.code); + quitAllSubquery(pSql, pParentSql, pSupporter); + + tscAsyncResultOnError(pParentSql); + + return; + } + + if (taos_errno(pSql) != TSDB_CODE_SUCCESS) { assert(numOfRows == taos_errno(pSql)); @@ -1088,9 +1176,8 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR } } - assert(pState->numOfRemain > 0); - if (atomic_sub_fetch_32(&pState->numOfRemain, 1) > 0) { - tscDebug("%p sub:%p completed, remain:%d, total:%d", pParentSql, tres, pState->numOfRemain, pState->numOfSub); + if (!subAndCheckDone(pSql, pParentSql, pSupporter->subqueryIndex)) { + tscDebug("%p sub:%p,%d completed, total:%d", pParentSql, tres, pSupporter->subqueryIndex, pState->numOfSub); return; } @@ -1205,15 +1292,16 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) { } } - // get the number of subquery that need to retrieve the next vnode. + if (orderedPrjQuery) { for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSub = pSql->pSubs[i]; if (pSub != NULL && pSub->res.row >= pSub->res.numOfRows && pSub->res.completed) { - pSql->subState.numOfRemain++; + subquerySetState(pSub, &pSql->subState, i, 0); } } } + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSub = pSql->pSubs[i]; @@ -1270,7 +1358,19 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) { // retrieve data from current vnode. tscDebug("%p retrieve data from %d subqueries", pSql, numOfFetch); SJoinSupporter* pSupporter = NULL; - pSql->subState.numOfRemain = numOfFetch; + + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { + SSqlObj* pSql1 = pSql->pSubs[i]; + if (pSql1 == NULL) { + continue; + } + + SSqlRes* pRes1 = &pSql1->res; + + if (pRes1->row >= pRes1->numOfRows) { + subquerySetState(pSql1, &pSql->subState, i, 0); + } + } for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSql1 = pSql->pSubs[i]; @@ -1372,7 +1472,8 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) { // retrieve actual query results from vnode during the second stage join subquery if (pParentSql->res.code != TSDB_CODE_SUCCESS) { tscError("%p abort query due to other subquery failure. code:%d, global code:%d", pSql, code, pParentSql->res.code); - quitAllSubquery(pParentSql, pSupporter); + quitAllSubquery(pSql, pParentSql, pSupporter); + tscAsyncResultOnError(pParentSql); return; @@ -1384,7 +1485,8 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) { tscError("%p abort query, code:%s, global code:%s", pSql, tstrerror(code), tstrerror(pParentSql->res.code)); pParentSql->res.code = code; - quitAllSubquery(pParentSql, pSupporter); + + quitAllSubquery(pSql, pParentSql, pSupporter); tscAsyncResultOnError(pParentSql); return; @@ -1408,9 +1510,9 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) { // In case of consequence query from other vnode, do not wait for other query response here. if (!(pTableMetaInfo->vgroupIndex > 0 && tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0))) { - if (atomic_sub_fetch_32(&pParentSql->subState.numOfRemain, 1) > 0) { + if (!subAndCheckDone(pSql, pParentSql, pSupporter->subqueryIndex)) { return; - } + } } tscSetupOutputColumnIndex(pParentSql); @@ -1422,6 +1524,7 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) { if (pTableMetaInfo->vgroupIndex > 0 && tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0)) { pSql->fp = joinRetrieveFinalResCallback; // continue retrieve data pSql->cmd.command = TSDB_SQL_FETCH; + tscProcessSql(pSql); } else { // first retrieve from vnode during the secondary stage sub-query // set the command flag must be after the semaphore been correctly set. @@ -1457,8 +1560,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter return TSDB_CODE_TSC_OUT_OF_MEMORY; } - pSql->pSubs[pSql->subState.numOfRemain++] = pNew; - assert(pSql->subState.numOfRemain <= pSql->subState.numOfSub); + pSql->pSubs[tableIndex] = pNew; if (QUERY_IS_JOIN_QUERY(pQueryInfo->type)) { addGroupInfoForSubquery(pSql, pNew, 0, tableIndex); @@ -1534,7 +1636,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter "%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, transfer to tid_tag query to retrieve (tableId, tags), " "exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, tagIndex:%d, name:%s", pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo), - numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, colIndex.columnIndex, pNewQueryInfo->pTableMetaInfo[0]->name); + numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, colIndex.columnIndex, tNameGetTableName(&pNewQueryInfo->pTableMetaInfo[0]->name)); } else { SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1}; SColumnIndex colIndex = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX}; @@ -1569,7 +1671,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter "%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%u, transfer to ts_comp query to retrieve timestamps, " "exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s", pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo), - numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, pNewQueryInfo->pTableMetaInfo[0]->name); + numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pNewQueryInfo->pTableMetaInfo[0]->name)); } } else { assert(0); @@ -1590,6 +1692,19 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) { int32_t code = TSDB_CODE_SUCCESS; pSql->subState.numOfSub = pQueryInfo->numOfTables; + if (pSql->subState.states == NULL) { + pSql->subState.states = calloc(pSql->subState.numOfSub, sizeof(*pSql->subState.states)); + if (pSql->subState.states == NULL) { + code = TSDB_CODE_TSC_OUT_OF_MEMORY; + goto _error; + } + + pthread_mutex_init(&pSql->subState.mutex, NULL); + } + + memset(pSql->subState.states, 0, sizeof(*pSql->subState.states) * pSql->subState.numOfSub); + tscDebug("%p reset all sub states to 0", pSql); + bool hasEmptySub = false; tscDebug("%p start subquery, total:%d", pSql, pQueryInfo->numOfTables); @@ -1622,14 +1737,25 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) { pSql->cmd.command = TSDB_SQL_RETRIEVE_EMPTY_RESULT; (*pSql->fp)(pSql->param, pSql, 0); } else { + int fail = 0; for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSub = pSql->pSubs[i]; + if (fail) { + (*pSub->fp)(pSub->param, pSub, 0); + continue; + } + if ((code = tscProcessSql(pSub)) != TSDB_CODE_SUCCESS) { - pSql->subState.numOfRemain = i - 1; // the already sent request will continue and do not go to the error process routine - break; + pRes->code = code; + (*pSub->fp)(pSub->param, pSub, 0); + fail = 1; } } + if(fail) { + return; + } + pSql->cmd.command = TSDB_SQL_TABLE_JOIN_RETRIEVE; } @@ -1728,7 +1854,21 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { return ret; } - pState->numOfRemain = pState->numOfSub; + if (pState->states == NULL) { + pState->states = calloc(pState->numOfSub, sizeof(*pState->states)); + if (pState->states == NULL) { + pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscAsyncResultOnError(pSql); + tfree(pMemoryBuf); + return ret; + } + + pthread_mutex_init(&pState->mutex, NULL); + } + + memset(pState->states, 0, sizeof(*pState->states) * pState->numOfSub); + tscDebug("%p reset all sub states to 0", pSql); + pRes->code = TSDB_CODE_SUCCESS; int32_t i = 0; @@ -1877,7 +2017,6 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO assert(pSql != NULL); SSubqueryState* pState = &pParentSql->subState; - assert(pState->numOfRemain <= pState->numOfSub && pState->numOfRemain >= 0); // retrieved in subquery failed. OR query cancelled in retrieve phase. if (taos_errno(pSql) == TSDB_CODE_SUCCESS && pParentSql->res.code != TSDB_CODE_SUCCESS) { @@ -1908,14 +2047,12 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO } } - int32_t remain = -1; - if ((remain = atomic_sub_fetch_32(&pState->numOfRemain, 1)) > 0) { - tscDebug("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pParentSql, pSql, trsupport->subqueryIndex, - pState->numOfSub - remain); + if (!subAndCheckDone(pSql, pParentSql, subqueryIndex)) { + tscDebug("%p sub:%p,%d freed, not finished, total:%d", pParentSql, pSql, trsupport->subqueryIndex, pState->numOfSub); tscFreeRetrieveSup(pSql); return; - } + } // all subqueries are failed tscError("%p retrieve from %d vnode(s) completed,code:%s.FAILED.", pParentSql, pState->numOfSub, @@ -1980,14 +2117,12 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p return; } - int32_t remain = -1; - if ((remain = atomic_sub_fetch_32(&pParentSql->subState.numOfRemain, 1)) > 0) { - tscDebug("%p sub:%p orderOfSub:%d freed, finished subqueries:%d", pParentSql, pSql, trsupport->subqueryIndex, - pState->numOfSub - remain); + if (!subAndCheckDone(pSql, pParentSql, idx)) { + tscDebug("%p sub:%p orderOfSub:%d freed, not finished", pParentSql, pSql, trsupport->subqueryIndex); tscFreeRetrieveSup(pSql); return; - } + } // all sub-queries are returned, start to local merge process pDesc->pColumnModel->capacity = trsupport->pExtMemBuffer[idx]->numOfElemsPerPage; @@ -1998,7 +2133,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p SQueryInfo *pPQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, 0); tscClearInterpInfo(pPQueryInfo); - tscCreateLocalReducer(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, trsupport->pFinalColModel, trsupport->pFFColModel, pParentSql); + tscCreateLocalMerger(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, trsupport->pFinalColModel, trsupport->pFFColModel, pParentSql); tscDebug("%p build loser tree completed", pParentSql); pParentSql->res.precision = pSql->res.precision; @@ -2033,7 +2168,6 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR SSqlObj * pParentSql = trsupport->pParentSql; SSubqueryState* pState = &pParentSql->subState; - assert(pState->numOfRemain <= pState->numOfSub && pState->numOfRemain >= 0); STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0); SVgroupInfo *pVgroup = &pTableMetaInfo->vgroupList->vgroups[0]; @@ -2254,7 +2388,8 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) } } - if (atomic_sub_fetch_32(&pParentObj->subState.numOfRemain, 1) > 0) { + if (!subAndCheckDone(tres, pParentObj, pSupporter->index)) { + tscDebug("%p insert:%p,%d completed, total:%d", pParentObj, tres, pSupporter->index, pParentObj->subState.numOfSub); return; } @@ -2286,7 +2421,9 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) tscFreeQueryInfo(&pSql->cmd); SQueryInfo* pQueryInfo = tscGetQueryInfoDetailSafely(&pSql->cmd, 0); STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pParentObj->cmd, pSql->cmd.clauseIndex, 0); - tscAddTableMetaInfo(pQueryInfo, pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL); + tscAddTableMetaInfo(pQueryInfo, &pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL); + + subquerySetState(pSql, &pParentObj->subState, i, 0); tscDebug("%p, failed sub:%d, %p", pParentObj, i, pSql); } @@ -2297,14 +2434,14 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) tscDebug("%p cleanup %d tableMeta in hashTable", pParentObj, pParentObj->cmd.numOfTables); for(int32_t i = 0; i < pParentObj->cmd.numOfTables; ++i) { - char* name = pParentObj->cmd.pTableNameList[i]; + char name[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(pParentObj->cmd.pTableNameList[i], name); taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN)); } pParentObj->cmd.parseFinished = false; - pParentObj->subState.numOfRemain = numOfFailed; - tscResetSqlCmdObj(&pParentObj->cmd); + tscResetSqlCmd(&pParentObj->cmd, false); // in case of insert, redo parsing the sql string and build new submit data block for two reasons: // 1. the table Id(tid & uid) may have been update, the submit block needs to be updated accordingly. @@ -2378,7 +2515,19 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { // the number of already initialized subqueries int32_t numOfSub = 0; - pSql->subState.numOfRemain = pSql->subState.numOfSub; + if (pSql->subState.states == NULL) { + pSql->subState.states = calloc(pSql->subState.numOfSub, sizeof(*pSql->subState.states)); + if (pSql->subState.states == NULL) { + pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; + goto _error; + } + + pthread_mutex_init(&pSql->subState.mutex, NULL); + } + + memset(pSql->subState.states, 0, sizeof(*pSql->subState.states) * pSql->subState.numOfSub); + tscDebug("%p reset all sub states to 0", pSql); + pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES); if (pSql->pSubs == NULL) { goto _error; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 005d83bf2c7ea569bed25058cf2f97faec909fa7..d580eccca82e536f25184abf8b2e350be0c07662 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -16,7 +16,7 @@ #include "tscUtil.h" #include "hash.h" #include "os.h" -#include "qAst.h" +#include "texpr.h" #include "taosmsg.h" #include "tkey.h" #include "tmd5.h" @@ -89,21 +89,6 @@ bool tscQueryTags(SQueryInfo* pQueryInfo) { return true; } -// todo refactor, extract methods and move the common module -void tscGetDBInfoFromTableFullName(char* tableId, char* db) { - char* st = strstr(tableId, TS_PATH_DELIMITER); - if (st != NULL) { - char* end = strstr(st + 1, TS_PATH_DELIMITER); - if (end != NULL) { - memcpy(db, tableId, (end - tableId)); - db[end - tableId] = 0; - return; - } - } - - db[0] = 0; -} - bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) { if (pQueryInfo == NULL) { return false; @@ -396,7 +381,7 @@ void tscFreeQueryInfo(SSqlCmd* pCmd) { tfree(pCmd->pQueryInfo); } -void tscResetSqlCmdObj(SSqlCmd* pCmd) { +void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) { pCmd->command = 0; pCmd->numOfCols = 0; pCmd->count = 0; @@ -414,13 +399,13 @@ void tscResetSqlCmdObj(SSqlCmd* pCmd) { pCmd->numOfTables = 0; tfree(pCmd->pTableNameList); - pCmd->pTableBlockHashList = tscDestroyBlockHashTable(pCmd->pTableBlockHashList); + pCmd->pTableBlockHashList = tscDestroyBlockHashTable(pCmd->pTableBlockHashList, removeMeta); pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks); tscFreeQueryInfo(pCmd); } void tscFreeSqlResult(SSqlObj* pSql) { - tscDestroyLocalReducer(pSql); + tscDestroyLocalMerger(pSql); SSqlRes* pRes = &pSql->res; tscDestroyResPointerInfo(pRes); @@ -441,6 +426,12 @@ static void tscFreeSubobj(SSqlObj* pSql) { pSql->pSubs[i] = NULL; } + if (pSql->subState.states) { + pthread_mutex_destroy(&pSql->subState.mutex); + } + + tfree(pSql->subState.states); + pSql->subState.numOfSub = 0; } @@ -510,7 +501,7 @@ void tscFreeSqlObj(SSqlObj* pSql) { pSql->self = 0; tscFreeSqlResult(pSql); - tscResetSqlCmdObj(pCmd); + tscResetSqlCmd(pCmd, false); tfree(pCmd->tagData.data); pCmd->tagData.dataLen = 0; @@ -524,7 +515,7 @@ void tscFreeSqlObj(SSqlObj* pSql) { free(pSql); } -void tscDestroyDataBlock(STableDataBlocks* pDataBlock) { +void tscDestroyDataBlock(STableDataBlocks* pDataBlock, bool removeMeta) { if (pDataBlock == NULL) { return; } @@ -537,6 +528,13 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) { tfree(pDataBlock->pTableMeta); } + if (removeMeta) { + char name[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&pDataBlock->tableName, name); + + taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN)); + } + tfree(pDataBlock); } @@ -572,21 +570,21 @@ void* tscDestroyBlockArrayList(SArray* pDataBlockList) { size_t size = taosArrayGetSize(pDataBlockList); for (int32_t i = 0; i < size; i++) { void* d = taosArrayGetP(pDataBlockList, i); - tscDestroyDataBlock(d); + tscDestroyDataBlock(d, false); } taosArrayDestroy(pDataBlockList); return NULL; } -void* tscDestroyBlockHashTable(SHashObj* pBlockHashTable) { +void* tscDestroyBlockHashTable(SHashObj* pBlockHashTable, bool removeMeta) { if (pBlockHashTable == NULL) { return NULL; } STableDataBlocks** p = taosHashIterate(pBlockHashTable, NULL); while(p) { - tscDestroyDataBlock(*p); + tscDestroyDataBlock(*p, removeMeta); p = taosHashIterate(pBlockHashTable, p); } @@ -606,15 +604,13 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) { // todo refactor // set the correct table meta object, the table meta has been locked in pDataBlocks, so it must be in the cache if (pTableMetaInfo->pTableMeta != pDataBlock->pTableMeta) { - tstrncpy(pTableMetaInfo->name, pDataBlock->tableName, sizeof(pTableMetaInfo->name)); + tNameAssign(&pTableMetaInfo->name, &pDataBlock->tableName); if (pTableMetaInfo->pTableMeta != NULL) { tfree(pTableMetaInfo->pTableMeta); } - pTableMetaInfo->pTableMeta = tscTableMetaClone(pDataBlock->pTableMeta); - } else { - assert(strncmp(pTableMetaInfo->name, pDataBlock->tableName, tListLen(pDataBlock->tableName)) == 0); + pTableMetaInfo->pTableMeta = tscTableMetaDup(pDataBlock->pTableMeta); } /* @@ -649,7 +645,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) { * @param dataBlocks * @return */ -int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, const char* name, +int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, SName* name, STableMeta* pTableMeta, STableDataBlocks** dataBlocks) { STableDataBlocks* dataBuf = (STableDataBlocks*)calloc(1, sizeof(STableDataBlocks)); if (dataBuf == NULL) { @@ -677,18 +673,18 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff dataBuf->size = startOffset; dataBuf->tsSource = -1; - tstrncpy(dataBuf->tableName, name, sizeof(dataBuf->tableName)); + tNameAssign(&dataBuf->tableName, name); //Here we keep the tableMeta to avoid it to be remove by other threads. - dataBuf->pTableMeta = tscTableMetaClone(pTableMeta); + dataBuf->pTableMeta = tscTableMetaDup(pTableMeta); assert(initialSize > 0 && pTableMeta != NULL && dataBuf->pTableMeta != NULL); *dataBlocks = dataBuf; return TSDB_CODE_SUCCESS; } -int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize, const char* tableId, STableMeta* pTableMeta, - STableDataBlocks** dataBlocks, SArray* pBlockList) { +int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize, + SName* name, STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList) { *dataBlocks = NULL; STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pHashList, (const char*)&id, sizeof(id)); if (t1 != NULL) { @@ -696,7 +692,7 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i } if (*dataBlocks == NULL) { - int32_t ret = tscCreateDataBlock((size_t)size, rowSize, startOffset, tableId, pTableMeta, dataBlocks); + int32_t ret = tscCreateDataBlock((size_t)size, rowSize, startOffset, name, pTableMeta, dataBlocks); if (ret != TSDB_CODE_SUCCESS) { return ret; } @@ -797,12 +793,12 @@ static void extractTableNameList(SSqlCmd* pCmd, bool freeBlockMap) { int32_t i = 0; while(p1) { STableDataBlocks* pBlocks = *p1; - pCmd->pTableNameList[i++] = strndup(pBlocks->tableName, TSDB_TABLE_FNAME_LEN); + pCmd->pTableNameList[i++] = tNameDup(&pBlocks->tableName); p1 = taosHashIterate(pCmd->pTableBlockHashList, p1); } if (freeBlockMap) { - pCmd->pTableBlockHashList = tscDestroyBlockHashTable(pCmd->pTableBlockHashList); + pCmd->pTableBlockHashList = tscDestroyBlockHashTable(pCmd->pTableBlockHashList, false); } } @@ -822,7 +818,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) { STableDataBlocks* dataBuf = NULL; int32_t ret = tscGetDataBlockFromList(pVnodeDataBlockHashList, pOneTableBlock->vgId, TSDB_PAYLOAD_SIZE, - INSERT_HEAD_SIZE, 0, pOneTableBlock->tableName, pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList); + INSERT_HEAD_SIZE, 0, &pOneTableBlock->tableName, pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList); if (ret != TSDB_CODE_SUCCESS) { tscError("%p failed to prepare the data block buffer for merging table data, code:%d", pSql, ret); taosHashCleanup(pVnodeDataBlockHashList); @@ -855,8 +851,8 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) { tscSortRemoveDataBlockDupRows(pOneTableBlock); char* ekey = (char*)pBlocks->data + pOneTableBlock->rowSize*(pBlocks->numOfRows-1); - - tscDebug("%p name:%s, sid:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql, pOneTableBlock->tableName, + + tscDebug("%p name:%s, name:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql, tNameGetTableName(&pOneTableBlock->tableName), pBlocks->tid, pBlocks->numOfRows, pBlocks->sversion, GET_INT64_VAL(pBlocks->data), GET_INT64_VAL(ekey)); int32_t len = pBlocks->numOfRows * (pOneTableBlock->rowSize + expandSize) + sizeof(STColumn) * tscGetNumOfColumns(pOneTableBlock->pTableMeta); @@ -1058,7 +1054,7 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) { SInternalField* pInfo = taosArrayGet(pFieldInfo->internalField, i); if (pInfo->pArithExprInfo != NULL) { - tExprTreeDestroy(&pInfo->pArithExprInfo->pExpr, NULL); + tExprTreeDestroy(pInfo->pArithExprInfo->pExpr, NULL); SSqlFuncMsg* pFuncMsg = &pInfo->pArithExprInfo->base; for(int32_t j = 0; j < pFuncMsg->numOfParams; ++j) { @@ -1306,7 +1302,7 @@ SColumn* tscColumnClone(const SColumn* src) { dst->colIndex = src->colIndex; dst->numOfFilters = src->numOfFilters; - dst->filterInfo = tscFilterInfoClone(src->filterInfo, src->numOfFilters); + dst->filterInfo = tFilterInfoDup(src->filterInfo, src->numOfFilters); return dst; } @@ -1812,10 +1808,10 @@ void tscVgroupTableCopy(SVgroupTableInfo* info, SVgroupTableInfo* pInfo) { info->vgInfo.epAddr[j].fqdn = strdup(pInfo->vgInfo.epAddr[j].fqdn); } - info->itemList = taosArrayClone(pInfo->itemList); + info->itemList = taosArrayDup(pInfo->itemList); } -SArray* tscVgroupTableInfoClone(SArray* pVgroupTables) { +SArray* tscVgroupTableInfoDup(SArray* pVgroupTables) { if (pVgroupTables == NULL) { return NULL; } @@ -1846,7 +1842,7 @@ void clearAllTableMetaInfo(SQueryInfo* pQueryInfo) { tfree(pQueryInfo->pTableMetaInfo); } -STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta, +STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, SName* name, STableMeta* pTableMeta, SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables) { void* pAlloc = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES); if (pAlloc == NULL) { @@ -1864,7 +1860,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST pQueryInfo->pTableMetaInfo[pQueryInfo->numOfTables] = pTableMetaInfo; if (name != NULL) { - tstrncpy(pTableMetaInfo->name, name, sizeof(pTableMetaInfo->name)); + tNameAssign(&pTableMetaInfo->name, name); } pTableMetaInfo->pTableMeta = pTableMeta; @@ -1883,7 +1879,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, -1); } - pTableMetaInfo->pVgroupTables = tscVgroupTableInfoClone(pVgroupTables); + pTableMetaInfo->pVgroupTables = tscVgroupTableInfoDup(pVgroupTables); pQueryInfo->numOfTables += 1; return pTableMetaInfo; @@ -1961,7 +1957,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, __async_cb_func_t fp, void* param, in assert(pSql->cmd.clauseIndex == 0); STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0); - tscAddTableMetaInfo(pQueryInfo, pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL); + tscAddTableMetaInfo(pQueryInfo, &pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL); registerSqlObj(pNew); return pNew; @@ -2066,7 +2062,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr; if (pQueryInfo->groupbyExpr.columnInfo != NULL) { - pNewQueryInfo->groupbyExpr.columnInfo = taosArrayClone(pQueryInfo->groupbyExpr.columnInfo); + pNewQueryInfo->groupbyExpr.columnInfo = taosArrayDup(pQueryInfo->groupbyExpr.columnInfo); if (pNewQueryInfo->groupbyExpr.columnInfo == NULL) { terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; goto _error; @@ -2117,27 +2113,26 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t pNew->param = param; pNew->maxRetry = TSDB_MAX_REPLICA; - char* name = pTableMetaInfo->name; STableMetaInfo* pFinalInfo = NULL; if (pPrevSql == NULL) { - STableMeta* pTableMeta = tscTableMetaClone(pTableMetaInfo->pTableMeta); + STableMeta* pTableMeta = tscTableMetaDup(pTableMetaInfo->pTableMeta); assert(pTableMeta != NULL); - pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, name, pTableMeta, pTableMetaInfo->vgroupList, + pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, &pTableMetaInfo->name, pTableMeta, pTableMetaInfo->vgroupList, pTableMetaInfo->tagColList, pTableMetaInfo->pVgroupTables); } else { // transfer the ownership of pTableMeta to the newly create sql object. STableMetaInfo* pPrevInfo = tscGetTableMetaInfoFromCmd(&pPrevSql->cmd, pPrevSql->cmd.clauseIndex, 0); - STableMeta* pPrevTableMeta = tscTableMetaClone(pPrevInfo->pTableMeta); + STableMeta* pPrevTableMeta = tscTableMetaDup(pPrevInfo->pTableMeta); SVgroupsInfo* pVgroupsInfo = pPrevInfo->vgroupList; - pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, name, pPrevTableMeta, pVgroupsInfo, pTableMetaInfo->tagColList, + pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, &pTableMetaInfo->name, pPrevTableMeta, pVgroupsInfo, pTableMetaInfo->tagColList, pTableMetaInfo->pVgroupTables); } // this case cannot be happened if (pFinalInfo->pTableMeta == NULL) { - tscError("%p new subquery failed since no tableMeta, name:%s", pSql, name); + tscError("%p new subquery failed since no tableMeta, name:%s", pSql, tNameGetTableName(&pTableMetaInfo->name)); if (pPrevSql != NULL) { // pass the previous error to client assert(pPrevSql->res.code != TSDB_CODE_SUCCESS); @@ -2162,7 +2157,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t "%p new subquery:%p, tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu "," "fieldInfo:%d, name:%s, qrang:%" PRId64 " - %" PRId64 " order:%d, limit:%" PRId64, pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo), - size, pNewQueryInfo->fieldsInfo.numOfOutput, pFinalInfo->name, pNewQueryInfo->window.skey, + size, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pFinalInfo->name), pNewQueryInfo->window.skey, pNewQueryInfo->window.ekey, pNewQueryInfo->order.order, pNewQueryInfo->limit.limit); tscPrintSelectClause(pNew, 0); @@ -2199,7 +2194,7 @@ void tscDoQuery(SSqlObj* pSql) { } if (pCmd->dataSourceType == DATA_FROM_DATA_FILE) { - tscProcessMultiVnodesImportFromFile(pSql); + tscImportDataFromFile(pSql); } else { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); uint16_t type = pQueryInfo->type; @@ -2299,7 +2294,6 @@ int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* s } return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; - } int32_t tscInvalidSQLErrMsg(char* msg, const char* additionalInfo, const char* sql) { @@ -2697,7 +2691,7 @@ uint32_t tscGetTableMetaMaxSize() { return sizeof(STableMeta) + TSDB_MAX_COLUMNS * sizeof(SSchema); } -STableMeta* tscTableMetaClone(STableMeta* pTableMeta) { +STableMeta* tscTableMetaDup(STableMeta* pTableMeta) { assert(pTableMeta != NULL); uint32_t size = tscGetTableMetaSize(pTableMeta); STableMeta* p = calloc(1, size); diff --git a/src/query/inc/qArithmeticOperator.h b/src/common/inc/tarithoperator.h similarity index 100% rename from src/query/inc/qArithmeticOperator.h rename to src/common/inc/tarithoperator.h diff --git a/src/query/inc/qAst.h b/src/common/inc/texpr.h similarity index 83% rename from src/query/inc/qAst.h rename to src/common/inc/texpr.h index 39af7261efc222c8a6bcfc809288c256eccb0970..acfbffc01e400f8b111ee92b7651bb048c112bd2 100644 --- a/src/query/inc/qAst.h +++ b/src/common/inc/texpr.h @@ -31,6 +31,15 @@ extern "C" { struct tExprNode; struct SSchema; +#define QUERY_COND_REL_PREFIX_IN "IN|" +#define QUERY_COND_REL_PREFIX_LIKE "LIKE|" + +#define QUERY_COND_REL_PREFIX_IN_LEN 3 +#define QUERY_COND_REL_PREFIX_LIKE_LEN 5 + +typedef bool (*__result_filter_fn_t)(const void *, void *); +typedef void (*__do_filter_suppl_fn_t)(void *, void *); + enum { TSQL_NODE_DUMMY = 0x0, TSQL_NODE_EXPR = 0x1, @@ -38,9 +47,6 @@ enum { TSQL_NODE_VALUE = 0x4, }; -typedef bool (*__result_filter_fn_t)(const void *, void *); -typedef void (*__do_filter_suppl_fn_t)(void *, void *); - /** * this structure is used to filter data in tags, so the offset of filtered tag column in tagdata string is required */ @@ -52,12 +58,6 @@ typedef struct tQueryInfo { bool indexed; // indexed columns } tQueryInfo; -typedef struct SExprTraverseSupp { - __result_filter_fn_t nodeFilterFn; - __do_filter_suppl_fn_t setupInfoFn; - void * pExtInfo; -} SExprTraverseSupp; - typedef struct tExprNode { uint8_t nodeType; union { @@ -65,7 +65,7 @@ typedef struct tExprNode { uint8_t optr; // filter operator uint8_t hasPK; // 0: do not contain primary filter, 1: contain void * info; // support filter operation on this expression only available for leaf node - + struct tExprNode *pLeft; // left child pointer struct tExprNode *pRight; // right child pointer } _node; @@ -74,19 +74,27 @@ typedef struct tExprNode { }; } tExprNode; -void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, void *param, int32_t order, - char *(*cb)(void *, const char*, int32_t)); +typedef struct SExprTraverseSupp { + __result_filter_fn_t nodeFilterFn; + __do_filter_suppl_fn_t setupInfoFn; + void * pExtInfo; +} SExprTraverseSupp; + +void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)); tExprNode* exprTreeFromBinary(const void* data, size_t size); tExprNode* exprTreeFromTableName(const char* tbnameCond); void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); -void tExprNodeDestroy(tExprNode *pNode, void (*fp)(void *)); -void tExprTreeDestroy(tExprNode **pExprs, void (*fp)(void*)); - bool exprTreeApplayFilter(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *param); +typedef void (*_arithmetic_operator_fn_t)(void *left, int32_t numLeft, int32_t leftType, void *right, int32_t numRight, + int32_t rightType, void *output, int32_t order); + +void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, void *param, int32_t order, + char *(*cb)(void *, const char*, int32_t)); + #ifdef __cplusplus } #endif diff --git a/src/common/inc/tname.h b/src/common/inc/tname.h index 6631d4e450f7841e3dea73ecd43973ad9904cc50..892d682756ceaef9cd4d27f5abf6b00f0b08c31b 100644 --- a/src/common/inc/tname.h +++ b/src/common/inc/tname.h @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + #ifndef TDENGINE_NAME_H #define TDENGINE_NAME_H @@ -21,6 +36,20 @@ typedef struct SColumnInfoData { void* pData; // the corresponding block data in memory } SColumnInfoData; +#define TSDB_DB_NAME_T 1 +#define TSDB_TABLE_NAME_T 2 + +#define T_NAME_ACCT 0x1u +#define T_NAME_DB 0x2u +#define T_NAME_TABLE 0x4u + +typedef struct SName { + uint8_t type; //db_name_t, table_name_t + char acctId[TSDB_ACCT_ID_LEN]; + char dbname[TSDB_DB_NAME_LEN]; + char tname[TSDB_TABLE_NAME_LEN]; +} SName; + void extractTableName(const char *tableId, char *name); char* extractDBName(const char *tableId, char *name); @@ -37,9 +66,9 @@ SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, SStrToken* exprStr, const bool tscValidateTableNameLength(size_t len); -SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters); +SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters); -SSchema tscGetTbnameColumnSchema(); +SSchema tGetTbnameColumnSchema(); /** * check if the schema is valid or not, including following aspects: @@ -53,6 +82,28 @@ SSchema tscGetTbnameColumnSchema(); * @param numOfCols * @return */ -bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags); +bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags); + +int32_t tNameExtractFullName(const SName* name, char* dst); +int32_t tNameLen(const SName* name); + +SName* tNameDup(const SName* name); + +bool tIsValidName(const SName* name); + +const char* tNameGetTableName(const SName* name); + +int32_t tNameGetDbName(const SName* name, char* dst); +int32_t tNameGetFullDbName(const SName* name, char* dst); + +bool tNameIsEmpty(const SName* name); + +void tNameAssign(SName* dst, const SName* src); + +int32_t tNameFromString(SName* dst, const char* str, uint32_t type); + +int32_t tNameSetAcctId(SName* dst, const char* acct); + +int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken); #endif // TDENGINE_NAME_H diff --git a/src/query/src/qArithmeticOperator.c b/src/common/src/tarithoperator.c similarity index 99% rename from src/query/src/qArithmeticOperator.c rename to src/common/src/tarithoperator.c index 677951bd07ba5c61e9e1078dbe94eb692a4a218c..1cb667d259f040cfab0656562f7c97444fc48d8a 100644 --- a/src/query/src/qArithmeticOperator.c +++ b/src/common/src/tarithoperator.c @@ -15,9 +15,9 @@ #include "os.h" -#include "qArithmeticOperator.h" #include "ttype.h" #include "tutil.h" +#include "tarithoperator.h" #define ARRAY_LIST_OP(left, right, _left_type, _right_type, len1, len2, out, op, _res_type, _ord) \ { \ diff --git a/src/query/src/qAst.c b/src/common/src/texpr.c similarity index 96% rename from src/query/src/qAst.c rename to src/common/src/texpr.c index 1e6dbe8e3dd52c98896c02954b2208c1cfcf7a50..f941fc45019dd5b267348de2a4fc1792638164e0 100644 --- a/src/query/src/qAst.c +++ b/src/common/src/texpr.c @@ -16,18 +16,15 @@ #include "os.h" #include "exception.h" -#include "qArithmeticOperator.h" -#include "qAst.h" #include "taosdef.h" #include "taosmsg.h" #include "tarray.h" #include "tbuffer.h" #include "tcompare.h" -#include "tname.h" -#include "tschemautil.h" #include "tsdb.h" #include "tskiplist.h" -#include "tsqlfunction.h" +#include "texpr.h" +#include "tarithoperator.h" static uint8_t UNUSED_FUNC isQueryOnPrimaryKey(const char *primaryColumnName, const tExprNode *pLeft, const tExprNode *pRight) { if (pLeft->nodeType == TSQL_NODE_COL) { @@ -102,13 +99,15 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf } } -void tExprNodeDestroy(tExprNode *pNode, void (*fp)(void *)) { +static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)); + +void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)) { if (pNode == NULL) { return; } if (pNode->nodeType == TSQL_NODE_EXPR) { - tExprTreeDestroy(&pNode, fp); + doExprTreeDestroy(&pNode, fp); } else if (pNode->nodeType == TSQL_NODE_VALUE) { tVariantDestroy(pNode->pVal); } else if (pNode->nodeType == TSQL_NODE_COL) { @@ -118,14 +117,14 @@ void tExprNodeDestroy(tExprNode *pNode, void (*fp)(void *)) { free(pNode); } -void tExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) { +static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) { if (*pExpr == NULL) { return; } if ((*pExpr)->nodeType == TSQL_NODE_EXPR) { - tExprTreeDestroy(&(*pExpr)->_node.pLeft, fp); - tExprTreeDestroy(&(*pExpr)->_node.pRight, fp); + doExprTreeDestroy(&(*pExpr)->_node.pLeft, fp); + doExprTreeDestroy(&(*pExpr)->_node.pRight, fp); if (fp != NULL) { fp((*pExpr)->_node.info); @@ -270,8 +269,9 @@ void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, } } - free(pLeftOutput); - free(pRightOutput); + tfree(pdata); + tfree(pLeftOutput); + tfree(pRightOutput); } static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { @@ -342,7 +342,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { } tExprNode* pExpr = exception_calloc(1, sizeof(tExprNode)); - CLEANUP_PUSH_VOID_PTR_PTR(true, tExprNodeDestroy, pExpr, NULL); + CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, pExpr, NULL); pExpr->nodeType = tbufReadUint8(br); if (pExpr->nodeType == TSQL_NODE_VALUE) { @@ -396,7 +396,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) { int32_t anchor = CLEANUP_GET_ANCHOR(); tExprNode* expr = exception_calloc(1, sizeof(tExprNode)); - CLEANUP_PUSH_VOID_PTR_PTR(true, tExprNodeDestroy, expr, NULL); + CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, expr, NULL); expr->nodeType = TSQL_NODE_EXPR; @@ -407,7 +407,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) { SSchema* pSchema = exception_calloc(1, sizeof(SSchema)); left->pSchema = pSchema; - *pSchema = tscGetTbnameColumnSchema(); + *pSchema = tGetTbnameColumnSchema(); tExprNode* right = exception_calloc(1, sizeof(tExprNode)); expr->_node.pRight = right; diff --git a/src/common/src/tname.c b/src/common/src/tname.c index 31d473866a9022c5003bd8ce4e4c537cfed51f99..178ed09123e43b960faa3516cc3e9761dae1fcd3 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -3,31 +3,12 @@ #include "tname.h" #include "tstoken.h" -#include "ttokendef.h" #include "tvariant.h" -#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS) - +#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS) #define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS) -// todo refactor -UNUSED_FUNC static FORCE_INLINE const char* skipSegments(const char* input, char delim, int32_t num) { - for (int32_t i = 0; i < num; ++i) { - while (*input != 0 && *input++ != delim) { - }; - } - return input; -} - -UNUSED_FUNC static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) { - size_t len = 0; - while (*src != delimiter && *src != 0) { - *dst++ = *src++; - len++; - } - - return len; -} +#define VALID_NAME_TYPE(x) ((x) == TSDB_DB_NAME_T || (x) == TSDB_TABLE_NAME_T) void extractTableName(const char* tableId, char* name) { size_t s1 = strcspn(tableId, &TS_PATH_DELIMITER[0]); @@ -93,7 +74,7 @@ bool tscValidateTableNameLength(size_t len) { return len < TSDB_TABLE_NAME_LEN; } -SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters) { +SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters) { if (numOfFilters == 0) { assert(src == NULL); return NULL; @@ -208,7 +189,7 @@ void extractTableNameFromToken(SStrToken* pToken, SStrToken* pTable) { } } -SSchema tscGetTbnameColumnSchema() { +SSchema tGetTbnameColumnSchema() { struct SSchema s = { .colId = TSDB_TBNAME_COLUMN_INDEX, .type = TSDB_DATA_TYPE_BINARY, @@ -256,7 +237,7 @@ static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen return rowLen <= maxLen; } -bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags) { +bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags) { if (!VALIDNUMOFCOLS(numOfCols)) { return false; } @@ -280,3 +261,184 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags return true; } + +int32_t tNameExtractFullName(const SName* name, char* dst) { + assert(name != NULL && dst != NULL); + + // invalid full name format, abort + if (!tIsValidName(name)) { + return -1; + } + + int32_t len = snprintf(dst, TSDB_ACCT_ID_LEN + 1 + TSDB_DB_NAME_LEN, "%s.%s", name->acctId, name->dbname); + + size_t tnameLen = strlen(name->tname); + if (tnameLen > 0) { + assert(name->type == TSDB_TABLE_NAME_T); + dst[len] = TS_PATH_DELIMITER[0]; + + memcpy(dst + len + 1, name->tname, tnameLen); + dst[len + tnameLen + 1] = 0; + } + + return 0; +} + +int32_t tNameLen(const SName* name) { + assert(name != NULL); + int32_t len = (int32_t) strlen(name->acctId); + int32_t len1 = (int32_t) strlen(name->dbname); + int32_t len2 = (int32_t) strlen(name->tname); + + if (name->type == TSDB_DB_NAME_T) { + assert(len2 == 0); + return len + len1 + TS_PATH_DELIMITER_LEN; + } else { + assert(len2 > 0); + return len + len1 + len2 + TS_PATH_DELIMITER_LEN * 2; + } +} + +bool tIsValidName(const SName* name) { + assert(name != NULL); + + if (!VALID_NAME_TYPE(name->type)) { + return false; + } + + if (strlen(name->acctId) <= 0) { + return false; + } + + if (name->type == TSDB_DB_NAME_T) { + return strlen(name->dbname) > 0; + } else { + return strlen(name->dbname) > 0 && strlen(name->tname) > 0; + } +} + +SName* tNameDup(const SName* name) { + assert(name != NULL); + + SName* p = calloc(1, sizeof(SName)); + memcpy(p, name, sizeof(SName)); + return p; +} + +int32_t tNameGetDbName(const SName* name, char* dst) { + assert(name != NULL && dst != NULL); + strncpy(dst, name->dbname, tListLen(name->dbname)); + return 0; +} + +int32_t tNameGetFullDbName(const SName* name, char* dst) { + assert(name != NULL && dst != NULL); + snprintf(dst, TSDB_ACCT_ID_LEN + TS_PATH_DELIMITER_LEN + TSDB_DB_NAME_LEN, + "%s.%s", name->acctId, name->dbname); + return 0; +} + +bool tNameIsEmpty(const SName* name) { + assert(name != NULL); + return name->type == 0 || strlen(name->acctId) <= 0; +} + +const char* tNameGetTableName(const SName* name) { + assert(name != NULL && name->type == TSDB_TABLE_NAME_T); + return &name->tname[0]; +} + +void tNameAssign(SName* dst, const SName* src) { + memcpy(dst, src, sizeof(SName)); +} + +int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken) { + assert(dst != NULL && dbToken != NULL && acct != NULL); + + // too long account id or too long db name + if (strlen(acct) >= tListLen(dst->acctId) || dbToken->n >= tListLen(dst->dbname)) { + return -1; + } + + dst->type = TSDB_DB_NAME_T; + tstrncpy(dst->acctId, acct, tListLen(dst->acctId)); + tstrncpy(dst->dbname, dbToken->z, dbToken->n + 1); + return 0; +} + +int32_t tNameSetAcctId(SName* dst, const char* acct) { + assert(dst != NULL && acct != NULL); + + // too long account id or too long db name + if (strlen(acct) >= tListLen(dst->acctId)) { + return -1; + } + + tstrncpy(dst->acctId, acct, tListLen(dst->acctId)); + + assert(strlen(dst->acctId) > 0); + + return 0; +} + +int32_t tNameFromString(SName* dst, const char* str, uint32_t type) { + assert(dst != NULL && str != NULL && strlen(str) > 0); + + char* p = NULL; + if ((type & T_NAME_ACCT) == T_NAME_ACCT) { + p = strstr(str, TS_PATH_DELIMITER); + if (p == NULL) { + return -1; + } + + int32_t len = (int32_t)(p - str); + + // too long account id or too long db name + if ((len >= tListLen(dst->acctId)) || (len <= 0)) { + return -1; + } + + memcpy (dst->acctId, str, len); + dst->acctId[len] = 0; + + assert(strlen(dst->acctId) > 0); + } + + if ((type & T_NAME_DB) == T_NAME_DB) { + dst->type = TSDB_DB_NAME_T; + char* start = (char*)((p == NULL)? str:(p+1)); + + int32_t len = 0; + p = strstr(start, TS_PATH_DELIMITER); + if (p == NULL) { + len = (int32_t) strlen(start); + } else { + len = (int32_t) (p - start); + } + + // too long account id or too long db name + if ((len >= tListLen(dst->dbname)) || (len <= 0)) { + return -1; + } + + memcpy (dst->dbname, start, len); + dst->dbname[len] = 0; + } + + if ((type & T_NAME_TABLE) == T_NAME_TABLE) { + dst->type = TSDB_TABLE_NAME_T; + char* start = (char*) ((p == NULL)? str: (p+1)); + + int32_t len = (int32_t) strlen(start); + + // too long account id or too long db name + if ((len >= tListLen(dst->tname)) || (len <= 0)) { + return -1; + } + + memcpy (dst->tname, start, len); + dst->tname[len] = 0; + } + + return 0; +} diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt index 7097e9bc5add0b944e1df1911972422cdcbd1c58..b64161e2e4fd6fc00abb659118cfdcd50dfcf0a8 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.16-dist.jar ${LIBRARY_OUTPUT_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.17-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 5aa60c0df9311a18d5c849f125b24f6764579bdd..1f03c3c6fe5e1d5f1d7d12a0df7babb6edb789f1 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.16 + 2.0.17 jar JDBCDriver diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index d18d86258a41ef4420863eddc47c20b24407f49a..6be0ca036e797decb668c42a81eeaafb91d52787 100755 --- 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.16 + 2.0.17 jar JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc @@ -74,6 +74,14 @@ 1.2.58 + + + org.apache.commons + commons-dbcp2 + 2.7.0 + + + diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java index 8ab0e4429a89ac15447786f89afbec0c61503ed9..08414d05e9f8b03582ac1257e6c460c05522f57e 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDatabaseMetaData.java @@ -1,28 +1,13 @@ -/*************************************************************************** - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ package com.taosdata.jdbc; import java.sql.*; import java.util.ArrayList; import java.util.List; -public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { +public abstract class AbstractDatabaseMetaData implements DatabaseMetaData, Wrapper { private final static String PRODUCT_NAME = "TDengine"; private final static String PRODUCT_VESION = "2.0.x.x"; - private final static String DRIVER_NAME = "taos-jdbcdriver"; private final static String DRIVER_VERSION = "2.0.x"; private final static int DRIVER_MAJAR_VERSION = 2; private final static int DRIVER_MINOR_VERSION = 0; @@ -67,9 +52,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { return PRODUCT_VESION; } - public String getDriverName() throws SQLException { - return DRIVER_NAME; - } + public abstract String getDriverName() throws SQLException; public String getDriverVersion() throws SQLException { return DRIVER_VERSION; @@ -92,6 +75,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { } public boolean supportsMixedCaseIdentifiers() throws SQLException { + //像database、table这些对象的标识符,在存储时是否采用大小写混合的模式 return false; } @@ -100,7 +84,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { } public boolean storesLowerCaseIdentifiers() throws SQLException { - return false; + return true; } public boolean storesMixedCaseIdentifiers() throws SQLException { @@ -168,10 +152,12 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { } public boolean nullPlusNonNullIsNull() throws SQLException { + // null + non-null != null return false; } public boolean supportsConvert() throws SQLException { + // 是否支持转换函数convert return false; } @@ -196,7 +182,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { } public boolean supportsGroupBy() throws SQLException { - return false; + return true; } public boolean supportsGroupByUnrelated() throws SQLException { @@ -468,7 +454,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { } public int getDefaultTransactionIsolation() throws SQLException { - return 0; + return Connection.TRANSACTION_NONE; } public boolean supportsTransactions() throws SQLException { @@ -476,6 +462,8 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { } public boolean supportsTransactionIsolationLevel(int level) throws SQLException { + if (level == Connection.TRANSACTION_NONE) + return true; return false; } @@ -495,18 +483,113 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { return false; } - public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) - throws SQLException { + public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException { return null; } - public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, - String columnNamePattern) throws SQLException { + public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException { return null; } - public abstract ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) - throws SQLException; + public abstract ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException; + + protected ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types, Connection connection) throws SQLException { + try (Statement stmt = connection.createStatement()) { + if (catalog == null || catalog.isEmpty()) + return null; + + ResultSet databases = stmt.executeQuery("show databases"); + String dbname = null; + while (databases.next()) { + dbname = databases.getString("name"); + if (dbname.equalsIgnoreCase(catalog)) + break; + } + databases.close(); + if (dbname == null) + return null; + + stmt.execute("use " + dbname); + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + List columnMetaDataList = new ArrayList<>(); + ColumnMetaData col1 = new ColumnMetaData(); + col1.setColIndex(1); + col1.setColName("TABLE_CAT"); + col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col1); + ColumnMetaData col2 = new ColumnMetaData(); + col2.setColIndex(2); + col2.setColName("TABLE_SCHEM"); + col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col2); + ColumnMetaData col3 = new ColumnMetaData(); + col3.setColIndex(3); + col3.setColName("TABLE_NAME"); + col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col3); + ColumnMetaData col4 = new ColumnMetaData(); + col4.setColIndex(4); + col4.setColName("TABLE_TYPE"); + col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col4); + ColumnMetaData col5 = new ColumnMetaData(); + col5.setColIndex(5); + col5.setColName("REMARKS"); + col5.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col5); + ColumnMetaData col6 = new ColumnMetaData(); + col6.setColIndex(6); + col6.setColName("TYPE_CAT"); + col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col6); + ColumnMetaData col7 = new ColumnMetaData(); + col7.setColIndex(7); + col7.setColName("TYPE_SCHEM"); + col7.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col7); + ColumnMetaData col8 = new ColumnMetaData(); + col8.setColIndex(8); + col8.setColName("TYPE_NAME"); + col8.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col8); + ColumnMetaData col9 = new ColumnMetaData(); + col9.setColIndex(9); + col9.setColName("SELF_REFERENCING_COL_NAME"); + col9.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col9); + ColumnMetaData col10 = new ColumnMetaData(); + col10.setColIndex(10); + col10.setColName("REF_GENERATION"); + col10.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col10); + resultSet.setColumnMetaDataList(columnMetaDataList); + + List rowDataList = new ArrayList<>(); + ResultSet tables = stmt.executeQuery("show tables"); + while (tables.next()) { + TSDBResultSetRowData rowData = new TSDBResultSetRowData(10); + rowData.setString(0, dbname); //table_cat + rowData.setString(1, null); //TABLE_SCHEM + rowData.setString(2, tables.getString("table_name")); //TABLE_NAME + rowData.setString(3, "TABLE"); //TABLE_TYPE + rowData.setString(4, ""); //REMARKS + rowDataList.add(rowData); + } + + ResultSet stables = stmt.executeQuery("show stables"); + while (stables.next()) { + TSDBResultSetRowData rowData = new TSDBResultSetRowData(10); + rowData.setString(0, dbname); //TABLE_CAT + rowData.setString(1, null); //TABLE_SCHEM + rowData.setString(2, stables.getString("name")); //TABLE_NAME + rowData.setString(3, "TABLE"); //TABLE_TYPE + rowData.setString(4, "STABLE"); //REMARKS + rowDataList.add(rowData); + } + resultSet.setRowDataList(rowDataList); + return resultSet; + } + } public ResultSet getSchemas() throws SQLException { return getEmptyResultSet(); @@ -516,32 +599,239 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { public ResultSet getTableTypes() throws SQLException { DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); - // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList(1); + List columnMetaDataList = new ArrayList<>(); ColumnMetaData colMetaData = new ColumnMetaData(); colMetaData.setColIndex(0); colMetaData.setColName("TABLE_TYPE"); colMetaData.setColSize(10); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); + colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); columnMetaDataList.add(colMetaData); + resultSet.setColumnMetaDataList(columnMetaDataList); // set up rowDataList - List rowDataList = new ArrayList(2); - TSDBResultSetRowData rowData = new TSDBResultSetRowData(); + List rowDataList = new ArrayList<>(); + TSDBResultSetRowData rowData = new TSDBResultSetRowData(1); rowData.setString(0, "TABLE"); rowDataList.add(rowData); - rowData = new TSDBResultSetRowData(); + rowData = new TSDBResultSetRowData(1); rowData.setString(0, "STABLE"); rowDataList.add(rowData); - - resultSet.setColumnMetaDataList(columnMetaDataList); resultSet.setRowDataList(rowDataList); + return resultSet; } public abstract ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException; + protected ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern, Connection conn) { + try (Statement stmt = conn.createStatement()) { + if (catalog == null || catalog.isEmpty()) + return null; + + ResultSet databases = stmt.executeQuery("show databases"); + String dbname = null; + while (databases.next()) { + dbname = databases.getString("name"); + if (dbname.equalsIgnoreCase(catalog)) + break; + } + databases.close(); + if (dbname == null) + return null; + + stmt.execute("use " + dbname); + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + // set up ColumnMetaDataList + + List columnMetaDataList = new ArrayList<>(); + // TABLE_CAT + ColumnMetaData col1 = new ColumnMetaData(); + col1.setColIndex(1); + col1.setColName("TABLE_CAT"); + col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col1); + // TABLE_SCHEM + ColumnMetaData col2 = new ColumnMetaData(); + col2.setColIndex(2); + col2.setColName("TABLE_SCHEM"); + col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col2); + // TABLE_NAME + ColumnMetaData col3 = new ColumnMetaData(); + col3.setColIndex(3); + col3.setColName("TABLE_NAME"); + col3.setColSize(193); + col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col3); + // COLUMN_NAME + ColumnMetaData col4 = new ColumnMetaData(); + col4.setColIndex(4); + col4.setColName("COLUMN_NAME"); + col4.setColSize(65); + col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col4); + // DATA_TYPE + ColumnMetaData col5 = new ColumnMetaData(); + col5.setColIndex(5); + col5.setColName("DATA_TYPE"); + col5.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col5); + // TYPE_NAME + ColumnMetaData col6 = new ColumnMetaData(); + col6.setColIndex(6); + col6.setColName("TYPE_NAME"); + col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col6); + // COLUMN_SIZE + ColumnMetaData col7 = new ColumnMetaData(); + col7.setColIndex(7); + col7.setColName("COLUMN_SIZE"); + col7.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col7); + // BUFFER_LENGTH, not used + ColumnMetaData col8 = new ColumnMetaData(); + col8.setColIndex(8); + col8.setColName("BUFFER_LENGTH"); + columnMetaDataList.add(col8); + // DECIMAL_DIGITS + ColumnMetaData col9 = new ColumnMetaData(); + col9.setColIndex(9); + col9.setColName("DECIMAL_DIGITS"); + col9.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col9); + // add NUM_PREC_RADIX + ColumnMetaData col10 = new ColumnMetaData(); + col10.setColIndex(10); + col10.setColName("NUM_PREC_RADIX"); + col10.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col10); + // NULLABLE + ColumnMetaData col11 = new ColumnMetaData(); + col11.setColIndex(11); + col11.setColName("NULLABLE"); + col11.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col11); + // REMARKS + ColumnMetaData col12 = new ColumnMetaData(); + col12.setColIndex(12); + col12.setColName("REMARKS"); + col12.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col12); + // COLUMN_DEF + ColumnMetaData col13 = new ColumnMetaData(); + col13.setColIndex(13); + col13.setColName("COLUMN_DEF"); + col13.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col13); + //SQL_DATA_TYPE + ColumnMetaData col14 = new ColumnMetaData(); + col14.setColIndex(14); + col14.setColName("SQL_DATA_TYPE"); + col14.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col14); + //SQL_DATETIME_SUB + ColumnMetaData col15 = new ColumnMetaData(); + col15.setColIndex(15); + col15.setColName("SQL_DATETIME_SUB"); + col15.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col15); + //CHAR_OCTET_LENGTH + ColumnMetaData col16 = new ColumnMetaData(); + col16.setColIndex(16); + col16.setColName("CHAR_OCTET_LENGTH"); + col16.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col16); + //ORDINAL_POSITION + ColumnMetaData col17 = new ColumnMetaData(); + col17.setColIndex(17); + col17.setColName("ORDINAL_POSITION"); + col17.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col17); + // IS_NULLABLE + ColumnMetaData col18 = new ColumnMetaData(); + col18.setColIndex(18); + col18.setColName("IS_NULLABLE"); + col18.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col18); + //SCOPE_CATALOG + ColumnMetaData col19 = new ColumnMetaData(); + col19.setColIndex(19); + col19.setColName("SCOPE_CATALOG"); + col19.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col19); + //SCOPE_SCHEMA + ColumnMetaData col20 = new ColumnMetaData(); + col20.setColIndex(20); + col20.setColName("SCOPE_SCHEMA"); + col20.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col20); + //SCOPE_TABLE + ColumnMetaData col21 = new ColumnMetaData(); + col21.setColIndex(21); + col21.setColName("SCOPE_TABLE"); + col21.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col21); + //SOURCE_DATA_TYPE + ColumnMetaData col22 = new ColumnMetaData(); + col22.setColIndex(22); + col22.setColName("SOURCE_DATA_TYPE"); + col22.setColType(TSDBConstants.TSDB_DATA_TYPE_SMALLINT); + columnMetaDataList.add(col22); + //IS_AUTOINCREMENT + ColumnMetaData col23 = new ColumnMetaData(); + col23.setColIndex(23); + col23.setColName("IS_AUTOINCREMENT"); + col23.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col23); + //IS_GENERATEDCOLUMN + ColumnMetaData col24 = new ColumnMetaData(); + col24.setColIndex(24); + col24.setColName("IS_GENERATEDCOLUMN"); + col24.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col24); + + resultSet.setColumnMetaDataList(columnMetaDataList); + // set up rowDataList + ResultSet rs = stmt.executeQuery("describe " + dbname + "." + tableNamePattern); + List rowDataList = new ArrayList<>(); + int index = 0; + while (rs.next()) { + TSDBResultSetRowData rowData = new TSDBResultSetRowData(24); + // set TABLE_CAT + rowData.setString(0, dbname); + // set TABLE_NAME + rowData.setString(2, tableNamePattern); + // set COLUMN_NAME + rowData.setString(3, rs.getString("Field")); + // set DATA_TYPE + String typeName = rs.getString("Type"); + rowData.setInt(4, getDataType(typeName)); + // set TYPE_NAME + rowData.setString(5, typeName); + // set COLUMN_SIZE + int length = rs.getInt("Length"); + rowData.setInt(6, getColumnSize(typeName, length)); + // set DECIMAL_DIGITS + rowData.setInt(8, getDecimalDigits(typeName)); + // set NUM_PREC_RADIX + rowData.setInt(9, 10); + // set NULLABLE + rowData.setInt(10, getNullable(index, typeName)); + // set REMARKS + rowData.setString(11, rs.getString("Note")); + rowDataList.add(rowData); + index++; + } + resultSet.setRowDataList(rowDataList); + return resultSet; + + } catch (SQLException e) { + e.printStackTrace(); + } + return null; + } + protected int getNullable(int index, String typeName) { if (index == 0 && "TIMESTAMP".equals(typeName)) return DatabaseMetaData.columnNoNulls; @@ -552,7 +842,6 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { switch (typeName) { case "TIMESTAMP": return 23; - default: return 0; } @@ -615,9 +904,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { return getEmptyResultSet(); } - public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { - return getEmptyResultSet(); - } + public abstract ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException; public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException { return getEmptyResultSet(); @@ -718,9 +1005,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { return getEmptyResultSet(); } - public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { - return getEmptyResultSet(); - } + public abstract ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException; public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException { @@ -728,15 +1013,17 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { } public boolean supportsResultSetHoldability(int holdability) throws SQLException { + if (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT) + return true; return false; } public int getResultSetHoldability() throws SQLException { - return 0; + return ResultSet.HOLD_CURSORS_OVER_COMMIT; } public int getDatabaseMajorVersion() throws SQLException { - return 0; + return 2; } public int getDatabaseMinorVersion() throws SQLException { @@ -744,7 +1031,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { } public int getJDBCMajorVersion() throws SQLException { - return 0; + return 2; } public int getJDBCMinorVersion() throws SQLException { @@ -768,7 +1055,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { } public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { - return null; + return getEmptyResultSet(); } public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { @@ -805,4 +1092,180 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData { private ResultSet getEmptyResultSet() { return new EmptyResultSet(); } + + @Override + public T unwrap(Class iface) throws SQLException { + try { + return iface.cast(this); + } catch (ClassCastException cce) { + throw new SQLException("Unable to unwrap to " + iface.toString()); + } + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return iface.isInstance(this); + } + + protected ResultSet getCatalogs(Connection conn) throws SQLException { + try (Statement stmt = conn.createStatement()) { + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + // set up ColumnMetaDataList + List columnMetaDataList = new ArrayList<>(); + // TABLE_CAT + ColumnMetaData col1 = new ColumnMetaData(); + col1.setColIndex(1); + col1.setColName("TABLE_CAT"); + col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col1); + + resultSet.setColumnMetaDataList(columnMetaDataList); + + List rowDataList = new ArrayList<>(); + ResultSet rs = stmt.executeQuery("show databases"); + while (rs.next()) { + TSDBResultSetRowData rowData = new TSDBResultSetRowData(1); + rowData.setString(0, rs.getString("name")); + rowDataList.add(rowData); + } + resultSet.setRowDataList(rowDataList); + return resultSet; + } + } + + + protected ResultSet getPrimaryKeys(String catalog, String schema, String table, Connection conn) throws SQLException { + try (Statement stmt = conn.createStatement()) { + if (catalog == null || catalog.isEmpty()) + return null; + + ResultSet databases = stmt.executeQuery("show databases"); + String dbname = null; + while (databases.next()) { + dbname = databases.getString("name"); + if (dbname.equalsIgnoreCase(catalog)) + break; + } + databases.close(); + if (dbname == null) + return null; + + stmt.execute("use " + dbname); + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + // set up ColumnMetaDataList + List columnMetaDataList = new ArrayList<>(); + // TABLE_CAT + ColumnMetaData col1 = new ColumnMetaData(); + col1.setColIndex(0); + col1.setColName("TABLE_CAT"); + col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col1); + // TABLE_SCHEM + ColumnMetaData col2 = new ColumnMetaData(); + col2.setColIndex(1); + col2.setColName("TABLE_SCHEM"); + col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col2); + // TABLE_NAME + ColumnMetaData col3 = new ColumnMetaData(); + col3.setColIndex(2); + col3.setColName("TABLE_NAME"); + col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col3); + // COLUMN_NAME + ColumnMetaData col4 = new ColumnMetaData(); + col4.setColIndex(3); + col4.setColName("COLUMN_NAME"); + col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col4); + // KEY_SEQ + ColumnMetaData col5 = new ColumnMetaData(); + col5.setColIndex(4); + col5.setColName("KEY_SEQ"); + col5.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); + columnMetaDataList.add(col5); + // PK_NAME + ColumnMetaData col6 = new ColumnMetaData(); + col6.setColIndex(5); + col6.setColName("PK_NAME"); + col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col6); + resultSet.setColumnMetaDataList(columnMetaDataList); + + // set rowData + List rowDataList = new ArrayList<>(); + ResultSet rs = stmt.executeQuery("describe " + dbname + "." + table); + rs.next(); + TSDBResultSetRowData rowData = new TSDBResultSetRowData(6); + rowData.setString(0, null); + rowData.setString(1, null); + rowData.setString(2, table); + String pkName = rs.getString(1); + rowData.setString(3, pkName); + rowData.setInt(4, 1); + rowData.setString(5, pkName); + rowDataList.add(rowData); + resultSet.setRowDataList(rowDataList); + return resultSet; + } + } + + protected ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern, Connection conn) throws SQLException { + try (Statement stmt = conn.createStatement()) { + if (catalog == null || catalog.isEmpty()) + return null; + + ResultSet databases = stmt.executeQuery("show databases"); + String dbname = null; + while (databases.next()) { + dbname = databases.getString("name"); + if (dbname.equalsIgnoreCase(catalog)) + break; + } + databases.close(); + if (dbname == null) + return null; + + stmt.execute("use " + dbname); + DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); + // set up ColumnMetaDataList + List columnMetaDataList = new ArrayList<>(); + // TABLE_CAT + ColumnMetaData col1 = new ColumnMetaData(); + col1.setColIndex(0); + col1.setColName("TABLE_CAT"); + col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col1); + // TABLE_SCHEM + ColumnMetaData col2 = new ColumnMetaData(); + col2.setColIndex(1); + col2.setColName("TABLE_SCHEM"); + col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col2); + // TABLE_NAME + ColumnMetaData col3 = new ColumnMetaData(); + col3.setColIndex(2); + col3.setColName("TABLE_NAME"); + col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col3); + // SUPERTABLE_NAME + ColumnMetaData col4 = new ColumnMetaData(); + col4.setColIndex(3); + col4.setColName("SUPERTABLE_NAME"); + col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR); + columnMetaDataList.add(col4); + resultSet.setColumnMetaDataList(columnMetaDataList); + + ResultSet rs = stmt.executeQuery("show tables like '" + tableNamePattern + "'"); + List rowDataList = new ArrayList<>(); + while (rs.next()) { + TSDBResultSetRowData rowData = new TSDBResultSetRowData(4); + rowData.setString(2, rs.getString(1)); + rowData.setString(3, rs.getString(4)); + rowDataList.add(rowData); + } + resultSet.setRowDataList(rowDataList); + return resultSet; + } + } } \ No newline at end of file diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java deleted file mode 100644 index 3a01e2e09297d6af1405c63200e2ba91b3fa99a2..0000000000000000000000000000000000000000 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/CatalogResultSet.java +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ -package com.taosdata.jdbc; - -import java.sql.ResultSet; -import java.sql.SQLException; - -/* - * TDengine only supports a subset of the standard SQL, thus this implemetation of the - * standard JDBC API contains more or less some adjustments customized for certain - * compatibility needs. - */ -public class CatalogResultSet extends TSDBResultSetWrapper { - - - public CatalogResultSet(ResultSet resultSet) { - super.setOriginalResultSet(resultSet); - } - - @Override - public String getString(int columnIndex) throws SQLException { - if (columnIndex <= 1) { - return super.getString(columnIndex); - } else { - return null; - } - } - - @Override - public boolean getBoolean(int columnIndex) throws SQLException { - if (columnIndex <= 1) { - return super.getBoolean(columnIndex); - } else { - return false; - } - } - - @Override - public byte[] getBytes(int columnIndex) throws SQLException { - if (columnIndex <= 1) { - return super.getBytes(columnIndex); - } else { - return null; - } - } - - @Override - public Object getObject(int columnIndex) throws SQLException { - if (columnIndex <= 1) { - return super.getObject(columnIndex); - } else { - return null; - } - } - -} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java index 633fdcd5ab7c9f077abbd725c2511bcc2251db44..fe16aa653546f4033bd944f0b6c72aec1863ab8a 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/ColumnMetaData.java @@ -16,40 +16,40 @@ package com.taosdata.jdbc; public class ColumnMetaData { - private int colType = 0; - private String colName = null; - private int colSize = -1; - private int colIndex = 0; - - public int getColSize() { - return colSize; - } - - public void setColSize(int colSize) { - this.colSize = colSize; - } - - public int getColType() { - return colType; - } - - public void setColType(int colType) { - this.colType = colType; - } - - public String getColName() { - return colName; - } - - public void setColName(String colName) { - this.colName = colName; - } - - public int getColIndex() { - return colIndex; - } - - public void setColIndex(int colIndex) { - this.colIndex = colIndex; - } + private int colType = 0; + private String colName = null; + private int colSize = -1; + private int colIndex = 0; + + public int getColSize() { + return colSize; + } + + public void setColSize(int colSize) { + this.colSize = colSize; + } + + public int getColType() { + return colType; + } + + public void setColType(int colType) { + this.colType = colType; + } + + public String getColName() { + return colName; + } + + public void setColName(String colName) { + this.colName = colName; + } + + public int getColIndex() { + return colIndex; + } + + public void setColIndex(int colIndex) { + this.colIndex = colIndex; + } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetColumnsResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetColumnsResultSet.java deleted file mode 100644 index e15415e037948dd7ec757bcdeee03d14a0d588fb..0000000000000000000000000000000000000000 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetColumnsResultSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ -package com.taosdata.jdbc; - -import java.sql.ResultSet; - -/* - * TDengine only supports a subset of the standard SQL, thus this implemetation of the - * standard JDBC API contains more or less some adjustments customized for certain - * compatibility needs. - */ -public class GetColumnsResultSet extends TSDBResultSetWrapper { - private String catalog; - private String schemaPattern; - private String tableNamePattern; - private String columnNamePattern; - - public GetColumnsResultSet(ResultSet resultSet, String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) { - super.setOriginalResultSet(resultSet); - this.catalog = catalog; - this.schemaPattern = schemaPattern; - this.tableNamePattern = tableNamePattern; - this.columnNamePattern = columnNamePattern; - } - - @Override - public String getString(int columnIndex) { - switch (columnIndex) { - case 1: - return catalog; - case 2: - return null; - case 3: - return tableNamePattern; - default: - return null; - } - } -} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetTablesResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetTablesResultSet.java deleted file mode 100644 index e28f6e3c9adf8564437e1214b28b2eb13bdaf8d9..0000000000000000000000000000000000000000 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/GetTablesResultSet.java +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ -package com.taosdata.jdbc; - -import java.sql.ResultSet; -import java.sql.SQLException; - -/* - * TDengine only supports a subset of the standard SQL, thus this implemetation of the - * standard JDBC API contains more or less some adjustments customized for certain - * compatibility needs. - */ -public class GetTablesResultSet extends TSDBResultSetWrapper { - - private String catalog; - private String schemaPattern; - private String tableNamePattern; - private String[] types; - - public GetTablesResultSet(ResultSet resultSet, String catalog, String schemaPattern, String tableNamePattern, String[] types) { - super.setOriginalResultSet(resultSet); - this.catalog = catalog; - this.schemaPattern = schemaPattern; - this.tableNamePattern = tableNamePattern; - this.types = types; - } - - @Override - public String getString(int columnIndex) throws SQLException { - String ret = null; - switch (columnIndex) { - case 3: - return super.getString(1); - case 4: - return "table"; - default: - return null; - } - } - -} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java index 4ea0fc79507dc1c0f5a963fba0e055491561a6b4..d1f1e77b1c1e325e04c018a23d5589b7501f4919 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDatabaseMetaData.java @@ -14,11 +14,11 @@ *****************************************************************************/ package com.taosdata.jdbc; -import java.sql.*; -import java.util.ArrayList; -import java.util.List; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; -public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { +public class TSDBDatabaseMetaData extends AbstractDatabaseMetaData { private String url; private String userName; @@ -29,29 +29,12 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { this.userName = userName; } - public void setConnection(Connection conn) { - this.conn = conn; - } - - @Override - public T unwrap(Class iface) throws SQLException { - try { - return iface.cast(this); - } catch (ClassCastException cce) { - throw new SQLException("Unable to unwrap to " + iface.toString()); - } - } - - public boolean isWrapperFor(Class iface) throws SQLException { - return iface.isInstance(this); - } - - public boolean allProceduresAreCallable() throws SQLException { - return false; + public Connection getConnection() throws SQLException { + return this.conn; } - public boolean allTablesAreSelectable() throws SQLException { - return false; + public void setConnection(Connection conn) { + this.conn = conn; } public String getURL() throws SQLException { @@ -62,911 +45,52 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { return this.userName; } - public boolean isReadOnly() throws SQLException { - return false; - } - - public boolean nullsAreSortedHigh() throws SQLException { - return false; - } - - public boolean nullsAreSortedLow() throws SQLException { - return !nullsAreSortedHigh(); - } - - public boolean nullsAreSortedAtStart() throws SQLException { - return true; - } - - public boolean nullsAreSortedAtEnd() throws SQLException { - return !nullsAreSortedAtStart(); - } - - public String getDatabaseProductName() throws SQLException { - return "TDengine"; - } - - public String getDatabaseProductVersion() throws SQLException { - return "2.0.x.x"; - } - public String getDriverName() throws SQLException { return TSDBDriver.class.getName(); } - public String getDriverVersion() throws SQLException { - return "2.0.x"; - } - - public int getDriverMajorVersion() { - return 2; - } - - public int getDriverMinorVersion() { - return 0; - } - - public boolean usesLocalFiles() throws SQLException { - return false; - } - - public boolean usesLocalFilePerTable() throws SQLException { - return false; - } - - - public boolean supportsMixedCaseIdentifiers() throws SQLException { - //像database、table这些对象的标识符,在存储时是否采用大小写混合的模式 - return false; - } - - public boolean storesUpperCaseIdentifiers() throws SQLException { - return false; - } - - public boolean storesLowerCaseIdentifiers() throws SQLException { - return true; - } - - public boolean storesMixedCaseIdentifiers() throws SQLException { - return false; - } - - public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { - //像database、table这些对象的标识符,在存储时是否采用大小写混合、并带引号的模式 - return false; - } - - public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { - return false; - } - - public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { - return false; - } - - public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { - return false; - } - - public String getIdentifierQuoteString() throws SQLException { - return " "; - } - - public String getSQLKeywords() throws SQLException { - return null; - } - - public String getNumericFunctions() throws SQLException { - return null; - } - - public String getStringFunctions() throws SQLException { - return null; - } - - public String getSystemFunctions() throws SQLException { - return null; - } - - public String getTimeDateFunctions() throws SQLException { - return null; - } - - public String getSearchStringEscape() throws SQLException { - return null; - } - - public String getExtraNameCharacters() throws SQLException { - return null; - } - - public boolean supportsAlterTableWithAddColumn() throws SQLException { - return true; - } - - public boolean supportsAlterTableWithDropColumn() throws SQLException { - return true; - } - - public boolean supportsColumnAliasing() throws SQLException { - return true; - } - - public boolean nullPlusNonNullIsNull() throws SQLException { - // null + non-null != null - return false; - } - - public boolean supportsConvert() throws SQLException { - // 是否支持转换函数convert - return false; - } - - public boolean supportsConvert(int fromType, int toType) throws SQLException { - return false; - } - - public boolean supportsTableCorrelationNames() throws SQLException { - return false; - } - - public boolean supportsDifferentTableCorrelationNames() throws SQLException { - return false; - } - - public boolean supportsExpressionsInOrderBy() throws SQLException { - return false; - } - - public boolean supportsOrderByUnrelated() throws SQLException { - return false; - } - - public boolean supportsGroupBy() throws SQLException { - return true; - } - - public boolean supportsGroupByUnrelated() throws SQLException { - return false; - } - - public boolean supportsGroupByBeyondSelect() throws SQLException { - return false; - } - - public boolean supportsLikeEscapeClause() throws SQLException { - return false; - } - - public boolean supportsMultipleResultSets() throws SQLException { - return false; - } - - public boolean supportsMultipleTransactions() throws SQLException { - return false; - } - - public boolean supportsNonNullableColumns() throws SQLException { - return false; - } - - public boolean supportsMinimumSQLGrammar() throws SQLException { - return false; - } - - public boolean supportsCoreSQLGrammar() throws SQLException { - return false; - } - - public boolean supportsExtendedSQLGrammar() throws SQLException { - return false; - } - - public boolean supportsANSI92EntryLevelSQL() throws SQLException { - return false; - } - - public boolean supportsANSI92IntermediateSQL() throws SQLException { - return false; - } - - public boolean supportsANSI92FullSQL() throws SQLException { - return false; - } - - public boolean supportsIntegrityEnhancementFacility() throws SQLException { - return false; - } - - public boolean supportsOuterJoins() throws SQLException { - return false; - } - - public boolean supportsFullOuterJoins() throws SQLException { - return false; - } - - public boolean supportsLimitedOuterJoins() throws SQLException { - return false; - } - - public String getSchemaTerm() throws SQLException { - return null; - } - - public String getProcedureTerm() throws SQLException { - return null; - } - - public String getCatalogTerm() throws SQLException { - return "database"; - } - - public boolean isCatalogAtStart() throws SQLException { - return true; - } - - public String getCatalogSeparator() throws SQLException { - return "."; - } - - public boolean supportsSchemasInDataManipulation() throws SQLException { - return false; - } - - public boolean supportsSchemasInProcedureCalls() throws SQLException { - return false; - } - - public boolean supportsSchemasInTableDefinitions() throws SQLException { - return false; - } - - public boolean supportsSchemasInIndexDefinitions() throws SQLException { - return false; - } - - public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { - return false; - } - - public boolean supportsCatalogsInDataManipulation() throws SQLException { - return true; - } - - public boolean supportsCatalogsInProcedureCalls() throws SQLException { - return false; - } - - public boolean supportsCatalogsInTableDefinitions() throws SQLException { - return false; - } - - public boolean supportsCatalogsInIndexDefinitions() throws SQLException { - return false; - } - - public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { - return false; - } - - public boolean supportsPositionedDelete() throws SQLException { - return false; - } - - public boolean supportsPositionedUpdate() throws SQLException { - return false; - } - - public boolean supportsSelectForUpdate() throws SQLException { - return false; - } - - public boolean supportsStoredProcedures() throws SQLException { - return false; - } - - public boolean supportsSubqueriesInComparisons() throws SQLException { - return false; - } - - public boolean supportsSubqueriesInExists() throws SQLException { - return false; - } - - public boolean supportsSubqueriesInIns() throws SQLException { - return false; - } - - public boolean supportsSubqueriesInQuantifieds() throws SQLException { - return false; - } - - public boolean supportsCorrelatedSubqueries() throws SQLException { - return false; - } - - public boolean supportsUnion() throws SQLException { - return false; - } - - public boolean supportsUnionAll() throws SQLException { - return false; - } - - public boolean supportsOpenCursorsAcrossCommit() throws SQLException { - return false; - } - - public boolean supportsOpenCursorsAcrossRollback() throws SQLException { - return false; - } - - public boolean supportsOpenStatementsAcrossCommit() throws SQLException { - return false; - } - - public boolean supportsOpenStatementsAcrossRollback() throws SQLException { - return false; - } - - public int getMaxBinaryLiteralLength() throws SQLException { - return 0; - } - - public int getMaxCharLiteralLength() throws SQLException { - return 0; - } - - public int getMaxColumnNameLength() throws SQLException { - return 0; - } - - public int getMaxColumnsInGroupBy() throws SQLException { - return 0; - } - - public int getMaxColumnsInIndex() throws SQLException { - return 0; - } - - public int getMaxColumnsInOrderBy() throws SQLException { - return 0; - } - - public int getMaxColumnsInSelect() throws SQLException { - return 0; - } - - public int getMaxColumnsInTable() throws SQLException { - return 0; - } - - public int getMaxConnections() throws SQLException { - return 0; - } - - public int getMaxCursorNameLength() throws SQLException { - return 0; - } - - public int getMaxIndexLength() throws SQLException { - return 0; - } - - public int getMaxSchemaNameLength() throws SQLException { - return 0; - } - - public int getMaxProcedureNameLength() throws SQLException { - return 0; - } - - public int getMaxCatalogNameLength() throws SQLException { - return 0; - } - - public int getMaxRowSize() throws SQLException { - return 0; - } - - public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { - return false; - } - - public int getMaxStatementLength() throws SQLException { - return 0; - } - - public int getMaxStatements() throws SQLException { - return 0; - } - - public int getMaxTableNameLength() throws SQLException { - return 0; - } - - public int getMaxTablesInSelect() throws SQLException { - return 0; - } - - public int getMaxUserNameLength() throws SQLException { - return 0; - } - - public int getDefaultTransactionIsolation() throws SQLException { - return Connection.TRANSACTION_NONE; - } - - public boolean supportsTransactions() throws SQLException { - return false; - } - - public boolean supportsTransactionIsolationLevel(int level) throws SQLException { - if (level == Connection.TRANSACTION_NONE) - return true; - return false; - } - - public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { - return false; - } - - public boolean supportsDataManipulationTransactionsOnly() throws SQLException { - return false; - } - - public boolean dataDefinitionCausesTransactionCommit() throws SQLException { - return false; - } - - public boolean dataDefinitionIgnoredInTransactions() throws SQLException { - return false; - } - - public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) - throws SQLException { - return null; - } - - public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, - String columnNamePattern) throws SQLException { - return null; - } - + /** + * @Param catalog : database名称,"" 表示不属于任何database的table,null表示不使用database来缩小范围 + * @Param schemaPattern : schema名称,""表示 + * @Param tableNamePattern : 表名满足tableNamePattern的表, null表示返回所有表 + * @Param types : 表类型,null表示返回所有类型 + */ public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException { if (conn == null || conn.isClosed()) { throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); } - - try (Statement stmt = conn.createStatement()) { - if (catalog == null || catalog.isEmpty()) - return null; - - stmt.executeUpdate("use " + catalog); - ResultSet resultSet0 = stmt.executeQuery("show tables"); - GetTablesResultSet getTablesResultSet = new GetTablesResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, types); - return getTablesResultSet; - } + return super.getTables(catalog, schemaPattern, tableNamePattern, types, conn); } - public ResultSet getSchemas() throws SQLException { - return getEmptyResultSet(); - } public ResultSet getCatalogs() throws SQLException { if (conn == null || conn.isClosed()) throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); - - try (Statement stmt = conn.createStatement()) { - ResultSet rs = stmt.executeQuery("show databases"); - return new CatalogResultSet(rs); - } + return super.getCatalogs(conn); } public ResultSet getTableTypes() throws SQLException { - DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); - - // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList<>(1); - ColumnMetaData colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(0); - colMetaData.setColName("TABLE_TYPE"); - colMetaData.setColSize(10); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); - columnMetaDataList.add(colMetaData); - - // set up rowDataList - List rowDataList = new ArrayList<>(2); - TSDBResultSetRowData rowData = new TSDBResultSetRowData(); - rowData.setString(0, "TABLE"); - rowDataList.add(rowData); - rowData = new TSDBResultSetRowData(); - rowData.setString(0, "STABLE"); - rowDataList.add(rowData); - - resultSet.setColumnMetaDataList(columnMetaDataList); - resultSet.setRowDataList(rowDataList); - return resultSet; - } - - public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) - throws SQLException { - - /** add by zyyang **********/ - Statement stmt = null; - if (null != conn && !conn.isClosed()) { - stmt = conn.createStatement(); - if (catalog == null || catalog.isEmpty()) - return null; - - stmt.executeUpdate("use " + catalog); - DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); - // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList<>(24); - columnMetaDataList.add(null); - columnMetaDataList.add(null); - // add TABLE_NAME - ColumnMetaData colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(3); - colMetaData.setColName("TABLE_NAME"); - colMetaData.setColSize(193); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); - columnMetaDataList.add(colMetaData); - // add COLUMN_NAME - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(4); - colMetaData.setColName("COLUMN_NAME"); - colMetaData.setColSize(65); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); - columnMetaDataList.add(colMetaData); - // add DATA_TYPE - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(5); - colMetaData.setColName("DATA_TYPE"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - // add TYPE_NAME - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(6); - colMetaData.setColName("TYPE_NAME"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); - columnMetaDataList.add(colMetaData); - // add COLUMN_SIZE - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(7); - colMetaData.setColName("COLUMN_SIZE"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - // add BUFFER_LENGTH ,not used - columnMetaDataList.add(null); - // add DECIMAL_DIGITS - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(9); - colMetaData.setColName("DECIMAL_DIGITS"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - // add NUM_PREC_RADIX - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(10); - colMetaData.setColName("NUM_PREC_RADIX"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - // add NULLABLE - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(11); - colMetaData.setColName("NULLABLE"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - - resultSet.setColumnMetaDataList(columnMetaDataList); - - // set up rowDataList - ResultSet resultSet0 = stmt.executeQuery("describe " + tableNamePattern); - List rowDataList = new ArrayList<>(); - int index = 0; - while (resultSet0.next()) { - TSDBResultSetRowData rowData = new TSDBResultSetRowData(24); - // set TABLE_NAME - rowData.setString(2, tableNamePattern); - // set COLUMN_NAME - rowData.setString(3, resultSet0.getString(1)); - // set DATA_TYPE - String typeName = resultSet0.getString(2); - rowData.setInt(4, getDataType(typeName)); - // set TYPE_NAME - rowData.setString(5, typeName); - // set COLUMN_SIZE - int length = resultSet0.getInt(3); - rowData.setInt(6, getColumnSize(typeName, length)); - // set DECIMAL_DIGITS - rowData.setInt(8, getDecimalDigits(typeName)); - // set NUM_PREC_RADIX - rowData.setInt(9, 10); - // set NULLABLE - rowData.setInt(10, getNullable(index, typeName)); - rowDataList.add(rowData); - index++; - } - resultSet.setRowDataList(rowDataList); - -// GetColumnsResultSet getColumnsResultSet = new GetColumnsResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, columnNamePattern); -// return getColumnsResultSet; -// DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); - return resultSet; - } else { + if (conn == null || conn.isClosed()) throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); - } - - /*************************/ - -// return getEmptyResultSet(); - } - - private int getNullable(int index, String typeName) { - if (index == 0 && "TIMESTAMP".equals(typeName)) - return DatabaseMetaData.columnNoNulls; - return DatabaseMetaData.columnNullable; + return super.getTableTypes(); } - private int getColumnSize(String typeName, int length) { - switch (typeName) { - case "TIMESTAMP": - return 23; - - default: - return 0; - } - } - - private int getDecimalDigits(String typeName) { - switch (typeName) { - case "FLOAT": - return 5; - case "DOUBLE": - return 9; - default: - return 0; - } - } - - private int getDataType(String typeName) { - switch (typeName) { - case "TIMESTAMP": - return Types.TIMESTAMP; - case "INT": - return Types.INTEGER; - case "BIGINT": - return Types.BIGINT; - case "FLOAT": - return Types.FLOAT; - case "DOUBLE": - return Types.DOUBLE; - case "BINARY": - return Types.BINARY; - case "SMALLINT": - return Types.SMALLINT; - case "TINYINT": - return Types.TINYINT; - case "BOOL": - return Types.BOOLEAN; - case "NCHAR": - return Types.NCHAR; - default: - return Types.NULL; - } - } - - public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) - throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) - throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) - throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException { - return getEmptyResultSet(); + public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException { + if (conn == null || conn.isClosed()) + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + return super.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern, conn); } public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, - String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getTypeInfo() throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) - throws SQLException { - return getEmptyResultSet(); - } - - public boolean supportsResultSetType(int type) throws SQLException { - return false; - } - - public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException { - return false; - } - - public boolean ownUpdatesAreVisible(int type) throws SQLException { - return false; - } - - public boolean ownDeletesAreVisible(int type) throws SQLException { - return false; - } - - public boolean ownInsertsAreVisible(int type) throws SQLException { - return false; - } - - public boolean othersUpdatesAreVisible(int type) throws SQLException { - return false; - } - - public boolean othersDeletesAreVisible(int type) throws SQLException { - return false; - } - - public boolean othersInsertsAreVisible(int type) throws SQLException { - return false; - } - - public boolean updatesAreDetected(int type) throws SQLException { - return false; - } - - public boolean deletesAreDetected(int type) throws SQLException { - return false; - } - - public boolean insertsAreDetected(int type) throws SQLException { - return false; - } - - public boolean supportsBatchUpdates() throws SQLException { - return false; - } - - public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) - throws SQLException { - return getEmptyResultSet(); - } - - public Connection getConnection() throws SQLException { - return this.conn; - } - - public boolean supportsSavepoints() throws SQLException { - return false; - } - - public boolean supportsNamedParameters() throws SQLException { - return false; - } - - public boolean supportsMultipleOpenResults() throws SQLException { - return false; - } - - public boolean supportsGetGeneratedKeys() throws SQLException { - return false; - } - - public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException { - return getEmptyResultSet(); + if (conn == null || conn.isClosed()) + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + return super.getPrimaryKeys(catalog, schema, table, conn); } public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, - String attributeNamePattern) throws SQLException { - return getEmptyResultSet(); - } - - public boolean supportsResultSetHoldability(int holdability) throws SQLException { - if (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT) - return true; - return false; - } - - public int getResultSetHoldability() throws SQLException { - return ResultSet.HOLD_CURSORS_OVER_COMMIT; - } - - public int getDatabaseMajorVersion() throws SQLException { - return 2; - } - - public int getDatabaseMinorVersion() throws SQLException { - return 0; - } - - public int getJDBCMajorVersion() throws SQLException { - return 2; - } - - public int getJDBCMinorVersion() throws SQLException { - return 0; - } - - public int getSQLStateType() throws SQLException { - return 0; - } - - public boolean locatorsUpdateCopy() throws SQLException { - return false; - } - - public boolean supportsStatementPooling() throws SQLException { - return false; - } - - public RowIdLifetime getRowIdLifetime() throws SQLException { - return null; - } - - public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { - return null; - } - - public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { - return false; - } - - public boolean autoCommitFailureClosesAllResultSets() throws SQLException { - return false; - } - - public ResultSet getClientInfoProperties() throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) - throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, - String columnNamePattern) throws SQLException { - return getEmptyResultSet(); - } - - public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, - String columnNamePattern) throws SQLException { - return getEmptyResultSet(); - } - - public boolean generatedKeyAlwaysReturned() throws SQLException { - return false; + if (conn == null || conn.isClosed()) + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + return super.getSuperTables(catalog, schemaPattern, tableNamePattern, conn); } - private ResultSet getEmptyResultSet() { - return new EmptyResultSet(); - } } \ No newline at end of file diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBParameterMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBParameterMetaData.java deleted file mode 100644 index d9227523d4ac623d23d85be6376a1530ca606751..0000000000000000000000000000000000000000 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBParameterMetaData.java +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ -package com.taosdata.jdbc; - -import java.sql.ParameterMetaData; -import java.sql.SQLException; - -public class TSDBParameterMetaData implements ParameterMetaData { - @Override - public int getParameterCount() throws SQLException { - return 0; - } - - @Override - public int isNullable(int param) throws SQLException { - return 0; - } - - @Override - public boolean isSigned(int param) throws SQLException { - return false; - } - - @Override - public int getPrecision(int param) throws SQLException { - return 0; - } - - @Override - public int getScale(int param) throws SQLException { - return 0; - } - - @Override - public int getParameterType(int param) throws SQLException { - return 0; - } - - @Override - public String getParameterTypeName(int param) throws SQLException { - return null; - } - - @Override - public String getParameterClassName(int param) throws SQLException { - return null; - } - - @Override - public int getParameterMode(int param) throws SQLException { - return 0; - } - - @Override - public T unwrap(Class iface) throws SQLException { - return null; - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } -} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java index c57f19550dd14719baecb835d76263df1e6a669b..6518bf10e444a05073206e1ef72b8f21a87e26b1 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java @@ -26,9 +26,9 @@ public class TSDBResultSetRowData { public TSDBResultSetRowData(int colSize) { this.setColSize(colSize); } - + public TSDBResultSetRowData() { - this.data = new ArrayList(); + this.data = new ArrayList<>(); this.setColSize(0); } @@ -39,7 +39,7 @@ public class TSDBResultSetRowData { if (this.colSize == 0) { return; } - this.data = new ArrayList(colSize); + this.data = new ArrayList<>(colSize); this.data.addAll(Collections.nCopies(this.colSize, null)); } @@ -53,7 +53,7 @@ public class TSDBResultSetRowData { public boolean getBoolean(int col, int srcType) throws SQLException { Object obj = data.get(col); - + switch(srcType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return (Boolean) obj; case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return ((Float) obj) == 1.0? Boolean.TRUE:Boolean.FALSE; @@ -64,10 +64,10 @@ public class TSDBResultSetRowData { case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return ((Long) obj) == 1L? Boolean.TRUE:Boolean.FALSE; } - + return Boolean.TRUE; } - + public void setByte(int col, byte value) { data.set(col, value); } @@ -82,20 +82,20 @@ public class TSDBResultSetRowData { public int getInt(int col, int srcType) throws SQLException { Object obj = data.get(col); - + switch(srcType) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj)? 1:0; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return ((Float) obj).intValue(); - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: return ((Double)obj).intValue(); - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return (Byte) obj; - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT:return (Short) obj; - case TSDBConstants.TSDB_DATA_TYPE_INT: return (Integer) obj; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return ((Long) obj).intValue(); - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: return Integer.parseInt((String) obj); + case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj)? 1:0; + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return ((Float) obj).intValue(); + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: return ((Double)obj).intValue(); + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return (Byte) obj; + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT:return (Short) obj; + case TSDBConstants.TSDB_DATA_TYPE_INT: return (Integer) obj; + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return ((Long) obj).intValue(); + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: return Integer.parseInt((String) obj); } - + return 0; } @@ -105,7 +105,7 @@ public class TSDBResultSetRowData { public long getLong(int col, int srcType) throws SQLException { Object obj = data.get(col); - + switch(srcType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj)? 1:0; case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return ((Float) obj).longValue(); @@ -116,9 +116,9 @@ public class TSDBResultSetRowData { case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return (Long) obj; case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: return Long.parseLong((String) obj); + case TSDBConstants.TSDB_DATA_TYPE_BINARY: return Long.parseLong((String) obj); } - + return 0; } @@ -128,7 +128,7 @@ public class TSDBResultSetRowData { public float getFloat(int col, int srcType) throws SQLException { Object obj = data.get(col); - + switch(srcType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj)? 1:0; case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return (Float) obj; @@ -139,7 +139,7 @@ public class TSDBResultSetRowData { case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return (Long) obj; } - + return 0; } @@ -149,7 +149,7 @@ public class TSDBResultSetRowData { public double getDouble(int col, int srcType) throws SQLException { Object obj = data.get(col); - + switch(srcType) { case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj)? 1:0; case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return (Float) obj; @@ -160,7 +160,7 @@ public class TSDBResultSetRowData { case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return (Long) obj; } - + return 0; } @@ -180,7 +180,7 @@ public class TSDBResultSetRowData { * The original type may not be a string type, but will be converted to by calling this method * @param col column index * @return - * @throws SQLException + * @throws SQLException */ public String getString(int col, int srcType) throws SQLException { if (srcType == TSDBConstants.TSDB_DATA_TYPE_BINARY || srcType == TSDBConstants.TSDB_DATA_TYPE_NCHAR) { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribeCallBack.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribeCallBack.java deleted file mode 100644 index c1b9b02fa85f8e2197f41d75f8f0c25b3f4c416c..0000000000000000000000000000000000000000 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribeCallBack.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ -package com.taosdata.jdbc; - -public interface TSDBSubscribeCallBack { - void invoke(TSDBResultSet resultSet); -} diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java index 3c372cc503f03f83b17e836a6b3d8335b9407334..0ef64e4a9ee9e58f9e1010889b030a6c0be13304 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDatabaseMetaData.java @@ -29,177 +29,53 @@ public class RestfulDatabaseMetaData extends AbstractDatabaseMetaData { } @Override - public String getSchemaTerm() throws SQLException { - return null; + public String getDriverName() throws SQLException { + return RestfulDriver.class.getName(); } - @Override - public String getProcedureTerm() throws SQLException { - return null; - } - - @Override - public String getCatalogTerm() throws SQLException { - return null; - } - - @Override - public boolean isCatalogAtStart() throws SQLException { - return false; - } @Override public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException { - Statement stmt = null; - if (null != connection && !connection.isClosed()) { - stmt = connection.createStatement(); - if (catalog == null || catalog.length() < 1) { - catalog = connection.getCatalog(); - } - stmt.executeUpdate("use " + catalog); - ResultSet resultSet0 = stmt.executeQuery("show tables"); - GetTablesResultSet getTablesResultSet = new GetTablesResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, types); - return getTablesResultSet; - } else { + if (connection == null || connection.isClosed()) { throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); } + return super.getTables(catalog, schemaPattern, tableNamePattern, types, connection); } @Override public ResultSet getCatalogs() throws SQLException { - if (connection != null && !connection.isClosed()) { - Statement stmt = connection.createStatement(); - ResultSet resultSet0 = stmt.executeQuery("show databases"); - CatalogResultSet resultSet = new CatalogResultSet(resultSet0); - return resultSet; - } else { - return new EmptyResultSet(); - } + if (connection == null || connection.isClosed()) + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + return super.getCatalogs(connection); } @Override - public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException { - Statement stmt = null; - if (null != connection && !connection.isClosed()) { - stmt = connection.createStatement(); - if (catalog == null || catalog.length() < 1) { - catalog = connection.getCatalog(); - } - stmt.execute("use " + catalog); - - DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); - // set up ColumnMetaDataList - List columnMetaDataList = new ArrayList<>(24); - columnMetaDataList.add(null); - columnMetaDataList.add(null); - // add TABLE_NAME - ColumnMetaData colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(3); - colMetaData.setColName("TABLE_NAME"); - colMetaData.setColSize(193); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); - columnMetaDataList.add(colMetaData); - // add COLUMN_NAME - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(4); - colMetaData.setColName("COLUMN_NAME"); - colMetaData.setColSize(65); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); - columnMetaDataList.add(colMetaData); - // add DATA_TYPE - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(5); - colMetaData.setColName("DATA_TYPE"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - // add TYPE_NAME - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(6); - colMetaData.setColName("TYPE_NAME"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY); - columnMetaDataList.add(colMetaData); - // add COLUMN_SIZE - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(7); - colMetaData.setColName("COLUMN_SIZE"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - // add BUFFER_LENGTH ,not used - columnMetaDataList.add(null); - // add DECIMAL_DIGITS - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(9); - colMetaData.setColName("DECIMAL_DIGITS"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - // add NUM_PREC_RADIX - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(10); - colMetaData.setColName("NUM_PREC_RADIX"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - // add NULLABLE - colMetaData = new ColumnMetaData(); - colMetaData.setColIndex(11); - colMetaData.setColName("NULLABLE"); - colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT); - columnMetaDataList.add(colMetaData); - - resultSet.setColumnMetaDataList(columnMetaDataList); - - // set up rowDataList - ResultSet resultSet0 = stmt.executeQuery("describe " + tableNamePattern); - List rowDataList = new ArrayList<>(); - int index = 0; - while (resultSet0.next()) { - TSDBResultSetRowData rowData = new TSDBResultSetRowData(24); - // set TABLE_NAME - rowData.setString(2, tableNamePattern); - // set COLUMN_NAME - rowData.setString(3, resultSet0.getString(1)); - // set DATA_TYPE - String typeName = resultSet0.getString(2); - rowData.setInt(4, getDataType(typeName)); - // set TYPE_NAME - rowData.setString(5, typeName); - // set COLUMN_SIZE - int length = resultSet0.getInt(3); - rowData.setInt(6, getColumnSize(typeName, length)); - // set DECIMAL_DIGITS - rowData.setInt(8, getDecimalDigits(typeName)); - // set NUM_PREC_RADIX - rowData.setInt(9, 10); - // set NULLABLE - rowData.setInt(10, getNullable(index, typeName)); - rowDataList.add(rowData); - index++; - } - resultSet.setRowDataList(rowDataList); - - return resultSet; - } else { + public ResultSet getTableTypes() throws SQLException { + if (connection == null || connection.isClosed()) { throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); } + return super.getTableTypes(); } @Override - public long getMaxLogicalLobSize() throws SQLException { - return 0; + public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException { + if (connection == null || connection.isClosed()) + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + return super.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern, connection); } @Override - public boolean supportsRefCursors() throws SQLException { - return false; + public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { + if (connection == null || connection.isClosed()) + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + return super.getPrimaryKeys(catalog, schema, table, connection); } - @Override - public T unwrap(Class iface) throws SQLException { - return null; + public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { + if (connection == null || connection.isClosed()) + throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + return super.getSuperTables(catalog, schemaPattern, tableNamePattern, connection); } - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; - } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java index cb6ff369f2b43f7cfae63fcc57701d692d3d803b..fca8847114529280bf70d4bf8e56508a572ef7e4 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java @@ -44,6 +44,8 @@ public class RestfulDriver extends AbstractTaosDriver { String result = HttpClientPoolUtil.execute(loginUrl); JSONObject jsonResult = JSON.parseObject(result); String status = jsonResult.getString("status"); + String token = jsonResult.getString("desc"); + HttpClientPoolUtil.token = token; if (!status.equals("succ")) { throw new SQLException(jsonResult.getString("desc")); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java index 23e8796980ac419635ef6953deff1033d158962e..9b1681ff948dc9257e7b775d947c598d9dc60378 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/util/HttpClientPoolUtil.java @@ -23,6 +23,7 @@ import java.nio.charset.Charset; public class HttpClientPoolUtil { public static PoolingHttpClientConnectionManager cm = null; public static CloseableHttpClient httpClient = null; + public static String token = "cm9vdDp0YW9zZGF0YQ=="; /** * 默认content 类型 */ @@ -61,9 +62,7 @@ public class HttpClientPoolUtil { try { return Long.parseLong(value) * 1000; } catch (Exception e) { - new Exception( - "format KeepAlive timeout exception, exception:" + e.toString()) - .printStackTrace(); + new Exception("format KeepAlive timeout exception, exception:" + e.toString()).printStackTrace(); } } } @@ -96,7 +95,7 @@ public class HttpClientPoolUtil { initPools(); } method = (HttpEntityEnclosingRequestBase) getRequest(uri, HttpPost.METHOD_NAME, DEFAULT_CONTENT_TYPE, 0); - method.setHeader("Authorization", "Basic cm9vdDp0YW9zZGF0YQ=="); + method.setHeader("Authorization", "Taosd " + token); method.setHeader("Content-Type", "text/plain"); method.setEntity(new StringEntity(data, Charset.forName("UTF-8"))); HttpContext context = HttpClientContext.create(); diff --git a/src/connector/jdbc/src/test/java/TestPreparedStatement.java b/src/connector/jdbc/src/test/java/TestPreparedStatement.java deleted file mode 100644 index 1edb957493183c407b668bd68532e83fa1a64dba..0000000000000000000000000000000000000000 --- a/src/connector/jdbc/src/test/java/TestPreparedStatement.java +++ /dev/null @@ -1,36 +0,0 @@ -import com.taosdata.jdbc.TSDBDriver; -import com.taosdata.jdbc.TSDBPreparedStatement; - -import java.sql.*; -import java.util.Properties; - -public class TestPreparedStatement { - - public static void main(String[] args) throws SQLException { - Connection connection = null; - try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, "localhost"); - connection = DriverManager.getConnection("jdbc:TAOS://localhost:0/", properties); - String rawSql = "select * from test.log0601"; -// String[] params = new String[]{"ts", "c1"}; - PreparedStatement pstmt = (TSDBPreparedStatement) connection.prepareStatement(rawSql); - ResultSet resSet = pstmt.executeQuery(); - while(resSet.next()) { - for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) { - System.out.printf("%d: %s \n", i, resSet.getString(i)); - } - } - resSet.close(); - pstmt.close(); - connection.close(); - - } catch (Exception e) { - e.printStackTrace(); - if (null != connection) { - connection.close(); - } - } - } -} diff --git a/src/connector/jdbc/src/test/java/TestTSDBDatabaseMetaData.java b/src/connector/jdbc/src/test/java/TestTSDBDatabaseMetaData.java deleted file mode 100644 index 39a08f0fe98a279e62ca07f20047813edeab56db..0000000000000000000000000000000000000000 --- a/src/connector/jdbc/src/test/java/TestTSDBDatabaseMetaData.java +++ /dev/null @@ -1,33 +0,0 @@ -import com.taosdata.jdbc.TSDBDriver; - -import java.sql.*; -import java.util.Properties; - -public class TestTSDBDatabaseMetaData { - - public static void main(String[] args) throws SQLException { - Connection connection = null; - DatabaseMetaData dbMetaData = null; - ResultSet resSet = null; - try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, "localhost"); - connection = DriverManager.getConnection("jdbc:TAOS://localhost:0/", properties); - dbMetaData = connection.getMetaData(); - resSet = dbMetaData.getCatalogs(); - while(resSet.next()) { - for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) { - System.out.printf("dbMetaData.getCatalogs(%d) = %s\n", i, resSet.getString(i)); - } - } - resSet.close(); - - } catch (Exception e) { - e.printStackTrace(); - if (null != connection) { - connection.close(); - } - } - } -} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/BatchInsertTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/BatchInsertTest.java index 7d96cbb5381d099f7b67ecdb5414093c54b37b65..4046e3edf6e1d9d62ceddaf99f73212dd1dd02c2 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/BatchInsertTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/BatchInsertTest.java @@ -13,17 +13,17 @@ import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; -public class BatchInsertTest extends BaseTest { - - static Connection connection = null; - static Statement statement = null; - static String dbName = "test"; - static String stbName = "meters"; - static String host = "localhost"; - static int numOfTables = 30; - final static int numOfRecordsPerTable = 1000; - static long ts = 1496732686000l; - final static String tablePrefix = "t"; +public class BatchInsertTest { + + private Connection connection; + + private static String dbName = "test"; + private static String stbName = "meters"; + private static String host = "127.0.0.1"; + private static int numOfTables = 30; + private static int numOfRecordsPerTable = 1000; + private static long ts = 1496732686000l; + private static String tablePrefix = "t"; @Before public void createDatabase() throws SQLException { @@ -32,65 +32,58 @@ public class BatchInsertTest extends BaseTest { } catch (ClassNotFoundException e) { return; } - + Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); - - statement = connection.createStatement(); - statement.executeUpdate("drop database if exists " + dbName); - statement.executeUpdate("create database if not exists " + dbName); - statement.executeUpdate("use " + dbName); - String createTableSql = "create table " + stbName + "(ts timestamp, f1 int, f2 int, f3 int) tags(areaid int, loc binary(20))"; - statement.executeUpdate(createTableSql); + Statement stmt = connection.createStatement(); + stmt.execute("drop database if exists " + dbName); + stmt.execute("create database if not exists " + dbName); + stmt.execute("use " + dbName); + + String createTableSql = "create table " + stbName + "(ts timestamp, f1 int, f2 int, f3 int) tags(areaid int, loc binary(20))"; + stmt.execute(createTableSql); - for(int i = 0; i < numOfTables; i++) { + for (int i = 0; i < numOfTables; i++) { String loc = i % 2 == 0 ? "beijing" : "shanghai"; - String createSubTalbesSql = "create table " + tablePrefix + i + " using " + stbName + " tags(" + i + ", '" + loc + "')"; - statement.executeUpdate(createSubTalbesSql); + String createSubTalbesSql = "create table " + tablePrefix + i + " using " + stbName + " tags(" + i + ", '" + loc + "')"; + stmt.execute(createSubTalbesSql); } - + stmt.close(); } - + @Test - public void testBatchInsert() throws SQLException{ - - ExecutorService executorService = Executors.newFixedThreadPool(numOfTables); - - for (int i = 0; i < numOfTables; i++) { - final int index = i; - executorService.execute(new Runnable() { - @Override - public void run() { - try { - long startTime = System.currentTimeMillis(); - Statement statement = connection.createStatement(); // get statement - StringBuilder sb = new StringBuilder(); - sb.append("INSERT INTO " + tablePrefix + index + " VALUES"); - Random rand = new Random(); - for (int j = 1; j <= numOfRecordsPerTable; j++) { - sb.append("(" + (ts + j) + ", "); - sb.append(rand.nextInt(100) + ", "); - sb.append(rand.nextInt(100) + ", "); - sb.append(rand.nextInt(100) + ")"); - } - statement.addBatch(sb.toString()); - statement.executeBatch(); - long endTime = System.currentTimeMillis(); - System.out.println("Thread " + index + " takes " + (endTime - startTime) + " microseconds"); - connection.commit(); - statement.close(); - } catch (Exception e) { - e.printStackTrace(); + public void testBatchInsert() throws SQLException { + ExecutorService executorService = Executors.newFixedThreadPool(numOfTables); + for (int i = 0; i < numOfTables; i++) { + final int index = i; + executorService.execute(() -> { + try { + long startTime = System.currentTimeMillis(); + Statement statement = connection.createStatement(); // get statement + StringBuilder sb = new StringBuilder(); + sb.append("INSERT INTO " + tablePrefix + index + " VALUES"); + Random rand = new Random(); + for (int j = 1; j <= numOfRecordsPerTable; j++) { + sb.append("(" + (ts + j) + ", "); + sb.append(rand.nextInt(100) + ", "); + sb.append(rand.nextInt(100) + ", "); + sb.append(rand.nextInt(100) + ")"); } + statement.addBatch(sb.toString()); + statement.executeBatch(); + long endTime = System.currentTimeMillis(); + System.out.println("Thread " + index + " takes " + (endTime - startTime) + " microseconds"); + connection.commit(); + statement.close(); + } catch (Exception e) { + e.printStackTrace(); } }); } - executorService.shutdown(); try { @@ -100,21 +93,23 @@ public class BatchInsertTest extends BaseTest { } Statement statement = connection.createStatement(); - ResultSet rs = statement.executeQuery("select * from meters"); + ResultSet rs = statement.executeQuery("select * from meters"); int num = 0; while (rs.next()) { num++; - } - assertEquals(num, numOfTables * numOfRecordsPerTable); + } + assertEquals(num, numOfTables * numOfRecordsPerTable); rs.close(); } - @After - public void close() throws Exception { - statement.close(); - connection.close(); - Thread.sleep(10); + public void close() { + try { + if (connection != null) + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } } - + } \ No newline at end of file diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java index a54ece4eadc54e930a4af4faddb58dfef3ceb25a..66d23f2ffafb8d266d0f24651676214b6c48d418 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ConnectionTest.java @@ -1,5 +1,6 @@ package com.taosdata.jdbc; +import org.junit.Assert; import org.junit.Test; import java.sql.Connection; @@ -8,53 +9,31 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; -import static org.junit.Assert.assertTrue; -public class ConnectionTest extends BaseTest { - static Connection connection = null; - static Statement statement = null; - static String dbName = "test"; - static String stbName = "st"; - static String host = "localhost"; +public class ConnectionTest { + private Connection connection; + private Statement statement; + private static String host = "127.0.0.1"; @Test - public void testConnection() throws SQLException { - try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); - } catch (ClassNotFoundException e) { - return; - } + public void testConnection() { Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); - - assertTrue(null != connection); - statement = connection.createStatement(); - assertTrue(null != statement); - - // try reconnect - connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); try { - statement.execute("create database if not exists " + dbName); + Class.forName("com.taosdata.jdbc.TSDBDriver"); + connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); + Assert.assertTrue(null != connection); + statement = connection.createStatement(); + Assert.assertTrue(null != statement); + statement.close(); + connection.close(); + } catch (ClassNotFoundException e) { + return; } catch (SQLException e) { - assert false : "create database error: " + e.getMessage(); - } - - try { - if (!connection.isClosed()) { - if (!statement.isClosed()) { - statement.executeUpdate("drop database " + dbName); - statement.close(); - } - connection.close(); - Thread.sleep(10); - } - } catch (Exception e) { - assert false : "close connection error: " + e.getMessage(); + e.printStackTrace(); } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java index dbe16d9fea33be117cfa93a3ecd9a1ff4bd12cd8..9d1884e6c2b44eb5269bcb5ad40fdfe9dd759f67 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/ImportTest.java @@ -1,92 +1,112 @@ package com.taosdata.jdbc; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.*; +import org.junit.runners.MethodSorters; import java.sql.*; import java.util.Properties; import static org.junit.Assert.assertEquals; -public class ImportTest extends BaseTest { - Connection connection = null; - Statement statement = null; - String dbName = "test"; - String tName = "t0"; - String host = "localhost"; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class ImportTest { + private static Connection connection; + static String dbName = "test"; + static String tName = "t0"; + static String host = "127.0.0.1"; + private static long ts; - @Before - public void createDatabase() throws SQLException { + @BeforeClass + public static void before() { try { Class.forName("com.taosdata.jdbc.TSDBDriver"); + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); + + Statement stmt = connection.createStatement(); + stmt.execute("create database if not exists " + dbName); + stmt.execute("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)"); + stmt.close(); + + ts = System.currentTimeMillis(); } catch (ClassNotFoundException e) { - return; + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); } - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); - - statement = connection.createStatement(); - statement.executeUpdate("drop database if exists " + dbName); - statement.executeUpdate("create database if not exists " + dbName); - statement.executeUpdate("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)"); } @Test - public void insertData() throws Exception { - long ts = 1496732686000l; - - for (int i = 0; i < 50; i++) { - ts++; - int row = statement.executeUpdate("insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")"); - System.out.println("insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")\t" + row); - assertEquals(1, row); + public void case001_insertData() throws Exception { + try (Statement stmt = connection.createStatement()) { + for (int i = 0; i < 50; i++) { + ts++; + int row = stmt.executeUpdate("import into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")"); + System.out.println("import into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")\t" + row); + assertEquals(1, row); + } } } @Test - public void selectData() throws Exception { - insertData(); - String sql = "select * from test.t0"; - ResultSet resSet = statement.executeQuery(sql); + public void case002_checkSum() { + Assert.assertEquals(50, select()); + } - while (resSet.next()) { - for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) { - System.out.printf(i + ": " + resSet.getString(i) + "\t"); + private int select() { + int count = 0; + try (Statement stmt = connection.createStatement()) { + + String sql = "select * from " + dbName + "." + tName; + ResultSet rs = stmt.executeQuery(sql); + while (rs.next()) { + count++; } + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); } - resSet.close(); + return count; } @Test - public void importData() throws Exception { + public void case003_importData() { // 避免时间重复 - long ts = 1496732686000l; - - StringBuilder sqlBuilder = new StringBuilder("insert into ").append(dbName).append(".").append(tName).append(" values "); - - for (int i = 0; i < 50; i++) { - int a = i / 5; - long t = ts + a; - sqlBuilder.append("(").append(t).append(",").append((100 + i)).append(",").append(i).append(") "); + try (Statement stmt = connection.createStatement()) { + StringBuilder sqlBuilder = new StringBuilder("import into ").append(dbName).append(".").append(tName).append(" values "); + for (int i = 0; i < 50; i++) { + int a = i / 5; + long t = (++ts) + a; + sqlBuilder.append("(").append(t).append(",").append((100 + i)).append(",").append(i).append(") "); + } + System.out.println(sqlBuilder.toString()); + int rows = stmt.executeUpdate(sqlBuilder.toString()); + assertEquals(50, rows); + } catch (SQLException e) { + e.printStackTrace(); } - System.out.println(sqlBuilder.toString()); - int rows = statement.executeUpdate(sqlBuilder.toString()); - System.out.println(rows); - assertEquals(10, rows); } - @After - public void close() throws Exception { - statement.executeUpdate("drop database " + dbName); - statement.close(); - connection.close(); - Thread.sleep(10); + @Test + public void case004_checkSum() { + Assert.assertEquals(100, select()); + } + @AfterClass + public static void close() { + try { + if (connection != null) { + Statement statement = connection.createStatement(); + statement.executeUpdate("drop database " + dbName); + statement.close(); + connection.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java index 0535214ac198685ad65edf338bc6d72f841731a8..f52c50ff1a6dde4709a99a0172eef2d13877d3d0 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/PreparedStatementTest.java @@ -4,7 +4,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; -import org.junit.runners.MethodSorters; import java.sql.*; import java.util.Properties; @@ -12,7 +11,7 @@ import java.util.Properties; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -@FixMethodOrder(MethodSorters.DEFAULT) +@FixMethodOrder() public class PreparedStatementTest extends BaseTest { static Connection connection = null; static PreparedStatement statement = null; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java index 6c75860e0f0a2647175de6e836f7f1aeb62c539a..7db37beaf4b355b8d256b5d63f4eedd8e7fd0e0e 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SelectTest.java @@ -9,61 +9,73 @@ import java.util.Properties; import static org.junit.Assert.assertEquals; -public class SelectTest extends BaseTest { - Connection connection = null; - Statement statement = null; +public class SelectTest { + Connection connection; String dbName = "test"; String tName = "t0"; - String host = "localhost"; + String host = "127.0.0.1"; @Before - public void createDatabaseAndTable() throws SQLException { + public void createDatabaseAndTable() { try { Class.forName("com.taosdata.jdbc.TSDBDriver"); + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); + + Statement stmt = connection.createStatement(); + stmt.execute("drop database if exists " + dbName); + stmt.execute("create database if not exists " + dbName); + stmt.execute("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)"); + stmt.close(); } catch (ClassNotFoundException e) { return; + } catch (SQLException e) { + e.printStackTrace(); } - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); - statement = connection.createStatement(); - statement.executeUpdate("drop database if exists " + dbName); - statement.executeUpdate("create database if not exists " + dbName); - statement.executeUpdate("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)"); } @Test - public void selectData() throws SQLException { + public void selectData() { long ts = 1496732686000l; - for (int i = 0; i < 50; i++) { - ts++; - int row = statement.executeUpdate("insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")"); - System.out.println("insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")\t" + row); - assertEquals(1, row); - } + try (Statement stmt = connection.createStatement()) { + for (int i = 0; i < 50; i++) { + ts++; + int row = stmt.executeUpdate("insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")"); + System.out.println("insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")\t" + row); + assertEquals(1, row); + } - String sql = "select * from " + dbName + "." + tName; - ResultSet resSet = statement.executeQuery(sql); + String sql = "select * from " + dbName + "." + tName; + ResultSet resSet = stmt.executeQuery(sql); - int num = 0; - while (resSet.next()) { - num++; + int num = 0; + while (resSet.next()) { + num++; + } + resSet.close(); + assertEquals(num, 50); + } catch (SQLException e) { + e.printStackTrace(); } - resSet.close(); - assertEquals(num, 50); } @After - public void close() throws Exception { - statement.executeUpdate("drop database " + dbName); - statement.close(); - connection.close(); - Thread.sleep(10); + public void close() { + try { + if (connection != null) { + Statement stmt = connection.createStatement(); + stmt.executeUpdate("drop database " + dbName); + stmt.close(); + connection.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java index 6e01fb7c349bbab73fcc6878d85330ac39de2cfc..c86a0b4c6aeeab5def76d758268b2b9e0d84b01f 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StableTest.java @@ -12,69 +12,66 @@ import java.util.Properties; import static org.junit.Assert.assertEquals; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class StableTest extends BaseTest { - static Connection connection = null; - static Statement statement = null; - static String dbName = "test"; - static String stbName = "st"; - static String host = "localhost"; +public class StableTest { + + private static Connection connection; + private static String dbName = "test"; + private static String stbName = "st"; + private static String host = "127.0.0.1"; @BeforeClass - public static void createDatabase() throws SQLException { + public static void createDatabase() { try { Class.forName("com.taosdata.jdbc.TSDBDriver"); + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); + Statement statement = connection.createStatement(); + statement.execute("create database if not exists " + dbName); + statement.execute("use " + dbName); + statement.close(); } catch (ClassNotFoundException e) { return; + } catch (SQLException e) { + e.printStackTrace(); } - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); - - statement = connection.createStatement(); - statement.executeUpdate("create database if not exists " + dbName); - statement.executeQuery("use " + dbName); } -// @Test - public void createStable() { - String sql = "create table " + stbName + " (ts timestamp, v1 int, v2 int) tags (tg nchar(20)) "; - - try { - statement.executeUpdate(sql); + @Test + public void case001_createSuperTable() { + try (Statement stmt = connection.createStatement()) { + final String sql = "create table " + stbName + " (ts timestamp, v1 int, v2 int) tags (tg nchar(20)) "; + stmt.execute(sql); } catch (SQLException e) { assert false : "error create stable" + e.getMessage(); } } -// @Test - public void createTable() { - String sql = "create table t1 using " + stbName + " tags (\"beijing\")"; - - try { - statement.executeUpdate(sql); + @Test + public void case002_createTable() { + try (Statement stmt = connection.createStatement()) { + final String sql = "create table t1 using " + stbName + " tags (\"beijing\")"; + stmt.execute(sql); } catch (SQLException e) { assert false : "error create table" + e.getMessage(); } } @Test - public void describeSTable() { - createStable(); - String sql = "describe " + stbName; + public void case003_describeSTable() { int num = 0; - System.out.println("describe stable"); - try { - ResultSet res = statement.executeQuery(sql); - while (res.next()) { - for (int i = 1; i <= res.getMetaData().getColumnCount(); i++) { - System.out.printf("%d: %s\n", i, res.getString(i)); + try (Statement stmt = connection.createStatement()) { + String sql = "describe " + stbName; + ResultSet rs = stmt.executeQuery(sql); + while (rs.next()) { + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + System.out.println(i + ":" + rs.getString(i)); } num++; } - res.close(); + rs.close(); assertEquals(4, num); } catch (SQLException e) { assert false : "error describe stable" + e.getMessage(); @@ -82,41 +79,31 @@ public class StableTest extends BaseTest { } @Test - public void describeTable() { - createTable(); - String sql = "describe t1"; + public void case004_describeTable() { int num = 0; - System.out.println("describe table"); - try { - ResultSet res = statement.executeQuery(sql); - while (res.next()) { - for (int i = 1; i <= res.getMetaData().getColumnCount(); i++) { - System.out.printf("%d: %s\n", i, res.getString(i)); + try (Statement stmt = connection.createStatement()) { + ResultSet rs = stmt.executeQuery("describe t1"); + while (rs.next()) { + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + System.out.printf("%d: %s\n", i, rs.getString(i)); } num++; } - res.close(); + rs.close(); assertEquals(4, num); } catch (SQLException e) { assert false : "error describe stable" + e.getMessage(); } } - // @Test - public void validCreateSql() { - String sql = "create table t2 using " + stbName + " tags (\"beijing\")"; - boolean valid = ((TSDBConnection) connection).getConnection().validateCreateTableSql(sql); - assertEquals(true, valid); - } - @AfterClass - public static void close() throws Exception { - if (!statement.isClosed()) { - statement.executeUpdate("drop database " + dbName); - statement.close(); - connection.close(); - Thread.sleep(10); - + public static void close() { + try { + if (connection != null) + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); } + } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java index db7b8c8cb14cbc0d1ae5a5a3a3bf8df590c4bc2a..a79512984e6d78fda30b1281fefe91ddea7c2434 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/StatementTest.java @@ -10,7 +10,7 @@ import java.util.Properties; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -public class StatementTest extends BaseTest { +public class StatementTest { static Connection connection = null; static Statement statement = null; static String dbName = "test"; @@ -26,14 +26,29 @@ public class StatementTest extends BaseTest { return; } Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties); + connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", properties); statement = connection.createStatement(); statement.executeUpdate("drop database if exists " + dbName); + } + + @Test + public void testCase() { + try { + ResultSet rs = statement.executeQuery("show databases"); + ResultSetMetaData metaData = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= metaData.getColumnCount(); i++) { + System.out.print(metaData.getColumnLabel(i) + ":" + rs.getString(i) + "\t"); + } + System.out.println(); + } + } catch (SQLException e) { + e.printStackTrace(); + } } @@ -54,9 +69,6 @@ public class StatementTest extends BaseTest { @Test public void testUnsupport() { -// if(null == resSet) { -// return; -// } TSDBStatement tsdbStatement = (TSDBStatement) statement; try { tsdbStatement.unwrap(null); @@ -163,11 +175,10 @@ public class StatementTest extends BaseTest { @AfterClass public static void close() throws Exception { if (!statement.isClosed()) { - statement.executeUpdate("drop database " + dbName); + statement.executeUpdate("drop database if exists " + dbName); statement.close(); connection.close(); Thread.sleep(10); - } } } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java index 448b513d0edadc0b8e3c3537acfdc83f25cb90b0..8066b38573b87d9d5b91a628b56ab5700e379113 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBDatabaseMetaDataTest.java @@ -1,28 +1,41 @@ package com.taosdata.jdbc; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; +import org.junit.*; + +import java.sql.*; import java.util.Properties; public class TSDBDatabaseMetaDataTest { private TSDBDatabaseMetaData metaData; - private static final String host = "localhost"; - - @Before - public void before() throws ClassNotFoundException, SQLException { - Class.forName("com.taosdata.jdbc.TSDBDriver"); - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - metaData = (TSDBDatabaseMetaData) DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata", properties).getMetaData(); + private static final String host = "127.0.0.1"; + private Connection connection; + + @BeforeClass + public void before() { + try { + Class.forName("com.taosdata.jdbc.TSDBDriver"); + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata", properties); + metaData = connection.getMetaData().unwrap(TSDBDatabaseMetaData.class); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @AfterClass + public void after() { + try { + if (connection != null) + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } } @Test @@ -642,7 +655,17 @@ public class TSDBDatabaseMetaDataTest { @Test public void getTables() throws SQLException { - Assert.assertNull(metaData.getTables("", "", "*", null)); + System.out.println("****************************************************"); + ResultSet tables = metaData.getTables("log", "", null, null); + ResultSetMetaData metaData = tables.getMetaData(); + while (tables.next()) { + System.out.print(metaData.getColumnLabel(1) + ":" + tables.getString(1) + "\t"); + System.out.print(metaData.getColumnLabel(3) + ":" + tables.getString(3) + "\t"); + System.out.print(metaData.getColumnLabel(4) + ":" + tables.getString(4) + "\t"); + System.out.print(metaData.getColumnLabel(5) + ":" + tables.getString(5) + "\n"); + } + System.out.println(); + Assert.assertNotNull(tables); } @Test @@ -652,17 +675,47 @@ public class TSDBDatabaseMetaDataTest { @Test public void getCatalogs() throws SQLException { - Assert.assertNotNull(metaData.getCatalogs()); + System.out.println("****************************************************"); + + ResultSet catalogs = metaData.getCatalogs(); + ResultSetMetaData meta = catalogs.getMetaData(); + while (catalogs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.print(meta.getColumnLabel(i) + ": " + catalogs.getString(i)); + } + System.out.println(); + } } @Test public void getTableTypes() throws SQLException { + System.out.println("****************************************************"); + + ResultSet tableTypes = metaData.getTableTypes(); + while (tableTypes.next()) { + System.out.println(tableTypes.getString("TABLE_TYPE")); + } Assert.assertNotNull(metaData.getTableTypes()); } @Test public void getColumns() throws SQLException { - Assert.assertNotNull(metaData.getColumns("", "", "", "")); + System.out.println("****************************************************"); + + ResultSet columns = metaData.getColumns("log", "", "dn", ""); + ResultSetMetaData meta = columns.getMetaData(); + while (columns.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + columns.getString(1) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + columns.getString(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + columns.getString(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + columns.getString(5) + "\t"); + System.out.print(meta.getColumnLabel(6) + ": " + columns.getString(6) + "\t"); + System.out.print(meta.getColumnLabel(7) + ": " + columns.getString(7) + "\t"); + System.out.print(meta.getColumnLabel(9) + ": " + columns.getString(9) + "\t"); + System.out.print(meta.getColumnLabel(10) + ": " + columns.getString(10) + "\t"); + System.out.print(meta.getColumnLabel(11) + ": " + columns.getString(11) + "\n"); + System.out.print(meta.getColumnLabel(12) + ": " + columns.getString(12) + "\n"); + } } @Test @@ -687,7 +740,17 @@ public class TSDBDatabaseMetaDataTest { @Test public void getPrimaryKeys() throws SQLException { - Assert.assertNotNull(metaData.getPrimaryKeys("", "", "")); + System.out.println("****************************************************"); + + ResultSet rs = metaData.getPrimaryKeys("log", "", "dn1"); + while (rs.next()) { + System.out.println("TABLE_NAME: " + rs.getString("TABLE_NAME")); + System.out.println("COLUMN_NAME: " + rs.getString("COLUMN_NAME")); + System.out.println("KEY_SEQ: " + rs.getString("KEY_SEQ")); + System.out.println("PK_NAME: " + rs.getString("PK_NAME")); + } + + Assert.assertNotNull(rs); } @Test @@ -812,7 +875,14 @@ public class TSDBDatabaseMetaDataTest { @Test public void getSuperTables() throws SQLException { - Assert.assertNotNull(metaData.getSuperTables("", "", "")); + System.out.println("****************************************************"); + + ResultSet rs = metaData.getSuperTables("log", "", "dn1"); + while (rs.next()) { + System.out.println("TABLE_NAME: " + rs.getString("TABLE_NAME")); + System.out.println("SUPERTABLE_NAME: " + rs.getString("SUPERTABLE_NAME")); + } + Assert.assertNotNull(rs); } @Test @@ -871,11 +941,6 @@ public class TSDBDatabaseMetaDataTest { Assert.assertNull(metaData.getRowIdLifetime()); } - @Test - public void testGetSchemas() throws SQLException { - Assert.assertNull(metaData.getSchemas()); - } - @Test public void supportsStoredFunctionsUsingCallSyntax() throws SQLException { Assert.assertFalse(metaData.supportsStoredFunctionsUsingCallSyntax()); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..918714da22d45df3e78af93c07423689f1baccc2 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/AuthenticationTest.java @@ -0,0 +1,65 @@ +package com.taosdata.jdbc.rs; + +import org.junit.Before; +import org.junit.Test; + +import java.sql.*; + +public class AuthenticationTest { + + private static final String host = "127.0.0.1"; + private static final String user = "root"; + private static final String password = "123456"; + private Connection conn; + + @Test + public void test() { + // change password + try { + conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/restful_test?user=" + user + "&password=taosdata"); + Statement stmt = conn.createStatement(); + stmt.execute("alter user " + user + " pass '" + password + "'"); + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + // use new to login and execute query + try { + conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/restful_test?user=" + user + "&password=" + password); + Statement stmt = conn.createStatement(); + stmt.execute("show databases"); + ResultSet rs = stmt.getResultSet(); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.print(meta.getColumnLabel(i) + ":" + rs.getString(i) + "\t"); + } + System.out.println(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + // change password back + try { + conn = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/restful_test?user=" + user + "&password=" + password); + Statement stmt = conn.createStatement(); + stmt.execute("alter user " + user + " pass 'taosdata'"); + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + + } + + @Before + public void before() { + try { + Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java index d07a6a21796fc2ea7927c04fd0cf5a37e9a49988..e239aa068bae0ee70d204aec4412bf29e5b36bf1 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulDriverTest.java @@ -6,6 +6,7 @@ import org.junit.Test; import java.sql.*; public class RestfulDriverTest { + private static final String host = "127.0.0.1"; @Test public void connect() { @@ -15,9 +16,9 @@ public class RestfulDriverTest { @Test public void acceptsURL() throws SQLException { Driver driver = new RestfulDriver(); - boolean isAccept = driver.acceptsURL("jdbc:TAOS-RS://master:6041"); + boolean isAccept = driver.acceptsURL("jdbc:TAOS-RS://" + host + ":6041"); Assert.assertTrue(isAccept); - isAccept = driver.acceptsURL("jdbc:TAOS://master:6041"); + isAccept = driver.acceptsURL("jdbc:TAOS://" + host + ":6041"); Assert.assertFalse(isAccept); } @@ -26,6 +27,9 @@ public class RestfulDriverTest { Driver driver = new RestfulDriver(); final String url = ""; DriverPropertyInfo[] propertyInfo = driver.getPropertyInfo(url, null); + for (DriverPropertyInfo prop : propertyInfo) { + System.out.println(prop); + } } @Test diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java index 0af6b91532b63773510e10806d8f1e744ffe966e..ee4b2ed4dd2944a5b09df9afb5d15638422d52cb 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java @@ -1,6 +1,5 @@ package com.taosdata.jdbc.rs; - import org.junit.*; import org.junit.runners.MethodSorters; @@ -10,12 +9,13 @@ import java.util.Random; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class RestfulJDBCTest { + private static final String host = "127.0.0.1"; private Connection connection; @Before public void before() throws ClassNotFoundException, SQLException { Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); - connection = DriverManager.getConnection("jdbc:TAOS-RS://master:6041/restful_test?user=root&password=taosdata"); + connection = DriverManager.getConnection("jdbc:TAOS-RS://" + host + ":6041/restful_test?user=root&password=taosdata"); } @After diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java index 8ff308f8546b39519b9b24412e772a60a3ef68f0..ad6ed43ac737429707ff4f086a320cb62336b020 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java @@ -10,7 +10,7 @@ import java.sql.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class SQLTest { - private static final String host = "master"; + private static final String host = "127.0.0.1"; private static Connection connection; diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java index ce84f967d09e2217bac90cc7a3f59bf4f50b2a15..c38958c6ceb50af5d3925003f34e5cc16c272b97 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java @@ -21,4 +21,5 @@ public class SqlSyntaxValidatorTest { Assert.assertTrue(SqlSyntaxValidator.isUseSql("drop database test")); Assert.assertTrue(SqlSyntaxValidator.isUseSql("drop database if exist test")); } + } \ No newline at end of file diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/TimeStampUtil.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/TimeStampUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..1c6af7e3d2f1fd36fa620ab4a4dec77636d92db4 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/TimeStampUtil.java @@ -0,0 +1,67 @@ +package com.taosdata.jdbc.utils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class TimeStampUtil { + + private static final String datetimeFormat = "yyyy-MM-dd HH:mm:ss.SSS"; + + public static long datetimeToLong(String dateTime) { + SimpleDateFormat sdf = new SimpleDateFormat(datetimeFormat); + try { + return sdf.parse(dateTime).getTime(); + } catch (ParseException e) { + throw new IllegalArgumentException("invalid datetime string >>> " + dateTime); + } + } + + public static String longToDatetime(long time) { + SimpleDateFormat sdf = new SimpleDateFormat(datetimeFormat); + return sdf.format(new Date(time)); + } + + public static class TimeTuple { + public Long start; + public Long end; + public Long timeGap; + + TimeTuple(long start, long end, long timeGap) { + this.start = start; + this.end = end; + this.timeGap = timeGap; + } + } + + public static TimeTuple range(long start, long timeGap, long size) { + long now = System.currentTimeMillis(); + if (timeGap < 1) + timeGap = 1; + if (start == 0) + start = now - size * timeGap; + + // 如果size小于1异常 + if (size < 1) + throw new IllegalArgumentException("size less than 1."); + // 如果timeGap为1,已经超长,需要前移start + if (start + size > now) { + start = now - size; + return new TimeTuple(start, now, 1); + } + long end = start + (long) (timeGap * size); + if (end > now) { + //压缩timeGap + end = now; + double gap = (end - start) / (size * 1.0f); + if (gap < 1.0f) { + timeGap = 1; + start = end - size; + } else { + timeGap = (long) gap; + end = start + (long) (timeGap * size); + } + } + return new TimeTuple(start, end, timeGap); + } +} diff --git a/src/connector/nodejs/nodetaos/cinterface.js b/src/connector/nodejs/nodetaos/cinterface.js index a246256f15f313b61c0b7e990e63848fee2431bf..43a08a800afe7aa3e445a943f8d7a7f95f1ed05f 100644 --- a/src/connector/nodejs/nodetaos/cinterface.js +++ b/src/connector/nodejs/nodetaos/cinterface.js @@ -3,15 +3,15 @@ * @module CTaosInterface */ -const ref = require('ref'); +const ref = require('ref-napi'); const os = require('os'); -const ffi = require('ffi'); -const ArrayType = require('ref-array'); -const Struct = require('ref-struct'); +const ffi = require('ffi-napi'); +const ArrayType = require('ref-array-napi'); +const Struct = require('ref-struct-napi'); const FieldTypes = require('./constants'); const errors = require ('./error'); const TaosObjects = require('./taosobjects'); -const { NULL_POINTER } = require('ref'); +const { NULL_POINTER } = require('ref-napi'); module.exports = CTaosInterface; diff --git a/src/connector/nodejs/nodetaos/cursor.js b/src/connector/nodejs/nodetaos/cursor.js index 0c9214fe32656fdfb7edb6cfc0d0c3587d4f7bb6..e18e6c2500019684dea85fe05bc7306e0a372478 100644 --- a/src/connector/nodejs/nodetaos/cursor.js +++ b/src/connector/nodejs/nodetaos/cursor.js @@ -1,4 +1,4 @@ -const ref = require('ref'); +const ref = require('ref-napi'); require('./globalfunc.js') const CTaosInterface = require('./cinterface') const errors = require ('./error') diff --git a/src/connector/nodejs/package-lock.json b/src/connector/nodejs/package-lock.json index d13fe6959c07955f5b15c7281f571ab932a996c3..9ca174ccd12f782b047789e44a6abce231b15ad0 100644 --- a/src/connector/nodejs/package-lock.json +++ b/src/connector/nodejs/package-lock.json @@ -1,44 +1,9 @@ { "name": "td2.0-connector", - "version": "2.0.1", + "version": "2.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { - "abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" - }, - "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", - "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" - }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" - }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, "array-index": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-index/-/array-index-1.0.0.tgz", @@ -46,104 +11,23 @@ "requires": { "debug": "^2.2.0", "es6-symbol": "^3.0.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } } }, - "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", - "requires": { - "safer-buffer": "~2.1.0" - } - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" - }, - "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, - "bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "requires": { - "tweetnacl": "^0.14.3" - } - }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "requires": { - "file-uri-to-path": "1.0.0" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" - }, - "chownr": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz", - "integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==" - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" - }, - "combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" - }, "d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", @@ -153,54 +37,22 @@ "type": "^1.0.1" } }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "requires": { - "assert-plus": "^1.0.0" - } - }, "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" - }, - "ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "requires": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" + "ms": "2.1.2" } }, - "env-paths": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-1.0.0.tgz", - "integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=" - }, "es5-ext": { - "version": "0.10.50", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.50.tgz", - "integrity": "sha512-KMzZTPBkeQV/JcSQhI5/z6d9VWJ3EnQ194USTUwIYZ2ZbpN8+SGXQKt1h68EX44+qt+Fzr8DO17vnxrw7c3agw==", + "version": "0.10.53", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", + "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", "requires": { "es6-iterator": "~2.0.3", - "es6-symbol": "~3.1.1", - "next-tick": "^1.0.0" + "es6-symbol": "~3.1.3", + "next-tick": "~1.0.0" } }, "es6-iterator": { @@ -214,631 +66,220 @@ } }, "es6-symbol": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", - "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", "requires": { - "d": "1", - "es5-ext": "~0.10.14" + "d": "^1.0.1", + "ext": "^1.1.2" } }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" - }, - "ffi": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/ffi/-/ffi-2.3.0.tgz", - "integrity": "sha512-vkPA9Hf9CVuQ5HeMZykYvrZF2QNJ/iKGLkyDkisBnoOOFeFXZQhUPxBARPBIZMJVulvBI2R+jgofW03gyPpJcQ==", + "ext": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz", + "integrity": "sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A==", "requires": { - "bindings": "~1.2.0", - "debug": "2", - "nan": "2", - "ref": "1", - "ref-struct": "1" + "type": "^2.0.0" }, "dependencies": { - "bindings": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", - "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" + "type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.1.0.tgz", + "integrity": "sha512-G9absDWvhAWCV2gmF1zKud3OyC61nZDwWvBL2DApaVFogI07CprggiQAOOjvp2NRjYWFzPyu7vwtDrQFq8jeSA==" } } }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" - }, - "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - }, - "fs-minipass": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", - "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", - "requires": { - "minipass": "^2.2.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "requires": { - "assert-plus": "^1.0.0" - } - }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", - "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==" - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" - }, - "har-validator": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", - "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "ffi-napi": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/ffi-napi/-/ffi-napi-3.1.0.tgz", + "integrity": "sha512-EsHO+sP2p/nUC/3l/l8m9niee1BLm4asUFDzkkBGR4kYVgp2KqdAYUomZhkKtzim4Fq7mcYHjpUaIHsMqs+E1g==", "requires": { - "ajv": "^6.5.5", - "har-schema": "^2.0.0" + "debug": "^4.1.1", + "get-uv-event-loop-napi-h": "^1.0.5", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.1", + "ref-napi": "^2.0.1", + "ref-struct-di": "^1.1.0" + }, + "dependencies": { + "ref-napi": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-2.1.2.tgz", + "integrity": "sha512-aFl+vrIuLWUXMUTQGAwGAuSNLX3Ub5W3iVP8b7KyFFZUdn4+i4U1TXXTop0kCTUfGNu8glBGVz4lowkwMcPVVA==", + "requires": { + "debug": "^4.1.1", + "get-symbol-from-current-process-h": "^1.0.2", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.1" + } + } } }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } + "get-symbol-from-current-process-h": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/get-symbol-from-current-process-h/-/get-symbol-from-current-process-h-1.0.2.tgz", + "integrity": "sha512-syloC6fsCt62ELLrr1VKBM1ggOpMdetX9hTrdW77UQdcApPHLmf7CI7OKcN1c9kYuNxKcDe4iJ4FY9sX3aw2xw==" }, - "inflight": { + "get-uv-event-loop-napi-h": { "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "resolved": "https://registry.npmjs.org/get-uv-event-loop-napi-h/-/get-uv-event-loop-napi-h-1.0.6.tgz", + "integrity": "sha512-t5c9VNR84nRoF+eLiz6wFrEp1SE2Acg0wS+Ysa2zF0eROes+LzOfuTaVHxGy8AbS8rq7FHEJzjnCZo1BupwdJg==", "requires": { - "number-is-nan": "^1.0.0" - } - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, - "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" - }, - "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", - "requires": { - "mime-db": "1.40.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" - }, - "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", - "requires": { - "minipass": "^2.2.1" - } - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { - "minimist": "0.0.8" + "get-symbol-from-current-process-h": "^1.0.1" } }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" }, - "node-gyp": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.2.tgz", - "integrity": "sha512-sNcb5O7eJ9XiNAhWZ/UE2bWsBJn3Jb7rayMqMP4wjenlr1DwzZxUmbtmIrl04EU0p5fN2rU9WIDV+u0EbsI8oQ==", - "requires": { - "env-paths": "^1.0.0", - "glob": "^7.0.3", - "graceful-fs": "^4.1.2", - "mkdirp": "^0.5.0", - "nopt": "2 || 3", - "npmlog": "0 || 1 || 2 || 3 || 4", - "request": "^2.87.0", - "rimraf": "2", - "semver": "~5.3.0", - "tar": "^4.4.8", - "which": "1" - } - }, - "nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", - "requires": { - "abbrev": "1" - } - }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "psl": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.2.0.tgz", - "integrity": "sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA==" - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + "node-addon-api": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", + "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" }, - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + "node-gyp-build": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", + "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==" }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "ref": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ref/-/ref-1.3.5.tgz", - "integrity": "sha512-2cBCniTtxcGUjDpvFfVpw323a83/0RLSGJJY5l5lcomZWhYpU2cuLdsvYqMixvsdLJ9+sTdzEkju8J8ZHDM2nA==", - "requires": { - "bindings": "1", - "debug": "2", - "nan": "2" - } - }, - "ref-array": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/ref-array/-/ref-array-1.2.0.tgz", - "integrity": "sha1-u6hwFS1O4KvtFCGwYjkvCwGEKQw=", + "ref-array-napi": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ref-array-napi/-/ref-array-napi-1.2.1.tgz", + "integrity": "sha512-jQp2WWSucmxkqVfoNfm7yDlDeGu3liAbzqfwjNybL80ooLOCnCZpAK2woDInY+lxNOK/VlIVSqeDEYb4gVPuNQ==", "requires": { "array-index": "1", "debug": "2", - "ref": "1" - } - }, - "ref-struct": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ref-struct/-/ref-struct-1.1.0.tgz", - "integrity": "sha1-XV7mWtQc78Olxf60BYcmHkee3BM=", - "requires": { - "debug": "2", - "ref": "1" - } - }, - "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", - "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.0", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - } - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "requires": { - "glob": "^7.1.3" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "semver": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=" - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" - }, - "sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" + "ref-napi": "^1.4.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "ref-napi": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-1.5.2.tgz", + "integrity": "sha512-hwyNmWpUkt1bDWDW4aiwCoC+SJfJO69UIdjqssNqdaS0sYJpgqzosGg/rLtk69UoQ8drZdI9yyQefM7eEMM3Gw==", + "requires": { + "debug": "^3.1.0", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.1" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + } + } + } } }, - "strip-ansi": { + "ref-napi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "tar": { - "version": "4.4.10", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.10.tgz", - "integrity": "sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==", + "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-3.0.1.tgz", + "integrity": "sha512-W3rcb0E+tlO9u9ySFnX5vifInwwPGToOfFgTZUHJBNiOBsW0NNvgHz2zJN7ctABo/2yIlgdPQUvuqqfORIF4LA==", "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.5", - "minizlib": "^1.2.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.3" + "debug": "^4.1.1", + "get-symbol-from-current-process-h": "^1.0.2", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.1" } }, - "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "ref-struct-di": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.1.tgz", + "integrity": "sha512-2Xyn/0Qgz89VT+++WP0sTosdm9oeowLP23wRJYhG4BFdMUrLj3jhwHZNEytYNYgtPKLNTP3KJX4HEgBvM1/Y2g==", "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" + "debug": "^3.1.0" }, "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "requires": { + "ms": "^2.1.1" + } } } }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "ref-struct-napi": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ref-struct-napi/-/ref-struct-napi-1.1.1.tgz", + "integrity": "sha512-YgS5/d7+kT5zgtySYI5ieH0hREdv+DabgDvoczxsui0f9VLm0rrDcWEj4DHKehsH+tJnVMsLwuyctWgvdEcVRw==", "requires": { - "safe-buffer": "^5.0.1" + "debug": "2", + "ref-napi": "^1.4.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "ref-napi": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-1.5.2.tgz", + "integrity": "sha512-hwyNmWpUkt1bDWDW4aiwCoC+SJfJO69UIdjqssNqdaS0sYJpgqzosGg/rLtk69UoQ8drZdI9yyQefM7eEMM3Gw==", + "requires": { + "debug": "^3.1.0", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.1" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + } + } + } } }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" - }, "type": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/type/-/type-1.0.1.tgz", - "integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw==" - }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "requires": { - "punycode": "^2.1.0" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "requires": { - "isexe": "^2.0.0" - } - }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" } } } diff --git a/src/connector/nodejs/package.json b/src/connector/nodejs/package.json index 5587a69e01e6743a7eb7ef234d111c86db246841..b39ce2c17d8e693d0e981885aed55ba1b82313b6 100644 --- a/src/connector/nodejs/package.json +++ b/src/connector/nodejs/package.json @@ -1,31 +1,34 @@ { "name": "td2.0-connector", - "version": "2.0.5", + "version": "2.0.6", "description": "A Node.js connector for TDengine.", "main": "tdengine.js", + "directories": { + "test": "test" + }, "scripts": { "test": "node test/test.js" }, + "repository": { + "type": "git", + "url": "git+https://github.com/taosdata/tdengine.git" + }, "keywords": [ "TDengine", "TAOS Data", "Time Series Database", "Connector" ], - "author": "StoneT2000", - "license": "AGPL-3.0", - "dependencies": { - "ffi": "^2.3.0", - "node-gyp": "^5.0.2", - "ref": "^1.3.5", - "ref-array": "^1.2.0" - }, - "homepage": "https://github.com/taosdata/tdengine", + "author": "TaosData Inc.", + "license": "AGPL-3.0-or-later", "bugs": { "url": "https://github.com/taosdata/tdengine/issues" }, - "repository": { - "type": "git", - "url": "https://github.com/taosdata/tdengine.git" + "homepage": "https://github.com/taosdata/tdengine#readme", + "dependencies": { + "ffi-napi": "^3.1.0", + "ref-array-napi": "^1.2.1", + "ref-napi": "^1.5.2", + "ref-struct-napi": "^1.1.1" } } diff --git a/src/dnode/src/dnodeTelemetry.c b/src/dnode/src/dnodeTelemetry.c index ff9598ecc563ac48bac051027385ab188e94ce75..c63536818a69e658e8ca229b936bf2a6e8bfb526 100644 --- a/src/dnode/src/dnodeTelemetry.c +++ b/src/dnode/src/dnodeTelemetry.c @@ -291,7 +291,7 @@ int32_t dnodeInitTelemetry() { int32_t code = pthread_create(&tsTelemetryThread, &attr, telemetryThread, NULL); pthread_attr_destroy(&attr); if (code != 0) { - dTrace("failed to create telemetry thread, reason:%s", strerror(errno)); + dTrace("failed to create telemetry thread, reason:%s", strerror(code)); } dInfo("dnode telemetry is initialized"); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 4582efbc407c4d6c66d9bedf22e3b2b2d9123970..5b31fbf292804962dce1144335d4b33656e30023 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -268,8 +268,7 @@ typedef struct { typedef struct { int32_t len; // one create table message - char tableFname[TSDB_TABLE_FNAME_LEN]; - char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; + char tableName[TSDB_TABLE_FNAME_LEN]; int8_t igExists; int8_t getMeta; int16_t numOfTags; @@ -285,7 +284,7 @@ typedef struct { } SCMCreateTableMsg; typedef struct { - char tableFname[TSDB_TABLE_FNAME_LEN]; + char name[TSDB_TABLE_FNAME_LEN]; int8_t igNotExists; } SCMDropTableMsg; diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index dae886189b1e67b789ccdaa8e44afe2cca0a697b..95e6b7ff4a9208cb37f04e00b3137552a79292d9 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -114,6 +114,8 @@ void* tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type, int16_ char* tsdbGetTableName(void *pTable); #define TSDB_TABLEID(_table) ((STableId*) (_table)) +#define TSDB_PREV_ROW 0x1 +#define TSDB_NEXT_ROW 0x2 STableCfg *tsdbCreateTableCfgFromMsg(SMDCreateTableMsg *pMsg); @@ -141,7 +143,6 @@ typedef struct { int64_t tableTotalDataSize; // In bytes int64_t tableTotalDiskSize; // In bytes } STableInfo; -STableInfo *tsdbGetTableInfo(TSDB_REPO_T *pRepo, STableId tid); // -- FOR INSERT DATA /** @@ -160,9 +161,10 @@ typedef void *TsdbQueryHandleT; // Use void to hide implementation details // query condition to build vnode iterator typedef struct STsdbQueryCond { STimeWindow twindow; - int32_t order; // desc|asc order to iterate the data block + int32_t order; // desc|asc order to iterate the data block int32_t numOfCols; SColumnInfo *colList; + bool loadExternalRows; // load external rows or not } STsdbQueryCond; typedef struct SMemRef { @@ -257,6 +259,8 @@ bool tsdbNextDataBlock(TsdbQueryHandleT *pQueryHandle); */ bool tsdbNextDataBlockWithoutMerge(TsdbQueryHandleT *pQueryHandle); +SArray* tsdbGetExternalRow(TsdbQueryHandleT *pHandle, SMemRef* pMemRef, int16_t type); + /** * Get current data block information * diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index 09500fc8c575c8660076e0ef5093a1590e49f90f..dde74f4eb1c5ad9640a20fd21b1109441a53d87b 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -82,145 +82,145 @@ #define TK_STABLES 64 #define TK_VGROUPS 65 #define TK_DROP 66 -#define TK_DNODE 67 -#define TK_USER 68 -#define TK_ACCOUNT 69 -#define TK_USE 70 -#define TK_DESCRIBE 71 -#define TK_ALTER 72 -#define TK_PASS 73 -#define TK_PRIVILEGE 74 -#define TK_LOCAL 75 -#define TK_IF 76 -#define TK_EXISTS 77 -#define TK_PPS 78 -#define TK_TSERIES 79 -#define TK_DBS 80 -#define TK_STORAGE 81 -#define TK_QTIME 82 -#define TK_CONNS 83 -#define TK_STATE 84 -#define TK_KEEP 85 -#define TK_CACHE 86 -#define TK_REPLICA 87 -#define TK_QUORUM 88 -#define TK_DAYS 89 -#define TK_MINROWS 90 -#define TK_MAXROWS 91 -#define TK_BLOCKS 92 -#define TK_CTIME 93 -#define TK_WAL 94 -#define TK_FSYNC 95 -#define TK_COMP 96 -#define TK_PRECISION 97 -#define TK_UPDATE 98 -#define TK_CACHELAST 99 -#define TK_LP 100 -#define TK_RP 101 -#define TK_UNSIGNED 102 -#define TK_TAGS 103 -#define TK_USING 104 -#define TK_AS 105 -#define TK_COMMA 106 -#define TK_NULL 107 -#define TK_SELECT 108 -#define TK_UNION 109 -#define TK_ALL 110 -#define TK_FROM 111 -#define TK_VARIABLE 112 -#define TK_INTERVAL 113 -#define TK_FILL 114 -#define TK_SLIDING 115 -#define TK_ORDER 116 -#define TK_BY 117 -#define TK_ASC 118 -#define TK_DESC 119 -#define TK_GROUP 120 -#define TK_HAVING 121 -#define TK_LIMIT 122 -#define TK_OFFSET 123 -#define TK_SLIMIT 124 -#define TK_SOFFSET 125 -#define TK_WHERE 126 -#define TK_NOW 127 -#define TK_RESET 128 -#define TK_QUERY 129 -#define TK_ADD 130 -#define TK_COLUMN 131 -#define TK_TAG 132 -#define TK_CHANGE 133 -#define TK_SET 134 -#define TK_KILL 135 -#define TK_CONNECTION 136 -#define TK_STREAM 137 -#define TK_COLON 138 -#define TK_ABORT 139 -#define TK_AFTER 140 -#define TK_ATTACH 141 -#define TK_BEFORE 142 -#define TK_BEGIN 143 -#define TK_CASCADE 144 -#define TK_CLUSTER 145 -#define TK_CONFLICT 146 -#define TK_COPY 147 -#define TK_DEFERRED 148 -#define TK_DELIMITERS 149 -#define TK_DETACH 150 -#define TK_EACH 151 -#define TK_END 152 -#define TK_EXPLAIN 153 -#define TK_FAIL 154 -#define TK_FOR 155 -#define TK_IGNORE 156 -#define TK_IMMEDIATE 157 -#define TK_INITIALLY 158 -#define TK_INSTEAD 159 -#define TK_MATCH 160 -#define TK_KEY 161 -#define TK_OF 162 -#define TK_RAISE 163 -#define TK_REPLACE 164 -#define TK_RESTRICT 165 -#define TK_ROW 166 -#define TK_STATEMENT 167 -#define TK_TRIGGER 168 -#define TK_VIEW 169 -#define TK_COUNT 170 -#define TK_SUM 171 -#define TK_AVG 172 -#define TK_MIN 173 -#define TK_MAX 174 -#define TK_FIRST 175 -#define TK_LAST 176 -#define TK_TOP 177 -#define TK_BOTTOM 178 -#define TK_STDDEV 179 -#define TK_PERCENTILE 180 -#define TK_APERCENTILE 181 -#define TK_LEASTSQUARES 182 -#define TK_HISTOGRAM 183 -#define TK_DIFF 184 -#define TK_SPREAD 185 -#define TK_TWA 186 -#define TK_INTERP 187 -#define TK_LAST_ROW 188 -#define TK_RATE 189 -#define TK_IRATE 190 -#define TK_SUM_RATE 191 -#define TK_SUM_IRATE 192 -#define TK_AVG_RATE 193 -#define TK_AVG_IRATE 194 -#define TK_TBID 195 -#define TK_SEMI 196 -#define TK_NONE 197 -#define TK_PREV 198 -#define TK_LINEAR 199 -#define TK_IMPORT 200 -#define TK_METRIC 201 -#define TK_TBNAME 202 -#define TK_JOIN 203 -#define TK_METRICS 204 -#define TK_STABLE 205 +#define TK_STABLE 67 +#define TK_DNODE 68 +#define TK_USER 69 +#define TK_ACCOUNT 70 +#define TK_USE 71 +#define TK_DESCRIBE 72 +#define TK_ALTER 73 +#define TK_PASS 74 +#define TK_PRIVILEGE 75 +#define TK_LOCAL 76 +#define TK_IF 77 +#define TK_EXISTS 78 +#define TK_PPS 79 +#define TK_TSERIES 80 +#define TK_DBS 81 +#define TK_STORAGE 82 +#define TK_QTIME 83 +#define TK_CONNS 84 +#define TK_STATE 85 +#define TK_KEEP 86 +#define TK_CACHE 87 +#define TK_REPLICA 88 +#define TK_QUORUM 89 +#define TK_DAYS 90 +#define TK_MINROWS 91 +#define TK_MAXROWS 92 +#define TK_BLOCKS 93 +#define TK_CTIME 94 +#define TK_WAL 95 +#define TK_FSYNC 96 +#define TK_COMP 97 +#define TK_PRECISION 98 +#define TK_UPDATE 99 +#define TK_CACHELAST 100 +#define TK_LP 101 +#define TK_RP 102 +#define TK_UNSIGNED 103 +#define TK_TAGS 104 +#define TK_USING 105 +#define TK_AS 106 +#define TK_COMMA 107 +#define TK_NULL 108 +#define TK_SELECT 109 +#define TK_UNION 110 +#define TK_ALL 111 +#define TK_FROM 112 +#define TK_VARIABLE 113 +#define TK_INTERVAL 114 +#define TK_FILL 115 +#define TK_SLIDING 116 +#define TK_ORDER 117 +#define TK_BY 118 +#define TK_ASC 119 +#define TK_DESC 120 +#define TK_GROUP 121 +#define TK_HAVING 122 +#define TK_LIMIT 123 +#define TK_OFFSET 124 +#define TK_SLIMIT 125 +#define TK_SOFFSET 126 +#define TK_WHERE 127 +#define TK_NOW 128 +#define TK_RESET 129 +#define TK_QUERY 130 +#define TK_ADD 131 +#define TK_COLUMN 132 +#define TK_TAG 133 +#define TK_CHANGE 134 +#define TK_SET 135 +#define TK_KILL 136 +#define TK_CONNECTION 137 +#define TK_STREAM 138 +#define TK_COLON 139 +#define TK_ABORT 140 +#define TK_AFTER 141 +#define TK_ATTACH 142 +#define TK_BEFORE 143 +#define TK_BEGIN 144 +#define TK_CASCADE 145 +#define TK_CLUSTER 146 +#define TK_CONFLICT 147 +#define TK_COPY 148 +#define TK_DEFERRED 149 +#define TK_DELIMITERS 150 +#define TK_DETACH 151 +#define TK_EACH 152 +#define TK_END 153 +#define TK_EXPLAIN 154 +#define TK_FAIL 155 +#define TK_FOR 156 +#define TK_IGNORE 157 +#define TK_IMMEDIATE 158 +#define TK_INITIALLY 159 +#define TK_INSTEAD 160 +#define TK_MATCH 161 +#define TK_KEY 162 +#define TK_OF 163 +#define TK_RAISE 164 +#define TK_REPLACE 165 +#define TK_RESTRICT 166 +#define TK_ROW 167 +#define TK_STATEMENT 168 +#define TK_TRIGGER 169 +#define TK_VIEW 170 +#define TK_COUNT 171 +#define TK_SUM 172 +#define TK_AVG 173 +#define TK_MIN 174 +#define TK_MAX 175 +#define TK_FIRST 176 +#define TK_LAST 177 +#define TK_TOP 178 +#define TK_BOTTOM 179 +#define TK_STDDEV 180 +#define TK_PERCENTILE 181 +#define TK_APERCENTILE 182 +#define TK_LEASTSQUARES 183 +#define TK_HISTOGRAM 184 +#define TK_DIFF 185 +#define TK_SPREAD 186 +#define TK_TWA 187 +#define TK_INTERP 188 +#define TK_LAST_ROW 189 +#define TK_RATE 190 +#define TK_IRATE 191 +#define TK_SUM_RATE 192 +#define TK_SUM_IRATE 193 +#define TK_AVG_RATE 194 +#define TK_AVG_IRATE 195 +#define TK_TBID 196 +#define TK_SEMI 197 +#define TK_NONE 198 +#define TK_PREV 199 +#define TK_LINEAR 200 +#define TK_IMPORT 201 +#define TK_METRIC 202 +#define TK_TBNAME 203 +#define TK_JOIN 204 +#define TK_METRICS 205 #define TK_INSERT 206 #define TK_INTO 207 #define TK_VALUES 208 diff --git a/src/inc/ttype.h b/src/inc/ttype.h index 686c986f5bba65d3c1313cca46047b6dc832e568..05622a16bee29b1cf023fbbe0fa104fac32d5fbf 100644 --- a/src/inc/ttype.h +++ b/src/inc/ttype.h @@ -45,6 +45,7 @@ typedef struct tstr { case TSDB_DATA_TYPE_USMALLINT: \ (_v) = (_finalType)GET_UINT16_VAL(_data); \ break; \ + case TSDB_DATA_TYPE_TIMESTAMP:\ case TSDB_DATA_TYPE_BIGINT: \ (_v) = (_finalType)(GET_INT64_VAL(_data)); \ break; \ @@ -66,6 +67,43 @@ typedef struct tstr { } \ } while (0) +#define SET_TYPED_DATA(_v, _type, _data) \ + do { \ + switch (_type) { \ + case TSDB_DATA_TYPE_BOOL: \ + case TSDB_DATA_TYPE_TINYINT: \ + *(int8_t *)(_v) = (int8_t)(_data); \ + break; \ + case TSDB_DATA_TYPE_UTINYINT: \ + *(uint8_t *)(_v) = (uint8_t)(_data); \ + break; \ + case TSDB_DATA_TYPE_SMALLINT: \ + *(int16_t *)(_v) = (int16_t)(_data); \ + break; \ + case TSDB_DATA_TYPE_USMALLINT: \ + *(uint16_t *)(_v) = (uint16_t)(_data); \ + break; \ + case TSDB_DATA_TYPE_BIGINT: \ + *(int64_t *)(_v) = (int64_t)(_data); \ + break; \ + case TSDB_DATA_TYPE_UBIGINT: \ + *(uint64_t *)(_v) = (uint64_t)(_data); \ + break; \ + case TSDB_DATA_TYPE_FLOAT: \ + *(float *)(_v) = (float)(_data); \ + break; \ + case TSDB_DATA_TYPE_DOUBLE: \ + *(double *)(_v) = (double)(_data); \ + break; \ + case TSDB_DATA_TYPE_UINT: \ + *(uint32_t *)(_v) = (uint32_t)(_data); \ + break; \ + default: \ + *(int32_t *)(_v) = (int32_t)(_data); \ + break; \ + } \ + } while (0) + #define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT) #define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT) #define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE) diff --git a/src/kit/taosdemox/taosdemox.c b/src/kit/taosdemox/taosdemox.c index 2968d653313c56ffc1842969cadfcc1458fef4a4..a6d962df55670d7b188cfe4ffcf2df9a4be3594a 100644 --- a/src/kit/taosdemox/taosdemox.c +++ b/src/kit/taosdemox/taosdemox.c @@ -4507,6 +4507,7 @@ void setParaFromArg(){ strncpy(g_Dbs.db[0].superTbls[0].sTblName, "meters", MAX_TB_NAME_SIZE); g_Dbs.db[0].superTbls[0].childTblCount = g_args.num_of_tables; g_Dbs.threadCount = g_args.num_of_threads; + g_Dbs.threadCountByCreateTbl = 1; g_Dbs.queryMode = g_args.mode; g_Dbs.db[0].superTbls[0].autoCreateTable = PRE_CREATE_SUBTBL; diff --git a/src/mnode/inc/mnodeDb.h b/src/mnode/inc/mnodeDb.h index 9354b923d74de055d3905ebe6581d3f721630b08..d03ba8d717a13cc943f2494dc0dca0d59d108b6f 100644 --- a/src/mnode/inc/mnodeDb.h +++ b/src/mnode/inc/mnodeDb.h @@ -32,7 +32,7 @@ int32_t mnodeInitDbs(); void mnodeCleanupDbs(); int64_t mnodeGetDbNum(); SDbObj *mnodeGetDb(char *db); -SDbObj *mnodeGetDbByTableId(char *db); +SDbObj *mnodeGetDbByTableName(char *db); void * mnodeGetNextDb(void *pIter, SDbObj **pDb); void mnodeCancelGetNextDb(void *pIter); void mnodeIncDbRef(SDbObj *pDb); diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index fbcad151bc5f8f7f9168e12db02059b0c86d0f2c..d9ed22a567710ecabe9f9a74f5d31a65d99aa7bf 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -199,18 +199,13 @@ void mnodeDecDbRef(SDbObj *pDb) { return sdbDecRef(tsDbSdb, pDb); } -SDbObj *mnodeGetDbByTableId(char *tableId) { - char db[TSDB_TABLE_FNAME_LEN], *pos; - - // tableId format should be : acct.db.table - pos = strstr(tableId, TS_PATH_DELIMITER); - assert(NULL != pos); - - pos = strstr(pos + 1, TS_PATH_DELIMITER); - assert(NULL != pos); - - memset(db, 0, sizeof(db)); - strncpy(db, tableId, pos - tableId); +SDbObj *mnodeGetDbByTableName(char *tableName) { + SName name = {0}; + tNameFromString(&name, tableName, T_NAME_ACCT|T_NAME_DB|T_NAME_TABLE); + + // validate the tableName? + char db[TSDB_TABLE_FNAME_LEN] = {0}; + tNameGetFullDbName(&name, db); return mnodeGetDb(db); } diff --git a/src/mnode/src/mnodeProfile.c b/src/mnode/src/mnodeProfile.c index 7c35829f88f4e7d1753a3ee00b13a9f87d03ae48..89dc32f03a8d63592bf34ba7e0e44566e9bcb92a 100644 --- a/src/mnode/src/mnodeProfile.c +++ b/src/mnode/src/mnodeProfile.c @@ -385,12 +385,22 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v SConnObj *pConnObj = NULL; int32_t cols = 0; char * pWrite; + void * pIter; char str[TSDB_IPv4ADDR_LEN + 6] = {0}; while (numOfRows < rows) { - pShow->pIter = mnodeGetNextConn(pShow->pIter, &pConnObj); - if (pConnObj == NULL) break; + pIter = mnodeGetNextConn(pShow->pIter, &pConnObj); + if (pConnObj == NULL) { + pShow->pIter = pIter; + break; + } + + if (numOfRows + pConnObj->numOfQueries >= rows) { + mnodeCancelGetNextConn(pIter); + break; + } + pShow->pIter = pIter; for (int32_t i = 0; i < pConnObj->numOfQueries; ++i) { SQueryDesc *pDesc = pConnObj->pQueries + i; cols = 0; @@ -518,12 +528,22 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v SConnObj *pConnObj = NULL; int32_t cols = 0; char * pWrite; + void * pIter; char ipStr[TSDB_IPv4ADDR_LEN + 6]; while (numOfRows < rows) { - pShow->pIter = mnodeGetNextConn(pShow->pIter, &pConnObj); - if (pConnObj == NULL) break; + pIter = mnodeGetNextConn(pShow->pIter, &pConnObj); + if (pConnObj == NULL) { + pShow->pIter = pIter; + break; + } + + if (numOfRows + pConnObj->numOfStreams >= rows) { + mnodeCancelGetNextConn(pIter); + break; + } + pShow->pIter = pIter; for (int32_t i = 0; i < pConnObj->numOfStreams; ++i) { SStreamDesc *pDesc = pConnObj->pStreams + i; cols = 0; diff --git a/src/mnode/src/mnodeRead.c b/src/mnode/src/mnodeRead.c index 200f589b7866d3fa6cf9865be397935657d7ba86..dadd8155d8648244dba762afec63bfc6f2ac3721 100644 --- a/src/mnode/src/mnodeRead.c +++ b/src/mnode/src/mnodeRead.c @@ -50,6 +50,9 @@ int32_t mnodeProcessRead(SMnodeMsg *pMsg) { if (!sdbIsMaster()) { SMnodeRsp *rpcRsp = &pMsg->rpcRsp; SRpcEpSet *epSet = rpcMallocCont(sizeof(SRpcEpSet)); + if (!epSet) { + return TSDB_CODE_MND_OUT_OF_MEMORY; + } mnodeGetMnodeEpSetForShell(epSet, true); rpcRsp->rsp = epSet; rpcRsp->len = sizeof(SRpcEpSet); diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index bdf5a7fb8bdbd794cce217a1a5a900aed5b4fefd..4229a4ce6e42480d26ee8e2dc0d60a2536371202 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -297,7 +297,7 @@ static int32_t mnodeChildTableActionRestored() { pIter = mnodeGetNextChildTable(pIter, &pTable); if (pTable == NULL) break; - SDbObj *pDb = mnodeGetDbByTableId(pTable->info.tableId); + SDbObj *pDb = mnodeGetDbByTableName(pTable->info.tableId); if (pDb == NULL || pDb->status != TSDB_DB_STATUS_READY) { mError("ctable:%s, failed to get db or db in dropping, discard it", pTable->info.tableId); SSdbRow desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .pTable = tsChildTableSdb}; @@ -443,7 +443,7 @@ static int32_t mnodeSuperTableActionDestroy(SSdbRow *pRow) { static int32_t mnodeSuperTableActionInsert(SSdbRow *pRow) { SSTableObj *pStable = pRow->pObj; - SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId); + SDbObj *pDb = mnodeGetDbByTableName(pStable->info.tableId); if (pDb != NULL && pDb->status == TSDB_DB_STATUS_READY) { mnodeAddSuperTableIntoDb(pDb); } @@ -455,7 +455,7 @@ static int32_t mnodeSuperTableActionInsert(SSdbRow *pRow) { static int32_t mnodeSuperTableActionDelete(SSdbRow *pRow) { SSTableObj *pStable = pRow->pObj; - SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId); + SDbObj *pDb = mnodeGetDbByTableName(pStable->info.tableId); if (pDb != NULL) { mnodeRemoveSuperTableFromDb(pDb); mnodeDropAllChildTablesInStable((SSTableObj *)pStable); @@ -748,9 +748,12 @@ void mnodeDestroySubMsg(SMnodeMsg *pSubMsg) { } static int32_t mnodeValidateCreateTableMsg(SCreateTableMsg *pCreateTable, SMnodeMsg *pMsg) { - if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(pCreateTable->db); if (pMsg->pDb == NULL) { - mError("msg:%p, app:%p table:%s, failed to create, db not selected", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableFname); + pMsg->pDb = mnodeGetDbByTableName(pCreateTable->tableName); + } + + if (pMsg->pDb == NULL) { + mError("msg:%p, app:%p table:%s, failed to create, db not selected", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableName); return TSDB_CODE_MND_DB_NOT_SELECTED; } @@ -759,28 +762,28 @@ static int32_t mnodeValidateCreateTableMsg(SCreateTableMsg *pCreateTable, SMnode return TSDB_CODE_MND_DB_IN_DROPPING; } - if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreateTable->tableFname); + if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreateTable->tableName); if (pMsg->pTable != NULL && pMsg->retry == 0) { if (pCreateTable->getMeta) { - mDebug("msg:%p, app:%p table:%s, continue to get meta", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableFname); + mDebug("msg:%p, app:%p table:%s, continue to get meta", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableName); return mnodeGetChildTableMeta(pMsg); } else if (pCreateTable->igExists) { - mDebug("msg:%p, app:%p table:%s, is already exist", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableFname); + mDebug("msg:%p, app:%p table:%s, is already exist", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableName); return TSDB_CODE_SUCCESS; } else { mError("msg:%p, app:%p table:%s, failed to create, table already exist", pMsg, pMsg->rpcMsg.ahandle, - pCreateTable->tableFname); + pCreateTable->tableName); return TSDB_CODE_MND_TABLE_ALREADY_EXIST; } } if (pCreateTable->numOfTags != 0) { mDebug("msg:%p, app:%p table:%s, create stable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle, - pCreateTable->tableFname, pMsg->rpcMsg.handle); + pCreateTable->tableName, pMsg->rpcMsg.handle); return mnodeProcessCreateSuperTableMsg(pMsg); } else { mDebug("msg:%p, app:%p table:%s, create ctable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle, - pCreateTable->tableFname, pMsg->rpcMsg.handle); + pCreateTable->tableName, pMsg->rpcMsg.handle); return mnodeProcessCreateChildTableMsg(pMsg); } } @@ -860,9 +863,12 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) { } SCreateTableMsg *p = (SCreateTableMsg*)((char*) pCreate + sizeof(SCMCreateTableMsg)); - if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(p->db); if (pMsg->pDb == NULL) { - mError("msg:%p, app:%p table:%s, failed to create, db not selected", pMsg, pMsg->rpcMsg.ahandle, p->tableFname); + pMsg->pDb = mnodeGetDbByTableName(p->tableName); + } + + if (pMsg->pDb == NULL) { + mError("msg:%p, app:%p table:%s, failed to create, db not selected", pMsg, pMsg->rpcMsg.ahandle, p->tableName); return TSDB_CODE_MND_DB_NOT_SELECTED; } @@ -871,37 +877,37 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) { return TSDB_CODE_MND_DB_IN_DROPPING; } - if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(p->tableFname); + if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(p->tableName); if (pMsg->pTable != NULL && pMsg->retry == 0) { if (p->getMeta) { - mDebug("msg:%p, app:%p table:%s, continue to get meta", pMsg, pMsg->rpcMsg.ahandle, p->tableFname); + mDebug("msg:%p, app:%p table:%s, continue to get meta", pMsg, pMsg->rpcMsg.ahandle, p->tableName); return mnodeGetChildTableMeta(pMsg); } else if (p->igExists) { - mDebug("msg:%p, app:%p table:%s, is already exist", pMsg, pMsg->rpcMsg.ahandle, p->tableFname); + mDebug("msg:%p, app:%p table:%s, is already exist", pMsg, pMsg->rpcMsg.ahandle, p->tableName); return TSDB_CODE_SUCCESS; } else { - mError("msg:%p, app:%p table:%s, failed to create, table already exist", pMsg, pMsg->rpcMsg.ahandle, p->tableFname); + mError("msg:%p, app:%p table:%s, failed to create, table already exist", pMsg, pMsg->rpcMsg.ahandle, p->tableName); return TSDB_CODE_MND_TABLE_ALREADY_EXIST; } } if (p->numOfTags != 0) { mDebug("msg:%p, app:%p table:%s, create stable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle, - p->tableFname, pMsg->rpcMsg.handle); + p->tableName, pMsg->rpcMsg.handle); return mnodeProcessCreateSuperTableMsg(pMsg); } else { mDebug("msg:%p, app:%p table:%s, create ctable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle, - p->tableFname, pMsg->rpcMsg.handle); + p->tableName, pMsg->rpcMsg.handle); return mnodeProcessCreateChildTableMsg(pMsg); } } static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) { SCMDropTableMsg *pDrop = pMsg->rpcMsg.pCont; - if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(pDrop->tableFname); + if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableName(pDrop->name); if (pMsg->pDb == NULL) { mError("msg:%p, app:%p table:%s, failed to drop table, db not selected or db in dropping", pMsg, - pMsg->rpcMsg.ahandle, pDrop->tableFname); + pMsg->rpcMsg.ahandle, pDrop->name); return TSDB_CODE_MND_DB_NOT_SELECTED; } @@ -912,17 +918,17 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) { if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) { mError("msg:%p, app:%p table:%s, failed to drop table, in monitor database", pMsg, pMsg->rpcMsg.ahandle, - pDrop->tableFname); + pDrop->name); return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN; } - if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pDrop->tableFname); + if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pDrop->name); if (pMsg->pTable == NULL) { if (pDrop->igNotExists) { - mDebug("msg:%p, app:%p table:%s is not exist, treat as success", pMsg, pMsg->rpcMsg.ahandle, pDrop->tableFname); + mDebug("msg:%p, app:%p table:%s is not exist, treat as success", pMsg, pMsg->rpcMsg.ahandle, pDrop->name); return TSDB_CODE_SUCCESS; } else { - mError("msg:%p, app:%p table:%s, failed to drop, table not exist", pMsg, pMsg->rpcMsg.ahandle, pDrop->tableFname); + mError("msg:%p, app:%p table:%s, failed to drop, table not exist", pMsg, pMsg->rpcMsg.ahandle, pDrop->name); return TSDB_CODE_MND_INVALID_TABLE_NAME; } } @@ -930,12 +936,12 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) { if (pMsg->pTable->type == TSDB_SUPER_TABLE) { SSTableObj *pSTable = (SSTableObj *)pMsg->pTable; mInfo("msg:%p, app:%p table:%s, start to drop stable, uid:%" PRIu64 ", numOfChildTables:%d, sizeOfVgList:%d", pMsg, - pMsg->rpcMsg.ahandle, pDrop->tableFname, pSTable->uid, pSTable->numOfTables, taosHashGetSize(pSTable->vgHash)); + pMsg->rpcMsg.ahandle, pDrop->name, pSTable->uid, pSTable->numOfTables, taosHashGetSize(pSTable->vgHash)); return mnodeProcessDropSuperTableMsg(pMsg); } else { SCTableObj *pCTable = (SCTableObj *)pMsg->pTable; mInfo("msg:%p, app:%p table:%s, start to drop ctable, vgId:%d tid:%d uid:%" PRIu64, pMsg, pMsg->rpcMsg.ahandle, - pDrop->tableFname, pCTable->vgId, pCTable->tid, pCTable->uid); + pDrop->name, pCTable->vgId, pCTable->tid, pCTable->uid); return mnodeProcessDropChildTableMsg(pMsg); } } @@ -946,7 +952,7 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) { mDebug("msg:%p, app:%p table:%s, table meta msg is received from thandle:%p, createFlag:%d", pMsg, pMsg->rpcMsg.ahandle, pInfo->tableFname, pMsg->rpcMsg.handle, pInfo->createFlag); - if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(pInfo->tableFname); + if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableName(pInfo->tableFname); if (pMsg->pDb == NULL) { mError("msg:%p, app:%p table:%s, failed to get table meta, db not selected", pMsg, pMsg->rpcMsg.ahandle, pInfo->tableFname); @@ -1006,12 +1012,12 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { SSTableObj * pStable = calloc(1, sizeof(SSTableObj)); if (pStable == NULL) { - mError("msg:%p, app:%p table:%s, failed to create, no enough memory", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname); + mError("msg:%p, app:%p table:%s, failed to create, no enough memory", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName); return TSDB_CODE_MND_OUT_OF_MEMORY; } int64_t us = taosGetTimestampUs(); - pStable->info.tableId = strdup(pCreate->tableFname); + pStable->info.tableId = strdup(pCreate->tableName); pStable->info.type = TSDB_SUPER_TABLE; pStable->createdTime = taosGetTimestampMs(); pStable->uid = (us << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul)); @@ -1025,14 +1031,14 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { pStable->schema = (SSchema *)calloc(1, schemaSize); if (pStable->schema == NULL) { free(pStable); - mError("msg:%p, app:%p table:%s, failed to create, no schema input", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname); + mError("msg:%p, app:%p table:%s, failed to create, no schema input", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName); return TSDB_CODE_MND_INVALID_TABLE_NAME; } memcpy(pStable->schema, pCreate->schema, numOfCols * sizeof(SSchema)); if (pStable->numOfColumns > TSDB_MAX_COLUMNS || pStable->numOfTags > TSDB_MAX_TAGS) { - mError("msg:%p, app:%p table:%s, failed to create, too many columns", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname); + mError("msg:%p, app:%p table:%s, failed to create, too many columns", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName); return TSDB_CODE_MND_INVALID_TABLE_NAME; } @@ -1044,8 +1050,8 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { tschema[col].bytes = htons(tschema[col].bytes); } - if (!isValidSchema(pStable->schema, pStable->numOfColumns, pStable->numOfTags)) { - mError("msg:%p, app:%p table:%s, failed to create table, invalid schema", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname); + if (!tIsValidSchema(pStable->schema, pStable->numOfColumns, pStable->numOfTags)) { + mError("msg:%p, app:%p table:%s, failed to create table, invalid schema", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName); return TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG; } @@ -1065,7 +1071,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mnodeDestroySuperTable(pStable); pMsg->pTable = NULL; - mError("msg:%p, app:%p table:%s, failed to create, sdb error", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname); + mError("msg:%p, app:%p table:%s, failed to create, sdb error", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName); } return code; @@ -1907,12 +1913,12 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { SCTableObj *pTable = calloc(1, sizeof(SCTableObj)); if (pTable == NULL) { - mError("msg:%p, app:%p table:%s, failed to alloc memory", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname); + mError("msg:%p, app:%p table:%s, failed to alloc memory", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName); return TSDB_CODE_MND_OUT_OF_MEMORY; } pTable->info.type = (pCreate->numOfColumns == 0)? TSDB_CHILD_TABLE:TSDB_NORMAL_TABLE; - pTable->info.tableId = strdup(pCreate->tableFname); + pTable->info.tableId = strdup(pCreate->tableName); pTable->createdTime = taosGetTimestampMs(); pTable->tid = tid; pTable->vgId = pVgroup->vgId; @@ -1928,7 +1934,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { size_t prefixLen = tableIdPrefix(pMsg->pDb->name, prefix, 64); if (0 != strncasecmp(prefix, stableName, prefixLen)) { mError("msg:%p, app:%p table:%s, corresponding super table:%s not in this db", pMsg, pMsg->rpcMsg.ahandle, - pCreate->tableFname, stableName); + pCreate->tableName, stableName); mnodeDestroyChildTable(pTable); return TSDB_CODE_TDB_INVALID_CREATE_TB_MSG; } @@ -1936,7 +1942,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { if (pMsg->pSTable == NULL) pMsg->pSTable = mnodeGetSuperTable(stableName); if (pMsg->pSTable == NULL) { mError("msg:%p, app:%p table:%s, corresponding super table:%s does not exist", pMsg, pMsg->rpcMsg.ahandle, - pCreate->tableFname, stableName); + pCreate->tableName, stableName); mnodeDestroyChildTable(pTable); return TSDB_CODE_MND_INVALID_TABLE_NAME; } @@ -2003,7 +2009,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mnodeDestroyChildTable(pTable); pMsg->pTable = NULL; - mError("msg:%p, app:%p table:%s, failed to create, reason:%s", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname, + mError("msg:%p, app:%p table:%s, failed to create, reason:%s", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName, tstrerror(code)); } else { mDebug("msg:%p, app:%p table:%s, allocated in vgroup, vgId:%d sid:%d uid:%" PRIu64, pMsg, pMsg->rpcMsg.ahandle, @@ -2020,7 +2026,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { int32_t code = grantCheck(TSDB_GRANT_TIMESERIES); if (code != TSDB_CODE_SUCCESS) { mError("msg:%p, app:%p table:%s, failed to create, grant timeseries failed", pMsg, pMsg->rpcMsg.ahandle, - pCreate->tableFname); + pCreate->tableName); return code; } @@ -2031,7 +2037,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &tid); if (code != TSDB_CODE_SUCCESS) { mDebug("msg:%p, app:%p table:%s, failed to get available vgroup, reason:%s", pMsg, pMsg->rpcMsg.ahandle, - pCreate->tableFname, tstrerror(code)); + pCreate->tableName, tstrerror(code)); return code; } @@ -2045,15 +2051,15 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { return mnodeDoCreateChildTable(pMsg, tid); } } else { - if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableFname); + if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableName); } if (pMsg->pTable == NULL) { - mError("msg:%p, app:%p table:%s, object not found, retry:%d reason:%s", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname, pMsg->retry, + mError("msg:%p, app:%p table:%s, object not found, retry:%d reason:%s", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName, pMsg->retry, tstrerror(terrno)); return terrno; } else { - mDebug("msg:%p, app:%p table:%s, send create msg to vnode again", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname); + mDebug("msg:%p, app:%p table:%s, send create msg to vnode again", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName); return mnodeDoCreateChildTableFp(pMsg); } } @@ -2398,8 +2404,7 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) { SCreateTableMsg* pCreate = (SCreateTableMsg*) ((char*) pCreateMsg + sizeof(SCMCreateTableMsg)); size_t size = tListLen(pInfo->tableFname); - tstrncpy(pCreate->tableFname, pInfo->tableFname, size); - tstrncpy(pCreate->db, pMsg->pDb->name, sizeof(pCreate->db)); + tstrncpy(pCreate->tableName, pInfo->tableFname, size); pCreate->igExists = 1; pCreate->getMeta = 1; @@ -2767,7 +2772,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) { SCTableObj *pTable = mnodeGetChildTable(tableId); if (pTable == NULL) continue; - if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(tableId); + if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableName(tableId); if (pMsg->pDb == NULL || pMsg->pDb->status != TSDB_DB_STATUS_READY) { mnodeDecTableRef(pTable); continue; @@ -2988,7 +2993,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) { mDebug("msg:%p, app:%p table:%s, alter table msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle, pAlter->tableFname, pMsg->rpcMsg.handle); - if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(pAlter->tableFname); + if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableName(pAlter->tableFname); if (pMsg->pDb == NULL) { mError("msg:%p, app:%p table:%s, failed to alter table, db not selected", pMsg, pMsg->rpcMsg.ahandle, pAlter->tableFname); return TSDB_CODE_MND_DB_NOT_SELECTED; diff --git a/src/os/src/detail/osTime.c b/src/os/src/detail/osTime.c index 1710c469fb48506f21d914ac586fa8356f044619..d6877790a8362e6422f1b658732d3fc5f5e9d616 100644 --- a/src/os/src/detail/osTime.c +++ b/src/os/src/detail/osTime.c @@ -504,13 +504,13 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio int64_t end = 0; // not enough time range - if (INT64_MAX - start > pInterval->interval - 1) { + if (start < 0 || INT64_MAX - start > pInterval->interval - 1) { end = start + pInterval->interval - 1; while(end < t && ((start + pInterval->sliding) <= INT64_MAX)) { // move forward to the correct time window start += pInterval->sliding; - if (INT64_MAX - start > pInterval->interval - 1) { + if (start < 0 || INT64_MAX - start > pInterval->interval - 1) { end = start + pInterval->interval - 1; } else { end = INT64_MAX; diff --git a/src/plugins/http/inc/httpInt.h b/src/plugins/http/inc/httpInt.h index ac182b707b585adf76b92cf4fbc027d22277f220..3dac0dec930d9a14fb25b3acd06ccad2f987f054 100644 --- a/src/plugins/http/inc/httpInt.h +++ b/src/plugins/http/inc/httpInt.h @@ -39,7 +39,8 @@ #define HTTP_GC_TARGET_SIZE 512 #define HTTP_WRITE_RETRY_TIMES 500 #define HTTP_WRITE_WAIT_TIME_MS 5 -#define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + TSDB_KEY_LEN) +#define HTTP_PASSWORD_LEN TSDB_UNI_LEN +#define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + HTTP_PASSWORD_LEN) typedef enum HttpReqType { HTTP_REQTYPE_OTHERS = 0, @@ -147,7 +148,7 @@ typedef struct HttpContext { uint8_t parsed; char ipstr[22]; char user[TSDB_USER_LEN]; // parsed from auth token or login message - char pass[TSDB_KEY_LEN]; + char pass[HTTP_PASSWORD_LEN]; TAOS * taos; void * ppContext; HttpSession *session; diff --git a/src/plugins/http/src/httpAuth.c b/src/plugins/http/src/httpAuth.c index 56da8a7089e635effa0fc54e1aeb7137ea391c23..973f69f24e850b0f6a3182a38e339ac653eb51a9 100644 --- a/src/plugins/http/src/httpAuth.c +++ b/src/plugins/http/src/httpAuth.c @@ -51,7 +51,7 @@ int32_t httpParseBasicAuthToken(HttpContext *pContext, char *token, int32_t len) char *password = user + 1; int32_t pass_len = (int32_t)((base64 + outlen) - password); - if (pass_len < 1 || pass_len >= TSDB_KEY_LEN) { + if (pass_len < 1 || pass_len >= HTTP_PASSWORD_LEN) { httpError("context:%p, fd:%d, basic token:%s parse password error", pContext, pContext->fd, token); free(base64); return -1; @@ -73,7 +73,7 @@ int32_t httpParseTaosdAuthToken(HttpContext *pContext, char *token, int32_t len) if (base64) free(base64); return 01; } - if (outlen != (TSDB_USER_LEN + TSDB_KEY_LEN)) { + if (outlen != (TSDB_USER_LEN + HTTP_PASSWORD_LEN)) { httpError("context:%p, fd:%d, taosd token:%s length error", pContext, pContext->fd, token); free(base64); return -1; @@ -103,8 +103,8 @@ int32_t httpGenTaosdAuthToken(HttpContext *pContext, char *token, int32_t maxLen size = sizeof(pContext->pass); tstrncpy(buffer + sizeof(pContext->user), pContext->pass, size); - char *encrypt = taosDesEncode(KEY_DES_4, buffer, TSDB_USER_LEN + TSDB_KEY_LEN); - char *base64 = base64_encode((const unsigned char *)encrypt, TSDB_USER_LEN + TSDB_KEY_LEN); + char *encrypt = taosDesEncode(KEY_DES_4, buffer, TSDB_USER_LEN + HTTP_PASSWORD_LEN); + char *base64 = base64_encode((const unsigned char *)encrypt, TSDB_USER_LEN + HTTP_PASSWORD_LEN); size_t len = strlen(base64); tstrncpy(token, base64, len + 1); diff --git a/src/plugins/http/src/httpGcHandle.c b/src/plugins/http/src/httpGcHandle.c index c21799e736027eb4a021032d670f1b542500fe8f..4c10249672ae68510593c0b7b0c924f80e0bd1e3 100644 --- a/src/plugins/http/src/httpGcHandle.c +++ b/src/plugins/http/src/httpGcHandle.c @@ -59,11 +59,11 @@ bool gcGetUserFromUrl(HttpContext* pContext) { bool gcGetPassFromUrl(HttpContext* pContext) { HttpParser* pParser = pContext->parser; - if (pParser->path[GC_PASS_URL_POS].pos >= TSDB_KEY_LEN || pParser->path[GC_PASS_URL_POS].pos <= 0) { + if (pParser->path[GC_PASS_URL_POS].pos >= HTTP_PASSWORD_LEN || pParser->path[GC_PASS_URL_POS].pos <= 0) { return false; } - tstrncpy(pContext->pass, pParser->path[GC_PASS_URL_POS].str, TSDB_KEY_LEN); + tstrncpy(pContext->pass, pParser->path[GC_PASS_URL_POS].str, HTTP_PASSWORD_LEN); return true; } diff --git a/src/plugins/http/src/httpRestHandle.c b/src/plugins/http/src/httpRestHandle.c index 66f1db1a541322a0018e741dd537cd7b518f4bb5..112137b3df0aa99123cbc7b4f177f606e213ed9e 100644 --- a/src/plugins/http/src/httpRestHandle.c +++ b/src/plugins/http/src/httpRestHandle.c @@ -72,11 +72,11 @@ bool restGetUserFromUrl(HttpContext* pContext) { bool restGetPassFromUrl(HttpContext* pContext) { HttpParser* pParser = pContext->parser; - if (pParser->path[REST_PASS_URL_POS].pos >= TSDB_KEY_LEN || pParser->path[REST_PASS_URL_POS].pos <= 0) { + if (pParser->path[REST_PASS_URL_POS].pos >= HTTP_PASSWORD_LEN || pParser->path[REST_PASS_URL_POS].pos <= 0) { return false; } - tstrncpy(pContext->pass, pParser->path[REST_PASS_URL_POS].str, TSDB_KEY_LEN); + tstrncpy(pContext->pass, pParser->path[REST_PASS_URL_POS].str, HTTP_PASSWORD_LEN); return true; } diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index 4896d50c6cabf6d924161c97f7fe020fe81e2ebf..bc768788d8b659088f95f83e3ce9e2dc1c7c27e5 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -60,7 +60,10 @@ void httpCleanUpConnect() { HttpServer *pServer = &tsHttpServer; if (pServer->pThreads == NULL) return; - pthread_join(pServer->thread, NULL); + if (taosCheckPthreadValid(pServer->thread)) { + pthread_join(pServer->thread, NULL); + } + for (int32_t i = 0; i < pServer->numOfThreads; ++i) { HttpThread* pThread = pServer->pThreads + i; if (pThread != NULL) { diff --git a/src/plugins/http/src/httpTgHandle.c b/src/plugins/http/src/httpTgHandle.c index 0a3ef539e37acd576596e5444ea3989602c00e90..bae8c44490afecd8d4a6f2e36c5b40e078fa26ca 100644 --- a/src/plugins/http/src/httpTgHandle.c +++ b/src/plugins/http/src/httpTgHandle.c @@ -324,7 +324,7 @@ bool tgGetUserFromUrl(HttpContext *pContext) { bool tgGetPassFromUrl(HttpContext *pContext) { HttpParser *pParser = pContext->parser; - if (pParser->path[TG_PASS_URL_POS].pos >= TSDB_KEY_LEN || pParser->path[TG_PASS_URL_POS].pos <= 0) { + if (pParser->path[TG_PASS_URL_POS].pos >= HTTP_PASSWORD_LEN || pParser->path[TG_PASS_URL_POS].pos <= 0) { return false; } diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index 9443b1ce12deba75a070f25ae4f67f7887870f7d..3b0b6a2fef9e29fa8dd2c93c2c42473d2708187d 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -246,7 +246,10 @@ void monStopSystem() { void monCleanupSystem() { tsMonitor.quiting = 1; monStopSystem(); - pthread_join(tsMonitor.thread, NULL); + if (taosCheckPthreadValid(tsMonitor.thread)) { + pthread_join(tsMonitor.thread, NULL); + } + if (tsMonitor.conn != NULL) { taos_close(tsMonitor.conn); tsMonitor.conn = NULL; diff --git a/src/query/inc/tsqlfunction.h b/src/query/inc/qAggMain.h similarity index 97% rename from src/query/inc/tsqlfunction.h rename to src/query/inc/qAggMain.h index 51048bbe72368cb6869092b65d5f035f26f3545b..53af502e27c64377d6d0355ea8060f63e27ba82d 100644 --- a/src/query/inc/tsqlfunction.h +++ b/src/query/inc/qAggMain.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_TSQLFUNCTION_H -#define TDENGINE_TSQLFUNCTION_H +#ifndef TDENGINE_QAGGMAIN_H +#define TDENGINE_QAGGMAIN_H #ifdef __cplusplus extern "C" { @@ -97,11 +97,7 @@ extern "C" { #define DATA_SET_FLAG ',' // to denote the output area has data, not null value #define DATA_SET_FLAG_SIZE sizeof(DATA_SET_FLAG) -#define QUERY_COND_REL_PREFIX_IN "IN|" -#define QUERY_COND_REL_PREFIX_LIKE "LIKE|" -#define QUERY_COND_REL_PREFIX_IN_LEN 3 -#define QUERY_COND_REL_PREFIX_LIKE_LEN 5 #define QUERY_ASC_FORWARD_STEP 1 #define QUERY_DESC_FORWARD_STEP -1 @@ -153,7 +149,7 @@ typedef struct SResultRowCellInfo { typedef struct SPoint1 { int64_t key; - double val; + union{double val; char* ptr;}; } SPoint1; #define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowCellInfo))) @@ -279,4 +275,4 @@ static FORCE_INLINE void initResultInfo(SResultRowCellInfo *pResInfo, uint32_t b } #endif -#endif // TDENGINE_TSQLFUNCTION_H +#endif // TDENGINE_QAGGMAIN_H diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index b5174ca43ea63bf564c21daca52f64ffe695edaf..87c16f2ee489847db18253b924685623c8626850 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -18,6 +18,7 @@ #include "os.h" #include "hash.h" +#include "qAggMain.h" #include "qFill.h" #include "qResultbuf.h" #include "qSqlparser.h" @@ -27,7 +28,6 @@ #include "tarray.h" #include "tlockfree.h" #include "tsdb.h" -#include "tsqlfunction.h" struct SColumnFilterElem; typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, const char* val1, const char* val2, int16_t type); @@ -164,13 +164,14 @@ typedef struct SQuery { SColumnInfo* tagColList; int32_t numOfFilterCols; int64_t* fillVal; - uint32_t status; // query status + uint32_t status; // query status SResultRec rec; int32_t pos; tFilePage** sdata; STableQueryInfo* current; + int32_t numOfCheckedBlocks; // number of check data blocks - SOrderedPrjQueryInfo prjInfo; // limit value for each vgroup, only available in global order projection query. + SOrderedPrjQueryInfo prjInfo; // limit value for each vgroup, only available in global order projection query. SSingleColumnFilterInfo* pFilterInfo; } SQuery; diff --git a/src/query/inc/qFill.h b/src/query/inc/qFill.h index 93537ec3da582859ff752faf5521f39985b5728e..9b7f0fb5292d3668940ba610d6ba4991dd70afcf 100644 --- a/src/query/inc/qFill.h +++ b/src/query/inc/qFill.h @@ -86,7 +86,7 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo); int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, int64_t ekey, int32_t maxNumOfRows); -int32_t taosGetLinearInterpolationVal(int32_t type, SPoint *point1, SPoint *point2, SPoint *point); +int32_t taosGetLinearInterpolationVal(SPoint* point, int32_t outputType, SPoint* point1, SPoint* point2, int32_t inputType); int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, tFilePage** output, int32_t capacity); diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index 56e676ef167b8c9f1a694ef0571d1b0318ef6992..c225ebd44a3138231dd260491c8a738389d2bb04 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -96,15 +96,16 @@ typedef struct SCreateTableSQL { SQuerySQL *pSelect; } SCreateTableSQL; -typedef struct SAlterTableSQL { +typedef struct SAlterTableInfo { SStrToken name; + int16_t tableType; int16_t type; STagData tagData; SArray *pAddColumns; // SArray SArray *varList; // set t=val or: change src dst, SArray -} SAlterTableSQL; +} SAlterTableInfo; -typedef struct SCreateDBInfo { +typedef struct SCreateDbInfo { SStrToken dbname; int32_t replica; int32_t cacheBlockSize; @@ -122,11 +123,10 @@ typedef struct SCreateDBInfo { bool ignoreExists; int8_t update; int8_t cachelast; - - SArray *keep; -} SCreateDBInfo; + SArray *keep; +} SCreateDbInfo; -typedef struct SCreateAcctSQL { +typedef struct SCreateAcctInfo { int32_t maxUsers; int32_t maxDbs; int32_t maxTimeSeries; @@ -136,7 +136,7 @@ typedef struct SCreateAcctSQL { int64_t maxQueryTime; int32_t maxConnections; SStrToken stat; -} SCreateAcctSQL; +} SCreateAcctInfo; typedef struct SShowInfo { uint8_t showType; @@ -151,22 +151,18 @@ typedef struct SUserInfo { int16_t type; } SUserInfo; -typedef struct tDCLSQL { - int32_t nTokens; /* Number of expressions on the list */ - int32_t nAlloc; /* Number of entries allocated below */ - SStrToken *a; /* one entry for element */ - bool existsCheck; - +typedef struct SMiscInfo { + SArray *a; // SArray + bool existsCheck; + int16_t tableType; + SUserInfo user; union { - SCreateDBInfo dbOpt; - SCreateAcctSQL acctOpt; - SShowInfo showOpt; - SStrToken ip; + SCreateDbInfo dbOpt; + SCreateAcctInfo acctOpt; + SShowInfo showOpt; + SStrToken id; }; - - SUserInfo user; - -} tDCLSQL; +} SMiscInfo; typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause SQuerySQL **pClause; @@ -176,15 +172,13 @@ typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause typedef struct SSqlInfo { int32_t type; bool valid; - + SSubclauseInfo subclauseInfo; + char msg[256]; union { - SCreateTableSQL *pCreateTableInfo; - SAlterTableSQL *pAlterInfo; - tDCLSQL *pDCLInfo; + SCreateTableSQL *pCreateTableInfo; + SAlterTableInfo *pAlterInfo; + SMiscInfo *pMiscInfo; }; - - SSubclauseInfo subclauseInfo; - char pzErrMsg[256]; } SSqlInfo; typedef struct tSQLExpr { @@ -250,7 +244,7 @@ SCreateTableSQL *tSetCreateSqlElems(SArray *pCols, SArray *pTags, SQuerySQL *pSe void tSqlExprNodeDestroy(tSQLExpr *pExpr); -SAlterTableSQL * tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type); +SAlterTableInfo * tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableTable); SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVals, SStrToken *pToken, SStrToken* igExists); void destroyAllSelectClause(SSubclauseInfo *pSql); @@ -267,19 +261,17 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken void SqlInfoDestroy(SSqlInfo *pInfo); void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParams, ...); -void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck); +void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck,int16_t tableType); void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns); -tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SStrToken *pToken); - -void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDBInfo *pDB, SStrToken *pIgExists); +void setCreateDbInfo(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDbInfo *pDB, SStrToken *pIgExists); -void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo); +void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctInfo *pAcctInfo); void setCreateUserSql(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd); void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *ip); void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege); -void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo); +void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo); // prefix show db.tables; void setDbName(SStrToken *pCpxName, SStrToken *pDb); diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 1fa1369bb5da5bfe0fd4a08ce7c059396b8fa394..2a4a91ac3a9c877c8b03db4d49d4bba7243fcadd 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -36,7 +36,7 @@ %syntax_error { pInfo->valid = false; - int32_t outputBufLen = tListLen(pInfo->pzErrMsg); + int32_t outputBufLen = tListLen(pInfo->msg); int32_t len = 0; if(TOKEN.z) { @@ -46,13 +46,13 @@ if (sqlLen + sizeof(msg)/sizeof(msg[0]) + 1 > outputBufLen) { char tmpstr[128] = {0}; memcpy(tmpstr, &TOKEN.z[0], sizeof(tmpstr)/sizeof(tmpstr[0]) - 1); - len = sprintf(pInfo->pzErrMsg, msg, tmpstr); + len = sprintf(pInfo->msg, msg, tmpstr); } else { - len = sprintf(pInfo->pzErrMsg, msg, &TOKEN.z[0]); + len = sprintf(pInfo->msg, msg, &TOKEN.z[0]); } } else { - len = sprintf(pInfo->pzErrMsg, "Incomplete SQL statement"); + len = sprintf(pInfo->msg, "Incomplete SQL statement"); } assert(len <= outputBufLen); @@ -131,10 +131,16 @@ cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). { //drop configure for tables cmd ::= DROP TABLE ifexists(Y) ids(X) cpxName(Z). { X.n += Z.n; - setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y); + setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y, -1); } -cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y); } +//drop stable +cmd ::= DROP STABLE ifexists(Y) ids(X) cpxName(Z). { + X.n += Z.n; + setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y, TSDB_SUPER_TABLE); +} + +cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y, -1); } cmd ::= DROP DNODE ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &X); } cmd ::= DROP USER ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_USER, 1, &X); } cmd ::= DROP ACCOUNT ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &X); } @@ -210,7 +216,7 @@ conns(Y) ::= CONNS INTEGER(X). { Y = X; } state(Y) ::= . { Y.n = 0; } state(Y) ::= STATE ids(X). { Y = X; } -%type acct_optr {SCreateAcctSQL} +%type acct_optr {SCreateAcctInfo} acct_optr(Y) ::= pps(C) tseries(D) storage(P) streams(F) qtime(Q) dbs(E) users(K) conns(L) state(M). { Y.maxUsers = (K.n>0)?atoi(K.z):-1; Y.maxDbs = (E.n>0)?atoi(E.z):-1; @@ -242,7 +248,7 @@ prec(Y) ::= PRECISION STRING(X). { Y = X; } update(Y) ::= UPDATE INTEGER(X). { Y = X; } cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; } -%type db_optr {SCreateDBInfo} +%type db_optr {SCreateDbInfo} db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);} db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); } @@ -261,7 +267,7 @@ db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; } db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); } -%type alter_db_optr {SCreateDBInfo} +%type alter_db_optr {SCreateDbInfo} alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y);} alter_db_optr(Y) ::= alter_db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); } @@ -305,6 +311,8 @@ signed(A) ::= MINUS INTEGER(X). { A = -strtol(X.z, NULL, 10);} ////////////////////////////////// The CREATE TABLE statement /////////////////////////////// cmd ::= CREATE TABLE create_table_args. {} +cmd ::= CREATE TABLE create_stable_args. {} +cmd ::= CREATE STABLE create_stable_args. {} cmd ::= CREATE TABLE create_table_list(Z). { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = Z;} %type create_table_list{SCreateTableSQL*} @@ -333,7 +341,8 @@ create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP. { } // create super table -create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP TAGS LP columnlist(Y) RP. { +%type create_stable_args{SCreateTableSQL*} +create_stable_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP TAGS LP columnlist(Y) RP. { A = tSetCreateSqlElems(X, Y, NULL, TSQL_CREATE_STABLE); setSqlInfo(pInfo, A, NULL, TSDB_SQL_CREATE_TABLE); @@ -683,7 +692,7 @@ cmd ::= RESET QUERY CACHE. { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} ///////////////////////////////////ALTER TABLE statement////////////////////////////////// cmd ::= ALTER TABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). { X.n += F.n; - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } @@ -693,14 +702,14 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). { toTSDBType(A.type); SArray* K = tVariantListAppendToken(NULL, &A, -1); - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } //////////////////////////////////ALTER TAGS statement///////////////////////////////////// cmd ::= ALTER TABLE ids(X) cpxName(Y) ADD TAG columnlist(A). { X.n += Y.n; - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). { @@ -709,7 +718,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). { toTSDBType(Y.type); SArray* A = tVariantListAppendToken(NULL, &Y, -1); - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } @@ -722,7 +731,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). { toTSDBType(Z.type); A = tVariantListAppendToken(A, &Z, -1); - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } @@ -733,7 +742,54 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). { SArray* A = tVariantListAppendToken(NULL, &Y, -1); A = tVariantListAppend(A, &Z, -1); - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} + + +///////////////////////////////////ALTER STABLE statement////////////////////////////////// +cmd ::= ALTER STABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). { + X.n += F.n; + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} + +cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). { + X.n += F.n; + + toTSDBType(A.type); + SArray* K = tVariantListAppendToken(NULL, &A, -1); + + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, TSDB_SUPER_TABLE); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} + +//////////////////////////////////ALTER TAGS statement///////////////////////////////////// +cmd ::= ALTER STABLE ids(X) cpxName(Y) ADD TAG columnlist(A). { + X.n += Y.n; + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} +cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). { + X.n += Z.n; + + toTSDBType(Y.type); + SArray* A = tVariantListAppendToken(NULL, &Y, -1); + + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, TSDB_SUPER_TABLE); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} + +cmd ::= ALTER STABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). { + X.n += F.n; + + toTSDBType(Y.type); + SArray* A = tVariantListAppendToken(NULL, &Y, -1); + + toTSDBType(Z.type); + A = tVariantListAppendToken(A, &Z, -1); + + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 543b205112c1c286031e23e53babb0673936850c..12c8a16f1fa1d4f6819cb95b8175157086a29fc6 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -14,17 +14,17 @@ */ #include "os.h" -#include "qAst.h" +#include "taosdef.h" +#include "taosmsg.h" +#include "texpr.h" +#include "ttype.h" + +#include "qAggMain.h" #include "qFill.h" #include "qHistogram.h" #include "qPercentile.h" #include "qTsbuf.h" -#include "taosdef.h" -#include "taosmsg.h" #include "queryLog.h" -#include "tscSubquery.h" -#include "tsqlfunction.h" -#include "ttype.h" #define GET_INPUT_DATA_LIST(x) (((char *)((x)->aInputElemBuf)) + ((x)->startOffset) * ((x)->inputBytes)) #define GET_INPUT_DATA(x, y) (GET_INPUT_DATA_LIST(x) + (y) * (x)->inputBytes) @@ -3776,89 +3776,67 @@ void twa_function_finalizer(SQLFunctionCtx *pCtx) { * * @param pCtx */ -static void interp_function(SQLFunctionCtx *pCtx) { - // at this point, the value is existed, return directly - SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - SInterpInfoDetail* pInfo = GET_ROWCELL_INTERBUF(pResInfo); - assert(pCtx->startOffset == 0); +static void interp_function_impl(SQLFunctionCtx *pCtx) { + int32_t type = (int32_t) pCtx->param[2].i64; + if (type == TSDB_FILL_NONE) { + return; + } - if (pCtx->size == 1) { - char *pData = GET_INPUT_DATA_LIST(pCtx); - assignVal(pCtx->aOutputBuf, pData, pCtx->inputBytes, pCtx->inputType); + if (pCtx->inputType == TSDB_DATA_TYPE_TIMESTAMP) { + *(TSKEY *) pCtx->aOutputBuf = pCtx->nStartQueryTimestamp; } else { - /* - * use interpolation to generate the result. - * Note: the result of primary timestamp column uses the timestamp specified by user in the query sql - */ - assert(pCtx->size == 2); - if (pInfo->type == TSDB_FILL_NONE) { // set no output result + if (pCtx->start.key == INT64_MIN) { + assert(pCtx->end.key == INT64_MIN); return; } - - if (pInfo->primaryCol == 1) { - *(TSKEY *) pCtx->aOutputBuf = pInfo->ts; - } else { - if (pInfo->type == TSDB_FILL_NULL) { - if (pCtx->outputType == TSDB_DATA_TYPE_BINARY || pCtx->outputType == TSDB_DATA_TYPE_NCHAR) { - setVardataNull(pCtx->aOutputBuf, pCtx->outputType); - } else { - setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); - } - - SET_VAL(pCtx, pCtx->size, 1); - } else if (pInfo->type == TSDB_FILL_SET_VALUE) { - tVariantDump(&pCtx->param[1], pCtx->aOutputBuf, pCtx->inputType, true); - } else if (pInfo->type == TSDB_FILL_PREV) { - char *data = GET_INPUT_DATA(pCtx, 0); - assignVal(pCtx->aOutputBuf, data, pCtx->outputBytes, pCtx->outputType); - - SET_VAL(pCtx, pCtx->size, 1); - } else if (pInfo->type == TSDB_FILL_LINEAR) { - char *data1 = GET_INPUT_DATA(pCtx, 0); - char *data2 = GET_INPUT_DATA(pCtx, 1); - - TSKEY key1 = pCtx->ptsList[0]; - TSKEY key2 = pCtx->ptsList[1]; - - SPoint point1 = {.key = key1, .val = data1}; - SPoint point2 = {.key = key2, .val = data2}; - - SPoint point = {.key = pInfo->ts, .val = pCtx->aOutputBuf}; - - int32_t srcType = pCtx->inputType; - if ((srcType >= TSDB_DATA_TYPE_TINYINT && srcType <= TSDB_DATA_TYPE_BIGINT) || - srcType == TSDB_DATA_TYPE_TIMESTAMP || srcType == TSDB_DATA_TYPE_DOUBLE) { - point1.val = data1; - point2.val = data2; - - if (isNull(data1, srcType) || isNull(data2, srcType)) { - setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes); - } else { - taosGetLinearInterpolationVal(pCtx->outputType, &point1, &point2, &point); - } - } else if (srcType == TSDB_DATA_TYPE_FLOAT) { - point1.val = data1; - point2.val = data2; - - if (isNull(data1, srcType) || isNull(data2, srcType)) { - setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes); - } else { - taosGetLinearInterpolationVal(pCtx->outputType, &point1, &point2, &point); - } - + + if (type == TSDB_FILL_NULL) { + setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); + } else if (type == TSDB_FILL_SET_VALUE) { + tVariantDump(&pCtx->param[1], pCtx->aOutputBuf, pCtx->inputType, true); + } else if (type == TSDB_FILL_PREV) { + if (IS_NUMERIC_TYPE(pCtx->inputType) || pCtx->inputType == TSDB_DATA_TYPE_BOOL) { + SET_TYPED_DATA(pCtx->aOutputBuf, pCtx->inputType, pCtx->start.val); + } else { + assignVal(pCtx->aOutputBuf, pCtx->start.ptr, pCtx->outputBytes, pCtx->inputType); + } + } else if (type == TSDB_FILL_LINEAR) { + SPoint point1 = {.key = pCtx->start.key, .val = &pCtx->start.val}; + SPoint point2 = {.key = pCtx->end.key, .val = &pCtx->end.val}; + SPoint point = {.key = pCtx->nStartQueryTimestamp, .val = pCtx->aOutputBuf}; + + int32_t srcType = pCtx->inputType; + if (IS_NUMERIC_TYPE(srcType)) { // TODO should find the not null data? + if (isNull((char *)&pCtx->start.val, srcType) || isNull((char *)&pCtx->end.val, srcType)) { + setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes); } else { - if (srcType == TSDB_DATA_TYPE_BINARY || srcType == TSDB_DATA_TYPE_NCHAR) { - setVardataNull(pCtx->aOutputBuf, pCtx->inputType); - } else { - setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes); - } + taosGetLinearInterpolationVal(&point, pCtx->outputType, &point1, &point2, TSDB_DATA_TYPE_DOUBLE); } + } else { + setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes); } } } - - SET_VAL(pCtx, pCtx->size, 1); + + SET_VAL(pCtx, 1, 1); + +} +static void interp_function(SQLFunctionCtx *pCtx) { + // at this point, the value is existed, return directly + if (pCtx->size > 0) { + // impose the timestamp check + TSKEY key = GET_TS_DATA(pCtx, 0); + if (key == pCtx->nStartQueryTimestamp) { + char *pData = GET_INPUT_DATA(pCtx, 0); + assignVal(pCtx->aOutputBuf, pData, pCtx->inputBytes, pCtx->inputType); + SET_VAL(pCtx, 1, 1); + } else { + interp_function_impl(pCtx); + } + } else { //no qualified data rows and interpolation is required + interp_function_impl(pCtx); + } } static bool ts_comp_function_setup(SQLFunctionCtx *pCtx) { diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 960127b15df82d457f497de61d7d7be963d2416b..63b2f3ea158fc90a05ed9c7ea818dfbf674989d3 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -20,7 +20,7 @@ #include "exception.h" #include "hash.h" -#include "qAst.h" +#include "texpr.h" #include "qExecutor.h" #include "qResultbuf.h" #include "qUtil.h" @@ -416,7 +416,7 @@ static bool isTopBottomQuery(SQuery *pQuery) { static bool timeWindowInterpoRequired(SQuery *pQuery) { for(int32_t i = 0; i < pQuery->numOfOutput; ++i) { int32_t functionId = pQuery->pExpr1[i].base.functionId; - if (functionId == TSDB_FUNC_TWA) { + if (functionId == TSDB_FUNC_TWA || functionId == TSDB_FUNC_INTERP) { return true; } } @@ -826,6 +826,7 @@ static int32_t getNumOfRowsInTimeWindow(SQuery *pQuery, SDataBlockInfo *pDataBlo return num; } +// TODO decouple the data block and the SQLFunctionCtx static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow *pWin, int32_t offset, int32_t forwardStep, TSKEY *tsCol, int32_t numOfTotal) { SQuery *pQuery = pRuntimeEnv->pQuery; SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx; @@ -833,8 +834,8 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow bool hasPrev = pCtx[0].preAggVals.isSet; for (int32_t k = 0; k < pQuery->numOfOutput; ++k) { - pCtx[k].nStartQueryTimestamp = pWin->skey; pCtx[k].size = forwardStep; + pCtx[k].nStartQueryTimestamp = pWin->skey; pCtx[k].startOffset = (QUERY_IS_ASC_QUERY(pQuery)) ? offset : offset - (forwardStep - 1); int32_t functionId = pQuery->pExpr1[k].base.functionId; @@ -1037,7 +1038,8 @@ static void setNotInterpoWindowKey(SQLFunctionCtx* pCtx, int32_t numOfOutput, in } // window start key interpolation -static bool setTimeWindowInterpolationStartTs(SQueryRuntimeEnv* pRuntimeEnv, int32_t pos, int32_t numOfRows, SArray* pDataBlock, TSKEY* tsCols, STimeWindow* win) { +static bool setTimeWindowInterpolationStartTs(SQueryRuntimeEnv* pRuntimeEnv, int32_t pos, int32_t numOfRows, + SArray* pDataBlock, TSKEY* tsCols, STimeWindow* win, int16_t type) { SQuery* pQuery = pRuntimeEnv->pQuery; TSKEY curTs = tsCols[pos]; @@ -1126,6 +1128,8 @@ static void doWindowBorderInterpolation(SQueryRuntimeEnv* pRuntimeEnv, SDataBloc assert(pDataBlock != NULL); SQuery* pQuery = pRuntimeEnv->pQuery; + int32_t fillType = pQuery->fillType; + int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); SColumnInfoData *pColInfo = taosArrayGet(pDataBlock, 0); @@ -1134,7 +1138,7 @@ static void doWindowBorderInterpolation(SQueryRuntimeEnv* pRuntimeEnv, SDataBloc bool done = resultRowInterpolated(pResult, RESULT_ROW_START_INTERP); if (!done) { int32_t startRowIndex = startPos; - bool interp = setTimeWindowInterpolationStartTs(pRuntimeEnv, startRowIndex, pDataBlockInfo->rows, pDataBlock, tsCols, win); + bool interp = setTimeWindowInterpolationStartTs(pRuntimeEnv, startRowIndex, pDataBlockInfo->rows, pDataBlock, tsCols, win, fillType); if (interp) { setResultRowInterpo(pResult, RESULT_ROW_START_INTERP); } @@ -1142,6 +1146,12 @@ static void doWindowBorderInterpolation(SQueryRuntimeEnv* pRuntimeEnv, SDataBloc setNotInterpoWindowKey(pRuntimeEnv->pCtx, pQuery->numOfOutput, RESULT_ROW_START_INTERP); } + // point interpolation does not require the end key time window interpolation. + if (isPointInterpoQuery(pQuery)) { + return; + } + + // interpolation query does not generate the time window end interpolation done = resultRowInterpolated(pResult, RESULT_ROW_END_INTERP); if (!done) { int32_t endRowIndex = startPos + (forwardStep - 1) * step; @@ -1267,7 +1277,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis * for (int32_t k = 0; k < pQuery->numOfOutput; ++k) { int32_t functionId = pQuery->pExpr1[k].base.functionId; if (functionNeedToExecute(pRuntimeEnv, &pCtx[k], functionId)) { - pCtx[k].nStartQueryTimestamp = pDataBlockInfo->window.skey; + pCtx[k].nStartQueryTimestamp = pQuery->window.skey; aAggs[functionId].xFunction(&pCtx[k]); } } @@ -1431,18 +1441,20 @@ static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx return true; } -void doRowwiseTimeWindowInterpolation(SQueryRuntimeEnv* pRuntimeEnv, SArray* pDataBlock, TSKEY prevTs, int32_t prevRowIndex, TSKEY curTs, int32_t curRowIndex, TSKEY windowKey, int32_t type) { - SQuery* pQuery = pRuntimeEnv->pQuery; +void doRowwiseTimeWindowInterpolation(SQueryRuntimeEnv *pRuntimeEnv, SArray *pDataBlock, TSKEY prevTs, + int32_t prevRowIndex, TSKEY curTs, int32_t curRowIndex, TSKEY windowKey, + int32_t type) { + SQuery *pQuery = pRuntimeEnv->pQuery; for (int32_t k = 0; k < pQuery->numOfOutput; ++k) { int32_t functionId = pQuery->pExpr1[k].base.functionId; - if (functionId != TSDB_FUNC_TWA) { + if (functionId != TSDB_FUNC_TWA && functionId != TSDB_FUNC_INTERP) { pRuntimeEnv->pCtx[k].start.key = INT64_MIN; continue; } - SColIndex* pColIndex = &pQuery->pExpr1[k].base.colInfo; - int16_t index = pColIndex->colIndex; - SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, index); + SColIndex * pColIndex = &pQuery->pExpr1[k].base.colInfo; + int16_t index = pColIndex->colIndex; + SColumnInfoData *pColInfo = taosArrayGet(pDataBlock, index); assert(pColInfo->info.colId == pColIndex->colId && curTs != windowKey); double v1 = 0, v2 = 0, v = 0; @@ -1458,14 +1470,25 @@ void doRowwiseTimeWindowInterpolation(SQueryRuntimeEnv* pRuntimeEnv, SArray* pDa SPoint point1 = (SPoint){.key = prevTs, .val = &v1}; SPoint point2 = (SPoint){.key = curTs, .val = &v2}; SPoint point = (SPoint){.key = windowKey, .val = &v}; - taosGetLinearInterpolationVal(TSDB_DATA_TYPE_DOUBLE, &point1, &point2, &point); - if (type == RESULT_ROW_START_INTERP) { - pRuntimeEnv->pCtx[k].start.key = point.key; - pRuntimeEnv->pCtx[k].start.val = v; + if (functionId == TSDB_FUNC_TWA) { + taosGetLinearInterpolationVal(&point, TSDB_DATA_TYPE_DOUBLE, &point1, &point2, TSDB_DATA_TYPE_DOUBLE); + + if (type == RESULT_ROW_START_INTERP) { + pRuntimeEnv->pCtx[k].start.key = point.key; + pRuntimeEnv->pCtx[k].start.val = v; + } else { + pRuntimeEnv->pCtx[k].end.key = point.key; + pRuntimeEnv->pCtx[k].end.val = v; + } } else { - pRuntimeEnv->pCtx[k].end.key = point.key; - pRuntimeEnv->pCtx[k].end.val = v; + if (type == RESULT_ROW_START_INTERP) { + pRuntimeEnv->pCtx[k].start.key = prevTs; + pRuntimeEnv->pCtx[k].start.val = v1; + + pRuntimeEnv->pCtx[k].end.key = curTs; + pRuntimeEnv->pCtx[k].end.val = v2; + } } } } @@ -1804,13 +1827,7 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY pCtx->preAggVals.statis.max = pBlockInfo->window.ekey; } } else if (functionId == TSDB_FUNC_INTERP) { - SResultRowCellInfo* pInfo = GET_RES_INFO(pCtx); - - SInterpInfoDetail *pInterpInfo = (SInterpInfoDetail *)GET_ROWCELL_INTERBUF(pInfo); - pInterpInfo->type = (int8_t)pQuery->fillType; - pInterpInfo->ts = pQuery->window.skey; - pInterpInfo->primaryCol = (colId == PRIMARYKEY_TIMESTAMP_COL_INDEX); - + pCtx->param[2].i64 = (int8_t) pQuery->fillType; if (pQuery->fillVal != NULL) { if (isNull((const char*) &pQuery->fillVal[colIndex], pCtx->inputType)) { pCtx->param[1].nType = TSDB_DATA_TYPE_NULL; @@ -1883,6 +1900,7 @@ static int32_t setCtxTagColumnInfo(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx return TSDB_CODE_SUCCESS; } +// todo refactor static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order) { qDebug("QInfo:%p setup runtime env", GET_QINFO_ADDR(pRuntimeEnv)); SQuery *pQuery = pRuntimeEnv->pQuery; @@ -2590,7 +2608,6 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo * pW if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTsBuf > 0) { *status = BLK_DATA_ALL_NEEDED; } else { // check if this data block is required to load - // Calculate all time windows that are overlapping or contain current data block. // If current data block is contained by all possible time window, do not load current data block. if (QUERY_IS_INTERVAL_QUERY(pQuery) && overlapWithTimeWindow(pQuery, pBlockInfo)) { @@ -2829,6 +2846,10 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { while (tsdbNextDataBlock(pQueryHandle)) { summary->totalBlocks += 1; + if (IS_MASTER_SCAN(pRuntimeEnv)) { + pQuery->numOfCheckedBlocks += 1; + } + if (isQueryKilled(GET_QINFO_ADDR(pRuntimeEnv))) { longjmp(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED); } @@ -3568,7 +3589,7 @@ void setQueryStatus(SQuery *pQuery, int8_t status) { } } -bool needScanDataBlocksAgain(SQueryRuntimeEnv *pRuntimeEnv) { +bool needRepeatScan(SQueryRuntimeEnv *pRuntimeEnv) { SQuery *pQuery = pRuntimeEnv->pQuery; bool toContinue = false; @@ -3695,6 +3716,67 @@ static void restoreTimeWindow(STableGroupInfo* pTableGroupInfo, STsdbQueryCond* pKeyInfo->lastKey = pCond->twindow.skey; } +static void handleInterpolationQuery(SQInfo* pQInfo) { + SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv; + + SQuery *pQuery = pRuntimeEnv->pQuery; + if (pQuery->numOfCheckedBlocks > 0 || !isPointInterpoQuery(pQuery)) { + return; + } + + SArray *prev = tsdbGetExternalRow(pRuntimeEnv->pQueryHandle, &pQInfo->memRef, TSDB_PREV_ROW); + SArray *next = tsdbGetExternalRow(pRuntimeEnv->pQueryHandle, &pQInfo->memRef, TSDB_NEXT_ROW); + if (prev == NULL || next == NULL) { + return; + } + + // setup the pCtx->start/end info and calculate the interpolation value + SColumnInfoData *startTs = taosArrayGet(prev, 0); + SColumnInfoData *endTs = taosArrayGet(next, 0); + + for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { + SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i]; + + int32_t functionId = pQuery->pExpr1[i].base.functionId; + SColIndex *pColIndex = &pQuery->pExpr1[i].base.colInfo; + + if (!TSDB_COL_IS_NORMAL_COL(pColIndex->flag)) { + aAggs[functionId].xFunction(pCtx); + continue; + } + + SColumnInfoData *p = taosArrayGet(prev, pColIndex->colIndex); + SColumnInfoData *n = taosArrayGet(next, pColIndex->colIndex); + + assert(p->info.colId == pColIndex->colId); + + pCtx->start.key = *(TSKEY *)startTs->pData; + pCtx->end.key = *(TSKEY *)endTs->pData; + + if (p->info.type != TSDB_DATA_TYPE_BINARY && p->info.type != TSDB_DATA_TYPE_NCHAR) { + GET_TYPED_DATA(pCtx->start.val, double, p->info.type, p->pData); + GET_TYPED_DATA(pCtx->end.val, double, n->info.type, n->pData); + } else { // string pointer + pCtx->start.ptr = p->pData; + pCtx->end.ptr = n->pData; + } + + pCtx->param[2].i64 = (int8_t)pQuery->fillType; + pCtx->nStartQueryTimestamp = pQuery->window.skey; + if (pQuery->fillVal != NULL) { + if (isNull((const char *)&pQuery->fillVal[i], pCtx->inputType)) { + pCtx->param[1].nType = TSDB_DATA_TYPE_NULL; + } else { // todo refactor, tVariantCreateFromBinary should handle the NULL value + if (pCtx->inputType != TSDB_DATA_TYPE_BINARY && pCtx->inputType != TSDB_DATA_TYPE_NCHAR) { + tVariantCreateFromBinary(&pCtx->param[1], (char *)&pQuery->fillVal[i], pCtx->inputBytes, pCtx->inputType); + } + } + } + + aAggs[functionId].xFunction(pCtx); + } +} + void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) { SQInfo *pQInfo = (SQInfo *) GET_QINFO_ADDR(pRuntimeEnv); SQuery *pQuery = pRuntimeEnv->pQuery; @@ -3722,7 +3804,7 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) { } } - if (!needScanDataBlocksAgain(pRuntimeEnv)) { + if (!needRepeatScan(pRuntimeEnv)) { // restore the status code and jump out of loop if (pRuntimeEnv->scanFlag == REPEAT_SCAN) { pQuery->status = qstatus.status; @@ -3748,24 +3830,19 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) { qDebug("QInfo:%p start to repeat scan data blocks due to query func required, qrange:%"PRId64"-%"PRId64, pQInfo, cond.twindow.skey, cond.twindow.ekey); - - // check if query is killed or not - if (isQueryKilled(pQInfo)) { - longjmp(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED); - } } - if (!needReverseScan(pQuery)) { - return; - } + if (needReverseScan(pQuery)) { + setEnvBeforeReverseScan(pRuntimeEnv, &qstatus); - setEnvBeforeReverseScan(pRuntimeEnv, &qstatus); + // reverse scan from current position + qDebug("QInfo:%p start to reverse scan", pQInfo); + doScanAllDataBlocks(pRuntimeEnv); - // reverse scan from current position - qDebug("QInfo:%p start to reverse scan", pQInfo); - doScanAllDataBlocks(pRuntimeEnv); + clearEnvAfterReverseScan(pRuntimeEnv, &qstatus); + } - clearEnvAfterReverseScan(pRuntimeEnv, &qstatus); + handleInterpolationQuery(pQInfo); } void finalizeQueryResult(SQueryRuntimeEnv *pRuntimeEnv) { @@ -3861,11 +3938,6 @@ void setExecutionContext(SQInfo *pQInfo, int32_t groupIndex, TSKEY nextKey) { // lastKey needs to be updated pTableQueryInfo->lastKey = nextKey; - - if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTsBuf != NULL) { - setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo); - } - if (pRuntimeEnv->prevGroupId != INT32_MIN && pRuntimeEnv->prevGroupId == groupIndex) { return; } @@ -4843,19 +4915,17 @@ static void enableExecutionForNextTable(SQueryRuntimeEnv *pRuntimeEnv) { } } -// TODO refactor: setAdditionalInfo static FORCE_INLINE void setEnvForEachBlock(SQInfo* pQInfo, STableQueryInfo* pTableQueryInfo, SDataBlockInfo* pBlockInfo) { SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv; SQuery* pQuery = pQInfo->runtimeEnv.pQuery; int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); - if (QUERY_IS_INTERVAL_QUERY(pQuery)) { - TSKEY nextKey = pBlockInfo->window.skey; - setIntervalQueryRange(pQInfo, nextKey); + if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTsBuf != NULL) { + setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo); + } - if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTsBuf != NULL) { - setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo); - } + if (QUERY_IS_INTERVAL_QUERY(pQuery)) { + setIntervalQueryRange(pQInfo, pBlockInfo->window.skey); } else { // non-interval query setExecutionContext(pQInfo, pTableQueryInfo->groupIndex, pBlockInfo->window.ekey + step); } @@ -4878,7 +4948,7 @@ static void doTableQueryInfoTimeWindowCheck(SQuery* pQuery, STableQueryInfo* pTa static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) { SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQuery* pQuery = pRuntimeEnv->pQuery; - SQueryCostInfo* summary = &pRuntimeEnv->summary; + SQueryCostInfo* summary = &pRuntimeEnv->summary; int64_t st = taosGetTimestampMs(); @@ -4961,6 +5031,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { .order = pQuery->order.order, .colList = pQuery->colList, .numOfCols = pQuery->numOfCols, + .loadExternalRows = false, }; // todo refactor @@ -5055,6 +5126,7 @@ STsdbQueryCond createTsdbQueryCond(SQuery* pQuery, STimeWindow* win) { .colList = pQuery->colList, .order = pQuery->order.order, .numOfCols = pQuery->numOfCols, + .loadExternalRows = false, }; TIME_WINDOW_COPY(cond.twindow, *win); @@ -5111,7 +5183,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window); SArray *g1 = taosArrayInit(1, POINTER_BYTES); - SArray *tx = taosArrayClone(group); + SArray *tx = taosArrayDup(group); taosArrayPush(g1, &tx); STableGroupInfo gp = {.numOfTables = taosArrayGetSize(tx), .pGroupList = g1}; @@ -5171,7 +5243,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window); SArray *g1 = taosArrayInit(1, POINTER_BYTES); - SArray *tx = taosArrayClone(group); + SArray *tx = taosArrayDup(group); taosArrayPush(g1, &tx); STableGroupInfo gp = {.numOfTables = taosArrayGetSize(tx), .pGroupList = g1}; @@ -5535,7 +5607,7 @@ static void doRestoreContext(SQInfo *pQInfo) { SET_MASTER_SCAN_FLAG(pRuntimeEnv); } -static void doCloseAllTimeWindowAfterScan(SQInfo *pQInfo) { +static void doCloseAllTimeWindow(SQInfo *pQInfo) { SQuery *pQuery = pQInfo->runtimeEnv.pQuery; if (QUERY_IS_INTERVAL_QUERY(pQuery)) { @@ -5587,7 +5659,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { } // close all time window results - doCloseAllTimeWindowAfterScan(pQInfo); + doCloseAllTimeWindow(pQInfo); if (needReverseScan(pQuery)) { int32_t code = doSaveContext(pQInfo); @@ -5798,15 +5870,13 @@ static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) { } scanOneTableDataBlocks(pRuntimeEnv, newStartKey); - assert(!Q_STATUS_EQUAL(pQuery->status, QUERY_NOT_COMPLETED)); - finalizeQueryResult(pRuntimeEnv); // skip offset result rows pQuery->rec.rows = 0; // not fill or no result generated during this query - if (pQuery->fillType == TSDB_FILL_NONE || pRuntimeEnv->windowResInfo.size == 0) { + if (pQuery->fillType == TSDB_FILL_NONE || pRuntimeEnv->windowResInfo.size == 0 || isPointInterpoQuery(pQuery)) { // all data scanned, the group by normal column can return int32_t numOfClosed = numOfClosedResultRows(&pRuntimeEnv->windowResInfo); if (pQuery->limit.offset > numOfClosed) { @@ -5841,7 +5911,7 @@ static void tableQueryImpl(SQInfo *pQInfo) { SQuery * pQuery = pRuntimeEnv->pQuery; if (hasNotReturnedResults(pRuntimeEnv)) { - if (pQuery->fillType != TSDB_FILL_NONE) { + if (pQuery->fillType != TSDB_FILL_NONE && !isPointInterpoQuery(pQuery)) { /* * There are remain results that are not returned due to result interpolation * So, we do keep in this procedure instead of launching retrieve procedure for next results. @@ -5964,8 +6034,7 @@ static void stableQueryImpl(SQInfo *pQInfo) { (isFixedOutputQuery(pRuntimeEnv) && (!isPointInterpoQuery(pQuery)) && (!pRuntimeEnv->groupbyColumn))) { multiTableQueryProcess(pQInfo); } else { - assert((pQuery->checkResultBuf == 1 && pQuery->interval.interval == 0) || isPointInterpoQuery(pQuery) || - pRuntimeEnv->groupbyColumn); + assert(pQuery->checkResultBuf == 1 || isPointInterpoQuery(pQuery) || pRuntimeEnv->groupbyColumn); sequentialTableProcess(pQInfo); } @@ -6500,7 +6569,7 @@ static int32_t createQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t num if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) { int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols); if (j < 0 || j >= pQueryMsg->numOfCols) { - assert(0); + return TSDB_CODE_QRY_INVALID_MSG; } else { SColumnInfo *pCol = &pQueryMsg->colList[j]; int32_t ret = @@ -6699,7 +6768,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou int32_t srcSize = 0; for (int16_t i = 0; i < numOfCols; ++i) { pQuery->colList[i] = pQueryMsg->colList[i]; - pQuery->colList[i].filters = tscFilterInfoClone(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters); + pQuery->colList[i].filters = tFilterInfoDup(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters); srcSize += pQuery->colList[i].bytes; } @@ -6765,7 +6834,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou pQInfo->runtimeEnv.summary.tableInfoSize += (pTableGroupInfo->numOfTables * sizeof(STableQueryInfo)); pQInfo->runtimeEnv.pResultRowHashTable = taosHashInit(pTableGroupInfo->numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - pQInfo->runtimeEnv.keyBuf = malloc(TSDB_MAX_BYTES_PER_ROW); + pQInfo->runtimeEnv.keyBuf = malloc(TSDB_MAX_BYTES_PER_ROW); // todo opt size pQInfo->runtimeEnv.pool = initResultRowPool(getResultRowSize(&pQInfo->runtimeEnv)); pQInfo->runtimeEnv.prevRow = malloc(POINTER_BYTES * pQuery->numOfCols + srcSize); @@ -6850,7 +6919,8 @@ _cleanup_query: for (int32_t i = 0; i < numOfOutput; ++i) { SExprInfo* pExprInfo = &pExprs[i]; if (pExprInfo->pExpr != NULL) { - tExprTreeDestroy(&pExprInfo->pExpr, NULL); + tExprTreeDestroy(pExprInfo->pExpr, NULL); + pExprInfo->pExpr = NULL; } } @@ -6966,7 +7036,7 @@ static void* destroyQueryFuncExpr(SExprInfo* pExprInfo, int32_t numOfExpr) { for (int32_t i = 0; i < numOfExpr; ++i) { if (pExprInfo[i].pExpr != NULL) { - tExprNodeDestroy(pExprInfo[i].pExpr, NULL); + tExprTreeDestroy(pExprInfo[i].pExpr, NULL); } } diff --git a/src/query/src/qExtbuffer.c b/src/query/src/qExtbuffer.c index fa3fe285a857cc0d146e25f52710d0ebc0a69193..e4c62d90e38407954af1fe00454e6df99cb288bd 100644 --- a/src/query/src/qExtbuffer.c +++ b/src/query/src/qExtbuffer.c @@ -12,13 +12,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "os.h" #include "qExtbuffer.h" +#include "os.h" +#include "qAggMain.h" #include "queryLog.h" #include "taos.h" #include "taosdef.h" #include "taosmsg.h" -#include "tsqlfunction.h" #include "tulog.h" #define COLMODEL_GET_VAL(data, schema, allrow, rowId, colId) \ diff --git a/src/query/src/qFill.c b/src/query/src/qFill.c index 65b58467b7e65e20f0de030a5c9bed52543193e5..c82f8f632d0d15f9732c6aa417d4e18dd6e9a0d1 100644 --- a/src/query/src/qFill.c +++ b/src/query/src/qFill.c @@ -15,9 +15,9 @@ #include "os.h" +#include "qAggMain.h" #include "taosdef.h" #include "taosmsg.h" -#include "tsqlfunction.h" #include "ttype.h" #include "qFill.h" @@ -120,7 +120,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, tFilePage** data, char** sr point1 = (SPoint){.key = *(TSKEY*)(prev), .val = prev + pCol->col.offset}; point2 = (SPoint){.key = ts, .val = srcData[i] + pFillInfo->index * bytes}; point = (SPoint){.key = pFillInfo->currentKey, .val = val1}; - taosGetLinearInterpolationVal(type, &point1, &point2, &point); + taosGetLinearInterpolationVal(&point, type, &point1, &point2, type); } } else { setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, index); @@ -479,25 +479,13 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes; } -int32_t taosGetLinearInterpolationVal(int32_t type, SPoint* point1, SPoint* point2, SPoint* point) { - double v1 = -1; - double v2 = -1; - - GET_TYPED_DATA(v1, double, type, point1->val); - GET_TYPED_DATA(v2, double, type, point2->val); +int32_t taosGetLinearInterpolationVal(SPoint* point, int32_t outputType, SPoint* point1, SPoint* point2, int32_t inputType) { + double v1 = -1, v2 = -1; + GET_TYPED_DATA(v1, double, inputType, point1->val); + GET_TYPED_DATA(v2, double, inputType, point2->val); double r = DO_INTERPOLATION(v1, v2, point1->key, point2->key, point->key); - - switch(type) { - case TSDB_DATA_TYPE_TINYINT: *(int8_t*) point->val = (int8_t) r;break; - case TSDB_DATA_TYPE_SMALLINT: *(int16_t*) point->val = (int16_t) r;break; - case TSDB_DATA_TYPE_INT: *(int32_t*) point->val = (int32_t) r;break; - case TSDB_DATA_TYPE_BIGINT: *(int64_t*) point->val = (int64_t) r;break; - case TSDB_DATA_TYPE_DOUBLE: *(double*) point->val = (double) r;break; - case TSDB_DATA_TYPE_FLOAT: *(float*) point->val = (float) r;break; - default: - assert(0); - } + SET_TYPED_DATA(point->val, outputType, r); return TSDB_CODE_SUCCESS; } diff --git a/src/query/src/qParserImpl.c b/src/query/src/qParserImpl.c index a5a3d7e323ebb1a933f90900904c0c0acb7160ce..6dff55075545d87ff8357b2ce5ab271f7ae5cd65 100644 --- a/src/query/src/qParserImpl.c +++ b/src/query/src/qParserImpl.c @@ -54,7 +54,7 @@ SSqlInfo qSQLParse(const char *pStr) { case TK_QUESTION: case TK_ILLEGAL: { - snprintf(sqlInfo.pzErrMsg, tListLen(sqlInfo.pzErrMsg), "unrecognized token: \"%s\"", t0.z); + snprintf(sqlInfo.msg, tListLen(sqlInfo.msg), "unrecognized token: \"%s\"", t0.z); sqlInfo.valid = false; goto abort_parse; } @@ -585,11 +585,12 @@ SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVal return info; } -SAlterTableSQL *tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type) { - SAlterTableSQL *pAlterTable = calloc(1, sizeof(SAlterTableSQL)); +SAlterTableInfo *tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableType) { + SAlterTableInfo *pAlterTable = calloc(1, sizeof(SAlterTableInfo)); pAlterTable->name = *pTableName; pAlterTable->type = type; + pAlterTable->tableType = tableType; if (type == TSDB_ALTER_TABLE_ADD_COLUMN || type == TSDB_ALTER_TABLE_ADD_TAG_COLUMN) { pAlterTable->pAddColumns = pCols; @@ -631,15 +632,15 @@ void SqlInfoDestroy(SSqlInfo *pInfo) { tfree(pInfo->pAlterInfo->tagData.data); tfree(pInfo->pAlterInfo); } else { - if (pInfo->pDCLInfo != NULL && pInfo->pDCLInfo->nAlloc > 0) { - free(pInfo->pDCLInfo->a); + if (pInfo->pMiscInfo != NULL) { + taosArrayDestroy(pInfo->pMiscInfo->a); } - if (pInfo->pDCLInfo != NULL && pInfo->type == TSDB_SQL_CREATE_DB) { - taosArrayDestroyEx(pInfo->pDCLInfo->dbOpt.keep, freeVariant); + if (pInfo->pMiscInfo != NULL && pInfo->type == TSDB_SQL_CREATE_DB) { + taosArrayDestroyEx(pInfo->pMiscInfo->dbOpt.keep, freeVariant); } - tfree(pInfo->pDCLInfo); + tfree(pInfo->pMiscInfo); } } @@ -696,57 +697,49 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken pInfo->pCreateTableInfo->existCheck = (pIfNotExists->n != 0); } -void tTokenListBuyMoreSpace(tDCLSQL *pTokenList) { - if (pTokenList->nAlloc <= pTokenList->nTokens) { // - pTokenList->nAlloc = (pTokenList->nAlloc << 1u) + 4; - pTokenList->a = realloc(pTokenList->a, pTokenList->nAlloc * sizeof(pTokenList->a[0])); - if (pTokenList->a == 0) { - pTokenList->nTokens = pTokenList->nAlloc = 0; - } - } -} - -tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SStrToken *pToken) { - if (pToken == NULL) return NULL; - - if (pTokenList == NULL) pTokenList = calloc(1, sizeof(tDCLSQL)); - - tTokenListBuyMoreSpace(pTokenList); - pTokenList->a[pTokenList->nTokens++] = *pToken; - - return pTokenList; -} - void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) { pInfo->type = type; + if (nParam == 0) { + return; + } - if (nParam == 0) return; - if (pInfo->pDCLInfo == NULL) pInfo->pDCLInfo = (tDCLSQL *)calloc(1, sizeof(tDCLSQL)); + if (pInfo->pMiscInfo == NULL) { + pInfo->pMiscInfo = (SMiscInfo *)calloc(1, sizeof(SMiscInfo)); + pInfo->pMiscInfo->a = taosArrayInit(4, sizeof(SStrToken)); + } va_list va; va_start(va, nParam); - while (nParam-- > 0) { + while ((nParam--) > 0) { SStrToken *pToken = va_arg(va, SStrToken *); - pInfo->pDCLInfo = tTokenListAppend(pInfo->pDCLInfo, pToken); + taosArrayPush(pInfo->pMiscInfo->a, pToken); } va_end(va); } -void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck) { +void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck, int16_t tableType) { pInfo->type = type; - pInfo->pDCLInfo = tTokenListAppend(pInfo->pDCLInfo, pToken); - pInfo->pDCLInfo->existsCheck = (existsCheck->n == 1); + + if (pInfo->pMiscInfo == NULL) { + pInfo->pMiscInfo = (SMiscInfo *)calloc(1, sizeof(SMiscInfo)); + pInfo->pMiscInfo->a = taosArrayInit(4, sizeof(SStrToken)); + } + + taosArrayPush(pInfo->pMiscInfo->a, pToken); + + pInfo->pMiscInfo->existsCheck = (existsCheck->n == 1); + pInfo->pMiscInfo->tableType = tableType; } void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns) { - if (pInfo->pDCLInfo == NULL) { - pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL)); + if (pInfo->pMiscInfo == NULL) { + pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo)); } pInfo->type = TSDB_SQL_SHOW; - SShowInfo* pShowInfo = &pInfo->pDCLInfo->showOpt; + SShowInfo* pShowInfo = &pInfo->pMiscInfo->showOpt; pShowInfo->showType = type; if (prefix != NULL && prefix->type != 0) { @@ -762,54 +755,54 @@ void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* } } -void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDBInfo *pDB, SStrToken *pIgExists) { +void setCreateDbInfo(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDbInfo *pDB, SStrToken *pIgExists) { pInfo->type = type; - if (pInfo->pDCLInfo == NULL) { - pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL)); + if (pInfo->pMiscInfo == NULL) { + pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo)); } - pInfo->pDCLInfo->dbOpt = *pDB; - pInfo->pDCLInfo->dbOpt.dbname = *pToken; - pInfo->pDCLInfo->dbOpt.ignoreExists = pIgExists->n; // sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;} + pInfo->pMiscInfo->dbOpt = *pDB; + pInfo->pMiscInfo->dbOpt.dbname = *pToken; + pInfo->pMiscInfo->dbOpt.ignoreExists = pIgExists->n; // sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;} } -void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo) { +void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctInfo *pAcctInfo) { pInfo->type = type; - if (pInfo->pDCLInfo == NULL) { - pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL)); + if (pInfo->pMiscInfo == NULL) { + pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo)); } - pInfo->pDCLInfo->acctOpt = *pAcctInfo; + pInfo->pMiscInfo->acctOpt = *pAcctInfo; assert(pName != NULL); - pInfo->pDCLInfo->user.user = *pName; + pInfo->pMiscInfo->user.user = *pName; if (pPwd != NULL) { - pInfo->pDCLInfo->user.passwd = *pPwd; + pInfo->pMiscInfo->user.passwd = *pPwd; } } void setCreateUserSql(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd) { pInfo->type = TSDB_SQL_CREATE_USER; - if (pInfo->pDCLInfo == NULL) { - pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL)); + if (pInfo->pMiscInfo == NULL) { + pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo)); } assert(pName != NULL && pPasswd != NULL); - pInfo->pDCLInfo->user.user = *pName; - pInfo->pDCLInfo->user.passwd = *pPasswd; + pInfo->pMiscInfo->user.user = *pName; + pInfo->pMiscInfo->user.passwd = *pPasswd; } void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege) { pInfo->type = TSDB_SQL_ALTER_USER; - if (pInfo->pDCLInfo == NULL) { - pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL)); + if (pInfo->pMiscInfo == NULL) { + pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo)); } assert(pName != NULL); - SUserInfo* pUser = &pInfo->pDCLInfo->user; + SUserInfo* pUser = &pInfo->pMiscInfo->user; pUser->type = type; pUser->user = *pName; @@ -826,18 +819,17 @@ void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* } } -void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *ip) { +void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *id) { pInfo->type = type; - if (pInfo->pDCLInfo == NULL) { - pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL)); + if (pInfo->pMiscInfo == NULL) { + pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo)); } - assert(ip != NULL); - - pInfo->pDCLInfo->ip = *ip; + assert(id != NULL); + pInfo->pMiscInfo->id = *id; } -void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) { +void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo) { pDBInfo->compressionLevel = -1; pDBInfo->walLevel = -1; diff --git a/src/query/src/qPercentile.c b/src/query/src/qPercentile.c index 3e4891092a9696f871f2295555156730bd7b224a..523fa42547e34e9f0bb9ac23868ab3dc67eeec34 100644 --- a/src/query/src/qPercentile.c +++ b/src/query/src/qPercentile.c @@ -115,6 +115,11 @@ int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) { GET_TYPED_DATA(v, int64_t, pBucket->type, value); int32_t index = -1; + + if (v > pBucket->range.i64MaxVal || v < pBucket->range.i64MinVal) { + return index; + } + // divide the value range into 1024 buckets uint64_t span = pBucket->range.i64MaxVal - pBucket->range.i64MinVal; if (span < pBucket->numOfSlots) { @@ -128,7 +133,7 @@ int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) { } } - assert(v >= pBucket->range.i64MinVal && v <= pBucket->range.i64MaxVal && index >= 0 && index < pBucket->numOfSlots); + assert(index >= 0 && index < pBucket->numOfSlots); return index; } @@ -137,6 +142,11 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) { GET_TYPED_DATA(v, uint64_t, pBucket->type, value); int32_t index = -1; + + if (v > pBucket->range.u64MaxVal || v < pBucket->range.u64MinVal) { + return index; + } + // divide the value range into 1024 buckets uint64_t span = pBucket->range.u64MaxVal - pBucket->range.u64MinVal; if (span < pBucket->numOfSlots) { @@ -150,7 +160,7 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) { } } - assert(v >= pBucket->range.u64MinVal && v <= pBucket->range.i64MaxVal && index >= 0 && index < pBucket->numOfSlots); + assert(index >= 0 && index < pBucket->numOfSlots); return index; } @@ -164,6 +174,10 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) { int32_t index = -1; + if (v > pBucket->range.dMaxVal || v < pBucket->range.dMinVal) { + return index; + } + // divide a range of [dMinVal, dMaxVal] into 1024 buckets double span = pBucket->range.dMaxVal - pBucket->range.dMinVal; if (span < pBucket->numOfSlots) { @@ -177,7 +191,7 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) { } } - assert(v >= pBucket->range.dMinVal && v <= pBucket->range.dMaxVal && index >= 0 && index < pBucket->numOfSlots); + assert(index >= 0 && index < pBucket->numOfSlots); return index; } @@ -309,9 +323,13 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { int32_t bytes = pBucket->bytes; for (int32_t i = 0; i < size; ++i) { char *d = (char *) data + i * bytes; - count += 1; int32_t index = (pBucket->hashFunc)(pBucket, d); + if (index < 0) { + continue; + } + + count += 1; tMemBucketSlot *pSlot = &pBucket->pSlots[index]; tMemBucketUpdateBoundingBox(&pSlot->range, d, pBucket->type); diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 6c59a5107404eac92632ebcd4f418ccc8468dafe..cc5d6c0b4a57ea37a208ef5eebc045fde60efc6f 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -97,27 +97,27 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 279 +#define YYNOCODE 280 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; + SQuerySQL* yy30; SCreateTableSQL* yy38; - SCreateAcctSQL yy71; - tSQLExpr* yy78; - int yy96; - SQuerySQL* yy148; - SCreatedTableInfo yy152; + SCreatedTableInfo yy78; + SLimitVal yy126; + int yy130; + SArray* yy135; SSubclauseInfo* yy153; - tSQLExprList* yy166; - SLimitVal yy167; - TAOS_FIELD yy183; - SCreateDBInfo yy234; - int64_t yy325; - SIntervalVal yy400; - SArray* yy421; - tVariant yy430; + SIntervalVal yy160; + TAOS_FIELD yy181; + SCreateDbInfo yy256; + tSQLExprList* yy266; + SCreateAcctInfo yy277; + tVariant yy308; + tSQLExpr* yy316; + int64_t yy531; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -127,17 +127,17 @@ typedef union { #define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo #define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 -#define YYNSTATE 258 -#define YYNRULE 240 +#define YYNSTATE 282 +#define YYNRULE 248 #define YYNTOKEN 209 -#define YY_MAX_SHIFT 257 -#define YY_MIN_SHIFTREDUCE 431 -#define YY_MAX_SHIFTREDUCE 670 -#define YY_ERROR_ACTION 671 -#define YY_ACCEPT_ACTION 672 -#define YY_NO_ACTION 673 -#define YY_MIN_REDUCE 674 -#define YY_MAX_REDUCE 913 +#define YY_MAX_SHIFT 281 +#define YY_MIN_SHIFTREDUCE 461 +#define YY_MAX_SHIFTREDUCE 708 +#define YY_ERROR_ACTION 709 +#define YY_ACCEPT_ACTION 710 +#define YY_NO_ACTION 711 +#define YY_MIN_REDUCE 712 +#define YY_MAX_REDUCE 959 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined @@ -203,228 +203,243 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (586) +#define YY_ACTTAB_COUNT (622) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 143, 474, 143, 23, 672, 257, 165, 547, 827, 475, - /* 10 */ 900, 168, 901, 37, 38, 12, 39, 40, 816, 23, - /* 20 */ 173, 31, 474, 474, 210, 43, 41, 45, 42, 805, - /* 30 */ 475, 475, 163, 36, 35, 232, 231, 34, 33, 32, - /* 40 */ 37, 38, 801, 39, 40, 816, 110, 173, 31, 162, - /* 50 */ 255, 210, 43, 41, 45, 42, 176, 66, 802, 195, - /* 60 */ 36, 35, 178, 824, 34, 33, 32, 432, 433, 434, - /* 70 */ 435, 436, 437, 438, 439, 440, 441, 442, 443, 256, - /* 80 */ 179, 225, 185, 37, 38, 805, 39, 40, 796, 242, - /* 90 */ 173, 31, 143, 180, 210, 43, 41, 45, 42, 110, - /* 100 */ 110, 167, 901, 36, 35, 57, 853, 34, 33, 32, - /* 110 */ 17, 223, 250, 249, 222, 221, 220, 248, 219, 247, - /* 120 */ 246, 245, 218, 244, 243, 803, 142, 774, 624, 762, - /* 130 */ 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, - /* 140 */ 773, 775, 776, 38, 181, 39, 40, 229, 228, 173, - /* 150 */ 31, 605, 606, 210, 43, 41, 45, 42, 207, 854, - /* 160 */ 61, 205, 36, 35, 23, 110, 34, 33, 32, 188, - /* 170 */ 39, 40, 23, 251, 173, 31, 192, 191, 210, 43, - /* 180 */ 41, 45, 42, 34, 33, 32, 105, 36, 35, 104, - /* 190 */ 147, 34, 33, 32, 172, 637, 805, 28, 628, 897, - /* 200 */ 631, 177, 634, 802, 172, 637, 896, 13, 628, 230, - /* 210 */ 631, 802, 634, 18, 172, 637, 794, 895, 628, 63, - /* 220 */ 631, 28, 634, 155, 574, 62, 169, 170, 23, 156, - /* 230 */ 209, 29, 197, 92, 91, 150, 169, 170, 77, 76, - /* 240 */ 582, 17, 198, 250, 249, 159, 169, 170, 248, 626, - /* 250 */ 247, 246, 245, 715, 244, 243, 133, 211, 780, 80, - /* 260 */ 160, 778, 779, 18, 242, 234, 781, 802, 783, 784, - /* 270 */ 782, 28, 785, 786, 43, 41, 45, 42, 724, 579, - /* 280 */ 64, 133, 36, 35, 19, 627, 34, 33, 32, 3, - /* 290 */ 124, 194, 225, 44, 910, 72, 68, 71, 158, 11, - /* 300 */ 10, 566, 592, 44, 563, 636, 564, 107, 565, 793, - /* 310 */ 22, 795, 630, 44, 633, 636, 716, 36, 35, 133, - /* 320 */ 635, 34, 33, 32, 171, 636, 596, 49, 78, 82, - /* 330 */ 635, 48, 182, 183, 87, 90, 81, 137, 135, 629, - /* 340 */ 635, 632, 84, 95, 94, 93, 50, 9, 145, 640, - /* 350 */ 52, 65, 120, 254, 253, 98, 597, 656, 638, 555, - /* 360 */ 146, 15, 14, 14, 24, 4, 55, 53, 546, 213, - /* 370 */ 556, 570, 148, 571, 24, 48, 568, 149, 569, 89, - /* 380 */ 88, 103, 101, 153, 154, 152, 141, 151, 144, 804, - /* 390 */ 864, 863, 818, 174, 860, 859, 175, 233, 826, 846, - /* 400 */ 831, 833, 106, 121, 845, 122, 567, 119, 123, 726, - /* 410 */ 217, 139, 26, 226, 102, 723, 28, 227, 909, 74, - /* 420 */ 908, 906, 125, 744, 27, 25, 196, 140, 713, 591, - /* 430 */ 83, 711, 85, 86, 199, 709, 708, 184, 54, 134, - /* 440 */ 706, 164, 705, 704, 703, 702, 136, 700, 698, 696, - /* 450 */ 694, 692, 138, 203, 58, 59, 51, 847, 815, 46, - /* 460 */ 208, 206, 204, 202, 200, 30, 79, 235, 236, 237, - /* 470 */ 238, 239, 240, 241, 161, 215, 216, 252, 670, 187, - /* 480 */ 186, 669, 69, 189, 157, 190, 668, 193, 661, 707, - /* 490 */ 197, 576, 60, 56, 593, 96, 128, 97, 127, 745, - /* 500 */ 126, 130, 129, 131, 132, 701, 693, 113, 111, 118, - /* 510 */ 116, 114, 112, 115, 800, 1, 117, 2, 166, 20, - /* 520 */ 108, 201, 6, 598, 109, 7, 639, 5, 8, 21, - /* 530 */ 16, 67, 212, 641, 214, 515, 65, 511, 509, 508, - /* 540 */ 507, 504, 478, 224, 70, 47, 73, 75, 24, 549, - /* 550 */ 548, 545, 499, 497, 489, 495, 491, 493, 487, 485, - /* 560 */ 517, 516, 514, 513, 512, 510, 506, 505, 48, 476, - /* 570 */ 447, 445, 674, 673, 673, 673, 673, 673, 673, 673, - /* 580 */ 673, 673, 673, 673, 99, 100, + /* 0 */ 158, 505, 158, 710, 281, 857, 15, 578, 182, 506, + /* 10 */ 941, 185, 942, 41, 42, 157, 43, 44, 26, 179, + /* 20 */ 190, 35, 505, 505, 231, 47, 45, 49, 46, 868, + /* 30 */ 506, 506, 846, 40, 39, 256, 255, 38, 37, 36, + /* 40 */ 41, 42, 162, 43, 44, 857, 951, 190, 35, 178, + /* 50 */ 279, 231, 47, 45, 49, 46, 180, 195, 843, 214, + /* 60 */ 40, 39, 938, 61, 38, 37, 36, 462, 463, 464, + /* 70 */ 465, 466, 467, 468, 469, 470, 471, 472, 473, 280, + /* 80 */ 198, 846, 204, 41, 42, 865, 43, 44, 246, 266, + /* 90 */ 190, 35, 158, 834, 231, 47, 45, 49, 46, 122, + /* 100 */ 122, 184, 942, 40, 39, 122, 62, 38, 37, 36, + /* 110 */ 20, 244, 274, 273, 243, 242, 241, 272, 240, 271, + /* 120 */ 270, 269, 239, 268, 267, 38, 37, 36, 813, 657, + /* 130 */ 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, + /* 140 */ 811, 812, 814, 815, 42, 200, 43, 44, 253, 252, + /* 150 */ 190, 35, 937, 275, 231, 47, 45, 49, 46, 228, + /* 160 */ 895, 66, 226, 40, 39, 115, 894, 38, 37, 36, + /* 170 */ 26, 43, 44, 32, 26, 190, 35, 846, 207, 231, + /* 180 */ 47, 45, 49, 46, 26, 211, 210, 754, 40, 39, + /* 190 */ 146, 845, 38, 37, 36, 189, 670, 117, 835, 661, + /* 200 */ 71, 664, 26, 667, 763, 189, 670, 146, 193, 661, + /* 210 */ 843, 664, 194, 667, 843, 189, 670, 16, 26, 661, + /* 220 */ 936, 664, 249, 667, 843, 10, 21, 186, 187, 70, + /* 230 */ 132, 230, 837, 166, 32, 196, 69, 186, 187, 167, + /* 240 */ 250, 615, 843, 122, 102, 101, 165, 186, 187, 174, + /* 250 */ 20, 26, 274, 273, 219, 905, 254, 272, 843, 271, + /* 260 */ 270, 269, 607, 268, 267, 832, 833, 25, 836, 819, + /* 270 */ 216, 90, 817, 818, 21, 246, 266, 820, 68, 822, + /* 280 */ 823, 821, 32, 824, 825, 47, 45, 49, 46, 258, + /* 290 */ 33, 843, 199, 40, 39, 48, 26, 38, 37, 36, + /* 300 */ 197, 217, 213, 248, 67, 48, 27, 669, 659, 173, + /* 310 */ 278, 277, 109, 755, 232, 48, 146, 669, 599, 638, + /* 320 */ 639, 596, 668, 597, 844, 598, 612, 669, 175, 40, + /* 330 */ 39, 22, 668, 38, 37, 36, 842, 160, 625, 88, + /* 340 */ 92, 188, 668, 119, 660, 82, 97, 100, 91, 201, + /* 350 */ 202, 99, 98, 629, 94, 3, 136, 161, 52, 152, + /* 360 */ 148, 29, 77, 73, 76, 150, 105, 104, 103, 630, + /* 370 */ 689, 671, 53, 56, 18, 17, 17, 663, 163, 666, + /* 380 */ 662, 588, 665, 4, 81, 80, 27, 234, 589, 164, + /* 390 */ 57, 54, 27, 52, 12, 11, 87, 86, 59, 603, + /* 400 */ 577, 604, 14, 13, 601, 170, 602, 673, 114, 112, + /* 410 */ 171, 169, 156, 168, 159, 859, 904, 191, 901, 116, + /* 420 */ 900, 192, 257, 867, 600, 872, 874, 887, 118, 886, + /* 430 */ 133, 134, 32, 131, 135, 765, 238, 154, 30, 247, + /* 440 */ 762, 956, 78, 955, 953, 137, 251, 950, 84, 113, + /* 450 */ 949, 947, 138, 783, 31, 28, 155, 752, 93, 750, + /* 460 */ 215, 95, 96, 748, 624, 58, 747, 203, 147, 745, + /* 470 */ 744, 743, 742, 220, 741, 55, 149, 50, 181, 229, + /* 480 */ 224, 856, 227, 124, 151, 738, 736, 734, 732, 730, + /* 490 */ 225, 223, 221, 153, 34, 218, 89, 63, 64, 259, + /* 500 */ 260, 888, 261, 262, 264, 263, 265, 276, 708, 205, + /* 510 */ 206, 707, 208, 209, 706, 176, 236, 237, 694, 177, + /* 520 */ 172, 212, 74, 216, 65, 609, 746, 60, 233, 106, + /* 530 */ 6, 183, 740, 141, 107, 140, 784, 139, 142, 144, + /* 540 */ 143, 145, 739, 1, 108, 841, 731, 2, 626, 129, + /* 550 */ 127, 125, 123, 126, 128, 120, 222, 130, 631, 121, + /* 560 */ 23, 7, 8, 672, 24, 5, 9, 674, 19, 72, + /* 570 */ 235, 546, 542, 70, 540, 539, 538, 535, 509, 245, + /* 580 */ 79, 75, 27, 83, 51, 580, 579, 576, 530, 528, + /* 590 */ 520, 526, 522, 85, 524, 518, 516, 548, 547, 545, + /* 600 */ 544, 543, 541, 537, 536, 52, 507, 477, 475, 110, + /* 610 */ 712, 711, 711, 711, 711, 711, 711, 711, 711, 711, + /* 620 */ 711, 111, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 267, 1, 267, 213, 210, 211, 230, 5, 213, 9, - /* 10 */ 277, 276, 277, 13, 14, 267, 16, 17, 251, 213, - /* 20 */ 20, 21, 1, 1, 24, 25, 26, 27, 28, 253, - /* 30 */ 9, 9, 265, 33, 34, 33, 34, 37, 38, 39, - /* 40 */ 13, 14, 252, 16, 17, 251, 213, 20, 21, 212, - /* 50 */ 213, 24, 25, 26, 27, 28, 250, 218, 252, 265, - /* 60 */ 33, 34, 230, 268, 37, 38, 39, 45, 46, 47, + /* 0 */ 268, 1, 268, 210, 211, 252, 268, 5, 230, 9, + /* 10 */ 278, 277, 278, 13, 14, 268, 16, 17, 213, 266, + /* 20 */ 20, 21, 1, 1, 24, 25, 26, 27, 28, 213, + /* 30 */ 9, 9, 254, 33, 34, 33, 34, 37, 38, 39, + /* 40 */ 13, 14, 268, 16, 17, 252, 254, 20, 21, 212, + /* 50 */ 213, 24, 25, 26, 27, 28, 251, 230, 253, 266, + /* 60 */ 33, 34, 268, 218, 37, 38, 39, 45, 46, 47, /* 70 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - /* 80 */ 66, 76, 60, 13, 14, 253, 16, 17, 249, 78, - /* 90 */ 20, 21, 267, 213, 24, 25, 26, 27, 28, 213, - /* 100 */ 213, 276, 277, 33, 34, 105, 273, 37, 38, 39, - /* 110 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - /* 120 */ 95, 96, 97, 98, 99, 245, 267, 229, 101, 231, - /* 130 */ 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, - /* 140 */ 242, 243, 244, 14, 130, 16, 17, 133, 134, 20, - /* 150 */ 21, 118, 119, 24, 25, 26, 27, 28, 271, 273, - /* 160 */ 273, 275, 33, 34, 213, 213, 37, 38, 39, 129, - /* 170 */ 16, 17, 213, 230, 20, 21, 136, 137, 24, 25, - /* 180 */ 26, 27, 28, 37, 38, 39, 213, 33, 34, 100, - /* 190 */ 267, 37, 38, 39, 1, 2, 253, 108, 5, 267, - /* 200 */ 7, 250, 9, 252, 1, 2, 267, 44, 5, 250, - /* 210 */ 7, 252, 9, 100, 1, 2, 0, 267, 5, 254, - /* 220 */ 7, 108, 9, 60, 101, 273, 33, 34, 213, 66, - /* 230 */ 37, 266, 109, 70, 71, 72, 33, 34, 131, 132, - /* 240 */ 37, 85, 269, 87, 88, 267, 33, 34, 92, 1, - /* 250 */ 94, 95, 96, 217, 98, 99, 220, 15, 229, 73, - /* 260 */ 267, 232, 233, 100, 78, 250, 237, 252, 239, 240, - /* 270 */ 241, 108, 243, 244, 25, 26, 27, 28, 217, 106, - /* 280 */ 218, 220, 33, 34, 111, 37, 37, 38, 39, 61, - /* 290 */ 62, 128, 76, 100, 253, 67, 68, 69, 135, 131, - /* 300 */ 132, 2, 101, 100, 5, 112, 7, 106, 9, 247, - /* 310 */ 248, 249, 5, 100, 7, 112, 217, 33, 34, 220, - /* 320 */ 127, 37, 38, 39, 59, 112, 101, 106, 61, 62, - /* 330 */ 127, 106, 33, 34, 67, 68, 69, 61, 62, 5, - /* 340 */ 127, 7, 75, 67, 68, 69, 125, 100, 267, 107, - /* 350 */ 106, 104, 105, 63, 64, 65, 101, 101, 101, 101, - /* 360 */ 267, 106, 106, 106, 106, 100, 100, 123, 102, 101, - /* 370 */ 101, 5, 267, 7, 106, 106, 5, 267, 7, 73, - /* 380 */ 74, 61, 62, 267, 267, 267, 267, 267, 267, 253, - /* 390 */ 246, 246, 251, 246, 246, 246, 246, 246, 213, 274, - /* 400 */ 213, 213, 213, 213, 274, 213, 107, 255, 213, 213, - /* 410 */ 213, 213, 213, 213, 59, 213, 108, 213, 213, 213, - /* 420 */ 213, 213, 213, 213, 213, 213, 251, 213, 213, 112, - /* 430 */ 213, 213, 213, 213, 270, 213, 213, 213, 122, 213, - /* 440 */ 213, 270, 213, 213, 213, 213, 213, 213, 213, 213, - /* 450 */ 213, 213, 213, 270, 214, 214, 124, 214, 264, 121, - /* 460 */ 116, 120, 115, 114, 113, 126, 84, 83, 49, 80, - /* 470 */ 82, 53, 81, 79, 214, 214, 214, 76, 5, 5, - /* 480 */ 138, 5, 218, 138, 214, 5, 5, 129, 86, 214, - /* 490 */ 109, 101, 106, 110, 101, 215, 222, 215, 226, 228, - /* 500 */ 227, 223, 225, 224, 221, 214, 214, 261, 263, 256, - /* 510 */ 258, 260, 262, 259, 251, 219, 257, 216, 1, 106, - /* 520 */ 100, 100, 117, 101, 100, 117, 101, 100, 100, 106, - /* 530 */ 100, 73, 103, 107, 103, 9, 104, 5, 5, 5, - /* 540 */ 5, 5, 77, 15, 73, 16, 132, 132, 106, 5, - /* 550 */ 5, 101, 5, 5, 5, 5, 5, 5, 5, 5, - /* 560 */ 5, 5, 5, 5, 5, 5, 5, 5, 106, 77, - /* 570 */ 59, 58, 0, 278, 278, 278, 278, 278, 278, 278, - /* 580 */ 278, 278, 278, 278, 21, 21, 278, 278, 278, 278, - /* 590 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 600 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 610 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 620 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 630 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 640 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 650 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 660 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 670 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 680 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 690 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 700 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 710 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 720 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 730 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 740 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 750 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 760 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 770 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 780 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 790 */ 278, 278, 278, 278, 278, + /* 80 */ 66, 254, 60, 13, 14, 269, 16, 17, 77, 79, + /* 90 */ 20, 21, 268, 248, 24, 25, 26, 27, 28, 213, + /* 100 */ 213, 277, 278, 33, 34, 213, 106, 37, 38, 39, + /* 110 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + /* 120 */ 96, 97, 98, 99, 100, 37, 38, 39, 229, 102, + /* 130 */ 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, + /* 140 */ 241, 242, 243, 244, 14, 131, 16, 17, 134, 135, + /* 150 */ 20, 21, 268, 230, 24, 25, 26, 27, 28, 272, + /* 160 */ 274, 274, 276, 33, 34, 101, 274, 37, 38, 39, + /* 170 */ 213, 16, 17, 109, 213, 20, 21, 254, 130, 24, + /* 180 */ 25, 26, 27, 28, 213, 137, 138, 217, 33, 34, + /* 190 */ 220, 254, 37, 38, 39, 1, 2, 213, 0, 5, + /* 200 */ 218, 7, 213, 9, 217, 1, 2, 220, 251, 5, + /* 210 */ 253, 7, 251, 9, 253, 1, 2, 44, 213, 5, + /* 220 */ 268, 7, 251, 9, 253, 101, 101, 33, 34, 105, + /* 230 */ 106, 37, 250, 60, 109, 66, 218, 33, 34, 66, + /* 240 */ 251, 37, 253, 213, 71, 72, 73, 33, 34, 268, + /* 250 */ 86, 213, 88, 89, 270, 246, 251, 93, 253, 95, + /* 260 */ 96, 97, 102, 99, 100, 247, 248, 249, 250, 229, + /* 270 */ 110, 74, 232, 233, 101, 77, 79, 237, 255, 239, + /* 280 */ 240, 241, 109, 243, 244, 25, 26, 27, 28, 251, + /* 290 */ 267, 253, 213, 33, 34, 101, 213, 37, 38, 39, + /* 300 */ 131, 102, 129, 134, 274, 101, 107, 113, 1, 136, + /* 310 */ 63, 64, 65, 217, 15, 101, 220, 113, 2, 119, + /* 320 */ 120, 5, 128, 7, 245, 9, 107, 113, 268, 33, + /* 330 */ 34, 112, 128, 37, 38, 39, 253, 268, 102, 61, + /* 340 */ 62, 59, 128, 107, 37, 67, 68, 69, 70, 33, + /* 350 */ 34, 74, 75, 102, 76, 61, 62, 268, 107, 61, + /* 360 */ 62, 67, 68, 69, 70, 67, 68, 69, 70, 102, + /* 370 */ 102, 102, 107, 107, 107, 107, 107, 5, 268, 7, + /* 380 */ 5, 102, 7, 101, 132, 133, 107, 102, 102, 268, + /* 390 */ 124, 126, 107, 107, 132, 133, 132, 133, 101, 5, + /* 400 */ 103, 7, 132, 133, 5, 268, 7, 108, 61, 62, + /* 410 */ 268, 268, 268, 268, 268, 252, 246, 246, 246, 213, + /* 420 */ 246, 246, 246, 213, 108, 213, 213, 275, 213, 275, + /* 430 */ 213, 213, 109, 256, 213, 213, 213, 213, 213, 213, + /* 440 */ 213, 213, 213, 213, 213, 213, 213, 213, 213, 59, + /* 450 */ 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, + /* 460 */ 252, 213, 213, 213, 113, 123, 213, 213, 213, 213, + /* 470 */ 213, 213, 213, 271, 213, 125, 213, 122, 271, 117, + /* 480 */ 271, 265, 121, 263, 213, 213, 213, 213, 213, 213, + /* 490 */ 116, 115, 114, 213, 127, 214, 85, 214, 214, 84, + /* 500 */ 49, 214, 81, 83, 82, 53, 80, 77, 5, 139, + /* 510 */ 5, 5, 139, 5, 5, 214, 214, 214, 87, 214, + /* 520 */ 214, 130, 218, 110, 107, 102, 214, 111, 104, 215, + /* 530 */ 101, 1, 214, 222, 215, 226, 228, 227, 225, 224, + /* 540 */ 223, 221, 214, 219, 215, 252, 214, 216, 102, 258, + /* 550 */ 260, 262, 264, 261, 259, 101, 101, 257, 102, 101, + /* 560 */ 107, 118, 118, 102, 107, 101, 101, 108, 101, 74, + /* 570 */ 104, 9, 5, 105, 5, 5, 5, 5, 78, 15, + /* 580 */ 133, 74, 107, 133, 16, 5, 5, 102, 5, 5, + /* 590 */ 5, 5, 5, 133, 5, 5, 5, 5, 5, 5, + /* 600 */ 5, 5, 5, 5, 5, 107, 78, 59, 58, 21, + /* 610 */ 0, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 620 */ 279, 21, 279, 279, 279, 279, 279, 279, 279, 279, + /* 630 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 640 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 650 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 660 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 670 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 680 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 690 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 700 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 710 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 720 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 730 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 740 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 750 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 760 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 770 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 780 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 790 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 800 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 810 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 820 */ 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + /* 830 */ 279, }; -#define YY_SHIFT_COUNT (257) +#define YY_SHIFT_COUNT (281) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (572) +#define YY_SHIFT_MAX (610) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 163, 25, 156, 5, 193, 213, 21, 21, 21, 21, - /* 10 */ 21, 21, 0, 22, 213, 299, 299, 299, 113, 21, - /* 20 */ 21, 21, 216, 21, 21, 186, 11, 11, 586, 203, - /* 30 */ 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, - /* 40 */ 213, 213, 213, 213, 213, 213, 213, 299, 299, 2, - /* 50 */ 2, 2, 2, 2, 2, 2, 89, 21, 21, 21, - /* 60 */ 21, 33, 33, 173, 21, 21, 21, 21, 21, 21, + /* 0 */ 173, 24, 164, 11, 194, 214, 21, 21, 21, 21, + /* 10 */ 21, 21, 21, 21, 21, 0, 22, 214, 316, 316, + /* 20 */ 316, 125, 21, 21, 21, 198, 21, 21, 197, 11, + /* 30 */ 10, 10, 622, 204, 214, 214, 214, 214, 214, 214, + /* 40 */ 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, + /* 50 */ 214, 316, 316, 2, 2, 2, 2, 2, 2, 2, + /* 60 */ 64, 21, 21, 21, 21, 21, 200, 200, 219, 21, /* 70 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, /* 80 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, /* 90 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - /* 100 */ 21, 21, 21, 21, 308, 355, 355, 317, 317, 317, - /* 110 */ 355, 316, 332, 338, 344, 341, 347, 349, 351, 339, - /* 120 */ 308, 355, 355, 355, 5, 355, 382, 384, 419, 389, - /* 130 */ 388, 418, 391, 394, 355, 401, 355, 401, 355, 586, - /* 140 */ 586, 27, 70, 70, 70, 129, 154, 249, 249, 249, - /* 150 */ 267, 284, 284, 284, 284, 228, 276, 14, 40, 146, - /* 160 */ 146, 247, 290, 123, 201, 225, 255, 256, 257, 307, - /* 170 */ 334, 248, 265, 242, 221, 244, 258, 268, 269, 107, - /* 180 */ 266, 168, 366, 371, 306, 320, 473, 342, 474, 476, - /* 190 */ 345, 480, 481, 402, 358, 381, 390, 383, 386, 393, - /* 200 */ 420, 517, 421, 422, 424, 413, 405, 423, 408, 425, - /* 210 */ 427, 426, 428, 429, 430, 431, 432, 458, 526, 532, - /* 220 */ 533, 534, 535, 536, 465, 528, 471, 529, 414, 415, - /* 230 */ 442, 544, 545, 450, 442, 547, 548, 549, 550, 551, - /* 240 */ 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, - /* 250 */ 562, 462, 492, 563, 564, 511, 513, 572, + /* 100 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + /* 110 */ 21, 21, 21, 21, 21, 323, 390, 390, 390, 351, + /* 120 */ 351, 351, 390, 342, 350, 355, 362, 361, 374, 376, + /* 130 */ 378, 367, 323, 390, 390, 390, 11, 390, 390, 411, + /* 140 */ 415, 451, 421, 420, 452, 422, 426, 390, 430, 390, + /* 150 */ 430, 390, 430, 390, 622, 622, 27, 70, 70, 70, + /* 160 */ 130, 155, 260, 260, 260, 278, 294, 298, 296, 296, + /* 170 */ 296, 296, 14, 48, 88, 88, 124, 169, 247, 160, + /* 180 */ 199, 236, 251, 267, 268, 269, 372, 375, 307, 282, + /* 190 */ 299, 265, 266, 279, 285, 286, 252, 262, 264, 297, + /* 200 */ 270, 394, 399, 277, 347, 503, 370, 505, 506, 373, + /* 210 */ 508, 509, 431, 391, 413, 423, 416, 424, 429, 417, + /* 220 */ 446, 454, 530, 455, 456, 458, 453, 443, 457, 444, + /* 230 */ 461, 464, 459, 465, 424, 467, 466, 468, 495, 562, + /* 240 */ 567, 569, 570, 571, 572, 500, 564, 507, 447, 475, + /* 250 */ 475, 568, 450, 460, 475, 580, 581, 485, 475, 583, + /* 260 */ 584, 585, 586, 587, 589, 590, 591, 592, 593, 594, + /* 270 */ 595, 596, 597, 598, 599, 498, 528, 588, 600, 548, + /* 280 */ 550, 610, }; -#define YY_REDUCE_COUNT (140) -#define YY_REDUCE_MIN (-267) -#define YY_REDUCE_MAX (301) +#define YY_REDUCE_COUNT (155) +#define YY_REDUCE_MIN (-268) +#define YY_REDUCE_MAX (332) static const short yy_reduce_ofst[] = { - /* 0 */ -206, -102, 29, 62, -265, -175, -114, -113, -194, -49, - /* 10 */ -41, 15, -205, -163, -267, -224, -168, -57, -233, -27, - /* 20 */ -167, -48, -161, -120, -210, 36, 61, 99, -35, -252, - /* 30 */ -141, -77, -68, -61, -50, -22, -7, 81, 93, 105, - /* 40 */ 110, 116, 117, 118, 119, 120, 121, 41, 136, 144, - /* 50 */ 145, 147, 148, 149, 150, 151, 141, 185, 187, 188, - /* 60 */ 189, 125, 130, 152, 190, 192, 195, 196, 197, 198, - /* 70 */ 199, 200, 202, 204, 205, 206, 207, 208, 209, 210, - /* 80 */ 211, 212, 214, 215, 217, 218, 219, 220, 222, 223, - /* 90 */ 224, 226, 227, 229, 230, 231, 232, 233, 234, 235, - /* 100 */ 236, 237, 238, 239, 175, 240, 241, 164, 171, 183, - /* 110 */ 243, 194, 245, 250, 246, 251, 254, 252, 259, 253, - /* 120 */ 263, 260, 261, 262, 264, 270, 271, 273, 272, 274, - /* 130 */ 277, 278, 279, 283, 275, 280, 291, 282, 292, 296, - /* 140 */ 301, + /* 0 */ -207, -101, 40, 18, -266, -176, -195, -114, -113, -43, + /* 10 */ -39, -29, -11, 5, 38, -184, -163, -268, -222, -173, + /* 20 */ -77, -247, -16, -108, 30, -18, 79, 83, -30, -155, + /* 30 */ -13, 96, 23, -262, -253, -226, -206, -116, -48, -19, + /* 40 */ 60, 69, 89, 110, 121, 137, 142, 143, 144, 145, + /* 50 */ 146, -208, -63, 9, 170, 171, 172, 174, 175, 176, + /* 60 */ 163, 206, 210, 212, 213, 215, 152, 154, 177, 217, + /* 70 */ 218, 221, 222, 223, 224, 225, 226, 227, 228, 229, + /* 80 */ 230, 231, 232, 233, 234, 235, 237, 238, 239, 240, + /* 90 */ 241, 242, 243, 244, 245, 246, 248, 249, 250, 253, + /* 100 */ 254, 255, 256, 257, 258, 259, 261, 263, 271, 272, + /* 110 */ 273, 274, 275, 276, 280, 208, 281, 283, 284, 202, + /* 120 */ 207, 209, 287, 216, 288, 220, 289, 292, 290, 295, + /* 130 */ 291, 300, 293, 301, 302, 303, 304, 305, 306, 308, + /* 140 */ 310, 309, 311, 313, 317, 315, 320, 312, 314, 318, + /* 150 */ 319, 328, 329, 332, 324, 331, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 671, 725, 714, 722, 903, 903, 671, 671, 671, 671, - /* 10 */ 671, 671, 828, 689, 903, 671, 671, 671, 671, 671, - /* 20 */ 671, 671, 722, 671, 671, 727, 727, 727, 823, 671, - /* 30 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, - /* 40 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, - /* 50 */ 671, 671, 671, 671, 671, 671, 671, 671, 830, 832, - /* 60 */ 671, 850, 850, 821, 671, 671, 671, 671, 671, 671, - /* 70 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, - /* 80 */ 671, 671, 671, 712, 671, 710, 671, 671, 671, 671, - /* 90 */ 671, 671, 671, 671, 671, 671, 671, 671, 699, 671, - /* 100 */ 671, 671, 671, 671, 671, 691, 691, 671, 671, 671, - /* 110 */ 691, 857, 861, 855, 843, 851, 842, 838, 837, 865, - /* 120 */ 671, 691, 691, 691, 722, 691, 743, 741, 739, 731, - /* 130 */ 737, 733, 735, 729, 691, 720, 691, 720, 691, 761, - /* 140 */ 777, 671, 866, 902, 856, 892, 891, 898, 890, 889, - /* 150 */ 671, 885, 886, 888, 887, 671, 671, 671, 671, 894, - /* 160 */ 893, 671, 671, 671, 671, 671, 671, 671, 671, 671, - /* 170 */ 671, 671, 868, 671, 862, 858, 671, 671, 671, 671, - /* 180 */ 787, 671, 671, 671, 671, 671, 671, 671, 671, 671, - /* 190 */ 671, 671, 671, 671, 671, 820, 671, 671, 829, 671, - /* 200 */ 671, 671, 671, 671, 671, 852, 671, 844, 671, 671, - /* 210 */ 671, 671, 671, 797, 671, 671, 671, 671, 671, 671, - /* 220 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, - /* 230 */ 907, 671, 671, 671, 905, 671, 671, 671, 671, 671, - /* 240 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, - /* 250 */ 671, 746, 671, 697, 695, 671, 687, 671, + /* 0 */ 709, 764, 753, 761, 944, 944, 709, 709, 709, 709, + /* 10 */ 709, 709, 709, 709, 709, 869, 727, 944, 709, 709, + /* 20 */ 709, 709, 709, 709, 709, 761, 709, 709, 766, 761, + /* 30 */ 766, 766, 864, 709, 709, 709, 709, 709, 709, 709, + /* 40 */ 709, 709, 709, 709, 709, 709, 709, 709, 709, 709, + /* 50 */ 709, 709, 709, 709, 709, 709, 709, 709, 709, 709, + /* 60 */ 709, 709, 709, 871, 873, 709, 891, 891, 862, 709, + /* 70 */ 709, 709, 709, 709, 709, 709, 709, 709, 709, 709, + /* 80 */ 709, 709, 709, 709, 709, 709, 709, 709, 709, 709, + /* 90 */ 709, 709, 709, 751, 709, 749, 709, 709, 709, 709, + /* 100 */ 709, 709, 709, 709, 709, 709, 709, 709, 709, 737, + /* 110 */ 709, 709, 709, 709, 709, 709, 729, 729, 729, 709, + /* 120 */ 709, 709, 729, 898, 902, 896, 884, 892, 883, 879, + /* 130 */ 878, 906, 709, 729, 729, 729, 761, 729, 729, 782, + /* 140 */ 780, 778, 770, 776, 772, 774, 768, 729, 759, 729, + /* 150 */ 759, 729, 759, 729, 800, 816, 709, 907, 943, 897, + /* 160 */ 933, 932, 939, 931, 930, 709, 709, 709, 926, 927, + /* 170 */ 929, 928, 709, 709, 935, 934, 709, 709, 709, 709, + /* 180 */ 709, 709, 709, 709, 709, 709, 709, 709, 709, 909, + /* 190 */ 709, 903, 899, 709, 709, 709, 709, 709, 709, 826, + /* 200 */ 709, 709, 709, 709, 709, 709, 709, 709, 709, 709, + /* 210 */ 709, 709, 709, 709, 861, 709, 709, 709, 709, 870, + /* 220 */ 709, 709, 709, 709, 709, 709, 893, 709, 885, 709, + /* 230 */ 709, 709, 709, 709, 838, 709, 709, 709, 709, 709, + /* 240 */ 709, 709, 709, 709, 709, 709, 709, 709, 709, 954, + /* 250 */ 952, 709, 709, 709, 948, 709, 709, 709, 946, 709, + /* 260 */ 709, 709, 709, 709, 709, 709, 709, 709, 709, 709, + /* 270 */ 709, 709, 709, 709, 709, 785, 709, 735, 733, 709, + /* 280 */ 725, 709, }; /********** End of lemon-generated parsing tables *****************************/ @@ -511,6 +526,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* STABLES => nothing */ 0, /* VGROUPS => nothing */ 0, /* DROP => nothing */ + 1, /* STABLE => ID */ 0, /* DNODE => nothing */ 0, /* USER => nothing */ 0, /* ACCOUNT => nothing */ @@ -649,7 +665,6 @@ static const YYCODETYPE yyFallback[] = { 1, /* TBNAME => ID */ 1, /* JOIN => ID */ 1, /* METRICS => ID */ - 1, /* STABLE => ID */ 1, /* INSERT => ID */ 1, /* INTO => ID */ 1, /* VALUES => ID */ @@ -806,145 +821,145 @@ static const char *const yyTokenName[] = { /* 64 */ "STABLES", /* 65 */ "VGROUPS", /* 66 */ "DROP", - /* 67 */ "DNODE", - /* 68 */ "USER", - /* 69 */ "ACCOUNT", - /* 70 */ "USE", - /* 71 */ "DESCRIBE", - /* 72 */ "ALTER", - /* 73 */ "PASS", - /* 74 */ "PRIVILEGE", - /* 75 */ "LOCAL", - /* 76 */ "IF", - /* 77 */ "EXISTS", - /* 78 */ "PPS", - /* 79 */ "TSERIES", - /* 80 */ "DBS", - /* 81 */ "STORAGE", - /* 82 */ "QTIME", - /* 83 */ "CONNS", - /* 84 */ "STATE", - /* 85 */ "KEEP", - /* 86 */ "CACHE", - /* 87 */ "REPLICA", - /* 88 */ "QUORUM", - /* 89 */ "DAYS", - /* 90 */ "MINROWS", - /* 91 */ "MAXROWS", - /* 92 */ "BLOCKS", - /* 93 */ "CTIME", - /* 94 */ "WAL", - /* 95 */ "FSYNC", - /* 96 */ "COMP", - /* 97 */ "PRECISION", - /* 98 */ "UPDATE", - /* 99 */ "CACHELAST", - /* 100 */ "LP", - /* 101 */ "RP", - /* 102 */ "UNSIGNED", - /* 103 */ "TAGS", - /* 104 */ "USING", - /* 105 */ "AS", - /* 106 */ "COMMA", - /* 107 */ "NULL", - /* 108 */ "SELECT", - /* 109 */ "UNION", - /* 110 */ "ALL", - /* 111 */ "FROM", - /* 112 */ "VARIABLE", - /* 113 */ "INTERVAL", - /* 114 */ "FILL", - /* 115 */ "SLIDING", - /* 116 */ "ORDER", - /* 117 */ "BY", - /* 118 */ "ASC", - /* 119 */ "DESC", - /* 120 */ "GROUP", - /* 121 */ "HAVING", - /* 122 */ "LIMIT", - /* 123 */ "OFFSET", - /* 124 */ "SLIMIT", - /* 125 */ "SOFFSET", - /* 126 */ "WHERE", - /* 127 */ "NOW", - /* 128 */ "RESET", - /* 129 */ "QUERY", - /* 130 */ "ADD", - /* 131 */ "COLUMN", - /* 132 */ "TAG", - /* 133 */ "CHANGE", - /* 134 */ "SET", - /* 135 */ "KILL", - /* 136 */ "CONNECTION", - /* 137 */ "STREAM", - /* 138 */ "COLON", - /* 139 */ "ABORT", - /* 140 */ "AFTER", - /* 141 */ "ATTACH", - /* 142 */ "BEFORE", - /* 143 */ "BEGIN", - /* 144 */ "CASCADE", - /* 145 */ "CLUSTER", - /* 146 */ "CONFLICT", - /* 147 */ "COPY", - /* 148 */ "DEFERRED", - /* 149 */ "DELIMITERS", - /* 150 */ "DETACH", - /* 151 */ "EACH", - /* 152 */ "END", - /* 153 */ "EXPLAIN", - /* 154 */ "FAIL", - /* 155 */ "FOR", - /* 156 */ "IGNORE", - /* 157 */ "IMMEDIATE", - /* 158 */ "INITIALLY", - /* 159 */ "INSTEAD", - /* 160 */ "MATCH", - /* 161 */ "KEY", - /* 162 */ "OF", - /* 163 */ "RAISE", - /* 164 */ "REPLACE", - /* 165 */ "RESTRICT", - /* 166 */ "ROW", - /* 167 */ "STATEMENT", - /* 168 */ "TRIGGER", - /* 169 */ "VIEW", - /* 170 */ "COUNT", - /* 171 */ "SUM", - /* 172 */ "AVG", - /* 173 */ "MIN", - /* 174 */ "MAX", - /* 175 */ "FIRST", - /* 176 */ "LAST", - /* 177 */ "TOP", - /* 178 */ "BOTTOM", - /* 179 */ "STDDEV", - /* 180 */ "PERCENTILE", - /* 181 */ "APERCENTILE", - /* 182 */ "LEASTSQUARES", - /* 183 */ "HISTOGRAM", - /* 184 */ "DIFF", - /* 185 */ "SPREAD", - /* 186 */ "TWA", - /* 187 */ "INTERP", - /* 188 */ "LAST_ROW", - /* 189 */ "RATE", - /* 190 */ "IRATE", - /* 191 */ "SUM_RATE", - /* 192 */ "SUM_IRATE", - /* 193 */ "AVG_RATE", - /* 194 */ "AVG_IRATE", - /* 195 */ "TBID", - /* 196 */ "SEMI", - /* 197 */ "NONE", - /* 198 */ "PREV", - /* 199 */ "LINEAR", - /* 200 */ "IMPORT", - /* 201 */ "METRIC", - /* 202 */ "TBNAME", - /* 203 */ "JOIN", - /* 204 */ "METRICS", - /* 205 */ "STABLE", + /* 67 */ "STABLE", + /* 68 */ "DNODE", + /* 69 */ "USER", + /* 70 */ "ACCOUNT", + /* 71 */ "USE", + /* 72 */ "DESCRIBE", + /* 73 */ "ALTER", + /* 74 */ "PASS", + /* 75 */ "PRIVILEGE", + /* 76 */ "LOCAL", + /* 77 */ "IF", + /* 78 */ "EXISTS", + /* 79 */ "PPS", + /* 80 */ "TSERIES", + /* 81 */ "DBS", + /* 82 */ "STORAGE", + /* 83 */ "QTIME", + /* 84 */ "CONNS", + /* 85 */ "STATE", + /* 86 */ "KEEP", + /* 87 */ "CACHE", + /* 88 */ "REPLICA", + /* 89 */ "QUORUM", + /* 90 */ "DAYS", + /* 91 */ "MINROWS", + /* 92 */ "MAXROWS", + /* 93 */ "BLOCKS", + /* 94 */ "CTIME", + /* 95 */ "WAL", + /* 96 */ "FSYNC", + /* 97 */ "COMP", + /* 98 */ "PRECISION", + /* 99 */ "UPDATE", + /* 100 */ "CACHELAST", + /* 101 */ "LP", + /* 102 */ "RP", + /* 103 */ "UNSIGNED", + /* 104 */ "TAGS", + /* 105 */ "USING", + /* 106 */ "AS", + /* 107 */ "COMMA", + /* 108 */ "NULL", + /* 109 */ "SELECT", + /* 110 */ "UNION", + /* 111 */ "ALL", + /* 112 */ "FROM", + /* 113 */ "VARIABLE", + /* 114 */ "INTERVAL", + /* 115 */ "FILL", + /* 116 */ "SLIDING", + /* 117 */ "ORDER", + /* 118 */ "BY", + /* 119 */ "ASC", + /* 120 */ "DESC", + /* 121 */ "GROUP", + /* 122 */ "HAVING", + /* 123 */ "LIMIT", + /* 124 */ "OFFSET", + /* 125 */ "SLIMIT", + /* 126 */ "SOFFSET", + /* 127 */ "WHERE", + /* 128 */ "NOW", + /* 129 */ "RESET", + /* 130 */ "QUERY", + /* 131 */ "ADD", + /* 132 */ "COLUMN", + /* 133 */ "TAG", + /* 134 */ "CHANGE", + /* 135 */ "SET", + /* 136 */ "KILL", + /* 137 */ "CONNECTION", + /* 138 */ "STREAM", + /* 139 */ "COLON", + /* 140 */ "ABORT", + /* 141 */ "AFTER", + /* 142 */ "ATTACH", + /* 143 */ "BEFORE", + /* 144 */ "BEGIN", + /* 145 */ "CASCADE", + /* 146 */ "CLUSTER", + /* 147 */ "CONFLICT", + /* 148 */ "COPY", + /* 149 */ "DEFERRED", + /* 150 */ "DELIMITERS", + /* 151 */ "DETACH", + /* 152 */ "EACH", + /* 153 */ "END", + /* 154 */ "EXPLAIN", + /* 155 */ "FAIL", + /* 156 */ "FOR", + /* 157 */ "IGNORE", + /* 158 */ "IMMEDIATE", + /* 159 */ "INITIALLY", + /* 160 */ "INSTEAD", + /* 161 */ "MATCH", + /* 162 */ "KEY", + /* 163 */ "OF", + /* 164 */ "RAISE", + /* 165 */ "REPLACE", + /* 166 */ "RESTRICT", + /* 167 */ "ROW", + /* 168 */ "STATEMENT", + /* 169 */ "TRIGGER", + /* 170 */ "VIEW", + /* 171 */ "COUNT", + /* 172 */ "SUM", + /* 173 */ "AVG", + /* 174 */ "MIN", + /* 175 */ "MAX", + /* 176 */ "FIRST", + /* 177 */ "LAST", + /* 178 */ "TOP", + /* 179 */ "BOTTOM", + /* 180 */ "STDDEV", + /* 181 */ "PERCENTILE", + /* 182 */ "APERCENTILE", + /* 183 */ "LEASTSQUARES", + /* 184 */ "HISTOGRAM", + /* 185 */ "DIFF", + /* 186 */ "SPREAD", + /* 187 */ "TWA", + /* 188 */ "INTERP", + /* 189 */ "LAST_ROW", + /* 190 */ "RATE", + /* 191 */ "IRATE", + /* 192 */ "SUM_RATE", + /* 193 */ "SUM_IRATE", + /* 194 */ "AVG_RATE", + /* 195 */ "AVG_IRATE", + /* 196 */ "TBID", + /* 197 */ "SEMI", + /* 198 */ "NONE", + /* 199 */ "PREV", + /* 200 */ "LINEAR", + /* 201 */ "IMPORT", + /* 202 */ "METRIC", + /* 203 */ "TBNAME", + /* 204 */ "JOIN", + /* 205 */ "METRICS", /* 206 */ "INSERT", /* 207 */ "INTO", /* 208 */ "VALUES", @@ -987,36 +1002,37 @@ static const char *const yyTokenName[] = { /* 245 */ "typename", /* 246 */ "signed", /* 247 */ "create_table_args", - /* 248 */ "create_table_list", - /* 249 */ "create_from_stable", - /* 250 */ "columnlist", - /* 251 */ "select", - /* 252 */ "column", - /* 253 */ "tagitem", - /* 254 */ "selcollist", - /* 255 */ "from", - /* 256 */ "where_opt", - /* 257 */ "interval_opt", - /* 258 */ "fill_opt", - /* 259 */ "sliding_opt", - /* 260 */ "groupby_opt", - /* 261 */ "orderby_opt", - /* 262 */ "having_opt", - /* 263 */ "slimit_opt", - /* 264 */ "limit_opt", - /* 265 */ "union", - /* 266 */ "sclp", - /* 267 */ "expr", - /* 268 */ "as", - /* 269 */ "tablelist", - /* 270 */ "tmvar", - /* 271 */ "sortlist", - /* 272 */ "sortitem", - /* 273 */ "item", - /* 274 */ "sortorder", - /* 275 */ "grouplist", - /* 276 */ "exprlist", - /* 277 */ "expritem", + /* 248 */ "create_stable_args", + /* 249 */ "create_table_list", + /* 250 */ "create_from_stable", + /* 251 */ "columnlist", + /* 252 */ "select", + /* 253 */ "column", + /* 254 */ "tagitem", + /* 255 */ "selcollist", + /* 256 */ "from", + /* 257 */ "where_opt", + /* 258 */ "interval_opt", + /* 259 */ "fill_opt", + /* 260 */ "sliding_opt", + /* 261 */ "groupby_opt", + /* 262 */ "orderby_opt", + /* 263 */ "having_opt", + /* 264 */ "slimit_opt", + /* 265 */ "limit_opt", + /* 266 */ "union", + /* 267 */ "sclp", + /* 268 */ "expr", + /* 269 */ "as", + /* 270 */ "tablelist", + /* 271 */ "tmvar", + /* 272 */ "sortlist", + /* 273 */ "sortitem", + /* 274 */ "item", + /* 275 */ "sortorder", + /* 276 */ "grouplist", + /* 277 */ "exprlist", + /* 278 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1052,218 +1068,226 @@ static const char *const yyRuleName[] = { /* 25 */ "cmd ::= SHOW dbPrefix VGROUPS", /* 26 */ "cmd ::= SHOW dbPrefix VGROUPS ids", /* 27 */ "cmd ::= DROP TABLE ifexists ids cpxName", - /* 28 */ "cmd ::= DROP DATABASE ifexists ids", - /* 29 */ "cmd ::= DROP DNODE ids", - /* 30 */ "cmd ::= DROP USER ids", - /* 31 */ "cmd ::= DROP ACCOUNT ids", - /* 32 */ "cmd ::= USE ids", - /* 33 */ "cmd ::= DESCRIBE ids cpxName", - /* 34 */ "cmd ::= ALTER USER ids PASS ids", - /* 35 */ "cmd ::= ALTER USER ids PRIVILEGE ids", - /* 36 */ "cmd ::= ALTER DNODE ids ids", - /* 37 */ "cmd ::= ALTER DNODE ids ids ids", - /* 38 */ "cmd ::= ALTER LOCAL ids", - /* 39 */ "cmd ::= ALTER LOCAL ids ids", - /* 40 */ "cmd ::= ALTER DATABASE ids alter_db_optr", - /* 41 */ "cmd ::= ALTER ACCOUNT ids acct_optr", - /* 42 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", - /* 43 */ "ids ::= ID", - /* 44 */ "ids ::= STRING", - /* 45 */ "ifexists ::= IF EXISTS", - /* 46 */ "ifexists ::=", - /* 47 */ "ifnotexists ::= IF NOT EXISTS", - /* 48 */ "ifnotexists ::=", - /* 49 */ "cmd ::= CREATE DNODE ids", - /* 50 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", - /* 51 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", - /* 52 */ "cmd ::= CREATE USER ids PASS ids", - /* 53 */ "pps ::=", - /* 54 */ "pps ::= PPS INTEGER", - /* 55 */ "tseries ::=", - /* 56 */ "tseries ::= TSERIES INTEGER", - /* 57 */ "dbs ::=", - /* 58 */ "dbs ::= DBS INTEGER", - /* 59 */ "streams ::=", - /* 60 */ "streams ::= STREAMS INTEGER", - /* 61 */ "storage ::=", - /* 62 */ "storage ::= STORAGE INTEGER", - /* 63 */ "qtime ::=", - /* 64 */ "qtime ::= QTIME INTEGER", - /* 65 */ "users ::=", - /* 66 */ "users ::= USERS INTEGER", - /* 67 */ "conns ::=", - /* 68 */ "conns ::= CONNS INTEGER", - /* 69 */ "state ::=", - /* 70 */ "state ::= STATE ids", - /* 71 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", - /* 72 */ "keep ::= KEEP tagitemlist", - /* 73 */ "cache ::= CACHE INTEGER", - /* 74 */ "replica ::= REPLICA INTEGER", - /* 75 */ "quorum ::= QUORUM INTEGER", - /* 76 */ "days ::= DAYS INTEGER", - /* 77 */ "minrows ::= MINROWS INTEGER", - /* 78 */ "maxrows ::= MAXROWS INTEGER", - /* 79 */ "blocks ::= BLOCKS INTEGER", - /* 80 */ "ctime ::= CTIME INTEGER", - /* 81 */ "wal ::= WAL INTEGER", - /* 82 */ "fsync ::= FSYNC INTEGER", - /* 83 */ "comp ::= COMP INTEGER", - /* 84 */ "prec ::= PRECISION STRING", - /* 85 */ "update ::= UPDATE INTEGER", - /* 86 */ "cachelast ::= CACHELAST INTEGER", - /* 87 */ "db_optr ::=", - /* 88 */ "db_optr ::= db_optr cache", - /* 89 */ "db_optr ::= db_optr replica", - /* 90 */ "db_optr ::= db_optr quorum", - /* 91 */ "db_optr ::= db_optr days", - /* 92 */ "db_optr ::= db_optr minrows", - /* 93 */ "db_optr ::= db_optr maxrows", - /* 94 */ "db_optr ::= db_optr blocks", - /* 95 */ "db_optr ::= db_optr ctime", - /* 96 */ "db_optr ::= db_optr wal", - /* 97 */ "db_optr ::= db_optr fsync", - /* 98 */ "db_optr ::= db_optr comp", - /* 99 */ "db_optr ::= db_optr prec", - /* 100 */ "db_optr ::= db_optr keep", - /* 101 */ "db_optr ::= db_optr update", - /* 102 */ "db_optr ::= db_optr cachelast", - /* 103 */ "alter_db_optr ::=", - /* 104 */ "alter_db_optr ::= alter_db_optr replica", - /* 105 */ "alter_db_optr ::= alter_db_optr quorum", - /* 106 */ "alter_db_optr ::= alter_db_optr keep", - /* 107 */ "alter_db_optr ::= alter_db_optr blocks", - /* 108 */ "alter_db_optr ::= alter_db_optr comp", - /* 109 */ "alter_db_optr ::= alter_db_optr wal", - /* 110 */ "alter_db_optr ::= alter_db_optr fsync", - /* 111 */ "alter_db_optr ::= alter_db_optr update", - /* 112 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 113 */ "typename ::= ids", - /* 114 */ "typename ::= ids LP signed RP", - /* 115 */ "typename ::= ids UNSIGNED", - /* 116 */ "signed ::= INTEGER", - /* 117 */ "signed ::= PLUS INTEGER", - /* 118 */ "signed ::= MINUS INTEGER", - /* 119 */ "cmd ::= CREATE TABLE create_table_args", - /* 120 */ "cmd ::= CREATE TABLE create_table_list", - /* 121 */ "create_table_list ::= create_from_stable", - /* 122 */ "create_table_list ::= create_table_list create_from_stable", - /* 123 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 124 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 125 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", - /* 126 */ "create_table_args ::= ifnotexists ids cpxName AS select", - /* 127 */ "columnlist ::= columnlist COMMA column", - /* 128 */ "columnlist ::= column", - /* 129 */ "column ::= ids typename", - /* 130 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 131 */ "tagitemlist ::= tagitem", - /* 132 */ "tagitem ::= INTEGER", - /* 133 */ "tagitem ::= FLOAT", - /* 134 */ "tagitem ::= STRING", - /* 135 */ "tagitem ::= BOOL", - /* 136 */ "tagitem ::= NULL", - /* 137 */ "tagitem ::= MINUS INTEGER", - /* 138 */ "tagitem ::= MINUS FLOAT", - /* 139 */ "tagitem ::= PLUS INTEGER", - /* 140 */ "tagitem ::= PLUS FLOAT", - /* 141 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", - /* 142 */ "union ::= select", - /* 143 */ "union ::= LP union RP", - /* 144 */ "union ::= union UNION ALL select", - /* 145 */ "union ::= union UNION ALL LP select RP", - /* 146 */ "cmd ::= union", - /* 147 */ "select ::= SELECT selcollist", - /* 148 */ "sclp ::= selcollist COMMA", - /* 149 */ "sclp ::=", - /* 150 */ "selcollist ::= sclp expr as", - /* 151 */ "selcollist ::= sclp STAR", - /* 152 */ "as ::= AS ids", - /* 153 */ "as ::= ids", - /* 154 */ "as ::=", - /* 155 */ "from ::= FROM tablelist", - /* 156 */ "tablelist ::= ids cpxName", - /* 157 */ "tablelist ::= ids cpxName ids", - /* 158 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 159 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 160 */ "tmvar ::= VARIABLE", - /* 161 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 162 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", - /* 163 */ "interval_opt ::=", - /* 164 */ "fill_opt ::=", - /* 165 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 166 */ "fill_opt ::= FILL LP ID RP", - /* 167 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 168 */ "sliding_opt ::=", - /* 169 */ "orderby_opt ::=", - /* 170 */ "orderby_opt ::= ORDER BY sortlist", - /* 171 */ "sortlist ::= sortlist COMMA item sortorder", - /* 172 */ "sortlist ::= item sortorder", - /* 173 */ "item ::= ids cpxName", - /* 174 */ "sortorder ::= ASC", - /* 175 */ "sortorder ::= DESC", - /* 176 */ "sortorder ::=", - /* 177 */ "groupby_opt ::=", - /* 178 */ "groupby_opt ::= GROUP BY grouplist", - /* 179 */ "grouplist ::= grouplist COMMA item", - /* 180 */ "grouplist ::= item", - /* 181 */ "having_opt ::=", - /* 182 */ "having_opt ::= HAVING expr", - /* 183 */ "limit_opt ::=", - /* 184 */ "limit_opt ::= LIMIT signed", - /* 185 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 186 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 187 */ "slimit_opt ::=", - /* 188 */ "slimit_opt ::= SLIMIT signed", - /* 189 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 190 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 191 */ "where_opt ::=", - /* 192 */ "where_opt ::= WHERE expr", - /* 193 */ "expr ::= LP expr RP", - /* 194 */ "expr ::= ID", - /* 195 */ "expr ::= ID DOT ID", - /* 196 */ "expr ::= ID DOT STAR", - /* 197 */ "expr ::= INTEGER", - /* 198 */ "expr ::= MINUS INTEGER", - /* 199 */ "expr ::= PLUS INTEGER", - /* 200 */ "expr ::= FLOAT", - /* 201 */ "expr ::= MINUS FLOAT", - /* 202 */ "expr ::= PLUS FLOAT", - /* 203 */ "expr ::= STRING", - /* 204 */ "expr ::= NOW", - /* 205 */ "expr ::= VARIABLE", - /* 206 */ "expr ::= BOOL", - /* 207 */ "expr ::= ID LP exprlist RP", - /* 208 */ "expr ::= ID LP STAR RP", - /* 209 */ "expr ::= expr IS NULL", - /* 210 */ "expr ::= expr IS NOT NULL", - /* 211 */ "expr ::= expr LT expr", - /* 212 */ "expr ::= expr GT expr", - /* 213 */ "expr ::= expr LE expr", - /* 214 */ "expr ::= expr GE expr", - /* 215 */ "expr ::= expr NE expr", - /* 216 */ "expr ::= expr EQ expr", - /* 217 */ "expr ::= expr AND expr", - /* 218 */ "expr ::= expr OR expr", - /* 219 */ "expr ::= expr PLUS expr", - /* 220 */ "expr ::= expr MINUS expr", - /* 221 */ "expr ::= expr STAR expr", - /* 222 */ "expr ::= expr SLASH expr", - /* 223 */ "expr ::= expr REM expr", - /* 224 */ "expr ::= expr LIKE expr", - /* 225 */ "expr ::= expr IN LP exprlist RP", - /* 226 */ "exprlist ::= exprlist COMMA expritem", - /* 227 */ "exprlist ::= expritem", - /* 228 */ "expritem ::= expr", - /* 229 */ "expritem ::=", - /* 230 */ "cmd ::= RESET QUERY CACHE", - /* 231 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 232 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 233 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 234 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 235 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 236 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 237 */ "cmd ::= KILL CONNECTION INTEGER", - /* 238 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 239 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 28 */ "cmd ::= DROP STABLE ifexists ids cpxName", + /* 29 */ "cmd ::= DROP DATABASE ifexists ids", + /* 30 */ "cmd ::= DROP DNODE ids", + /* 31 */ "cmd ::= DROP USER ids", + /* 32 */ "cmd ::= DROP ACCOUNT ids", + /* 33 */ "cmd ::= USE ids", + /* 34 */ "cmd ::= DESCRIBE ids cpxName", + /* 35 */ "cmd ::= ALTER USER ids PASS ids", + /* 36 */ "cmd ::= ALTER USER ids PRIVILEGE ids", + /* 37 */ "cmd ::= ALTER DNODE ids ids", + /* 38 */ "cmd ::= ALTER DNODE ids ids ids", + /* 39 */ "cmd ::= ALTER LOCAL ids", + /* 40 */ "cmd ::= ALTER LOCAL ids ids", + /* 41 */ "cmd ::= ALTER DATABASE ids alter_db_optr", + /* 42 */ "cmd ::= ALTER ACCOUNT ids acct_optr", + /* 43 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", + /* 44 */ "ids ::= ID", + /* 45 */ "ids ::= STRING", + /* 46 */ "ifexists ::= IF EXISTS", + /* 47 */ "ifexists ::=", + /* 48 */ "ifnotexists ::= IF NOT EXISTS", + /* 49 */ "ifnotexists ::=", + /* 50 */ "cmd ::= CREATE DNODE ids", + /* 51 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", + /* 52 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", + /* 53 */ "cmd ::= CREATE USER ids PASS ids", + /* 54 */ "pps ::=", + /* 55 */ "pps ::= PPS INTEGER", + /* 56 */ "tseries ::=", + /* 57 */ "tseries ::= TSERIES INTEGER", + /* 58 */ "dbs ::=", + /* 59 */ "dbs ::= DBS INTEGER", + /* 60 */ "streams ::=", + /* 61 */ "streams ::= STREAMS INTEGER", + /* 62 */ "storage ::=", + /* 63 */ "storage ::= STORAGE INTEGER", + /* 64 */ "qtime ::=", + /* 65 */ "qtime ::= QTIME INTEGER", + /* 66 */ "users ::=", + /* 67 */ "users ::= USERS INTEGER", + /* 68 */ "conns ::=", + /* 69 */ "conns ::= CONNS INTEGER", + /* 70 */ "state ::=", + /* 71 */ "state ::= STATE ids", + /* 72 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", + /* 73 */ "keep ::= KEEP tagitemlist", + /* 74 */ "cache ::= CACHE INTEGER", + /* 75 */ "replica ::= REPLICA INTEGER", + /* 76 */ "quorum ::= QUORUM INTEGER", + /* 77 */ "days ::= DAYS INTEGER", + /* 78 */ "minrows ::= MINROWS INTEGER", + /* 79 */ "maxrows ::= MAXROWS INTEGER", + /* 80 */ "blocks ::= BLOCKS INTEGER", + /* 81 */ "ctime ::= CTIME INTEGER", + /* 82 */ "wal ::= WAL INTEGER", + /* 83 */ "fsync ::= FSYNC INTEGER", + /* 84 */ "comp ::= COMP INTEGER", + /* 85 */ "prec ::= PRECISION STRING", + /* 86 */ "update ::= UPDATE INTEGER", + /* 87 */ "cachelast ::= CACHELAST INTEGER", + /* 88 */ "db_optr ::=", + /* 89 */ "db_optr ::= db_optr cache", + /* 90 */ "db_optr ::= db_optr replica", + /* 91 */ "db_optr ::= db_optr quorum", + /* 92 */ "db_optr ::= db_optr days", + /* 93 */ "db_optr ::= db_optr minrows", + /* 94 */ "db_optr ::= db_optr maxrows", + /* 95 */ "db_optr ::= db_optr blocks", + /* 96 */ "db_optr ::= db_optr ctime", + /* 97 */ "db_optr ::= db_optr wal", + /* 98 */ "db_optr ::= db_optr fsync", + /* 99 */ "db_optr ::= db_optr comp", + /* 100 */ "db_optr ::= db_optr prec", + /* 101 */ "db_optr ::= db_optr keep", + /* 102 */ "db_optr ::= db_optr update", + /* 103 */ "db_optr ::= db_optr cachelast", + /* 104 */ "alter_db_optr ::=", + /* 105 */ "alter_db_optr ::= alter_db_optr replica", + /* 106 */ "alter_db_optr ::= alter_db_optr quorum", + /* 107 */ "alter_db_optr ::= alter_db_optr keep", + /* 108 */ "alter_db_optr ::= alter_db_optr blocks", + /* 109 */ "alter_db_optr ::= alter_db_optr comp", + /* 110 */ "alter_db_optr ::= alter_db_optr wal", + /* 111 */ "alter_db_optr ::= alter_db_optr fsync", + /* 112 */ "alter_db_optr ::= alter_db_optr update", + /* 113 */ "alter_db_optr ::= alter_db_optr cachelast", + /* 114 */ "typename ::= ids", + /* 115 */ "typename ::= ids LP signed RP", + /* 116 */ "typename ::= ids UNSIGNED", + /* 117 */ "signed ::= INTEGER", + /* 118 */ "signed ::= PLUS INTEGER", + /* 119 */ "signed ::= MINUS INTEGER", + /* 120 */ "cmd ::= CREATE TABLE create_table_args", + /* 121 */ "cmd ::= CREATE TABLE create_stable_args", + /* 122 */ "cmd ::= CREATE STABLE create_stable_args", + /* 123 */ "cmd ::= CREATE TABLE create_table_list", + /* 124 */ "create_table_list ::= create_from_stable", + /* 125 */ "create_table_list ::= create_table_list create_from_stable", + /* 126 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", + /* 127 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", + /* 128 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", + /* 129 */ "create_table_args ::= ifnotexists ids cpxName AS select", + /* 130 */ "columnlist ::= columnlist COMMA column", + /* 131 */ "columnlist ::= column", + /* 132 */ "column ::= ids typename", + /* 133 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 134 */ "tagitemlist ::= tagitem", + /* 135 */ "tagitem ::= INTEGER", + /* 136 */ "tagitem ::= FLOAT", + /* 137 */ "tagitem ::= STRING", + /* 138 */ "tagitem ::= BOOL", + /* 139 */ "tagitem ::= NULL", + /* 140 */ "tagitem ::= MINUS INTEGER", + /* 141 */ "tagitem ::= MINUS FLOAT", + /* 142 */ "tagitem ::= PLUS INTEGER", + /* 143 */ "tagitem ::= PLUS FLOAT", + /* 144 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", + /* 145 */ "union ::= select", + /* 146 */ "union ::= LP union RP", + /* 147 */ "union ::= union UNION ALL select", + /* 148 */ "union ::= union UNION ALL LP select RP", + /* 149 */ "cmd ::= union", + /* 150 */ "select ::= SELECT selcollist", + /* 151 */ "sclp ::= selcollist COMMA", + /* 152 */ "sclp ::=", + /* 153 */ "selcollist ::= sclp expr as", + /* 154 */ "selcollist ::= sclp STAR", + /* 155 */ "as ::= AS ids", + /* 156 */ "as ::= ids", + /* 157 */ "as ::=", + /* 158 */ "from ::= FROM tablelist", + /* 159 */ "tablelist ::= ids cpxName", + /* 160 */ "tablelist ::= ids cpxName ids", + /* 161 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 162 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 163 */ "tmvar ::= VARIABLE", + /* 164 */ "interval_opt ::= INTERVAL LP tmvar RP", + /* 165 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", + /* 166 */ "interval_opt ::=", + /* 167 */ "fill_opt ::=", + /* 168 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 169 */ "fill_opt ::= FILL LP ID RP", + /* 170 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 171 */ "sliding_opt ::=", + /* 172 */ "orderby_opt ::=", + /* 173 */ "orderby_opt ::= ORDER BY sortlist", + /* 174 */ "sortlist ::= sortlist COMMA item sortorder", + /* 175 */ "sortlist ::= item sortorder", + /* 176 */ "item ::= ids cpxName", + /* 177 */ "sortorder ::= ASC", + /* 178 */ "sortorder ::= DESC", + /* 179 */ "sortorder ::=", + /* 180 */ "groupby_opt ::=", + /* 181 */ "groupby_opt ::= GROUP BY grouplist", + /* 182 */ "grouplist ::= grouplist COMMA item", + /* 183 */ "grouplist ::= item", + /* 184 */ "having_opt ::=", + /* 185 */ "having_opt ::= HAVING expr", + /* 186 */ "limit_opt ::=", + /* 187 */ "limit_opt ::= LIMIT signed", + /* 188 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 189 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 190 */ "slimit_opt ::=", + /* 191 */ "slimit_opt ::= SLIMIT signed", + /* 192 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 193 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 194 */ "where_opt ::=", + /* 195 */ "where_opt ::= WHERE expr", + /* 196 */ "expr ::= LP expr RP", + /* 197 */ "expr ::= ID", + /* 198 */ "expr ::= ID DOT ID", + /* 199 */ "expr ::= ID DOT STAR", + /* 200 */ "expr ::= INTEGER", + /* 201 */ "expr ::= MINUS INTEGER", + /* 202 */ "expr ::= PLUS INTEGER", + /* 203 */ "expr ::= FLOAT", + /* 204 */ "expr ::= MINUS FLOAT", + /* 205 */ "expr ::= PLUS FLOAT", + /* 206 */ "expr ::= STRING", + /* 207 */ "expr ::= NOW", + /* 208 */ "expr ::= VARIABLE", + /* 209 */ "expr ::= BOOL", + /* 210 */ "expr ::= ID LP exprlist RP", + /* 211 */ "expr ::= ID LP STAR RP", + /* 212 */ "expr ::= expr IS NULL", + /* 213 */ "expr ::= expr IS NOT NULL", + /* 214 */ "expr ::= expr LT expr", + /* 215 */ "expr ::= expr GT expr", + /* 216 */ "expr ::= expr LE expr", + /* 217 */ "expr ::= expr GE expr", + /* 218 */ "expr ::= expr NE expr", + /* 219 */ "expr ::= expr EQ expr", + /* 220 */ "expr ::= expr AND expr", + /* 221 */ "expr ::= expr OR expr", + /* 222 */ "expr ::= expr PLUS expr", + /* 223 */ "expr ::= expr MINUS expr", + /* 224 */ "expr ::= expr STAR expr", + /* 225 */ "expr ::= expr SLASH expr", + /* 226 */ "expr ::= expr REM expr", + /* 227 */ "expr ::= expr LIKE expr", + /* 228 */ "expr ::= expr IN LP exprlist RP", + /* 229 */ "exprlist ::= exprlist COMMA expritem", + /* 230 */ "exprlist ::= expritem", + /* 231 */ "expritem ::= expr", + /* 232 */ "expritem ::=", + /* 233 */ "cmd ::= RESET QUERY CACHE", + /* 234 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 235 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 236 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 237 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 238 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 239 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 240 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 241 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 242 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 243 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 244 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 245 */ "cmd ::= KILL CONNECTION INTEGER", + /* 246 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 247 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1386,49 +1410,49 @@ static void yy_destructor( /********* Begin destructor definitions ***************************************/ case 229: /* keep */ case 230: /* tagitemlist */ - case 250: /* columnlist */ - case 258: /* fill_opt */ - case 260: /* groupby_opt */ - case 261: /* orderby_opt */ - case 271: /* sortlist */ - case 275: /* grouplist */ + case 251: /* columnlist */ + case 259: /* fill_opt */ + case 261: /* groupby_opt */ + case 262: /* orderby_opt */ + case 272: /* sortlist */ + case 276: /* grouplist */ { -taosArrayDestroy((yypminor->yy421)); +taosArrayDestroy((yypminor->yy135)); } break; - case 248: /* create_table_list */ + case 249: /* create_table_list */ { destroyCreateTableSql((yypminor->yy38)); } break; - case 251: /* select */ + case 252: /* select */ { -doDestroyQuerySql((yypminor->yy148)); +doDestroyQuerySql((yypminor->yy30)); } break; - case 254: /* selcollist */ - case 266: /* sclp */ - case 276: /* exprlist */ + case 255: /* selcollist */ + case 267: /* sclp */ + case 277: /* exprlist */ { -tSqlExprListDestroy((yypminor->yy166)); +tSqlExprListDestroy((yypminor->yy266)); } break; - case 256: /* where_opt */ - case 262: /* having_opt */ - case 267: /* expr */ - case 277: /* expritem */ + case 257: /* where_opt */ + case 263: /* having_opt */ + case 268: /* expr */ + case 278: /* expritem */ { -tSqlExprDestroy((yypminor->yy78)); +tSqlExprDestroy((yypminor->yy316)); } break; - case 265: /* union */ + case 266: /* union */ { destroyAllSelectClause((yypminor->yy153)); } break; - case 272: /* sortitem */ + case 273: /* sortitem */ { -tVariantDestroy(&(yypminor->yy430)); +tVariantDestroy(&(yypminor->yy308)); } break; /********* End destructor definitions *****************************************/ @@ -1750,218 +1774,226 @@ static const struct { { 211, -3 }, /* (25) cmd ::= SHOW dbPrefix VGROUPS */ { 211, -4 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS ids */ { 211, -5 }, /* (27) cmd ::= DROP TABLE ifexists ids cpxName */ - { 211, -4 }, /* (28) cmd ::= DROP DATABASE ifexists ids */ - { 211, -3 }, /* (29) cmd ::= DROP DNODE ids */ - { 211, -3 }, /* (30) cmd ::= DROP USER ids */ - { 211, -3 }, /* (31) cmd ::= DROP ACCOUNT ids */ - { 211, -2 }, /* (32) cmd ::= USE ids */ - { 211, -3 }, /* (33) cmd ::= DESCRIBE ids cpxName */ - { 211, -5 }, /* (34) cmd ::= ALTER USER ids PASS ids */ - { 211, -5 }, /* (35) cmd ::= ALTER USER ids PRIVILEGE ids */ - { 211, -4 }, /* (36) cmd ::= ALTER DNODE ids ids */ - { 211, -5 }, /* (37) cmd ::= ALTER DNODE ids ids ids */ - { 211, -3 }, /* (38) cmd ::= ALTER LOCAL ids */ - { 211, -4 }, /* (39) cmd ::= ALTER LOCAL ids ids */ - { 211, -4 }, /* (40) cmd ::= ALTER DATABASE ids alter_db_optr */ - { 211, -4 }, /* (41) cmd ::= ALTER ACCOUNT ids acct_optr */ - { 211, -6 }, /* (42) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - { 213, -1 }, /* (43) ids ::= ID */ - { 213, -1 }, /* (44) ids ::= STRING */ - { 215, -2 }, /* (45) ifexists ::= IF EXISTS */ - { 215, 0 }, /* (46) ifexists ::= */ - { 218, -3 }, /* (47) ifnotexists ::= IF NOT EXISTS */ - { 218, 0 }, /* (48) ifnotexists ::= */ - { 211, -3 }, /* (49) cmd ::= CREATE DNODE ids */ - { 211, -6 }, /* (50) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - { 211, -5 }, /* (51) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - { 211, -5 }, /* (52) cmd ::= CREATE USER ids PASS ids */ - { 220, 0 }, /* (53) pps ::= */ - { 220, -2 }, /* (54) pps ::= PPS INTEGER */ - { 221, 0 }, /* (55) tseries ::= */ - { 221, -2 }, /* (56) tseries ::= TSERIES INTEGER */ - { 222, 0 }, /* (57) dbs ::= */ - { 222, -2 }, /* (58) dbs ::= DBS INTEGER */ - { 223, 0 }, /* (59) streams ::= */ - { 223, -2 }, /* (60) streams ::= STREAMS INTEGER */ - { 224, 0 }, /* (61) storage ::= */ - { 224, -2 }, /* (62) storage ::= STORAGE INTEGER */ - { 225, 0 }, /* (63) qtime ::= */ - { 225, -2 }, /* (64) qtime ::= QTIME INTEGER */ - { 226, 0 }, /* (65) users ::= */ - { 226, -2 }, /* (66) users ::= USERS INTEGER */ - { 227, 0 }, /* (67) conns ::= */ - { 227, -2 }, /* (68) conns ::= CONNS INTEGER */ - { 228, 0 }, /* (69) state ::= */ - { 228, -2 }, /* (70) state ::= STATE ids */ - { 217, -9 }, /* (71) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - { 229, -2 }, /* (72) keep ::= KEEP tagitemlist */ - { 231, -2 }, /* (73) cache ::= CACHE INTEGER */ - { 232, -2 }, /* (74) replica ::= REPLICA INTEGER */ - { 233, -2 }, /* (75) quorum ::= QUORUM INTEGER */ - { 234, -2 }, /* (76) days ::= DAYS INTEGER */ - { 235, -2 }, /* (77) minrows ::= MINROWS INTEGER */ - { 236, -2 }, /* (78) maxrows ::= MAXROWS INTEGER */ - { 237, -2 }, /* (79) blocks ::= BLOCKS INTEGER */ - { 238, -2 }, /* (80) ctime ::= CTIME INTEGER */ - { 239, -2 }, /* (81) wal ::= WAL INTEGER */ - { 240, -2 }, /* (82) fsync ::= FSYNC INTEGER */ - { 241, -2 }, /* (83) comp ::= COMP INTEGER */ - { 242, -2 }, /* (84) prec ::= PRECISION STRING */ - { 243, -2 }, /* (85) update ::= UPDATE INTEGER */ - { 244, -2 }, /* (86) cachelast ::= CACHELAST INTEGER */ - { 219, 0 }, /* (87) db_optr ::= */ - { 219, -2 }, /* (88) db_optr ::= db_optr cache */ - { 219, -2 }, /* (89) db_optr ::= db_optr replica */ - { 219, -2 }, /* (90) db_optr ::= db_optr quorum */ - { 219, -2 }, /* (91) db_optr ::= db_optr days */ - { 219, -2 }, /* (92) db_optr ::= db_optr minrows */ - { 219, -2 }, /* (93) db_optr ::= db_optr maxrows */ - { 219, -2 }, /* (94) db_optr ::= db_optr blocks */ - { 219, -2 }, /* (95) db_optr ::= db_optr ctime */ - { 219, -2 }, /* (96) db_optr ::= db_optr wal */ - { 219, -2 }, /* (97) db_optr ::= db_optr fsync */ - { 219, -2 }, /* (98) db_optr ::= db_optr comp */ - { 219, -2 }, /* (99) db_optr ::= db_optr prec */ - { 219, -2 }, /* (100) db_optr ::= db_optr keep */ - { 219, -2 }, /* (101) db_optr ::= db_optr update */ - { 219, -2 }, /* (102) db_optr ::= db_optr cachelast */ - { 216, 0 }, /* (103) alter_db_optr ::= */ - { 216, -2 }, /* (104) alter_db_optr ::= alter_db_optr replica */ - { 216, -2 }, /* (105) alter_db_optr ::= alter_db_optr quorum */ - { 216, -2 }, /* (106) alter_db_optr ::= alter_db_optr keep */ - { 216, -2 }, /* (107) alter_db_optr ::= alter_db_optr blocks */ - { 216, -2 }, /* (108) alter_db_optr ::= alter_db_optr comp */ - { 216, -2 }, /* (109) alter_db_optr ::= alter_db_optr wal */ - { 216, -2 }, /* (110) alter_db_optr ::= alter_db_optr fsync */ - { 216, -2 }, /* (111) alter_db_optr ::= alter_db_optr update */ - { 216, -2 }, /* (112) alter_db_optr ::= alter_db_optr cachelast */ - { 245, -1 }, /* (113) typename ::= ids */ - { 245, -4 }, /* (114) typename ::= ids LP signed RP */ - { 245, -2 }, /* (115) typename ::= ids UNSIGNED */ - { 246, -1 }, /* (116) signed ::= INTEGER */ - { 246, -2 }, /* (117) signed ::= PLUS INTEGER */ - { 246, -2 }, /* (118) signed ::= MINUS INTEGER */ - { 211, -3 }, /* (119) cmd ::= CREATE TABLE create_table_args */ - { 211, -3 }, /* (120) cmd ::= CREATE TABLE create_table_list */ - { 248, -1 }, /* (121) create_table_list ::= create_from_stable */ - { 248, -2 }, /* (122) create_table_list ::= create_table_list create_from_stable */ - { 247, -6 }, /* (123) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 247, -10 }, /* (124) create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 249, -10 }, /* (125) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - { 247, -5 }, /* (126) create_table_args ::= ifnotexists ids cpxName AS select */ - { 250, -3 }, /* (127) columnlist ::= columnlist COMMA column */ - { 250, -1 }, /* (128) columnlist ::= column */ - { 252, -2 }, /* (129) column ::= ids typename */ - { 230, -3 }, /* (130) tagitemlist ::= tagitemlist COMMA tagitem */ - { 230, -1 }, /* (131) tagitemlist ::= tagitem */ - { 253, -1 }, /* (132) tagitem ::= INTEGER */ - { 253, -1 }, /* (133) tagitem ::= FLOAT */ - { 253, -1 }, /* (134) tagitem ::= STRING */ - { 253, -1 }, /* (135) tagitem ::= BOOL */ - { 253, -1 }, /* (136) tagitem ::= NULL */ - { 253, -2 }, /* (137) tagitem ::= MINUS INTEGER */ - { 253, -2 }, /* (138) tagitem ::= MINUS FLOAT */ - { 253, -2 }, /* (139) tagitem ::= PLUS INTEGER */ - { 253, -2 }, /* (140) tagitem ::= PLUS FLOAT */ - { 251, -12 }, /* (141) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - { 265, -1 }, /* (142) union ::= select */ - { 265, -3 }, /* (143) union ::= LP union RP */ - { 265, -4 }, /* (144) union ::= union UNION ALL select */ - { 265, -6 }, /* (145) union ::= union UNION ALL LP select RP */ - { 211, -1 }, /* (146) cmd ::= union */ - { 251, -2 }, /* (147) select ::= SELECT selcollist */ - { 266, -2 }, /* (148) sclp ::= selcollist COMMA */ - { 266, 0 }, /* (149) sclp ::= */ - { 254, -3 }, /* (150) selcollist ::= sclp expr as */ - { 254, -2 }, /* (151) selcollist ::= sclp STAR */ - { 268, -2 }, /* (152) as ::= AS ids */ - { 268, -1 }, /* (153) as ::= ids */ - { 268, 0 }, /* (154) as ::= */ - { 255, -2 }, /* (155) from ::= FROM tablelist */ - { 269, -2 }, /* (156) tablelist ::= ids cpxName */ - { 269, -3 }, /* (157) tablelist ::= ids cpxName ids */ - { 269, -4 }, /* (158) tablelist ::= tablelist COMMA ids cpxName */ - { 269, -5 }, /* (159) tablelist ::= tablelist COMMA ids cpxName ids */ - { 270, -1 }, /* (160) tmvar ::= VARIABLE */ - { 257, -4 }, /* (161) interval_opt ::= INTERVAL LP tmvar RP */ - { 257, -6 }, /* (162) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - { 257, 0 }, /* (163) interval_opt ::= */ - { 258, 0 }, /* (164) fill_opt ::= */ - { 258, -6 }, /* (165) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 258, -4 }, /* (166) fill_opt ::= FILL LP ID RP */ - { 259, -4 }, /* (167) sliding_opt ::= SLIDING LP tmvar RP */ - { 259, 0 }, /* (168) sliding_opt ::= */ - { 261, 0 }, /* (169) orderby_opt ::= */ - { 261, -3 }, /* (170) orderby_opt ::= ORDER BY sortlist */ - { 271, -4 }, /* (171) sortlist ::= sortlist COMMA item sortorder */ - { 271, -2 }, /* (172) sortlist ::= item sortorder */ - { 273, -2 }, /* (173) item ::= ids cpxName */ - { 274, -1 }, /* (174) sortorder ::= ASC */ - { 274, -1 }, /* (175) sortorder ::= DESC */ - { 274, 0 }, /* (176) sortorder ::= */ - { 260, 0 }, /* (177) groupby_opt ::= */ - { 260, -3 }, /* (178) groupby_opt ::= GROUP BY grouplist */ - { 275, -3 }, /* (179) grouplist ::= grouplist COMMA item */ - { 275, -1 }, /* (180) grouplist ::= item */ - { 262, 0 }, /* (181) having_opt ::= */ - { 262, -2 }, /* (182) having_opt ::= HAVING expr */ - { 264, 0 }, /* (183) limit_opt ::= */ - { 264, -2 }, /* (184) limit_opt ::= LIMIT signed */ - { 264, -4 }, /* (185) limit_opt ::= LIMIT signed OFFSET signed */ - { 264, -4 }, /* (186) limit_opt ::= LIMIT signed COMMA signed */ - { 263, 0 }, /* (187) slimit_opt ::= */ - { 263, -2 }, /* (188) slimit_opt ::= SLIMIT signed */ - { 263, -4 }, /* (189) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 263, -4 }, /* (190) slimit_opt ::= SLIMIT signed COMMA signed */ - { 256, 0 }, /* (191) where_opt ::= */ - { 256, -2 }, /* (192) where_opt ::= WHERE expr */ - { 267, -3 }, /* (193) expr ::= LP expr RP */ - { 267, -1 }, /* (194) expr ::= ID */ - { 267, -3 }, /* (195) expr ::= ID DOT ID */ - { 267, -3 }, /* (196) expr ::= ID DOT STAR */ - { 267, -1 }, /* (197) expr ::= INTEGER */ - { 267, -2 }, /* (198) expr ::= MINUS INTEGER */ - { 267, -2 }, /* (199) expr ::= PLUS INTEGER */ - { 267, -1 }, /* (200) expr ::= FLOAT */ - { 267, -2 }, /* (201) expr ::= MINUS FLOAT */ - { 267, -2 }, /* (202) expr ::= PLUS FLOAT */ - { 267, -1 }, /* (203) expr ::= STRING */ - { 267, -1 }, /* (204) expr ::= NOW */ - { 267, -1 }, /* (205) expr ::= VARIABLE */ - { 267, -1 }, /* (206) expr ::= BOOL */ - { 267, -4 }, /* (207) expr ::= ID LP exprlist RP */ - { 267, -4 }, /* (208) expr ::= ID LP STAR RP */ - { 267, -3 }, /* (209) expr ::= expr IS NULL */ - { 267, -4 }, /* (210) expr ::= expr IS NOT NULL */ - { 267, -3 }, /* (211) expr ::= expr LT expr */ - { 267, -3 }, /* (212) expr ::= expr GT expr */ - { 267, -3 }, /* (213) expr ::= expr LE expr */ - { 267, -3 }, /* (214) expr ::= expr GE expr */ - { 267, -3 }, /* (215) expr ::= expr NE expr */ - { 267, -3 }, /* (216) expr ::= expr EQ expr */ - { 267, -3 }, /* (217) expr ::= expr AND expr */ - { 267, -3 }, /* (218) expr ::= expr OR expr */ - { 267, -3 }, /* (219) expr ::= expr PLUS expr */ - { 267, -3 }, /* (220) expr ::= expr MINUS expr */ - { 267, -3 }, /* (221) expr ::= expr STAR expr */ - { 267, -3 }, /* (222) expr ::= expr SLASH expr */ - { 267, -3 }, /* (223) expr ::= expr REM expr */ - { 267, -3 }, /* (224) expr ::= expr LIKE expr */ - { 267, -5 }, /* (225) expr ::= expr IN LP exprlist RP */ - { 276, -3 }, /* (226) exprlist ::= exprlist COMMA expritem */ - { 276, -1 }, /* (227) exprlist ::= expritem */ - { 277, -1 }, /* (228) expritem ::= expr */ - { 277, 0 }, /* (229) expritem ::= */ - { 211, -3 }, /* (230) cmd ::= RESET QUERY CACHE */ - { 211, -7 }, /* (231) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 211, -7 }, /* (232) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 211, -7 }, /* (233) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 211, -7 }, /* (234) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 211, -8 }, /* (235) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 211, -9 }, /* (236) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 211, -3 }, /* (237) cmd ::= KILL CONNECTION INTEGER */ - { 211, -5 }, /* (238) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 211, -5 }, /* (239) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 211, -5 }, /* (28) cmd ::= DROP STABLE ifexists ids cpxName */ + { 211, -4 }, /* (29) cmd ::= DROP DATABASE ifexists ids */ + { 211, -3 }, /* (30) cmd ::= DROP DNODE ids */ + { 211, -3 }, /* (31) cmd ::= DROP USER ids */ + { 211, -3 }, /* (32) cmd ::= DROP ACCOUNT ids */ + { 211, -2 }, /* (33) cmd ::= USE ids */ + { 211, -3 }, /* (34) cmd ::= DESCRIBE ids cpxName */ + { 211, -5 }, /* (35) cmd ::= ALTER USER ids PASS ids */ + { 211, -5 }, /* (36) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 211, -4 }, /* (37) cmd ::= ALTER DNODE ids ids */ + { 211, -5 }, /* (38) cmd ::= ALTER DNODE ids ids ids */ + { 211, -3 }, /* (39) cmd ::= ALTER LOCAL ids */ + { 211, -4 }, /* (40) cmd ::= ALTER LOCAL ids ids */ + { 211, -4 }, /* (41) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 211, -4 }, /* (42) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 211, -6 }, /* (43) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 213, -1 }, /* (44) ids ::= ID */ + { 213, -1 }, /* (45) ids ::= STRING */ + { 215, -2 }, /* (46) ifexists ::= IF EXISTS */ + { 215, 0 }, /* (47) ifexists ::= */ + { 218, -3 }, /* (48) ifnotexists ::= IF NOT EXISTS */ + { 218, 0 }, /* (49) ifnotexists ::= */ + { 211, -3 }, /* (50) cmd ::= CREATE DNODE ids */ + { 211, -6 }, /* (51) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 211, -5 }, /* (52) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 211, -5 }, /* (53) cmd ::= CREATE USER ids PASS ids */ + { 220, 0 }, /* (54) pps ::= */ + { 220, -2 }, /* (55) pps ::= PPS INTEGER */ + { 221, 0 }, /* (56) tseries ::= */ + { 221, -2 }, /* (57) tseries ::= TSERIES INTEGER */ + { 222, 0 }, /* (58) dbs ::= */ + { 222, -2 }, /* (59) dbs ::= DBS INTEGER */ + { 223, 0 }, /* (60) streams ::= */ + { 223, -2 }, /* (61) streams ::= STREAMS INTEGER */ + { 224, 0 }, /* (62) storage ::= */ + { 224, -2 }, /* (63) storage ::= STORAGE INTEGER */ + { 225, 0 }, /* (64) qtime ::= */ + { 225, -2 }, /* (65) qtime ::= QTIME INTEGER */ + { 226, 0 }, /* (66) users ::= */ + { 226, -2 }, /* (67) users ::= USERS INTEGER */ + { 227, 0 }, /* (68) conns ::= */ + { 227, -2 }, /* (69) conns ::= CONNS INTEGER */ + { 228, 0 }, /* (70) state ::= */ + { 228, -2 }, /* (71) state ::= STATE ids */ + { 217, -9 }, /* (72) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 229, -2 }, /* (73) keep ::= KEEP tagitemlist */ + { 231, -2 }, /* (74) cache ::= CACHE INTEGER */ + { 232, -2 }, /* (75) replica ::= REPLICA INTEGER */ + { 233, -2 }, /* (76) quorum ::= QUORUM INTEGER */ + { 234, -2 }, /* (77) days ::= DAYS INTEGER */ + { 235, -2 }, /* (78) minrows ::= MINROWS INTEGER */ + { 236, -2 }, /* (79) maxrows ::= MAXROWS INTEGER */ + { 237, -2 }, /* (80) blocks ::= BLOCKS INTEGER */ + { 238, -2 }, /* (81) ctime ::= CTIME INTEGER */ + { 239, -2 }, /* (82) wal ::= WAL INTEGER */ + { 240, -2 }, /* (83) fsync ::= FSYNC INTEGER */ + { 241, -2 }, /* (84) comp ::= COMP INTEGER */ + { 242, -2 }, /* (85) prec ::= PRECISION STRING */ + { 243, -2 }, /* (86) update ::= UPDATE INTEGER */ + { 244, -2 }, /* (87) cachelast ::= CACHELAST INTEGER */ + { 219, 0 }, /* (88) db_optr ::= */ + { 219, -2 }, /* (89) db_optr ::= db_optr cache */ + { 219, -2 }, /* (90) db_optr ::= db_optr replica */ + { 219, -2 }, /* (91) db_optr ::= db_optr quorum */ + { 219, -2 }, /* (92) db_optr ::= db_optr days */ + { 219, -2 }, /* (93) db_optr ::= db_optr minrows */ + { 219, -2 }, /* (94) db_optr ::= db_optr maxrows */ + { 219, -2 }, /* (95) db_optr ::= db_optr blocks */ + { 219, -2 }, /* (96) db_optr ::= db_optr ctime */ + { 219, -2 }, /* (97) db_optr ::= db_optr wal */ + { 219, -2 }, /* (98) db_optr ::= db_optr fsync */ + { 219, -2 }, /* (99) db_optr ::= db_optr comp */ + { 219, -2 }, /* (100) db_optr ::= db_optr prec */ + { 219, -2 }, /* (101) db_optr ::= db_optr keep */ + { 219, -2 }, /* (102) db_optr ::= db_optr update */ + { 219, -2 }, /* (103) db_optr ::= db_optr cachelast */ + { 216, 0 }, /* (104) alter_db_optr ::= */ + { 216, -2 }, /* (105) alter_db_optr ::= alter_db_optr replica */ + { 216, -2 }, /* (106) alter_db_optr ::= alter_db_optr quorum */ + { 216, -2 }, /* (107) alter_db_optr ::= alter_db_optr keep */ + { 216, -2 }, /* (108) alter_db_optr ::= alter_db_optr blocks */ + { 216, -2 }, /* (109) alter_db_optr ::= alter_db_optr comp */ + { 216, -2 }, /* (110) alter_db_optr ::= alter_db_optr wal */ + { 216, -2 }, /* (111) alter_db_optr ::= alter_db_optr fsync */ + { 216, -2 }, /* (112) alter_db_optr ::= alter_db_optr update */ + { 216, -2 }, /* (113) alter_db_optr ::= alter_db_optr cachelast */ + { 245, -1 }, /* (114) typename ::= ids */ + { 245, -4 }, /* (115) typename ::= ids LP signed RP */ + { 245, -2 }, /* (116) typename ::= ids UNSIGNED */ + { 246, -1 }, /* (117) signed ::= INTEGER */ + { 246, -2 }, /* (118) signed ::= PLUS INTEGER */ + { 246, -2 }, /* (119) signed ::= MINUS INTEGER */ + { 211, -3 }, /* (120) cmd ::= CREATE TABLE create_table_args */ + { 211, -3 }, /* (121) cmd ::= CREATE TABLE create_stable_args */ + { 211, -3 }, /* (122) cmd ::= CREATE STABLE create_stable_args */ + { 211, -3 }, /* (123) cmd ::= CREATE TABLE create_table_list */ + { 249, -1 }, /* (124) create_table_list ::= create_from_stable */ + { 249, -2 }, /* (125) create_table_list ::= create_table_list create_from_stable */ + { 247, -6 }, /* (126) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 248, -10 }, /* (127) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 250, -10 }, /* (128) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + { 247, -5 }, /* (129) create_table_args ::= ifnotexists ids cpxName AS select */ + { 251, -3 }, /* (130) columnlist ::= columnlist COMMA column */ + { 251, -1 }, /* (131) columnlist ::= column */ + { 253, -2 }, /* (132) column ::= ids typename */ + { 230, -3 }, /* (133) tagitemlist ::= tagitemlist COMMA tagitem */ + { 230, -1 }, /* (134) tagitemlist ::= tagitem */ + { 254, -1 }, /* (135) tagitem ::= INTEGER */ + { 254, -1 }, /* (136) tagitem ::= FLOAT */ + { 254, -1 }, /* (137) tagitem ::= STRING */ + { 254, -1 }, /* (138) tagitem ::= BOOL */ + { 254, -1 }, /* (139) tagitem ::= NULL */ + { 254, -2 }, /* (140) tagitem ::= MINUS INTEGER */ + { 254, -2 }, /* (141) tagitem ::= MINUS FLOAT */ + { 254, -2 }, /* (142) tagitem ::= PLUS INTEGER */ + { 254, -2 }, /* (143) tagitem ::= PLUS FLOAT */ + { 252, -12 }, /* (144) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + { 266, -1 }, /* (145) union ::= select */ + { 266, -3 }, /* (146) union ::= LP union RP */ + { 266, -4 }, /* (147) union ::= union UNION ALL select */ + { 266, -6 }, /* (148) union ::= union UNION ALL LP select RP */ + { 211, -1 }, /* (149) cmd ::= union */ + { 252, -2 }, /* (150) select ::= SELECT selcollist */ + { 267, -2 }, /* (151) sclp ::= selcollist COMMA */ + { 267, 0 }, /* (152) sclp ::= */ + { 255, -3 }, /* (153) selcollist ::= sclp expr as */ + { 255, -2 }, /* (154) selcollist ::= sclp STAR */ + { 269, -2 }, /* (155) as ::= AS ids */ + { 269, -1 }, /* (156) as ::= ids */ + { 269, 0 }, /* (157) as ::= */ + { 256, -2 }, /* (158) from ::= FROM tablelist */ + { 270, -2 }, /* (159) tablelist ::= ids cpxName */ + { 270, -3 }, /* (160) tablelist ::= ids cpxName ids */ + { 270, -4 }, /* (161) tablelist ::= tablelist COMMA ids cpxName */ + { 270, -5 }, /* (162) tablelist ::= tablelist COMMA ids cpxName ids */ + { 271, -1 }, /* (163) tmvar ::= VARIABLE */ + { 258, -4 }, /* (164) interval_opt ::= INTERVAL LP tmvar RP */ + { 258, -6 }, /* (165) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + { 258, 0 }, /* (166) interval_opt ::= */ + { 259, 0 }, /* (167) fill_opt ::= */ + { 259, -6 }, /* (168) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 259, -4 }, /* (169) fill_opt ::= FILL LP ID RP */ + { 260, -4 }, /* (170) sliding_opt ::= SLIDING LP tmvar RP */ + { 260, 0 }, /* (171) sliding_opt ::= */ + { 262, 0 }, /* (172) orderby_opt ::= */ + { 262, -3 }, /* (173) orderby_opt ::= ORDER BY sortlist */ + { 272, -4 }, /* (174) sortlist ::= sortlist COMMA item sortorder */ + { 272, -2 }, /* (175) sortlist ::= item sortorder */ + { 274, -2 }, /* (176) item ::= ids cpxName */ + { 275, -1 }, /* (177) sortorder ::= ASC */ + { 275, -1 }, /* (178) sortorder ::= DESC */ + { 275, 0 }, /* (179) sortorder ::= */ + { 261, 0 }, /* (180) groupby_opt ::= */ + { 261, -3 }, /* (181) groupby_opt ::= GROUP BY grouplist */ + { 276, -3 }, /* (182) grouplist ::= grouplist COMMA item */ + { 276, -1 }, /* (183) grouplist ::= item */ + { 263, 0 }, /* (184) having_opt ::= */ + { 263, -2 }, /* (185) having_opt ::= HAVING expr */ + { 265, 0 }, /* (186) limit_opt ::= */ + { 265, -2 }, /* (187) limit_opt ::= LIMIT signed */ + { 265, -4 }, /* (188) limit_opt ::= LIMIT signed OFFSET signed */ + { 265, -4 }, /* (189) limit_opt ::= LIMIT signed COMMA signed */ + { 264, 0 }, /* (190) slimit_opt ::= */ + { 264, -2 }, /* (191) slimit_opt ::= SLIMIT signed */ + { 264, -4 }, /* (192) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 264, -4 }, /* (193) slimit_opt ::= SLIMIT signed COMMA signed */ + { 257, 0 }, /* (194) where_opt ::= */ + { 257, -2 }, /* (195) where_opt ::= WHERE expr */ + { 268, -3 }, /* (196) expr ::= LP expr RP */ + { 268, -1 }, /* (197) expr ::= ID */ + { 268, -3 }, /* (198) expr ::= ID DOT ID */ + { 268, -3 }, /* (199) expr ::= ID DOT STAR */ + { 268, -1 }, /* (200) expr ::= INTEGER */ + { 268, -2 }, /* (201) expr ::= MINUS INTEGER */ + { 268, -2 }, /* (202) expr ::= PLUS INTEGER */ + { 268, -1 }, /* (203) expr ::= FLOAT */ + { 268, -2 }, /* (204) expr ::= MINUS FLOAT */ + { 268, -2 }, /* (205) expr ::= PLUS FLOAT */ + { 268, -1 }, /* (206) expr ::= STRING */ + { 268, -1 }, /* (207) expr ::= NOW */ + { 268, -1 }, /* (208) expr ::= VARIABLE */ + { 268, -1 }, /* (209) expr ::= BOOL */ + { 268, -4 }, /* (210) expr ::= ID LP exprlist RP */ + { 268, -4 }, /* (211) expr ::= ID LP STAR RP */ + { 268, -3 }, /* (212) expr ::= expr IS NULL */ + { 268, -4 }, /* (213) expr ::= expr IS NOT NULL */ + { 268, -3 }, /* (214) expr ::= expr LT expr */ + { 268, -3 }, /* (215) expr ::= expr GT expr */ + { 268, -3 }, /* (216) expr ::= expr LE expr */ + { 268, -3 }, /* (217) expr ::= expr GE expr */ + { 268, -3 }, /* (218) expr ::= expr NE expr */ + { 268, -3 }, /* (219) expr ::= expr EQ expr */ + { 268, -3 }, /* (220) expr ::= expr AND expr */ + { 268, -3 }, /* (221) expr ::= expr OR expr */ + { 268, -3 }, /* (222) expr ::= expr PLUS expr */ + { 268, -3 }, /* (223) expr ::= expr MINUS expr */ + { 268, -3 }, /* (224) expr ::= expr STAR expr */ + { 268, -3 }, /* (225) expr ::= expr SLASH expr */ + { 268, -3 }, /* (226) expr ::= expr REM expr */ + { 268, -3 }, /* (227) expr ::= expr LIKE expr */ + { 268, -5 }, /* (228) expr ::= expr IN LP exprlist RP */ + { 277, -3 }, /* (229) exprlist ::= exprlist COMMA expritem */ + { 277, -1 }, /* (230) exprlist ::= expritem */ + { 278, -1 }, /* (231) expritem ::= expr */ + { 278, 0 }, /* (232) expritem ::= */ + { 211, -3 }, /* (233) cmd ::= RESET QUERY CACHE */ + { 211, -7 }, /* (234) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 211, -7 }, /* (235) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 211, -7 }, /* (236) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 211, -7 }, /* (237) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 211, -8 }, /* (238) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 211, -9 }, /* (239) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 211, -7 }, /* (240) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 211, -7 }, /* (241) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 211, -7 }, /* (242) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 211, -7 }, /* (243) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 211, -8 }, /* (244) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 211, -3 }, /* (245) cmd ::= KILL CONNECTION INTEGER */ + { 211, -5 }, /* (246) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 211, -5 }, /* (247) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2042,7 +2074,9 @@ static void yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 119: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==119); + case 120: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==120); + case 121: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==121); + case 122: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==122); {} break; case 1: /* cmd ::= SHOW DATABASES */ @@ -2150,275 +2184,283 @@ static void yy_reduce( case 27: /* cmd ::= DROP TABLE ifexists ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0); + setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0, -1); +} + break; + case 28: /* cmd ::= DROP STABLE ifexists ids cpxName */ +{ + yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; + setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0, TSDB_SUPER_TABLE); } break; - case 28: /* cmd ::= DROP DATABASE ifexists ids */ -{ setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0); } + case 29: /* cmd ::= DROP DATABASE ifexists ids */ +{ setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0, -1); } break; - case 29: /* cmd ::= DROP DNODE ids */ + case 30: /* cmd ::= DROP DNODE ids */ { setDCLSQLElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &yymsp[0].minor.yy0); } break; - case 30: /* cmd ::= DROP USER ids */ + case 31: /* cmd ::= DROP USER ids */ { setDCLSQLElems(pInfo, TSDB_SQL_DROP_USER, 1, &yymsp[0].minor.yy0); } break; - case 31: /* cmd ::= DROP ACCOUNT ids */ + case 32: /* cmd ::= DROP ACCOUNT ids */ { setDCLSQLElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &yymsp[0].minor.yy0); } break; - case 32: /* cmd ::= USE ids */ + case 33: /* cmd ::= USE ids */ { setDCLSQLElems(pInfo, TSDB_SQL_USE_DB, 1, &yymsp[0].minor.yy0);} break; - case 33: /* cmd ::= DESCRIBE ids cpxName */ + case 34: /* cmd ::= DESCRIBE ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDCLSQLElems(pInfo, TSDB_SQL_DESCRIBE_TABLE, 1, &yymsp[-1].minor.yy0); } break; - case 34: /* cmd ::= ALTER USER ids PASS ids */ + case 35: /* cmd ::= ALTER USER ids PASS ids */ { setAlterUserSql(pInfo, TSDB_ALTER_USER_PASSWD, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, NULL); } break; - case 35: /* cmd ::= ALTER USER ids PRIVILEGE ids */ + case 36: /* cmd ::= ALTER USER ids PRIVILEGE ids */ { setAlterUserSql(pInfo, TSDB_ALTER_USER_PRIVILEGES, &yymsp[-2].minor.yy0, NULL, &yymsp[0].minor.yy0);} break; - case 36: /* cmd ::= ALTER DNODE ids ids */ + case 37: /* cmd ::= ALTER DNODE ids ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 37: /* cmd ::= ALTER DNODE ids ids ids */ + case 38: /* cmd ::= ALTER DNODE ids ids ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 3, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 38: /* cmd ::= ALTER LOCAL ids */ + case 39: /* cmd ::= ALTER LOCAL ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &yymsp[0].minor.yy0); } break; - case 39: /* cmd ::= ALTER LOCAL ids ids */ + case 40: /* cmd ::= ALTER LOCAL ids ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 40: /* cmd ::= ALTER DATABASE ids alter_db_optr */ -{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy234, &t);} + case 41: /* cmd ::= ALTER DATABASE ids alter_db_optr */ +{ SStrToken t = {0}; + setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy256, &t);} break; - case 41: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy71);} + case 42: /* cmd ::= ALTER ACCOUNT ids acct_optr */ +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy277);} break; - case 42: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy71);} + case 43: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy277);} break; - case 43: /* ids ::= ID */ - case 44: /* ids ::= STRING */ yytestcase(yyruleno==44); + case 44: /* ids ::= ID */ + case 45: /* ids ::= STRING */ yytestcase(yyruleno==45); {yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 45: /* ifexists ::= IF EXISTS */ + case 46: /* ifexists ::= IF EXISTS */ { yymsp[-1].minor.yy0.n = 1;} break; - case 46: /* ifexists ::= */ - case 48: /* ifnotexists ::= */ yytestcase(yyruleno==48); + case 47: /* ifexists ::= */ + case 49: /* ifnotexists ::= */ yytestcase(yyruleno==49); { yymsp[1].minor.yy0.n = 0;} break; - case 47: /* ifnotexists ::= IF NOT EXISTS */ + case 48: /* ifnotexists ::= IF NOT EXISTS */ { yymsp[-2].minor.yy0.n = 1;} break; - case 49: /* cmd ::= CREATE DNODE ids */ + case 50: /* cmd ::= CREATE DNODE ids */ { setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; - case 50: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy71);} + case 51: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy277);} break; - case 51: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ -{ setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy234, &yymsp[-2].minor.yy0);} + case 52: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ +{ + setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy256, &yymsp[-2].minor.yy0);} break; - case 52: /* cmd ::= CREATE USER ids PASS ids */ + case 53: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} break; - case 53: /* pps ::= */ - case 55: /* tseries ::= */ yytestcase(yyruleno==55); - case 57: /* dbs ::= */ yytestcase(yyruleno==57); - case 59: /* streams ::= */ yytestcase(yyruleno==59); - case 61: /* storage ::= */ yytestcase(yyruleno==61); - case 63: /* qtime ::= */ yytestcase(yyruleno==63); - case 65: /* users ::= */ yytestcase(yyruleno==65); - case 67: /* conns ::= */ yytestcase(yyruleno==67); - case 69: /* state ::= */ yytestcase(yyruleno==69); + case 54: /* pps ::= */ + case 56: /* tseries ::= */ yytestcase(yyruleno==56); + case 58: /* dbs ::= */ yytestcase(yyruleno==58); + case 60: /* streams ::= */ yytestcase(yyruleno==60); + case 62: /* storage ::= */ yytestcase(yyruleno==62); + case 64: /* qtime ::= */ yytestcase(yyruleno==64); + case 66: /* users ::= */ yytestcase(yyruleno==66); + case 68: /* conns ::= */ yytestcase(yyruleno==68); + case 70: /* state ::= */ yytestcase(yyruleno==70); { yymsp[1].minor.yy0.n = 0; } break; - case 54: /* pps ::= PPS INTEGER */ - case 56: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==56); - case 58: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==58); - case 60: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==60); - case 62: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==62); - case 64: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==64); - case 66: /* users ::= USERS INTEGER */ yytestcase(yyruleno==66); - case 68: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==68); - case 70: /* state ::= STATE ids */ yytestcase(yyruleno==70); + case 55: /* pps ::= PPS INTEGER */ + case 57: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==57); + case 59: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==59); + case 61: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==61); + case 63: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==63); + case 65: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==65); + case 67: /* users ::= USERS INTEGER */ yytestcase(yyruleno==67); + case 69: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==69); + case 71: /* state ::= STATE ids */ yytestcase(yyruleno==71); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 71: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + case 72: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy71.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy71.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy71.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy71.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy71.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy71.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy71.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy71.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy71.stat = yymsp[0].minor.yy0; -} - yymsp[-8].minor.yy71 = yylhsminor.yy71; - break; - case 72: /* keep ::= KEEP tagitemlist */ -{ yymsp[-1].minor.yy421 = yymsp[0].minor.yy421; } - break; - case 73: /* cache ::= CACHE INTEGER */ - case 74: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==74); - case 75: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==75); - case 76: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==76); - case 77: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==77); - case 78: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==78); - case 79: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==79); - case 80: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==80); - case 81: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==81); - case 82: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==82); - case 83: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==83); - case 84: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==84); - case 85: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==85); - case 86: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==86); + yylhsminor.yy277.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy277.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy277.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy277.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy277.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy277.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy277.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy277.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy277.stat = yymsp[0].minor.yy0; +} + yymsp[-8].minor.yy277 = yylhsminor.yy277; + break; + case 73: /* keep ::= KEEP tagitemlist */ +{ yymsp[-1].minor.yy135 = yymsp[0].minor.yy135; } + break; + case 74: /* cache ::= CACHE INTEGER */ + case 75: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==75); + case 76: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==76); + case 77: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==77); + case 78: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==78); + case 79: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==79); + case 80: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==80); + case 81: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==81); + case 82: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==82); + case 83: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==83); + case 84: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==84); + case 85: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==85); + case 86: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==86); + case 87: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==87); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 87: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy234);} - break; - case 88: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 89: /* db_optr ::= db_optr replica */ - case 104: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==104); -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 90: /* db_optr ::= db_optr quorum */ - case 105: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==105); -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 91: /* db_optr ::= db_optr days */ -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 92: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 93: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 94: /* db_optr ::= db_optr blocks */ - case 107: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==107); -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 95: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 96: /* db_optr ::= db_optr wal */ - case 109: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==109); -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 97: /* db_optr ::= db_optr fsync */ - case 110: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==110); -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 98: /* db_optr ::= db_optr comp */ - case 108: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==108); -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 99: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 100: /* db_optr ::= db_optr keep */ - case 106: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==106); -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.keep = yymsp[0].minor.yy421; } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 101: /* db_optr ::= db_optr update */ - case 111: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==111); -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 102: /* db_optr ::= db_optr cachelast */ - case 112: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==112); -{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy234 = yylhsminor.yy234; - break; - case 103: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy234);} - break; - case 113: /* typename ::= ids */ + case 88: /* db_optr ::= */ +{setDefaultCreateDbOption(&yymsp[1].minor.yy256);} + break; + case 89: /* db_optr ::= db_optr cache */ +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 90: /* db_optr ::= db_optr replica */ + case 105: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==105); +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 91: /* db_optr ::= db_optr quorum */ + case 106: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==106); +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 92: /* db_optr ::= db_optr days */ +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 93: /* db_optr ::= db_optr minrows */ +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 94: /* db_optr ::= db_optr maxrows */ +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 95: /* db_optr ::= db_optr blocks */ + case 108: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==108); +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 96: /* db_optr ::= db_optr ctime */ +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 97: /* db_optr ::= db_optr wal */ + case 110: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==110); +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 98: /* db_optr ::= db_optr fsync */ + case 111: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==111); +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 99: /* db_optr ::= db_optr comp */ + case 109: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==109); +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 100: /* db_optr ::= db_optr prec */ +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 101: /* db_optr ::= db_optr keep */ + case 107: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==107); +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.keep = yymsp[0].minor.yy135; } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 102: /* db_optr ::= db_optr update */ + case 112: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==112); +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 103: /* db_optr ::= db_optr cachelast */ + case 113: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==113); +{ yylhsminor.yy256 = yymsp[-1].minor.yy256; yylhsminor.yy256.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy256 = yylhsminor.yy256; + break; + case 104: /* alter_db_optr ::= */ +{ setDefaultCreateDbOption(&yymsp[1].minor.yy256);} + break; + case 114: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSqlSetColumnType (&yylhsminor.yy183, &yymsp[0].minor.yy0); + tSqlSetColumnType (&yylhsminor.yy181, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy183 = yylhsminor.yy183; + yymsp[0].minor.yy181 = yylhsminor.yy181; break; - case 114: /* typename ::= ids LP signed RP */ + case 115: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy325 <= 0) { + if (yymsp[-1].minor.yy531 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSqlSetColumnType(&yylhsminor.yy183, &yymsp[-3].minor.yy0); + tSqlSetColumnType(&yylhsminor.yy181, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy325; // negative value of name length - tSqlSetColumnType(&yylhsminor.yy183, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy531; // negative value of name length + tSqlSetColumnType(&yylhsminor.yy181, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy183 = yylhsminor.yy183; + yymsp[-3].minor.yy181 = yylhsminor.yy181; break; - case 115: /* typename ::= ids UNSIGNED */ + case 116: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); - tSqlSetColumnType (&yylhsminor.yy183, &yymsp[-1].minor.yy0); + tSqlSetColumnType (&yylhsminor.yy181, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy183 = yylhsminor.yy183; + yymsp[-1].minor.yy181 = yylhsminor.yy181; break; - case 116: /* signed ::= INTEGER */ -{ yylhsminor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy325 = yylhsminor.yy325; + case 117: /* signed ::= INTEGER */ +{ yylhsminor.yy531 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy531 = yylhsminor.yy531; break; - case 117: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + case 118: /* signed ::= PLUS INTEGER */ +{ yymsp[-1].minor.yy531 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 118: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy325 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} + case 119: /* signed ::= MINUS INTEGER */ +{ yymsp[-1].minor.yy531 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 120: /* cmd ::= CREATE TABLE create_table_list */ + case 123: /* cmd ::= CREATE TABLE create_table_list */ { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy38;} break; - case 121: /* create_table_list ::= create_from_stable */ + case 124: /* create_table_list ::= create_from_stable */ { SCreateTableSQL* pCreateTable = calloc(1, sizeof(SCreateTableSQL)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy152); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy78); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; yylhsminor.yy38 = pCreateTable; } yymsp[0].minor.yy38 = yylhsminor.yy38; break; - case 122: /* create_table_list ::= create_table_list create_from_stable */ + case 125: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy38->childTableInfo, &yymsp[0].minor.yy152); + taosArrayPush(yymsp[-1].minor.yy38->childTableInfo, &yymsp[0].minor.yy78); yylhsminor.yy38 = yymsp[-1].minor.yy38; } yymsp[-1].minor.yy38 = yylhsminor.yy38; break; - case 123: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 126: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy38 = tSetCreateSqlElems(yymsp[-1].minor.yy421, NULL, NULL, TSQL_CREATE_TABLE); + yylhsminor.yy38 = tSetCreateSqlElems(yymsp[-1].minor.yy135, NULL, NULL, TSQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy38, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -2426,9 +2468,9 @@ static void yy_reduce( } yymsp[-5].minor.yy38 = yylhsminor.yy38; break; - case 124: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + case 127: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy38 = tSetCreateSqlElems(yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, NULL, TSQL_CREATE_STABLE); + yylhsminor.yy38 = tSetCreateSqlElems(yymsp[-5].minor.yy135, yymsp[-1].minor.yy135, NULL, TSQL_CREATE_STABLE); setSqlInfo(pInfo, yylhsminor.yy38, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; @@ -2436,17 +2478,17 @@ static void yy_reduce( } yymsp[-9].minor.yy38 = yylhsminor.yy38; break; - case 125: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + case 128: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; - yylhsminor.yy152 = createNewChildTableInfo(&yymsp[-5].minor.yy0, yymsp[-1].minor.yy421, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy78 = createNewChildTableInfo(&yymsp[-5].minor.yy0, yymsp[-1].minor.yy135, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy152 = yylhsminor.yy152; + yymsp[-9].minor.yy78 = yylhsminor.yy78; break; - case 126: /* create_table_args ::= ifnotexists ids cpxName AS select */ + case 129: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy38 = tSetCreateSqlElems(NULL, NULL, yymsp[0].minor.yy148, TSQL_CREATE_STREAM); + yylhsminor.yy38 = tSetCreateSqlElems(NULL, NULL, yymsp[0].minor.yy30, TSQL_CREATE_STREAM); setSqlInfo(pInfo, yylhsminor.yy38, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; @@ -2454,451 +2496,451 @@ static void yy_reduce( } yymsp[-4].minor.yy38 = yylhsminor.yy38; break; - case 127: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy183); yylhsminor.yy421 = yymsp[-2].minor.yy421; } - yymsp[-2].minor.yy421 = yylhsminor.yy421; + case 130: /* columnlist ::= columnlist COMMA column */ +{taosArrayPush(yymsp[-2].minor.yy135, &yymsp[0].minor.yy181); yylhsminor.yy135 = yymsp[-2].minor.yy135; } + yymsp[-2].minor.yy135 = yylhsminor.yy135; break; - case 128: /* columnlist ::= column */ -{yylhsminor.yy421 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy183);} - yymsp[0].minor.yy421 = yylhsminor.yy421; + case 131: /* columnlist ::= column */ +{yylhsminor.yy135 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy135, &yymsp[0].minor.yy181);} + yymsp[0].minor.yy135 = yylhsminor.yy135; break; - case 129: /* column ::= ids typename */ + case 132: /* column ::= ids typename */ { - tSqlSetColumnInfo(&yylhsminor.yy183, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy183); + tSqlSetColumnInfo(&yylhsminor.yy181, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy181); } - yymsp[-1].minor.yy183 = yylhsminor.yy183; + yymsp[-1].minor.yy181 = yylhsminor.yy181; break; - case 130: /* tagitemlist ::= tagitemlist COMMA tagitem */ -{ yylhsminor.yy421 = tVariantListAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy430, -1); } - yymsp[-2].minor.yy421 = yylhsminor.yy421; + case 133: /* tagitemlist ::= tagitemlist COMMA tagitem */ +{ yylhsminor.yy135 = tVariantListAppend(yymsp[-2].minor.yy135, &yymsp[0].minor.yy308, -1); } + yymsp[-2].minor.yy135 = yylhsminor.yy135; break; - case 131: /* tagitemlist ::= tagitem */ -{ yylhsminor.yy421 = tVariantListAppend(NULL, &yymsp[0].minor.yy430, -1); } - yymsp[0].minor.yy421 = yylhsminor.yy421; + case 134: /* tagitemlist ::= tagitem */ +{ yylhsminor.yy135 = tVariantListAppend(NULL, &yymsp[0].minor.yy308, -1); } + yymsp[0].minor.yy135 = yylhsminor.yy135; break; - case 132: /* tagitem ::= INTEGER */ - case 133: /* tagitem ::= FLOAT */ yytestcase(yyruleno==133); - case 134: /* tagitem ::= STRING */ yytestcase(yyruleno==134); - case 135: /* tagitem ::= BOOL */ yytestcase(yyruleno==135); -{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy430, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy430 = yylhsminor.yy430; + case 135: /* tagitem ::= INTEGER */ + case 136: /* tagitem ::= FLOAT */ yytestcase(yyruleno==136); + case 137: /* tagitem ::= STRING */ yytestcase(yyruleno==137); + case 138: /* tagitem ::= BOOL */ yytestcase(yyruleno==138); +{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy308, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy308 = yylhsminor.yy308; break; - case 136: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy430, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy430 = yylhsminor.yy430; + case 139: /* tagitem ::= NULL */ +{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy308, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy308 = yylhsminor.yy308; break; - case 137: /* tagitem ::= MINUS INTEGER */ - case 138: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==138); - case 139: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==139); - case 140: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==140); + case 140: /* tagitem ::= MINUS INTEGER */ + case 141: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==141); + case 142: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==142); + case 143: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==143); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; toTSDBType(yymsp[-1].minor.yy0.type); - tVariantCreate(&yylhsminor.yy430, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy308, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy430 = yylhsminor.yy430; + yymsp[-1].minor.yy308 = yylhsminor.yy308; break; - case 141: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + case 144: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { - yylhsminor.yy148 = tSetQuerySqlElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy166, yymsp[-9].minor.yy421, yymsp[-8].minor.yy78, yymsp[-4].minor.yy421, yymsp[-3].minor.yy421, &yymsp[-7].minor.yy400, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy421, &yymsp[0].minor.yy167, &yymsp[-1].minor.yy167); + yylhsminor.yy30 = tSetQuerySqlElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy266, yymsp[-9].minor.yy135, yymsp[-8].minor.yy316, yymsp[-4].minor.yy135, yymsp[-3].minor.yy135, &yymsp[-7].minor.yy160, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy135, &yymsp[0].minor.yy126, &yymsp[-1].minor.yy126); } - yymsp[-11].minor.yy148 = yylhsminor.yy148; + yymsp[-11].minor.yy30 = yylhsminor.yy30; break; - case 142: /* union ::= select */ -{ yylhsminor.yy153 = setSubclause(NULL, yymsp[0].minor.yy148); } + case 145: /* union ::= select */ +{ yylhsminor.yy153 = setSubclause(NULL, yymsp[0].minor.yy30); } yymsp[0].minor.yy153 = yylhsminor.yy153; break; - case 143: /* union ::= LP union RP */ + case 146: /* union ::= LP union RP */ { yymsp[-2].minor.yy153 = yymsp[-1].minor.yy153; } break; - case 144: /* union ::= union UNION ALL select */ -{ yylhsminor.yy153 = appendSelectClause(yymsp[-3].minor.yy153, yymsp[0].minor.yy148); } + case 147: /* union ::= union UNION ALL select */ +{ yylhsminor.yy153 = appendSelectClause(yymsp[-3].minor.yy153, yymsp[0].minor.yy30); } yymsp[-3].minor.yy153 = yylhsminor.yy153; break; - case 145: /* union ::= union UNION ALL LP select RP */ -{ yylhsminor.yy153 = appendSelectClause(yymsp[-5].minor.yy153, yymsp[-1].minor.yy148); } + case 148: /* union ::= union UNION ALL LP select RP */ +{ yylhsminor.yy153 = appendSelectClause(yymsp[-5].minor.yy153, yymsp[-1].minor.yy30); } yymsp[-5].minor.yy153 = yylhsminor.yy153; break; - case 146: /* cmd ::= union */ + case 149: /* cmd ::= union */ { setSqlInfo(pInfo, yymsp[0].minor.yy153, NULL, TSDB_SQL_SELECT); } break; - case 147: /* select ::= SELECT selcollist */ + case 150: /* select ::= SELECT selcollist */ { - yylhsminor.yy148 = tSetQuerySqlElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy166, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy30 = tSetQuerySqlElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy266, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy148 = yylhsminor.yy148; + yymsp[-1].minor.yy30 = yylhsminor.yy30; break; - case 148: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy166 = yymsp[-1].minor.yy166;} - yymsp[-1].minor.yy166 = yylhsminor.yy166; + case 151: /* sclp ::= selcollist COMMA */ +{yylhsminor.yy266 = yymsp[-1].minor.yy266;} + yymsp[-1].minor.yy266 = yylhsminor.yy266; break; - case 149: /* sclp ::= */ -{yymsp[1].minor.yy166 = 0;} + case 152: /* sclp ::= */ +{yymsp[1].minor.yy266 = 0;} break; - case 150: /* selcollist ::= sclp expr as */ + case 153: /* selcollist ::= sclp expr as */ { - yylhsminor.yy166 = tSqlExprListAppend(yymsp[-2].minor.yy166, yymsp[-1].minor.yy78, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy266 = tSqlExprListAppend(yymsp[-2].minor.yy266, yymsp[-1].minor.yy316, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-2].minor.yy166 = yylhsminor.yy166; + yymsp[-2].minor.yy266 = yylhsminor.yy266; break; - case 151: /* selcollist ::= sclp STAR */ + case 154: /* selcollist ::= sclp STAR */ { tSQLExpr *pNode = tSqlExprIdValueCreate(NULL, TK_ALL); - yylhsminor.yy166 = tSqlExprListAppend(yymsp[-1].minor.yy166, pNode, 0); + yylhsminor.yy266 = tSqlExprListAppend(yymsp[-1].minor.yy266, pNode, 0); } - yymsp[-1].minor.yy166 = yylhsminor.yy166; + yymsp[-1].minor.yy266 = yylhsminor.yy266; break; - case 152: /* as ::= AS ids */ + case 155: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 153: /* as ::= ids */ + case 156: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 154: /* as ::= */ + case 157: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 155: /* from ::= FROM tablelist */ -{yymsp[-1].minor.yy421 = yymsp[0].minor.yy421;} + case 158: /* from ::= FROM tablelist */ +{yymsp[-1].minor.yy135 = yymsp[0].minor.yy135;} break; - case 156: /* tablelist ::= ids cpxName */ + case 159: /* tablelist ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy421 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); - yylhsminor.yy421 = tVariantListAppendToken(yylhsminor.yy421, &yymsp[-1].minor.yy0, -1); // table alias name + yylhsminor.yy135 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy135 = tVariantListAppendToken(yylhsminor.yy135, &yymsp[-1].minor.yy0, -1); // table alias name } - yymsp[-1].minor.yy421 = yylhsminor.yy421; + yymsp[-1].minor.yy135 = yylhsminor.yy135; break; - case 157: /* tablelist ::= ids cpxName ids */ + case 160: /* tablelist ::= ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy421 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - yylhsminor.yy421 = tVariantListAppendToken(yylhsminor.yy421, &yymsp[0].minor.yy0, -1); + yylhsminor.yy135 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); + yylhsminor.yy135 = tVariantListAppendToken(yylhsminor.yy135, &yymsp[0].minor.yy0, -1); } - yymsp[-2].minor.yy421 = yylhsminor.yy421; + yymsp[-2].minor.yy135 = yylhsminor.yy135; break; - case 158: /* tablelist ::= tablelist COMMA ids cpxName */ + case 161: /* tablelist ::= tablelist COMMA ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy421 = tVariantListAppendToken(yymsp[-3].minor.yy421, &yymsp[-1].minor.yy0, -1); - yylhsminor.yy421 = tVariantListAppendToken(yylhsminor.yy421, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy135 = tVariantListAppendToken(yymsp[-3].minor.yy135, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy135 = tVariantListAppendToken(yylhsminor.yy135, &yymsp[-1].minor.yy0, -1); } - yymsp[-3].minor.yy421 = yylhsminor.yy421; + yymsp[-3].minor.yy135 = yylhsminor.yy135; break; - case 159: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 162: /* tablelist ::= tablelist COMMA ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy421 = tVariantListAppendToken(yymsp[-4].minor.yy421, &yymsp[-2].minor.yy0, -1); - yylhsminor.yy421 = tVariantListAppendToken(yylhsminor.yy421, &yymsp[0].minor.yy0, -1); + yylhsminor.yy135 = tVariantListAppendToken(yymsp[-4].minor.yy135, &yymsp[-2].minor.yy0, -1); + yylhsminor.yy135 = tVariantListAppendToken(yylhsminor.yy135, &yymsp[0].minor.yy0, -1); } - yymsp[-4].minor.yy421 = yylhsminor.yy421; + yymsp[-4].minor.yy135 = yylhsminor.yy135; break; - case 160: /* tmvar ::= VARIABLE */ + case 163: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 161: /* interval_opt ::= INTERVAL LP tmvar RP */ -{yymsp[-3].minor.yy400.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy400.offset.n = 0; yymsp[-3].minor.yy400.offset.z = NULL; yymsp[-3].minor.yy400.offset.type = 0;} + case 164: /* interval_opt ::= INTERVAL LP tmvar RP */ +{yymsp[-3].minor.yy160.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy160.offset.n = 0; yymsp[-3].minor.yy160.offset.z = NULL; yymsp[-3].minor.yy160.offset.type = 0;} break; - case 162: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ -{yymsp[-5].minor.yy400.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy400.offset = yymsp[-1].minor.yy0;} + case 165: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ +{yymsp[-5].minor.yy160.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy160.offset = yymsp[-1].minor.yy0;} break; - case 163: /* interval_opt ::= */ -{memset(&yymsp[1].minor.yy400, 0, sizeof(yymsp[1].minor.yy400));} + case 166: /* interval_opt ::= */ +{memset(&yymsp[1].minor.yy160, 0, sizeof(yymsp[1].minor.yy160));} break; - case 164: /* fill_opt ::= */ -{yymsp[1].minor.yy421 = 0; } + case 167: /* fill_opt ::= */ +{yymsp[1].minor.yy135 = 0; } break; - case 165: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 168: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { tVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); tVariantCreate(&A, &yymsp[-3].minor.yy0); - tVariantListInsert(yymsp[-1].minor.yy421, &A, -1, 0); - yymsp[-5].minor.yy421 = yymsp[-1].minor.yy421; + tVariantListInsert(yymsp[-1].minor.yy135, &A, -1, 0); + yymsp[-5].minor.yy135 = yymsp[-1].minor.yy135; } break; - case 166: /* fill_opt ::= FILL LP ID RP */ + case 169: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy421 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy135 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 167: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 170: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 168: /* sliding_opt ::= */ + case 171: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 169: /* orderby_opt ::= */ -{yymsp[1].minor.yy421 = 0;} + case 172: /* orderby_opt ::= */ +{yymsp[1].minor.yy135 = 0;} break; - case 170: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} + case 173: /* orderby_opt ::= ORDER BY sortlist */ +{yymsp[-2].minor.yy135 = yymsp[0].minor.yy135;} break; - case 171: /* sortlist ::= sortlist COMMA item sortorder */ + case 174: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy421 = tVariantListAppend(yymsp[-3].minor.yy421, &yymsp[-1].minor.yy430, yymsp[0].minor.yy96); + yylhsminor.yy135 = tVariantListAppend(yymsp[-3].minor.yy135, &yymsp[-1].minor.yy308, yymsp[0].minor.yy130); } - yymsp[-3].minor.yy421 = yylhsminor.yy421; + yymsp[-3].minor.yy135 = yylhsminor.yy135; break; - case 172: /* sortlist ::= item sortorder */ + case 175: /* sortlist ::= item sortorder */ { - yylhsminor.yy421 = tVariantListAppend(NULL, &yymsp[-1].minor.yy430, yymsp[0].minor.yy96); + yylhsminor.yy135 = tVariantListAppend(NULL, &yymsp[-1].minor.yy308, yymsp[0].minor.yy130); } - yymsp[-1].minor.yy421 = yylhsminor.yy421; + yymsp[-1].minor.yy135 = yylhsminor.yy135; break; - case 173: /* item ::= ids cpxName */ + case 176: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - tVariantCreate(&yylhsminor.yy430, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy308, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy430 = yylhsminor.yy430; + yymsp[-1].minor.yy308 = yylhsminor.yy308; break; - case 174: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy96 = TSDB_ORDER_ASC; } + case 177: /* sortorder ::= ASC */ +{ yymsp[0].minor.yy130 = TSDB_ORDER_ASC; } break; - case 175: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy96 = TSDB_ORDER_DESC;} + case 178: /* sortorder ::= DESC */ +{ yymsp[0].minor.yy130 = TSDB_ORDER_DESC;} break; - case 176: /* sortorder ::= */ -{ yymsp[1].minor.yy96 = TSDB_ORDER_ASC; } + case 179: /* sortorder ::= */ +{ yymsp[1].minor.yy130 = TSDB_ORDER_ASC; } break; - case 177: /* groupby_opt ::= */ -{ yymsp[1].minor.yy421 = 0;} + case 180: /* groupby_opt ::= */ +{ yymsp[1].minor.yy135 = 0;} break; - case 178: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} + case 181: /* groupby_opt ::= GROUP BY grouplist */ +{ yymsp[-2].minor.yy135 = yymsp[0].minor.yy135;} break; - case 179: /* grouplist ::= grouplist COMMA item */ + case 182: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy421 = tVariantListAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy430, -1); + yylhsminor.yy135 = tVariantListAppend(yymsp[-2].minor.yy135, &yymsp[0].minor.yy308, -1); } - yymsp[-2].minor.yy421 = yylhsminor.yy421; + yymsp[-2].minor.yy135 = yylhsminor.yy135; break; - case 180: /* grouplist ::= item */ + case 183: /* grouplist ::= item */ { - yylhsminor.yy421 = tVariantListAppend(NULL, &yymsp[0].minor.yy430, -1); + yylhsminor.yy135 = tVariantListAppend(NULL, &yymsp[0].minor.yy308, -1); } - yymsp[0].minor.yy421 = yylhsminor.yy421; + yymsp[0].minor.yy135 = yylhsminor.yy135; break; - case 181: /* having_opt ::= */ - case 191: /* where_opt ::= */ yytestcase(yyruleno==191); - case 229: /* expritem ::= */ yytestcase(yyruleno==229); -{yymsp[1].minor.yy78 = 0;} + case 184: /* having_opt ::= */ + case 194: /* where_opt ::= */ yytestcase(yyruleno==194); + case 232: /* expritem ::= */ yytestcase(yyruleno==232); +{yymsp[1].minor.yy316 = 0;} break; - case 182: /* having_opt ::= HAVING expr */ - case 192: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==192); -{yymsp[-1].minor.yy78 = yymsp[0].minor.yy78;} + case 185: /* having_opt ::= HAVING expr */ + case 195: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==195); +{yymsp[-1].minor.yy316 = yymsp[0].minor.yy316;} break; - case 183: /* limit_opt ::= */ - case 187: /* slimit_opt ::= */ yytestcase(yyruleno==187); -{yymsp[1].minor.yy167.limit = -1; yymsp[1].minor.yy167.offset = 0;} + case 186: /* limit_opt ::= */ + case 190: /* slimit_opt ::= */ yytestcase(yyruleno==190); +{yymsp[1].minor.yy126.limit = -1; yymsp[1].minor.yy126.offset = 0;} break; - case 184: /* limit_opt ::= LIMIT signed */ - case 188: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==188); -{yymsp[-1].minor.yy167.limit = yymsp[0].minor.yy325; yymsp[-1].minor.yy167.offset = 0;} + case 187: /* limit_opt ::= LIMIT signed */ + case 191: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==191); +{yymsp[-1].minor.yy126.limit = yymsp[0].minor.yy531; yymsp[-1].minor.yy126.offset = 0;} break; - case 185: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy167.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy167.offset = yymsp[0].minor.yy325;} + case 188: /* limit_opt ::= LIMIT signed OFFSET signed */ +{ yymsp[-3].minor.yy126.limit = yymsp[-2].minor.yy531; yymsp[-3].minor.yy126.offset = yymsp[0].minor.yy531;} break; - case 186: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy167.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy167.offset = yymsp[-2].minor.yy325;} + case 189: /* limit_opt ::= LIMIT signed COMMA signed */ +{ yymsp[-3].minor.yy126.limit = yymsp[0].minor.yy531; yymsp[-3].minor.yy126.offset = yymsp[-2].minor.yy531;} break; - case 189: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy167.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy167.offset = yymsp[0].minor.yy325;} + case 192: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ +{yymsp[-3].minor.yy126.limit = yymsp[-2].minor.yy531; yymsp[-3].minor.yy126.offset = yymsp[0].minor.yy531;} break; - case 190: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy167.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy167.offset = yymsp[-2].minor.yy325;} + case 193: /* slimit_opt ::= SLIMIT signed COMMA signed */ +{yymsp[-3].minor.yy126.limit = yymsp[0].minor.yy531; yymsp[-3].minor.yy126.offset = yymsp[-2].minor.yy531;} break; - case 193: /* expr ::= LP expr RP */ -{yylhsminor.yy78 = yymsp[-1].minor.yy78; yylhsminor.yy78->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy78->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 196: /* expr ::= LP expr RP */ +{yylhsminor.yy316 = yymsp[-1].minor.yy316; yylhsminor.yy316->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy316->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 194: /* expr ::= ID */ -{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy78 = yylhsminor.yy78; + case 197: /* expr ::= ID */ +{ yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy316 = yylhsminor.yy316; break; - case 195: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 198: /* expr ::= ID DOT ID */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 196: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 199: /* expr ::= ID DOT STAR */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 197: /* expr ::= INTEGER */ -{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy78 = yylhsminor.yy78; + case 200: /* expr ::= INTEGER */ +{ yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy316 = yylhsminor.yy316; break; - case 198: /* expr ::= MINUS INTEGER */ - case 199: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==199); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy78 = yylhsminor.yy78; + case 201: /* expr ::= MINUS INTEGER */ + case 202: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==202); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy316 = yylhsminor.yy316; break; - case 200: /* expr ::= FLOAT */ -{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy78 = yylhsminor.yy78; + case 203: /* expr ::= FLOAT */ +{ yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy316 = yylhsminor.yy316; break; - case 201: /* expr ::= MINUS FLOAT */ - case 202: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==202); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy78 = yylhsminor.yy78; + case 204: /* expr ::= MINUS FLOAT */ + case 205: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==205); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy316 = yylhsminor.yy316; break; - case 203: /* expr ::= STRING */ -{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy78 = yylhsminor.yy78; + case 206: /* expr ::= STRING */ +{ yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy316 = yylhsminor.yy316; break; - case 204: /* expr ::= NOW */ -{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy78 = yylhsminor.yy78; + case 207: /* expr ::= NOW */ +{ yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy316 = yylhsminor.yy316; break; - case 205: /* expr ::= VARIABLE */ -{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy78 = yylhsminor.yy78; + case 208: /* expr ::= VARIABLE */ +{ yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy316 = yylhsminor.yy316; break; - case 206: /* expr ::= BOOL */ -{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy78 = yylhsminor.yy78; + case 209: /* expr ::= BOOL */ +{ yylhsminor.yy316 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy316 = yylhsminor.yy316; break; - case 207: /* expr ::= ID LP exprlist RP */ -{ yylhsminor.yy78 = tSqlExprCreateFunction(yymsp[-1].minor.yy166, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy78 = yylhsminor.yy78; + case 210: /* expr ::= ID LP exprlist RP */ +{ yylhsminor.yy316 = tSqlExprCreateFunction(yymsp[-1].minor.yy266, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy316 = yylhsminor.yy316; break; - case 208: /* expr ::= ID LP STAR RP */ -{ yylhsminor.yy78 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy78 = yylhsminor.yy78; + case 211: /* expr ::= ID LP STAR RP */ +{ yylhsminor.yy316 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy316 = yylhsminor.yy316; break; - case 209: /* expr ::= expr IS NULL */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, NULL, TK_ISNULL);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 212: /* expr ::= expr IS NULL */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, NULL, TK_ISNULL);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 210: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-3].minor.yy78, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy78 = yylhsminor.yy78; + case 213: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-3].minor.yy316, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy316 = yylhsminor.yy316; break; - case 211: /* expr ::= expr LT expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_LT);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 214: /* expr ::= expr LT expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_LT);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 212: /* expr ::= expr GT expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_GT);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 215: /* expr ::= expr GT expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_GT);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 213: /* expr ::= expr LE expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_LE);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 216: /* expr ::= expr LE expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_LE);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 214: /* expr ::= expr GE expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_GE);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 217: /* expr ::= expr GE expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_GE);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 215: /* expr ::= expr NE expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_NE);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 218: /* expr ::= expr NE expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_NE);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 216: /* expr ::= expr EQ expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_EQ);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 219: /* expr ::= expr EQ expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_EQ);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 217: /* expr ::= expr AND expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_AND);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 220: /* expr ::= expr AND expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_AND);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 218: /* expr ::= expr OR expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_OR); } - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 221: /* expr ::= expr OR expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_OR); } + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 219: /* expr ::= expr PLUS expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_PLUS); } - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 222: /* expr ::= expr PLUS expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_PLUS); } + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 220: /* expr ::= expr MINUS expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_MINUS); } - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 223: /* expr ::= expr MINUS expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_MINUS); } + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 221: /* expr ::= expr STAR expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_STAR); } - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 224: /* expr ::= expr STAR expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_STAR); } + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 222: /* expr ::= expr SLASH expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_DIVIDE);} - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 225: /* expr ::= expr SLASH expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_DIVIDE);} + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 223: /* expr ::= expr REM expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_REM); } - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 226: /* expr ::= expr REM expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_REM); } + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 224: /* expr ::= expr LIKE expr */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_LIKE); } - yymsp[-2].minor.yy78 = yylhsminor.yy78; + case 227: /* expr ::= expr LIKE expr */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-2].minor.yy316, yymsp[0].minor.yy316, TK_LIKE); } + yymsp[-2].minor.yy316 = yylhsminor.yy316; break; - case 225: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy78 = tSqlExprCreate(yymsp[-4].minor.yy78, (tSQLExpr*)yymsp[-1].minor.yy166, TK_IN); } - yymsp[-4].minor.yy78 = yylhsminor.yy78; + case 228: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy316 = tSqlExprCreate(yymsp[-4].minor.yy316, (tSQLExpr*)yymsp[-1].minor.yy266, TK_IN); } + yymsp[-4].minor.yy316 = yylhsminor.yy316; break; - case 226: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy166 = tSqlExprListAppend(yymsp[-2].minor.yy166,yymsp[0].minor.yy78,0);} - yymsp[-2].minor.yy166 = yylhsminor.yy166; + case 229: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy266 = tSqlExprListAppend(yymsp[-2].minor.yy266,yymsp[0].minor.yy316,0);} + yymsp[-2].minor.yy266 = yylhsminor.yy266; break; - case 227: /* exprlist ::= expritem */ -{yylhsminor.yy166 = tSqlExprListAppend(0,yymsp[0].minor.yy78,0);} - yymsp[0].minor.yy166 = yylhsminor.yy166; + case 230: /* exprlist ::= expritem */ +{yylhsminor.yy266 = tSqlExprListAppend(0,yymsp[0].minor.yy316,0);} + yymsp[0].minor.yy266 = yylhsminor.yy266; break; - case 228: /* expritem ::= expr */ -{yylhsminor.yy78 = yymsp[0].minor.yy78;} - yymsp[0].minor.yy78 = yylhsminor.yy78; + case 231: /* expritem ::= expr */ +{yylhsminor.yy316 = yymsp[0].minor.yy316;} + yymsp[0].minor.yy316 = yylhsminor.yy316; break; - case 230: /* cmd ::= RESET QUERY CACHE */ + case 233: /* cmd ::= RESET QUERY CACHE */ { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 231: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 234: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy135, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 232: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 235: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; toTSDBType(yymsp[0].minor.yy0.type); SArray* K = tVariantListAppendToken(NULL, &yymsp[0].minor.yy0, -1); - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 233: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 236: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy135, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 234: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 237: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; toTSDBType(yymsp[0].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[0].minor.yy0, -1); - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 235: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 238: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -2908,29 +2950,79 @@ static void yy_reduce( toTSDBType(yymsp[0].minor.yy0.type); A = tVariantListAppendToken(A, &yymsp[0].minor.yy0, -1); - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 236: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 239: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tVariantListAppend(A, &yymsp[0].minor.yy430, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy308, -1); + + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} + break; + case 240: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ +{ + yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy135, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} + break; + case 241: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ +{ + yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; + + toTSDBType(yymsp[0].minor.yy0.type); + SArray* K = tVariantListAppendToken(NULL, &yymsp[0].minor.yy0, -1); + + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, TSDB_SUPER_TABLE); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} + break; + case 242: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ +{ + yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy135, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} + break; + case 243: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ +{ + yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; + + toTSDBType(yymsp[0].minor.yy0.type); + SArray* A = tVariantListAppendToken(NULL, &yymsp[0].minor.yy0, -1); + + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, TSDB_SUPER_TABLE); + setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); +} + break; + case 244: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ +{ + yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; + + toTSDBType(yymsp[-1].minor.yy0.type); + SArray* A = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + + toTSDBType(yymsp[0].minor.yy0.type); + A = tVariantListAppendToken(A, &yymsp[0].minor.yy0, -1); - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL); + SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 237: /* cmd ::= KILL CONNECTION INTEGER */ + case 245: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 238: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 246: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 239: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 247: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: @@ -2991,7 +3083,7 @@ static void yy_syntax_error( /************ Begin %syntax_error code ****************************************/ pInfo->valid = false; - int32_t outputBufLen = tListLen(pInfo->pzErrMsg); + int32_t outputBufLen = tListLen(pInfo->msg); int32_t len = 0; if(TOKEN.z) { @@ -3001,13 +3093,13 @@ static void yy_syntax_error( if (sqlLen + sizeof(msg)/sizeof(msg[0]) + 1 > outputBufLen) { char tmpstr[128] = {0}; memcpy(tmpstr, &TOKEN.z[0], sizeof(tmpstr)/sizeof(tmpstr[0]) - 1); - len = sprintf(pInfo->pzErrMsg, msg, tmpstr); + len = sprintf(pInfo->msg, msg, tmpstr); } else { - len = sprintf(pInfo->pzErrMsg, msg, &TOKEN.z[0]); + len = sprintf(pInfo->msg, msg, &TOKEN.z[0]); } } else { - len = sprintf(pInfo->pzErrMsg, "Incomplete SQL statement"); + len = sprintf(pInfo->msg, "Incomplete SQL statement"); } assert(len <= outputBufLen); diff --git a/src/query/tests/astTest.cpp b/src/query/tests/astTest.cpp index 728de4357ce64abad78eb5bc421ce82a1e1e7a6d..ce7b2f94a177576c8046b299bcb2e695fb5ead2d 100644 --- a/src/query/tests/astTest.cpp +++ b/src/query/tests/astTest.cpp @@ -3,7 +3,7 @@ #include #include -#include "qAst.h" +#include "texpr.h" #include "taosmsg.h" #include "tsdb.h" #include "tskiplist.h" diff --git a/src/query/tests/patternMatchTest.cpp b/src/query/tests/patternMatchTest.cpp index fa2b58a10bd044491a2fabbaee6180c37320ae35..f3e0d3e119259d0a7cc8a94a6b43f4c71558bf78 100644 --- a/src/query/tests/patternMatchTest.cpp +++ b/src/query/tests/patternMatchTest.cpp @@ -3,7 +3,7 @@ #include #include -#include "tsqlfunction.h" +#include "qAggMain.h" #include "tcompare.h" TEST(testCase, patternMatchTest) { diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index daf3bd86c168ea75c29f5229cecea1acd0c66cd3..6cdf3eff9a7ec46716a5a73a9d6e4330cdb90328 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -154,7 +154,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread if (code == 0) { code = pthread_create(&pServerObj->thread, &thattr, taosAcceptTcpConnection, (void *)pServerObj); if (code != 0) { - tError("%s failed to create TCP accept thread(%s)", label, strerror(errno)); + tError("%s failed to create TCP accept thread(%s)", label, strerror(code)); } } diff --git a/src/rpc/src/rpcUdp.c b/src/rpc/src/rpcUdp.c index 22301fcecc83fb1f4c9a29132b0311e05b2382e6..5f5a65b8f97c9d61e6e9ea991d34c04b9faec756 100644 --- a/src/rpc/src/rpcUdp.c +++ b/src/rpc/src/rpcUdp.c @@ -140,6 +140,7 @@ void taosStopUdpConnection(void *handle) { pConn = pSet->udpConn + i; if (pConn->fd >=0) shutdown(pConn->fd, SHUT_RDWR); if (pConn->fd >=0) taosCloseSocket(pConn->fd); + pConn->fd = -1; } for (int i = 0; i < pSet->threads; ++i) { @@ -198,8 +199,13 @@ static void *taosRecvUdpData(void *param) { while (1) { dataLen = recvfrom(pConn->fd, pConn->buffer, RPC_MAX_UDP_SIZE, 0, (struct sockaddr *)&sourceAdd, &addLen); if(dataLen <= 0) { - tDebug("%s UDP socket was closed, exiting(%s)", pConn->label, strerror(errno)); - break; + tDebug("%s UDP socket(fd:%d) receive dataLen(%d) error(%s)", pConn->label, pConn->fd, (int32_t)dataLen, strerror(errno)); + // for windows usage, remote shutdown also returns - 1 in windows client + if (-1 == pConn->fd) { + break; + } else { + continue; + } } port = ntohs(sourceAdd.sin_port); diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index 98100fbdd87dddc3d9d30431db912813172405b9..1981196525161737255c9807af36c4babc9d20a3 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -568,7 +568,7 @@ static void syncStartCheckPeerConn(SSyncPeer *pPeer) { int32_t ret = strcmp(pPeer->fqdn, tsNodeFqdn); if (pPeer->nodeId == 0 || (ret > 0) || (ret == 0 && pPeer->port > tsSyncPort)) { int32_t checkMs = 100 + (pNode->vgId * 10) % 100; - if (pNode->vgId > 1) checkMs = tsStatusInterval * 1000 + checkMs; + sDebug("%s, check peer connection after %d ms", pPeer->id, checkMs); taosTmrReset(syncCheckPeerConnection, checkMs, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); } diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 11c6de68f89b9bddac42e64a41fd8d890e41b9ac..39030b15d711aacb70054464d2f5a1106c147d2b 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -19,10 +19,10 @@ #include "tcompare.h" #include "exception.h" -#include "../../query/inc/qAst.h" // todo move to common module #include "tlosertree.h" #include "tsdb.h" #include "tsdbMain.h" +#include "texpr.h" #define EXTRA_BYTES 2 #define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) @@ -111,6 +111,7 @@ typedef struct STsdbQueryHandle { int32_t activeIndex; bool checkFiles; // check file stage bool cachelastrow; // check if last row cached + bool loadExternalRow; // load time window external data rows void* qinfo; // query info handle, for debug purpose int32_t type; // query type: retrieve all data blocks, 2. retrieve only last row, 3. retrieve direct prev|next rows SFileGroup* pFileGroup; @@ -125,6 +126,8 @@ typedef struct STsdbQueryHandle { SDataBlockLoadInfo dataBlockLoadInfo; /* record current block load information */ SLoadCompBlockInfo compBlockLoadInfo; /* record current compblock information in SQuery */ + SArray *prev; // previous row which is before than time window + SArray *next; // next row which is after the query time window SIOCostSummary cost; } STsdbQueryHandle; @@ -141,10 +144,10 @@ static int32_t tsdbGetCachedLastRow(STable* pTable, SDataRow* pRes, TSKEY* lastK static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle); static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock); static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order); -static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int maxRowsToRead, STimeWindow* win, - STsdbQueryHandle* pQueryHandle); -static int tsdbCheckInfoCompar(const void* key1, const void* key2); - +static int32_t tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int maxRowsToRead, STimeWindow* win, STsdbQueryHandle* pQueryHandle); +static int32_t tsdbCheckInfoCompar(const void* key1, const void* key2); +static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SMemRef* pMemRef); +static void* doFreeColumnInfoData(SArray* pColumnInfoData); static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) { pBlockLoadInfo->slot = -1; @@ -324,6 +327,7 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(TSDB_REPO_T* tsdb, STsdbQueryCond* pQueryHandle->allocSize = 0; pQueryHandle->locateStart = false; pQueryHandle->pMemRef = pMemRef; + pQueryHandle->loadExternalRow = pCond->loadExternalRows; if (tsdbInitReadHelper(&pQueryHandle->rhelper, (STsdbRepo*) tsdb) != 0) { goto out_of_memory; @@ -440,10 +444,11 @@ SArray* tsdbGetQueriedTableList(TsdbQueryHandleT *pHandle) { TsdbQueryHandleT tsdbQueryRowsInExternalWindow(TSDB_REPO_T *tsdb, STsdbQueryCond* pCond, STableGroupInfo *groupList, void* qinfo, SMemRef* pRef) { STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qinfo, pRef); + pQueryHandle->loadExternalRow = true; if (pQueryHandle != NULL) { - pQueryHandle->type = TSDB_QUERY_TYPE_EXTERNAL; changeQueryHandleForInterpQuery(pQueryHandle); } + return pQueryHandle; } @@ -1418,8 +1423,8 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* break; } - if (((tsArray[pos] > pQueryHandle->window.ekey || pos > endPos) && ASCENDING_TRAVERSE(pQueryHandle->order)) || - ((tsArray[pos] < pQueryHandle->window.ekey || pos < endPos) && !ASCENDING_TRAVERSE(pQueryHandle->order))) { + if (((pos > endPos || tsArray[pos] > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) || + ((pos < endPos || tsArray[pos] < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))) { break; } @@ -1930,17 +1935,21 @@ static bool doHasDataInBuffer(STsdbQueryHandle* pQueryHandle) { pQueryHandle->activeIndex += 1; } + if (pQueryHandle->loadExternalRow && pQueryHandle->window.skey == pQueryHandle->window.ekey) { + SMemRef* pMemRef = pQueryHandle->pMemRef; + doGetExternalRow(pQueryHandle, TSDB_PREV_ROW, pMemRef); + doGetExternalRow(pQueryHandle, TSDB_NEXT_ROW, pMemRef); + } + // no data in memtable or imemtable, decrease the memory reference. tsdbMayUnTakeMemSnapshot(pQueryHandle); return false; } +//todo not unref yet, since it is not support multi-group interpolation query static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) { // filter the queried time stamp in the first place STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle; - pQueryHandle->order = TSDB_ORDER_DESC; - - assert(pQueryHandle->window.skey == pQueryHandle->window.ekey); // starts from the buffer in case of descending timestamp order check data blocks size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); @@ -1950,8 +1959,8 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) { STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i); // the first qualified table for interpolation query - if (pQueryHandle->window.skey <= pCheckInfo->pTableObj->lastKey && - pCheckInfo->pTableObj->lastKey != TSKEY_INITIAL_VAL) { + if ((pQueryHandle->window.skey <= pCheckInfo->pTableObj->lastKey) && + (pCheckInfo->pTableObj->lastKey != TSKEY_INITIAL_VAL)) { break; } @@ -1968,9 +1977,6 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) { info.lastKey = pQueryHandle->window.skey; taosArrayPush(pQueryHandle->pTableCheckInfo, &info); - - // update the query time window according to the chosen last timestamp - pQueryHandle->window = (STimeWindow) {info.lastKey, TSKEY_INITIAL_VAL}; } static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int maxRowsToRead, STimeWindow* win, @@ -2050,7 +2056,6 @@ static void destroyHelper(void* param) { return; } - tQueryInfo* pInfo = (tQueryInfo*)param; if (pInfo->optr != TSDB_RELATION_IN) { tfree(pInfo->q); @@ -2059,111 +2064,6 @@ static void destroyHelper(void* param) { free(param); } -static bool getNeighborRows(STsdbQueryHandle* pQueryHandle) { - assert (pQueryHandle->type == TSDB_QUERY_TYPE_EXTERNAL); - - SDataBlockInfo blockInfo = {{0}, 0}; - - pQueryHandle->type = TSDB_QUERY_TYPE_ALL; - pQueryHandle->order = TSDB_ORDER_DESC; - - if (!tsdbNextDataBlock((void*) pQueryHandle)) { - return false; - } - - tsdbRetrieveDataBlockInfo((void*) pQueryHandle, &blockInfo); - /*SArray *pDataBlock = */tsdbRetrieveDataBlock((void*) pQueryHandle, pQueryHandle->defaultLoadColumn); - if (terrno != TSDB_CODE_SUCCESS) { - return false; - } - - if (pQueryHandle->cur.win.ekey == pQueryHandle->window.skey) { - // data already retrieve, discard other data rows and return - int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle)); - for (int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); - memcpy((char*)pCol->pData, (char*)pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows - 1), pCol->info.bytes); - } - - pQueryHandle->cur.win = (STimeWindow){pQueryHandle->window.skey, pQueryHandle->window.skey}; - pQueryHandle->window = pQueryHandle->cur.win; - pQueryHandle->cur.rows = 1; - pQueryHandle->type = TSDB_QUERY_TYPE_ALL; - return true; - } else { - STimeWindow win = (STimeWindow) {pQueryHandle->window.skey, INT64_MAX}; - STsdbQueryCond cond = { - .order = TSDB_ORDER_ASC, - .numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle)) - }; - cond.twindow = win; - - cond.colList = calloc(cond.numOfCols, sizeof(SColumnInfo)); - if (cond.colList == NULL) { - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; - return false; - } - - for(int32_t i = 0; i < cond.numOfCols; ++i) { - SColumnInfoData* pColInfoData = taosArrayGet(pQueryHandle->pColumns, i); - memcpy(&cond.colList[i], &pColInfoData->info, sizeof(SColumnInfo)); - } - - STsdbQueryHandle* pSecQueryHandle = tsdbQueryTablesImpl(pQueryHandle->pTsdb, &cond, pQueryHandle->qinfo, pQueryHandle->pMemRef); - - tfree(cond.colList); - - pSecQueryHandle->pTableCheckInfo = createCheckInfoFromCheckInfo(pQueryHandle->pTableCheckInfo, pSecQueryHandle->window.skey); - if (pSecQueryHandle->pTableCheckInfo == NULL) { - tsdbCleanupQueryHandle(pSecQueryHandle); - return false; - } - - if (!tsdbNextDataBlock((void*) pSecQueryHandle)) { - tsdbCleanupQueryHandle(pSecQueryHandle); - return false; - } - - tsdbRetrieveDataBlockInfo((void*) pSecQueryHandle, &blockInfo); - tsdbRetrieveDataBlock((void*) pSecQueryHandle, pSecQueryHandle->defaultLoadColumn); - - int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pSecQueryHandle)); - size_t si = taosArrayGetSize(pSecQueryHandle->pTableCheckInfo); - - for (int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); - memcpy((char*)pCol->pData, (char*)pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows - 1), pCol->info.bytes); - - SColumnInfoData* pCol1 = taosArrayGet(pSecQueryHandle->pColumns, i); - assert(pCol->info.colId == pCol1->info.colId); - - memcpy((char*)pCol->pData + pCol->info.bytes, pCol1->pData, pCol1->info.bytes); - } - - SColumnInfoData* pTSCol = taosArrayGet(pQueryHandle->pColumns, 0); - - // it is ascending order - pQueryHandle->order = TSDB_ORDER_DESC; - pQueryHandle->window = pQueryHandle->cur.win; - pQueryHandle->cur.win = (STimeWindow){((TSKEY*)pTSCol->pData)[0], ((TSKEY*)pTSCol->pData)[1]}; - pQueryHandle->cur.rows = 2; - pQueryHandle->cur.mixBlock = true; - - int32_t step = -1;// one step for ascending order traverse - for (int32_t j = 0; j < si; ++j) { - STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, j); - pCheckInfo->lastKey = pQueryHandle->cur.win.ekey + step; - } - - tsdbCleanupQueryHandle(pSecQueryHandle); - } - - //disable it after retrieve data - pQueryHandle->type = TSDB_QUERY_TYPE_EXTERNAL; - pQueryHandle->checkFiles = false; - return true; -} - // handle data in cache situation bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) { STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle; @@ -2174,16 +2074,7 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) { size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); assert(numOfTables > 0); - if (pQueryHandle->type == TSDB_QUERY_TYPE_EXTERNAL) { - SMemRef* pMemRef = pQueryHandle->pMemRef; - tsdbMayTakeMemSnapshot(pQueryHandle); - bool ret = getNeighborRows(pQueryHandle); - tsdbMayUnTakeMemSnapshot(pQueryHandle); - - // restore the pMemRef - pQueryHandle->pMemRef = pMemRef; - return ret; - } else if (pQueryHandle->type == TSDB_QUERY_TYPE_LAST && pQueryHandle->cachelastrow) { + if (pQueryHandle->type == TSDB_QUERY_TYPE_LAST && pQueryHandle->cachelastrow) { // the last row is cached in buffer, return it directly. // here note that the pQueryHandle->window must be the TS_INITIALIZER int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle)); @@ -2326,6 +2217,116 @@ bool tsdbNextDataBlockWithoutMerge(TsdbQueryHandleT* pHandle) { pQueryHandle->cost.checkForNextTime += elapsedTime; return false; } + +static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SMemRef* pMemRef) { + STsdbQueryHandle* pSecQueryHandle = NULL; + + if (type == TSDB_PREV_ROW && pQueryHandle->prev) { + return TSDB_CODE_SUCCESS; + } + + if (type == TSDB_NEXT_ROW && pQueryHandle->next) { + return TSDB_CODE_SUCCESS; + } + + // prepare the structure + int32_t numOfCols = (int32_t) QH_GET_NUM_OF_COLS(pQueryHandle); + + if (type == TSDB_PREV_ROW) { + pQueryHandle->prev = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); + if (pQueryHandle->prev == NULL) { + terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + goto out_of_memory; + } + } else { + pQueryHandle->next = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); + if (pQueryHandle->next == NULL) { + terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + goto out_of_memory; + } + } + + SArray* row = (type == TSDB_PREV_ROW)? pQueryHandle->prev:pQueryHandle->next; + + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); + + SColumnInfoData colInfo = {{0}, 0}; + colInfo.info = pCol->info; + colInfo.pData = calloc(1, pCol->info.bytes); + if (colInfo.pData == NULL) { + terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + goto out_of_memory; + } + + taosArrayPush(row, &colInfo); + } + + // load the previous row + STsdbQueryCond cond = {.numOfCols = numOfCols, .loadExternalRows = false,}; + if (type == TSDB_PREV_ROW) { + cond.order = TSDB_ORDER_DESC; + cond.twindow = (STimeWindow){pQueryHandle->window.skey, INT64_MIN}; + } else { + cond.order = TSDB_ORDER_ASC; + cond.twindow = (STimeWindow){pQueryHandle->window.skey, INT64_MAX}; + } + + cond.colList = calloc(cond.numOfCols, sizeof(SColumnInfo)); + if (cond.colList == NULL) { + terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + goto out_of_memory; + } + + for (int32_t i = 0; i < cond.numOfCols; ++i) { + SColumnInfoData* pColInfoData = taosArrayGet(pQueryHandle->pColumns, i); + memcpy(&cond.colList[i], &pColInfoData->info, sizeof(SColumnInfo)); + } + + pSecQueryHandle = tsdbQueryTablesImpl(pQueryHandle->pTsdb, &cond, pQueryHandle->qinfo, pMemRef); + + tfree(cond.colList); + pSecQueryHandle->pTableCheckInfo = createCheckInfoFromCheckInfo(pQueryHandle->pTableCheckInfo, pSecQueryHandle->window.skey); + if (pSecQueryHandle->pTableCheckInfo == NULL) { + terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + goto out_of_memory; + } + + if (!tsdbNextDataBlock((void*)pSecQueryHandle)) { + // no result in current query, free the corresponding result rows structure + if (type == TSDB_PREV_ROW) { + pQueryHandle->prev = doFreeColumnInfoData(pQueryHandle->prev); + } else { + pQueryHandle->next = doFreeColumnInfoData(pQueryHandle->next); + } + + goto out_of_memory; + } + + SDataBlockInfo blockInfo = {{0}, 0}; + tsdbRetrieveDataBlockInfo((void*)pSecQueryHandle, &blockInfo); + tsdbRetrieveDataBlock((void*)pSecQueryHandle, pSecQueryHandle->defaultLoadColumn); + + row = (type == TSDB_PREV_ROW)? pQueryHandle->prev:pQueryHandle->next; + int32_t pos = (type == TSDB_PREV_ROW)?pSecQueryHandle->cur.rows - 1:0; + + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pCol = taosArrayGet(row, i); + SColumnInfoData* s = taosArrayGet(pSecQueryHandle->pColumns, i); + memcpy((char*)pCol->pData, (char*)s->pData + s->info.bytes * pos, pCol->info.bytes); + } + +out_of_memory: + tsdbCleanupQueryHandle(pSecQueryHandle); + return terrno; +} + +SArray* tsdbGetExternalRow(TsdbQueryHandleT *pHandle, SMemRef* pMemRef, int16_t type) { + STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle; + assert(type == TSDB_PREV_ROW || type == TSDB_NEXT_ROW); + return (type == TSDB_PREV_ROW)? pQueryHandle->prev:pQueryHandle->next; +} + /* * 1. no data at all (pTable->lastKey = TSKEY_INITIAL_VAL), just return TSKEY_INITIAL_VAL * 2. has data but not loaded, just return lastKey but not set pRes @@ -2824,7 +2825,7 @@ static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) }; getTableListfromSkipList(pExpr, pSTable->pIndex, pRes, &supp); - tExprTreeDestroy(&pExpr, destroyHelper); + tExprTreeDestroy(pExpr, destroyHelper); return TSDB_CODE_SUCCESS; } @@ -2881,10 +2882,10 @@ int32_t tsdbQuerySTableByTagCond(TSDB_REPO_T* tsdb, uint64_t uid, TSKEY skey, co if (expr == NULL) { expr = exprTreeFromBinary(pTagCond, len); } else { - CLEANUP_PUSH_VOID_PTR_PTR(true, tExprNodeDestroy, expr, NULL); + CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, expr, NULL); tExprNode* tagExpr = exprTreeFromBinary(pTagCond, len); if (tagExpr != NULL) { - CLEANUP_PUSH_VOID_PTR_PTR(true, tExprNodeDestroy, tagExpr, NULL); + CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, tagExpr, NULL); tExprNode* tbnameExpr = expr; expr = calloc(1, sizeof(tExprNode)); if (expr == NULL) { @@ -2998,6 +2999,21 @@ int32_t tsdbGetTableGroupFromIdList(TSDB_REPO_T* tsdb, SArray* pTableIdList, STa return TSDB_CODE_SUCCESS; } +static void* doFreeColumnInfoData(SArray* pColumnInfoData) { + if (pColumnInfoData == NULL) { + return NULL; + } + + size_t cols = taosArrayGetSize(pColumnInfoData); + for (int32_t i = 0; i < cols; ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pColumnInfoData, i); + tfree(pColInfo->pData); + } + + taosArrayDestroy(pColumnInfoData); + return NULL; +} + void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) { STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*)queryHandle; if (pQueryHandle == NULL) { @@ -3015,14 +3031,7 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) { taosArrayDestroy(pQueryHandle->pTableCheckInfo); } - if (pQueryHandle->pColumns != NULL) { - size_t cols = taosArrayGetSize(pQueryHandle->pColumns); - for (int32_t i = 0; i < cols; ++i) { - SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); - tfree(pColInfo->pData); - } - taosArrayDestroy(pQueryHandle->pColumns); - } + pQueryHandle->pColumns = doFreeColumnInfoData(pQueryHandle->pColumns); taosArrayDestroy(pQueryHandle->defaultLoadColumn); tfree(pQueryHandle->pDataBlockInfo); @@ -3036,6 +3045,9 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) { tdFreeDataCols(pQueryHandle->pDataCols); pQueryHandle->pDataCols = NULL; + pQueryHandle->prev = doFreeColumnInfoData(pQueryHandle->prev); + pQueryHandle->next = doFreeColumnInfoData(pQueryHandle->next); + SIOCostSummary* pCost = &pQueryHandle->cost; tsdbDebug("%p :io-cost summary: statis-info:%"PRId64" us, datablock:%" PRId64" us, check data:%"PRId64" us, %p", pQueryHandle, pCost->statisInfoLoadTime, pCost->blockLoadTime, pCost->checkForNextTime, pQueryHandle->qinfo); diff --git a/src/util/inc/tarray.h b/src/util/inc/tarray.h index bf922fe9c44b4f923d44f4a38c1c4c1a7fb20af3..35053c278e3a0a5f50b6244a38248ac4e17d04c4 100644 --- a/src/util/inc/tarray.h +++ b/src/util/inc/tarray.h @@ -110,7 +110,7 @@ void taosArrayCopy(SArray* pDst, const SArray* pSrc); * clone a new array * @param pSrc */ -SArray* taosArrayClone(const SArray* pSrc); +SArray* taosArrayDup(const SArray* pSrc); /** * clear the array (remove all element) diff --git a/src/util/src/tarray.c b/src/util/src/tarray.c index bec2fac7dfd03ada681b9011df7e465cd0a49f0c..45cb6eee0f5f5ad891c7bf620d2c3acdaabd629e 100644 --- a/src/util/src/tarray.c +++ b/src/util/src/tarray.c @@ -165,7 +165,7 @@ void taosArrayCopy(SArray* pDst, const SArray* pSrc) { pDst->size = pSrc->size; } -SArray* taosArrayClone(const SArray* pSrc) { +SArray* taosArrayDup(const SArray* pSrc) { assert(pSrc != NULL); if (pSrc->size == 0) { // empty array list diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 3afdf41d05cf131922a24c6641d02b95acfe2a93..c0cc8ce33942d1e6784db0f7f4b86757f8f7f593 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -510,7 +510,9 @@ void taosCacheCleanup(SCacheObj *pCacheObj) { } pCacheObj->deleting = 1; - pthread_join(pCacheObj->refreshWorker, NULL); + if (taosCheckPthreadValid(pCacheObj->refreshWorker)) { + pthread_join(pCacheObj->refreshWorker, NULL); + } uInfo("cache:%s will be cleaned up", pCacheObj->name); doCleanupDataCache(pCacheObj); diff --git a/src/util/src/tref.c b/src/util/src/tref.c index 3ef45e9b191fddc45220c7b07551b098ae0891ba..ebae8ece14e2f3bd045fee92482afa4c6c403949 100644 --- a/src/util/src/tref.c +++ b/src/util/src/tref.c @@ -274,7 +274,7 @@ void *taosIterateRef(int rsetId, int64_t rid) { return NULL; } - if (rid <= 0) { + if (rid < 0) { uTrace("rsetId:%d rid:%" PRId64 " failed to iterate, rid not valid", rsetId, rid); terrno = TSDB_CODE_REF_NOT_EXIST; return NULL; diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 5f6f3fe105a9f0e4933db830dc42a6b597ea2ee1..3e72562c551b1071a703fc92b270182ec6c1f8be 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -201,6 +201,8 @@ int32_t vnodeOpen(int32_t vgId) { pthread_mutex_init(&pVnode->statusMutex, NULL); vnodeSetInitStatus(pVnode); + tsdbIncCommitRef(pVnode->vgId); + int32_t code = vnodeReadCfg(pVnode); if (code != TSDB_CODE_SUCCESS) { vnodeCleanUp(pVnode); @@ -297,7 +299,6 @@ int32_t vnodeOpen(int32_t vgId) { pVnode->events = NULL; vDebug("vgId:%d, vnode is opened in %s, pVnode:%p", pVnode->vgId, rootDir, pVnode); - tsdbIncCommitRef(pVnode->vgId); vnodeAddIntoHash(pVnode); diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java index e569de10cf7894aa04fc3cb5bdb8354b581d5a93..0fa0059805e54893a3c25a4dbd7a0f4d67207b57 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java @@ -48,7 +48,6 @@ public class JDBCDemo { Class.forName("com.taosdata.jdbc.TSDBDriver"); } Properties properties = new Properties(); - properties.setProperty("host", host); properties.setProperty("charset", "UTF-8"); properties.setProperty("locale", "en_US.UTF-8"); properties.setProperty("timezone", "UTC-8"); diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..880bcbfc6fcda29c7225090707d694b3d0f7d4ea --- /dev/null +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java @@ -0,0 +1,45 @@ +package com.taosdata.example; + +import java.sql.*; +import java.util.Properties; + +public class JdbcRestfulDemo { + private static final String host = "master"; + + public static void main(String[] args) { + try { + // load JDBC-restful driver + Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); + // use port 6041 in url when use JDBC-restful + String url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"; + + Properties properties = new Properties(); + properties.setProperty("charset", "UTF-8"); + properties.setProperty("locale", "en_US.UTF-8"); + properties.setProperty("timezone", "UTC-8"); + + Connection conn = DriverManager.getConnection(url, properties); + Statement stmt = conn.createStatement(); + + stmt.execute("create database if not exists restful_test"); + stmt.execute("use restful_test"); + stmt.execute("create table restful_test.weather(ts timestamp, temperature float) tags(location nchar(64))"); + stmt.executeUpdate("insert into t1 using restful_test.weather tags('北京') values(now, 18.2)"); + ResultSet rs = stmt.executeQuery("select * from restful_test.weather"); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); + } + System.out.println(); + } + + stmt.close(); + conn.close(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } + } +} diff --git a/src/connector/jdbc/src/test/java/TestTSDBSubscribe.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java similarity index 85% rename from src/connector/jdbc/src/test/java/TestTSDBSubscribe.java rename to tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java index 47acb200649be4c8c6af5817c2ef4c074a2a3fa0..bb3712a3024de84aea1dba0e71b47dec5e2405a5 100644 --- a/src/connector/jdbc/src/test/java/TestTSDBSubscribe.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java @@ -1,3 +1,5 @@ +package com.taosdata.example; + import com.taosdata.jdbc.TSDBConnection; import com.taosdata.jdbc.TSDBDriver; import com.taosdata.jdbc.TSDBResultSet; @@ -6,9 +8,9 @@ import com.taosdata.jdbc.TSDBSubscribe; import java.sql.DriverManager; import java.util.Properties; -public class TestTSDBSubscribe { +public class SubscribeDemo { - public static TSDBConnection connectTDengine(String host, String database) throws Exception { + public static TSDBConnection getConnection(String host, String database) throws Exception { Class.forName("com.taosdata.jdbc.TSDBDriver"); Properties properties = new Properties(); properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host); @@ -17,7 +19,7 @@ public class TestTSDBSubscribe { properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); String cs = String.format("jdbc:TAOS://%s:0/%s", host, database); - return (TSDBConnection)DriverManager.getConnection(cs, properties); + return (TSDBConnection) DriverManager.getConnection(cs, properties); } public static void main(String[] args) throws Exception { @@ -43,21 +45,21 @@ public class TestTSDBSubscribe { } } if (database.isEmpty() || topic.isEmpty() || sql.isEmpty()) { - System.err.println(usage); - return; + System.err.println(usage); + return; } TSDBConnection connection = null; TSDBSubscribe sub = null; try { - connection = connectTDengine(host, database); + connection = getConnection(host, database); sub = ((TSDBConnection) connection).subscribe(topic, sql, false); int total = 0; - while(true) { + while (true) { TSDBResultSet rs = sub.consume(); int count = 0; - while(rs.next()) { + while (rs.next()) { count++; } total += count; diff --git a/tests/examples/JDBC/taosdemo/pom.xml b/tests/examples/JDBC/taosdemo/pom.xml index 15b22917b6103740ac419e046d5fd8fa79363d25..15f868a117238956e79d58222809140e2a098144 100644 --- a/tests/examples/JDBC/taosdemo/pom.xml +++ b/tests/examples/JDBC/taosdemo/pom.xml @@ -67,9 +67,9 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.15 - system - ${project.basedir}/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar + 2.0.17 + + diff --git a/tests/examples/JDBC/taosdemo/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar b/tests/examples/JDBC/taosdemo/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar deleted file mode 100644 index 58508b92e5afec7e400691d213940536e8abe5f6..0000000000000000000000000000000000000000 Binary files a/tests/examples/JDBC/taosdemo/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar and /dev/null differ diff --git a/tests/examples/c/CMakeLists.txt b/tests/examples/c/CMakeLists.txt index 59bcb6eaff349e8b20fa13995d1a7297f9185a50..9e879d4c4c8fec6f2913c0b08e45a746782fe35f 100644 --- a/tests/examples/c/CMakeLists.txt +++ b/tests/examples/c/CMakeLists.txt @@ -3,6 +3,6 @@ PROJECT(TDengine) IF (TD_LINUX) INCLUDE_DIRECTORIES(. ${TD_COMMUNITY_DIR}/src/inc ${TD_COMMUNITY_DIR}/src/client/inc ${TD_COMMUNITY_DIR}/inc) AUX_SOURCE_DIRECTORY(. SRC) - ADD_EXECUTABLE(demo demo.c) + ADD_EXECUTABLE(demo apitest.c) TARGET_LINK_LIBRARIES(demo taos_static trpc tutil pthread ) ENDIF () diff --git a/tests/examples/nodejs/nodejsChecker.js b/tests/examples/nodejs/nodejsChecker.js index f838d5cc8465dba70b5372a5d7720a8cff69544a..e634a54ea1c56310bae7d38188590a0d7862f953 100644 --- a/tests/examples/nodejs/nodejsChecker.js +++ b/tests/examples/nodejs/nodejsChecker.js @@ -1,4 +1,5 @@ const taos = require('td2.0-connector'); +//const taos = require('../../../src/connector/nodejs/'); var host = null; diff --git a/tests/pytest/account/account_create.py b/tests/pytest/account/account_create.py index 85adfff19994a3fbb12611e28d9872fb6cb1aeca..c008acccd8d8d33af0ca77bd161d4ab020c1543e 100644 --- a/tests/pytest/account/account_create.py +++ b/tests/pytest/account/account_create.py @@ -24,6 +24,17 @@ class TDTestCase: tdSql.init(conn.cursor(), logSql) def run(self): + tdSql.query("show users") + rows = tdSql.queryRows + + tdSql.execute("create user test PASS 'test' ") + tdSql.query("show users") + tdSql.checkRows(rows + 1) + + tdSql.error("create user tdenginetdenginetdengine PASS 'test' ") + + tdSql.error("create user tdenginet PASS '1234512345123456' ") + try: tdSql.execute("create account a&cc PASS 'pass123'") except Exception as e: @@ -31,6 +42,7 @@ class TDTestCase: return tdLog.exit("drop built-in user is error.") + def stop(self): tdSql.close() diff --git a/tests/pytest/alter/alter_table.py b/tests/pytest/alter/alter_table.py index 2982492f6567ad54a62a3fcca44d4f1ac9560697..48b0154361803c9f614e64b1f66e416613e83131 100644 --- a/tests/pytest/alter/alter_table.py +++ b/tests/pytest/alter/alter_table.py @@ -126,6 +126,8 @@ class TDTestCase: for i in range(2, size): tdSql.checkData(0, i, self.rowNum * (size - i)) + tdSql.error("alter local debugflag 143") + tdSql.execute("create table st(ts timestamp, c1 int) tags(t1 float)") tdSql.execute("create table t0 using st tags(null)") tdSql.execute("alter table t0 set tag t1=2.1") diff --git a/tests/pytest/concurrent_inquiry.py b/tests/pytest/concurrent_inquiry.py index 7bdab8bc6717905e0d81309b0c948d2f3108b55c..e832c9a74e1c8b6c42a882a59931bff6d481f445 100644 --- a/tests/pytest/concurrent_inquiry.py +++ b/tests/pytest/concurrent_inquiry.py @@ -18,6 +18,8 @@ import time import random import requests import argparse +import datetime +import string from requests.auth import HTTPBasicAuth func_list=['avg','count','twa','sum','stddev','leastsquares','min', 'max','first','last','top','bottom','percentile','apercentile', @@ -31,7 +33,7 @@ condition_list=[ 'fill(null)' ] -where_list = ['_c0>now-10d',' <50'," like \'%a%\'"] +where_list = ['_c0>now-10d',' <50','like',' is null'] class ConcurrentInquiry: # def __init__(self,ts=1500000001000,host='127.0.0.1',user='root',password='taosdata',dbname='test', # stb_prefix='st',subtb_prefix='t',n_Therads=10,r_Therads=10,probabilities=0.05,loop=5, @@ -54,13 +56,15 @@ class ConcurrentInquiry: self.subtb_stru_list=[] self.stb_tag_list=[] self.subtb_tag_list=[] - self.probabilities = [probabilities,1-probabilities] - self.ifjoin = [0,1] + self.probabilities = [1-probabilities,probabilities] + self.ifjoin = [1,0] self.loop = loop self.stableNum = stableNum self.subtableNum = subtableNum self.insertRows = insertRows self.mix_table = mix_table + self.max_ts = datetime.datetime.now() + self.min_ts = datetime.datetime.now() - datetime.timedelta(days=5) def SetThreadsNum(self,num): self.numOfTherads=num @@ -103,6 +107,14 @@ class ConcurrentInquiry: self.subtb_stru_list.append(tb) self.subtb_tag_list.append(tag) + def get_timespan(self,cl): #获取时间跨度(仅第一个超级表) + sql = 'select first(_c0),last(_c0) from ' + self.dbname + '.' + self.stb_list[0] + ';' + print(sql) + cl.execute(sql) + for data in cl: + self.max_ts = data[1] + self.min_ts = data[0] + def get_full(self): #获取所有的表、表结构 host = self.host user = self.user @@ -118,6 +130,7 @@ class ConcurrentInquiry: self.r_subtb_list(cl,i) self.r_stb_stru(cl) self.r_subtb_stru(cl) + self.get_timespan(cl) cl.close() conn.close() @@ -127,9 +140,21 @@ class ConcurrentInquiry: for i in range(random.randint(0,len(tlist))): c = random.choice(where_list) if c == '_c0>now-10d': - l.append(c) + rdate = self.min_ts + (self.max_ts - self.min_ts)/10 * random.randint(-11,11) + conlist = ' _c0 ' + random.choice(['<','>','>=','<=','<>']) + "'" + str(rdate) + "'" + if self.random_pick(): + l.append(conlist) + else: l.append(c) + elif '<50' in c: + conlist = ' ' + random.choice(tlist) + random.choice(['<','>','>=','<=','<>']) + str(random.randrange(-100,100)) + l.append(conlist) + elif 'is null' in c: + conlist = ' ' + random.choice(tlist) + random.choice([' is null',' is not null']) + l.append(conlist) else: - l.append(random.choice(tlist)+c) + s_all = string.ascii_letters + conlist = ' ' + random.choice(tlist) + " like \'%" + random.choice(s_all) + "%\' " + l.append(conlist) return 'where '+random.choice([' and ',' or ']).join(l) def con_interval(self,tlist,col_list,tag_list): @@ -195,8 +220,10 @@ class ConcurrentInquiry: if bool(random.getrandbits(1)): pick_func+=alias sel_col_list.append(pick_func) - - sql=sql+','.join(sel_col_list) #select col & func + if col_rand == 0: + sql = sql + '*' + else: + sql=sql+','.join(sel_col_list) #select col & func if self.mix_table == 0: sql = sql + ' from '+random.choice(self.stb_list+self.subtb_list)+' ' elif self.mix_table == 1: @@ -262,7 +289,26 @@ class ConcurrentInquiry: else: sel_col_tag.append('t1.' + str(random.choice(col_list[0] + tag_list[0]))) sel_col_tag.append('t2.' + str(random.choice(col_list[1] + tag_list[1]))) - sql += ','.join(sel_col_tag) + sel_col_list = [] + random.shuffle(func_list) + if self.random_pick(): + loop = 0 + for i,j in zip(sel_col_tag,func_list): #决定每个被查询col的函数 + alias = ' as '+ 'taos%d ' % loop + loop += 1 + pick_func = '' + if j == 'leastsquares': + pick_func=j+'('+i+',1,1)' + elif j == 'top' or j == 'bottom' or j == 'percentile' or j == 'apercentile': + pick_func=j+'('+i+',1)' + else: + pick_func=j+'('+i+')' + if bool(random.getrandbits(1)): + pick_func+=alias + sel_col_list.append(pick_func) + sql += ','.join(sel_col_list) + else: + sql += ','.join(sel_col_tag) sql = sql + ' from '+ str(tbname[0]) +' t1,' + str(tbname[1]) + ' t2 ' #select col & func join_section = None @@ -274,7 +320,6 @@ class ConcurrentInquiry: else: temp = random.choices(col_intersection+tag_intersection) join_section = temp.pop() - print(random.choices(col_intersection)) sql += 'where t1._c0 = t2._c0 and ' + 't1.' + str(join_section) + '=t2.' + str(join_section) return sql diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index d9bc185b6c326b79d933dafc50cd7db0e0d396f4..3be784ae95c84599c773d5c52b68ef5a630482ea 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -175,6 +175,7 @@ python3 ./test.py -f query/bug2119.py python3 ./test.py -f query/isNullTest.py python3 ./test.py -f query/queryWithTaosdKilled.py python3 ./test.py -f query/floatCompare.py +python3 ./test.py -f query/queryGroupbySort.py #stream python3 ./test.py -f stream/metric_1.py @@ -258,4 +259,7 @@ python3 ./test.py -f update/merge_commit_last.py python3 ./test.py -f update/bug_td2279.py # wal -python3 ./test.py -f wal/addOldWalTest.py \ No newline at end of file +python3 ./test.py -f wal/addOldWalTest.py + +# account +python3 ./test.py -f account/account_create.py \ No newline at end of file diff --git a/tests/pytest/query/queryFillTest.py b/tests/pytest/query/queryFillTest.py index 9fd898041a525f9aaba65bda1233f94b1bb922e6..e50d02faf27f33191f4a76c535443f6802e0ed28 100644 --- a/tests/pytest/query/queryFillTest.py +++ b/tests/pytest/query/queryFillTest.py @@ -47,11 +47,38 @@ class TDTestCase: tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h)") tdSql.checkRows(139) + tdSql.checkData(0, 1, -1.5) + tdSql.checkData(138, 1, -1.0) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(none)") + tdSql.checkRows(139) + tdSql.checkData(0, 1, -1.5) + tdSql.checkData(138, 1, -1.0) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(value, 2.0)") + tdSql.checkRows(141) + tdSql.checkData(0, 1, 2.0) + tdSql.checkData(140, 1, 2.0) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(prev)") + tdSql.checkRows(141) + tdSql.checkData(0, 1, None) + tdSql.checkData(140, 1, -1.0) tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(null)") tdSql.checkRows(141) tdSql.checkData(0, 1, None) - tdSql.checkData(140, 1, None) + tdSql.checkData(140, 1, None) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(linear)") + tdSql.checkRows(141) + tdSql.checkData(0, 1, None) + tdSql.checkData(140, 1, None) + + tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(next)") + tdSql.checkRows(141) + tdSql.checkData(0, 1, -1.5) + tdSql.checkData(140, 1, None) tdSql.query("select max(col1) - min(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' and id = 1 group by loc, id") rows = tdSql.queryRows diff --git a/tests/pytest/query/queryGroupbySort.py b/tests/pytest/query/queryGroupbySort.py index 28ef897f42924d3e41c6598cac6b4c51e33d38ef..80f6d55aae1ae79cafbe651cc99db1d301dd90fc 100644 --- a/tests/pytest/query/queryGroupbySort.py +++ b/tests/pytest/query/queryGroupbySort.py @@ -28,19 +28,24 @@ class TDTestCase: def run(self): tdSql.prepare() - tdSql.execute( - "create table stb(ts timestamp,i int) tags (p_id nchar(20));") - tdSql.execute( - "insert into tb using stb tags('11231') values (%d, %d) (%d, %d) (%d, %d) (%d, %d)" - % (self.ts, 12, self.ts + 1, 15, self.ts + 2, 15, self.ts + 3, 12)) - - tdSql.query(''' select last(ts) p_time,i from stb where p_id='11231' and ts>=%d and ts <=%d - group by i order by time desc limit 100 ''' % (self.ts, self.ts + 4)) - tdSql.checkRows(2) - tdSql.checkData(0, 0, "2018-09-17 09:00:00.003000") - tdSql.checkData(1, 0, "2018-09-17 09:00:00.002000") - - + tdSql.execute("CREATE TABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int)") + tdSql.execute("CREATE TABLE D1001 USING meters TAGS ('Beijing.Chaoyang', 2)") + tdSql.execute("CREATE TABLE D1002 USING meters TAGS ('Beijing.Chaoyang', 3)") + tdSql.execute("INSERT INTO D1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, 218, 0.33) (1538548696800, 12.3, 221, 0.31)") + tdSql.execute("INSERT INTO D1002 VALUES (1538548685001, 10.5, 220, 0.28) (1538548696800, 12.3, 221, 0.31)") + + tdSql.query("SELECT SUM(current), AVG(voltage) FROM meters WHERE groupId > 1 INTERVAL(1s) GROUP BY location order by ts DESC") + tdSql.checkRows(3) + tdSql.checkData(0, 0, "2018-10-03 14:38:16") + tdSql.checkData(1, 0, "2018-10-03 14:38:15") + tdSql.checkData(2, 0, "2018-10-03 14:38:05") + + tdSql.query("SELECT SUM(current), AVG(voltage) FROM meters WHERE groupId > 1 INTERVAL(1s) GROUP BY location order by ts ASC") + tdSql.checkRows(3) + tdSql.checkData(0, 0, "2018-10-03 14:38:05") + tdSql.checkData(1, 0, "2018-10-03 14:38:15") + tdSql.checkData(2, 0, "2018-10-03 14:38:16") + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/query/sliding.py b/tests/pytest/query/sliding.py index 810d90117a73bba81ea010f81aa605196a496dc4..d7a7c9a36964796dd530f913523f8f4d344d467a 100644 --- a/tests/pytest/query/sliding.py +++ b/tests/pytest/query/sliding.py @@ -52,7 +52,15 @@ class TDTestCase: tdSql.query("select count(*) from meters group by loc") tdSql.checkRows(2) - tdSql.error("select * from meters group by loc sliding(5s)") + tdSql.error("select * from meters group by loc sliding(5s)") + + # Fix defect: https://jira.taosdata.com:18080/browse/TD-2700 + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create table t1(ts timestamp, k int)") + tdSql.execute("insert into t1 values(1500000001000, 0)") + tdSql.query("select sum(k) from t1 interval(1d) sliding(1h)") + tdSql.checkRows(24) def stop(self): tdSql.close() diff --git a/tests/script/general/alter/cached_schema_after_alter.sim b/tests/script/general/alter/cached_schema_after_alter.sim index 2d049ec5955e281d866eaaa15abf06583909c87d..96ee4390845450d53508cc90c48a3148a0a827dd 100644 --- a/tests/script/general/alter/cached_schema_after_alter.sim +++ b/tests/script/general/alter/cached_schema_after_alter.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $db = csaa_db @@ -53,10 +53,10 @@ endi print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed -sleep 5000 +sleep 3000 sql connect sql use $db diff --git a/tests/script/general/alter/count.sim b/tests/script/general/alter/count.sim index 157b4c137198b70a9e7ad3b1f64e5b4b06a90415..fc936668b8ea08f9cd08874ad98668a4d8904315 100644 --- a/tests/script/general/alter/count.sim +++ b/tests/script/general/alter/count.sim @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 print ========= start dnode1 as master system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 @@ -141,9 +141,9 @@ endi print ============= step10 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb if $data00 != 24 then @@ -250,9 +250,9 @@ endi print ============== step18 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 #sql select count(g) from tb #if $data00 != 12 then diff --git a/tests/script/general/alter/dnode.sim b/tests/script/general/alter/dnode.sim index 73a095ec054320d0373f137250193bc4d8230234..7b31218fc231cfdbb79ca97573cfc6f6f149037d 100644 --- a/tests/script/general/alter/dnode.sim +++ b/tests/script/general/alter/dnode.sim @@ -4,14 +4,14 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 sql alter dnode 1 resetlog sql alter dnode 1 monitor 1 -sleep 5000 +sleep 3000 sql select * from log.dn if $rows <= 0 then return -1 diff --git a/tests/script/general/alter/import.sim b/tests/script/general/alter/import.sim index 76388a26f2b15d1ce9a86331ab2e70cb29a88480..aef0a258b24563e915cd8aa3dd42f6623a29170a 100644 --- a/tests/script/general/alter/import.sim +++ b/tests/script/general/alter/import.sim @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 print ========= start dnode1 as master system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 diff --git a/tests/script/general/alter/insert1.sim b/tests/script/general/alter/insert1.sim index 3b16214465c15133aecc3e2c5977996cbaa22b5f..12ab09beb989dd963a9e8c9c3ff5926e78d8b0ac 100644 --- a/tests/script/general/alter/insert1.sim +++ b/tests/script/general/alter/insert1.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 @@ -940,9 +940,9 @@ endi print ======== step9 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql select * from tb order by ts asc if $rows != 8 then diff --git a/tests/script/general/alter/insert2.sim b/tests/script/general/alter/insert2.sim index 28948b69d231952f3baae0d79a75c1f2c9c6fb60..dcd9f500304f906ddddb33bd1a04c5943c232d49 100644 --- a/tests/script/general/alter/insert2.sim +++ b/tests/script/general/alter/insert2.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 @@ -608,9 +608,9 @@ sql_error alter table tb drop column a print ======== step9 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql select * from tb order by ts desc if $rows != 7 then diff --git a/tests/script/general/alter/metrics.sim b/tests/script/general/alter/metrics.sim index 5ed8050b96b90d679fcb85ada06c6065b8f0735a..fd0b210cd1b452b2a35ebcd9f74aec98c3817b03 100644 --- a/tests/script/general/alter/metrics.sim +++ b/tests/script/general/alter/metrics.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 @@ -367,9 +367,9 @@ endi print ======== step9 print ======== step10 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql use d2 sql describe tb diff --git a/tests/script/general/alter/table.sim b/tests/script/general/alter/table.sim index 5a72fc925619e1a0ab40289056f6af355b995ca9..06704eeca6b3149b47ddc2ffb90aaab9df934bd8 100644 --- a/tests/script/general/alter/table.sim +++ b/tests/script/general/alter/table.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 @@ -318,9 +318,9 @@ endi print ======== step9 print ======== step10 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql use d1 sql describe tb diff --git a/tests/script/general/cache/new_metrics.sim b/tests/script/general/cache/new_metrics.sim index 84f9e40de39b6946984204f4e3cb6f7e395af0e2..a13dd23bb64c490f52fed7abe946ec7dfec90adb 100644 --- a/tests/script/general/cache/new_metrics.sim +++ b/tests/script/general/cache/new_metrics.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/cache/restart_metrics.sim b/tests/script/general/cache/restart_metrics.sim index f24768859fe8b771b9c03e0ea328d0066174909d..f5035e1251c11c7c4010160cfac967d9b2617c21 100644 --- a/tests/script/general/cache/restart_metrics.sim +++ b/tests/script/general/cache/restart_metrics.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start @@ -49,7 +49,7 @@ endi print =============== step2 system sh/exec.sh -n dnode1 -s stop -sleep 5000 +sleep 3000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start diff --git a/tests/script/general/cache/restart_table.sim b/tests/script/general/cache/restart_table.sim index 8697c26bc3d7708a4eca1c3480d6cdb248c072dc..fcdb2fb593bac7d3eb13b82c7abfe268eafe36dc 100644 --- a/tests/script/general/cache/restart_table.sim +++ b/tests/script/general/cache/restart_table.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start @@ -33,14 +33,14 @@ endi print =============== step2 system sh/exec.sh -n dnode1 -s stop -sleep 5000 +sleep 3000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start print =============== step3 print ==> sleep 8 seconds to renew cache -sleep 3000 +sleep 2000 sql reset query cache sleep 18000 diff --git a/tests/script/general/column/commit.sim b/tests/script/general/column/commit.sim index c574db1aa9dd28139251b4aa0433200e5fde230a..e1b98d38147fa4d5721f4e38915f68370378998d 100644 --- a/tests/script/general/column/commit.sim +++ b/tests/script/general/column/commit.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step1 @@ -89,9 +89,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 print =============== step5 diff --git a/tests/script/general/column/metrics.sim b/tests/script/general/column/metrics.sim index 673b66c9e266a68171161c88d3e2dfadd9d446da..a46ab6560ae4d76c74408639ad6055eb093cb143 100644 --- a/tests/script/general/column/metrics.sim +++ b/tests/script/general/column/metrics.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step1 @@ -157,9 +157,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 print =============== step5 diff --git a/tests/script/general/column/table.sim b/tests/script/general/column/table.sim index aec0dc3c75031f9c4e167ffae5511ff34e4ec886..7c9302aa083fd03d6b53190ff38927a5f115d688 100644 --- a/tests/script/general/column/table.sim +++ b/tests/script/general/column/table.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step1 @@ -129,9 +129,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 print ============== step5 diff --git a/tests/script/general/compress/commitlog.sim b/tests/script/general/compress/commitlog.sim index b5d653fe83e94045c6f5f7ce7f58104504ad5330..e8eab6ed0cd9b5b6c2ea70042bd0f24e92c512a6 100644 --- a/tests/script/general/compress/commitlog.sim +++ b/tests/script/general/compress/commitlog.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c comp -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start @@ -87,9 +87,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 print =============== step5 diff --git a/tests/script/general/compress/compress.sim b/tests/script/general/compress/compress.sim index 6975f879968107bd142a3595869fc120bc1daa02..0df2a0d4cba3c6fb2b28ac8506e498c650c988b7 100644 --- a/tests/script/general/compress/compress.sim +++ b/tests/script/general/compress/compress.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c comp -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start @@ -82,9 +82,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 print =============== step5 diff --git a/tests/script/general/compress/compress2.sim b/tests/script/general/compress/compress2.sim index cf96f572ace4a693b1c5640986510d2f5a4d9d74..007d1ec3394d0cc141bc8ece6ee3968407eb4c20 100644 --- a/tests/script/general/compress/compress2.sim +++ b/tests/script/general/compress/compress2.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c comp -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start @@ -82,9 +82,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 print =============== step5 diff --git a/tests/script/general/compress/uncompress.sim b/tests/script/general/compress/uncompress.sim index 13d288451c8031154f2c62fe4e5f8670fad8517a..9c71c8c1cc642557f929022f0d46a33399e10abf 100644 --- a/tests/script/general/compress/uncompress.sim +++ b/tests/script/general/compress/uncompress.sim @@ -4,7 +4,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c comp -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start @@ -81,9 +81,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 -system sh/exec.sh -n dnode1 -s start sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 2000 print =============== step5 diff --git a/tests/script/general/compute/avg.sim b/tests/script/general/compute/avg.sim index 52a270bc6d9b1581fb210693f74cce9ecc73b3fa..027cfbe61deb28dc1767d8a571a0def3c300b628 100644 --- a/tests/script/general/compute/avg.sim +++ b/tests/script/general/compute/avg.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_av_db diff --git a/tests/script/general/compute/bottom.sim b/tests/script/general/compute/bottom.sim index 415bd36e2e0417e8f9da2989e21f1a1908e01cfd..5c76d5d171139cdebe8796fffe390e48809c4cb9 100644 --- a/tests/script/general/compute/bottom.sim +++ b/tests/script/general/compute/bottom.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_bo_db diff --git a/tests/script/general/compute/count.sim b/tests/script/general/compute/count.sim index d8aeb18752a3fee18471a3402d259142486ecc1a..fc481088a5774ea318f62a22d11dc5b375f53b7e 100644 --- a/tests/script/general/compute/count.sim +++ b/tests/script/general/compute/count.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_co_db diff --git a/tests/script/general/compute/diff.sim b/tests/script/general/compute/diff.sim index 88c2ecb09df9128499cef1426a53d5b922512164..433a9356096c4fba8f7049db25c201ae55748e42 100644 --- a/tests/script/general/compute/diff.sim +++ b/tests/script/general/compute/diff.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_di_db diff --git a/tests/script/general/compute/diff2.sim b/tests/script/general/compute/diff2.sim index 14675c823f04693c76fcb151169b6dba738b8aaf..7406771ac6769ffd077eab73f682c1d82a5d3d40 100644 --- a/tests/script/general/compute/diff2.sim +++ b/tests/script/general/compute/diff2.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_di_db diff --git a/tests/script/general/compute/first.sim b/tests/script/general/compute/first.sim index 01b82cce62adbc13420289878ea01ed63776bbce..f12ed2b73a78aba273804452a9121a193baa686c 100644 --- a/tests/script/general/compute/first.sim +++ b/tests/script/general/compute/first.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_fi_db diff --git a/tests/script/general/compute/interval.sim b/tests/script/general/compute/interval.sim index 8f9bf2ecb3013afe2bc11d5c851d8effbcf37686..79f34752223f93ac9a3d6446a934a54a16c60f08 100644 --- a/tests/script/general/compute/interval.sim +++ b/tests/script/general/compute/interval.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_in_db diff --git a/tests/script/general/compute/last.sim b/tests/script/general/compute/last.sim index 88a6a268463ef005dd4c611e2b127c3a0d8f3bf0..7b7c45044f1164bbb1510ae898c8a1ee26421b62 100644 --- a/tests/script/general/compute/last.sim +++ b/tests/script/general/compute/last.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_la_db diff --git a/tests/script/general/compute/last_row.sim b/tests/script/general/compute/last_row.sim index 55d97fe53c75b8df34caed98f4bd57bc05a9711f..03fa9bc4af66d8585b3f2052f01092eb5ee7562e 100644 --- a/tests/script/general/compute/last_row.sim +++ b/tests/script/general/compute/last_row.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_la_db diff --git a/tests/script/general/compute/leastsquare.sim b/tests/script/general/compute/leastsquare.sim index 5a28e74bffeed53e3c7202a2dc5d3bf2551ed94b..20e2cc9d1757fafa25a950a44c0813c70f21aedc 100644 --- a/tests/script/general/compute/leastsquare.sim +++ b/tests/script/general/compute/leastsquare.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_le_db diff --git a/tests/script/general/compute/max.sim b/tests/script/general/compute/max.sim index 1029ba78cc595b70048f887c55a2393cb2b46e10..ba87416292458ffdc3e1c9e37723f08b2d57a03b 100644 --- a/tests/script/general/compute/max.sim +++ b/tests/script/general/compute/max.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_ma_db diff --git a/tests/script/general/compute/min.sim b/tests/script/general/compute/min.sim index d6a57f4f20d01a4ab1fc95ec902785363d1f004b..e981f8335f1242ea5258647298d18e56b3dcc164 100644 --- a/tests/script/general/compute/min.sim +++ b/tests/script/general/compute/min.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_mi_db diff --git a/tests/script/general/compute/null.sim b/tests/script/general/compute/null.sim index 47f7a3c1b96152e5a30b4712831146187b98abc7..de2a834684e0a555a9a5ea694f074b59a8a21af1 100644 --- a/tests/script/general/compute/null.sim +++ b/tests/script/general/compute/null.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = db diff --git a/tests/script/general/compute/percentile.sim b/tests/script/general/compute/percentile.sim index 0fb88e7a40224404c2889696d6e8ba34655d18ee..9798aa2f5c6e1c1a2271c255fbd6cce81b4dc4e6 100644 --- a/tests/script/general/compute/percentile.sim +++ b/tests/script/general/compute/percentile.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_pe_db diff --git a/tests/script/general/compute/stddev.sim b/tests/script/general/compute/stddev.sim index abe4025e961460803e33c63c7243a1112a1bfab5..2f6ffb097a91854a714a6c9b24ace8d43726c913 100644 --- a/tests/script/general/compute/stddev.sim +++ b/tests/script/general/compute/stddev.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_st_db diff --git a/tests/script/general/compute/sum.sim b/tests/script/general/compute/sum.sim index 9d42e766b61e4c137b7f738dcb8b27d1f5061413..230248a37093e7e163eba6fe9fc5ca63d386d298 100644 --- a/tests/script/general/compute/sum.sim +++ b/tests/script/general/compute/sum.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_su_db diff --git a/tests/script/general/compute/top.sim b/tests/script/general/compute/top.sim index e6bcd4a5cb0cfb928d8e322b80aa10d801fe76e5..a4f482b12759f9586a4660f0622b463b7a46b9da 100644 --- a/tests/script/general/compute/top.sim +++ b/tests/script/general/compute/top.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_to_db diff --git a/tests/script/general/connection/connection.sim b/tests/script/general/connection/connection.sim index abebbacbd94f0a3fc88083f980da77f7b7df8b9b..1af6e1fda6989c8a9c6eed36e579f8325eee0ac6 100644 --- a/tests/script/general/connection/connection.sim +++ b/tests/script/general/connection/connection.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 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============= step1 diff --git a/tests/script/general/connection/mqtt.sim b/tests/script/general/connection/mqtt.sim index 4b291f91ea5089018207b11b2016b234dcc2a883..c2c50ef17e1264d6f27f64417f1500bc83346012 100644 --- a/tests/script/general/connection/mqtt.sim +++ b/tests/script/general/connection/mqtt.sim @@ -10,7 +10,7 @@ system sh/cfg.sh -n dnode1 -c mqtt -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database mqttdb; sql create table mqttdb.devices(ts timestamp, value double) tags(name binary(32), model binary(32), serial binary(16), param binary(16), unit binary(16)); diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim index 1c3f543ffdb149d67cfaf1527a0e88f46f626913..9d4dedfce0e081345d8659abdcdebf3cce2efb74 100644 --- a/tests/script/general/db/alter_option.sim +++ b/tests/script/general/db/alter_option.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============= create database @@ -78,23 +78,10 @@ if $data5_db != 1 then return -1 endi -sql alter database db quorum 2 -sql show databases -print quorum $data5_db -if $data5_db != 2 then - return -1 -endi +sql_error alter database db quorum 2 -sql alter database db quorum 3 -sql show databases -print quorum $data5_db -if $data5_db != 3 then - return -1 -endi +sql_error alter database db quorum 3 -sql alter database db quorum 3 -sql alter database db quorum 2 -sql alter database db quorum 1 sql_error alter database db quorum 0 sql_error alter database db quorum 4 sql_error alter database db quorum 5 diff --git a/tests/script/general/db/alter_tables_d2.sim b/tests/script/general/db/alter_tables_d2.sim index cd3121057b2c8d02755e89c40e11ca7b9d52b4ce..f74f98d571e49090e2c25d2371a0e0c268c9a3ee 100644 --- a/tests/script/general/db/alter_tables_d2.sim +++ b/tests/script/general/db/alter_tables_d2.sim @@ -264,10 +264,10 @@ endi print ============================ step7 system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 sql reset query cache sleep 1000 diff --git a/tests/script/general/db/alter_tables_v4.sim b/tests/script/general/db/alter_tables_v4.sim index b57b2c03208274949a901cf72c2d580133ca1ecd..10bb4e108bf7fc6c879e230565dad29599f15549 100644 --- a/tests/script/general/db/alter_tables_v4.sim +++ b/tests/script/general/db/alter_tables_v4.sim @@ -232,9 +232,9 @@ endi print ============================ step7 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql reset query cache sleep 1000 diff --git a/tests/script/general/db/alter_vgroups.sim b/tests/script/general/db/alter_vgroups.sim index 13928cf03301f1528db3a1fd9e5951b3115a6125..81ffc7d443ce6b21978d338bfeb01f00f89a17b1 100644 --- a/tests/script/general/db/alter_vgroups.sim +++ b/tests/script/general/db/alter_vgroups.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ step1 @@ -70,9 +70,9 @@ endi print ============================ step3 system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 2 -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql create table db.t100 using db.st tags(0) sql create table db.t101 using db.st tags(1) @@ -132,9 +132,9 @@ print ============================ step5 system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3 -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql create table db.t200 using db.st tags(0) sql create table db.t201 using db.st tags(1) diff --git a/tests/script/general/db/backup/keep.sim b/tests/script/general/db/backup/keep.sim index 29771fc97815c6781cfa3e44fbbfa81760859633..943022deba516fc2dbbc64bdf984659da0233cff 100644 --- a/tests/script/general/db/backup/keep.sim +++ b/tests/script/general/db/backup/keep.sim @@ -23,7 +23,7 @@ sql connect print ========= start other dnodes sql create dnode $hostname2 system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 print ======== step1 create db sql create database keepdb replica 1 keep 30 days 7 @@ -50,9 +50,9 @@ endi print ======== step2 stop dnode system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 sql select * from tb print ===> rows $rows @@ -112,9 +112,9 @@ endi print ======== step5 stop dnode system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 sql select * from tb print ===> rows $rows @@ -153,9 +153,9 @@ endi print ======== step7 stop dnode system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 sql select * from tb print ===> rows $rows diff --git a/tests/script/general/db/basic.sim b/tests/script/general/db/basic.sim index 1c4939256be82541f40e34d5c89ea4c1f67de288..684ce825fecb64ef580751a8df104fd4e1c7cf24 100644 --- a/tests/script/general/db/basic.sim +++ b/tests/script/general/db/basic.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/db/basic1.sim b/tests/script/general/db/basic1.sim index 302c5ac40992271e9ef757cb9704beb377a75d16..9ec1aabe98ba21af5927faec2e26aef1c3a14aeb 100644 --- a/tests/script/general/db/basic1.sim +++ b/tests/script/general/db/basic1.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== create database diff --git a/tests/script/general/db/basic2.sim b/tests/script/general/db/basic2.sim index afe5ee5d95402fac985b9c5673fb43e35a285f22..acd035bd744eb53b856c32beaf69445eb24e8315 100644 --- a/tests/script/general/db/basic2.sim +++ b/tests/script/general/db/basic2.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== create database d1 diff --git a/tests/script/general/db/basic3.sim b/tests/script/general/db/basic3.sim index 88f5bf64604d2f1f6bd11040de844e871808c566..fb64476696c7aba65d5f5f87c68857ed32ff24fc 100644 --- a/tests/script/general/db/basic3.sim +++ b/tests/script/general/db/basic3.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== create database d1 diff --git a/tests/script/general/db/basic4.sim b/tests/script/general/db/basic4.sim index a0a9aaa627fd643b2863b14a4cacb93f092104b0..ce6d352d12412c95d0883ca246e2603b36617bb8 100644 --- a/tests/script/general/db/basic4.sim +++ b/tests/script/general/db/basic4.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== create database d1 diff --git a/tests/script/general/db/basic5.sim b/tests/script/general/db/basic5.sim index 82b9bf9bf4dadf2c0215626d8905a64cc0962fe3..08c9db23323ba7d4257671d6f0a71c3dd133ad03 100644 --- a/tests/script/general/db/basic5.sim +++ b/tests/script/general/db/basic5.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== create database d1 diff --git a/tests/script/general/db/delete.sim b/tests/script/general/db/delete.sim index e4d40bf5da267985066f61383c6614dee78aaff1..4384044885e7c6a660079551b1190481ace3554e 100644 --- a/tests/script/general/db/delete.sim +++ b/tests/script/general/db/delete.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 print ========= start dnodes system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 @@ -44,7 +44,7 @@ endi print ======= step3 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start $x = 0 diff --git a/tests/script/general/db/delete_reuse1.sim b/tests/script/general/db/delete_reuse1.sim index feeb0152c1d8dc707a327f89ebf95e242b35294b..b18bb285d1c002b6607a0a6574798baf6a59bb3d 100644 --- a/tests/script/general/db/delete_reuse1.sim +++ b/tests/script/general/db/delete_reuse1.sim @@ -22,7 +22,7 @@ system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 print ========= start dnodes system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 diff --git a/tests/script/general/db/delete_reuse2.sim b/tests/script/general/db/delete_reuse2.sim index 9053e8af011674162174a718c52d157b1e70984a..c82457ec42921cccf90d3351a09de41d8bf7197c 100644 --- a/tests/script/general/db/delete_reuse2.sim +++ b/tests/script/general/db/delete_reuse2.sim @@ -21,9 +21,9 @@ system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 print ========= start dnodes -sleep 2000 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 + sql connect sql reset query cache @@ -65,7 +65,7 @@ endi print ======== step2 sql drop database d1 -sleep 1000 +sleep 500 sql insert into d1.t1 values(now, 2) -x step2 return -1 step2: @@ -73,7 +73,7 @@ step2: print ========= step3 sql create database db1 replica 1 sql reset query cache -sleep 1000 +sleep 500 sql create table db1.tb1 (ts timestamp, i int) sql insert into db1.tb1 values(now, 2) sql select * from db1.tb1 @@ -90,7 +90,7 @@ while $x < 20 sql use $db sql drop database $db - sleep 1000 + sleep 500 sql insert into $tb values(now, -1) -x step4 return -1 step4: @@ -100,7 +100,7 @@ while $x < 20 $tb = tb . $x sql reset query cache - sleep 1000 + sleep 500 sql create database $db replica 1 sql use $db diff --git a/tests/script/general/db/delete_reusevnode2.sim b/tests/script/general/db/delete_reusevnode2.sim index 0db2440b3bcd92a9fa252f387be22767ae1f7d7c..c05db6b65a43df2cec9cb410aef69ac23985307e 100644 --- a/tests/script/general/db/delete_reusevnode2.sim +++ b/tests/script/general/db/delete_reusevnode2.sim @@ -4,7 +4,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 print ========= start dnodes system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 diff --git a/tests/script/general/db/delete_writing1.sim b/tests/script/general/db/delete_writing1.sim index 8b369b4e3d0fc918aad19d2295583a0e2c1fda59..98e9a3d66f54bc40ac87feb3271403bace0319e8 100644 --- a/tests/script/general/db/delete_writing1.sim +++ b/tests/script/general/db/delete_writing1.sim @@ -43,7 +43,7 @@ while $x < 20 sql create database db sql create table db.tb (ts timestamp, i int) - sleep 3000 + sleep 2000 $x = $x + 1 endw diff --git a/tests/script/general/db/delete_writing2.sim b/tests/script/general/db/delete_writing2.sim index 3ea220cb8ce9ab2e30ab4c57652b3e35add56452..2d1b0c8d9cb4b4bfc8774436accf6b8ff90843da 100644 --- a/tests/script/general/db/delete_writing2.sim +++ b/tests/script/general/db/delete_writing2.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c wallevel -v 0 print ========= start dnodes system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database db @@ -39,7 +39,7 @@ while $x < 10 sql create database db sql create table db.tb (ts timestamp, i int) - sleep 3000 + sleep 2000 $x = $x + 1 endw diff --git a/tests/script/general/db/dropdnodes.sim b/tests/script/general/db/dropdnodes.sim index c7bbdf73a4b6b6e1f236c7cc920a43def08bd013..8a46d5f9ce405cb84957900c37986cbede044464 100644 --- a/tests/script/general/db/dropdnodes.sim +++ b/tests/script/general/db/dropdnodes.sim @@ -11,7 +11,7 @@ print ========== prepare data system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 sql connect sql create dnode $hostname2 @@ -72,7 +72,7 @@ endi print ========== step3 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 sql drop dnode $hostname2 sleep 2000 diff --git a/tests/script/general/db/len.sim b/tests/script/general/db/len.sim index 30abcbe10010cd4a6bca8285c9d526133e9ea1f3..561245e666920bbe8b32d3fa3c7999f02f2553f7 100644 --- a/tests/script/general/db/len.sim +++ b/tests/script/general/db/len.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step1 diff --git a/tests/script/general/db/nosuchfile.sim b/tests/script/general/db/nosuchfile.sim index 98ac4ec012dc694357878a61ca0dbc11259f0a9e..69db8c0dc53ff39fff9840b3c86deef85e6d6dfa 100644 --- a/tests/script/general/db/nosuchfile.sim +++ b/tests/script/general/db/nosuchfile.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c wallevel -v 2 print ========== step1 system sh/exec.sh -n dnode1 -s start sql connect -sleep 3000 +sleep 2000 print ========== step3 sql create database d1 @@ -20,7 +20,7 @@ sql insert into d1.t1 values(now+5s, 31) print ========== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 print ========== step5 sql select * from d1.t1 order by t desc diff --git a/tests/script/general/db/repeat.sim b/tests/script/general/db/repeat.sim index aaa103234d1e3206adce7511e4ac5e105b2dc6c4..b3bbca2d19012e49c3c4210dbbb3b94256cfe278 100644 --- a/tests/script/general/db/repeat.sim +++ b/tests/script/general/db/repeat.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start @@ -21,13 +21,13 @@ sql create table d3.t1(ts timestamp, i int) sql create database d4 sql create table d4.t1(ts timestamp, i int) -sleep 3000 +sleep 2000 sql drop database d1 sql drop database d2 sql drop database d3 sql drop database d4 -sleep 3000 +sleep 2000 sql create database d5 sql create table d5.t1(ts timestamp, i int) @@ -41,14 +41,14 @@ sql create table d7.t1(ts timestamp, i int) sql create database d8 sql create table d8.t1(ts timestamp, i int) -sleep 3000 +sleep 2000 sql drop database d5 sql drop database d6 sql drop database d7 sql drop database d8 -sleep 3000 +sleep 2000 sql create database d9; sql create table d9.t1(ts timestamp, i int) diff --git a/tests/script/general/db/show_create_db.sim b/tests/script/general/db/show_create_db.sim index baa7b253e12154c5d320dd6d8411e223ce1cd4e2..edaa971c5cac45d1cb95e48acf84c9c6058901c1 100644 --- a/tests/script/general/db/show_create_db.sim +++ b/tests/script/general/db/show_create_db.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step2 diff --git a/tests/script/general/db/show_create_table.sim b/tests/script/general/db/show_create_table.sim index 83386387093a7c4f778bb5696eea6019fd4691fa..0d7408748a48a41e06dbd1a892aa03595f221383 100644 --- a/tests/script/general/db/show_create_table.sim +++ b/tests/script/general/db/show_create_table.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ===============create three type table diff --git a/tests/script/general/db/tables.sim b/tests/script/general/db/tables.sim index d700bf80689a8d0413b59e13382fdf213ee9c4ec..50b6805ecad44a74a7c421301c7bc6bdc625f21d 100644 --- a/tests/script/general/db/tables.sim +++ b/tests/script/general/db/tables.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 4 system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step2 diff --git a/tests/script/general/db/vnodes.sim b/tests/script/general/db/vnodes.sim index b01e94206fa33978b359b6c40576284f69b74d87..b123e91ad120e26aad4648794397d2e06b627f8e 100644 --- a/tests/script/general/db/vnodes.sim +++ b/tests/script/general/db/vnodes.sim @@ -15,7 +15,7 @@ system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 100000 print ========== prepare data system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database db blocks 3 cache 1 sql use db diff --git a/tests/script/general/field/2.sim b/tests/script/general/field/2.sim index 28506b7cb82456ce424be5052a1f41269dcd56a3..812301dfbda072e302b8db029c6ee4a514683198 100644 --- a/tests/script/general/field/2.sim +++ b/tests/script/general/field/2.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/3.sim b/tests/script/general/field/3.sim index 453f4968bfe1be218886bf958aaab44a287ba914..a531caaca0471887edf1e573f69cd5fa9839facf 100644 --- a/tests/script/general/field/3.sim +++ b/tests/script/general/field/3.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/4.sim b/tests/script/general/field/4.sim index 243424724fa8a487f8b8ea5394014c5913b097de..c530ff62d1f1a892550a7d755dc35a58c0a9b302 100644 --- a/tests/script/general/field/4.sim +++ b/tests/script/general/field/4.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/5.sim b/tests/script/general/field/5.sim index ca1543b54bf83ee40b077e2542e43e7e5c8e4c03..a676281313abd59e933513b9687d88f91a83ff5d 100644 --- a/tests/script/general/field/5.sim +++ b/tests/script/general/field/5.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/6.sim b/tests/script/general/field/6.sim index 23223e5c1502105b5df13f9d9cad5ad12b08944c..f187d7db108a3b8c787479acf8a1511bbede1125 100644 --- a/tests/script/general/field/6.sim +++ b/tests/script/general/field/6.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/bigint.sim b/tests/script/general/field/bigint.sim index 10060f7422f50ccbb36b118d9dbfbc7729059e3f..c9bda687e19e28adec072bd593b5305eb8e4c2de 100644 --- a/tests/script/general/field/bigint.sim +++ b/tests/script/general/field/bigint.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/binary.sim b/tests/script/general/field/binary.sim index b51f023efe0bb768f90fc2f9e682363d208d0410..36a43272ca094a85c2d95b51495ecaa33fa32c18 100644 --- a/tests/script/general/field/binary.sim +++ b/tests/script/general/field/binary.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/bool.sim b/tests/script/general/field/bool.sim index 4528f79bc79ddb9fb6c2eeeb54c13384eec7df99..d8e613572ace057fd0750e2ea584779a338954c5 100644 --- a/tests/script/general/field/bool.sim +++ b/tests/script/general/field/bool.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/double.sim b/tests/script/general/field/double.sim index 40650cb9bdbc3908892a6e6ee1958fa62c90d6bb..f7dac3192afaf8083df902e6447bcfdbb3e89e5a 100644 --- a/tests/script/general/field/double.sim +++ b/tests/script/general/field/double.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/float.sim b/tests/script/general/field/float.sim index 0ead9fb48a424e5d2c5d2ff3b69a6ecc21fbf540..3ab5602c55f8e5a12c9c978583c7b08891d91757 100644 --- a/tests/script/general/field/float.sim +++ b/tests/script/general/field/float.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/int.sim b/tests/script/general/field/int.sim index a095dc2176ad75c0123c7dcc9a1e0a5a1c75d75f..5c3cec99cfab308559b6450c7c6e7f0487207d10 100644 --- a/tests/script/general/field/int.sim +++ b/tests/script/general/field/int.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/single.sim b/tests/script/general/field/single.sim index 8540608e96aacfe50dc346a0bf4217f8c38db7b7..d572f6df2af770f43f0d72b6a9053bfcc5898561 100644 --- a/tests/script/general/field/single.sim +++ b/tests/script/general/field/single.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/smallint.sim b/tests/script/general/field/smallint.sim index 578de4ea442b87bea61f24db8c24b71efe0e2621..8bd99723217db4800645ef0ca1dffa72b2d8ec95 100644 --- a/tests/script/general/field/smallint.sim +++ b/tests/script/general/field/smallint.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/field/tinyint.sim b/tests/script/general/field/tinyint.sim index f132b427025d4c706cdcf09b4ede678e36fbaaf8..3a2d7bc44e55432f48a318f1a59bf31bea556986 100644 --- a/tests/script/general/field/tinyint.sim +++ b/tests/script/general/field/tinyint.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/http/autocreate.sim b/tests/script/general/http/autocreate.sim index 98d64ab839df11d17bd6d9036a53fcc087b69ea8..39af990b50d18fbcb6e7972d2adb67a1eb9900e3 100644 --- a/tests/script/general/http/autocreate.sim +++ b/tests/script/general/http/autocreate.sim @@ -1,12 +1,12 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/http/chunked.sim b/tests/script/general/http/chunked.sim index 6592c761c6ccaea94f385ac72982115c775f01d7..c5855e5d2953ca36d95cd84a5590c47ef693d406 100644 --- a/tests/script/general/http/chunked.sim +++ b/tests/script/general/http/chunked.sim @@ -1,12 +1,12 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c maxSQLLength -v 340032 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/http/grafana.sim b/tests/script/general/http/grafana.sim index c7866e5f4ce950292f17a1b4d0f8a49838fc18a1..128994640de39c03514a69ba1c5629e90f25468b 100644 --- a/tests/script/general/http/grafana.sim +++ b/tests/script/general/http/grafana.sim @@ -1,5 +1,5 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start @@ -94,7 +94,7 @@ if $system_content != @{"status":"error","code":4387,"desc":"invalid format of A return -1 endi -sleep 3000 +sleep 2000 system_content curl 127.0.0.1:7111/grafana/login/root/taosdata print 8-> $system_content if $system_content != @{"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}@ then diff --git a/tests/script/general/http/grafana_bug.sim b/tests/script/general/http/grafana_bug.sim index 43c52ba75ff72f8567eebaec741f3edee3206d85..ce039af44c22975b164db15852e836175252ed8f 100644 --- a/tests/script/general/http/grafana_bug.sim +++ b/tests/script/general/http/grafana_bug.sim @@ -1,5 +1,5 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 @@ -8,7 +8,7 @@ system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 system sh/exec.sh -n dnode1 -s start sql connect -sleep 3000 +sleep 2000 print ============================ dnode1 start diff --git a/tests/script/general/http/gzip.sim b/tests/script/general/http/gzip.sim index 9c77567abb9874459a2363a93cb62cb57cf02b1a..ce358d84a177b79f8333c2bb4ce370b79b4e0eca 100644 --- a/tests/script/general/http/gzip.sim +++ b/tests/script/general/http/gzip.sim @@ -1,12 +1,12 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c maxSQLLength -v 340032 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/http/prepare.sim b/tests/script/general/http/prepare.sim index 0bcb42ad41baa48544e0febba6ccf693f3efb85b..6803643caf7d0b97822c18582597db90f74c5001 100644 --- a/tests/script/general/http/prepare.sim +++ b/tests/script/general/http/prepare.sim @@ -1,11 +1,11 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/http/restful.sim b/tests/script/general/http/restful.sim index 7d1169ca27eac99e740aba3fb8c1f6483791a85b..a06e899d93986d1b9aa3781fc867909b69b92d86 100644 --- a/tests/script/general/http/restful.sim +++ b/tests/script/general/http/restful.sim @@ -1,12 +1,12 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim index 7e12d30ac91eb49025fbebed05336e15cc6900ac..69f820634759433bb3c5ec59978ac0845376c6d9 100644 --- a/tests/script/general/http/restful_full.sim +++ b/tests/script/general/http/restful_full.sim @@ -1,11 +1,11 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/exec.sh -n dnode1 -s start -#sleep 3000 +#sleep 2000 sql connect print ============================ dnode1 start @@ -15,6 +15,7 @@ print =============== step1 - login system_content curl 127.0.0.1:7111/rest/ print 1-> $system_content if $system_content != @{"status":"error","code":4357,"desc":"no auth info input"}@ then + print $system_content return -1 endi @@ -68,7 +69,7 @@ if $system_content != @{"status":"error","code":4387,"desc":"invalid format of A return -1 endi -sleep 3000 +sleep 2000 system_content curl 127.0.0.1:7111/rest/login/root/taosdata/ print 10-> $system_content diff --git a/tests/script/general/http/restful_insert.sim b/tests/script/general/http/restful_insert.sim index f230f98723e041487232c5725b91c4755fe56fcf..90bf7e1b1568f02f3f897bedbbba889be649a169 100644 --- a/tests/script/general/http/restful_insert.sim +++ b/tests/script/general/http/restful_insert.sim @@ -1,12 +1,12 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/http/restful_limit.sim b/tests/script/general/http/restful_limit.sim index 7d2b6e9a02fce66a3961177c635929302a92387d..c925656b3612e9a52cffc5f53a5a3fb7290ab2e5 100644 --- a/tests/script/general/http/restful_limit.sim +++ b/tests/script/general/http/restful_limit.sim @@ -1,10 +1,10 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/http/telegraf.sim b/tests/script/general/http/telegraf.sim index 4018d9661a0a1d7b445fc9eff416bd40f84d2116..6825e5c479774f2a8eca5df42d55910e12a975fd 100644 --- a/tests/script/general/http/telegraf.sim +++ b/tests/script/general/http/telegraf.sim @@ -1,5 +1,5 @@ system sh/stop_dnodes.sh -sleep 3000 +sleep 2000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c http -v 1 @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c httpEnableRecordSql -v 1 system sh/cfg.sh -n dnode1 -c telegrafUseFieldNum -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start @@ -245,7 +245,7 @@ if $system_content != @{"metrics":[{"metric":"win_cpu","stable":"win_cpu","table return -1 endi -sleep 3000 +sleep 2000 print =============== step2 - insert single data system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1564641722000}' 127.0.0.1:7111/telegraf/db/ diff --git a/tests/script/general/import/basic.sim b/tests/script/general/import/basic.sim index 07febb2bd52155af1cec70f84a1fe60460815750..50c4059c52c65cf353f5987d44be78cc7649733d 100644 --- a/tests/script/general/import/basic.sim +++ b/tests/script/general/import/basic.sim @@ -26,7 +26,7 @@ system sh/cfg.sh -n dnode4 -c walLevel -v 0 print ========= start dnode1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database ibadb diff --git a/tests/script/general/import/commit.sim b/tests/script/general/import/commit.sim index 36d201e9effaa8398f5087c95b8e03f5893a7846..0aa63b14ff4af7c4c410dd2363b9ad8c98da39a9 100644 --- a/tests/script/general/import/commit.sim +++ b/tests/script/general/import/commit.sim @@ -26,7 +26,7 @@ system sh/cfg.sh -n dnode4 -c walLevel -v 0 print ========= start dnode1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ========= step1 @@ -72,9 +72,9 @@ endi print ========= step3 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 print ========= step4 sql select * from ic2db.tb; diff --git a/tests/script/general/import/large.sim b/tests/script/general/import/large.sim index 5bf05a57fbdb3bf3c8bb123215686ccd5bdd4a8e..3b82c0355aa17266bbd9addbfe13ca0d7235cb8d 100644 --- a/tests/script/general/import/large.sim +++ b/tests/script/general/import/large.sim @@ -26,7 +26,7 @@ system sh/cfg.sh -n dnode4 -c walLevel -v 0 print ========= start dnode1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database db diff --git a/tests/script/general/import/replica1.sim b/tests/script/general/import/replica1.sim index d450b3fb49883df2d83b2969d951b981c30b65af..48d5455b7931bfc167112574c8193097aad74334 100644 --- a/tests/script/general/import/replica1.sim +++ b/tests/script/general/import/replica1.sim @@ -27,7 +27,7 @@ system sh/cfg.sh -n dnode4 -c walLevel -v 2 print ========= start dnode1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database ir1db days 7 @@ -93,9 +93,9 @@ endi print ================== dnode restart system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql use ir1db sql select * from tb; @@ -162,9 +162,9 @@ endi print ================= step10 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql use ir1db sql select * from tb; diff --git a/tests/script/general/insert/basic.sim b/tests/script/general/insert/basic.sim index 3f0f25a95ba68c8099c02e6daab933411089a632..c688342fc5cf3c3b77cdfcd45270bc1ccb685f0f 100644 --- a/tests/script/general/insert/basic.sim +++ b/tests/script/general/insert/basic.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/insert/insert_drop.sim b/tests/script/general/insert/insert_drop.sim index 9b68e5a6a6c7e77fc0e591e4950500369a88a650..859263762620b193873e4a355b061f12359c4f2a 100644 --- a/tests/script/general/insert/insert_drop.sim +++ b/tests/script/general/insert/insert_drop.sim @@ -4,7 +4,7 @@ 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 3000 +sleep 2000 sql connect $tbNum = 10 @@ -43,7 +43,7 @@ print ====== tables created print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed @@ -69,7 +69,7 @@ endw print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/insert/query_block1_file.sim b/tests/script/general/insert/query_block1_file.sim index 6d6daca7b59dbd1a5fa5f1981aab6ca78691474a..63f46d84f15d813acb1c1166331ab61ba15734a2 100644 --- a/tests/script/general/insert/query_block1_file.sim +++ b/tests/script/general/insert/query_block1_file.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/insert/query_block1_memory.sim b/tests/script/general/insert/query_block1_memory.sim index bec9190f9b93044d4321b96d6604209cbc78daba..516085f93f8c297b305ef5908010e898673f3a1d 100644 --- a/tests/script/general/insert/query_block1_memory.sim +++ b/tests/script/general/insert/query_block1_memory.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/insert/query_block2_file.sim b/tests/script/general/insert/query_block2_file.sim index 34da170a9ee6cf3af09de374d8c1da54966a6382..a1fa920c0f389300b621cdaf953a330830282128 100644 --- a/tests/script/general/insert/query_block2_file.sim +++ b/tests/script/general/insert/query_block2_file.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/insert/query_block2_memory.sim b/tests/script/general/insert/query_block2_memory.sim index 3f2c97a098c35847ae566f6d9fdba0fa85a674d4..9ce0b942d43cb34ad0a8f2e537144283438f3a12 100644 --- a/tests/script/general/insert/query_block2_memory.sim +++ b/tests/script/general/insert/query_block2_memory.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/insert/query_file_memory.sim b/tests/script/general/insert/query_file_memory.sim index f923ebed13c2f9c592b38dc98ace644fcd8fb671..d43328a65a521654c9d2ae871c76436d8a1251c2 100644 --- a/tests/script/general/insert/query_file_memory.sim +++ b/tests/script/general/insert/query_file_memory.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/insert/query_multi_file.sim b/tests/script/general/insert/query_multi_file.sim index 8622fa6f9b47ff2b82305fdfff8d187d7b95c275..3b70dd621484f68bf34ed520e366930e67bd8f26 100644 --- a/tests/script/general/insert/query_multi_file.sim +++ b/tests/script/general/insert/query_multi_file.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/insert/tcp.sim b/tests/script/general/insert/tcp.sim index 6f9752087d9d5d099703dd851b55305d65726784..50383efb498a40df5f37542415971eebce615c5c 100644 --- a/tests/script/general/insert/tcp.sim +++ b/tests/script/general/insert/tcp.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database d1; diff --git a/tests/script/general/parser/alter.sim b/tests/script/general/parser/alter.sim index eae9b88be95ed91b1e0889c8640909a6bc70f592..56a677cc73f35d7656daef6fd3062bbc453007ef 100644 --- a/tests/script/general/parser/alter.sim +++ b/tests/script/general/parser/alter.sim @@ -133,7 +133,7 @@ sleep 100 # return -1 #endi #sql alter table tb1 drop column c3 -#sleep 3000 +#sleep 2000 #sql insert into tb1 values (now, 2, 'taos') #sleep 30000 #sql select * from strm @@ -144,7 +144,7 @@ sleep 100 # return -1 #endi #sql alter table tb1 add column c3 int -#sleep 3000 +#sleep 2000 #sql insert into tb1 values (now, 3, 'taos', 3); #sleep 100 #sql select * from strm diff --git a/tests/script/general/parser/auto_create_tb.sim b/tests/script/general/parser/auto_create_tb.sim index 903f8f988113aded636e04512029ce67cce55e73..e19eb0c667d5e667e3a044c9045c0584ec41d4e2 100644 --- a/tests/script/general/parser/auto_create_tb.sim +++ b/tests/script/general/parser/auto_create_tb.sim @@ -208,7 +208,7 @@ endi print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect diff --git a/tests/script/general/parser/col_arithmetic_operation.sim b/tests/script/general/parser/col_arithmetic_operation.sim index ae6ecb88e24a7ec10105b752b21e0714f74dcc42..9fd690a44426f81b89939de864c556cf452bf383 100644 --- a/tests/script/general/parser/col_arithmetic_operation.sim +++ b/tests/script/general/parser/col_arithmetic_operation.sim @@ -105,7 +105,7 @@ run general/parser/col_arithmetic_query.sim #======================================= all in files query ======================================= print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/parser/commit.sim b/tests/script/general/parser/commit.sim index 67d98de2076e7db20c95d9fd626b4a7e79c1b17f..533fbf48f068d166ff0d7de440117694c4d48a97 100644 --- a/tests/script/general/parser/commit.sim +++ b/tests/script/general/parser/commit.sim @@ -82,7 +82,7 @@ endw print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start sleep 100 print ================== server restart completed diff --git a/tests/script/general/parser/first_last.sim b/tests/script/general/parser/first_last.sim index a16b5b1e077f3fe3ffced5a6809bf7ca10423606..9c1f0774badf5edf44cc616f085eb06c8a47c120 100644 --- a/tests/script/general/parser/first_last.sim +++ b/tests/script/general/parser/first_last.sim @@ -77,7 +77,7 @@ run general/parser/first_last_query.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim index 7d702e989e6f816832adbd92507efbef68fdb088..c4d9d910e4b5f52efdc92a2c678b1b6ba13d5cfc 100644 --- a/tests/script/general/parser/function.sim +++ b/tests/script/general/parser/function.sim @@ -382,4 +382,29 @@ sql drop table cars; sql create table cars(ts timestamp, c int) tags(id int); sql create table car1 using cars tags(1); sql create table car2 using cars tags(2); -sql insert into car1 (ts, c) values (now,1) car2(ts, c) values(now, 2); \ No newline at end of file +sql insert into car1 (ts, c) values (now,1) car2(ts, c) values(now, 2); + +print ========================> TD-2700 +sql create table tx(ts timestamp, k int); +sql insert into tx values(1500000001000, 0); +sql select sum(k) from tx interval(1d) sliding(1h); +if $rows != 24 then + print expect 24, actual:$rows + return -1 +endi + +print ========================> TD-2740 +sql drop table if exists m1; +sql create table m1(ts timestamp, k int) tags(a int); +sql create table tm10 using m1 tags(0); +sql create table tm11 using m1 tags(1); +sql create table tm12 using m1 tags(2); +sql create table tm13 using m1 tags(3); +sql insert into tm10 values('2020-1-1 1:1:1', 0); +sql insert into tm11 values('2020-1-5 1:1:1', 0); +sql insert into tm12 values('2020-1-7 1:1:1', 0); +sql insert into tm13 values('2020-1-1 1:1:1', 0); +sql select count(*) from m1 where ts='2020-1-1 1:1:1' interval(1h) group by tbname; +if $rows != 2 then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/parser/import_commit1.sim b/tests/script/general/parser/import_commit1.sim index eb49be947c71727a1367026420728cbd94fca7d4..27be5560c5812d3856929d0da7b53a23fda6210c 100644 --- a/tests/script/general/parser/import_commit1.sim +++ b/tests/script/general/parser/import_commit1.sim @@ -40,7 +40,7 @@ while $x < $rowNum endw print ====== tables created -sleep 3000 +sleep 2000 $ts = $ts0 + $delta $ts = $ts + 1 diff --git a/tests/script/general/parser/import_commit2.sim b/tests/script/general/parser/import_commit2.sim index 7222a5412be6b62d90f88878179e8e49f39fa661..72ee2b3844f09af2dc3c15ba6426c9fd51ad832f 100644 --- a/tests/script/general/parser/import_commit2.sim +++ b/tests/script/general/parser/import_commit2.sim @@ -39,7 +39,7 @@ while $x < $rowNum endw print ====== tables created -sleep 3000 +sleep 2000 $ts = $ts0 + $delta $ts = $ts + 1 diff --git a/tests/script/general/parser/import_commit3.sim b/tests/script/general/parser/import_commit3.sim index ea9980930a2ea6c626c04b8bfaa5b3d5eb863a0a..a9f021b20c42c03535fda4df28fbe1eb3c246a11 100644 --- a/tests/script/general/parser/import_commit3.sim +++ b/tests/script/general/parser/import_commit3.sim @@ -39,7 +39,7 @@ while $x < $rowNum endw print ====== tables created -sleep 3000 +sleep 2000 $ts = $ts + 1 sql insert into $tb values ( $ts , -1, -1, -1, -1, -1) @@ -47,7 +47,7 @@ $ts = $ts0 + $delta $ts = $ts + 1 sql import into $tb values ( $ts , -2, -2, -2, -2, -2) -sleep 3000 +sleep 2000 sql show databases diff --git a/tests/script/general/parser/interp.sim b/tests/script/general/parser/interp.sim index 4078fc1ead096a34e3bbc4c6b276a6a16f0a21a7..36a643c424b9db0bf81f9ab0c7f5d4f093e2183e 100644 --- a/tests/script/general/parser/interp.sim +++ b/tests/script/general/parser/interp.sim @@ -59,7 +59,7 @@ run general/parser/interp_test.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/parser/interp_test.sim b/tests/script/general/parser/interp_test.sim index 819e5741d3966c81b52c0f2626d7004ad911981c..28601808306334286d2a9691626a2b1c1d211b30 100644 --- a/tests/script/general/parser/interp_test.sim +++ b/tests/script/general/parser/interp_test.sim @@ -638,209 +638,293 @@ if $data24 != NULL then return -1 endi - ## interp(*) from stb + group by + fill(prev) - $t = $ts0 + 1000 - sql select interp(*) from $stb where ts = $t fill(prev) group by tbname - print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 - print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 - if $rows != $tbNum then - return -1 - endi - if $data00 != @18-09-17 09:00:01.000@ then - return -1 - endi - if $data01 != 0 then - return -1 - endi - if $data02 != 0 then - return -1 - endi - if $data03 != 0.00000 then - return -1 - endi - if $data04 != 0.000000000 then - return -1 - endi - if $data05 != 0 then - return -1 - endi - if $data06 != 0 then - return -1 - endi - if $data07 != 1 then - return -1 - endi - if $data08 != binary0 then - return -1 - endi - if $data09 != nchar0 then - return -1 - endi - if $data20 != @18-09-17 09:00:01.000@ then - return -1 - endi - if $data21 != 0 then - return -1 - endi - if $data22 != NULL then - return -1 - endi - if $data23 != 0.00000 then - return -1 - endi - if $data24 != NULL then - return -1 - endi - if $data25 != 0 then - return -1 - endi - if $data26 != 0 then - return -1 - endi - if $data27 != 1 then - return -1 - endi - if $data28 != binary0 then - return -1 - endi - if $data29 != nchar0 then - return -1 - endi +## interp(*) from stb + group by + fill(prev) +$t = $ts0 + 1000 +sql select interp(*) from $stb where ts = $t fill(prev) group by tbname +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != binary0 then + return -1 +endi +if $data09 != nchar0 then + return -1 +endi +if $data20 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data23 != 0.00000 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != 0 then + return -1 +endi +if $data26 != 0 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != binary0 then + return -1 +endi +if $data29 != nchar0 then + return -1 +endi - ## interp(*) from stb + group by + fill(linear) - $t = $ts0 + 1000 - sql select interp(*) from $stb where ts = $t fill(linear) group by tbname - print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 - print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 - if $rows != $tbNum then - return -1 - endi - if $data00 != @18-09-17 09:00:01.000@ then - return -1 - endi - if $data01 != 0 then - return -1 - endi - if $data02 != 0 then - return -1 - endi - if $data03 != 0.00167 then - return -1 - endi - if $data04 != 0.001666667 then - return -1 - endi - if $data05 != 0 then - return -1 - endi - if $data06 != 0 then - return -1 - endi - if $data07 != NULL then - return -1 - endi - if $data08 != NULL then - return -1 - endi - if $data09 != NULL then - return -1 - endi - if $data20 != @18-09-17 09:00:01.000@ then - return -1 - endi - if $data21 != 0 then - return -1 - endi - if $data22 != NULL then - return -1 - endi - if $data23 != 0.00167 then - return -1 - endi - if $data24 != NULL then - return -1 - endi - if $data25 != 0 then - return -1 - endi - if $data26 != 0 then - return -1 - endi - if $data27 != NULL then - return -1 - endi - if $data28 != NULL then - return -1 - endi - if $data29 != NULL then - return -1 - endi +## interp(*) from stb + group by + fill(linear) +$t = $ts0 + 1000 +sql select interp(*) from $stb where ts = $t fill(linear) group by tbname +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data03 != 0.00167 then + return -1 +endi +if $data04 != 0.001666667 then + return -1 +endi +if $data05 != 0 then + return -1 +endi +if $data06 != 0 then + return -1 +endi +if $data07 != NULL then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data09 != NULL then + return -1 +endi +if $data20 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data23 != 0.00167 then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data25 != 0 then + return -1 +endi +if $data26 != 0 then + return -1 +endi +if $data27 != NULL then + return -1 +endi +if $data28 != NULL then + return -1 +endi +if $data29 != NULL then + return -1 +endi - ## interp(*) from stb + group by + fill(value) - $t = $ts0 + 1000 - sql select interp(*) from $stb where ts = $t fill(value, -1, -2) group by tbname - print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 - print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 - if $rows != $tbNum then - return -1 - endi - if $data00 != @18-09-17 09:00:01.000@ then - return -1 - endi - if $data01 != -2 then - return -1 - endi - if $data02 != -2 then - return -1 - endi - if $data03 != -2.00000 then - return -1 - endi - if $data04 != -2.000000000 then - return -1 - endi - if $data05 != -2 then - return -1 - endi - if $data06 != -2 then - return -1 - endi - if $data07 != 1 then - return -1 - endi - if $data08 != NULL then - return -1 - endi - if $data09 != NULL then - return -1 - endi - if $data20 != @18-09-17 09:00:01.000@ then - return -1 - endi - if $data21 != -2 then - return -1 - endi - if $data22 != -2 then - return -1 - endi - if $data23 != -2.00000 then - return -1 - endi - if $data24 != -2.000000000 then - return -1 - endi - if $data25 != -2 then - return -1 - endi - if $data26 != -2 then - return -1 - endi - if $data27 != 1 then - return -1 - endi - if $data28 != NULL then - return -1 - endi - if $data29 != NULL then - return -1 - endi + ## interp(*) from stb + group by + fill(value) +$t = $ts0 + 1000 +sql select interp(*) from $stb where ts = $t fill(value, -1, -2) group by tbname +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +print ====== 0:$data20, 1:$data21, 2:$data22, 3:$data23, 4:$data24, 5:$data25, 6:$data26, 7:$data27, 8:$data28, 9:$data29 +if $rows != $tbNum then + return -1 +endi +if $data00 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data01 != -2 then + return -1 +endi +if $data02 != -2 then + return -1 +endi +if $data03 != -2.00000 then + return -1 +endi +if $data04 != -2.000000000 then + return -1 +endi +if $data05 != -2 then + return -1 +endi +if $data06 != -2 then + return -1 +endi +if $data07 != 1 then + return -1 +endi +if $data08 != NULL then + return -1 +endi +if $data09 != NULL then + return -1 +endi +if $data20 != @18-09-17 09:00:01.000@ then + return -1 +endi +if $data21 != -2 then + return -1 +endi +if $data22 != -2 then + return -1 +endi +if $data23 != -2.00000 then + return -1 +endi +if $data24 != -2.000000000 then + return -1 +endi +if $data25 != -2 then + return -1 +endi +if $data26 != -2 then + return -1 +endi +if $data27 != 1 then + return -1 +endi +if $data28 != NULL then + return -1 +endi +if $data29 != NULL then + return -1 +endi + +sql_error select interp(ts,c1) from intp_tb0 where ts>'2018-11-25 19:19:00' and ts<'2018-11-25 19:19:12'; +sql select interp(ts,c1) from intp_tb0 where ts>'2018-11-25 19:19:00' and ts<'2018-11-25 19:19:12' interval(1s) fill(linear); +if $rows != 0 then + return -1 +endi + +sql select interp(c1) from intp_tb0 where ts>'2018-11-25 18:09:00' and ts<'2018-11-25 19:20:12' interval(18m); +if $rows != 1 then + return -1 +endi + +if $data00 != @18-11-25 18:30:00.000@ then + return -1 +endi + +if $data01 != 3 then + return -1 +endi + +sql select interp(c1,c3,c4,ts) from intp_tb0 where ts>'2018-11-25 18:09:00' and ts<'2018-11-25 19:20:12' interval(18m) fill(linear) +if $rows != 5 then + return -1 +endi + +if $data00 != @18-11-25 17:54:00.000@ then + return -1 +endi + +if $data01 != 0 then + return -1 +endi + +if $data02 != 0.00000 then + return -1 +endi + +if $data03 != 0.000000000 then + return -1 +endi + +if $data04 != @18-11-25 17:54:00.000@ then + return -1 +endi + +if $data10 != @18-11-25 18:12:00.000@ then + return -1 +endi + +if $data11 != 1 then + return -1 +endi + +if $data12 != 1.20000 then + return -1 +endi + +if $data13 != 1.200000000 then + return -1 +endi + +if $data14 != @18-11-25 18:12:00.000@ then + return -1 +endi + +if $data40 != @18-11-25 19:06:00.000@ then + return -1 +endi + +if $data41 != 6 then + return -1 +endi + +if $data42 != 6.60000 then + return -1 +endi + +if $data43 != 6.600000000 then + return -1 +endi + +if $data44 != @18-11-25 19:06:00.000@ then + return -1 +endi \ No newline at end of file diff --git a/tests/script/general/parser/join.sim b/tests/script/general/parser/join.sim index d18a3d76760bb61f7ddd5d37f37b073ca40ffba6..56f115051cd4e558839d958a5177164b9fcf7a91 100644 --- a/tests/script/general/parser/join.sim +++ b/tests/script/general/parser/join.sim @@ -415,6 +415,7 @@ sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_m $val = 100 if $rows != $val then + print $rows return -1 endi @@ -514,4 +515,4 @@ sql drop table tm2; sql select count(*) from m1, m2 where m1.ts=m2.ts and m1.b=m2.a; sql drop database ux1; -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/lastrow.sim b/tests/script/general/parser/lastrow.sim index f997dc504fdecf997d316059257ec73d4047aaf0..682a6cd5dfe42fe0d0411416b76faba15ba88f2c 100644 --- a/tests/script/general/parser/lastrow.sim +++ b/tests/script/general/parser/lastrow.sim @@ -62,7 +62,7 @@ run general/parser/lastrow_query.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect diff --git a/tests/script/general/parser/limit.sim b/tests/script/general/parser/limit.sim index 682b449ca3c97a7ecff0d047b64361629dcfb858..22d52c4257f07481e1dcc02119989d277d9e018d 100644 --- a/tests/script/general/parser/limit.sim +++ b/tests/script/general/parser/limit.sim @@ -66,7 +66,7 @@ run general/parser/limit_stb.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect diff --git a/tests/script/general/parser/limit1.sim b/tests/script/general/parser/limit1.sim index c047dc28443bb06ca4efbe6c6bb1e366ec4b8e3b..0597723490f1c6af3ef6518dfa3b0d8aa005d3c4 100644 --- a/tests/script/general/parser/limit1.sim +++ b/tests/script/general/parser/limit1.sim @@ -61,7 +61,7 @@ run general/parser/limit1_stb.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/parser/limit1_tblocks100.sim b/tests/script/general/parser/limit1_tblocks100.sim index 039a171ad703998499e9492e3633741cee3fa6e5..43519d2df4ddee99ea5de3a797d5333b10f48f4a 100644 --- a/tests/script/general/parser/limit1_tblocks100.sim +++ b/tests/script/general/parser/limit1_tblocks100.sim @@ -61,7 +61,7 @@ run general/parser/limit1_stb.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/parser/limit2.sim b/tests/script/general/parser/limit2.sim index f9b46f5c3e187179ac25eb666696ee3caeb7aa3d..ddc5c10362a0743381e3f935a9d078c20be31858 100644 --- a/tests/script/general/parser/limit2.sim +++ b/tests/script/general/parser/limit2.sim @@ -69,7 +69,7 @@ print ====== tables created print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/parser/mixed_blocks.sim b/tests/script/general/parser/mixed_blocks.sim index 772dc1db59c0d8bdcaaf63e11495c9a7d4572929..79bf65d1475a8f73fb31df35bf5e8e5f31476fca 100644 --- a/tests/script/general/parser/mixed_blocks.sim +++ b/tests/script/general/parser/mixed_blocks.sim @@ -154,7 +154,7 @@ sql insert into t2 values('2020-1-1 1:5:1', 99); print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql select ts from m1 where ts='2020-1-1 1:5:1' diff --git a/tests/script/general/parser/projection_limit_offset.sim b/tests/script/general/parser/projection_limit_offset.sim index df5be140f6dc77a9ed961c1a4555b200e08ae5ab..e8a4c75a12f7ffcbe38cf2bd342dbace5e12cf02 100644 --- a/tests/script/general/parser/projection_limit_offset.sim +++ b/tests/script/general/parser/projection_limit_offset.sim @@ -409,7 +409,7 @@ sql_error select k, sum(k)+1 from tm0; print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/parser/selectResNum.sim b/tests/script/general/parser/selectResNum.sim index 071dd87bc975532ea0032cb54fff6aca1408ff8e..8f18a41d417ce8928dd2a991526641a17fc62d77 100644 --- a/tests/script/general/parser/selectResNum.sim +++ b/tests/script/general/parser/selectResNum.sim @@ -118,7 +118,7 @@ endw print ====== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ====== server restart completed sleep 100 diff --git a/tests/script/general/parser/select_from_cache_disk.sim b/tests/script/general/parser/select_from_cache_disk.sim index 5feae919059b72a877a789158055370887343659..36a749cc3c4aa46bc2d52dd2352905f68a213c87 100644 --- a/tests/script/general/parser/select_from_cache_disk.sim +++ b/tests/script/general/parser/select_from_cache_disk.sim @@ -35,7 +35,7 @@ sql insert into $tb values ('2018-09-17 09:00:00.030', 3) print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect diff --git a/tests/script/general/parser/single_row_in_tb.sim b/tests/script/general/parser/single_row_in_tb.sim index 6f1535c390ac18614e9da07d74e390ab39099303..651f44a3a4dac3437e3c95bd3d8b42b632c58abf 100644 --- a/tests/script/general/parser/single_row_in_tb.sim +++ b/tests/script/general/parser/single_row_in_tb.sim @@ -32,7 +32,7 @@ run general/parser/single_row_in_tb_query.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/parser/slimit.sim b/tests/script/general/parser/slimit.sim index 9aaf4a35caf32c67e2e1c04f5182074465ba11ad..426104c1680c777214c5514ecf8dc251540f75b6 100644 --- a/tests/script/general/parser/slimit.sim +++ b/tests/script/general/parser/slimit.sim @@ -97,7 +97,7 @@ run general/parser/slimit_query.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect diff --git a/tests/script/general/parser/slimit1.sim b/tests/script/general/parser/slimit1.sim index 2c8fa28d326aa97cb3e3e740961c381eda34e09d..85cbe51aad166973367c094ac531fe7e58776468 100644 --- a/tests/script/general/parser/slimit1.sim +++ b/tests/script/general/parser/slimit1.sim @@ -56,7 +56,7 @@ run general/parser/slimit1_query.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect diff --git a/tests/script/general/parser/slimit_alter_tags.sim b/tests/script/general/parser/slimit_alter_tags.sim index 3fe40dbe2e3f46a06da59753cfd8b40339771735..1073e0a3cc254dad66436896216411b026354040 100644 --- a/tests/script/general/parser/slimit_alter_tags.sim +++ b/tests/script/general/parser/slimit_alter_tags.sim @@ -171,7 +171,7 @@ endi print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect diff --git a/tests/script/general/parser/stableOp.sim b/tests/script/general/parser/stableOp.sim new file mode 100644 index 0000000000000000000000000000000000000000..133de95b9cf72a307ebc12dea3ac759a6193f893 --- /dev/null +++ b/tests/script/general/parser/stableOp.sim @@ -0,0 +1,97 @@ +system sh/stop_dnodes.sh + + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect +print ======================== dnode1 start + +$dbPrefix = fi_in_db +$tbPrefix = fi_in_tb +$stbPrefix = fi_in_stb +$mtPrefix = fi_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print create_tb test +print =============== set up +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i +$tb = $tbPrefix . $i +$stb = $stbPrefix . $i + +sql create database $db +sql use $db + +# case1: create stable test +print =========== stableOp.sim case1: create/alter/drop stable test +sql CREATE STABLE $stb (TS TIMESTAMP, COL1 INT) TAGS (ID INT); +sql show stables + +if $rows != 1 then + return -1 +endi +print data00 = $data00 +if $data00 != $stb then + return -1 +endi + +sql_error CREATE STABLE $tb using $stb tags (1); + +sql create table $tb using $stb tags (2); +sql show tables + +if $rows != 1 then + return -1 +endi + +sql alter stable $stb add column COL2 DOUBLE; + +sql insert into $tb values (now, 1, 2.0); + +sql select * from $tb ; + +if $rows != 1 then + return -1 +endi + +sql alter stable $stb drop column COL2; + +sql_error insert into $tb values (now, 1, 2.0); + +sql alter stable $stb add tag tag2 int; + +sql alter stable $stb change tag tag2 tag3; + +sql_error drop stable $tb + +sql drop table $tb ; + +sql show tables + +if $rows != 0 then + return -1 +endi + + +sql DROP STABLE $stb +sql show stables + +if $rows != 0 then + return -1 +endi + +print create/alter/drop stable test passed + +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/tbnameIn.sim b/tests/script/general/parser/tbnameIn.sim index e1d200e71688e8e633c97e6ada59848cd2b0ec44..65ed1ed65d50e96bee1b9185f1ecc5f2e18f376e 100644 --- a/tests/script/general/parser/tbnameIn.sim +++ b/tests/script/general/parser/tbnameIn.sim @@ -67,7 +67,7 @@ run general/parser/tbnameIn_query.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim index 90cccb80e52670ef3ad0ab8cea4503f27f6ac23f..1868ff9683870830aad822cef8020963fe2780c0 100644 --- a/tests/script/general/parser/testSuite.sim +++ b/tests/script/general/parser/testSuite.sim @@ -105,3 +105,5 @@ sleep 100 run general/parser/sliding.sim sleep 100 run general/parser/function.sim +sleep 100 +run general/parse/stableOp.sim diff --git a/tests/script/general/parser/topbot.sim b/tests/script/general/parser/topbot.sim index 6188f42ff51e87b19ced47ab2ae3cae792bb2ace..57378331e80489e9c3d3eaaaf321730e7e132f55 100644 --- a/tests/script/general/parser/topbot.sim +++ b/tests/script/general/parser/topbot.sim @@ -128,7 +128,7 @@ sql insert into test values(29999, 1)(70000, 2)(80000, 3) print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect diff --git a/tests/script/general/stable/disk.sim b/tests/script/general/stable/disk.sim index a67ef6d79097706f90c4a2eb229d5329d785e24c..35088c757c83c315b51881b4e1eaaf5f28e74529 100644 --- a/tests/script/general/stable/disk.sim +++ b/tests/script/general/stable/disk.sim @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start @@ -58,7 +58,7 @@ endi sleep 1000 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start sleep 6000 diff --git a/tests/script/general/stable/metrics.sim b/tests/script/general/stable/metrics.sim index b94c76429dcae6dbd39d80beab03b4a5bc8b401f..5bda2ad42e48362084a5d8d8559109fc7a879d92 100644 --- a/tests/script/general/stable/metrics.sim +++ b/tests/script/general/stable/metrics.sim @@ -4,7 +4,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_me_db diff --git a/tests/script/general/stable/refcount.sim b/tests/script/general/stable/refcount.sim index 5fe95dde9fdf8bd8820b067f0fc30d01b5e89f80..e609ccc0552978a9570be5635482d269d7115af7 100644 --- a/tests/script/general/stable/refcount.sim +++ b/tests/script/general/stable/refcount.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step1 diff --git a/tests/script/general/stable/show.sim b/tests/script/general/stable/show.sim index 66755edea73f30a3d3ecfc2dc090f0588dc21947..836a848ce0cfa715c6fd84a746009259f39692fb 100644 --- a/tests/script/general/stable/show.sim +++ b/tests/script/general/stable/show.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== create stable diff --git a/tests/script/general/stable/values.sim b/tests/script/general/stable/values.sim index 51488aabef8918b957ca63fd29823b14f772b675..5e5416e4e92928760f20b7509ed6d7eaad572216 100644 --- a/tests/script/general/stable/values.sim +++ b/tests/script/general/stable/values.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/stable/vnode3.sim b/tests/script/general/stable/vnode3.sim index 3409aef9f88bf652979d5b16c023417c4820168f..0889a8f0b7da653687264e727e144e96b661f834 100644 --- a/tests/script/general/stable/vnode3.sim +++ b/tests/script/general/stable/vnode3.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/stream/agg_stream.sim b/tests/script/general/stream/agg_stream.sim index 814438ac74531c565327bca6bb9615928bf289e1..65657fc33be88152040ce68c46d559e8b2c119a5 100644 --- a/tests/script/general/stream/agg_stream.sim +++ b/tests/script/general/stream/agg_stream.sim @@ -13,7 +13,7 @@ system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 30000 system sh/cfg.sh -n dnode1 -c maxShellConns -v 30000 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step2 diff --git a/tests/script/general/stream/column_stream.sim b/tests/script/general/stream/column_stream.sim index cb94904ff27903acb57b2202c790d25a9b1877ba..c43ca1fd5ac7cfc5e477c970b313414469e9a29c 100644 --- a/tests/script/general/stream/column_stream.sim +++ b/tests/script/general/stream/column_stream.sim @@ -9,7 +9,7 @@ system sh/cfg.sh -n dnode1 -c monitor -v 1 system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step1 @@ -121,7 +121,7 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start print sleep 22 seconds sleep 22000 diff --git a/tests/script/general/stream/metrics_del.sim b/tests/script/general/stream/metrics_del.sim index e21fa5999aa1b6ce0c063af54172f222aeb983e1..030f9fc527623c67619801202042c2a604cb8778 100644 --- a/tests/script/general/stream/metrics_del.sim +++ b/tests/script/general/stream/metrics_del.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/stream/metrics_replica1_vnoden.sim b/tests/script/general/stream/metrics_replica1_vnoden.sim index dcbc8ae7de4962c8970cdffec5829c74cdfb7351..d7541bac662081277fddcc4991539119e2814e2e 100644 --- a/tests/script/general/stream/metrics_replica1_vnoden.sim +++ b/tests/script/general/stream/metrics_replica1_vnoden.sim @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/stream/restart_stream.sim b/tests/script/general/stream/restart_stream.sim index b5a2038d9b207217f9a41250939b9853e2e822d1..ce06f24df72d81c5b4da45cde75ff7d8bbd507d0 100644 --- a/tests/script/general/stream/restart_stream.sim +++ b/tests/script/general/stream/restart_stream.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/stream/stream_3.sim b/tests/script/general/stream/stream_3.sim index 88105a77d667e9cad499ec55cad7f0d7f8fc0c3f..632fe78c7f4ffd71da58ebc7824ee3fb5031a7c0 100644 --- a/tests/script/general/stream/stream_3.sim +++ b/tests/script/general/stream/stream_3.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/stream/stream_restart.sim b/tests/script/general/stream/stream_restart.sim index 480b23055e90f59bd597d3319a5fe139eba83bab..dd7bdf1a914337101c94fd84f100f8bf0f0ca1a3 100644 --- a/tests/script/general/stream/stream_restart.sim +++ b/tests/script/general/stream/stream_restart.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/stream/table_del.sim b/tests/script/general/stream/table_del.sim index ce4065a1a85ba2c4f8f79b77d1d82c5118091e9c..7ddce53c4f222de6a8462373322716a82d200bc2 100644 --- a/tests/script/general/stream/table_del.sim +++ b/tests/script/general/stream/table_del.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/stream/table_replica1_vnoden.sim b/tests/script/general/stream/table_replica1_vnoden.sim index 13a4a56fb300e877c01bbe52e15aa8221d246cb5..3c30897d2b76ceee358e300b048e38306f112c00 100644 --- a/tests/script/general/stream/table_replica1_vnoden.sim +++ b/tests/script/general/stream/table_replica1_vnoden.sim @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/table/autocreate.sim b/tests/script/general/table/autocreate.sim index 8469a6484ac5aeb7e656ad63164ebfb0546af646..404c714ab4cfa85593d191fcd528f7b902e4cea9 100644 --- a/tests/script/general/table/autocreate.sim +++ b/tests/script/general/table/autocreate.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== create database diff --git a/tests/script/general/table/basic1.sim b/tests/script/general/table/basic1.sim index e8d0cd7bd8bd0b6f3dd7193b12a33c70bb46f95b..c26c3c33e4102723805925cccb61c63d01c866b8 100644 --- a/tests/script/general/table/basic1.sim +++ b/tests/script/general/table/basic1.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== create database diff --git a/tests/script/general/table/basic2.sim b/tests/script/general/table/basic2.sim index d1678e8abd984b3aaa5061feb9430550d8909feb..4286f9ee4a5fce5ae98956d8f2e4d143000cbdbf 100644 --- a/tests/script/general/table/basic2.sim +++ b/tests/script/general/table/basic2.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== one table diff --git a/tests/script/general/table/basic3.sim b/tests/script/general/table/basic3.sim index ded00e153a2be88ed8c9193d4c9051dacde1fc31..41c276ae984c73672c439f39ba7c54f94f375ef4 100644 --- a/tests/script/general/table/basic3.sim +++ b/tests/script/general/table/basic3.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== create database diff --git a/tests/script/general/table/bigint.sim b/tests/script/general/table/bigint.sim index dd61d25ef9f2c300a33ef8a30bcc17a1ab5d867d..0b2841f0f8f781cf42a27ea5db4e5ba28b59402a 100644 --- a/tests/script/general/table/bigint.sim +++ b/tests/script/general/table/bigint.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/binary.sim b/tests/script/general/table/binary.sim index cdbfcd4cbfe15438db884cd69b149c6e3519b6e6..fd2aa5ec44762a9de3c4d564ba75b7142da332c9 100644 --- a/tests/script/general/table/binary.sim +++ b/tests/script/general/table/binary.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/bool.sim b/tests/script/general/table/bool.sim index fbb6fe823cf30fc18302855aca9e847373cd1f6f..59297e90a9529856cf0996b4cbd7b2c0b2c5deb4 100644 --- a/tests/script/general/table/bool.sim +++ b/tests/script/general/table/bool.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/column2.sim b/tests/script/general/table/column2.sim index 9251e31daa633b45dae6ea7c6240d6c7a731f405..85d59fef49603400031358bd1b05cf653ab90324 100644 --- a/tests/script/general/table/column2.sim +++ b/tests/script/general/table/column2.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step1 diff --git a/tests/script/general/table/column_name.sim b/tests/script/general/table/column_name.sim index 0b09f65129d2204c4088e5aff55c08384988a2b5..480bcd06107a8f6617f8380f1e496b6c13435d5e 100644 --- a/tests/script/general/table/column_name.sim +++ b/tests/script/general/table/column_name.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/column_num.sim b/tests/script/general/table/column_num.sim index d1091528b249cc35f31ab623b29d4dc3148c9836..b055027f595b4aa0358bb68678ad0ac61750b439 100644 --- a/tests/script/general/table/column_num.sim +++ b/tests/script/general/table/column_num.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/column_value.sim b/tests/script/general/table/column_value.sim index 117c288b3602d3ca61fe83591c6943b79903e779..92ce02ade5dad14768aded9d0ab5737a71d472d0 100644 --- a/tests/script/general/table/column_value.sim +++ b/tests/script/general/table/column_value.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/createmulti.sim b/tests/script/general/table/createmulti.sim new file mode 100644 index 0000000000000000000000000000000000000000..0da1ce96a759551936eb00b00d6915b01682a64c --- /dev/null +++ b/tests/script/general/table/createmulti.sim @@ -0,0 +1,46 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 3000 +sql connect + +print =============== create database +sql create database db +sql show databases +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create super table +sql create table db.st1 (ts timestamp, i int) tags (j int) +sql create table db.st2 (ts timestamp, i int, j int) tags (t1 int, t2 int, t3 int) +sql show db.stables +if $rows != 2 then + return -1 +endi + +print $data00 $data01 $data02 + +print =============== create multiple child tables +sql create table db.ct1 using db.st1 tags(1) db.ct2 using db.st1 tags(2); + +sql show db.tables +if $rows != 2 then + return -1 +endi + +sql create table db.ct3 using db.st2 tags(1, 1, 1) db.ct4 using db.st2 tags(2, 2, 2); +sql show db.tables +if $rows != 4 then + return -1 +endi + +sql create table db.ct5 using db.st1 tags(3) db.ct6 using db.st2 tags(3, 3, 3); +sql show db.tables +if $rows != 6 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/table/date.sim b/tests/script/general/table/date.sim index 2e73a217a616859781f709cfa9c7117f6e34b9ae..7dea76dbc40473d1b97c31e07b73922c85a55108 100644 --- a/tests/script/general/table/date.sim +++ b/tests/script/general/table/date.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/db.table.sim b/tests/script/general/table/db.table.sim index 50224f83b554001cd725926986d4769d36a47cb7..717f5158c49fc98189ce1547d4c3bfdb5ed1fa51 100644 --- a/tests/script/general/table/db.table.sim +++ b/tests/script/general/table/db.table.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/delete_reuse1.sim b/tests/script/general/table/delete_reuse1.sim index 17974ccf4d3c2348c51b15e6382884d73fd73bf9..26c82e201b4b7ec0de59691516730d02a3f3693e 100644 --- a/tests/script/general/table/delete_reuse1.sim +++ b/tests/script/general/table/delete_reuse1.sim @@ -22,7 +22,7 @@ system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 print ========= start dnodes system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 diff --git a/tests/script/general/table/delete_reuse2.sim b/tests/script/general/table/delete_reuse2.sim index 917893b2d286208737693d10b8ec146455c8ed3c..2e3f01a3a23a3cb0243bb78e377602bb43a8390a 100644 --- a/tests/script/general/table/delete_reuse2.sim +++ b/tests/script/general/table/delete_reuse2.sim @@ -22,7 +22,7 @@ system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 print ========= start dnodes system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======== step1 diff --git a/tests/script/general/table/delete_writing.sim b/tests/script/general/table/delete_writing.sim index 2a7fb09104391c0bf7dd04ed94ca6e710c3d9bb2..342915f0e802a784a3a9e3ae144e6ce3b719d8ed 100644 --- a/tests/script/general/table/delete_writing.sim +++ b/tests/script/general/table/delete_writing.sim @@ -41,7 +41,7 @@ while $x < 15 sql create table db.tb (ts timestamp, i int) - sleep 3000 + sleep 2000 $x = $x + 1 endw diff --git a/tests/script/general/table/describe.sim b/tests/script/general/table/describe.sim index ebec004f1964119d97504f8bc78a0b42941824ab..ca5cf6f6e04925f861112063bfbab18524ecae37 100644 --- a/tests/script/general/table/describe.sim +++ b/tests/script/general/table/describe.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/double.sim b/tests/script/general/table/double.sim index 10239568fe488de55961e134a8e248cb83963393..c46029e39135cebc03a30668ec7cd784287a0fcc 100644 --- a/tests/script/general/table/double.sim +++ b/tests/script/general/table/double.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/fill.sim b/tests/script/general/table/fill.sim index 333573e577b636ef780e652d1dc61d4d6701f925..fd79e09ba16f2a43f6a16a79c45a0b6a072094ee 100644 --- a/tests/script/general/table/fill.sim +++ b/tests/script/general/table/fill.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =================== step1 @@ -42,9 +42,9 @@ sql select count(*), last(ts), min(k), max(k), avg(k) from db.mt where a=0 and t print =================== step2 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 -system sh/exec.sh -n dnode1 -s start sleep 3000 +system sh/exec.sh -n dnode1 -s start +sleep 2000 print =================== step3 sql select * from db.mt diff --git a/tests/script/general/table/float.sim b/tests/script/general/table/float.sim index e4ef8a42d67569aa75dda90236861ac11c951870..bbeb56e37099b60d7774e7a969dafd8123529843 100644 --- a/tests/script/general/table/float.sim +++ b/tests/script/general/table/float.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/int.sim b/tests/script/general/table/int.sim index 81bdcda47dd14c59df6017a07dde64da87b6546f..142c8b4f04fdf05f0c1310ed0f34f5b3dd842b95 100644 --- a/tests/script/general/table/int.sim +++ b/tests/script/general/table/int.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/limit.sim b/tests/script/general/table/limit.sim index 18597f2e1cd8ebed7747fed32067ed51664aebc8..45a20f680d0d4b8f15c2a20a9abce7d3c2075ba0 100644 --- a/tests/script/general/table/limit.sim +++ b/tests/script/general/table/limit.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 129 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 8 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/table/smallint.sim b/tests/script/general/table/smallint.sim index b6f0d6948faf9323085902cfc9b463238cb3f9ca..53dfbe15bfa5c54e575cc3f129cb6f4268050903 100644 --- a/tests/script/general/table/smallint.sim +++ b/tests/script/general/table/smallint.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/table.sim b/tests/script/general/table/table.sim index 6ad1b13b1cae6cd05b3b0bd3de4c648e4aab1fde..5d6f2ee1a3db7c54c5aa3d9254a8142f22296e64 100644 --- a/tests/script/general/table/table.sim +++ b/tests/script/general/table/table.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/table/table_len.sim b/tests/script/general/table/table_len.sim index 2568ebc7a5e460284f8a4d620beffadd73e76baf..f4c27926fb1815e1e60625cf888ff4c5c6aa3cfe 100644 --- a/tests/script/general/table/table_len.sim +++ b/tests/script/general/table/table_len.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/tinyint.sim b/tests/script/general/table/tinyint.sim index 017c007e8425385c6045d8c4ea1d3f7335e62a0d..5ad8a6933a51932b127b8a64ea4a3619b25fabe4 100644 --- a/tests/script/general/table/tinyint.sim +++ b/tests/script/general/table/tinyint.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/table/vgroup.sim b/tests/script/general/table/vgroup.sim index f4496e2f1988f86fc756dddc124224e84ed6fc06..f7806e316e68324c157b0ba4f34ba76e347da90d 100644 --- a/tests/script/general/table/vgroup.sim +++ b/tests/script/general/table/vgroup.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/general/tag/3.sim b/tests/script/general/tag/3.sim index 4b3104fe1bf591b69e4cc8837df9007ed2e815a5..878fdc04142fb54b22a9a023a85b71ce6300164f 100644 --- a/tests/script/general/tag/3.sim +++ b/tests/script/general/tag/3.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/4.sim b/tests/script/general/tag/4.sim index 120ef4e4e3ba4dd5446eff7143d2dd605374fa5d..d5ac6476d9ef8a02b41465e69405b16522e9a21c 100644 --- a/tests/script/general/tag/4.sim +++ b/tests/script/general/tag/4.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql reset query cache diff --git a/tests/script/general/tag/5.sim b/tests/script/general/tag/5.sim index efe88b36503c5161179602afea18fcf6ea1a106a..ae6d49e9f8b0502d2ef177e77a60c64ea07ef35b 100644 --- a/tests/script/general/tag/5.sim +++ b/tests/script/general/tag/5.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql reset query cache diff --git a/tests/script/general/tag/6.sim b/tests/script/general/tag/6.sim index d5f0a6c4af9b13420a07d4140a456f2b5112acd2..71957dad9f7fe920615c66fddd0e8565a31753f2 100644 --- a/tests/script/general/tag/6.sim +++ b/tests/script/general/tag/6.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql reset query cache diff --git a/tests/script/general/tag/add.sim b/tests/script/general/tag/add.sim index 301ec4f825c9954f9b5790c5e27e417538c3b4e2..4a3871235ecfbd1546cbab1ba4ab90de33ac7ed8 100644 --- a/tests/script/general/tag/add.sim +++ b/tests/script/general/tag/add.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/bigint.sim b/tests/script/general/tag/bigint.sim index 4fa22d3995617ec16d9ad85d5ef9a11bfe65ac06..c8e6e72825aeeb436c0e8918f437bfa42a424e3f 100644 --- a/tests/script/general/tag/bigint.sim +++ b/tests/script/general/tag/bigint.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/binary.sim b/tests/script/general/tag/binary.sim index 7c6f95b1ef785d5621d02e51e28fe96f7fe37f6c..771e7dc263a43c12db2ff3db362e7208c7469a91 100644 --- a/tests/script/general/tag/binary.sim +++ b/tests/script/general/tag/binary.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/binary_binary.sim b/tests/script/general/tag/binary_binary.sim index 077ec85b523d9fa20a90c1ec8f0e9309dd2b3ea2..5660b1b320f5a4bf95a3d39cc5dcee70db0f8885 100644 --- a/tests/script/general/tag/binary_binary.sim +++ b/tests/script/general/tag/binary_binary.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/bool.sim b/tests/script/general/tag/bool.sim index 349cb738bffbb216305af0718611987ae7f20f9c..828e89f3c7c9144ce444b974042079c173eb10a5 100644 --- a/tests/script/general/tag/bool.sim +++ b/tests/script/general/tag/bool.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/bool_binary.sim b/tests/script/general/tag/bool_binary.sim index a3f99e25ad8f62562cc70f3776e99397a815ae2f..fc25399c5a6e41e9c56ab93c37b6aca4af38baf1 100644 --- a/tests/script/general/tag/bool_binary.sim +++ b/tests/script/general/tag/bool_binary.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/bool_int.sim b/tests/script/general/tag/bool_int.sim index 1a2726dbaa684e2c39a37f1ef29827b480fc3617..aa443cca620ca9ba032e5df15f5e52d1ee014cab 100644 --- a/tests/script/general/tag/bool_int.sim +++ b/tests/script/general/tag/bool_int.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/change.sim b/tests/script/general/tag/change.sim index a7b8554bd96f6e8857d9b6a6b2de4faa4459bf2e..6f294c0f48fb18d232a5e78f9fbec084e8dc699d 100644 --- a/tests/script/general/tag/change.sim +++ b/tests/script/general/tag/change.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start @@ -175,7 +175,7 @@ sql alter table $mt change tag tgcol3 tgcol9 sql alter table $mt change tag tgcol5 tgcol10 sql alter table $mt change tag tgcol6 tgcol11 -sleep 5000 +sleep 3000 sql reset query cache print =============== step2 diff --git a/tests/script/general/tag/column.sim b/tests/script/general/tag/column.sim index 4a36e832f1bf6f373a81318e483ee02ee6bf2e01..36610d78da826f2f037a2202bd8321b78c6833bf 100644 --- a/tests/script/general/tag/column.sim +++ b/tests/script/general/tag/column.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/commit.sim b/tests/script/general/tag/commit.sim index 8b07d98afbaf343056ca94955e1b8977e1c46fe1..bcd9d7c618f68eb356813224a7b75f6e649a2e12 100644 --- a/tests/script/general/tag/commit.sim +++ b/tests/script/general/tag/commit.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start @@ -821,9 +821,9 @@ if $data07 != 12 then endi system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 print =============== step1 $i = 0 diff --git a/tests/script/general/tag/create.sim b/tests/script/general/tag/create.sim index adbb14e88aa28a1b5b1d1f7cd7bdab53c6d7c104..d387b4345fc890e8d63e35b3dfc31dfdc3121ae5 100644 --- a/tests/script/general/tag/create.sim +++ b/tests/script/general/tag/create.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/delete.sim b/tests/script/general/tag/delete.sim index f3d0735b5c2c158b1bbc9725755c7349a474178a..2a0aa27bde6ef70e5354695a83dfc2d3853e1463 100644 --- a/tests/script/general/tag/delete.sim +++ b/tests/script/general/tag/delete.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start @@ -409,7 +409,7 @@ sql alter table $mt drop tag tgcol3 sql alter table $mt drop tag tgcol4 sql alter table $mt drop tag tgcol6 -sleep 5000 +sleep 3000 print =============== step2 $i = 2 diff --git a/tests/script/general/tag/double.sim b/tests/script/general/tag/double.sim index 13dcb1fc72b7c760c325a09fe0589ce0a211e23a..514c35dc47c4cd4dfec51afafda6182981159044 100644 --- a/tests/script/general/tag/double.sim +++ b/tests/script/general/tag/double.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/filter.sim b/tests/script/general/tag/filter.sim index 75a6ed00da6d3b8173b748961d42ab8f909e7ef1..7a899a7e67d9261ea2a68c5ad1ee311f03278cb9 100644 --- a/tests/script/general/tag/filter.sim +++ b/tests/script/general/tag/filter.sim @@ -2,7 +2,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/float.sim b/tests/script/general/tag/float.sim index 2352bbaf2e8a2c5e27158332434d59be62e8d9d6..bfc7e0f569702423f97ac3b101ef354dd6ee5c6c 100644 --- a/tests/script/general/tag/float.sim +++ b/tests/script/general/tag/float.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/int.sim b/tests/script/general/tag/int.sim index a93df9a57afabdd59d22e1de44504db1bdbdaef4..2518aeb285b4a18a3842354979117fa9313a024d 100644 --- a/tests/script/general/tag/int.sim +++ b/tests/script/general/tag/int.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/int_binary.sim b/tests/script/general/tag/int_binary.sim index d3795006680a771190930b446c2390a5240dcb01..cb7aa16209f4b58f9e0d5c7323aad177a0f4467b 100644 --- a/tests/script/general/tag/int_binary.sim +++ b/tests/script/general/tag/int_binary.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/int_float.sim b/tests/script/general/tag/int_float.sim index 510c4f92d0810f6a675f0b0180081c0bf552584e..afd0a3644a4bc2de59050b2eccbec6cfe0a629d2 100644 --- a/tests/script/general/tag/int_float.sim +++ b/tests/script/general/tag/int_float.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/set.sim b/tests/script/general/tag/set.sim index 112695d37b0a924779812485e22ffb5680a8856e..cbc964fad7d73b9ba6fee5128e50bb4b9dfa433b 100644 --- a/tests/script/general/tag/set.sim +++ b/tests/script/general/tag/set.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/smallint.sim b/tests/script/general/tag/smallint.sim index 18b0957b1517560bca651ef9fbd4cc9325e94a22..598b397890003a3e5e07e1470e4e27ac4dbb1373 100644 --- a/tests/script/general/tag/smallint.sim +++ b/tests/script/general/tag/smallint.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/tag/tinyint.sim b/tests/script/general/tag/tinyint.sim index f104f8df04356487999bd4232db70b9ea067dd73..3c173a66bf57475516871fc03e337e5ce65989cd 100644 --- a/tests/script/general/tag/tinyint.sim +++ b/tests/script/general/tag/tinyint.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ======================== dnode1 start diff --git a/tests/script/general/user/authority.sim b/tests/script/general/user/authority.sim index 71f185043b3ef8fbe0fb09d53c9d4dae372d41fa..45230e3e8af59dcac57ff71a7802ba6a637cc8d7 100644 --- a/tests/script/general/user/authority.sim +++ b/tests/script/general/user/authority.sim @@ -2,7 +2,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -sleep 3000 +sleep 2000 print ============= step1 sql create user read pass 'taosdata' diff --git a/tests/script/general/user/monitor.sim b/tests/script/general/user/monitor.sim index eb543612f560fa43be7cb8a87ba36c3a344c1212..fe12df9baaf1f6ae3810e51d1fdc0020b67cbb40 100644 --- a/tests/script/general/user/monitor.sim +++ b/tests/script/general/user/monitor.sim @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c monitor -v 1 system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ========== step2 @@ -23,7 +23,7 @@ step23: print ========== step3 -sleep 3000 +sleep 2000 sql select * from log.dn if $rows == 0 then return -1 diff --git a/tests/script/general/user/pass_alter.sim b/tests/script/general/user/pass_alter.sim index 857d658db1ee7f1b91220106983ebb95c9b687d6..964e311ec0b17eb99d8cbfd745cc4510b9a94252 100644 --- a/tests/script/general/user/pass_alter.sim +++ b/tests/script/general/user/pass_alter.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 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============= step1 diff --git a/tests/script/general/user/pass_len.sim b/tests/script/general/user/pass_len.sim index d5d7b3250fe18490f92a299d100990f8b0405bca..5eb200b51f9ac28b19ea095be6530dbada9be894 100644 --- a/tests/script/general/user/pass_len.sim +++ b/tests/script/general/user/pass_len.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/user/user_len.sim b/tests/script/general/user/user_len.sim index 79b72468bbf64a5f834c34979391f43c25809c0c..55e5eb19ef476691882e7c9ba589697aef8190da 100644 --- a/tests/script/general/user/user_len.sim +++ b/tests/script/general/user/user_len.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/general/vector/metrics_field.sim b/tests/script/general/vector/metrics_field.sim index 2a03ccea19a46771a89755791c7b696f547d296c..84c1ed37e7ea9d924e53275962f8381cf32a615c 100644 --- a/tests/script/general/vector/metrics_field.sim +++ b/tests/script/general/vector/metrics_field.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_mf_db diff --git a/tests/script/general/vector/metrics_mix.sim b/tests/script/general/vector/metrics_mix.sim index 96b2f6a7a013d4bd323de7db9c39dfcf433421b2..2c7fc86f9f3ab2af95ffaad34d276dfe10a20844 100644 --- a/tests/script/general/vector/metrics_mix.sim +++ b/tests/script/general/vector/metrics_mix.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_mx_db diff --git a/tests/script/general/vector/metrics_query.sim b/tests/script/general/vector/metrics_query.sim index 824aa6f22e45153b295f2b42afe9ebcf45d00642..46afe7df20ff8b71346ad2b0834b3f0fac52602e 100644 --- a/tests/script/general/vector/metrics_query.sim +++ b/tests/script/general/vector/metrics_query.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_mq_db diff --git a/tests/script/general/vector/metrics_tag.sim b/tests/script/general/vector/metrics_tag.sim index e7575cc9df5e9c0c49af8ec21ed629c73cd7a0e6..be13ac764b7cac6e00753429a2f41b6025044fa0 100644 --- a/tests/script/general/vector/metrics_tag.sim +++ b/tests/script/general/vector/metrics_tag.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_mtg_db diff --git a/tests/script/general/vector/metrics_time.sim b/tests/script/general/vector/metrics_time.sim index bbcabfd1b7f81dc65f8c61f4c46d09bd18d1c35b..0b82153860ed7ea6312fbc1c74ef79acecc8dc70 100644 --- a/tests/script/general/vector/metrics_time.sim +++ b/tests/script/general/vector/metrics_time.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_mt_db diff --git a/tests/script/general/vector/multi.sim b/tests/script/general/vector/multi.sim index 105f210950960ac8dc75dd38e22af1fb8dd5b060..2ca9b7f48f046ea1ad659312983f2bf90d36bef4 100644 --- a/tests/script/general/vector/multi.sim +++ b/tests/script/general/vector/multi.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_mu_db diff --git a/tests/script/general/vector/single.sim b/tests/script/general/vector/single.sim index 2292d6f44ae43286d619a560320c31b3085ea267..eee5364a4fcea4de6fcf354982af29c480e5571f 100644 --- a/tests/script/general/vector/single.sim +++ b/tests/script/general/vector/single.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_si_db diff --git a/tests/script/general/vector/table_field.sim b/tests/script/general/vector/table_field.sim index a9d6910f4da4c1258d7a2efdf592352e7d043349..65c50dadc2acdbe1dd59f811dec458c3d8ff239d 100644 --- a/tests/script/general/vector/table_field.sim +++ b/tests/script/general/vector/table_field.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_tf_db diff --git a/tests/script/general/vector/table_mix.sim b/tests/script/general/vector/table_mix.sim index a6c4dc92da51d312c2a65561ecb8fcbf4737239a..12808fd6a617c6f75b1daac33ecfbff82eaa953d 100644 --- a/tests/script/general/vector/table_mix.sim +++ b/tests/script/general/vector/table_mix.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_tm_db diff --git a/tests/script/general/vector/table_query.sim b/tests/script/general/vector/table_query.sim index 812229afc4acaf7cb8515c3cbb483bad302b8ac0..3e9d2d0b772ffd2083333f7e764c3bfdf99e10ff 100644 --- a/tests/script/general/vector/table_query.sim +++ b/tests/script/general/vector/table_query.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_tq_db diff --git a/tests/script/general/vector/table_time.sim b/tests/script/general/vector/table_time.sim index a83195beba2fe0dec305098407ec872aa47e8535..552bdb2a99199119b6a4cd1605ef04d2fde39ea6 100644 --- a/tests/script/general/vector/table_time.sim +++ b/tests/script/general/vector/table_time.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $dbPrefix = m_tt_db diff --git a/tests/script/general/wal/kill.sim b/tests/script/general/wal/kill.sim index 7f103874a561c2bb2534996ab30d30ab0e8907a3..94a35b636e7915842787ed982590b39a93e1f408 100644 --- a/tests/script/general/wal/kill.sim +++ b/tests/script/general/wal/kill.sim @@ -13,62 +13,62 @@ sql create table t1 (ts timestamp, i int) sql insert into t1 values(now, 1); print =============== step3 -sleep 3000 +sleep 2000 sql select * from t1; print rows: $rows if $rows != 1 then return -1 endi system sh/exec.sh -n dnode1 -s stop -x SIGKILL -sleep 3000 +sleep 2000 print =============== step4 system sh/exec.sh -n dnode1 -s start -x SIGKILL -sleep 3000 +sleep 2000 sql select * from t1; print rows: $rows if $rows != 1 then return -1 endi system sh/exec.sh -n dnode1 -s stop -x SIGKILL -sleep 3000 +sleep 2000 print =============== step5 system sh/exec.sh -n dnode1 -s start -x SIGKILL -sleep 3000 +sleep 2000 sql select * from t1; print rows: $rows if $rows != 1 then return -1 endi system sh/exec.sh -n dnode1 -s stop -x SIGKILL -sleep 3000 +sleep 2000 print =============== step6 system sh/exec.sh -n dnode1 -s start -x SIGKILL -sleep 3000 +sleep 2000 sql select * from t1; print rows: $rows if $rows != 1 then return -1 endi system sh/exec.sh -n dnode1 -s stop -x SIGKILL -sleep 3000 +sleep 2000 print =============== step7 system sh/exec.sh -n dnode1 -s start -x SIGKILL -sleep 3000 +sleep 2000 sql select * from t1; print rows: $rows if $rows != 1 then return -1 endi system sh/exec.sh -n dnode1 -s stop -x SIGKILL -sleep 3000 +sleep 2000 print =============== step8 system sh/exec.sh -n dnode1 -s start -x SIGKILL -sleep 3000 +sleep 2000 sql select * from t1; print rows: $rows if $rows != 1 then diff --git a/tests/script/general/wal/maxtables.sim b/tests/script/general/wal/maxtables.sim index e504c7e92e3447f7d29dbb2dc03456c3775ced2c..acd6af1d1a1dbb02a3aef35fe2d9c07cae74b529 100644 --- a/tests/script/general/wal/maxtables.sim +++ b/tests/script/general/wal/maxtables.sim @@ -32,11 +32,11 @@ endi system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 -sleep 3000 +sleep 2000 print =============== step4 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql select * from st; if $rows != 100 then diff --git a/tests/script/jenkins/basic_2.txt b/tests/script/jenkins/basic_2.txt index 4f5651219bf3fc8d87e9f95c73963ed16a2f28fd..f35a0cd31dc33acc9aca77026ad33bc383162cd3 100644 --- a/tests/script/jenkins/basic_2.txt +++ b/tests/script/jenkins/basic_2.txt @@ -10,7 +10,7 @@ cd ../../../debug; make ./test.sh -f general/tag/binary_binary.sim ./test.sh -f general/tag/binary.sim ./test.sh -f general/tag/bool_binary.sim -./test.sh -f general/tag/bool_int.sim +#./test.sh -f general/tag/bool_int.sim ./test.sh -f general/tag/bool.sim ./test.sh -f general/tag/change.sim ./test.sh -f general/tag/column.sim @@ -99,6 +99,5 @@ cd ../../../debug; make ./test.sh -f unique/dnode/m2.sim ./test.sh -f unique/dnode/m3.sim ./test.sh -f unique/dnode/offline3.sim -./test.sh -f general/wal/sync.sim ./test.sh -f general/wal/kill.sim ./test.sh -f general/wal/maxtables.sim \ No newline at end of file diff --git a/tests/script/sh/mv_old_data.sh b/tests/script/sh/mv_old_data.sh index 112e9760d637d9698b87729c06ba7b2bde9651f8..606ee171f1e6b8605fd19d542e0b0dce5dfdda28 100755 --- a/tests/script/sh/mv_old_data.sh +++ b/tests/script/sh/mv_old_data.sh @@ -32,6 +32,9 @@ NODE_DIR=$SIM_DIR/$NODE_NAME rm -rf $SIM_DIR/dnode1 rm -rf $SIM_DIR/dnode2 rm -rf $SIM_DIR/dnode3 -rm -rf $SIM_DIR/tsim tar zxf $SCRIPT_DIR/general/connection/sim.tar.gz -C $SIM_DIR/../ +cd $SIM_DIR/../sim +fqdn=`hostname -f || hostname` +grep 'test4' -l -r ./* | xargs sed -i "s/test4/${fqdn}/g" +grep 'dataDir' -l -r ./* | xargs sed -i "s#/root/TDengine#${TAOS_DIR}#g" diff --git a/tests/script/tmp/mnodes.sim b/tests/script/tmp/mnodes.sim index 23f59d1d00c296d5fc9d3724ce428375a419938e..8bca76c38b627ac6a6aa9eaae07a9126a9b19057 100644 --- a/tests/script/tmp/mnodes.sim +++ b/tests/script/tmp/mnodes.sim @@ -107,7 +107,7 @@ if $data4_3 != ready then endi $x = $x + 1 -sleep 5000 +sleep 3000 if $x == 100000 then return -1 endi diff --git a/tests/script/unique/account/account_create.sim b/tests/script/unique/account/account_create.sim index 9eecceb39d106ab335b631bcfae370c2ae516490..e36de29e7c5835ddc78a9f3eab4b2b4d34634c42 100644 --- a/tests/script/unique/account/account_create.sim +++ b/tests/script/unique/account/account_create.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start diff --git a/tests/script/unique/account/account_delete.sim b/tests/script/unique/account/account_delete.sim index 564512228eda3aa156faba4818e3bc150b69de76..d99a8b559dc6e04e4d6996e042d915671781d699 100644 --- a/tests/script/unique/account/account_delete.sim +++ b/tests/script/unique/account/account_delete.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============= step1 diff --git a/tests/script/unique/account/account_len.sim b/tests/script/unique/account/account_len.sim index 75636be513af84ba00d9052d09193dcbf9ee2158..f8379bdf954bdde122e68585b973f4957ef15739 100644 --- a/tests/script/unique/account/account_len.sim +++ b/tests/script/unique/account/account_len.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/unique/account/authority.sim b/tests/script/unique/account/authority.sim index f88f254a79c83a95ff0e89a3e36eddb2856ad3a2..8f2408de1429a8ea34add79e335f6bf7f42ca2b0 100644 --- a/tests/script/unique/account/authority.sim +++ b/tests/script/unique/account/authority.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============= step1 diff --git a/tests/script/unique/account/basic.sim b/tests/script/unique/account/basic.sim index 0861c9305b836eb96c62acf11a8cad21ec6212a3..00e706a4482d9fa57ed2f97a9995ce84d3667fa1 100644 --- a/tests/script/unique/account/basic.sim +++ b/tests/script/unique/account/basic.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== show accounts diff --git a/tests/script/unique/account/paras.sim b/tests/script/unique/account/paras.sim index ae511fe2b065dd23d7b1dc19464a06b3e43e1fe0..102f5b6a381e5100b35a4f0125b1318bcb8b1d76 100644 --- a/tests/script/unique/account/paras.sim +++ b/tests/script/unique/account/paras.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== show accounts diff --git a/tests/script/unique/account/pass_alter.sim b/tests/script/unique/account/pass_alter.sim index bf939acce37cb2d878f1e31ca01e11429d8d4fcb..8b857b014a292d53536c5acf2a00daa15be11239 100644 --- a/tests/script/unique/account/pass_alter.sim +++ b/tests/script/unique/account/pass_alter.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============= step1 diff --git a/tests/script/unique/account/pass_len.sim b/tests/script/unique/account/pass_len.sim index 1dd0a616f291549cf3e431348fe028114f11836d..f4ceb76f7b8b41873217bd11ae2c3d385386b0e9 100644 --- a/tests/script/unique/account/pass_len.sim +++ b/tests/script/unique/account/pass_len.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/unique/account/usage.sim b/tests/script/unique/account/usage.sim index 7fde3652017f5b17e61a39891b1f55c5940e2061..3b9c20b159a6237f469fc1e48b5b3a3f4ca5f7b8 100644 --- a/tests/script/unique/account/usage.sim +++ b/tests/script/unique/account/usage.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start #system sh/exec.sh -n monitor -s 1 system sh/exec.sh -n monitorInterval -s 1 -sleep 3000 +sleep 2000 sql connect print =============== show accounts diff --git a/tests/script/unique/account/user_create.sim b/tests/script/unique/account/user_create.sim index 029bda22ea5a192634c911bba1df74a266402fea..e54a380f0dbef8107de452354ea01bc58262d548 100644 --- a/tests/script/unique/account/user_create.sim +++ b/tests/script/unique/account/user_create.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step1 diff --git a/tests/script/unique/account/user_len.sim b/tests/script/unique/account/user_len.sim index 91a5ebfaaba09196ff62196b23e60b59784ee1eb..b8d448f0ffc9e43cbc0f0a5a849bda215e72e790 100644 --- a/tests/script/unique/account/user_len.sim +++ b/tests/script/unique/account/user_len.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $i = 0 diff --git a/tests/script/unique/arbitrator/check_cluster_cfg_para.sim b/tests/script/unique/arbitrator/check_cluster_cfg_para.sim index 915fef47da90a07ec20cc317580306d078321442..7bf2c2ac42a95d1ab6da3ecf50a287eea2ce46bb 100644 --- a/tests/script/unique/arbitrator/check_cluster_cfg_para.sim +++ b/tests/script/unique/arbitrator/check_cluster_cfg_para.sim @@ -90,7 +90,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2~7 and add into cluster diff --git a/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim b/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim index 6f0f61d2e2f6dd85523f5e9b888172f475d8cbad..dbd0e2bd87c099dca54aa33d609696cb2dc89381 100644 --- a/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim +++ b/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim @@ -49,7 +49,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data @@ -57,7 +57,7 @@ system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 2000 $totalTableNum = 1 $sleepTimer = 3000 @@ -178,7 +178,7 @@ endi print ============== step7: restart dnode3, waiting sync end system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 2000 $loopCnt = 0 wait_dnode3_ready: diff --git a/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim b/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim index 80a050f883dd4cb1516bee18791addadb5b4567d..e15edb3f3d444b7407244b8cf3fa781ba36357d6 100644 --- a/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim +++ b/tests/script/unique/arbitrator/dn2_mn1_cache_file_sync_second.sim @@ -9,11 +9,11 @@ # expect: in dnode2, the files 1837 and 1839 will be removed sql connect -sleep 3000 +sleep 2000 print ============== step7: restart dnode2, waiting sync end system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 wait_dnode2_ready: sql show dnodes diff --git a/tests/script/unique/arbitrator/dn3_mn1_full_createTableFail.sim b/tests/script/unique/arbitrator/dn3_mn1_full_createTableFail.sim index 97433741f53c3053e25b588d7368377e1b890117..057654abb47be64bcba726df8b689b8db4d97f58 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_full_createTableFail.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_full_createTableFail.sim @@ -39,7 +39,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table to max tables @@ -49,7 +49,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 16 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim b/tests/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim index a6a9129090da41d83e619d6ca123c2ba75d312fd..c597c576e2994725035f83268c6b1f99392627da 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim @@ -40,7 +40,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table to max tables @@ -50,7 +50,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 16 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim b/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim index 7bb37c5ebb65a1620f6dbcec24502e9b7e635844..49e1dba06719a3375b221854ccb3a35d1bd03dfe 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $sleepTimer = 3000 @@ -143,7 +143,7 @@ endi print ============== step5: create the middle table 5 and insert data sql create table tb5 using $stb tags( 5 ) -sleep 3000 +sleep 2000 $tsStart = 1420041620000 $i = 5 @@ -212,7 +212,7 @@ endi print ============== step8: create the first table 0 and insert data sql create table tb0 using $stb tags( 0 ) -sleep 3000 +sleep 2000 $tsStart = 1420041640000 $i = 0 @@ -277,7 +277,7 @@ endi print ============== step11: create the last table 9 and insert data sql create table tb9 using $stb tags( 9 ) -sleep 3000 +sleep 2000 $tsStart = 1420041660000 $i = 0 diff --git a/tests/script/unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim b/tests/script/unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim index e11dd69598943410def7d75abb53ce2c03fd63c0..2af7cf56b7b547a707abc18f26a18fe74bd8f95e 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim @@ -49,7 +49,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster, then create database, create table , and insert data @@ -59,7 +59,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $rowNum = 10 $tblNum = 16 diff --git a/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim index 318a89f96bd25ae8bc8b4f54aa501282b7f7f2ac..96fde9061a0648d69386cb7f5c23450dea6aad7e 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -53,7 +53,7 @@ system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 -sleep 5000 +sleep 3000 $sleepTimer = 3000 @@ -225,7 +225,7 @@ if $data00 != $totalRows then endi print ============== step5: stop dnode2, and remove its vnode -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep $sleepTimer diff --git a/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim index 9fc19d588ac0928625bee576097770d9c5d7b164..da76cc467b7813586c98761319a01eb1f2ed6bb6 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $sleepTimer = 3000 @@ -359,13 +359,13 @@ endi print ============== step7: stop dnode3/dnode2, and cluster unable to provide services system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT -sleep 3000 +sleep 2000 sql select count(*) from $stb -x s71 s71: print ============== step8: restart dnode2, and cluster Still unable to provide services system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 sql select count(*) from $stb -x s81 s81: diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim b/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim index 986df81bf695affa71a4e9be740fc246fcc0ee96..c924fee1ae673f4e5696d361be331527d41ff21d 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim @@ -70,7 +70,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster, then create database replica 2, create table , and insert data @@ -78,7 +78,7 @@ system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 2000 $rowNum = 100 $tblNum = 16 @@ -139,7 +139,7 @@ if $data00 != $totalRows then return -1 endi -#sleep 3000 +#sleep 2000 #sql show dnodes #print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 #print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 @@ -175,7 +175,7 @@ endi sql show dnodes if $rows != 3 then - sleep 3000 + sleep 2000 goto wait_drop endi print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 @@ -218,7 +218,7 @@ system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 16 system sh/exec.sh -n dnode3 -s start sql create dnode $hostname3 -sleep 3000 +sleep 2000 $loopCnt = 0 wait_dnode3_ready: @@ -230,7 +230,7 @@ endi sql show dnodes print rows: $rows if $rows != 4 then - sleep 3000 + sleep 2000 goto wait_dnode3_ready endi print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 @@ -271,7 +271,7 @@ sql drop database $db sleep 1000 system sh/exec.sh -n dnode5 -s start sql create dnode $hostname5 -sleep 3000 +sleep 2000 $loopCnt = 0 wait_dnode5: $loopCnt = $loopCnt + 1 @@ -281,7 +281,7 @@ endi sql show dnodes if $rows != 5 then - sleep 3000 + sleep 2000 goto wait_dnode5 endi print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 @@ -352,7 +352,7 @@ endw print info: select count(*) from $stb sleep 2000 sql reset query cache -sleep 3000 +sleep 2000 sql select count(*) from $stb print data00 $data00 if $data00 != $totalRows then diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim b/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim index 387ae4625f392b8f108d7e9c34645905348d5e45..b9008e4c42b4f4a34b99bb48d4e38c780e747bb4 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim @@ -321,7 +321,7 @@ step9: endi sql show dnodes -if $rows != 2 then +if $rows != 3 then goto step9 endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim b/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim index 08d2db207b1a0025689c1b21c5d50b1bdd792a9c..73702835f4f41c74ae4161019808d26fd8a7c7a7 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 10000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim b/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim index 438e4af34f4a462ea6e84e075889a4e289d35743..27b308411aea5022641ae920a3a4e8848fb1dc04 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim @@ -50,7 +50,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster, then create database, create table , and insert data @@ -60,7 +60,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $rowNum = 10 $tblNum = 16 @@ -152,7 +152,7 @@ endi print ============== step4: restart dnode4, but there are not dnode4 in cluster system sh/exec.sh -n dnode4 -s start -sleep 3000 +sleep 2000 sql show dnodes if $rows != 3 then return -1 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim index 4f80c2389ee25d06a9852d38af9df3d40d838c90..6d81effab63bb52801ab51e53ee1147326b3e851 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim index 3b208e6f1a401f855c434bd02dcab364a05694bb..d22aca07cbd3d3c6a902076103c9759209c6a966 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 #sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim index fb0650b78a6875a812fdbb1cbac4a97e48e88348..884a43bce12d1bc2c137bab17b0e780c521e327c 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data to can fall disc @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 #sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 4 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim index f50081ea70abfc37223e6b3720915ecd4a5eedb9..3c74de49166067624335937d0e0486924b9fdb4f 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 #sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim index df41e4df36d747f0f5e066ab249a5c47fb919a19..d0399222f14cc8b8d7ac12ebca8b91549c34942d 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim index d814398d06a8e2f07ef2b5b640b15e542f46f28d..19b29bf342d7c8d045b16111fdc5d2ef9b2039f1 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 #sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim index 8f2cd9169b5ba43fb0903fe7ffca5e4984b514a1..8e15c4f527db044d52cd725714f15b98161da2ce 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim @@ -50,7 +50,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -60,7 +60,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $sleepTimer = 3000 @@ -170,7 +170,7 @@ s31: print ============== step4: restart dnode2, then create database with replica 2, and create table, insert data system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/dn3_mn2_killDnode.sim b/tests/script/unique/arbitrator/dn3_mn2_killDnode.sim index 7906718b0890d6c69a1fb3e00e25ed00191c5b42..d90853d2e41e8384acad2f4dcd5a95eee8298745 100644 --- a/tests/script/unique/arbitrator/dn3_mn2_killDnode.sim +++ b/tests/script/unique/arbitrator/dn3_mn2_killDnode.sim @@ -39,7 +39,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 3, and create table to max tables @@ -47,10 +47,10 @@ system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start #system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 -sleep 3000 +sleep 2000 sql create dnode $hostname3 #sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 4 $sleepTimer = 3000 @@ -92,7 +92,7 @@ endi print ============== step3: stop dnode2 system sh/exec.sh -n dnode2 -s stop -sleep 3000 +sleep 2000 sql show mnodes print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 diff --git a/tests/script/unique/arbitrator/insert_duplicationTs.sim b/tests/script/unique/arbitrator/insert_duplicationTs.sim index d58f903dcf2839876b61f0c949aa198423e664cc..4af47ca336c188c3194b9fc64925073f8fb406c2 100644 --- a/tests/script/unique/arbitrator/insert_duplicationTs.sim +++ b/tests/script/unique/arbitrator/insert_duplicationTs.sim @@ -49,7 +49,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data @@ -57,7 +57,7 @@ system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 2000 $totalTableNum = 1 $sleepTimer = 3000 @@ -181,7 +181,7 @@ $totalRows = $totalRows + 2 print ============== step6: restart dnode2, waiting sync end system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 $loopCnt = 0 wait_dnode2_ready: $loopCnt = $loopCnt + 1 @@ -213,7 +213,7 @@ endi sleep $sleepTimer # check using select -sleep 5000 +sleep 3000 sql select count(*) from $stb print data00 $data00 if $data00 != $totalRows then diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim index 9527d230e463619df48b84d8f6b3953d4cb81874..0adb6b475938c1aa37f56c20c5d6327c9f89d574 100644 --- a/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 #sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim index 1da8d749d54e1cd29b3ab00fa28e8406c9fd4d17..a0877ad89c20697e3b9a46f4512766fbd11439d8 100644 --- a/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 #sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim index 791ba76a8d9af34b3b3dec3c7ce3e2276ddc0a21..376484a0661d89fcd38f6be790437e10c6ef2761 100644 --- a/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 #sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim index 0d5abb2b9148d51ac6f8424d4f8300218112563e..9f21193400a8d7833afe8dbc5b4671c2f623778d 100644 --- a/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 #sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim index 0c59ee8525a8bb9fda50e5512aaaf54aeb3e25e3..cb3bbb3a73f5213c346fc675049827730a6e3a01 100644 --- a/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 #sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim index ce7151f78e85e763f3c3373ba8fce12642fb2514..8a9995f89162883c6529a3cd8e63bc764884147b 100644 --- a/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim index e29f8267c31bd96711e5c5bda09e88ff5e416a56..6eed563bbc7c79ac35a782fbd9f2ccaa79f277d6 100644 --- a/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim index 8f8b996c09233e72e53ed2224f03bbd417777c8e..2633d822c91d87ad6e5cc70370ac880fd397b889 100644 --- a/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim index f3779cf20a5417f3afcc6bb244ce9487664cd874..3abfc401611044b5cc7a1fb9411e4fd461beca78 100644 --- a/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim index f70ef1fc8c3f93cfe87629d8e3be0e58422fff83..f2acb8b90a35186395ab559ee428a182a2cba0d4 100644 --- a/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim index 8d1a508ef008c8ba6b9fc79612d6d177f7040a90..9d0e967f4e1575195e126cd975540067038409c5 100644 --- a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim +++ b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim @@ -60,7 +60,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: replica is 1, and start 1 dnode, then create tables and insert data system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect $totalTableNum = 12 @@ -105,7 +105,7 @@ endi print ============== step2: add 1 new dnode, expect balanced system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 -sleep 3000 +sleep 2000 # expect after balanced, 2 vondes in dnode1, 1 vonde in dnode2 $cnt = 0 @@ -137,7 +137,7 @@ endi print ============== step3: stop dnode1/dnode2, modify cfg numOfMnodes to 2, and restart dnode1/dnode2 system sh/exec.sh -n dnode1 -s stop system sh/exec.sh -n dnode2 -s stop -sleep 3000 +sleep 2000 system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 @@ -150,7 +150,7 @@ system sh/cfg.sh -n dnode2 -c role -v 0 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 print ============= step4: wait dnode ready @@ -193,9 +193,9 @@ if $data00 != $totalRows then endi print ============== step5: stop dnode1 -sleep 5000 -system sh/exec.sh -n dnode1 -s stop sleep 3000 +system sh/exec.sh -n dnode1 -s stop +sleep 2000 $cnt = 0 wait_dnode2_master: diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim index 12db84cbb313e02579d0e689fac3172c92f7bb6a..a8c0e83cc1e5da61a473fa5b9753e90450e57bec 100644 --- a/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 #sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim index 06d67a1cc9577598f0f8666a718b61d960d40dba..951d26635b257d1c1d3ab81889b66bb909b8038b 100644 --- a/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 #sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim index b388bc73a66c3529aadd14cdc5f8497a8cfeac87..e4e7f951881cf87c426c869774b2a3a548b29517 100644 --- a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 #sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim index 2e20d7b5d488ffe5ff3ed9752e13ed375b795311..0049dc6fba9bd33cd9c2e4f5b56510769dd0c60e 100644 --- a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim +++ b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 2, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 #sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim index 69cdb9f9424d5253cffe6af72545e881717e040d..499089960100f0be445552112e2b2000164c1ca0 100644 --- a/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim index 491b858500e7ae64c2477b9a6ebf4962a9d788a0..10bd4fc8bd3946871605f66493e15cdde28ec257 100644 --- a/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/sync_replica3_createTable.sim b/tests/script/unique/arbitrator/sync_replica3_createTable.sim index d593577bee4bf2ec6997836905a99c327ba6f443..a0b391dd763f96fa6d340fad213943045b45ed69 100644 --- a/tests/script/unique/arbitrator/sync_replica3_createTable.sim +++ b/tests/script/unique/arbitrator/sync_replica3_createTable.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 20 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim index 1ef499534fe272a32556a4155a4e622a77ad1ecf..68c6ecbd6ecf7c06b5ae595c16e5b7d4b89435bd 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 20 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim index 7a5966f60c5753e5029f7d107b2b9221d6001714..83e53eaeeb16e0988b778ef0b2515dc12c397d38 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim index abd2d8a788094ada42daf4b843a42a3245b799f0..7496541b76da3245f034924e95fd468b61135aef 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim @@ -45,7 +45,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica 3, and create table, insert data @@ -55,7 +55,7 @@ system sh/exec.sh -n dnode4 -s start sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -sleep 3000 +sleep 2000 $totalTableNum = 10 $sleepTimer = 3000 diff --git a/tests/script/unique/big/maxvnodes.sim b/tests/script/unique/big/maxvnodes.sim index eb17929ff49848acfe0744b4319aeb404a225adc..10dbc8bbff1a7be19791b75d77c705ffb060e48a 100644 --- a/tests/script/unique/big/maxvnodes.sim +++ b/tests/script/unique/big/maxvnodes.sim @@ -17,7 +17,7 @@ system sh/cfg.sh -n dnode2 -c balanceInterval -v 1 print ========== prepare data system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database db blocks 3 cache 1 sql use db @@ -51,7 +51,7 @@ system sh/exec.sh -n dnode2 -s start $x = 0 show3: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 1000 then return -1 endi diff --git a/tests/script/unique/big/restartSpeed.sim b/tests/script/unique/big/restartSpeed.sim index ea4edefda8f96c94aab12d856914565f8e8115f4..bdc4a8678b2c0e766e644a69cd709ecb2cd85268 100644 --- a/tests/script/unique/big/restartSpeed.sim +++ b/tests/script/unique/big/restartSpeed.sim @@ -14,7 +14,7 @@ system sh/cfg.sh -n dnode2 -c walLevel -v 2 print ========== prepare data system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database db blocks 3 cache 1 sql use db diff --git a/tests/script/unique/cluster/alter.sim b/tests/script/unique/cluster/alter.sim index 7e56707a693e96bd602c012035bebd3b1a8b7b6a..77e040c6cd9675a6e9c0ee9926f056b008bc6596 100644 --- a/tests/script/unique/cluster/alter.sim +++ b/tests/script/unique/cluster/alter.sim @@ -28,11 +28,11 @@ system sh/cfg.sh -n dnode4 -c balance -v 0 print ========== step1 system sh/exec.sh -n dnode1 -s start sql connect -sleep 3000 +sleep 2000 sql create dnode $hostname2 system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 print ========== step2 sql create database d1 diff --git a/tests/script/unique/cluster/balance2.sim b/tests/script/unique/cluster/balance2.sim index ffd13445edbf76dbc96b82a14848ef6b788237fa..026678af7c5f7d1dfb8924152e8c26ea6dcdb2ec 100644 --- a/tests/script/unique/cluster/balance2.sim +++ b/tests/script/unique/cluster/balance2.sim @@ -335,8 +335,8 @@ print dnode5 ==> $dnode5Role print ============================== step6 system sh/exec.sh -n dnode1 -s stop -x SIGINT -print stop dnode1 and sleep 10000 -sleep 5000 +print stop dnode1 and sleep 3000 +sleep 3000 sql drop dnode $hostname1 print drop dnode1 and sleep 9000 diff --git a/tests/script/unique/cluster/cache.sim b/tests/script/unique/cluster/cache.sim index e23b40782870be00eb3f010cbcdba693e18b19da..7a5afae79d7fc501724ce61bc6afb388aa4df51c 100644 --- a/tests/script/unique/cluster/cache.sim +++ b/tests/script/unique/cluster/cache.sim @@ -17,7 +17,7 @@ system sh/cfg.sh -n dnode1 -c monitorInterval -v 1 system sh/cfg.sh -n dnode2 -c monitorInterval -v 1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create database testdb @@ -33,7 +33,7 @@ while $x < 30 $x = $x + 1 endw -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 diff --git a/tests/script/unique/cluster/cluster_main.sim b/tests/script/unique/cluster/cluster_main.sim index f0a9b1a2147288fb3f0d2437a507296f9517ce09..d3750be6b4cdefa602dc2987c7cab3541589bd8f 100644 --- a/tests/script/unique/cluster/cluster_main.sim +++ b/tests/script/unique/cluster/cluster_main.sim @@ -48,11 +48,11 @@ print ============== step1: start dnode1/dnode2/dnode3 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 2000 sql connect sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 2000 print ============== step2: create db1 with replica 3 $db = db1 @@ -84,7 +84,7 @@ sql select count(tbname) from $stb print select count(tbname) from $stb print data00 $data00 if $data00 < 1000 then - sleep 3000 + sleep 2000 goto wait_subsim_insert_complete_create_tables endi @@ -93,12 +93,12 @@ print select count(*) from $stb sql select count(*) from $stb print data00 $data00 if $data00 < 1000 then - sleep 3000 + sleep 2000 goto wait_subsim_insert_data endi print wait for a while to let clients start insert data -sleep 5000 +sleep 3000 print ============== step4-1: add dnode4/dnode5 into cluster sql create dnode $hostname4 @@ -116,7 +116,7 @@ print ============== step6: stop dnode1 system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 10000 #sql drop dnode $hostname1 -#sleep 5000 +#sleep 3000 #system rm -rf ../../../sim/dnode1/data #sleep 20000 @@ -152,7 +152,7 @@ print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 print ============== step7: stop dnode2 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 sql show mnodes print show mnodes diff --git a/tests/script/unique/cluster/cluster_main0.sim b/tests/script/unique/cluster/cluster_main0.sim index 9f775c0cef183bfe3b8dd231a08f5f829fe2d3ef..48403d011b4b7603e861441728fd030de6e3c7ba 100644 --- a/tests/script/unique/cluster/cluster_main0.sim +++ b/tests/script/unique/cluster/cluster_main0.sim @@ -48,11 +48,11 @@ print ============== step1: start dnode1/dnode2/dnode3 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 2000 sql connect sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 2000 print ============== step2: create db1 with replica 3 $db = db1 @@ -85,7 +85,7 @@ sql select count(tbname) from $stb print select count(tbname) from $stb print data00 $data00 if $data00 < 1000 then - sleep 3000 + sleep 2000 goto wait_subsim_insert_complete_create_tables endi @@ -94,12 +94,12 @@ print select count(*) from $stb sql select count(*) from $stb print data00 $data00 if $data00 < 1000 then - sleep 3000 + sleep 2000 goto wait_subsim_insert_data endi print wait for a while to let clients start insert data -sleep 5000 +sleep 3000 $loop_cnt = 0 loop_cluster_do: @@ -110,14 +110,14 @@ system sh/exec.sh -n dnode5 -s start sql create dnode $hostname4 sql create dnode $hostname5 -sleep 5000 +sleep 3000 print ============== step6: stop dnode1 system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 10000 #sql drop dnode $hostname1 -#sleep 5000 +#sleep 3000 #system rm -rf ../../../sim/dnode1/data #sleep 20000 print ============== step6-1: restart dnode1 @@ -139,7 +139,7 @@ print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 print ============== step7: stop dnode2 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 sql show mnodes print show mnodes @@ -235,7 +235,7 @@ endi print ============== step14: stop and drop dnode4/dnode5, then remove data dir of dnode4/dnode5 system sh/exec.sh -n dnode4 -s stop -x SIGINT system sh/exec.sh -n dnode5 -s stop -x SIGINT -sleep 3000 +sleep 2000 sql drop dnode $hostname4 sql drop dnode $hostname5 system rm -rf ../../../sim/dnode4/data diff --git a/tests/script/unique/cluster/cluster_main1.sim b/tests/script/unique/cluster/cluster_main1.sim index 7796f1ea00da9d9915aba6a9cbecee0223f99fd4..a2426dc5744fe116329013e658dee48dc957a5f2 100644 --- a/tests/script/unique/cluster/cluster_main1.sim +++ b/tests/script/unique/cluster/cluster_main1.sim @@ -48,11 +48,11 @@ print ============== step1: start dnode1/dnode2/dnode3 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 2000 sql connect sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 2000 print ============== step2: create db1 with replica 3 $replica = 3 @@ -92,17 +92,17 @@ print select count(*) from $stb sql select count(*) from $stb print data00 $data00 if $data00 < 1000 then - sleep 3000 + sleep 2000 goto wait_subsim_insert_data endi print wait for a while to let clients start insert data -sleep 5000 +sleep 3000 print ============== step4-1: add dnode4/dnode5 into cluster sql create dnode $hostname4 sql create dnode $hostname5 -sleep 5000 +sleep 3000 $loop_cnt = 0 loop_cluster_do: @@ -116,7 +116,7 @@ print ============== step6: stop dnode1 system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 10000 #sql drop dnode $hostname1 -#sleep 5000 +#sleep 3000 #system rm -rf ../../../sim/dnode1/data #sleep 20000 print ============== step6-1: restart dnode1 @@ -138,7 +138,7 @@ print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 print ============== step7: stop dnode2 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 sql show mnodes print show mnodes diff --git a/tests/script/unique/cluster/cluster_main2.sim b/tests/script/unique/cluster/cluster_main2.sim index 48661546815a1e4c60e2b8d983f0a3e20e232529..e050ab3acf54d22becb50f6e91f83fc4eab0485b 100644 --- a/tests/script/unique/cluster/cluster_main2.sim +++ b/tests/script/unique/cluster/cluster_main2.sim @@ -48,11 +48,11 @@ print ============== step1: start dnode1/dnode2/dnode3 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 2000 sql connect sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 2000 print ============== step2: create db1 with replica 3 $replica = 3 @@ -87,7 +87,7 @@ sql select count(tbname) from $stb print select count(tbname) from $stb print data00 $data00 if $data00 < 1000 then - sleep 3000 + sleep 2000 goto wait_subsim_insert_complete_create_tables endi @@ -96,17 +96,17 @@ print select count(*) from $stb sql select count(*) from $stb print data00 $data00 if $data00 < 1000 then - sleep 3000 + sleep 2000 goto wait_subsim_insert_data endi print wait for a while to let clients start insert data -sleep 5000 +sleep 3000 print ============== step4-1: add dnode4/dnode5 into cluster sql create dnode $hostname4 sql create dnode $hostname5 -sleep 5000 +sleep 3000 $loop_cnt = 0 @@ -120,7 +120,7 @@ print ============== step6: stop dnode1 system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 10000 #sql drop dnode $hostname1 -#sleep 5000 +#sleep 3000 #system rm -rf ../../../sim/dnode1/data #sleep 20000 print ============== step6-1: restart dnode1 @@ -142,7 +142,7 @@ print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 print ============== step7: stop dnode2 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 sql show mnodes print show mnodes diff --git a/tests/script/unique/cluster/flowctrl.sim b/tests/script/unique/cluster/flowctrl.sim index 6dc60d9fba0fd0a5f7a8088d8277c2da9e06a259..700fa0a3f195c84ed6e7903fe572c81b20b4fd21 100644 --- a/tests/script/unique/cluster/flowctrl.sim +++ b/tests/script/unique/cluster/flowctrl.sim @@ -79,14 +79,14 @@ while $x < 100 endw print =============== step3 -sleep 3000 +sleep 2000 system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT print =============== step4 -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start @@ -101,7 +101,7 @@ endw print =============== step6 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 3000 +sleep 2000 while $x < 300 $ms = $x . s sql insert into tb values (now + $ms , $x ) diff --git a/tests/script/unique/clusterSimCase/cluster_main.sim b/tests/script/unique/clusterSimCase/cluster_main.sim index 39607c2915da7594f7af3562ae3ccd7680b2b4aa..274ce85974bb2238bae60e6ffa9723760ae1c394 100644 --- a/tests/script/unique/clusterSimCase/cluster_main.sim +++ b/tests/script/unique/clusterSimCase/cluster_main.sim @@ -88,8 +88,8 @@ sql connect print ============== step1: add dnode2/dnode3 into cluster sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 -sleep 3000 +sleep 2000 +sleep 2000 print ============== step3: start back client-01.sim #run_back unique/clusterSimCase/client-01.sim #run_back unique/clusterSimCase/client-02.sim @@ -142,7 +142,7 @@ if $vg2Dnode2Status != master then endi -sleep 3000 +sleep 2000 print ============== step3: restart dnode3 system sh/exec.sh -n dnode3 -s start @@ -174,7 +174,7 @@ if $vg2Dnode2Status != master then goto wait_vgroup_chang_1 endi -sleep 3000 +sleep 2000 print ============== step4: stop dnode2 system sh/exec.sh -n dnode2 -s stop -x SIGINT @@ -207,7 +207,7 @@ if $vg2Dnode2Status != offline then endi -sleep 3000 +sleep 2000 print ============== step5: restart dnode2 system sh/exec.sh -n dnode2 -s start @@ -239,7 +239,7 @@ if $vg2Dnode3Status != master then goto wait_vgroup_chang_3 endi -sleep 3000 +sleep 2000 print **** **** **** (loop_cnt: $loop_cnt ) end, continue...... **** **** **** **** $loop_cnt = $loop_cnt + 1 if $loop_cnt == 50 then diff --git a/tests/script/unique/db/commit.sim b/tests/script/unique/db/commit.sim index caff3c6a7898090b307d487ccdf2b8ac0dd7a1f3..661dd4505f704fff961739075247d4264d617f72 100644 --- a/tests/script/unique/db/commit.sim +++ b/tests/script/unique/db/commit.sim @@ -16,12 +16,12 @@ system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 print ========= start dnode1 as master system sh/exec.sh -n dnode1 -s start sql connect -sleep 3000 +sleep 2000 print ========= start other dnodes sql create dnode $hostname2 system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 print ======== step1 create db sql create database commitdb replica 1 days 7 keep 30 @@ -48,9 +48,9 @@ endi print ======== step2 stop dnode system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 sql select * from tb order by ts desc print ===> rows $rows @@ -99,9 +99,9 @@ endi print ======== step5 stop dnode system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 sql select * from tb print ===> rows $rows diff --git a/tests/script/unique/db/delete.sim b/tests/script/unique/db/delete.sim index f84339be79ad08951ff60c0df0d8992027c2ef98..c876f23de35f67b0cd2a6f0e428a825d98de7c27 100644 --- a/tests/script/unique/db/delete.sim +++ b/tests/script/unique/db/delete.sim @@ -23,7 +23,7 @@ sql create dnode $hostname2 sql create dnode $hostname3 system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 2000 print ======== step1 sql create database db replica 3 blocks 3 @@ -49,7 +49,7 @@ if $rows != 0 then return -1 endi -sleep 3000 +sleep 2000 sql show dnodes print dnode1 openVnodes $data2_1 print dnode2 openVnodes $data2_2 diff --git a/tests/script/unique/db/replica_reduce32.sim b/tests/script/unique/db/replica_reduce32.sim index a5eb78dacb6065413e06a50d7a0d9f7e28897d9f..ead265d5d54bd415d12147e5b61b04fcc5d7544f 100644 --- a/tests/script/unique/db/replica_reduce32.sim +++ b/tests/script/unique/db/replica_reduce32.sim @@ -169,7 +169,7 @@ sleep 200 print ========= step4 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 sql insert into d1.t1 values(now, 3) -x s41 s41: diff --git a/tests/script/unique/dnode/alternativeRole.sim b/tests/script/unique/dnode/alternativeRole.sim index af627490ba8671203d740178ae8b42e22b2c3a74..955b757f06df22c884565d0fac350456e79cb73a 100644 --- a/tests/script/unique/dnode/alternativeRole.sim +++ b/tests/script/unique/dnode/alternativeRole.sim @@ -23,14 +23,14 @@ system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4 print ========== step1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create dnode $hostname2 system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 system sh/exec.sh -n dnode3 -s start -sleep 5000 +sleep 3000 sql show dnodes print dnode1 $data5_1 diff --git a/tests/script/unique/dnode/balance2.sim b/tests/script/unique/dnode/balance2.sim index 7b07eb3f37334e78d1b2828120472d4ea9ebb5a1..4c67e20c3eb5e65b0bacf0aafc3d9dc1a53d5ac3 100644 --- a/tests/script/unique/dnode/balance2.sim +++ b/tests/script/unique/dnode/balance2.sim @@ -120,7 +120,7 @@ system sh/exec.sh -n dnode4 -s start $x = 0 show3: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 20 then return -1 endi diff --git a/tests/script/unique/dnode/balancex.sim b/tests/script/unique/dnode/balancex.sim index da8197e22df73edfd1d5c6f02d014a45511fbae0..d2c738ee97ff8432999125abfd63d253b0546a91 100644 --- a/tests/script/unique/dnode/balancex.sim +++ b/tests/script/unique/dnode/balancex.sim @@ -23,7 +23,7 @@ system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4 print ========== step1 system sh/exec.sh -n dnode1 -s start sql connect -sleep 3000 +sleep 2000 sql create database d1 sql create table d1.t1 (t timestamp, i int) @@ -102,7 +102,7 @@ system sh/exec.sh -n dnode3 -s start $x = 0 show4: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 20 then return -1 endi @@ -145,7 +145,7 @@ if $data2_3 != 3 then endi system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 sql reset query cache sleep 1000 diff --git a/tests/script/unique/dnode/data1.sim b/tests/script/unique/dnode/data1.sim index 61a991148b21b471aef906223a5f600f7db38f5f..75a484abb60c1e09a7c96f8f03902ea4f0f40aa1 100644 --- a/tests/script/unique/dnode/data1.sim +++ b/tests/script/unique/dnode/data1.sim @@ -23,7 +23,7 @@ system sh/cfg.sh -n dnode4 -c wallevel -v 2 print ========== step1 system sh/exec.sh -n dnode1 -s start sql connect -sleep 3000 +sleep 2000 print ========== step2 sql create dnode $hostname2 @@ -36,7 +36,7 @@ system sh/exec.sh -n dnode4 -s start $x = 0 show2: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 10 then return -1 endi @@ -71,7 +71,7 @@ sql insert into d1.t1 values(now+5s, 31) $x = 0 show3: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 10 then return -1 endi diff --git a/tests/script/unique/dnode/datatrans_1node.sim b/tests/script/unique/dnode/datatrans_1node.sim index bc38bfaf2df172dfb752eaf94549995ed513ba74..a156c32672cf2936c0b69fe10242744d2dd235a3 100644 --- a/tests/script/unique/dnode/datatrans_1node.sim +++ b/tests/script/unique/dnode/datatrans_1node.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 2 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print =============== step1 @@ -40,7 +40,7 @@ system sh/exec.sh -n dnode2 -s start print =============== step 4 -sleep 3000 +sleep 2000 sql connect sql select * from db.m1 diff --git a/tests/script/unique/dnode/datatrans_3node.sim b/tests/script/unique/dnode/datatrans_3node.sim index 7c3708c1110df2714db25a59b6a5bc37b5f3818c..7948eb6d3a4317ab3d829a874ced71d9f290d641 100644 --- a/tests/script/unique/dnode/datatrans_3node.sim +++ b/tests/script/unique/dnode/datatrans_3node.sim @@ -31,7 +31,7 @@ system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 print ============== step1: start dnode1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data @@ -39,7 +39,7 @@ system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 2000 # create table sql drop database -x step1 @@ -76,7 +76,7 @@ system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode4 -s start print =============== step 4 -sleep 3000 +sleep 2000 sql connect sql select * from db.m1 diff --git a/tests/script/unique/dnode/datatrans_3node_2.sim b/tests/script/unique/dnode/datatrans_3node_2.sim index 4fb3b4535fb640ac7257af33b651941462a56896..844afc5b02f7de4e41d545ad546b9ec41943b18f 100644 --- a/tests/script/unique/dnode/datatrans_3node_2.sim +++ b/tests/script/unique/dnode/datatrans_3node_2.sim @@ -31,7 +31,7 @@ system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 print ============== step1: start dnode1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster , then create database with replica 2, and create table, insert data @@ -39,7 +39,7 @@ system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 2000 # create table sql drop database -x step1 @@ -76,7 +76,7 @@ system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode4 -s start print =============== step 4 -sleep 3000 +sleep 2000 sql connect sql select * from db.m1 diff --git a/tests/script/unique/dnode/monitor.sim b/tests/script/unique/dnode/monitor.sim index 1e5b0f6f56c261437ffc25c8a68139c53d7303df..b9b5e41889675ed199b67efc327477271e2f2959 100644 --- a/tests/script/unique/dnode/monitor.sim +++ b/tests/script/unique/dnode/monitor.sim @@ -23,7 +23,7 @@ system sh/cfg.sh -n dnode2 -c monitor -v 1 print ========== step1 system sh/exec.sh -n dnode1 -s start sql connect -sleep 5000 +sleep 3000 sql show dnodes print dnode1 openVnodes $data3_1 @@ -65,7 +65,7 @@ sql select * from log.dn1 print $rows $rows1 = $rows -sleep 3000 +sleep 2000 sql select * from log.dn1 print $rows $rows2 = $rows @@ -79,7 +79,7 @@ sql select * from log.dn2 print $rows $rows1 = $rows -sleep 3000 +sleep 2000 sql select * from log.dn2 print $rows $rows2 = $rows diff --git a/tests/script/unique/dnode/monitor_bug.sim b/tests/script/unique/dnode/monitor_bug.sim index 3169c7cdba4c9f631a41365e25e6537dd823fc5a..efdf5e94b9648a50860dfa79715f6df8cb4c2b3a 100644 --- a/tests/script/unique/dnode/monitor_bug.sim +++ b/tests/script/unique/dnode/monitor_bug.sim @@ -15,7 +15,7 @@ system sh/cfg.sh -n dnode2 -c monitor -v 0 print ========== step1 system sh/exec.sh -n dnode1 -s start sql connect -sleep 5000 +sleep 3000 sql show dnodes print dnode1 openVnodes $data2_1 @@ -64,7 +64,7 @@ sql select * from log.dn1 print $rows $rows1 = $rows -sleep 3000 +sleep 2000 sql select * from log.dn1 print $rows $rows2 = $rows diff --git a/tests/script/unique/dnode/offline1.sim b/tests/script/unique/dnode/offline1.sim index beebbfda60c03d24a774347c8ecf8c2f9a4c6c9e..9bbd14cf07891583711f8298c09da24d9fae4df4 100644 --- a/tests/script/unique/dnode/offline1.sim +++ b/tests/script/unique/dnode/offline1.sim @@ -25,7 +25,7 @@ system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 sql show dnodes print dnode1 $data4_1 diff --git a/tests/script/unique/dnode/offline2.sim b/tests/script/unique/dnode/offline2.sim index e8a5460de47919f42187f26a05169fa99ce47dd0..711488cf3f4dc2aebd1980c6615291b0e88dc825 100644 --- a/tests/script/unique/dnode/offline2.sim +++ b/tests/script/unique/dnode/offline2.sim @@ -32,7 +32,7 @@ system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 system sh/exec.sh -n dnode2 -s start -sleep 3000 +sleep 2000 sql create database d1 replica 2 sql create table d1.t1(ts timestamp, i int) @@ -60,7 +60,7 @@ print dnode1 $data4_2 if $data4_1 != ready then return -1 endi -if $data4_2 != offline then +if $data4_2 == ready then return -1 endi @@ -84,11 +84,11 @@ system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode2 -s start sql drop dnode $hostname2 -sleep 5000 +sleep 3000 $x = 0 show4: $x = $x + 1 - sleep 5000 + sleep 3000 if $x == 10 then return -1 endi diff --git a/tests/script/unique/dnode/simple.sim b/tests/script/unique/dnode/simple.sim index 014e2dd04f4e221dd036830eca95c50af03bd77e..38d8c08d75b4201fd4375afe50a83d8757ac0120 100644 --- a/tests/script/unique/dnode/simple.sim +++ b/tests/script/unique/dnode/simple.sim @@ -13,7 +13,7 @@ sql create dnode $hostname2 system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 2000 sql create database d1 replica 2 sql create table d1.t1 (t timestamp, i int) @@ -44,7 +44,7 @@ endi print ========== step2 sql create dnode $hostname4 system sh/exec.sh -n dnode4 -s start -sleep 3000 +sleep 2000 sql show dnodes print dnode1 openVnodes $data2_1 diff --git a/tests/script/unique/http/admin.sim b/tests/script/unique/http/admin.sim index 8833397487aaca05342b7c41db6c979b6084ca97..acc28a4e136b79ac6aaa3962f2b91c91f97a22a4 100644 --- a/tests/script/unique/http/admin.sim +++ b/tests/script/unique/http/admin.sim @@ -8,7 +8,7 @@ system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 system sh/exec.sh -n dnode1 -s start sql connect -sleep 3000 +sleep 2000 print ============================ dnode1 start @@ -79,7 +79,7 @@ if $system_content != @{"status":"error","code":4389,"desc":"invalid taosd Autho return -1 endi -sleep 3000 +sleep 2000 system_content curl 127.0.0.1:7111/admin/login/root/taosdata print 9 -----> $system_content diff --git a/tests/script/unique/http/opentsdb.sim b/tests/script/unique/http/opentsdb.sim index 526981716537ed8966e23fa3bc98662de0e06854..3d8e5a8c4411f1ae92d04d95596b052c26fe6889 100644 --- a/tests/script/unique/http/opentsdb.sim +++ b/tests/script/unique/http/opentsdb.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect print ============================ dnode1 start @@ -152,7 +152,7 @@ if $system_content != @{"status":"error","code":4515,"desc":"tag value is null"} return -1 endi -sleep 3000 +sleep 2000 print =============== step2 - insert single data system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400000,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:7111/opentsdb/db/put diff --git a/tests/script/unique/import/replica3.sim b/tests/script/unique/import/replica3.sim index 714141c412793f6608b11beb0a455ee3d37a3310..5da9e141a5867dd2e3d61114379ede589c0fa744 100644 --- a/tests/script/unique/import/replica3.sim +++ b/tests/script/unique/import/replica3.sim @@ -241,9 +241,9 @@ endi print ================= step13 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 print ================= step14 #1520000000000 diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim index 6c9e92502c254c9e1072ed1236822831ce7809cd..8f837b7e477ab801b296b32ddcf9a5c683c351f0 100644 --- a/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim @@ -159,7 +159,7 @@ if $loopCnt == 20 then endi sql show dnodes -x wait_dnode1_ready -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode1_ready endi @@ -232,7 +232,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode2_offline endi diff --git a/tests/script/unique/mnode/mgmt20.sim b/tests/script/unique/mnode/mgmt20.sim index ee9c2b914f237f619f342122a3b1fd2bccc5cf67..8945cffab226ab5dc379057d55e562f5c3ed9cfa 100644 --- a/tests/script/unique/mnode/mgmt20.sim +++ b/tests/script/unique/mnode/mgmt20.sim @@ -68,7 +68,7 @@ if $data2_2 != slave then goto show4 endi -sleep 3000 +sleep 2000 sql select * from log.dn1 $d1_second = $rows sql select * from log.dn2 diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim index 1dc419b17dbd537e09833780c0104e304f8b71fe..399805312ba905d55bceffe011cfe074c831684e 100644 --- a/tests/script/unique/mnode/mgmt22.sim +++ b/tests/script/unique/mnode/mgmt22.sim @@ -46,7 +46,7 @@ print should not drop master print ============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 sql_error show mnodes print error of no master diff --git a/tests/script/unique/mnode/mgmt26.sim b/tests/script/unique/mnode/mgmt26.sim index 9b534cca06c89d3fa6f05ab82a88fb80514acac2..2816845052e835cf11e0ec7d4ddc71cbdee0ada1 100644 --- a/tests/script/unique/mnode/mgmt26.sim +++ b/tests/script/unique/mnode/mgmt26.sim @@ -90,7 +90,7 @@ print ============== step5 system sh/exec.sh -n dnode2 -s stop system sh/deploy.sh -n dnode2 -i 2 system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 sleep 6000 diff --git a/tests/script/unique/mnode/mgmt30.sim b/tests/script/unique/mnode/mgmt30.sim index a9488799334ef81c82e231bc7782993b7a33a4fa..d0858c0d6cdffa1cb1cd7f2ba570ae0521f412d5 100644 --- a/tests/script/unique/mnode/mgmt30.sim +++ b/tests/script/unique/mnode/mgmt30.sim @@ -32,7 +32,7 @@ endi print ============== step2 system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 5000 +sleep 3000 sql create dnode $hostname2 sql create dnode $hostname3 diff --git a/tests/script/unique/mnode/mgmtr2.sim b/tests/script/unique/mnode/mgmtr2.sim index 0c9f961d253e1ca57477f5612ed5f1f28c7b9e26..5afb41905846bff3ce9894e928245a7d34078354 100644 --- a/tests/script/unique/mnode/mgmtr2.sim +++ b/tests/script/unique/mnode/mgmtr2.sim @@ -9,7 +9,7 @@ system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 print ============== step1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql show mnodes diff --git a/tests/script/unique/stable/dnode2_stop.sim b/tests/script/unique/stable/dnode2_stop.sim index 19c6de33b3882633acce74ca6c8f9bdbccbf7b1c..c10f04338d894106a6a543a872af69da9e49bae5 100644 --- a/tests/script/unique/stable/dnode2_stop.sim +++ b/tests/script/unique/stable/dnode2_stop.sim @@ -72,7 +72,7 @@ endi sleep 100 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 print =============== step2 sql select count(*) from $mt -x step2 @@ -84,7 +84,7 @@ sql select count(tbcol) from $mt -x step21 step21: system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 print =============== step3 sql select count(tbcol) as c from $mt where ts <= 1519833840000 diff --git a/tests/script/unique/stream/metrics_balance.sim b/tests/script/unique/stream/metrics_balance.sim index 3cb0d73ab862178e5d648ddd1342e0b930e1f6a0..b78cfc33a1d32c68feadc7696a449eadbdc70c36 100644 --- a/tests/script/unique/stream/metrics_balance.sim +++ b/tests/script/unique/stream/metrics_balance.sim @@ -175,7 +175,7 @@ print rows0=>$r0 rows3=>$r3 rows6=>$r6 rows9=>$r9 $x = 0 show1: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 20 then return -1 endi @@ -200,7 +200,7 @@ sleep 8000 $x = 0 show2: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 20 then return -1 endi diff --git a/tests/script/unique/stream/metrics_vnode_stop.sim b/tests/script/unique/stream/metrics_vnode_stop.sim index 1f9cab48e5f738dabe1e07fa5b1017eb23282ac0..f1a0981d70a1f6638af6174af9bfaf84d02a0673 100644 --- a/tests/script/unique/stream/metrics_vnode_stop.sim +++ b/tests/script/unique/stream/metrics_vnode_stop.sim @@ -112,11 +112,11 @@ connectTbase2: return -1 endi sql connect -x connectTbase2 -sleep 3000 +sleep 2000 sql create dnode $hostname1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 print ======================== dnode start $dbPrefix = db diff --git a/tests/script/unique/stream/table_balance.sim b/tests/script/unique/stream/table_balance.sim index facb7df45900eff83c18e2a5ee8344d4d426cf9b..e8dec54e3ed98ebfea67d7f61d2dbbb675f9b3b4 100644 --- a/tests/script/unique/stream/table_balance.sim +++ b/tests/script/unique/stream/table_balance.sim @@ -112,7 +112,7 @@ print rows1=>$r1 rows5=>$r5 rows8=>$r8 $x = 0 show1: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 20 then return -1 endi @@ -137,7 +137,7 @@ sleep 8000 $x = 0 show2: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 20 then return -1 endi diff --git a/tests/script/unique/stream/table_move.sim b/tests/script/unique/stream/table_move.sim index fe19e6f402b49ee74f5a4440fb6012925a85161e..964a0c025363fd650e8051312a812fffbddaea7d 100644 --- a/tests/script/unique/stream/table_move.sim +++ b/tests/script/unique/stream/table_move.sim @@ -63,7 +63,7 @@ print ========= start dnode1 system sh/exec.sh -n dnode1 -s start sql connect -sleep 3000 +sleep 2000 $i = 0 $db = $dbPrefix . $i @@ -170,7 +170,7 @@ sleep 8000 $x = 0 show2: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 20 then return -1 endi @@ -199,7 +199,7 @@ sleep 9000 $x = 0 show6: $x = $x + 1 - sleep 3000 + sleep 2000 if $x == 20 then return -1 endi diff --git a/tests/script/unique/stream/table_vnode_stop.sim b/tests/script/unique/stream/table_vnode_stop.sim index 16350949b12e53dd452e1fba46524352a1953408..229d814e42ced35d75eec6a4ccc2fbaa66e6f654 100644 --- a/tests/script/unique/stream/table_vnode_stop.sim +++ b/tests/script/unique/stream/table_vnode_stop.sim @@ -113,11 +113,11 @@ connectTbase2: return -1 endi sql connect -x connectTbase2 -sleep 3000 +sleep 2000 sql create dnode $hostname1 system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 print ======================== dnode start $dbPrefix = db diff --git a/tests/script/unique/vnode/many.sim b/tests/script/unique/vnode/many.sim index 869c7f82953e99ef9e14a193f3894c4b53466b9e..a9298b1cf275c24ab6ebe7fea9387a51d6d044ba 100644 --- a/tests/script/unique/vnode/many.sim +++ b/tests/script/unique/vnode/many.sim @@ -80,7 +80,7 @@ $lastRows4 = $rows print ======== step2 run_back unique/vnode/back_insert_many.sim -sleep 5000 +sleep 3000 print ======== step3 @@ -89,15 +89,15 @@ loop: print ======== step4 system sh/exec.sh -n dnode3 -s stop -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode3 -s start -sleep 5000 +sleep 3000 print ======== step5 system sh/exec.sh -n dnode2 -s stop -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 print ======== step6 sql select count(*) from db1.tb1 diff --git a/tests/script/unique/vnode/replica2_a_large.sim b/tests/script/unique/vnode/replica2_a_large.sim index 801570dd9c18daa5611d621660e88905fa73c2b3..6f318038454a171445600e37d17852b2c2de835e 100644 --- a/tests/script/unique/vnode/replica2_a_large.sim +++ b/tests/script/unique/vnode/replica2_a_large.sim @@ -29,14 +29,14 @@ print ============== step0: start tarbitrator system sh/exec_tarbitrator.sh -s start system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create dnode $hostname2 sql create dnode $hostname3 system sh/exec.sh -n dnode2 -s start -t system sh/exec.sh -n dnode3 -s start -t -sleep 3000 +sleep 2000 print ========= step1 sql create database db replica 2 @@ -56,7 +56,7 @@ $lastRows = $rows print ======== step2 #run_back unique/vnode/back_insert_many.sim run_back unique/vnode/back_insert.sim -sleep 3000 +sleep 2000 print ======== step3 diff --git a/tests/script/unique/vnode/replica2_basic2.sim b/tests/script/unique/vnode/replica2_basic2.sim index 6976353f3e292b3752b1df9f7ac1c398087a644a..c081f878dda513a3b11c9546db4dad31c3d2c5ff 100644 --- a/tests/script/unique/vnode/replica2_basic2.sim +++ b/tests/script/unique/vnode/replica2_basic2.sim @@ -22,13 +22,13 @@ system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 print ========= start dnodes system sh/exec.sh -n dnode1 -s start -sleep 3000 +sleep 2000 sql connect sql create dnode $hostname2 sql create dnode $hostname3 system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 2000 sql reset query cache @@ -126,7 +126,7 @@ endi print ========= step3 system sh/exec.sh -n dnode2 -s stop -x SIGINT -sleep 5000 +sleep 3000 #sql insert into d1.t1 values(now, 3) #sql insert into d2.t2 values(now, 3) @@ -155,9 +155,9 @@ sleep 5000 print ========= step4 system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode3 -s stop -x SIGINT -sleep 5000 +sleep 3000 #sql insert into d1.t1 values(now, 4) #sql insert into d2.t2 values(now, 4) @@ -186,7 +186,7 @@ sleep 5000 print ========= step5 system sh/exec.sh -n dnode3 -s start -sleep 5000 +sleep 3000 sql insert into d1.t1 values(now, 5) sql insert into d2.t2 values(now, 5) diff --git a/tests/script/unique/vnode/replica2_repeat.sim b/tests/script/unique/vnode/replica2_repeat.sim index 5dbb24437d3dc534018b788c5be1e29bf32cb72d..ac68d591648b2dd66f3fdda8c70b0af40c814459 100644 --- a/tests/script/unique/vnode/replica2_repeat.sim +++ b/tests/script/unique/vnode/replica2_repeat.sim @@ -65,7 +65,7 @@ $lastRows = $rows print ======== step2 run_back unique/vnode/back_insert.sim -sleep 3000 +sleep 2000 print ======== step3 @@ -74,15 +74,15 @@ loop: print ======== step4 system sh/exec.sh -n dnode2 -s stop -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 print ======== step5 system sh/exec.sh -n dnode3 -s stop -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode3 -s start -sleep 5000 +sleep 3000 print ======== step6 sql select count(*) from db.tb diff --git a/tests/script/unique/vnode/replica3_repeat.sim b/tests/script/unique/vnode/replica3_repeat.sim index d866fb05d89b5441d83390a154324fb4290c451d..636bc64f89948a8bd4ec0d3dc9dc2a1b10f50e00 100644 --- a/tests/script/unique/vnode/replica3_repeat.sim +++ b/tests/script/unique/vnode/replica3_repeat.sim @@ -72,32 +72,32 @@ $lastRows = $rows print ======== step2 run_back unique/vnode/back_insert.sim -sleep 3000 +sleep 2000 print ======== step3 system sh/exec.sh -n dnode2 -s stop -sleep 5000 +sleep 3000 $x = 0 loop: print ======== step4 system sh/exec.sh -n dnode2 -s start -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode3 -s stop -sleep 5000 +sleep 3000 print ======== step5 system sh/exec.sh -n dnode3 -s start -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode4 -s stop -sleep 5000 +sleep 3000 print ======== step6 system sh/exec.sh -n dnode4 -s start -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode2 -s stop -sleep 5000 +sleep 3000 print ======== step7 sql select count(*) from db.tb diff --git a/tests/script/unique/vnode/replica3_vgroup.sim b/tests/script/unique/vnode/replica3_vgroup.sim index 11295ba0a42cfea1ee6ff5fd50f8563ee344fc77..de4c48eca5683fc7599d545e2887ae8d2c073b82 100644 --- a/tests/script/unique/vnode/replica3_vgroup.sim +++ b/tests/script/unique/vnode/replica3_vgroup.sim @@ -16,13 +16,13 @@ sql create dnode $hostname2 sql create dnode $hostname3 system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 2000 $N = 10 $table = table_r3 $db = db1 -sleep 3000 +sleep 2000 print =================== step 1 diff --git a/tests/script/windows/alter/metrics.sim b/tests/script/windows/alter/metrics.sim index 7d5dc779490f7591ff9330c47622e46f98fb1783..7dfda05bd0b0849fa6cbdb27e064113ad2fec595 100644 --- a/tests/script/windows/alter/metrics.sim +++ b/tests/script/windows/alter/metrics.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases @@ -368,9 +368,9 @@ endi print ======== step9 print ======== step10 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql use d2 sql describe tb diff --git a/tests/script/windows/alter/table.sim b/tests/script/windows/alter/table.sim index 03182e613d6cea983529e75512b736acfd702765..52757da20ef226ececec64698cea7846584a73bd 100644 --- a/tests/script/windows/alter/table.sim +++ b/tests/script/windows/alter/table.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases @@ -319,9 +319,9 @@ endi print ======== step9 print ======== step10 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 +sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql use d1 sql describe tb diff --git a/tests/script/windows/compute/avg.sim b/tests/script/windows/compute/avg.sim index b655abf1638b290bc8b6c5dd4ac8887da57c8545..7445808db5dbd293e781f66ed7010396413880bc 100644 --- a/tests/script/windows/compute/avg.sim +++ b/tests/script/windows/compute/avg.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/compute/bottom.sim b/tests/script/windows/compute/bottom.sim index dc104a8ebd4c92587f26620df0c13438b2c597bf..18f6c0bd09d1e6ee4cba734dab20f2634e587d32 100644 --- a/tests/script/windows/compute/bottom.sim +++ b/tests/script/windows/compute/bottom.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/compute/count.sim b/tests/script/windows/compute/count.sim index 9c9d8821b01c5fa86f8eefe850c0923f2681d12b..227b49a8bd61d74f242f3f505fddd599a2862cdc 100644 --- a/tests/script/windows/compute/count.sim +++ b/tests/script/windows/compute/count.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/compute/diff.sim b/tests/script/windows/compute/diff.sim index 667fcdbcff7a92c130ee5fe2253f25fd636790c3..bdc5a0e3d8a781bdccc500ef667ad6f568ad8e66 100644 --- a/tests/script/windows/compute/diff.sim +++ b/tests/script/windows/compute/diff.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/first.sim b/tests/script/windows/compute/first.sim index d6e1b1deeaccff9fa5199eed86b1d85d7c541c29..a83939c2a629e13eb474b6b936e7e4b409d7329e 100644 --- a/tests/script/windows/compute/first.sim +++ b/tests/script/windows/compute/first.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/interval.sim b/tests/script/windows/compute/interval.sim index 4bf548ccf21ad1cf89d6688d1921b9742becbe1f..feacce16066a4b5a06268033dedefe327a9f6fa8 100644 --- a/tests/script/windows/compute/interval.sim +++ b/tests/script/windows/compute/interval.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/last.sim b/tests/script/windows/compute/last.sim index 63d4d3ecbdd9cd000e7a10a814aa19bb741c6880..379a5ae64a48b467ffdae816066e8bc3c956d50c 100644 --- a/tests/script/windows/compute/last.sim +++ b/tests/script/windows/compute/last.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/leastsquare.sim b/tests/script/windows/compute/leastsquare.sim index 69c8fb377b00ad28013ac81f07818151bf387791..20353a409e166243212c072d5596492e251e984b 100644 --- a/tests/script/windows/compute/leastsquare.sim +++ b/tests/script/windows/compute/leastsquare.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/max.sim b/tests/script/windows/compute/max.sim index e480736550781babf036a3ab4af40f81753dc8b6..641b31fe362712e09081f105bacdb11f41f2bb99 100644 --- a/tests/script/windows/compute/max.sim +++ b/tests/script/windows/compute/max.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/min.sim b/tests/script/windows/compute/min.sim index 1ff637cecd27c979bb7c4a978d806726c8c62ff6..3528f573ce4c65ac03ac0c0d6c5502b33979cb17 100644 --- a/tests/script/windows/compute/min.sim +++ b/tests/script/windows/compute/min.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/percentile.sim b/tests/script/windows/compute/percentile.sim index 5e327055a8bfd563691c04ff5cb9ea7fbd9dddc5..fa6212f013b4ec0aa92c06842263fd32be05e1e9 100644 --- a/tests/script/windows/compute/percentile.sim +++ b/tests/script/windows/compute/percentile.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/stddev.sim b/tests/script/windows/compute/stddev.sim index 2aa481248ae511ae0aaa3e2621c05eb9d4ea71e2..eea6c8aa0529d0f8dba9907de76017751fbf3d6f 100644 --- a/tests/script/windows/compute/stddev.sim +++ b/tests/script/windows/compute/stddev.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/sum.sim b/tests/script/windows/compute/sum.sim index 30e98a5b2596306865d774267936e4380a16d2d1..a429ce99e0b2faea0d594cc97c7f232b11c5e781 100644 --- a/tests/script/windows/compute/sum.sim +++ b/tests/script/windows/compute/sum.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/compute/top.sim b/tests/script/windows/compute/top.sim index 9590997ef76b396f37102b46140b8ff58598fb9e..65e448b0fa5fb1dffcaf1e63129099c57a4a9a02 100644 --- a/tests/script/windows/compute/top.sim +++ b/tests/script/windows/compute/top.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/db/basic.sim b/tests/script/windows/db/basic.sim index fffde94d66f1ae30b7632c66ff6444cfe3ba1934..914e456fe1e3a52ca107275b30995f88c37b0415 100644 --- a/tests/script/windows/db/basic.sim +++ b/tests/script/windows/db/basic.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/db/len.sim b/tests/script/windows/db/len.sim index 5afa2496dde23b624b6d54afd18f096c59d47f46..3356165117d3986d9eef4e7dced3bb1b61dd36da 100644 --- a/tests/script/windows/db/len.sim +++ b/tests/script/windows/db/len.sim @@ -1,4 +1,4 @@ -sleep 3000 +sleep 2000 sql connect sql show databases diff --git a/tests/script/windows/field/2.sim b/tests/script/windows/field/2.sim index 8ac6fa1a1b2dd85715b536efdb14dc8b6e6d79a9..e258fbe80efbdde2d1b8f289f5302b74adb8b0f7 100644 --- a/tests/script/windows/field/2.sim +++ b/tests/script/windows/field/2.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/3.sim b/tests/script/windows/field/3.sim index 331e930b3186ad9541912f87e5342046046850cf..e3fe0b0b1162548ccd8ce0d4e5d5606a628abcef 100644 --- a/tests/script/windows/field/3.sim +++ b/tests/script/windows/field/3.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/4.sim b/tests/script/windows/field/4.sim index c6224c46ee2c0064c5fa5ea14a67310fee11d423..aabfe2be2ce76d5fa52fcde85c129b0f4bdf75ac 100644 --- a/tests/script/windows/field/4.sim +++ b/tests/script/windows/field/4.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/5.sim b/tests/script/windows/field/5.sim index d1f40059d027fba7797967c7b65d86457f4fd3b9..874730ff1c9cd341e8c3cc1f9c8d33b228d5b3ad 100644 --- a/tests/script/windows/field/5.sim +++ b/tests/script/windows/field/5.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/6.sim b/tests/script/windows/field/6.sim index 98071f87df11ccd6d5984ce9065485bf2931a6ee..77277df35b2a41bbf7ab759763b9601054b0d5d6 100644 --- a/tests/script/windows/field/6.sim +++ b/tests/script/windows/field/6.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/bigint.sim b/tests/script/windows/field/bigint.sim index bef571f4456dc6a05d6844b28128df4137c39bf4..f912ee968b0955e339340e9ee712b99eb954914a 100644 --- a/tests/script/windows/field/bigint.sim +++ b/tests/script/windows/field/bigint.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/binary.sim b/tests/script/windows/field/binary.sim index 72a356e684bbada0ec1b81ca58303a3f885eca4f..aa641878e4c49463aca22ab3f57b43a558e955f7 100644 --- a/tests/script/windows/field/binary.sim +++ b/tests/script/windows/field/binary.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/bool.sim b/tests/script/windows/field/bool.sim index abc970264dae1346bb2177516b4056c024b69da2..3ef56a1d95082faf54f1e34db4009b8af0e80c6c 100644 --- a/tests/script/windows/field/bool.sim +++ b/tests/script/windows/field/bool.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/double.sim b/tests/script/windows/field/double.sim index e805e0373b83ab440a846139681d040a6c4b7ad1..ef404d28dc306edaf2fe6be00eb83dfb484c23a3 100644 --- a/tests/script/windows/field/double.sim +++ b/tests/script/windows/field/double.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/float.sim b/tests/script/windows/field/float.sim index 4178ab4e1e260ba9251466c53c0cd4da10ee0dc3..8435f31c1fbc3353f87f8abc620184919b32ccbc 100644 --- a/tests/script/windows/field/float.sim +++ b/tests/script/windows/field/float.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/int.sim b/tests/script/windows/field/int.sim index 05dc19094d85110672201436f99f19c19b425db8..781b9394849192725ba5d46e3d669d53838501b7 100644 --- a/tests/script/windows/field/int.sim +++ b/tests/script/windows/field/int.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/single.sim b/tests/script/windows/field/single.sim index 6422b7f6971870d72b6272c77d6109484501eb5e..b6b44020915e57b130c77f2c40e1a7a2e4e1342c 100644 --- a/tests/script/windows/field/single.sim +++ b/tests/script/windows/field/single.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/smallint.sim b/tests/script/windows/field/smallint.sim index 8bf41f45a5e62e584b39daa1ecde34691a922eb2..5f1839226b1d3aabfebfe9b30ad3f8b02d1e21a9 100644 --- a/tests/script/windows/field/smallint.sim +++ b/tests/script/windows/field/smallint.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/field/tinyint.sim b/tests/script/windows/field/tinyint.sim index 16c19ba38d58c407fd91ff43654b502fe9bb2d36..c90ff3f932a3eeb52e1ff607ac0bcacf21fecfe4 100644 --- a/tests/script/windows/field/tinyint.sim +++ b/tests/script/windows/field/tinyint.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/import/basic.sim b/tests/script/windows/import/basic.sim index 491b4f8b3445e616d75da1ca70058b1fe49089f9..ee19893ae21fd8c97eeb9aa5898ead86b8b8d19f 100644 --- a/tests/script/windows/import/basic.sim +++ b/tests/script/windows/import/basic.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/insert/basic.sim b/tests/script/windows/insert/basic.sim index 54cbd3f4d9a8ee068ff4595f15f0642ca3e92674..a516f80e1013a40a8889ca939ca650360e4fc976 100644 --- a/tests/script/windows/insert/basic.sim +++ b/tests/script/windows/insert/basic.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/insert/query_block1_file.sim b/tests/script/windows/insert/query_block1_file.sim index 388ed061e5c583ec46113811542b2f87267b860e..62b74ac19c18a624d41941e8c51a3e8fb87ddee0 100644 --- a/tests/script/windows/insert/query_block1_file.sim +++ b/tests/script/windows/insert/query_block1_file.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/insert/query_block1_memory.sim b/tests/script/windows/insert/query_block1_memory.sim index 9e4fc68d093d07d5c43797efc28265de750c376c..6c3e58d70e992a79bfcd84a670616b9b3441393f 100644 --- a/tests/script/windows/insert/query_block1_memory.sim +++ b/tests/script/windows/insert/query_block1_memory.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/insert/query_block2_file.sim b/tests/script/windows/insert/query_block2_file.sim index 9fd443447612917fd0ba85a9d8a591a7a384b87c..164c8a1124eb7648c2cb0d39a1dba3839849aab4 100644 --- a/tests/script/windows/insert/query_block2_file.sim +++ b/tests/script/windows/insert/query_block2_file.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/insert/query_block2_memory.sim b/tests/script/windows/insert/query_block2_memory.sim index ede7f3efc6e807492845786f5979e14a6ba337c6..f3ceb503acfebae398856d1a2d085fd0e3a0ce2d 100644 --- a/tests/script/windows/insert/query_block2_memory.sim +++ b/tests/script/windows/insert/query_block2_memory.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/insert/query_file_memory.sim b/tests/script/windows/insert/query_file_memory.sim index 083beb4ac5f3983eb90a0d38811398dff510c0a7..d9752c40c9cc7c264a86e245eb3877fc47783b2a 100644 --- a/tests/script/windows/insert/query_file_memory.sim +++ b/tests/script/windows/insert/query_file_memory.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/insert/query_multi_file.sim b/tests/script/windows/insert/query_multi_file.sim index 465970f9426440262f2a694c510ba40d184f7f64..ba617ce63c6886bc978fe732222a54a7a99ad4d5 100644 --- a/tests/script/windows/insert/query_multi_file.sim +++ b/tests/script/windows/insert/query_multi_file.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/table/binary.sim b/tests/script/windows/table/binary.sim index 64a081c72f5e4e5bd26013df03d7667211b4dce5..5efa0bc6667c4f2418e53f341315bf6529527455 100644 --- a/tests/script/windows/table/binary.sim +++ b/tests/script/windows/table/binary.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/table/bool.sim b/tests/script/windows/table/bool.sim index 9486c422215f39fac909af7620452dd3443eef8d..0d185d31e81c34d7289d753cce63ec419612646b 100644 --- a/tests/script/windows/table/bool.sim +++ b/tests/script/windows/table/bool.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/table/column_name.sim b/tests/script/windows/table/column_name.sim index fffb1334e5e317e6d22155abf4624463bfce9989..6f9f954461c6faaddb01ab8e327c008a86809bbd 100644 --- a/tests/script/windows/table/column_name.sim +++ b/tests/script/windows/table/column_name.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/table/column_num.sim b/tests/script/windows/table/column_num.sim index d182696ce08176f7d19c74858c069f1cdf73dd4c..395ee02cdea0b90fe8cd248af63cc950c090c283 100644 --- a/tests/script/windows/table/column_num.sim +++ b/tests/script/windows/table/column_num.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/table/column_value.sim b/tests/script/windows/table/column_value.sim index c59e7af8baae9c0b9b5140a624bd9b4c0c97c385..8db85f16ad876deff5c1a4b445351c83e9c5a3b7 100644 --- a/tests/script/windows/table/column_value.sim +++ b/tests/script/windows/table/column_value.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/table/db.table.sim b/tests/script/windows/table/db.table.sim index 97a9e6fbe94db8fec01db3db5e0a0c0335788842..0e207c998276fe4e33d0f875155d971506aadb70 100644 --- a/tests/script/windows/table/db.table.sim +++ b/tests/script/windows/table/db.table.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/table/double.sim b/tests/script/windows/table/double.sim index 93bf3bb1490d21d18c56bea0fc2e2a6535d59b43..b88ac4a199c9394422c7427eda6d824ec524e667 100644 --- a/tests/script/windows/table/double.sim +++ b/tests/script/windows/table/double.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/table/float.sim b/tests/script/windows/table/float.sim index 684f78a386f886b3f2c6f1c2e8510ebe2a1a043f..741525830d9a5ea38d82420e9affcb8015dab1db 100644 --- a/tests/script/windows/table/float.sim +++ b/tests/script/windows/table/float.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/table/table.sim b/tests/script/windows/table/table.sim index 985620152afae21b4c7c239bb80196bbe8facca2..13d157627720e9f5c8a355255782b10ea43b4a58 100644 --- a/tests/script/windows/table/table.sim +++ b/tests/script/windows/table/table.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ============================ dnode1 start sql show databases diff --git a/tests/script/windows/table/table_len.sim b/tests/script/windows/table/table_len.sim index 367f1c6895c80fb019a68bc36f0921becf1f30c7..72ed549466a61e984a0d9f287639a590c7d07f79 100644 --- a/tests/script/windows/table/table_len.sim +++ b/tests/script/windows/table/table_len.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/tag/3.sim b/tests/script/windows/tag/3.sim index 63a8766727fbdc14ce4504949a48bad7be6b5f64..5479be158ba4ab0be883d1f0eb26d2eb09aaafa1 100644 --- a/tests/script/windows/tag/3.sim +++ b/tests/script/windows/tag/3.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/4.sim b/tests/script/windows/tag/4.sim index 7e9af7ece7ebc8f3548dcacd3c26b094a9990160..17552010b0382db3e9cc7e0bafdecdefff03dd96 100644 --- a/tests/script/windows/tag/4.sim +++ b/tests/script/windows/tag/4.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/5.sim b/tests/script/windows/tag/5.sim index 5dc128a0e0eb68eb2a4c227ade718708224c5f8c..f06d78e7b5b4082699349e12ee99c96e110fa91b 100644 --- a/tests/script/windows/tag/5.sim +++ b/tests/script/windows/tag/5.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/6.sim b/tests/script/windows/tag/6.sim index 12e9c597f0deb9ec00ef70ae9cccb761f79cfbc6..64cb9df6f030d4c0314d533fb6239daf7ba3586e 100644 --- a/tests/script/windows/tag/6.sim +++ b/tests/script/windows/tag/6.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/add.sim b/tests/script/windows/tag/add.sim index 0a1416b68c34245a1ef6553a7d19b7601b34de79..02d027ccf4e43c472a1d8b60daa99d254b2df35c 100644 --- a/tests/script/windows/tag/add.sim +++ b/tests/script/windows/tag/add.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/bigint.sim b/tests/script/windows/tag/bigint.sim index d988ad1fdc6dca3616785a7646efc6fbf9f0d466..ebb67d452c82586d31f673d7c9c5c78249285795 100644 --- a/tests/script/windows/tag/bigint.sim +++ b/tests/script/windows/tag/bigint.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/binary.sim b/tests/script/windows/tag/binary.sim index 9dc18cfa94bba50e748edc48beabc40f9445243f..c59039b6a6d8ba5d05a653c1f5d40de170e89f15 100644 --- a/tests/script/windows/tag/binary.sim +++ b/tests/script/windows/tag/binary.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/binary_binary.sim b/tests/script/windows/tag/binary_binary.sim index ba688aa80e234e4ffcf117154d0ff45827ddb02f..361a6edb8b3f6d9440a1796bed5ca7c431bcf115 100644 --- a/tests/script/windows/tag/binary_binary.sim +++ b/tests/script/windows/tag/binary_binary.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/bool.sim b/tests/script/windows/tag/bool.sim index a7e5d909c598bc748bd431ba2a1c5d0e4db15ec6..adf12338d089c41fea9e23b65b8dee03f8eb5b46 100644 --- a/tests/script/windows/tag/bool.sim +++ b/tests/script/windows/tag/bool.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/bool_binary.sim b/tests/script/windows/tag/bool_binary.sim index 639f6c5f2f6f80ffe9c9237c0352c4951a1155a3..064677ee407ee9851e45ea3c743b5d95c66e8545 100644 --- a/tests/script/windows/tag/bool_binary.sim +++ b/tests/script/windows/tag/bool_binary.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/bool_int.sim b/tests/script/windows/tag/bool_int.sim index 900cc9e8a181584cbabb5cee2cd7e048449f7f4f..ef5cd27553161345e95d1ca1b0f414ed16394cb1 100644 --- a/tests/script/windows/tag/bool_int.sim +++ b/tests/script/windows/tag/bool_int.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/change.sim b/tests/script/windows/tag/change.sim index 75a976bbb1553960bfd77f6470e8cddabf9db110..4126ea1181e8b554cac2833eb66c27f3d4290071 100644 --- a/tests/script/windows/tag/change.sim +++ b/tests/script/windows/tag/change.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases @@ -175,7 +175,7 @@ sql alter table $mt change tag tgcol3 tgcol9 sql alter table $mt change tag tgcol5 tgcol10 sql alter table $mt change tag tgcol6 tgcol11 -sleep 5000 +sleep 3000 sql reset query cache print =============== step2 diff --git a/tests/script/windows/tag/column.sim b/tests/script/windows/tag/column.sim index 9f5bfce07e724d6aaec5268f6d85a67805f92209..40159bcae347e1292e2c327110bc4db6b7176bbb 100644 --- a/tests/script/windows/tag/column.sim +++ b/tests/script/windows/tag/column.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/create.sim b/tests/script/windows/tag/create.sim index 6a76c93d83db0afa3e9e9b2de00d614fad66d9e6..62dc8a7a21c442b0a38fd067da0d55ad5c8ed8ef 100644 --- a/tests/script/windows/tag/create.sim +++ b/tests/script/windows/tag/create.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/delete.sim b/tests/script/windows/tag/delete.sim index 9e8ea9aba03c99d116d0923bd27006c34c0253a2..2b503fdf47ac2eaa5ea18c8c6af1bbbe05e9c44c 100644 --- a/tests/script/windows/tag/delete.sim +++ b/tests/script/windows/tag/delete.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases @@ -409,7 +409,7 @@ sql alter table $mt drop tag tgcol3 sql alter table $mt drop tag tgcol4 sql alter table $mt drop tag tgcol6 -sleep 5000 +sleep 3000 print =============== step2 $i = 2 diff --git a/tests/script/windows/tag/double.sim b/tests/script/windows/tag/double.sim index 5445b1dbea083ea6664350c66b6342e606213678..4381aa20f939d79ac81804a5be54952db7a27ba4 100644 --- a/tests/script/windows/tag/double.sim +++ b/tests/script/windows/tag/double.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/filter.sim b/tests/script/windows/tag/filter.sim index f704f32cd2b5ead591ef76ed2237099273ba95a4..802e9a312f8cccbc34bb537dbba5ec3ab13b11d5 100644 --- a/tests/script/windows/tag/filter.sim +++ b/tests/script/windows/tag/filter.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/float.sim b/tests/script/windows/tag/float.sim index 64424c1e209bea2fc3a8c3aaa20dec4e03539587..8df44c24a56d8c013af7c63aa9d45b720069cbaa 100644 --- a/tests/script/windows/tag/float.sim +++ b/tests/script/windows/tag/float.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/int.sim b/tests/script/windows/tag/int.sim index 7d7b5271d194df316b1cc1ac6cd4db9e45bbe2ff..dbff8c15b6aad716a1c90ad5c74269f955c7307d 100644 --- a/tests/script/windows/tag/int.sim +++ b/tests/script/windows/tag/int.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/int_binary.sim b/tests/script/windows/tag/int_binary.sim index 1dd4771605046b8b54d89d54155f41fa9f751b69..94aa9eb7f40441f5cc4e399ac8a4f5f5ce396beb 100644 --- a/tests/script/windows/tag/int_binary.sim +++ b/tests/script/windows/tag/int_binary.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/int_float.sim b/tests/script/windows/tag/int_float.sim index cdb9032d8cc39780f7b71297901914e86bfc1ad2..9789c9ea06640432e8866a787ec0389ed3d239c2 100644 --- a/tests/script/windows/tag/int_float.sim +++ b/tests/script/windows/tag/int_float.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/set.sim b/tests/script/windows/tag/set.sim index 16103c6ce86cf62c8e8a228bebeaf931190435c4..54b87c7d0c1c4eac55a16d42b61979329a31167d 100644 --- a/tests/script/windows/tag/set.sim +++ b/tests/script/windows/tag/set.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/smallint.sim b/tests/script/windows/tag/smallint.sim index dbab4f2d43c86578c7726ca8db23863ec24f335a..bc668b164d53309512d69434e021f5744da2a253 100644 --- a/tests/script/windows/tag/smallint.sim +++ b/tests/script/windows/tag/smallint.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/tag/tinyint.sim b/tests/script/windows/tag/tinyint.sim index 7a0237c0d9dd9a02845774ad5102226955c83b38..44fc9ba4dc0d0f4a670c3c03abf36a38f658f878 100644 --- a/tests/script/windows/tag/tinyint.sim +++ b/tests/script/windows/tag/tinyint.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 print ======================== dnode1 start sql show databases diff --git a/tests/script/windows/vector/metrics_field.sim b/tests/script/windows/vector/metrics_field.sim index e7c926e141bc90531adea7dac389a7c9f59d7fdf..dfaa7e1d9978357f5858e529ebac40941dd6bf2c 100644 --- a/tests/script/windows/vector/metrics_field.sim +++ b/tests/script/windows/vector/metrics_field.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/metrics_mix.sim b/tests/script/windows/vector/metrics_mix.sim index 3d94a9638520961119740ba14628dca4143d6040..111fdebb05735057a922ce313d9c595a7d8491ff 100644 --- a/tests/script/windows/vector/metrics_mix.sim +++ b/tests/script/windows/vector/metrics_mix.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/metrics_query.sim b/tests/script/windows/vector/metrics_query.sim index c292c6b306da676dfcc7e94fc8db30b1533848db..45e734f468deb4fb1567260fdde8b072bdb2a3b2 100644 --- a/tests/script/windows/vector/metrics_query.sim +++ b/tests/script/windows/vector/metrics_query.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/metrics_tag.sim b/tests/script/windows/vector/metrics_tag.sim index f51a449d7171fcc1ad277b16d37be4e03e23f33f..80c204fa10e963fa264aa8f64d116cfc5ee1277f 100644 --- a/tests/script/windows/vector/metrics_tag.sim +++ b/tests/script/windows/vector/metrics_tag.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/metrics_time.sim b/tests/script/windows/vector/metrics_time.sim index 716f49d1e5ffeff106914626ac293e8cf0cc0c9e..c127fe78fc1acf712cc5505a680477c0e52d8514 100644 --- a/tests/script/windows/vector/metrics_time.sim +++ b/tests/script/windows/vector/metrics_time.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/multi.sim b/tests/script/windows/vector/multi.sim index 415384d2434ac0f54d3db639421406bc5c854859..ff63cda9a5777a3f20102aafb388f9a7b491a972 100644 --- a/tests/script/windows/vector/multi.sim +++ b/tests/script/windows/vector/multi.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/single.sim b/tests/script/windows/vector/single.sim index f3f3862e54291fcd9cbeddcc684f94c055d78b19..fb3a52760b4efb5133998a9d71d0b7ce2957e69b 100644 --- a/tests/script/windows/vector/single.sim +++ b/tests/script/windows/vector/single.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/table_field.sim b/tests/script/windows/vector/table_field.sim index 0c5df695fb25a6e0f13a5f3e309ad5b203b94962..10c5148243793adbd01221743cbda673ae7ce651 100644 --- a/tests/script/windows/vector/table_field.sim +++ b/tests/script/windows/vector/table_field.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/table_mix.sim b/tests/script/windows/vector/table_mix.sim index 3d660b5611e770ce99a934e11847dd23584387b5..7418cb453df7fc627acc9f34598db6ce7db144d9 100644 --- a/tests/script/windows/vector/table_mix.sim +++ b/tests/script/windows/vector/table_mix.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/table_query.sim b/tests/script/windows/vector/table_query.sim index 27fcd0f65450380411a7f18c5db2099c6d8c93a3..7654688b269eb16c278c000d9da565515512062a 100644 --- a/tests/script/windows/vector/table_query.sim +++ b/tests/script/windows/vector/table_query.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/script/windows/vector/table_time.sim b/tests/script/windows/vector/table_time.sim index 8a3804c6196375c84a2a49e19f3b42c8d7b57ec8..bea9d41d1bcdfa77acd5eaf52a2de22353b075d9 100644 --- a/tests/script/windows/vector/table_time.sim +++ b/tests/script/windows/vector/table_time.sim @@ -1,5 +1,5 @@ sql connect -sleep 3000 +sleep 2000 sql show databases sql drop database $data00 -x e1 diff --git a/tests/test-all.sh b/tests/test-all.sh index 0c1f55f5f019b102fb35ad800de7627a72cc2d9a..bcbf013096db2fa94cf4f2f2cea239e41e9047e8 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -20,11 +20,22 @@ function runSimCaseOneByOne { while read -r line; do if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then case=`echo $line | grep sim$ |awk '{print $NF}'` - + IN_TDINTERNAL="community" start_time=`date +%s` - ./test.sh -f $case > /dev/null 2>&1 && \ - echo -e "${GREEN}$case success${NC}" | tee -a out.log || \ - echo -e "${RED}$case failed${NC}" | tee -a out.log + IN_TDINTERNAL="community" + if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + echo -n $case + ./test.sh -f $case > /dev/null 2>&1 && \ + ( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ + ( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ + echo -e "${RED} failed${NC}" | tee -a out.log + else + echo -n $case + ./test.sh -f $case > /dev/null 2>&1 && \ + ( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ + ( grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ + echo -e "${RED} failed${NC}" | tee -a out.log + fi out_log=`tail -1 out.log ` # if [[ $out_log =~ 'failed' ]];then # exit 8 @@ -42,13 +53,17 @@ function runSimCaseOneByOnefq { start_time=`date +%s` IN_TDINTERNAL="community" if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then + echo -n $case ./test.sh -f $case > /dev/null 2>&1 && \ - echo -e "${GREEN}$case success${NC}" | tee -a out.log || \ - ( grep 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN}$case success${NC}" | tee -a out.log ) || echo -e "${RED}$case failed${NC}" | tee -a out.log + ( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ + ( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ + echo -e "${RED} failed${NC}" | tee -a out.log else + echo -n $case ./test.sh -f $case > /dev/null 2>&1 && \ - echo -e "${GREEN}$case success${NC}" | tee -a out.log || \ - ( grep 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN}$case success${NC}" | tee -a out.log ) || echo -e "${RED}$case failed${NC}" | tee -a out.log + ( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ + ( grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ + echo -e "${RED} failed${NC}" | tee -a out.log fi out_log=`tail -1 out.log ` @@ -77,9 +92,10 @@ function runPyCaseOneByOne { case=`echo $line|awk '{print $NF}'` fi start_time=`date +%s` + echo -n $case $line > /dev/null 2>&1 && \ - echo -e "${GREEN}$case success${NC}" | tee -a pytest-out.log || \ - echo -e "${RED}$case failed${NC}" | tee -a pytest-out.log + echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \ + echo -e "${RED} failed${NC}" | tee -a pytest-out.log end_time=`date +%s` out_log=`tail -1 pytest-out.log ` # if [[ $out_log =~ 'failed' ]];then @@ -103,9 +119,10 @@ function runPyCaseOneByOnefq { case=`echo $line|awk '{print $NF}'` fi start_time=`date +%s` + echo -n $case $line > /dev/null 2>&1 && \ - echo -e "${GREEN}$case success${NC}" | tee -a pytest-out.log || \ - echo -e "${RED}$case failed${NC}" | tee -a pytest-out.log + echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \ + echo -e "${RED} failed${NC}" | tee -a pytest-out.log end_time=`date +%s` out_log=`tail -1 pytest-out.log ` if [[ $out_log =~ 'failed' ]];then @@ -138,7 +155,7 @@ if [ "$2" != "python" ]; then elif [ "$1" == "b1" ]; then echo "### run TSIM b1 test ###" runSimCaseOneByOne jenkins/basic_1.txt - runSimCaseOneByOne jenkins/basic_4.txt + # runSimCaseOneByOne jenkins/basic_4.txt elif [ "$1" == "b2" ]; then echo "### run TSIM b2 test ###" runSimCaseOneByOne jenkins/basic_2.txt diff --git a/tests/tsim/src/simMain.c b/tests/tsim/src/simMain.c index 8f13254f68165a9e26ecac2406538f8cba905120..f30442ef41602ff276a704c358afb410eb6f76c9 100644 --- a/tests/tsim/src/simMain.c +++ b/tests/tsim/src/simMain.c @@ -20,6 +20,7 @@ #undef TAOS_MEM_CHECK bool simAsyncQuery = false; +bool simExecSuccess = false; void simHandleSignal(int32_t signo) { simSystemCleanUp(); @@ -62,5 +63,8 @@ int32_t main(int32_t argc, char *argv[]) { simScriptList[++simScriptPos] = script; simExecuteScript(script); - return 0; + int32_t ret = simExecSuccess ? 0 : -1; + simError("execute result %d", ret); + + return ret; } \ No newline at end of file diff --git a/tests/tsim/src/simSystem.c b/tests/tsim/src/simSystem.c index bf47c56718b7377aa5cd4fd48269eec0fc9e0b38..2a1048334abcbf88af46ac5cbc7b16422b8bb5db 100644 --- a/tests/tsim/src/simSystem.c +++ b/tests/tsim/src/simSystem.c @@ -21,6 +21,7 @@ #include "ttimer.h" #include "tutil.h" #include "tsocket.h" +#include "taoserror.h" #undef TAOS_MEM_CHECK SScript *simScriptList[MAX_MAIN_SCRIPT_NUM]; @@ -31,6 +32,8 @@ int32_t simDebugFlag = 135; void simCloseTaosdConnect(SScript *script); char simHostName[128]; +extern bool simExecSuccess; + char *simParseArbitratorName(char *varName) { static char hostName[140]; sprintf(hostName, "%s:%d", simHostName, 8000); @@ -118,10 +121,12 @@ SScript *simProcessCallOver(SScript *script) { if (script->type == SIM_SCRIPT_TYPE_MAIN) { simDebug("script:%s, is main script, set stop flag", script->fileName); if (script->killed) { + simExecSuccess = false; simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX "failed" FAILED_POSTFIX ", error:%s", script->fileName, script->error); return NULL; } else { + simExecSuccess = true; simInfo("script:" SUCCESS_PREFIX "%s" SUCCESS_POSTFIX ", " SUCCESS_PREFIX "success" SUCCESS_POSTFIX, script->fileName); simCloseTaosdConnect(script);