diff --git a/Jenkinsfile b/Jenkinsfile index 882d224407c27a06bacd96ff246dfc8d84e264a8..6109e4811a34fb159e6b17c3bf7c5af3c884ea3d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -265,12 +265,12 @@ pipeline { } } timeout(time: 60, unit: 'MINUTES'){ - sh ''' - cd ${WKC}/tests/pytest - rm -rf /var/lib/taos/* - rm -rf /var/log/taos/* - ./handle_crash_gen_val_log.sh - ''' + // sh ''' + // cd ${WKC}/tests/pytest + // rm -rf /var/lib/taos/* + // rm -rf /var/log/taos/* + // ./handle_crash_gen_val_log.sh + // ''' sh ''' cd ${WKC}/tests/pytest rm -rf /var/lib/taos/* diff --git a/deps/TSZ b/deps/TSZ index ceda5bf9fcd7836509ac97dcc0056b3f1dd48cc5..0ca5b15a8eac40327dd737be52c926fa5675712c 160000 --- a/deps/TSZ +++ b/deps/TSZ @@ -1 +1 @@ -Subproject commit ceda5bf9fcd7836509ac97dcc0056b3f1dd48cc5 +Subproject commit 0ca5b15a8eac40327dd737be52c926fa5675712c diff --git a/documentation20/cn/08.connector/01.java/docs.md b/documentation20/cn/08.connector/01.java/docs.md index a5f0d21ef82bad7e89d74ed3ac68b378558fbe3f..edd81a49cd334859fd9581a601822ee782bad45a 100644 --- a/documentation20/cn/08.connector/01.java/docs.md +++ b/documentation20/cn/08.connector/01.java/docs.md @@ -46,7 +46,7 @@ TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致 -注意:与 JNI 方式不同,RESTful 接口是无状态的。在使用JDBC-RESTful时,需要在sql中指定表、超级表的数据库名称。例如: +注意:与 JNI 方式不同,RESTful 接口是无状态的。在使用JDBC-RESTful时,需要在sql中指定表、超级表的数据库名称。(从 TDengine 2.1.8.0 版本开始,也可以在 RESTful url 中指定当前 SQL 语句所使用的默认数据库名。)例如: ```sql INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES(now, 24.6); ``` diff --git a/documentation20/cn/08.connector/docs.md b/documentation20/cn/08.connector/docs.md index 0ac5a91b507b451d33ea692e79e20aaa205677cc..ea3f9a4d55181e319848e1a5e14abb1409a3a5e9 100644 --- a/documentation20/cn/08.connector/docs.md +++ b/documentation20/cn/08.connector/docs.md @@ -654,22 +654,23 @@ conn.close() 为支持各种不同类型平台的开发,TDengine 提供符合 REST 设计标准的 API,即 RESTful API。为最大程度降低学习成本,不同于其他数据库 RESTful API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。RESTful 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。 -注意:与标准连接器的一个区别是,RESTful 接口是无状态的,因此 `USE db_name` 指令没有效果,所有对表名、超级表名的引用都需要指定数据库名前缀。 +注意:与标准连接器的一个区别是,RESTful 接口是无状态的,因此 `USE db_name` 指令没有效果,所有对表名、超级表名的引用都需要指定数据库名前缀。(从 2.1.8.0 版本开始,支持在 RESTful url 中指定 db_name,这时如果 SQL 语句中没有指定数据库名前缀的话,会使用 url 中指定的这个 db_name。) ### 安装 -RESTful接口不依赖于任何TDengine的库,因此客户端不需要安装任何TDengine的库,只要客户端的开发语言支持HTTP协议即可。 +RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安装任何 TDengine 的库,只要客户端的开发语言支持 HTTP 协议即可。 ### 验证 -在已经安装TDengine服务器端的情况下,可以按照如下方式进行验证。 +在已经安装 TDengine 服务器端的情况下,可以按照如下方式进行验证。 -下面以Ubuntu环境中使用curl工具(确认已经安装)来验证RESTful接口的正常。 +下面以 Ubuntu 环境中使用 curl 工具(确认已经安装)来验证 RESTful 接口的正常。 -下面示例是列出所有的数据库,请把h1.taosdata.com和6041(缺省值)替换为实际运行的TDengine服务fqdn和端口号: +下面示例是列出所有的数据库,请把 h1.taosdata.com 和 6041(缺省值)替换为实际运行的 TDengine 服务 fqdn 和端口号: ```html curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' h1.taosdata.com:6041/rest/sql ``` + 返回值结果如下表示验证通过: ```json { @@ -682,22 +683,23 @@ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' h1.taos } ``` -### RESTful连接器的使用 +### RESTful 连接器的使用 -#### HTTP请求格式 +#### HTTP 请求格式 ``` -http://:/rest/sql +http://:/rest/sql/[db_name] ``` 参数说明: -- fqnd: 集群中的任一台主机FQDN或IP地址 -- port: 配置文件中httpPort配置项,缺省为6041 +- fqnd: 集群中的任一台主机 FQDN 或 IP 地址 +- port: 配置文件中 httpPort 配置项,缺省为 6041 +- db_name: 可选参数,指定本次所执行的 SQL 语句的默认数据库库名。(从 2.1.8.0 版本开始支持) -例如:http://h1.taos.com:6041/rest/sql 是指向地址为h1.taos.com:6041的url。 +例如:http://h1.taos.com:6041/rest/sql/test 是指向地址为 h1.taos.com:6041 的 url,并将默认使用的数据库库名设置为 test。 -HTTP请求的Header里需带有身份认证信息,TDengine支持Basic认证与自定义认证两种机制,后续版本将提供标准安全的数字签名机制来做身份验证。 +HTTP 请求的 Header 里需带有身份认证信息,TDengine 支持 Basic 认证与自定义认证两种机制,后续版本将提供标准安全的数字签名机制来做身份验证。 - 自定义身份认证信息如下所示(稍后介绍) @@ -711,25 +713,25 @@ Authorization: Taosd Authorization: Basic ``` -HTTP请求的BODY里就是一个完整的SQL语句,SQL语句中的数据表应提供数据库前缀,例如\.\。如果表名不带数据库前缀,系统会返回错误。因为HTTP模块只是一个简单的转发,没有当前DB的概念。 +HTTP 请求的 BODY 里就是一个完整的 SQL 语句,SQL 语句中的数据表应提供数据库前缀,例如 \.\。如果表名不带数据库前缀,又没有在 url 中指定数据库名的话,系统会返回错误。因为 HTTP 模块只是一个简单的转发,没有当前 DB 的概念。 -使用curl通过自定义身份认证方式来发起一个HTTP Request,语法如下: +使用 curl 通过自定义身份认证方式来发起一个 HTTP Request,语法如下: ```bash -curl -H 'Authorization: Basic ' -d '' :/rest/sql +curl -H 'Authorization: Basic ' -d '' :/rest/sql/[db_name] ``` 或者 ```bash -curl -u username:password -d '' :/rest/sql +curl -u username:password -d '' :/rest/sql/[db_name] ``` -其中,`TOKEN`为`{username}:{password}`经过Base64编码之后的字符串,例如`root:taosdata`编码后为`cm9vdDp0YW9zZGF0YQ==` +其中,`TOKEN` 为 `{username}:{password}` 经过 Base64 编码之后的字符串,例如 `root:taosdata` 编码后为 `cm9vdDp0YW9zZGF0YQ==` -### HTTP返回格式 +### HTTP 返回格式 -返回值为JSON格式,如下: +返回值为 JSON 格式,如下: ```json { @@ -747,9 +749,9 @@ curl -u username:password -d '' :/rest/sql 说明: - status: 告知操作结果是成功还是失败。 -- head: 表的定义,如果不返回结果集,则仅有一列“affected_rows”。(从 2.0.17.0 版本开始,建议不要依赖 head 返回值来判断数据列类型,而推荐使用 column_meta。在未来版本中,有可能会从返回值中去掉 head 这一项。) +- head: 表的定义,如果不返回结果集,则仅有一列 “affected_rows”。(从 2.0.17.0 版本开始,建议不要依赖 head 返回值来判断数据列类型,而推荐使用 column_meta。在未来版本中,有可能会从返回值中去掉 head 这一项。) - column_meta: 从 2.0.17.0 版本开始,返回值中增加这一项来说明 data 里每一列的数据类型。具体每个列会用三个值来说明,分别为:列名、列类型、类型长度。例如`["current",6,4]`表示列名为“current”;列类型为 6,也即 float 类型;类型长度为 4,也即对应 4 个字节表示的 float。如果列类型为 binary 或 nchar,则类型长度表示该列最多可以保存的内容长度,而不是本次返回值中的具体数据长度。当列类型是 nchar 的时候,其类型长度表示可以保存的 unicode 字符数量,而不是 bytes。 -- data: 具体返回的数据,一行一行的呈现,如果不返回结果集,那么就仅有[[affected_rows]]。data 中每一行的数据列顺序,与 column_meta 中描述数据列的顺序完全一致。 +- data: 具体返回的数据,一行一行的呈现,如果不返回结果集,那么就仅有 [[affected_rows]]。data 中每一行的数据列顺序,与 column_meta 中描述数据列的顺序完全一致。 - rows: 表明总共多少行数据。 column_meta 中的列类型说明: @@ -766,13 +768,13 @@ column_meta 中的列类型说明: ### 自定义授权码 -HTTP请求中需要带有授权码``,用于身份识别。授权码通常由管理员提供,可简单的通过发送`HTTP GET`请求来获取授权码,操作如下: +HTTP 请求中需要带有授权码 ``,用于身份识别。授权码通常由管理员提供,可简单的通过发送 `HTTP GET` 请求来获取授权码,操作如下: ```bash curl http://:/rest/login// ``` -其中,`fqdn`是TDengine数据库的fqdn或ip地址,port是TDengine服务的端口号,`username`为数据库用户名,`password`为数据库密码,返回值为`JSON`格式,各字段含义如下: +其中,`fqdn` 是 TDengine 数据库的 fqdn 或 ip 地址,port 是 TDengine 服务的端口号,`username` 为数据库用户名,`password` 为数据库密码,返回值为 `JSON` 格式,各字段含义如下: - status:请求结果的标志位 @@ -798,7 +800,7 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata ### 使用示例 -- 在demo库里查询表d1001的所有记录: +- 在 demo 库里查询表 d1001 的所有记录: ```bash curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql @@ -818,7 +820,7 @@ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001 } ``` -- 创建库demo: +- 创建库 demo: ```bash curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql @@ -837,9 +839,9 @@ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 19 ### 其他用法 -#### 结果集采用Unix时间戳 +#### 结果集采用 Unix 时间戳 -HTTP请求URL采用`sqlt`时,返回结果集的时间戳将采用Unix时间戳格式表示,例如 +HTTP 请求 URL 采用 `sqlt` 时,返回结果集的时间戳将采用 Unix 时间戳格式表示,例如 ```bash curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sqlt @@ -860,9 +862,9 @@ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001 } ``` -#### 结果集采用UTC时间字符串 +#### 结果集采用 UTC 时间字符串 -HTTP请求URL采用`sqlutc`时,返回结果集的时间戳将采用UTC时间字符串表示,例如 +HTTP 请求 URL 采用 `sqlutc` 时,返回结果集的时间戳将采用 UTC 时间字符串表示,例如 ```bash curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.t1' 192.168.0.1:6041/rest/sqlutc ``` @@ -884,13 +886,14 @@ HTTP请求URL采用`sqlutc`时,返回结果集的时间戳将采用UTC时间 ### 重要配置项 -下面仅列出一些与RESTful接口有关的配置参数,其他系统参数请看配置文件里的说明。(注意:配置修改后,需要重启taosd服务才能生效) +下面仅列出一些与 RESTful 接口有关的配置参数,其他系统参数请看配置文件里的说明。(注意:配置修改后,需要重启 taosd 服务才能生效) -- 对外提供RESTful服务的端口号,默认绑定到 6041(实际取值是 serverPort + 11,因此可以通过修改 serverPort 参数的设置来修改) -- httpMaxThreads: 启动的线程数量,默认为2(2.0.17.0版本开始,默认值改为CPU核数的一半向下取整) -- restfulRowLimit: 返回结果集(JSON格式)的最大条数,默认值为10240 -- httpEnableCompress: 是否支持压缩,默认不支持,目前TDengine仅支持gzip压缩格式 -- httpDebugFlag: 日志开关,默认131。131:仅错误和报警信息,135:调试信息,143:非常详细的调试信息,默认131 +- 对外提供 RESTful 服务的端口号,默认绑定到 6041(实际取值是 serverPort + 11,因此可以通过修改 serverPort 参数的设置来修改)。 +- httpMaxThreads: 启动的线程数量,默认为 2(2.0.17.0 版本开始,默认值改为 CPU 核数的一半向下取整)。 +- restfulRowLimit: 返回结果集(JSON 格式)的最大条数,默认值为 10240。 +- httpEnableCompress: 是否支持压缩,默认不支持,目前 TDengine 仅支持 gzip 压缩格式。 +- httpDebugFlag: 日志开关,默认 131。131:仅错误和报警信息,135:调试信息,143:非常详细的调试信息,默认 131。 +- httpDbNameMandatory: 是否必须在 RESTful url 中指定默认的数据库名。默认为 0,即关闭此检查。如果设置为 1,那么每个 RESTful url 中都必须设置一个默认数据库名,否则无论此时执行的 SQL 语句是否需要指定数据库,都会返回一个执行错误,拒绝执行此 SQL 语句。 ## CSharp Connector diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 06e7cb7da01d50b613754b40c56a3cb335cffb37..310369aa14ad5e9e6ccb49843605a92fdc333563 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -194,6 +194,9 @@ keepColumnName 1 # maximum number of rows returned by the restful interface # restfulRowLimit 10240 +# database name must be specified in restful interface if the following parameter is set, off by default +# httpDbNameMandatory 1 + # The following parameter is used to limit the maximum number of lines in log files. # max number of lines per log filters # numOfLogLines 10000000 diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 55ca1174c91dd2a27049cc82733836344e73b90a..07f1d61fad81cd9653de257f47a7de309e664bf1 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -19,6 +19,7 @@ else fi # Dynamic directory + data_dir="/var/lib/taos" if [ "$osType" != "Darwin" ]; then @@ -29,25 +30,32 @@ fi data_link_dir="/usr/local/taos/data" log_link_dir="/usr/local/taos/log" - -cfg_install_dir="/etc/taos" +if [ "$osType" != "Darwin" ]; then + cfg_install_dir="/etc/taos" +else + cfg_install_dir="/usr/local/Cellar/tdengine/${verNumber}/taos" +fi if [ "$osType" != "Darwin" ]; then bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" lib64_link_dir="/usr/lib64" inc_link_dir="/usr/include" -else - bin_link_dir="/usr/local/bin" - lib_link_dir="/usr/local/lib" - inc_link_dir="/usr/local/include" fi #install main path -install_main_dir="/usr/local/taos" +if [ "$osType" != "Darwin" ]; then + install_main_dir="/usr/local/taos" +else + install_main_dir="/usr/local/Cellar/tdengine/${verNumber}" +fi # old bin dir -bin_dir="/usr/local/taos/bin" +if [ "$osType" != "Darwin" ]; then + bin_dir="/usr/local/taos/bin" +else + bin_dir="/usr/local/Cellar/tdengine/${verNumber}/bin" +fi service_config_dir="/etc/systemd/system" @@ -59,12 +67,11 @@ GREEN_UNDERLINE='\033[4;32m' NC='\033[0m' csudo="" -if command -v sudo > /dev/null; then - csudo="sudo" -fi if [ "$osType" != "Darwin" ]; then - + if command -v sudo > /dev/null; then + csudo="sudo" + fi initd_mod=0 service_mod=2 if pidof systemd &> /dev/null; then @@ -137,18 +144,16 @@ function install_main_path() { function install_bin() { # Remove links - ${csudo} rm -f ${bin_link_dir}/taos || : - if [ "$osType" != "Darwin" ]; then + ${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taosd || : ${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/perfMonitor || : ${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${bin_link_dir}/set_core || : + ${csudo} rm -f ${bin_link_dir}/rmtaos || : fi - - ${csudo} rm -f ${bin_link_dir}/rmtaos || : - + ${csudo} cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin ${csudo} cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin @@ -162,20 +167,17 @@ function install_bin() { ${csudo} chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : - if [ "$osType" != "Darwin" ]; then + [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : [ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : [ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${install_main_dir}/bin/perfMonitor ] && ${csudo} ln -s ${install_main_dir}/bin/perfMonitor ${bin_link_dir}/perfMonitor || : [ -x ${install_main_dir}/set_core.sh ] && ${csudo} ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : fi - + if [ "$osType" != "Darwin" ]; then - [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : - else - [ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || : + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : fi } @@ -222,7 +224,7 @@ function install_jemalloc() { fi if [ -d /etc/ld.so.conf.d ]; then - ${csudo} echo "/usr/local/lib" > /etc/ld.so.conf.d/jemalloc.conf + echo "/usr/local/lib" | ${csudo} tee /etc/ld.so.conf.d/jemalloc.conf ${csudo} ldconfig else echo "/etc/ld.so.conf.d not found!" @@ -248,10 +250,8 @@ function install_lib() { fi else ${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* - ${csudo} ln -sf ${install_main_dir}/driver/libtaos.1.dylib ${lib_link_dir}/libtaos.1.dylib - ${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib fi - + install_jemalloc if [ "$osType" != "Darwin" ]; then @@ -261,10 +261,14 @@ function install_lib() { function install_header() { - ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + if [ "$osType" != "Darwin" ]; then + ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || : + fi ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* - ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + if [ "$osType" != "Darwin" ]; then + ${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + fi } function install_config() { @@ -272,29 +276,30 @@ function install_config() { if [ ! -f ${cfg_install_dir}/taos.cfg ]; then ${csudo} mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/../cfg/taos.cfg ] && ${csudo} cp ${script_dir}/../cfg/taos.cfg ${cfg_install_dir} + [ -f ${script_dir}/../cfg/taos.cfg ] && + ${csudo} cp ${script_dir}/../cfg/taos.cfg ${cfg_install_dir} ${csudo} chmod 644 ${cfg_install_dir}/* fi ${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org - ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg + + if [ "$osType" != "Darwin" ]; then ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg + fi } function install_log() { - ${csudo} rm -rf ${log_dir} || : - if [ "$osType" != "Darwin" ]; then - ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} - else - mkdir -p ${log_dir} && chmod 777 ${log_dir} + ${csudo} rm -rf ${log_dir} || : + ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} + ${csudo} ln -s ${log_dir} ${install_main_dir}/log fi - - ${csudo} ln -s ${log_dir} ${install_main_dir}/log } function install_data() { - ${csudo} mkdir -p ${data_dir} - ${csudo} ln -s ${data_dir} ${install_main_dir}/data + if [ "$osType" != "Darwin" ]; then + ${csudo} mkdir -p ${data_dir} + ${csudo} ln -s ${data_dir} ${install_main_dir}/data + fi } function install_connector() { @@ -309,7 +314,6 @@ function install_connector() { echo "WARNING: go connector not found, please check if want to use it!" fi ${csudo} cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector - ${csudo} cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &> /dev/null && ${csudo} chmod 777 ${install_main_dir}/connector/*.jar || echo &> /dev/null } @@ -489,24 +493,24 @@ function install_TDengine() { else echo -e "${GREEN}Start to install TDEngine Client ...${NC}" fi - + install_main_path if [ "$osType" != "Darwin" ]; then install_data fi + install_log install_header install_lib install_connector install_examples - install_bin - + if [ "$osType" != "Darwin" ]; then install_service fi - + install_config if [ "$osType" != "Darwin" ]; then diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 87cc2b854a41c917d0ab5960b002861336e90311..c59ec3e624ec84a76ae805d969a6b319667fb1af 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -36,7 +36,7 @@ extern "C" { (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_CHILD_TABLE)) #define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo) \ - (!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo) || UTIL_TABLE_IS_TMP_TABLE(metaInfo))) + (!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo))) #define UTIL_TABLE_IS_TMP_TABLE(metaInfo) \ (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_TEMP_TABLE)) @@ -365,6 +365,8 @@ STblCond* tsGetTableFilter(SArray* filters, uint64_t uid, int16_t idx); void tscRemoveCachedTableMeta(STableMetaInfo* pTableMetaInfo, uint64_t id); +char* cloneCurrentDBName(SSqlObj* pSql); + #ifdef __cplusplus } #endif diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 9ef34c96388907c631d7f9c087e715b0106fa5c0..b8eb0a5286a7b72b3ddd1d34b103e5b6239a496c 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -492,6 +492,7 @@ bool tscHasReachLimitation(SQueryInfo *pQueryInfo, SSqlRes *pRes); void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32_t numOfCols); char *tscGetErrorMsgPayload(SSqlCmd *pCmd); +int32_t tscErrorMsgWithCode(int32_t code, char* dstBuffer, const char* errMsg, const char* sql); int32_t tscInvalidOperationMsg(char *msg, const char *additionalInfo, const char *sql); int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* sql); diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index eaad78333160a8c7dc0622ec5c670cd28bc517c8..6b12cd0da04c0f791201182c793d647fc54c00b1 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -363,15 +363,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { } if (TSDB_QUERY_HAS_TYPE(pCmd->insertParam.insertType, TSDB_QUERY_TYPE_STMT_INSERT)) { // stmt insert - STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - code = tscGetTableMeta(pSql, pTableMetaInfo); - if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { - taosReleaseRef(tscObjRef, pSql->self); - return; - } else { - assert(code == TSDB_CODE_SUCCESS); - } - (*pSql->fp)(pSql->param, pSql, code); } else if (TSDB_QUERY_HAS_TYPE(pCmd->insertParam.insertType, TSDB_QUERY_TYPE_FILE_INSERT)) { // file insert tscImportDataFromFile(pSql); diff --git a/src/client/src/tscGlobalmerge.c b/src/client/src/tscGlobalmerge.c index 093afc0968f54ef4e7c83148805b32397df83fef..6acbfe3e8929c9a5a46ed0370f6cfb883988ef3e 100644 --- a/src/client/src/tscGlobalmerge.c +++ b/src/client/src/tscGlobalmerge.c @@ -35,6 +35,7 @@ typedef struct SCompareParam { static bool needToMerge(SSDataBlock* pBlock, SArray* columnIndexList, int32_t index, char **buf) { int32_t ret = 0; + size_t size = taosArrayGetSize(columnIndexList); if (size > 0) { ret = compare_aRv(pBlock, columnIndexList, (int32_t) size, index, buf, TSDB_ORDER_ASC); @@ -564,9 +565,11 @@ static void savePrevOrderColumns(char** prevRow, SArray* pColumnList, SSDataBloc (*hasPrev) = true; } +// tsdb_func_tag function only produce one row of result. Therefore, we need to copy the +// output value to multiple rows static void setTagValueForMultipleRows(SQLFunctionCtx* pCtx, int32_t numOfOutput, int32_t numOfRows) { if (numOfRows <= 1) { - return ; + return; } for (int32_t k = 0; k < numOfOutput; ++k) { @@ -574,12 +577,49 @@ static void setTagValueForMultipleRows(SQLFunctionCtx* pCtx, int32_t numOfOutput continue; } - int32_t inc = numOfRows - 1; // tsdb_func_tag function only produce one row of result - char* src = pCtx[k].pOutput; + char* src = pCtx[k].pOutput; + char* dst = pCtx[k].pOutput + pCtx[k].outputBytes; + + // Let's start from the second row, as the first row has result value already. + for (int32_t i = 1; i < numOfRows; ++i) { + memcpy(dst, src, (size_t)pCtx[k].outputBytes); + dst += pCtx[k].outputBytes; + } + } +} + +static void doMergeResultImpl(SMultiwayMergeInfo* pInfo, SQLFunctionCtx *pCtx, int32_t numOfExpr, int32_t rowIndex, char** pDataPtr) { + for (int32_t j = 0; j < numOfExpr; ++j) { + pCtx[j].pInput = pDataPtr[j] + pCtx[j].inputBytes * rowIndex; + } + + for (int32_t j = 0; j < numOfExpr; ++j) { + int32_t functionId = pCtx[j].functionId; + if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { + continue; + } + + if (functionId < 0) { + SUdfInfo* pUdfInfo = taosArrayGet(pInfo->udfInfo, -1 * functionId - 1); + doInvokeUdf(pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_MERGE); + } else { + aAggs[functionId].mergeFunc(&pCtx[j]); + } + } +} + +static void doFinalizeResultImpl(SMultiwayMergeInfo* pInfo, SQLFunctionCtx *pCtx, int32_t numOfExpr) { + for(int32_t j = 0; j < numOfExpr; ++j) { + int32_t functionId = pCtx[j].functionId; + if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { + continue; + } - for (int32_t i = 0; i < inc; ++i) { - pCtx[k].pOutput += pCtx[k].outputBytes; - memcpy(pCtx[k].pOutput, src, (size_t)pCtx[k].outputBytes); + if (functionId < 0) { + SUdfInfo* pUdfInfo = taosArrayGet(pInfo->udfInfo, -1 * functionId - 1); + doInvokeUdf(pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_FINALIZE); + } else { + aAggs[functionId].xFinalize(&pCtx[j]); } } } @@ -588,52 +628,18 @@ static void doExecuteFinalMerge(SOperatorInfo* pOperator, int32_t numOfExpr, SSD SMultiwayMergeInfo* pInfo = pOperator->info; SQLFunctionCtx* pCtx = pInfo->binfo.pCtx; - char** add = calloc(pBlock->info.numOfCols, POINTER_BYTES); + char** addrPtr = calloc(pBlock->info.numOfCols, POINTER_BYTES); for(int32_t i = 0; i < pBlock->info.numOfCols; ++i) { - add[i] = pCtx[i].pInput; + addrPtr[i] = pCtx[i].pInput; pCtx[i].size = 1; } for(int32_t i = 0; i < pBlock->info.rows; ++i) { if (pInfo->hasPrev) { if (needToMerge(pBlock, pInfo->orderColumnList, i, pInfo->prevRow)) { - for (int32_t j = 0; j < numOfExpr; ++j) { - pCtx[j].pInput = add[j] + pCtx[j].inputBytes * i; - } - - for (int32_t j = 0; j < numOfExpr; ++j) { - int32_t functionId = pCtx[j].functionId; - if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { - continue; - } - - if (functionId < 0) { - SUdfInfo* pUdfInfo = taosArrayGet(pInfo->udfInfo, -1 * functionId - 1); - - doInvokeUdf(pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_MERGE); - - continue; - } - - aAggs[functionId].mergeFunc(&pCtx[j]); - } + doMergeResultImpl(pInfo, pCtx, numOfExpr, i, addrPtr); } else { - for(int32_t j = 0; j < numOfExpr; ++j) { // TODO refactor - int32_t functionId = pCtx[j].functionId; - if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { - continue; - } - - if (functionId < 0) { - SUdfInfo* pUdfInfo = taosArrayGet(pInfo->udfInfo, -1 * functionId - 1); - - doInvokeUdf(pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_FINALIZE); - - continue; - } - - aAggs[functionId].xFinalize(&pCtx[j]); - } + doFinalizeResultImpl(pInfo, pCtx, numOfExpr); int32_t numOfRows = getNumOfResult(pOperator->pRuntimeEnv, pInfo->binfo.pCtx, pOperator->numOfOutput); setTagValueForMultipleRows(pCtx, pOperator->numOfOutput, numOfRows); @@ -655,48 +661,10 @@ static void doExecuteFinalMerge(SOperatorInfo* pOperator, int32_t numOfExpr, SSD aAggs[pCtx[j].functionId].init(&pCtx[j], pCtx[j].resultInfo); } - for (int32_t j = 0; j < numOfExpr; ++j) { - pCtx[j].pInput = add[j] + pCtx[j].inputBytes * i; - } - - for (int32_t j = 0; j < numOfExpr; ++j) { - int32_t functionId = pCtx[j].functionId; - if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { - continue; - } - - if (functionId < 0) { - SUdfInfo* pUdfInfo = taosArrayGet(pInfo->udfInfo, -1 * functionId - 1); - - doInvokeUdf(pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_MERGE); - - continue; - } - - aAggs[functionId].mergeFunc(&pCtx[j]); - } + doMergeResultImpl(pInfo, pCtx, numOfExpr, i, addrPtr); } } else { - for (int32_t j = 0; j < numOfExpr; ++j) { - pCtx[j].pInput = add[j] + pCtx[j].inputBytes * i; - } - - for (int32_t j = 0; j < numOfExpr; ++j) { - int32_t functionId = pCtx[j].functionId; - if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { - continue; - } - - if (functionId < 0) { - SUdfInfo* pUdfInfo = taosArrayGet(pInfo->udfInfo, -1 * functionId - 1); - - doInvokeUdf(pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_MERGE); - - continue; - } - - aAggs[functionId].mergeFunc(&pCtx[j]); - } + doMergeResultImpl(pInfo, pCtx, numOfExpr, i, addrPtr); } savePrevOrderColumns(pInfo->prevRow, pInfo->orderColumnList, pBlock, i, &pInfo->hasPrev); @@ -704,11 +672,11 @@ static void doExecuteFinalMerge(SOperatorInfo* pOperator, int32_t numOfExpr, SSD { for(int32_t i = 0; i < pBlock->info.numOfCols; ++i) { - pCtx[i].pInput = add[i]; + pCtx[i].pInput = addrPtr[i]; } } - tfree(add); + tfree(addrPtr); } static bool isAllSourcesCompleted(SGlobalMerger *pMerger) { @@ -816,6 +784,8 @@ SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup) { SLocalDataSource *pOneDataSrc = pMerger->pLocalDataSrc[pTree->pNode[0].index]; bool sameGroup = true; if (pInfo->hasPrev) { + + // todo refactor extract method int32_t numOfCols = (int32_t)taosArrayGetSize(pInfo->orderColumnList); // if this row belongs to current result set group @@ -955,9 +925,10 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) { break; } + bool sameGroup = true; if (pAggInfo->hasGroupColData) { - bool sameGroup = isSameGroup(pAggInfo->groupColumnList, pBlock, pAggInfo->currentGroupColData); - if (!sameGroup) { + sameGroup = isSameGroup(pAggInfo->groupColumnList, pBlock, pAggInfo->currentGroupColData); + if (!sameGroup && !pAggInfo->multiGroupResults) { *newgroup = true; pAggInfo->hasDataBlockForNewGroup = true; pAggInfo->pExistBlock = pBlock; @@ -976,26 +947,10 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) { } if (handleData) { // data in current group is all handled - for(int32_t j = 0; j < pOperator->numOfOutput; ++j) { - int32_t functionId = pAggInfo->binfo.pCtx[j].functionId; - if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { - continue; - } - - if (functionId < 0) { - SUdfInfo* pUdfInfo = taosArrayGet(pAggInfo->udfInfo, -1 * functionId - 1); - - doInvokeUdf(pUdfInfo, &pAggInfo->binfo.pCtx[j], 0, TSDB_UDF_FUNC_FINALIZE); - - continue; - } - - aAggs[functionId].xFinalize(&pAggInfo->binfo.pCtx[j]); - } - + doFinalizeResultImpl(pAggInfo, pAggInfo->binfo.pCtx, pOperator->numOfOutput); int32_t numOfRows = getNumOfResult(pOperator->pRuntimeEnv, pAggInfo->binfo.pCtx, pOperator->numOfOutput); - pAggInfo->binfo.pRes->info.rows += numOfRows; + pAggInfo->binfo.pRes->info.rows += numOfRows; setTagValueForMultipleRows(pAggInfo->binfo.pCtx, pOperator->numOfOutput, numOfRows); } @@ -1019,71 +974,127 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) { return (pRes->info.rows != 0)? pRes:NULL; } -static SSDataBlock* skipGroupBlock(SOperatorInfo* pOperator, bool* newgroup) { - SSLimitOperatorInfo *pInfo = pOperator->info; - assert(pInfo->currentGroupOffset >= 0); +static void doHandleDataInCurrentGroup(SSLimitOperatorInfo* pInfo, SSDataBlock* pBlock, int32_t rowIndex) { + if (pInfo->currentOffset > 0) { + pInfo->currentOffset -= 1; + } else { + // discard the data rows in current group + if (pInfo->limit.limit < 0 || (pInfo->limit.limit >= 0 && pInfo->rowsTotal < pInfo->limit.limit)) { + size_t num1 = taosArrayGetSize(pInfo->pRes->pDataBlock); + for (int32_t i = 0; i < num1; ++i) { + SColumnInfoData *pColInfoData = taosArrayGet(pBlock->pDataBlock, i); + SColumnInfoData *pDstInfoData = taosArrayGet(pInfo->pRes->pDataBlock, i); - SSDataBlock* pBlock = NULL; - if (pInfo->currentGroupOffset == 0) { - publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC); - pBlock = pOperator->upstream[0]->exec(pOperator->upstream[0], newgroup); - publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC); - if (pBlock == NULL) { - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; - } + SColumnInfo *pColInfo = &pColInfoData->info; + + char *pSrc = rowIndex * pColInfo->bytes + (char *)pColInfoData->pData; + char *pDst = (char *)pDstInfoData->pData + (pInfo->pRes->info.rows * pColInfo->bytes); - if (*newgroup == false && pInfo->limit.limit > 0 && pInfo->rowsTotal >= pInfo->limit.limit) { - while ((*newgroup) == false) { // ignore the remain blocks - publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC); - pBlock = pOperator->upstream[0]->exec(pOperator->upstream[0], newgroup); - publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC); - if (pBlock == NULL) { - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; - return NULL; - } + memcpy(pDst, pSrc, pColInfo->bytes); } + + pInfo->rowsTotal += 1; + pInfo->pRes->info.rows += 1; } + } +} + +static void ensureOutputBuf(SSLimitOperatorInfo * pInfo, SSDataBlock *pResultBlock, int32_t numOfRows) { + if (pInfo->capacity < pResultBlock->info.rows + numOfRows) { + int32_t total = pResultBlock->info.rows + numOfRows; + + size_t num = taosArrayGetSize(pResultBlock->pDataBlock); + for (int32_t i = 0; i < num; ++i) { + SColumnInfoData *pInfoData = taosArrayGet(pResultBlock->pDataBlock, i); + + char *tmp = realloc(pInfoData->pData, total * pInfoData->info.bytes); + if (tmp != NULL) { + pInfoData->pData = tmp; + } else { + // todo handle the malloc failure + } - return pBlock; + pInfo->capacity = total; + pInfo->threshold = (int64_t)(total * 0.8); + } } +} - publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC); - pBlock = pOperator->upstream[0]->exec(pOperator->upstream[0], newgroup); - publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC); +enum { + BLOCK_NEW_GROUP = 1, + BLOCK_NO_GROUP = 2, + BLOCK_SAME_GROUP = 3, +}; - if (pBlock == NULL) { - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; - return NULL; +static int32_t doSlimitImpl(SOperatorInfo* pOperator, SSLimitOperatorInfo* pInfo, SSDataBlock* pBlock) { + int32_t rowIndex = 0; + + while (rowIndex < pBlock->info.rows) { + int32_t numOfCols = (int32_t)taosArrayGetSize(pInfo->orderColumnList); + + bool samegroup = true; + if (pInfo->hasPrev) { + for (int32_t i = 0; i < numOfCols; ++i) { + SColIndex *pIndex = taosArrayGet(pInfo->orderColumnList, i); + SColumnInfoData *pColInfoData = taosArrayGet(pBlock->pDataBlock, pIndex->colIndex); + + SColumnInfo *pColInfo = &pColInfoData->info; + + char *d = rowIndex * pColInfo->bytes + (char *)pColInfoData->pData; + int32_t ret = columnValueAscendingComparator(pInfo->prevRow[i], d, pColInfo->type, pColInfo->bytes); + if (ret != 0) { // it is a new group + samegroup = false; + break; + } + } } - while(1) { - if (*newgroup) { - pInfo->currentGroupOffset -= 1; - *newgroup = false; + if (!samegroup || !pInfo->hasPrev) { + pInfo->ignoreCurrentGroup = false; + savePrevOrderColumns(pInfo->prevRow, pInfo->orderColumnList, pBlock, rowIndex, &pInfo->hasPrev); + + pInfo->currentOffset = pInfo->limit.offset; // reset the offset value for a new group + pInfo->rowsTotal = 0; + + if (pInfo->currentGroupOffset > 0) { + pInfo->ignoreCurrentGroup = true; + pInfo->currentGroupOffset -= 1; // now we are in the next group data + rowIndex += 1; + continue; + } + + // A new group has arrived according to the result rows, and the group limitation has already reached. + // Let's jump out of current loop and return immediately. + if (pInfo->slimit.limit >= 0 && pInfo->groupTotal >= pInfo->slimit.limit) { + setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); + pOperator->status = OP_EXEC_DONE; + return BLOCK_NO_GROUP; } - while ((*newgroup) == false) { - publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC); - pBlock = pOperator->upstream[0]->exec(pOperator->upstream[0], newgroup); - publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC); + pInfo->groupTotal += 1; - if (pBlock == NULL) { - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; - return NULL; - } + // data in current group not allowed, return if current result does not belong to the previous group.And there + // are results exists in current SSDataBlock + if (!pInfo->multigroupResult && !samegroup && pInfo->pRes->info.rows > 0) { + return BLOCK_NEW_GROUP; } - // now we have got the first data block of the next group. - if (pInfo->currentGroupOffset == 0) { - return pBlock; + doHandleDataInCurrentGroup(pInfo, pBlock, rowIndex); + + } else { // handle the offset in the same group + // All the data in current group needs to be discarded, due to the limit parameter in the SQL statement + if (pInfo->ignoreCurrentGroup) { + rowIndex += 1; + continue; } + + doHandleDataInCurrentGroup(pInfo, pBlock, rowIndex); } - return NULL; + rowIndex += 1; + } + + return BLOCK_SAME_GROUP; } SSDataBlock* doSLimit(void* param, bool* newgroup) { @@ -1093,63 +1104,41 @@ SSDataBlock* doSLimit(void* param, bool* newgroup) { } SSLimitOperatorInfo *pInfo = pOperator->info; + pInfo->pRes->info.rows = 0; - SSDataBlock *pBlock = NULL; - while (1) { - pBlock = skipGroupBlock(pOperator, newgroup); - if (pBlock == NULL) { - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; - return NULL; - } - - if (*newgroup) { // a new group arrives - pInfo->groupTotal += 1; - pInfo->rowsTotal = 0; - pInfo->currentOffset = pInfo->limit.offset; - } + if (pInfo->pPrevBlock != NULL) { + ensureOutputBuf(pInfo, pInfo->pRes, pInfo->pPrevBlock->info.rows); + int32_t ret = doSlimitImpl(pOperator, pInfo, pInfo->pPrevBlock); + assert(ret != BLOCK_NEW_GROUP); - assert(pInfo->currentGroupOffset == 0); - - if (pInfo->currentOffset >= pBlock->info.rows) { - pInfo->currentOffset -= pBlock->info.rows; - } else { - if (pInfo->currentOffset == 0) { - break; - } - - int32_t remain = (int32_t)(pBlock->info.rows - pInfo->currentOffset); - pBlock->info.rows = remain; + pInfo->pPrevBlock = NULL; + } - // move the remain rows of this data block to the front. - for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { - SColumnInfoData *pColInfoData = taosArrayGet(pBlock->pDataBlock, i); + assert(pInfo->currentGroupOffset >= 0); - int16_t bytes = pColInfoData->info.bytes; - memmove(pColInfoData->pData, pColInfoData->pData + bytes * pInfo->currentOffset, remain * bytes); - } + while(1) { + publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC); + SSDataBlock *pBlock = pOperator->upstream[0]->exec(pOperator->upstream[0], newgroup); + publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC); - pInfo->currentOffset = 0; - break; + if (pBlock == NULL) { + return pInfo->pRes->info.rows == 0 ? NULL : pInfo->pRes; } - } - - if (pInfo->slimit.limit > 0 && pInfo->groupTotal > pInfo->slimit.limit) { // reach the group limit, abort - return NULL; - } - if (pInfo->limit.limit > 0 && (pInfo->rowsTotal + pBlock->info.rows >= pInfo->limit.limit)) { - pBlock->info.rows = (int32_t)(pInfo->limit.limit - pInfo->rowsTotal); - pInfo->rowsTotal = pInfo->limit.limit; + ensureOutputBuf(pInfo, pInfo->pRes, pBlock->info.rows); + int32_t ret = doSlimitImpl(pOperator, pInfo, pBlock); + if (ret == BLOCK_NEW_GROUP) { + pInfo->pPrevBlock = pBlock; + return pInfo->pRes; + } - if (pInfo->slimit.limit > 0 && pInfo->groupTotal >= pInfo->slimit.limit) { - pOperator->status = OP_EXEC_DONE; + if (pOperator->status == OP_EXEC_DONE) { + return pInfo->pRes->info.rows == 0 ? NULL : pInfo->pRes; } - // setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - } else { - pInfo->rowsTotal += pBlock->info.rows; + // now the number of rows in current group is enough, let's return to the invoke function + if (pInfo->pRes->info.rows > pInfo->threshold) { + return pInfo->pRes; + } } - - return pBlock; } diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index b3d6ade31942372dc875ab3fdf7ad938b3ad9aca..1bf27e6cad1d57fdfd4b786d1cdcea981bf3333b 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1777,6 +1777,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow } _error: + pParentSql->res.code = code; tfree(tokenBuf); tfree(line); taos_free_result(pSql); diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 2a16f1aad6525a25da652f643dc7b7f91debd432..778c0cfb47ad255663b403412931be71a3200d2a 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -32,9 +32,6 @@ typedef struct { uint8_t type; int16_t length; char* value; - - //=================================== - uint32_t fieldSchemaIdx; } TAOS_SML_KV; typedef struct { @@ -47,9 +44,6 @@ typedef struct { // first kv must be timestamp TAOS_SML_KV* fields; int32_t fieldNum; - - //================================ - uint32_t schemaIdx; } TAOS_SML_DATA_POINT; typedef enum { @@ -62,10 +56,23 @@ typedef enum { typedef struct { uint64_t id; - + SHashObj* smlDataToSchema; } SSmlLinesInfo; + //================================================================================================= +static uint64_t linesSmlHandleId = 0; + +uint64_t genLinesSmlId() { + uint64_t id; + + do { + id = atomic_add_fetch_64(&linesSmlHandleId, 1); + } while (id == 0); + + return id; +} + int compareSmlColKv(const void* p1, const void* p2) { TAOS_SML_KV* kv1 = (TAOS_SML_KV*)p1; TAOS_SML_KV* kv2 = (TAOS_SML_KV*)p2; @@ -168,11 +175,46 @@ static int32_t buildSmlKvSchema(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* arra taosHashPut(hash, field.name, tagKeyLen, &fieldIdx, sizeof(fieldIdx)); } - smlKv->fieldSchemaIdx = (uint32_t)fieldIdx; + uintptr_t valPointer = (uintptr_t)smlKv; + taosHashPut(info->smlDataToSchema, &valPointer, sizeof(uintptr_t), &fieldIdx, sizeof(fieldIdx)); return 0; } +static int32_t getSmlMd5ChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen, + SSmlLinesInfo* info) { + tscDebug("SML:0x%"PRIx64" taos_sml_insert get child table name through md5", info->id); + qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv); + + SStringBuilder sb; memset(&sb, 0, sizeof(sb)); + char sTableName[TSDB_TABLE_NAME_LEN] = {0}; + strtolower(sTableName, point->stableName); + taosStringBuilderAppendString(&sb, sTableName); + for (int j = 0; j < point->tagNum; ++j) { + taosStringBuilderAppendChar(&sb, ','); + TAOS_SML_KV* tagKv = point->tags + j; + char tagName[TSDB_COL_NAME_LEN] = {0}; + strtolower(tagName, tagKv->key); + taosStringBuilderAppendString(&sb, tagName); + taosStringBuilderAppendChar(&sb, '='); + taosStringBuilderAppend(&sb, tagKv->value, tagKv->length); + } + size_t len = 0; + char* keyJoined = taosStringBuilderGetResult(&sb, &len); + MD5_CTX context; + MD5Init(&context); + MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); + MD5Final(&context); + *tableNameLen = snprintf(tableName, *tableNameLen, + "t_%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], + context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], + context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], + context.digest[12], context.digest[13], context.digest[14], context.digest[15]); + taosStringBuilderDestroy(&sb); + tscDebug("SML:0x%"PRIx64" child table name: %s", info->id, tableName); + return 0; +} + static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint, SArray* stableSchemas, SSmlLinesInfo* info) { int32_t code = 0; SHashObj* sname2shema = taosHashInit(32, @@ -203,6 +245,15 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint, for (int j = 0; j < point->tagNum; ++j) { TAOS_SML_KV* tagKv = point->tags + j; + if (!point->childTableName) { + char childTableName[TSDB_TABLE_NAME_LEN]; + int32_t tableNameLen = TSDB_TABLE_NAME_LEN; + getSmlMd5ChildTableName(point, childTableName, &tableNameLen, info); + point->childTableName = calloc(1, tableNameLen+1); + strncpy(point->childTableName, childTableName, tableNameLen); + point->childTableName[tableNameLen] = '\0'; + } + code = buildSmlKvSchema(tagKv, pStableSchema->tagHash, pStableSchema->tags, info); if (code != 0) { tscError("SML:0x%"PRIx64" build data point schema failed. point no.: %d, tag key: %s", info->id, i, tagKv->key); @@ -219,7 +270,8 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint, } } - point->schemaIdx = (uint32_t)stableIdx; + uintptr_t valPointer = (uintptr_t)point; + taosHashPut(info->smlDataToSchema, &valPointer, sizeof(uintptr_t), &stableIdx, sizeof(stableIdx)); } size_t numStables = taosArrayGetSize(stableSchemas); @@ -319,7 +371,22 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action, SSmlLinesInf buildColumnDescription(action->alterSTable.field, result+n, capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + char* errStr = taos_errstr(res); + char* begin = strstr(errStr, "duplicated column names"); + bool tscDupColNames = (begin != NULL); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%"PRIx64" apply schema action. error: %s", info->id, errStr); + } taos_free_result(res); + + if (code == TSDB_CODE_MND_FIELD_ALREAY_EXIST || code == TSDB_CODE_MND_TAG_ALREAY_EXIST || tscDupColNames) { + TAOS_RES* res2 = taos_query(taos, "RESET QUERY CACHE"); + code = taos_errno(res2); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); + } + taos_free_result(res2); + } break; } case SCHEMA_ACTION_ADD_TAG: { @@ -328,7 +395,22 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action, SSmlLinesInf result+n, capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + char* errStr = taos_errstr(res); + char* begin = strstr(errStr, "duplicated column names"); + bool tscDupColNames = (begin != NULL); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + } taos_free_result(res); + + if (code == TSDB_CODE_MND_TAG_ALREAY_EXIST || code == TSDB_CODE_MND_FIELD_ALREAY_EXIST || tscDupColNames) { + TAOS_RES* res2 = taos_query(taos, "RESET QUERY CACHE"); + code = taos_errno(res2); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); + } + taos_free_result(res2); + } break; } case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: { @@ -337,7 +419,19 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action, SSmlLinesInf capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + } taos_free_result(res); + + if (code == TSDB_CODE_MND_INVALID_COLUMN_LENGTH || code == TSDB_CODE_TSC_INVALID_COLUMN_LENGTH) { + TAOS_RES* res2 = taos_query(taos, "RESET QUERY CACHE"); + code = taos_errno(res2); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); + } + taos_free_result(res2); + } break; } case SCHEMA_ACTION_CHANGE_TAG_SIZE: { @@ -346,7 +440,19 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action, SSmlLinesInf capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + } taos_free_result(res); + + if (code == TSDB_CODE_MND_INVALID_TAG_LENGTH || code == TSDB_CODE_TSC_INVALID_TAG_LENGTH) { + TAOS_RES* res2 = taos_query(taos, "RESET QUERY CACHE"); + code = taos_errno(res2); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); + } + taos_free_result(res2); + } break; } case SCHEMA_ACTION_CREATE_STABLE: { @@ -375,7 +481,19 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action, SSmlLinesInf outBytes = snprintf(pos, freeBytes, ")"); TAOS_RES* res = taos_query(taos, result); code = taos_errno(res); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res)); + } taos_free_result(res); + + if (code == TSDB_CODE_MND_TABLE_ALREADY_EXIST) { + TAOS_RES* res2 = taos_query(taos, "RESET QUERY CACHE"); + code = taos_errno(res2); + if (code != TSDB_CODE_SUCCESS) { + tscError("SML:0x%" PRIx64 " apply schema action. reset query cache. error: %s", info->id, taos_errstr(res2)); + } + taos_free_result(res2); + } break; } @@ -385,7 +503,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action, SSmlLinesInf free(result); if (code != 0) { - tscError("SML:0x%"PRIx64 "apply schema action failure. %s", info->id, tstrerror(code)); + tscError("SML:0x%"PRIx64 " apply schema action failure. %s", info->id, tstrerror(code)); } return code; } @@ -398,70 +516,12 @@ static int32_t destroySmlSTableSchema(SSmlSTableSchema* schema) { return 0; } -int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema, SSmlLinesInfo* info) { - int32_t code = 0; - - STscObj *pObj = (STscObj *)taos; - if (pObj == NULL || pObj->signature != pObj) { - terrno = TSDB_CODE_TSC_DISCONNECTED; - return TSDB_CODE_TSC_DISCONNECTED; - } - - tscDebug("SML:0x%"PRIx64" load table schema. super table name: %s", info->id, tableName); - - char tableNameLowerCase[TSDB_TABLE_NAME_LEN]; - strtolower(tableNameLowerCase, tableName); - - char sql[256]; - snprintf(sql, 256, "describe %s", tableNameLowerCase); - TAOS_RES* res = taos_query(taos, sql); - code = taos_errno(res); - if (code != 0) { - tscError("SML:0x%"PRIx64" describe table failure. %s", info->id, taos_errstr(res)); - taos_free_result(res); - return code; - } - taos_free_result(res); - - SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); - if (pSql == NULL){ - tscError("failed to allocate memory, reason:%s", strerror(errno)); - code = TSDB_CODE_TSC_OUT_OF_MEMORY; - return code; - } - pSql->pTscObj = taos; - pSql->signature = pSql; - pSql->fp = NULL; - - SStrToken tableToken = {.z=tableNameLowerCase, .n=(uint32_t)strlen(tableNameLowerCase), .type=TK_ID}; - tGetToken(tableNameLowerCase, &tableToken.type); - // Check if the table name available or not - if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { - code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; - sprintf(pSql->cmd.payload, "table name is invalid"); - tscFreeSqlObj(pSql); - return code; - } - - SName sname = {0}; - if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) { - tscFreeSqlObj(pSql); - return code; - } - char fullTableName[TSDB_TABLE_FNAME_LEN] = {0}; - memset(fullTableName, 0, tListLen(fullTableName)); - tNameExtractFullName(&sname, fullTableName); - tscFreeSqlObj(pSql); - +static int32_t fillDbSchema(STableMeta* tableMeta, char* tableName, SSmlSTableSchema* schema, SSmlLinesInfo* info) { schema->tags = taosArrayInit(8, sizeof(SSchema)); schema->fields = taosArrayInit(64, sizeof(SSchema)); schema->tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); schema->fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - size_t size = 0; - STableMeta* tableMeta = NULL; - taosHashGetCloneExt(tscTableMetaMap, fullTableName, strlen(fullTableName), NULL, (void **)&tableMeta, &size); - tstrncpy(schema->sTableName, tableName, strlen(tableName)+1); schema->precision = tableMeta->tableInfo.precision; for (int i=0; itableInfo.numOfColumns; ++i) { @@ -484,9 +544,93 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema, SSm size_t tagIndex = taosArrayGetSize(schema->tags) - 1; taosHashPut(schema->tagHash, field.name, strlen(field.name), &tagIndex, sizeof(tagIndex)); } - tscDebug("SML:0x%"PRIx64 " load table meta succeed. table name: %s, columns number: %d, tag number: %d, precision: %d", + tscDebug("SML:0x%"PRIx64 " load table schema succeed. table name: %s, columns number: %d, tag number: %d, precision: %d", info->id, tableName, tableMeta->tableInfo.numOfColumns, tableMeta->tableInfo.numOfTags, schema->precision); - free(tableMeta); tableMeta = NULL; + return TSDB_CODE_SUCCESS; +} + +static int32_t retrieveTableMeta(TAOS* taos, char* tableName, STableMeta** pTableMeta, SSmlLinesInfo* info) { + int32_t code = 0; + int32_t retries = 0; + STableMeta* tableMeta = NULL; + while (retries++ < TSDB_MAX_REPLICA && tableMeta == NULL) { + STscObj* pObj = (STscObj*)taos; + if (pObj == NULL || pObj->signature != pObj) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + tscDebug("SML:0x%" PRIx64 " retrieve table meta. super table name: %s", info->id, tableName); + + char tableNameLowerCase[TSDB_TABLE_NAME_LEN]; + strtolower(tableNameLowerCase, tableName); + + char sql[256]; + snprintf(sql, 256, "describe %s", tableNameLowerCase); + TAOS_RES* res = taos_query(taos, sql); + code = taos_errno(res); + if (code != 0) { + tscError("SML:0x%" PRIx64 " describe table failure. %s", info->id, taos_errstr(res)); + taos_free_result(res); + return code; + } + taos_free_result(res); + + SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); + if (pSql == NULL) { + tscError("SML:0x%" PRIx64 " failed to allocate memory, reason:%s", info->id, strerror(errno)); + code = TSDB_CODE_TSC_OUT_OF_MEMORY; + return code; + } + pSql->pTscObj = taos; + pSql->signature = pSql; + pSql->fp = NULL; + + registerSqlObj(pSql); + SStrToken tableToken = {.z = tableNameLowerCase, .n = (uint32_t)strlen(tableNameLowerCase), .type = TK_ID}; + tGetToken(tableNameLowerCase, &tableToken.type); + // Check if the table name available or not + if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { + code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; + sprintf(pSql->cmd.payload, "table name is invalid"); + tscFreeRegisteredSqlObj(pSql); + return code; + } + + SName sname = {0}; + if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) { + tscFreeRegisteredSqlObj(pSql); + return code; + } + char fullTableName[TSDB_TABLE_FNAME_LEN] = {0}; + memset(fullTableName, 0, tListLen(fullTableName)); + tNameExtractFullName(&sname, fullTableName); + tscFreeRegisteredSqlObj(pSql); + + size_t size = 0; + taosHashGetCloneExt(tscTableMetaMap, fullTableName, strlen(fullTableName), NULL, (void**)&tableMeta, &size); + } + + if (tableMeta != NULL) { + *pTableMeta = tableMeta; + return TSDB_CODE_SUCCESS; + } else { + tscError("SML:0x%" PRIx64 " failed to retrieve table meta. super table name: %s", info->id, tableName); + return TSDB_CODE_TSC_NO_META_CACHED; + } +} + +static int32_t loadTableSchemaFromDB(TAOS* taos, char* tableName, SSmlSTableSchema* schema, SSmlLinesInfo* info) { + int32_t code = 0; + STableMeta* tableMeta = NULL; + code = retrieveTableMeta(taos, tableName, &tableMeta, info); + if (code == TSDB_CODE_SUCCESS) { + assert(tableMeta != NULL); + fillDbSchema(tableMeta, tableName, schema, info); + free(tableMeta); + tableMeta = NULL; + } + return code; } @@ -498,7 +642,7 @@ static int32_t modifyDBSchemas(TAOS* taos, SArray* stableSchemas, SSmlLinesInfo* SSmlSTableSchema dbSchema; memset(&dbSchema, 0, sizeof(SSmlSTableSchema)); - code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema, info); + code = loadTableSchemaFromDB(taos, pointSchema->sTableName, &dbSchema, info); if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { SSchemaAction schemaAction = {0}; schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; @@ -507,7 +651,7 @@ static int32_t modifyDBSchemas(TAOS* taos, SArray* stableSchemas, SSmlLinesInfo* schemaAction.createSTable.tags = pointSchema->tags; schemaAction.createSTable.fields = pointSchema->fields; applySchemaAction(taos, &schemaAction, info); - code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema, info); + code = loadTableSchemaFromDB(taos, pointSchema->sTableName, &dbSchema, info); if (code != 0) { tscError("SML:0x%"PRIx64" reconcile point schema failed. can not create %s", info->id, pointSchema->sTableName); return code; @@ -567,74 +711,6 @@ static int32_t modifyDBSchemas(TAOS* taos, SArray* stableSchemas, SSmlLinesInfo* return 0; } -static int32_t getSmlMd5ChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen, - SSmlLinesInfo* info) { - tscDebug("SML:0x%"PRIx64" taos_sml_insert get child table name through md5", info->id); - qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv); - - SStringBuilder sb; memset(&sb, 0, sizeof(sb)); - char sTableName[TSDB_TABLE_NAME_LEN] = {0}; - strtolower(sTableName, point->stableName); - taosStringBuilderAppendString(&sb, sTableName); - for (int j = 0; j < point->tagNum; ++j) { - taosStringBuilderAppendChar(&sb, ','); - TAOS_SML_KV* tagKv = point->tags + j; - char tagName[TSDB_COL_NAME_LEN] = {0}; - strtolower(tagName, tagKv->key); - taosStringBuilderAppendString(&sb, tagName); - taosStringBuilderAppendChar(&sb, '='); - taosStringBuilderAppend(&sb, tagKv->value, tagKv->length); - } - size_t len = 0; - char* keyJoined = taosStringBuilderGetResult(&sb, &len); - MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); - MD5Final(&context); - *tableNameLen = snprintf(tableName, *tableNameLen, - "t_%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], - context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], - context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], - context.digest[12], context.digest[13], context.digest[14], context.digest[15]); - taosStringBuilderDestroy(&sb); - tscDebug("SML:0x%"PRIx64" child table name: %s", info->id, tableName); - return 0; -} - - -static int32_t changeChildTableTagValue(TAOS* taos, const char* cTableName, const char* tagName, TAOS_BIND* bind, SSmlLinesInfo* info) { - char sql[512]; - sprintf(sql, "alter table %s set tag %s=?", cTableName, tagName); - - int32_t code; - TAOS_STMT* stmt = taos_stmt_init(taos); - code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql)); - - if (code != 0) { - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); - return code; - } - - code = taos_stmt_bind_param(stmt, bind); - if (code != 0) { - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); - return code; - } - - code = taos_stmt_execute(stmt); - if (code != 0) { - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); - return code; - } - - code = taos_stmt_close(stmt); - if (code != 0) { - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); - return code; - } - return code; -} - static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, const char* sTableName, SArray* tagsSchema, SArray* tagsBind, SSmlLinesInfo* info) { size_t numTags = taosArrayGetSize(tagsSchema); @@ -673,28 +749,28 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co free(sql); if (code != 0) { - tfree(stmt); - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); + tscError("SML:0x%"PRIx64" taos_stmt_prepare returns %d:%s", info->id, code, tstrerror(code)); + taos_stmt_close(stmt); return code; } code = taos_stmt_bind_param(stmt, TARRAY_GET_START(tagsBind)); if (code != 0) { - tfree(stmt); - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); + tscError("SML:0x%"PRIx64" taos_stmt_bind_param returns %d:%s", info->id, code, tstrerror(code)); + taos_stmt_close(stmt); return code; } code = taos_stmt_execute(stmt); if (code != 0) { - tfree(stmt); - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); + tscError("SML:0x%"PRIx64" taos_stmt_execute returns %d:%s", info->id, code, tstrerror(code)); + taos_stmt_close(stmt); return code; } code = taos_stmt_close(stmt); if (code != 0) { - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); + tscError("SML:0x%"PRIx64" taos_stmt_close return %d:%s", info->id, code, tstrerror(code)); return code; } return code; @@ -726,27 +802,29 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols tscDebug("SML:0x%"PRIx64" insert rows into child table %s. num of rows: %zu", info->id, cTableName, taosArrayGetSize(rowsBind)); int32_t code = 0; - int32_t try = 0; TAOS_STMT* stmt = taos_stmt_init(taos); if (stmt == NULL) { tfree(sql); return TSDB_CODE_TSC_OUT_OF_MEMORY; } + code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql)); tfree(sql); if (code != 0) { - tfree(stmt); - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); + tscError("SML:0x%"PRIx64" taos_stmt_prepare return %d:%s", info->id, code, tstrerror(code)); + taos_stmt_close(stmt); return code; } + bool tryAgain = false; + int32_t try = 0; do { code = taos_stmt_set_tbname(stmt, cTableName); if (code != 0) { - tfree(stmt); - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); + tscError("SML:0x%"PRIx64" taos_stmt_set_tbname return %d:%s", info->id, code, tstrerror(code)); + taos_stmt_close(stmt); return code; } @@ -755,31 +833,52 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i); code = taos_stmt_bind_param(stmt, colsBinds); if (code != 0) { - tfree(stmt); - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); + tscError("SML:0x%"PRIx64" taos_stmt_bind_param return %d:%s", info->id, code, tstrerror(code)); + taos_stmt_close(stmt); return code; } code = taos_stmt_add_batch(stmt); if (code != 0) { - tfree(stmt); - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); + tscError("SML:0x%"PRIx64" taos_stmt_add_batch return %d:%s", info->id, code, tstrerror(code)); + taos_stmt_close(stmt); return code; } } code = taos_stmt_execute(stmt); if (code != 0) { - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); + tscError("SML:0x%"PRIx64" taos_stmt_execute return %d:%s, try:%d", info->id, code, tstrerror(code), try); } - } while (code == TSDB_CODE_TDB_TABLE_RECONFIGURE && try++ < TSDB_MAX_REPLICA); - if (code != 0) { - tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - } else { - taos_stmt_close(stmt); - } + tryAgain = false; + if ((code == TSDB_CODE_TDB_INVALID_TABLE_ID + || code == TSDB_CODE_VND_INVALID_VGROUP_ID + || code == TSDB_CODE_TDB_TABLE_RECONFIGURE + || code == TSDB_CODE_APP_NOT_READY + || code == TSDB_CODE_RPC_NETWORK_UNAVAIL) && try++ < TSDB_MAX_REPLICA) { + tryAgain = true; + } + if (code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) { + TAOS_RES* res2 = taos_query(taos, "RESET QUERY CACHE"); + int32_t code2 = taos_errno(res2); + if (code2 != TSDB_CODE_SUCCESS) { + tscError("SML:0x%" PRIx64 " insert child table. reset query cache. error: %s", info->id, taos_errstr(res2)); + } + taos_free_result(res2); + if (tryAgain) { + taosMsleep(50 * (2 << try)); + } + } + if (code == TSDB_CODE_APP_NOT_READY || code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { + if (tryAgain) { + taosMsleep( 50 * (2 << try)); + } + } + } while (tryAgain); + + + taos_stmt_close(stmt); return code; } @@ -787,16 +886,10 @@ static int32_t arrangePointsByChildTableName(TAOS_SML_DATA_POINT* points, int nu SHashObj* cname2points, SArray* stableSchemas, SSmlLinesInfo* info) { for (int32_t i = 0; i < numPoints; ++i) { TAOS_SML_DATA_POINT * point = points + i; - if (!point->childTableName) { - char childTableName[TSDB_TABLE_NAME_LEN]; - int32_t tableNameLen = TSDB_TABLE_NAME_LEN; - getSmlMd5ChildTableName(point, childTableName, &tableNameLen, info); - point->childTableName = calloc(1, tableNameLen+1); - strncpy(point->childTableName, childTableName, tableNameLen); - point->childTableName[tableNameLen] = '\0'; - } - - SSmlSTableSchema* stableSchema = taosArrayGet(stableSchemas, point->schemaIdx); + uintptr_t valPointer = (uintptr_t)point; + size_t* pSchemaIndex = taosHashGet(info->smlDataToSchema, &valPointer, sizeof(uintptr_t)); + assert(pSchemaIndex != NULL); + SSmlSTableSchema* stableSchema = taosArrayGet(stableSchemas, *pSchemaIndex); for (int j = 0; j < point->tagNum; ++j) { TAOS_SML_KV* kv = point->tags + j; @@ -840,16 +933,10 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam TAOS_SML_DATA_POINT * pDataPoint = taosArrayGetP(cTablePoints, i); for (int j = 0; j < pDataPoint->tagNum; ++j) { TAOS_SML_KV* kv = pDataPoint->tags + j; - tagKVs[kv->fieldSchemaIdx] = kv; - } - } - - int32_t notNullTagsIndices[TSDB_MAX_TAGS] = {0}; - int32_t numNotNullTags = 0; - for (int32_t i = 0; i < numTags; ++i) { - if (tagKVs[i] != NULL) { - notNullTagsIndices[numNotNullTags] = i; - ++numNotNullTags; + uintptr_t valPointer = (uintptr_t)kv; + size_t* pFieldSchemaIdx = taosHashGet(info->smlDataToSchema, &valPointer, sizeof(uintptr_t)); + assert(pFieldSchemaIdx != NULL); + tagKVs[*pFieldSchemaIdx] = kv; } } @@ -863,7 +950,10 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam for (int j = 0; j < numTags; ++j) { if (tagKVs[j] == NULL) continue; TAOS_SML_KV* kv = tagKVs[j]; - TAOS_BIND* bind = taosArrayGet(tagBinds, kv->fieldSchemaIdx); + uintptr_t valPointer = (uintptr_t)kv; + size_t* pFieldSchemaIdx = taosHashGet(info->smlDataToSchema, &valPointer, sizeof(uintptr_t)); + assert(pFieldSchemaIdx != NULL); + TAOS_BIND* bind = taosArrayGet(tagBinds, *pFieldSchemaIdx); bind->buffer_type = kv->type; bind->length = malloc(sizeof(uintptr_t*)); *bind->length = kv->length; @@ -871,65 +961,8 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam bind->is_null = NULL; } - // select tag1,tag2,... from stable where tbname in (ctable) - char* sql = malloc(tsMaxSQLStringLen+1); - int freeBytes = tsMaxSQLStringLen + 1; - snprintf(sql, freeBytes, "select tbname, "); - for (int i = 0; i < numNotNullTags ; ++i) { - snprintf(sql + strlen(sql), freeBytes-strlen(sql), "%s,", tagKVs[notNullTagsIndices[i]]->key); - } - snprintf(sql + strlen(sql) - 1, freeBytes - strlen(sql) + 1, - " from %s where tbname in (\'%s\')", sTableName, cTableName); - sql[strlen(sql)] = '\0'; - - TAOS_RES* result = taos_query(taos, sql); - free(sql); - - int32_t code = taos_errno(result); - if (code != 0) { - tscError("SML:0x%"PRIx64" get child table %s tags failed. error string %s", info->id, cTableName, taos_errstr(result)); - goto cleanup; - } + int32_t code = creatChildTableIfNotExists(taos, cTableName, sTableName, sTableSchema->tags, tagBinds, info); - // check tag value and set tag values if different - TAOS_ROW row = taos_fetch_row(result); - if (row != NULL) { - int numFields = taos_field_count(result); - TAOS_FIELD* fields = taos_fetch_fields(result); - int* lengths = taos_fetch_lengths(result); - for (int i = 1; i < numFields; ++i) { - uint8_t dbType = fields[i].type; - int32_t length = lengths[i]; - char* val = row[i]; - - TAOS_SML_KV* tagKV = tagKVs[notNullTagsIndices[i-1]]; - if (tagKV->type != dbType) { - tscError("SML:0x%"PRIx64" child table %s tag %s type mismatch. point type : %d, db type : %d", - info->id, cTableName, tagKV->key, tagKV->type, dbType); - return TSDB_CODE_TSC_INVALID_VALUE; - } - - assert(tagKV->value); - - if (val == NULL || length != tagKV->length || memcmp(tagKV->value, val, length) != 0) { - TAOS_BIND* bind = taosArrayGet(tagBinds, tagKV->fieldSchemaIdx); - code = changeChildTableTagValue(taos, cTableName, tagKV->key, bind, info); - if (code != 0) { - tscError("SML:0x%"PRIx64" change child table tag failed. table name %s, tag %s", info->id, cTableName, tagKV->key); - goto cleanup; - } - } - } - tscDebug("SML:0x%"PRIx64" successfully applied point tags. child table: %s", info->id, cTableName); - } else { - code = creatChildTableIfNotExists(taos, cTableName, sTableName, sTableSchema->tags, tagBinds, info); - if (code != 0) { - goto cleanup; - } - } - -cleanup: - taos_free_result(result); for (int i = 0; i < taosArrayGetSize(tagBinds); ++i) { TAOS_BIND* bind = taosArrayGet(tagBinds, i); free(bind->length); @@ -963,7 +996,10 @@ static int32_t applyChildTableFields(TAOS* taos, SSmlSTableSchema* sTableSchema, } for (int j = 0; j < point->fieldNum; ++j) { TAOS_SML_KV* kv = point->fields + j; - TAOS_BIND* bind = colBinds + kv->fieldSchemaIdx; + uintptr_t valPointer = (uintptr_t)kv; + size_t* pFieldSchemaIdx = taosHashGet(info->smlDataToSchema, &valPointer, sizeof(uintptr_t)); + assert(pFieldSchemaIdx != NULL); + TAOS_BIND* bind = colBinds + *pFieldSchemaIdx; bind->buffer_type = kv->type; bind->length = malloc(sizeof(uintptr_t*)); *bind->length = kv->length; @@ -1000,9 +1036,11 @@ static int32_t applyDataPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t while (pCTablePoints) { SArray* cTablePoints = *pCTablePoints; - TAOS_SML_DATA_POINT* point = taosArrayGetP(cTablePoints, 0); - SSmlSTableSchema* sTableSchema = taosArrayGet(stableSchemas, point->schemaIdx); + uintptr_t valPointer = (uintptr_t)point; + size_t* pSchemaIndex = taosHashGet(info->smlDataToSchema, &valPointer, sizeof(uintptr_t)); + assert(pSchemaIndex != NULL); + SSmlSTableSchema* sTableSchema = taosArrayGet(stableSchemas, *pSchemaIndex); tscDebug("SML:0x%"PRIx64" apply child table tags. child table: %s", info->id, point->childTableName); code = applyChildTableTags(taos, point->childTableName, point->stableName, sTableSchema, cTablePoints, info); @@ -1014,7 +1052,7 @@ static int32_t applyDataPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t tscDebug("SML:0x%"PRIx64" apply child table points. child table: %s", info->id, point->childTableName); code = applyChildTableFields(taos, sTableSchema, point->childTableName, cTablePoints, info); if (code != 0) { - tscError("Apply child table fields failed. child table %s, error %s", point->childTableName, tstrerror(code)); + tscError("SML:0x%"PRIx64" Apply child table fields failed. child table %s, error %s", info->id, point->childTableName, tstrerror(code)); goto cleanup; } @@ -1034,10 +1072,11 @@ cleanup: return code; } -int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLinesInfo* info) { +int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLinesInfo* info) { tscDebug("SML:0x%"PRIx64" taos_sml_insert. number of points: %d", info->id, numPoint); int32_t code = TSDB_CODE_SUCCESS; + info->smlDataToSchema = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), true, false); tscDebug("SML:0x%"PRIx64" build data point schemas", info->id); SArray* stableSchemas = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray @@ -1067,6 +1106,15 @@ clean_up: taosArrayDestroy(schema->tags); } taosArrayDestroy(stableSchemas); + taosHashCleanup(info->smlDataToSchema); + return code; +} + +int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { + SSmlLinesInfo* info = calloc(1, sizeof(SSmlLinesInfo)); + info->id = genLinesSmlId(); + int code = tscSmlInsert(taos, points, numPoint, info); + free(info); return code; } @@ -2076,18 +2124,6 @@ int32_t tscParseLine(const char* sql, TAOS_SML_DATA_POINT* smlData, SSmlLinesInf //========================================================================= -static uint64_t linesSmlHandleId = 0; - -uint64_t genLinesSmlId() { - uint64_t id; - - do { - id = atomic_add_fetch_64(&linesSmlHandleId, 1); - } while (id == 0); - - return id; -} - void destroySmlDataPoint(TAOS_SML_DATA_POINT* point) { for (int i=0; itagNum; ++i) { free((point->tags+i)->key); @@ -2157,7 +2193,7 @@ int taos_insert_lines(TAOS* taos, char* lines[], int numLines) { } TAOS_SML_DATA_POINT* points = TARRAY_GET_START(lpPoints); - code = taos_sml_insert(taos, points, (int)numPoints, info); + code = tscSmlInsert(taos, points, (int)numPoints, info); if (code != 0) { tscError("SML:0x%"PRIx64" taos_sml_insert error: %s", info->id, tstrerror((code))); } diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index e9a47abaad026325995c2d4c6699b741e56a0643..bbddc4bff925de1a7d0b67fd233b6e2e88a618a3 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1540,6 +1540,8 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { pRes->qId = 0; pRes->numOfRows = 1; + registerSqlObj(pSql); + strtolower(pSql->sqlstr, sql); tscDebugL("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr); @@ -1549,8 +1551,6 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { pSql->cmd.insertParam.numOfParams = 0; pSql->cmd.batchSize = 0; - registerSqlObj(pSql); - int32_t ret = stmtParseInsertTbTags(pSql, pStmt); if (ret != TSDB_CODE_SUCCESS) { STMT_RET(ret); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index d89b518b915c4e4f657d3a14949eaa242592013d..5a2e35045018a4780be8dff09c13454a039d4ab7 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -40,7 +40,6 @@ #include "qScript.h" #include "ttype.h" #include "qFilter.h" -#include "httpInt.h" #define DEFAULT_PRIMARY_TIMESTAMP_COL_NAME "_c0" @@ -72,7 +71,6 @@ static int convertTimestampStrToInt64(tVariant *pVar, int32_t precision); static bool serializeExprListToVariant(SArray* pList, tVariant **dst, int16_t colType, uint8_t precision); static bool has(SArray* pFieldList, int32_t startIdx, const char* name); -static char* cloneCurrentDBName(SSqlObj* pSql); static int32_t getDelimiterIndex(SStrToken* pTableName); static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd); static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd); @@ -117,7 +115,7 @@ static int32_t validateColumnName(char* name); static int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType); static int32_t setCompactVnodeInfo(SSqlObj* pSql, struct SSqlInfo* pInfo); -static bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField); +static int32_t validateOneTag(SSqlCmd* pCmd, TAOS_FIELD* pTagField); static bool hasTimestampForPointInterpQuery(SQueryInfo* pQueryInfo); static bool hasNormalColumnFilter(SQueryInfo* pQueryInfo); @@ -427,13 +425,12 @@ int32_t readFromFile(char *name, uint32_t *len, void **buf) { return TSDB_CODE_TSC_APP_ERROR; } close(fd); - tfree(*buf); return TSDB_CODE_SUCCESS; } int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) { - const char *msg1 = "function name is too long"; + const char *msg1 = "invalidate function name"; const char *msg2 = "path is too long"; const char *msg3 = "invalid outputtype"; const char *msg4 = "invalid script"; @@ -450,7 +447,10 @@ int32_t handleUserDefinedFunc(SSqlObj* pSql, struct SSqlInfo* pInfo) { } createInfo->name.z[createInfo->name.n] = 0; - + // funcname's naming rule is same to column + if (validateColumnName(createInfo->name.z) != TSDB_CODE_SUCCESS) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + } strdequote(createInfo->name.z); if (strlen(createInfo->name.z) >= TSDB_FUNC_NAME_LEN) { @@ -931,7 +931,6 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { pQueryInfo = pCmd->active; pQueryInfo->pUdfInfo = pUdfInfo; pQueryInfo->udfCopy = true; - } } @@ -1085,12 +1084,13 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS const char* msg1 = "sliding cannot be used without interval"; const char* msg2 = "interval cannot be less than 1 us"; const char* msg3 = "interval value is too small"; + const char* msg4 = "only point interpolation query requires keyword EVERY"; SSqlCmd* pCmd = &pSql->cmd; STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); - + if (!TPARSER_HAS_TOKEN(pSqlNode->interval.interval)) { if (TPARSER_HAS_TOKEN(pSqlNode->sliding)) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); @@ -1116,7 +1116,6 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS } if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit != 'y') { - // interval cannot be less than 10 milliseconds if (convertTimePrecision(pQueryInfo->interval.interval, tinfo.precision, TSDB_TIME_PRECISION_MICRO) < tsMinIntervalTime) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); @@ -1131,9 +1130,15 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS return TSDB_CODE_TSC_INVALID_OPERATION; } + bool interpQuery = tscIsPointInterpQuery(pQueryInfo); + if ((pSqlNode->interval.token == TK_EVERY && (!interpQuery)) || (pSqlNode->interval.token == TK_INTERVAL && interpQuery)) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); + } + // The following part is used to check for the invalid query expression. return checkInvalidExprForTimeWindow(pCmd, pQueryInfo); } + static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, bool isStable) { const char* msg1 = "invalid column name"; @@ -1540,9 +1545,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC /* * tags name /column name is truncated in sql.y */ -bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { - //const char* msg1 = "timestamp not allowed in tags"; - const char* msg2 = "duplicated column names"; +int32_t validateOneTag(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { const char* msg3 = "tag length too long"; const char* msg4 = "invalid tag name"; const char* msg5 = "invalid binary/nchar tag length"; @@ -1557,8 +1560,7 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { // no more max columns if (numOfTags + numOfCols >= TSDB_MAX_COLUMNS) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); } // no more than 6 tags @@ -1566,8 +1568,7 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { char msg[128] = {0}; sprintf(msg, "tags no more than %d", TSDB_MAX_TAGS); - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); } // no timestamp allowable @@ -1577,8 +1578,7 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { //} if ((pTagField->type < TSDB_DATA_TYPE_BOOL) || (pTagField->type > TSDB_DATA_TYPE_UBIGINT)) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); } SSchema* pTagSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta); @@ -1590,20 +1590,17 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { // length less than TSDB_MAX_TASG_LEN if (nLen + pTagField->bytes > TSDB_MAX_TAGS_LEN) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } // tags name can not be a keyword if (validateColumnName(pTagField->name) != TSDB_CODE_SUCCESS) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); } // binary(val), val can not be equalled to or less than 0 if ((pTagField->type == TSDB_DATA_TYPE_BINARY || pTagField->type == TSDB_DATA_TYPE_NCHAR) && pTagField->bytes <= 0) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); } // field name must be unique @@ -1611,17 +1608,16 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) { for (int32_t i = 0; i < numOfTags + numOfCols; ++i) { if (strncasecmp(pTagField->name, pSchema[i].name, sizeof(pTagField->name) - 1) == 0) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); - return false; + //return tscErrorMsgWithCode(TSDB_CODE_TSC_DUP_COL_NAMES, tscGetErrorMsgPayload(pCmd), pTagField->name, NULL); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "duplicated column names"); } } - return true; + return TSDB_CODE_SUCCESS; } -bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) { +int32_t validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) { const char* msg1 = "too many columns"; - const char* msg2 = "duplicated column names"; const char* msg3 = "column length too long"; const char* msg4 = "invalid data type"; const char* msg5 = "invalid column name"; @@ -1636,18 +1632,15 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) { // no more max columns if (numOfCols >= TSDB_MAX_COLUMNS || numOfTags + numOfCols >= TSDB_MAX_COLUMNS) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } if (pColField->type < TSDB_DATA_TYPE_BOOL || pColField->type > TSDB_DATA_TYPE_UBIGINT) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); } if (validateColumnName(pColField->name) != TSDB_CODE_SUCCESS) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5); } SSchema* pSchema = tscGetTableSchema(pTableMeta); @@ -1658,25 +1651,23 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) { } if (pColField->bytes <= 0) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); } // length less than TSDB_MAX_BYTES_PER_ROW if (nLen + pColField->bytes > TSDB_MAX_BYTES_PER_ROW) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); - return false; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } // field name must be unique for (int32_t i = 0; i < numOfTags + numOfCols; ++i) { if (strncasecmp(pColField->name, pSchema[i].name, sizeof(pColField->name) - 1) == 0) { - invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); - return false; + //return tscErrorMsgWithCode(TSDB_CODE_TSC_DUP_COL_NAMES, tscGetErrorMsgPayload(pCmd), pColField->name, NULL); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "duplicated column names"); } } - return true; + return TSDB_CODE_SUCCESS; } /* is contained in pFieldList or not */ @@ -1692,34 +1683,6 @@ static bool has(SArray* pFieldList, int32_t startIdx, const char* name) { static char* getAccountId(SSqlObj* pSql) { return pSql->pTscObj->acctId; } -static char* cloneCurrentDBName(SSqlObj* pSql) { - char *p = NULL; - HttpContext *pCtx = NULL; - - pthread_mutex_lock(&pSql->pTscObj->mutex); - STscObj *pTscObj = pSql->pTscObj; - switch (pTscObj->from) { - case TAOS_REQ_FROM_HTTP: - pCtx = pSql->param; - if (pCtx && pCtx->db[0] != '\0') { - char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN] = {0}; - int32_t len = sprintf(db, "%s%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pCtx->db); - assert(len <= sizeof(db)); - - p = strdup(db); - } - break; - default: - break; - } - if (p == NULL) { - p = strdup(pSql->pTscObj->db); - } - pthread_mutex_unlock(&pSql->pTscObj->mutex); - - return p; -} - /* length limitation, strstr cannot be applied */ static int32_t getDelimiterIndex(SStrToken* pTableName) { for (uint32_t i = 0; i < pTableName->n; ++i) { @@ -6070,7 +6033,6 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg19 = "invalid new tag name"; const char* msg20 = "table is not super table"; const char* msg21 = "only binary/nchar column length could be modified"; - const char* msg22 = "new column length should be bigger than old one"; const char* msg23 = "only column length coulbe be modified"; const char* msg24 = "invalid binary/nchar column length"; @@ -6122,8 +6084,9 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } TAOS_FIELD* p = taosArrayGet(pFieldList, 0); - if (!validateOneTags(pCmd, p)) { - return TSDB_CODE_TSC_INVALID_OPERATION; + int32_t ret = validateOneTag(pCmd, p); + if (ret != TSDB_CODE_SUCCESS) { + return ret; } tscFieldInfoAppend(&pQueryInfo->fieldsInfo, p); @@ -6300,8 +6263,9 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } TAOS_FIELD* p = taosArrayGet(pFieldList, 0); - if (!validateOneColumn(pCmd, p)) { - return TSDB_CODE_TSC_INVALID_OPERATION; + int32_t ret = validateOneColumn(pCmd, p); + if (ret != TSDB_CODE_SUCCESS) { + return ret; } tscFieldInfoAppend(&pQueryInfo->fieldsInfo, p); @@ -6364,7 +6328,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } if (pItem->bytes <= pColSchema->bytes) { - return invalidOperationMsg(pMsg, msg22); + return tscErrorMsgWithCode(TSDB_CODE_TSC_INVALID_COLUMN_LENGTH, pMsg, pItem->name, NULL); } SSchema* pSchema = (SSchema*) pTableMetaInfo->pTableMeta->schema; @@ -6415,7 +6379,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } if (pItem->bytes <= pColSchema->bytes) { - return invalidOperationMsg(pMsg, msg22); + return tscErrorMsgWithCode(TSDB_CODE_TSC_INVALID_TAG_LENGTH, pMsg, pItem->name, NULL); } SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta); @@ -7205,7 +7169,6 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo const char* msg1 = "interval not allowed in group by normal column"; STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); SSchema* tagSchema = NULL; @@ -8735,6 +8698,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS if (taosArrayGetSize(subInfo->pSubquery) >= 2) { return invalidOperationMsg(msgBuf, "not support union in subquery"); } + SQueryInfo* pSub = calloc(1, sizeof(SQueryInfo)); tscInitQueryInfo(pSub); @@ -8757,6 +8721,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS if (pTableMetaInfo1 == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } + pTableMetaInfo1->pTableMeta = extractTempTableMetaFromSubquery(pSub); pTableMetaInfo1->tableMetaCapacity = tscGetTableMetaSize(pTableMetaInfo1->pTableMeta); @@ -8822,7 +8787,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf * select server_status(); * select server_version(); * select client_version(); - * select current_database(); + * select database(); */ if (pSqlNode->from == NULL) { assert(pSqlNode->fillType == NULL && pSqlNode->pGroupby == NULL && pSqlNode->pWhere == NULL && @@ -8840,7 +8805,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf // check if there is 3 level select SRelElementPair* subInfo = taosArrayGet(pSqlNode->from->list, i); SSqlNode* p = taosArrayGetP(subInfo->pSubquery, 0); - if (p->from->type == SQL_NODE_FROM_SUBQUERY){ + if (p->from->type == SQL_NODE_FROM_SUBQUERY) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg9); } @@ -8933,6 +8898,15 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf } } + // disable group result mixed up if interval/session window query exists. + if (isTimeWindowQuery(pQueryInfo)) { + size_t num = taosArrayGetSize(pQueryInfo->pUpstream); + for(int32_t i = 0; i < num; ++i) { + SQueryInfo* pUp = taosArrayGetP(pQueryInfo->pUpstream, i); + pUp->multigroupResult = false; + } + } + // parse the having clause in the first place int32_t joinQuery = (pSqlNode->from != NULL && taosArrayGetSize(pSqlNode->from->list) > 1); if (validateHavingClause(pQueryInfo, pSqlNode->pHaving, pCmd, pSqlNode->pSelNodeList, joinQuery, timeWindowQuery) != diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 91d607bc28140f690bb406c5cd851e80d5bd01f7..9d523f273016e258940c67eaa1596153de0998eb 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -331,189 +331,36 @@ int tscSendMsgToServer(SSqlObj *pSql) { .handle = NULL, .code = 0 }; - rpcSendRequest(pObj->pRpcObj->pDnodeConn, &pSql->epSet, &rpcMsg, &pSql->rpcRid); return TSDB_CODE_SUCCESS; } -//static void doProcessMsgFromServer(SSchedMsg* pSchedMsg) { -// SRpcMsg* rpcMsg = pSchedMsg->ahandle; -// SRpcEpSet* pEpSet = pSchedMsg->thandle; -// -// TSDB_CACHE_PTR_TYPE handle = (TSDB_CACHE_PTR_TYPE) rpcMsg->ahandle; -// SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, handle); -// if (pSql == NULL) { -// rpcFreeCont(rpcMsg->pCont); -// free(rpcMsg); -// free(pEpSet); -// return; -// } -// -// assert(pSql->self == handle); -// -// STscObj *pObj = pSql->pTscObj; -// SSqlRes *pRes = &pSql->res; -// SSqlCmd *pCmd = &pSql->cmd; -// -// pSql->rpcRid = -1; -// -// if (pObj->signature != pObj) { -// tscDebug("0x%"PRIx64" DB connection is closed, cmd:%d pObj:%p signature:%p", pSql->self, pCmd->command, pObj, pObj->signature); -// -// taosRemoveRef(tscObjRef, handle); -// taosReleaseRef(tscObjRef, handle); -// rpcFreeCont(rpcMsg->pCont); -// free(rpcMsg); -// free(pEpSet); -// return; -// } -// -// SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); -// if (pQueryInfo != NULL && pQueryInfo->type == TSDB_QUERY_TYPE_FREE_RESOURCE) { -// tscDebug("0x%"PRIx64" sqlObj needs to be released or DB connection is closed, cmd:%d type:%d, pObj:%p signature:%p", -// pSql->self, pCmd->command, pQueryInfo->type, pObj, pObj->signature); -// -// taosRemoveRef(tscObjRef, handle); -// taosReleaseRef(tscObjRef, handle); -// rpcFreeCont(rpcMsg->pCont); -// free(rpcMsg); -// free(pEpSet); -// return; -// } -// -// if (pEpSet) { -// if (!tscEpSetIsEqual(&pSql->epSet, pEpSet)) { -// if (pCmd->command < TSDB_SQL_MGMT) { -// tscUpdateVgroupInfo(pSql, pEpSet); -// } else { -// tscUpdateMgmtEpSet(pSql, pEpSet); -// } -// } -// } -// -// int32_t cmd = pCmd->command; -// -// // set the flag to denote that sql string needs to be re-parsed and build submit block with table schema -// if (cmd == TSDB_SQL_INSERT && rpcMsg->code == TSDB_CODE_TDB_TABLE_RECONFIGURE) { -// pSql->cmd.insertParam.schemaAttached = 1; -// } -// -// // single table query error need to be handled here. -// if ((cmd == TSDB_SQL_SELECT || cmd == TSDB_SQL_UPDATE_TAGS_VAL) && -// (((rpcMsg->code == TSDB_CODE_TDB_INVALID_TABLE_ID || rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID)) || -// rpcMsg->code == TSDB_CODE_RPC_NETWORK_UNAVAIL || rpcMsg->code == TSDB_CODE_APP_NOT_READY)) { -// -// // 1. super table subquery -// // 2. nest queries are all not updated the tablemeta and retry parse the sql after cleanup local tablemeta/vgroup id buffer -// if ((TSDB_QUERY_HAS_TYPE(pQueryInfo->type, (TSDB_QUERY_TYPE_STABLE_SUBQUERY | TSDB_QUERY_TYPE_SUBQUERY | -// TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) && -// !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_PROJECTION_QUERY)) || -// (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_NEST_SUBQUERY)) || (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STABLE_SUBQUERY) && pQueryInfo->distinct)) { -// // do nothing in case of super table subquery -// } else { -// pSql->retry += 1; -// tscWarn("0x%" PRIx64 " it shall renew table meta, code:%s, retry:%d", pSql->self, tstrerror(rpcMsg->code), pSql->retry); -// -// pSql->res.code = rpcMsg->code; // keep the previous error code -// if (pSql->retry > pSql->maxRetry) { -// tscError("0x%" PRIx64 " max retry %d reached, give up", pSql->self, pSql->maxRetry); -// } else { -// // wait for a little bit moment and then retry -// // todo do not sleep in rpc callback thread, add this process into queue to process -// if (rpcMsg->code == TSDB_CODE_APP_NOT_READY || rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID) { -// int32_t duration = getWaitingTimeInterval(pSql->retry); -// taosMsleep(duration); -// } -// -// pSql->retryReason = rpcMsg->code; -// rpcMsg->code = tscRenewTableMeta(pSql, 0); -// // if there is an error occurring, proceed to the following error handling procedure. -// if (rpcMsg->code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { -// taosReleaseRef(tscObjRef, handle); -// rpcFreeCont(rpcMsg->pCont); -// free(rpcMsg); -// free(pEpSet); -// return; -// } -// } -// } -// } -// -// pRes->rspLen = 0; -// -// if (pRes->code == TSDB_CODE_TSC_QUERY_CANCELLED) { -// tscDebug("0x%"PRIx64" query is cancelled, code:%s", pSql->self, tstrerror(pRes->code)); -// } else { -// pRes->code = rpcMsg->code; -// } -// -// if (pRes->code == TSDB_CODE_SUCCESS) { -// tscDebug("0x%"PRIx64" reset retry counter to be 0 due to success rsp, old:%d", pSql->self, pSql->retry); -// pSql->retry = 0; -// } -// -// if (pRes->code != TSDB_CODE_TSC_QUERY_CANCELLED) { -// assert(rpcMsg->msgType == pCmd->msgType + 1); -// pRes->code = rpcMsg->code; -// pRes->rspType = rpcMsg->msgType; -// pRes->rspLen = rpcMsg->contLen; -// -// if (pRes->rspLen > 0 && rpcMsg->pCont) { -// char *tmp = (char *)realloc(pRes->pRsp, pRes->rspLen); -// if (tmp == NULL) { -// pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; -// } else { -// pRes->pRsp = tmp; -// memcpy(pRes->pRsp, rpcMsg->pCont, pRes->rspLen); -// } -// } else { -// tfree(pRes->pRsp); -// } -// -// /* -// * There is not response callback function for submit response. -// * The actual inserted number of points is the first number. -// */ -// if (rpcMsg->msgType == TSDB_MSG_TYPE_SUBMIT_RSP && pRes->pRsp != NULL) { -// SShellSubmitRspMsg *pMsg = (SShellSubmitRspMsg*)pRes->pRsp; -// pMsg->code = htonl(pMsg->code); -// pMsg->numOfRows = htonl(pMsg->numOfRows); -// pMsg->affectedRows = htonl(pMsg->affectedRows); -// pMsg->failedRows = htonl(pMsg->failedRows); -// pMsg->numOfFailedBlocks = htonl(pMsg->numOfFailedBlocks); -// -// pRes->numOfRows += pMsg->affectedRows; -// tscDebug("0x%"PRIx64" SQL cmd:%s, code:%s inserted rows:%d rspLen:%d", pSql->self, sqlCmd[pCmd->command], -// tstrerror(pRes->code), pMsg->affectedRows, pRes->rspLen); -// } else { -// tscDebug("0x%"PRIx64" SQL cmd:%s, code:%s rspLen:%d", pSql->self, sqlCmd[pCmd->command], tstrerror(pRes->code), pRes->rspLen); -// } -// } -// -// if (pRes->code == TSDB_CODE_SUCCESS && tscProcessMsgRsp[pCmd->command]) { -// rpcMsg->code = (*tscProcessMsgRsp[pCmd->command])(pSql); -// } -// -// bool shouldFree = tscShouldBeFreed(pSql); -// if (rpcMsg->code != TSDB_CODE_TSC_ACTION_IN_PROGRESS) { -// if (rpcMsg->code != TSDB_CODE_SUCCESS) { -// pRes->code = rpcMsg->code; -// } -// rpcMsg->code = (pRes->code == TSDB_CODE_SUCCESS) ? (int32_t)pRes->numOfRows : pRes->code; -// (*pSql->fp)(pSql->param, pSql, rpcMsg->code); -// } -// -// if (shouldFree) { // in case of table-meta/vgrouplist query, automatically free it -// tscDebug("0x%"PRIx64" sqlObj is automatically freed", pSql->self); -// taosRemoveRef(tscObjRef, handle); -// } -// -// taosReleaseRef(tscObjRef, handle); -// rpcFreeCont(rpcMsg->pCont); -// free(rpcMsg); -// free(pEpSet); -//} +// handle three situation +// 1. epset retry, only return last failure ep +// 2. no epset retry, like 'taos -h invalidFqdn', return invalidFqdn +// 3. other situation, no expected +void tscSetFqdnErrorMsg(SSqlObj* pSql, SRpcEpSet* pEpSet) { + SSqlCmd* pCmd = &pSql->cmd; + SSqlRes* pRes = &pSql->res; + + char* msgBuf = tscGetErrorMsgPayload(pCmd); + + if (pEpSet) { + sprintf(msgBuf, "%s\"%s\"", tstrerror(pRes->code),pEpSet->fqdn[(pEpSet->inUse)%(pEpSet->numOfEps)]); + } else if (pCmd->command >= TSDB_SQL_MGMT) { + SRpcEpSet tEpset; + + SRpcCorEpSet *pCorEpSet = pSql->pTscObj->tscCorMgmtEpSet; + taosCorBeginRead(&pCorEpSet->version); + tEpset = pCorEpSet->epSet; + taosCorEndRead(&pCorEpSet->version); + + sprintf(msgBuf, "%s\"%s\"", tstrerror(pRes->code),tEpset.fqdn[(tEpset.inUse)%(tEpset.numOfEps)]); + } else { + sprintf(msgBuf, "%s", tstrerror(pRes->code)); + } +} void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { TSDB_CACHE_PTR_TYPE handle = (TSDB_CACHE_PTR_TYPE) rpcMsg->ahandle; @@ -542,7 +389,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); if (pQueryInfo != NULL && pQueryInfo->type == TSDB_QUERY_TYPE_FREE_RESOURCE) { tscDebug("0x%"PRIx64" sqlObj needs to be released or DB connection is closed, cmd:%d type:%d, pObj:%p signature:%p", - pSql->self, pCmd->command, pQueryInfo->type, pObj, pObj->signature); + pSql->self, pCmd->command, pQueryInfo->type, pObj, pObj->signature); taosRemoveRef(tscObjRef, handle); taosReleaseRef(tscObjRef, handle); @@ -575,9 +422,9 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { // 1. super table subquery // 2. nest queries are all not updated the tablemeta and retry parse the sql after cleanup local tablemeta/vgroup id buffer if ((TSDB_QUERY_HAS_TYPE(pQueryInfo->type, (TSDB_QUERY_TYPE_STABLE_SUBQUERY | TSDB_QUERY_TYPE_SUBQUERY | - TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) && - !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_PROJECTION_QUERY)) || - (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_NEST_SUBQUERY)) || (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STABLE_SUBQUERY) && pQueryInfo->distinct)) { + TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) && + !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_PROJECTION_QUERY)) || + (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_NEST_SUBQUERY)) || (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STABLE_SUBQUERY) && pQueryInfo->distinct)) { // do nothing in case of super table subquery } else { pSql->retry += 1; @@ -651,7 +498,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { pRes->numOfRows += pMsg->affectedRows; tscDebug("0x%"PRIx64" SQL cmd:%s, code:%s inserted rows:%d rspLen:%d", pSql->self, sqlCmd[pCmd->command], - tstrerror(pRes->code), pMsg->affectedRows, pRes->rspLen); + tstrerror(pRes->code), pMsg->affectedRows, pRes->rspLen); } else { tscDebug("0x%"PRIx64" SQL cmd:%s, code:%s rspLen:%d", pSql->self, sqlCmd[pCmd->command], tstrerror(pRes->code), pRes->rspLen); } @@ -666,28 +513,13 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { if (rpcMsg->code != TSDB_CODE_SUCCESS) { pRes->code = rpcMsg->code; } + rpcMsg->code = (pRes->code == TSDB_CODE_SUCCESS) ? (int32_t)pRes->numOfRows : pRes->code; - if (pRes->code == TSDB_CODE_RPC_FQDN_ERROR) { - tscAllocPayload(pCmd, TSDB_FQDN_LEN + 64); - // handle three situation - // 1. epset retry, only return last failure ep - // 2. no epset retry, like 'taos -h invalidFqdn', return invalidFqdn - // 3. other situation, no expected - if (pEpSet) { - sprintf(tscGetErrorMsgPayload(pCmd), "%s\"%s\"", tstrerror(pRes->code),pEpSet->fqdn[(pEpSet->inUse)%(pEpSet->numOfEps)]); - } else if (pCmd->command >= TSDB_SQL_MGMT) { - SRpcEpSet tEpset; - - SRpcCorEpSet *pCorEpSet = pSql->pTscObj->tscCorMgmtEpSet; - taosCorBeginRead(&pCorEpSet->version); - tEpset = pCorEpSet->epSet; - taosCorEndRead(&pCorEpSet->version); - - sprintf(tscGetErrorMsgPayload(pCmd), "%s\"%s\"", tstrerror(pRes->code),tEpset.fqdn[(tEpset.inUse)%(tEpset.numOfEps)]); - } else { - sprintf(tscGetErrorMsgPayload(pCmd), "%s", tstrerror(pRes->code)); - } + if (rpcMsg->code == TSDB_CODE_RPC_FQDN_ERROR) { + tscAllocPayload(pCmd, TSDB_FQDN_LEN + 64); + tscSetFqdnErrorMsg(pSql, pEpSet); } + (*pSql->fp)(pSql->param, pSql, rpcMsg->code); } @@ -1571,7 +1403,6 @@ int32_t tscBuildSyncDbReplicaMsg(SSqlObj* pSql, SSqlInfo *pInfo) { } int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) { - STscObj *pObj = pSql->pTscObj; SSqlCmd *pCmd = &pSql->cmd; pCmd->msgType = TSDB_MSG_TYPE_CM_SHOW; pCmd->payloadLen = sizeof(SShowMsg) + 100; @@ -1594,9 +1425,9 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } if (tNameIsEmpty(&pTableMetaInfo->name)) { - pthread_mutex_lock(&pObj->mutex); - tstrncpy(pShowMsg->db, pObj->db, sizeof(pShowMsg->db)); - pthread_mutex_unlock(&pObj->mutex); + char *p = cloneCurrentDBName(pSql); + tstrncpy(pShowMsg->db, p, sizeof(pShowMsg->db)); + tfree(p); } else { tNameGetFullDbName(&pTableMetaInfo->name, pShowMsg->db); } @@ -3092,13 +2923,15 @@ int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool // just make runtime happy if (pTableMetaInfo->tableMetaCapacity != 0 && pTableMetaInfo->pTableMeta != NULL) { memset(pTableMetaInfo->pTableMeta, 0, pTableMetaInfo->tableMetaCapacity); - } + } + if (NULL == taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&(pTableMetaInfo->pTableMeta), &pTableMetaInfo->tableMetaCapacity)) { - tfree(pTableMetaInfo->pTableMeta); - } + tfree(pTableMetaInfo->pTableMeta); + } STableMeta* pMeta = pTableMetaInfo->pTableMeta; STableMeta* pSTMeta = (STableMeta *)(pSql->pBuf); + if (pMeta && pMeta->id.uid > 0) { // in case of child table, here only get the if (pMeta->tableType == TSDB_CHILD_TABLE) { @@ -3108,6 +2941,8 @@ int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool return getTableMetaFromMnode(pSql, pTableMetaInfo, autocreate); } } + + tscDebug("0x%"PRIx64 " %s retrieve tableMeta from cache, numOfCols:%d, numOfTags:%d", pSql->self, name, pMeta->tableInfo.numOfColumns, pMeta->tableInfo.numOfTags); return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 0c31a01be64cd66edee7467ef63ddf4903e9045c..e3bec2c2eaa50bb8e753ad499889b94dc23c2f40 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -2444,7 +2444,11 @@ static void doSendQueryReqs(SSchedMsg* pSchedMsg) { SSqlObj* pSql = pSchedMsg->ahandle; SPair* p = pSchedMsg->msg; - for(int32_t i = p->first; i < p->second; ++i) { + for (int32_t i = p->first; i < p->second; ++i) { + if (i >= pSql->subState.numOfSub) { + tfree(p); + return; + } SSqlObj* pSub = pSql->pSubs[i]; SRetrieveSupport* pSupport = pSub->param; @@ -2584,7 +2588,12 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { int32_t numOfTasks = (pState->numOfSub + MAX_REQUEST_PER_TASK - 1)/MAX_REQUEST_PER_TASK; assert(numOfTasks >= 1); - int32_t num = (pState->numOfSub/numOfTasks) + 1; + int32_t num; + if (pState->numOfSub / numOfTasks == MAX_REQUEST_PER_TASK) { + num = MAX_REQUEST_PER_TASK; + } else { + num = pState->numOfSub / numOfTasks + 1; + } tscDebug("0x%"PRIx64 " query will be sent by %d threads", pSql->self, numOfTasks); for(int32_t j = 0; j < numOfTasks; ++j) { @@ -2740,7 +2749,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO } } else { // reach the maximum retry count, abort atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, numOfRows); - tscError("0x%"PRIx64" sub:0x%"PRIx64" retrieve failed,code:%s,orderOfSub:%d failed.no more retry,set global code:%s", pParentSql->self, pSql->self, + tscError("0x%"PRIx64" sub:0x%"PRIx64" retrieve failed, code:%s, orderOfSub:%d FAILED. no more retry, set global code:%s", pParentSql->self, pSql->self, tstrerror(numOfRows), subqueryIndex, tstrerror(pParentSql->res.code)); } } @@ -2987,7 +2996,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR tscDebug("0x%"PRIx64" sub:0x%"PRIx64" retrieve numOfRows:%d totalNumOfRows:%" PRIu64 " from ep:%s, orderOfSub:%d", pParentSql->self, pSql->self, pRes->numOfRows, pState->numOfRetrievedRows, pSql->epSet.fqdn[pSql->epSet.inUse], idx); - if (num > tsMaxNumOfOrderedResults && /*tscIsProjectionQueryOnSTable(pQueryInfo, 0) &&*/ !(tscGetQueryInfo(&pParentSql->cmd)->distinct)) { + if (num > tsMaxNumOfOrderedResults && tscIsProjectionQueryOnSTable(pQueryInfo, 0) && !(tscGetQueryInfo(&pParentSql->cmd)->distinct)) { tscError("0x%"PRIx64" sub:0x%"PRIx64" num of OrderedRes is too many, max allowed:%" PRId32 " , current:%" PRId64, pParentSql->self, pSql->self, tsMaxNumOfOrderedResults, num); tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_SORTED_RES_TOO_MANY); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 0ae6ea07f1c7a083d3cf8edfda0e9a4b4fcb0969..31631560af12a01e27d5a71acaecb724cc822b5d 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -29,6 +29,7 @@ #include "tsclient.h" #include "ttimer.h" #include "ttokendef.h" +#include "httpInt.h" static void freeQueryInfoImpl(SQueryInfo* pQueryInfo); @@ -2120,7 +2121,7 @@ TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes) { return f; } -int32_t tscGetFirstInvisibleFieldPos(SQueryInfo* pQueryInfo) { +int32_t tscGetFirstInvisibleFieldPos(SQueryInfo* pQueryInfo) { if (pQueryInfo->fieldsInfo.numOfOutput <= 0 || pQueryInfo->fieldsInfo.internalField == NULL) { return 0; } @@ -2129,10 +2130,10 @@ int32_t tscGetFirstInvisibleFieldPos(SQueryInfo* pQueryInfo) { SInternalField* pField = taosArrayGet(pQueryInfo->fieldsInfo.internalField, i); if (!pField->visible) { return i; - } + } } - - return pQueryInfo->fieldsInfo.numOfOutput; + + return pQueryInfo->fieldsInfo.numOfOutput; } @@ -3181,6 +3182,7 @@ void tscInitQueryInfo(SQueryInfo* pQueryInfo) { pQueryInfo->slimit.offset = 0; pQueryInfo->pUpstream = taosArrayInit(4, POINTER_BYTES); pQueryInfo->window = TSWINDOW_INITIALIZER; + pQueryInfo->multigroupResult = true; } int32_t tscAddQueryInfo(SSqlCmd* pCmd) { @@ -3192,7 +3194,6 @@ int32_t tscAddQueryInfo(SSqlCmd* pCmd) { } tscInitQueryInfo(pQueryInfo); - pQueryInfo->msg = pCmd->payload; // pointer to the parent error message buffer if (pCmd->pQueryInfo == NULL) { @@ -3241,6 +3242,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) { taosArrayDestroy(pQueryInfo->pUpstream); pQueryInfo->pUpstream = NULL; + pQueryInfo->bufLen = 0; } void tscClearSubqueryInfo(SSqlCmd* pCmd) { @@ -3275,6 +3277,7 @@ int32_t tscQueryInfoCopy(SQueryInfo* pQueryInfo, const SQueryInfo* pSrc) { pQueryInfo->window = pSrc->window; pQueryInfo->sessionWindow = pSrc->sessionWindow; pQueryInfo->pTableMetaInfo = NULL; + pQueryInfo->multigroupResult = pSrc->multigroupResult; pQueryInfo->bufLen = pSrc->bufLen; pQueryInfo->orderProjectQuery = pSrc->orderProjectQuery; @@ -3660,24 +3663,25 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t pnCmd->active = pNewQueryInfo; memcpy(&pNewQueryInfo->interval, &pQueryInfo->interval, sizeof(pNewQueryInfo->interval)); - pNewQueryInfo->type = pQueryInfo->type; - pNewQueryInfo->window = pQueryInfo->window; - pNewQueryInfo->limit = pQueryInfo->limit; - pNewQueryInfo->slimit = pQueryInfo->slimit; - pNewQueryInfo->order = pQueryInfo->order; - pNewQueryInfo->vgroupLimit = pQueryInfo->vgroupLimit; - pNewQueryInfo->tsBuf = NULL; - pNewQueryInfo->fillType = pQueryInfo->fillType; - pNewQueryInfo->fillVal = NULL; + pNewQueryInfo->type = pQueryInfo->type; + pNewQueryInfo->window = pQueryInfo->window; + pNewQueryInfo->limit = pQueryInfo->limit; + pNewQueryInfo->slimit = pQueryInfo->slimit; + pNewQueryInfo->order = pQueryInfo->order; + pNewQueryInfo->tsBuf = NULL; + pNewQueryInfo->fillType = pQueryInfo->fillType; + pNewQueryInfo->fillVal = NULL; + pNewQueryInfo->clauseLimit = pQueryInfo->clauseLimit; + pNewQueryInfo->prjOffset = pQueryInfo->prjOffset; pNewQueryInfo->numOfFillVal = 0; - pNewQueryInfo->clauseLimit = pQueryInfo->clauseLimit; - pNewQueryInfo->prjOffset = pQueryInfo->prjOffset; - pNewQueryInfo->numOfTables = 0; + pNewQueryInfo->numOfTables = 0; pNewQueryInfo->pTableMetaInfo = NULL; - pNewQueryInfo->bufLen = pQueryInfo->bufLen; - pNewQueryInfo->buf = malloc(pQueryInfo->bufLen); + pNewQueryInfo->bufLen = pQueryInfo->bufLen; + pNewQueryInfo->vgroupLimit = pQueryInfo->vgroupLimit; + pNewQueryInfo->distinct = pQueryInfo->distinct; + pNewQueryInfo->multigroupResult = pQueryInfo->multigroupResult; - pNewQueryInfo->distinct = pQueryInfo->distinct; + pNewQueryInfo->buf = malloc(pQueryInfo->bufLen); if (pNewQueryInfo->buf == NULL) { terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; goto _error; @@ -3904,12 +3908,12 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) { tscDebug("0x%"PRIx64" all subquery response received, retry", pParentSql->self); if (code && !((code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) && pParentSql->retry < pParentSql->maxRetry)) { pParentSql->res.code = code; - + tscAsyncResultOnError(pParentSql); return; } - tscFreeSubobj(pParentSql); + tscFreeSubobj(pParentSql); tfree(pParentSql->pSubs); pParentSql->res.code = TSDB_CODE_SUCCESS; @@ -3918,9 +3922,9 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) { tscDebug("0x%"PRIx64" retry parse sql and send query, prev error: %s, retry:%d", pParentSql->self, tstrerror(code), pParentSql->retry); - + tscResetSqlCmd(&pParentSql->cmd, true, pParentSql->self); - + code = tsParseSql(pParentSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { return; @@ -3988,7 +3992,7 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) { pNew->maxRetry = pSql->maxRetry; pNew->cmd.resColumnId = TSDB_RES_COL_ID; - + tsem_init(&pNew->rspSem, 0, 0); SRetrieveSupport* ps = calloc(1, sizeof(SRetrieveSupport)); // todo use object id @@ -4165,6 +4169,31 @@ int32_t tscInvalidOperationMsg(char* msg, const char* additionalInfo, const char return TSDB_CODE_TSC_INVALID_OPERATION; } +int32_t tscErrorMsgWithCode(int32_t code, char* dstBuffer, const char* errMsg, const char* sql) { + const char* msgFormat1 = "%s:%s"; + const char* msgFormat2 = "%s:\'%s\' (%s)"; + const char* msgFormat3 = "%s:\'%s\'"; + + const int32_t BACKWARD_CHAR_STEP = 0; + + if (sql == NULL) { + assert(errMsg != NULL); + sprintf(dstBuffer, msgFormat1, tstrerror(code), errMsg); + return code; + } + + char buf[64] = {0}; // only extract part of sql string + strncpy(buf, (sql - BACKWARD_CHAR_STEP), tListLen(buf) - 1); + + if (errMsg != NULL) { + sprintf(dstBuffer, msgFormat2, tstrerror(code), buf, errMsg); + } else { + sprintf(dstBuffer, msgFormat3, tstrerror(code), buf); // no additional information for invalid sql error + } + + return code; +} + bool tscHasReachLimitation(SQueryInfo* pQueryInfo, SSqlRes* pRes) { assert(pQueryInfo != NULL && pQueryInfo->clauseLimit != 0); return (pQueryInfo->clauseLimit > 0 && pRes->numOfClauseTotal >= pQueryInfo->clauseLimit); @@ -4522,15 +4551,15 @@ int32_t tscCreateTableMetaFromSTableMeta(STableMeta** ppChild, const char* name, STableMeta* p = *ppSTable; STableMeta* pChild = *ppChild; - size_t sz = (p != NULL) ? tscGetTableMetaSize(p) : 0; //ppSTableBuf actually capacity may larger than sz, dont care - if (sz != 0) { + size_t sz = (p != NULL) ? tscGetTableMetaSize(p) : 0; //ppSTableBuf actually capacity may larger than sz, dont care + if (p != NULL && sz != 0) { memset((char *)p, 0, sz); } if (NULL == taosHashGetCloneExt(tscTableMetaMap, pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, (void **)&p, &sz)) { tfree(p); } else { - *ppSTable = p; + *ppSTable = p; } // tableMeta exists, build child table meta according to the super table meta @@ -4811,6 +4840,7 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt pQueryAttr->distinct = pQueryInfo->distinct; pQueryAttr->sw = pQueryInfo->sessionWindow; pQueryAttr->stateWindow = pQueryInfo->stateWindow; + pQueryAttr->multigroupResult = pQueryInfo->multigroupResult; pQueryAttr->numOfCols = numOfCols; pQueryAttr->numOfOutput = numOfOutput; @@ -5083,3 +5113,31 @@ void tscRemoveCachedTableMeta(STableMetaInfo* pTableMetaInfo, uint64_t id) { taosHashRemove(tscTableMetaMap, fname, len); tscDebug("0x%"PRIx64" remove table meta %s, numOfRemain:%d", id, fname, (int32_t) taosHashGetSize(tscTableMetaMap)); } + +char* cloneCurrentDBName(SSqlObj* pSql) { + char *p = NULL; + HttpContext *pCtx = NULL; + + pthread_mutex_lock(&pSql->pTscObj->mutex); + STscObj *pTscObj = pSql->pTscObj; + switch (pTscObj->from) { + case TAOS_REQ_FROM_HTTP: + pCtx = pSql->param; + if (pCtx && pCtx->db[0] != '\0') { + char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN] = {0}; + int32_t len = sprintf(db, "%s%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pCtx->db); + assert(len <= sizeof(db)); + + p = strdup(db); + } + break; + default: + break; + } + if (p == NULL) { + p = strdup(pSql->pTscObj->db); + } + pthread_mutex_unlock(&pSql->pTscObj->mutex); + + return p; +} diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index fc9160cd7f4f0333cd034decc82a9a8ac2014169..8a9c065e54145b510cd4d0d9fca08137f88c76d6 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -134,6 +134,7 @@ extern int32_t tsHttpMaxThreads; extern int8_t tsHttpEnableCompress; extern int8_t tsHttpEnableRecordSql; extern int8_t tsTelegrafUseFieldNum; +extern int8_t tsHttpDbNameMandatory; // mqtt extern int8_t tsEnableMqttModule; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index d2bf4890ea3ed54f6e3039b014faea46b21ecc99..a11b0d8d5fce07baeb3d4bfaf24778b10a1eaeb0 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -179,6 +179,7 @@ int32_t tsHttpMaxThreads = 2; int8_t tsHttpEnableCompress = 1; int8_t tsHttpEnableRecordSql = 0; int8_t tsTelegrafUseFieldNum = 0; +int8_t tsHttpDbNameMandatory = 0; // mqtt int8_t tsEnableMqttModule = 0; // not finished yet, not started it by default @@ -1291,6 +1292,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "httpDbNameMandatory"; + cfg.ptr = &tsHttpDbNameMandatory; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + // debug flag cfg.option = "numOfLogLines"; cfg.ptr = &tsNumOfLogLines; diff --git a/src/connector/go b/src/connector/go index 050667e5b4d0eafa5387e4283e713559b421203f..b8f76da4a708d158ec3cc4b844571dc4414e36b4 160000 --- a/src/connector/go +++ b/src/connector/go @@ -1 +1 @@ -Subproject commit 050667e5b4d0eafa5387e4283e713559b421203f +Subproject commit b8f76da4a708d158ec3cc4b844571dc4414e36b4 diff --git a/src/connector/hivemq-tdengine-extension b/src/connector/hivemq-tdengine-extension index b62a26ecc164a310104df57691691b237e091c89..ce5201014136503d34fecbd56494b67b4961056c 160000 --- a/src/connector/hivemq-tdengine-extension +++ b/src/connector/hivemq-tdengine-extension @@ -1 +1 @@ -Subproject commit b62a26ecc164a310104df57691691b237e091c89 +Subproject commit ce5201014136503d34fecbd56494b67b4961056c diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index fbeeeb56d30357294663a5ebf64608c57e066a7d..6b9fc9d96ce16700ee1243ef7c148a423a965d0b 100644 --- a/src/connector/jdbc/pom.xml +++ b/src/connector/jdbc/pom.xml @@ -117,7 +117,6 @@ **/DatetimeBefore1970Test.java **/FailOverTest.java **/InvalidResultSetPointerTest.java - **/RestfulConnectionTest.java **/TSDBJNIConnectorTest.java **/TaosInfoMonitorTest.java **/UnsignedNumberJniTest.java diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java index 977ae665152fd1627cf25005061a4ca2aaa4e488..bdb3ea410005cadd865de1d9e080dd5b9f20834f 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java @@ -40,13 +40,13 @@ public class TSDBError { TSDBErrorMap.put(TSDBErrorNumbers.ERROR_SUBSCRIBE_FAILED, "failed to create subscription"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING, "Unsupported encoding"); - TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_TDENGINE_ERROR, "internal error of database"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_TDENGINE_ERROR, "internal error of database, please see taoslog for more details"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL, "JNI connection is NULL"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL, "JNI result set is NULL"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0, "invalid num of fields"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_SQL_NULL, "empty sql string"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_FETCH_END, "fetch to the end of resultSet"); - TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY, "JNI alloc memory failed"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY, "JNI alloc memory failed, please see taoslog for more details"); } public static SQLException createSQLException(int errorCode) { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java index c634fe2e9503ff19afae85f285d921f330562612..4a9e80ba53b096f057840eab67e61418332dbf81 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java @@ -278,25 +278,20 @@ public class TSDBJNIConnector { private native int validateCreateTableSqlImp(long connection, byte[] sqlBytes); public long prepareStmt(String sql) throws SQLException { - long stmt; - try { - stmt = prepareStmtImp(sql.getBytes(), this.taos); - } catch (Exception e) { - e.printStackTrace(); - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING); - } + long stmt = prepareStmtImp(sql.getBytes(), this.taos); if (stmt == TSDBConstants.JNI_CONNECTION_NULL) { - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL, "connection already closed"); } - if (stmt == TSDBConstants.JNI_SQL_NULL) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_SQL_NULL); } - if (stmt == TSDBConstants.JNI_OUT_OF_MEMORY) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY); } + if (stmt == TSDBConstants.JNI_TDENGINE_ERROR) { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_TDENGINE_ERROR); + } return stmt; } @@ -313,8 +308,7 @@ public class TSDBJNIConnector { private native int setBindTableNameImp(long stmt, String name, long conn); public void setBindTableNameAndTags(long stmt, String tableName, int numOfTags, ByteBuffer tags, ByteBuffer typeList, ByteBuffer lengthList, ByteBuffer nullList) throws SQLException { - int code = setTableNameTagsImp(stmt, tableName, numOfTags, tags.array(), typeList.array(), lengthList.array(), - nullList.array(), this.taos); + int code = setTableNameTagsImp(stmt, tableName, numOfTags, tags.array(), typeList.array(), lengthList.array(), nullList.array(), this.taos); if (code != TSDBConstants.JNI_SUCCESS) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN, "failed to bind table name and corresponding tags"); } diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fbce021d1bff3655eedcf487dbcbf4747d5f9897 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java @@ -0,0 +1,84 @@ +package com.taosdata.jdbc.cases; + +import org.junit.Before; +import org.junit.Test; + +import java.sql.*; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class UseNowInsertTimestampTest { + String url = "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"; + + @Test + public void millisec() { + try (Connection conn = DriverManager.getConnection(url)) { + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists test"); + stmt.execute("create database if not exists test precision 'ms'"); + stmt.execute("use test"); + stmt.execute("create table weather(ts timestamp, f1 int)"); + stmt.execute("insert into weather values(now, 1)"); + + ResultSet rs = stmt.executeQuery("select * from weather"); + rs.next(); + Timestamp ts = rs.getTimestamp("ts"); + assertEquals(13, Long.toString(ts.getTime()).length()); + + int nanos = ts.getNanos(); + assertEquals(0, nanos % 1000_000); + + stmt.execute("drop database if exists test"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Test + public void microsec() { + try (Connection conn = DriverManager.getConnection(url)) { + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists test"); + stmt.execute("create database if not exists test precision 'us'"); + stmt.execute("use test"); + stmt.execute("create table weather(ts timestamp, f1 int)"); + stmt.execute("insert into weather values(now, 1)"); + + ResultSet rs = stmt.executeQuery("select * from weather"); + rs.next(); + Timestamp ts = rs.getTimestamp("ts"); + int nanos = ts.getNanos(); + + assertEquals(0, nanos % 1000); + + stmt.execute("drop database if exists test"); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Test + public void nanosec() { + try (Connection conn = DriverManager.getConnection(url)) { + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists test"); + stmt.execute("create database if not exists test precision 'ns'"); + stmt.execute("use test"); + stmt.execute("create table weather(ts timestamp, f1 int)"); + stmt.execute("insert into weather values(now, 1)"); + + ResultSet rs = stmt.executeQuery("select * from weather"); + rs.next(); + + Timestamp ts = rs.getTimestamp("ts"); + + int nanos = ts.getNanos(); + assertTrue(nanos % 1000 != 0); + + stmt.execute("drop database if exists test"); + } catch (SQLException e) { + e.printStackTrace(); + } + } +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java index abd60f5b63d46b406f19b6be9dcbbab6b786de12..1c5c03aacb5e7ed5683c75414975224a67d49e21 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java @@ -9,6 +9,8 @@ import org.junit.Test; import java.sql.*; import java.util.Properties; +import static org.junit.Assert.assertEquals; + public class RestfulConnectionTest { private static final String host = "127.0.0.1"; @@ -26,7 +28,7 @@ public class RestfulConnectionTest { ResultSet rs = stmt.executeQuery("select server_status()"); rs.next(); int status = rs.getInt("server_status()"); - Assert.assertEquals(1, status); + assertEquals(1, status); } catch (SQLException e) { e.printStackTrace(); } @@ -38,7 +40,7 @@ public class RestfulConnectionTest { ResultSet rs = pstmt.executeQuery(); rs.next(); int status = rs.getInt("server_status()"); - Assert.assertEquals(1, status); + assertEquals(1, status); } @Test(expected = SQLFeatureNotSupportedException.class) @@ -49,7 +51,7 @@ public class RestfulConnectionTest { @Test public void nativeSQL() throws SQLException { String nativeSQL = conn.nativeSQL("select * from log.log"); - Assert.assertEquals("select * from log.log", nativeSQL); + assertEquals("select * from log.log", nativeSQL); } @Test @@ -87,7 +89,7 @@ public class RestfulConnectionTest { public void getMetaData() throws SQLException { DatabaseMetaData meta = conn.getMetaData(); Assert.assertNotNull(meta); - Assert.assertEquals("com.taosdata.jdbc.rs.RestfulDriver", meta.getDriverName()); + assertEquals("com.taosdata.jdbc.rs.RestfulDriver", meta.getDriverName()); } @Test @@ -103,25 +105,25 @@ public class RestfulConnectionTest { @Test public void setCatalog() throws SQLException { conn.setCatalog("test"); - Assert.assertEquals("test", conn.getCatalog()); + assertEquals("test", conn.getCatalog()); } @Test public void getCatalog() throws SQLException { conn.setCatalog("log"); - Assert.assertEquals("log", conn.getCatalog()); + assertEquals("log", conn.getCatalog()); } @Test(expected = SQLFeatureNotSupportedException.class) public void setTransactionIsolation() throws SQLException { conn.setTransactionIsolation(Connection.TRANSACTION_NONE); - Assert.assertEquals(Connection.TRANSACTION_NONE, conn.getTransactionIsolation()); + assertEquals(Connection.TRANSACTION_NONE, conn.getTransactionIsolation()); conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); } @Test public void getTransactionIsolation() throws SQLException { - Assert.assertEquals(Connection.TRANSACTION_NONE, conn.getTransactionIsolation()); + assertEquals(Connection.TRANSACTION_NONE, conn.getTransactionIsolation()); } @Test @@ -140,7 +142,7 @@ public class RestfulConnectionTest { ResultSet rs = stmt.executeQuery("select server_status()"); rs.next(); int status = rs.getInt("server_status()"); - Assert.assertEquals(1, status); + assertEquals(1, status); conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); } @@ -152,7 +154,7 @@ public class RestfulConnectionTest { ResultSet rs = pstmt.executeQuery(); rs.next(); int status = rs.getInt("server_status()"); - Assert.assertEquals(1, status); + assertEquals(1, status); conn.prepareStatement("select server_status", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); } @@ -175,13 +177,13 @@ public class RestfulConnectionTest { @Test(expected = SQLFeatureNotSupportedException.class) public void setHoldability() throws SQLException { conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT); - Assert.assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, conn.getHoldability()); + assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, conn.getHoldability()); conn.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT); } @Test public void getHoldability() throws SQLException { - Assert.assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, conn.getHoldability()); + assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, conn.getHoldability()); } @Test(expected = SQLFeatureNotSupportedException.class) @@ -210,7 +212,7 @@ public class RestfulConnectionTest { ResultSet rs = stmt.executeQuery("select server_status()"); rs.next(); int status = rs.getInt("server_status()"); - Assert.assertEquals(1, status); + assertEquals(1, status); conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); } @@ -222,7 +224,7 @@ public class RestfulConnectionTest { ResultSet rs = pstmt.executeQuery(); rs.next(); int status = rs.getInt("server_status()"); - Assert.assertEquals(1, status); + assertEquals(1, status); conn.prepareStatement("select server_status", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); } @@ -299,11 +301,11 @@ public class RestfulConnectionTest { Properties info = conn.getClientInfo(); String charset = info.getProperty(TSDBDriver.PROPERTY_KEY_CHARSET); - Assert.assertEquals("UTF-8", charset); + assertEquals("UTF-8", charset); String locale = info.getProperty(TSDBDriver.PROPERTY_KEY_LOCALE); - Assert.assertEquals("en_US.UTF-8", locale); + assertEquals("en_US.UTF-8", locale); String timezone = info.getProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE); - Assert.assertEquals("UTC-8", timezone); + assertEquals("UTC-8", timezone); } @Test @@ -313,11 +315,11 @@ public class RestfulConnectionTest { conn.setClientInfo(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); String charset = conn.getClientInfo(TSDBDriver.PROPERTY_KEY_CHARSET); - Assert.assertEquals("UTF-8", charset); + assertEquals("UTF-8", charset); String locale = conn.getClientInfo(TSDBDriver.PROPERTY_KEY_LOCALE); - Assert.assertEquals("en_US.UTF-8", locale); + assertEquals("en_US.UTF-8", locale); String timezone = conn.getClientInfo(TSDBDriver.PROPERTY_KEY_TIME_ZONE); - Assert.assertEquals("UTC-8", timezone); + assertEquals("UTC-8", timezone); } @Test(expected = SQLFeatureNotSupportedException.class) @@ -345,14 +347,15 @@ public class RestfulConnectionTest { conn.abort(null); } - @Test(expected = SQLFeatureNotSupportedException.class) + @Test public void setNetworkTimeout() throws SQLException { conn.setNetworkTimeout(null, 1000); } - @Test(expected = SQLFeatureNotSupportedException.class) + @Test public void getNetworkTimeout() throws SQLException { - conn.getNetworkTimeout(); + int timeout = conn.getNetworkTimeout(); + assertEquals(0, timeout); } @Test diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 368658377c1a92792e9a03c039a57ddcbc5bd127..c401ab762eb7f17b075ca52ab1e9454eb136a2ab 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -103,6 +103,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TSC_FILE_EMPTY TAOS_DEF_ERROR_CODE(0, 0x021A) //"File is empty") #define TSDB_CODE_TSC_LINE_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x021B) //"Syntax error in Line") #define TSDB_CODE_TSC_NO_META_CACHED TAOS_DEF_ERROR_CODE(0, 0x021C) //"No table meta cached") +#define TSDB_CODE_TSC_DUP_COL_NAMES TAOS_DEF_ERROR_CODE(0, 0x021D) //"duplicated column names") +#define TSDB_CODE_TSC_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021E) //"Invalid tag length") +#define TSDB_CODE_TSC_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021F) //"Invalid column length") // mnode #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed") @@ -185,6 +188,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_INVALID_FUNC TAOS_DEF_ERROR_CODE(0, 0x0374) //"Invalid func") #define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x0375) //"Invalid func bufSize") +#define TSDB_CODE_MND_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0376) //"invalid tag length") +#define TSDB_CODE_MND_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0377) //"invalid column length") + #define TSDB_CODE_MND_DB_NOT_SELECTED TAOS_DEF_ERROR_CODE(0, 0x0380) //"Database not specified or available") #define TSDB_CODE_MND_DB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0381) //"Database already exists") #define TSDB_CODE_MND_INVALID_DB_OPTION TAOS_DEF_ERROR_CODE(0, 0x0382) //"Invalid database options") diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index a97de15e93f6059d912d6200680a066155b7169c..3d35a51006b9742528fc07fb2ec91e9cd6fa38db 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -91,125 +91,126 @@ #define TK_ACCOUNT 73 #define TK_USE 74 #define TK_DESCRIBE 75 -#define TK_ALTER 76 -#define TK_PASS 77 -#define TK_PRIVILEGE 78 -#define TK_LOCAL 79 -#define TK_COMPACT 80 -#define TK_LP 81 -#define TK_RP 82 -#define TK_IF 83 -#define TK_EXISTS 84 -#define TK_AS 85 -#define TK_OUTPUTTYPE 86 -#define TK_AGGREGATE 87 -#define TK_BUFSIZE 88 -#define TK_PPS 89 -#define TK_TSERIES 90 -#define TK_DBS 91 -#define TK_STORAGE 92 -#define TK_QTIME 93 -#define TK_CONNS 94 -#define TK_STATE 95 -#define TK_COMMA 96 -#define TK_KEEP 97 -#define TK_CACHE 98 -#define TK_REPLICA 99 -#define TK_QUORUM 100 -#define TK_DAYS 101 -#define TK_MINROWS 102 -#define TK_MAXROWS 103 -#define TK_BLOCKS 104 -#define TK_CTIME 105 -#define TK_WAL 106 -#define TK_FSYNC 107 -#define TK_COMP 108 -#define TK_PRECISION 109 -#define TK_UPDATE 110 -#define TK_CACHELAST 111 -#define TK_PARTITIONS 112 -#define TK_UNSIGNED 113 -#define TK_TAGS 114 -#define TK_USING 115 -#define TK_NULL 116 -#define TK_NOW 117 -#define TK_SELECT 118 -#define TK_UNION 119 -#define TK_ALL 120 -#define TK_DISTINCT 121 -#define TK_FROM 122 -#define TK_VARIABLE 123 -#define TK_INTERVAL 124 -#define TK_SESSION 125 -#define TK_STATE_WINDOW 126 -#define TK_FILL 127 -#define TK_SLIDING 128 -#define TK_ORDER 129 -#define TK_BY 130 -#define TK_ASC 131 -#define TK_DESC 132 -#define TK_GROUP 133 -#define TK_HAVING 134 -#define TK_LIMIT 135 -#define TK_OFFSET 136 -#define TK_SLIMIT 137 -#define TK_SOFFSET 138 -#define TK_WHERE 139 -#define TK_RESET 140 -#define TK_QUERY 141 -#define TK_SYNCDB 142 -#define TK_ADD 143 -#define TK_COLUMN 144 -#define TK_MODIFY 145 -#define TK_TAG 146 -#define TK_CHANGE 147 -#define TK_SET 148 -#define TK_KILL 149 -#define TK_CONNECTION 150 -#define TK_STREAM 151 -#define TK_COLON 152 -#define TK_ABORT 153 -#define TK_AFTER 154 -#define TK_ATTACH 155 -#define TK_BEFORE 156 -#define TK_BEGIN 157 -#define TK_CASCADE 158 -#define TK_CLUSTER 159 -#define TK_CONFLICT 160 -#define TK_COPY 161 -#define TK_DEFERRED 162 -#define TK_DELIMITERS 163 -#define TK_DETACH 164 -#define TK_EACH 165 -#define TK_END 166 -#define TK_EXPLAIN 167 -#define TK_FAIL 168 -#define TK_FOR 169 -#define TK_IGNORE 170 -#define TK_IMMEDIATE 171 -#define TK_INITIALLY 172 -#define TK_INSTEAD 173 -#define TK_MATCH 174 -#define TK_KEY 175 -#define TK_OF 176 -#define TK_RAISE 177 -#define TK_REPLACE 178 -#define TK_RESTRICT 179 -#define TK_ROW 180 -#define TK_STATEMENT 181 -#define TK_TRIGGER 182 -#define TK_VIEW 183 -#define TK_IPTOKEN 184 -#define TK_SEMI 185 -#define TK_NONE 186 -#define TK_PREV 187 -#define TK_LINEAR 188 -#define TK_IMPORT 189 -#define TK_TBNAME 190 -#define TK_JOIN 191 -#define TK_INSERT 192 -#define TK_INTO 193 -#define TK_VALUES 194 +#define TK_DESC 76 +#define TK_ALTER 77 +#define TK_PASS 78 +#define TK_PRIVILEGE 79 +#define TK_LOCAL 80 +#define TK_COMPACT 81 +#define TK_LP 82 +#define TK_RP 83 +#define TK_IF 84 +#define TK_EXISTS 85 +#define TK_AS 86 +#define TK_OUTPUTTYPE 87 +#define TK_AGGREGATE 88 +#define TK_BUFSIZE 89 +#define TK_PPS 90 +#define TK_TSERIES 91 +#define TK_DBS 92 +#define TK_STORAGE 93 +#define TK_QTIME 94 +#define TK_CONNS 95 +#define TK_STATE 96 +#define TK_COMMA 97 +#define TK_KEEP 98 +#define TK_CACHE 99 +#define TK_REPLICA 100 +#define TK_QUORUM 101 +#define TK_DAYS 102 +#define TK_MINROWS 103 +#define TK_MAXROWS 104 +#define TK_BLOCKS 105 +#define TK_CTIME 106 +#define TK_WAL 107 +#define TK_FSYNC 108 +#define TK_COMP 109 +#define TK_PRECISION 110 +#define TK_UPDATE 111 +#define TK_CACHELAST 112 +#define TK_PARTITIONS 113 +#define TK_UNSIGNED 114 +#define TK_TAGS 115 +#define TK_USING 116 +#define TK_NULL 117 +#define TK_NOW 118 +#define TK_SELECT 119 +#define TK_UNION 120 +#define TK_ALL 121 +#define TK_DISTINCT 122 +#define TK_FROM 123 +#define TK_VARIABLE 124 +#define TK_INTERVAL 125 +#define TK_EVERY 126 +#define TK_SESSION 127 +#define TK_STATE_WINDOW 128 +#define TK_FILL 129 +#define TK_SLIDING 130 +#define TK_ORDER 131 +#define TK_BY 132 +#define TK_ASC 133 +#define TK_GROUP 134 +#define TK_HAVING 135 +#define TK_LIMIT 136 +#define TK_OFFSET 137 +#define TK_SLIMIT 138 +#define TK_SOFFSET 139 +#define TK_WHERE 140 +#define TK_RESET 141 +#define TK_QUERY 142 +#define TK_SYNCDB 143 +#define TK_ADD 144 +#define TK_COLUMN 145 +#define TK_MODIFY 146 +#define TK_TAG 147 +#define TK_CHANGE 148 +#define TK_SET 149 +#define TK_KILL 150 +#define TK_CONNECTION 151 +#define TK_STREAM 152 +#define TK_COLON 153 +#define TK_ABORT 154 +#define TK_AFTER 155 +#define TK_ATTACH 156 +#define TK_BEFORE 157 +#define TK_BEGIN 158 +#define TK_CASCADE 159 +#define TK_CLUSTER 160 +#define TK_CONFLICT 161 +#define TK_COPY 162 +#define TK_DEFERRED 163 +#define TK_DELIMITERS 164 +#define TK_DETACH 165 +#define TK_EACH 166 +#define TK_END 167 +#define TK_EXPLAIN 168 +#define TK_FAIL 169 +#define TK_FOR 170 +#define TK_IGNORE 171 +#define TK_IMMEDIATE 172 +#define TK_INITIALLY 173 +#define TK_INSTEAD 174 +#define TK_MATCH 175 +#define TK_KEY 176 +#define TK_OF 177 +#define TK_RAISE 178 +#define TK_REPLACE 179 +#define TK_RESTRICT 180 +#define TK_ROW 181 +#define TK_STATEMENT 182 +#define TK_TRIGGER 183 +#define TK_VIEW 184 +#define TK_IPTOKEN 185 +#define TK_SEMI 186 +#define TK_NONE 187 +#define TK_PREV 188 +#define TK_LINEAR 189 +#define TK_IMPORT 190 +#define TK_TBNAME 191 +#define TK_JOIN 192 +#define TK_INSERT 193 +#define TK_INTO 194 +#define TK_VALUES 195 #define TK_SPACE 300 diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 7ccb1e5620025762d711edb1a0636c733f190429..3c4522df66869b109c8c851bbecd16fff9fc8e29 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -75,6 +75,8 @@ extern char configDir[]; #define OPT_ABORT 1 /* –abort */ #define MAX_FILE_NAME_LEN 256 // max file name length on linux is 255. +#define DEFAULT_START_TIME 1500000000000 + #define MAX_PREPARED_RAND 1000000 #define INT_BUFF_LEN 11 #define BIGINT_BUFF_LEN 21 @@ -102,6 +104,9 @@ extern char configDir[]; #define NOTE_BUFF_LEN (SMALL_BUFF_LEN*16) #define DEFAULT_TIMESTAMP_STEP 1 +#define DEFAULT_INTERLACE_ROWS 0 +#define DEFAULT_DATATYPE_NUM 3 +#define DEFAULT_CHILDTABLES 10000 enum TEST_MODE { @@ -201,9 +206,9 @@ enum _describe_table_index { static char *g_dupstr = NULL; typedef struct SArguments_S { - char * metaFile; + char *metaFile; uint32_t test_mode; - char * host; + char *host; uint16_t port; uint16_t iface; char * user; @@ -222,7 +227,7 @@ typedef struct SArguments_S { char * output_file; bool async_mode; char * datatype[MAX_NUM_COLUMNS + 1]; - uint32_t len_of_binary; + uint32_t binwidth; uint32_t num_of_CPR; uint32_t num_of_threads; uint64_t insert_interval; @@ -363,7 +368,7 @@ typedef struct SDbs_S { bool asyncMode; uint32_t threadCount; - uint32_t threadCountByCreateTbl; + uint32_t threadCountForCreateTbl; uint32_t dbCount; SDataBase db[MAX_DB_COUNT]; @@ -582,24 +587,22 @@ char *g_randdouble_buff = NULL; char *g_aggreFunc[] = {"*", "count(*)", "avg(col0)", "sum(col0)", "max(col0)", "min(col0)", "first(col0)", "last(col0)"}; -#define DEFAULT_DATATYPE_NUM 3 - SArguments g_args = { - NULL, // metaFile - 0, // test_mode - "127.0.0.1", // host - 6030, // port - INTERFACE_BUT, // iface - "root", // user + NULL, // metaFile + 0, // test_mode + "localhost", // host + 6030, // port + INTERFACE_BUT, // iface + "root", // user #ifdef _TD_POWER_ "powerdb", // password #elif (_TD_TQ_ == true) - "tqueue", // password + "tqueue", // password #else - "taosdata", // password + "taosdata", // password #endif - "test", // database - 1, // replica + "test", // database + 1, // replica "d", // tb_prefix NULL, // sqlFile true, // use_metric @@ -616,16 +619,16 @@ SArguments g_args = { "INT", // datatype "FLOAT", // datatype. DEFAULT_DATATYPE_NUM is 3 }, - 64, // len_of_binary + 64, // binwidth 4, // num_of_CPR 10, // num_of_connections/thread 0, // insert_interval DEFAULT_TIMESTAMP_STEP, // timestamp_step 1, // query_times - 0, // interlace_rows; + DEFAULT_INTERLACE_ROWS, // interlace_rows; 30000, // num_of_RPR (1024*1024), // max_sql_len - 10000, // num_of_tables + DEFAULT_CHILDTABLES, // num_of_tables 10000, // num_of_DPT 0, // abort 0, // disorderRatio @@ -636,10 +639,8 @@ SArguments g_args = { true, // demo_mode; }; - - static SDbs g_Dbs; -static int64_t g_totalChildTables = 0; +static int64_t g_totalChildTables = DEFAULT_CHILDTABLES; static int64_t g_actualChildTables = 0; static SQueryMetaInfo g_queryInfo; static FILE * g_fpOfInsertResult = NULL; @@ -719,89 +720,100 @@ static void printVersion() { } static void printHelp() { - char indent[10] = " "; - printf("%s%s%s%s\n", indent, "-f", indent, + char indent[10] = " "; + printf("%s\n\n", "Usage: taosdemo [OPTION...]"); + printf("%s%s%s%s\n", indent, "-f, --file=FILE", "\t\t", "The meta file to the execution procedure. Default is './meta.json'."); - printf("%s%s%s%s\n", indent, "-u", indent, - "The TDengine user name to use when connecting to the server. Default is 'root'."); + printf("%s%s%s%s\n", indent, "-u, --user=USER", "\t\t", + "The user name to use when connecting to the server."); #ifdef _TD_POWER_ - printf("%s%s%s%s\n", indent, "-p", indent, - "The password to use when connecting to the server. Default is 'powerdb'."); - printf("%s%s%s%s\n", indent, "-c", indent, + printf("%s%s%s%s\n", indent, "-p, --password", "\t\t", + "The password to use when connecting to the server. Default is 'powerdb'"); + printf("%s%s%s%s\n", indent, "-c, --config-dir=CONFIG_DIR", "\t", "Configuration directory. Default is '/etc/power/'."); #elif (_TD_TQ_ == true) - printf("%s%s%s%s\n", indent, "-p", indent, - "The password to use when connecting to the server. Default is 'tqueue'."); - printf("%s%s%s%s\n", indent, "-c", indent, + printf("%s%s%s%s\n", indent, "-p, --password", "\t\t", + "The password to use when connecting to the server. Default is 'tqueue'"); + printf("%s%s%s%s\n", indent, "-c, --config-dir=CONFIG_DIR", "\t", "Configuration directory. Default is '/etc/tq/'."); #else - printf("%s%s%s%s\n", indent, "-p", indent, - "The password to use when connecting to the server. Default is 'taosdata'."); - printf("%s%s%s%s\n", indent, "-c", indent, - "Configuration directory. Default is '/etc/taos/'."); + printf("%s%s%s%s\n", indent, "-p, --password", "\t\t", + "The password to use when connecting to the server."); + printf("%s%s%s%s\n", indent, "-c, --config-dir=CONFIG_DIR", "\t", + "Configuration directory."); #endif - printf("%s%s%s%s\n", indent, "-h", indent, - "The host to connect to TDengine. Default is localhost."); - printf("%s%s%s%s\n", indent, "-P", indent, - "The TCP/IP port number to use for the connection. Default is 0."); - printf("%s%s%s%s\n", indent, "-I", indent, + printf("%s%s%s%s\n", indent, "-h, --host=HOST", "\t\t", + "TDengine server FQDN to connect. The default host is localhost."); + printf("%s%s%s%s\n", indent, "-P, --port=PORT", "\t\t", + "The TCP/IP port number to use for the connection."); + printf("%s%s%s%s\n", indent, "-I, --interface=INTERFACE", "\t", "The interface (taosc, rest, and stmt) taosdemo uses. Default is 'taosc'."); - printf("%s%s%s%s\n", indent, "-d", indent, + printf("%s%s%s%s\n", indent, "-d, --database=DATABASE", "\t", "Destination database. Default is 'test'."); - printf("%s%s%s%s\n", indent, "-a", indent, + printf("%s%s%s%s\n", indent, "-a, --replica=REPLICA", "\t\t", "Set the replica parameters of the database, Default 1, min: 1, max: 3."); - printf("%s%s%s%s\n", indent, "-m", indent, + printf("%s%s%s%s\n", indent, "-m, --table-prefix=TABLEPREFIX", "\t", "Table prefix name. Default is 'd'."); - printf("%s%s%s%s\n", indent, "-s", indent, "The select sql file."); - printf("%s%s%s%s\n", indent, "-N", indent, "Use normal table flag."); - printf("%s%s%s%s\n", indent, "-o", indent, + printf("%s%s%s%s\n", indent, "-s, --sql-file=FILE", "\t\t", "The select sql file."); + printf("%s%s%s%s\n", indent, "-N, --normal-table", "\t\t", "Use normal table flag."); + printf("%s%s%s%s\n", indent, "-o, --output=FILE", "\t\t", "Direct output to the named file. Default is './output.txt'."); - printf("%s%s%s%s\n", indent, "-q", indent, + printf("%s%s%s%s\n", indent, "-s, --sql-file=FILE", "\t\t", + "The select sql file."); + printf("%s%s%s%s\n", indent, "-q, --query-mode=MODE", "\t\t", "Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC."); - printf("%s%s%s%s\n", indent, "-b", indent, + printf("%s%s%s%s\n", indent, "-b, --data-type=DATATYPE", "\t", "The data_type of columns, default: FLOAT, INT, FLOAT."); - printf("%s%s%s%s%d\n", indent, "-w", indent, - "The length of data_type 'BINARY' or 'NCHAR'. Default is ", - g_args.len_of_binary); - printf("%s%s%s%s%d%s%d\n", indent, "-l", indent, + printf("%s%s%s%s%d\n", indent, "-w, --binwidth=WIDTH", "\t\t", + "The width of data_type 'BINARY' or 'NCHAR'. Default is ", + g_args.binwidth); + printf("%s%s%s%s%d%s%d\n", indent, "-l, --columns=COLUMNS", "\t\t", "The number of columns per record. Demo mode by default is ", DEFAULT_DATATYPE_NUM, " (float, int, float). Max values is ", MAX_NUM_COLUMNS); printf("%s%s%s%s\n", indent, indent, indent, - "All of the new column(s) type is INT. If use -b to specify column type, -l will be ignored."); - printf("%s%s%s%s\n", indent, "-T", indent, + "\t\t\t\tAll of the new column(s) type is INT. If use -b to specify column type, -l will be ignored."); + printf("%s%s%s%s\n", indent, "-T, --threads=NUMBER", "\t\t", "The number of threads. Default is 10."); - printf("%s%s%s%s\n", indent, "-i", indent, + printf("%s%s%s%s\n", indent, "-i, --insert-interval=NUMBER", "\t", "The sleep time (ms) between insertion. Default is 0."); - printf("%s%s%s%s%d.\n", indent, "-S", indent, + printf("%s%s%s%s%d.\n", indent, "-S, --time-step=TIME_STEP", "\t", "The timestamp step between insertion. Default is ", DEFAULT_TIMESTAMP_STEP); - printf("%s%s%s%s\n", indent, "-r", indent, + printf("%s%s%s%s%d.\n", indent, "-B, --interlace-rows=NUMBER", "\t", + "The interlace rows of insertion. Default is ", + DEFAULT_INTERLACE_ROWS); + printf("%s%s%s%s\n", indent, "-r, --rec-per-req=NUMBER", "\t", "The number of records per request. Default is 30000."); - printf("%s%s%s%s\n", indent, "-t", indent, + printf("%s%s%s%s\n", indent, "-t, --tables=NUMBER", "\t\t", "The number of tables. Default is 10000."); - printf("%s%s%s%s\n", indent, "-n", indent, + printf("%s%s%s%s\n", indent, "-n, --records=NUMBER", "\t\t", "The number of records per table. Default is 10000."); - printf("%s%s%s%s\n", indent, "-M", indent, + printf("%s%s%s%s\n", indent, "-M, --random", "\t\t\t", "The value of records generated are totally random."); - printf("%s%s%s%s\n", indent, indent, indent, - " The default is to simulate power equipment senario."); - printf("%s%s%s%s\n", indent, "-x", indent, "Not insert only flag."); - printf("%s%s%s%s\n", indent, "-y", indent, "Default input yes for prompt."); - printf("%s%s%s%s\n", indent, "-O", indent, - "Insert mode--0: In order, 1 ~ 50: disorder ratio. Default is in order."); - printf("%s%s%s%s\n", indent, "-R", indent, + printf("%s\n", "\t\t\t\tThe default is to simulate power equipment senario."); + printf("%s%s%s%s\n", indent, "-x, --no-insert", "\t\t", + "No-insert flag."); + printf("%s%s%s%s\n", indent, "-y, --answer-yes", "\t\t", "Default input yes for prompt."); + printf("%s%s%s%s\n", indent, "-O, --disorder=NUMBER", "\t\t", + "Insert order mode--0: In order, 1 ~ 50: disorder ratio. Default is in order."); + printf("%s%s%s%s\n", indent, "-R, --disorder-range=NUMBER", "\t", "Out of order data's range, ms, default is 1000."); - printf("%s%s%s%s\n", indent, "-g", indent, + printf("%s%s%s%s\n", indent, "-g, --debug", "\t\t\t", "Print debug info."); - printf("%s%s%s\n", indent, "-V, --version\t", - "Print version info."); - printf("%s%s%s%s\n", indent, "--help\t", indent, - "Print command line arguments list info."); + printf("%s%s%s%s\n", indent, "-?, --help\t", "\t\t", + "Give this help list"); + printf("%s%s%s%s\n", indent, " --usage\t", "\t\t", + "Give a short usage message"); + printf("%s%s\n", indent, "-V, --version\t\t\tPrint program version."); /* printf("%s%s%s%s\n", indent, "-D", indent, "Delete database if exists. 0: no, 1: yes, default is 1"); */ + printf("\nMandatory or optional arguments to long options are also mandatory or optional\n\ +for any corresponding short options.\n\ +\n\ +Report bugs to .\n"); } static bool isStringNumber(char *input) @@ -819,66 +831,229 @@ static bool isStringNumber(char *input) return true; } +static void errorUnreconized(char *program, char *wrong_arg) +{ + fprintf(stderr, "%s: unrecognized options '%s'\n", program, wrong_arg); + fprintf(stderr, "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); +} + +static void errorPrintReqArg(char *program, char *wrong_arg) +{ + fprintf(stderr, + "%s: option requires an argument -- '%s'\n", + program, wrong_arg); + fprintf(stderr, + "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); +} + +static void errorPrintReqArg2(char *program, char *wrong_arg) +{ + fprintf(stderr, + "%s: option requires a number argument '-%s'\n", + program, wrong_arg); + fprintf(stderr, + "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); +} + +static void errorPrintReqArg3(char *program, char *wrong_arg) +{ + fprintf(stderr, + "%s: option '%s' requires an argument\n", + program, wrong_arg); + fprintf(stderr, + "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); +} + static void parse_args(int argc, char *argv[], SArguments *arguments) { for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "-f") == 0) { + if ((0 == strncmp(argv[i], "-f", strlen("-f"))) + || (0 == strncmp(argv[i], "--file", strlen("--file")))) { arguments->demo_mode = false; - if (NULL == argv[i+1]) { - printHelp(); - errorPrint("%s", "\n\t-f need a valid json file following!\n"); - exit(EXIT_FAILURE); - } - arguments->metaFile = argv[++i]; - } else if (strcmp(argv[i], "-c") == 0) { - if (argc == i+1) { - printHelp(); - errorPrint("%s", "\n\t-c need a valid path following!\n"); + if (2 == strlen(argv[i])) { + if (i+1 == argc) { + errorPrintReqArg(argv[0], "f"); + exit(EXIT_FAILURE); + } + arguments->metaFile = argv[++i]; + } else if (0 == strncmp(argv[i], "-f", strlen("-f"))) { + arguments->metaFile = (char *)(argv[i] + strlen("-f")); + } else if (strlen("--file") == strlen(argv[i])) { + if (i+1 == argc) { + errorPrintReqArg3(argv[0], "--file"); + exit(EXIT_FAILURE); + } + arguments->metaFile = argv[++i]; + } else if (0 == strncmp(argv[i], "--file=", strlen("--file="))) { + arguments->metaFile = (char *)(argv[i] + strlen("--file=")); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - tstrncpy(configDir, argv[++i], TSDB_FILENAME_LEN); - } else if (strcmp(argv[i], "-h") == 0) { - if (argc == i+1) { - printHelp(); - errorPrint("%s", "\n\t-h need a valid string following!\n"); + } else if ((0 == strncmp(argv[i], "-c", strlen("-c"))) + || (0 == strncmp(argv[i], "--config-dir", strlen("--config-dir")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "c"); + exit(EXIT_FAILURE); + } + tstrncpy(configDir, argv[++i], TSDB_FILENAME_LEN); + } else if (0 == strncmp(argv[i], "-c", strlen("-c"))) { + tstrncpy(configDir, (char *)(argv[i] + strlen("-")), TSDB_FILENAME_LEN); + } else if (strlen("--config-dir") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--config-dir"); + exit(EXIT_FAILURE); + } + tstrncpy(configDir, argv[++i], TSDB_FILENAME_LEN); + } else if (0 == strncmp(argv[i], "--config-dir=", strlen("--config-dir="))) { + tstrncpy(configDir, (char *)(argv[i] + strlen("--config-dir=")), TSDB_FILENAME_LEN); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->host = argv[++i]; - } else if (strcmp(argv[i], "-P") == 0) { - if ((argc == i+1) || - (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-P need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-h", strlen("-h"))) + || (0 == strncmp(argv[i], "--host", strlen("--host")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "h"); + exit(EXIT_FAILURE); + } + arguments->host = argv[++i]; + } else if (0 == strncmp(argv[i], "-h", strlen("-h"))) { + arguments->host = (char *)(argv[i] + strlen("-h")); + } else if (strlen("--host") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--host"); + exit(EXIT_FAILURE); + } + arguments->host = argv[++i]; + } else if (0 == strncmp(argv[i], "--host=", strlen("--host="))) { + arguments->host = (char *)(argv[i] + strlen("--host=")); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->port = atoi(argv[++i]); - } else if (strcmp(argv[i], "-I") == 0) { - if (argc == i+1) { - printHelp(); - errorPrint("%s", "\n\t-I need a valid string following!\n"); + } else if (strcmp(argv[i], "-PP") == 0) { + arguments->performance_print = true; + } else if ((0 == strncmp(argv[i], "-P", strlen("-P"))) + || (0 == strncmp(argv[i], "--port", strlen("--port")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "P"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "P"); + exit(EXIT_FAILURE); + } + arguments->port = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--port=", strlen("--port="))) { + if (isStringNumber((char *)(argv[i] + strlen("--port=")))) { + arguments->port = atoi((char *)(argv[i]+strlen("--port="))); + } + } else if (0 == strncmp(argv[i], "-P", strlen("-P"))) { + if (isStringNumber((char *)(argv[i] + strlen("-P")))) { + arguments->port = atoi((char *)(argv[i]+strlen("-P"))); + } + } else if (strlen("--port") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--port"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--port"); + exit(EXIT_FAILURE); + } + arguments->port = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - ++i; - if (0 == strcasecmp(argv[i], "taosc")) { - arguments->iface = TAOSC_IFACE; - } else if (0 == strcasecmp(argv[i], "rest")) { - arguments->iface = REST_IFACE; - } else if (0 == strcasecmp(argv[i], "stmt")) { - arguments->iface = STMT_IFACE; + } else if ((0 == strncmp(argv[i], "-I", strlen("-I"))) + || (0 == strncmp(argv[i], "--interface", strlen("--interface")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "I"); + exit(EXIT_FAILURE); + } + if (0 == strcasecmp(argv[i+1], "taosc")) { + arguments->iface = TAOSC_IFACE; + } else if (0 == strcasecmp(argv[i+1], "rest")) { + arguments->iface = REST_IFACE; + } else if (0 == strcasecmp(argv[i+1], "stmt")) { + arguments->iface = STMT_IFACE; + } else { + errorPrintReqArg(argv[0], "I"); + exit(EXIT_FAILURE); + } + i++; + } else if (0 == strncmp(argv[i], "--interface=", strlen("--interface="))) { + if (0 == strcasecmp((char *)(argv[i] + strlen("--interface=")), "taosc")) { + arguments->iface = TAOSC_IFACE; + } else if (0 == strcasecmp((char *)(argv[i] + strlen("--interface=")), "rest")) { + arguments->iface = REST_IFACE; + } else if (0 == strcasecmp((char *)(argv[i] + strlen("--interface=")), "stmt")) { + arguments->iface = STMT_IFACE; + } else { + errorPrintReqArg3(argv[0], "--interface"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-I", strlen("-I"))) { + if (0 == strcasecmp((char *)(argv[i] + strlen("-I")), "taosc")) { + arguments->iface = TAOSC_IFACE; + } else if (0 == strcasecmp((char *)(argv[i] + strlen("-I")), "rest")) { + arguments->iface = REST_IFACE; + } else if (0 == strcasecmp((char *)(argv[i] + strlen("-I")), "stmt")) { + arguments->iface = STMT_IFACE; + } else { + errorPrintReqArg3(argv[0], "-I"); + exit(EXIT_FAILURE); + } + } else if (strlen("--interface") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--interface"); + exit(EXIT_FAILURE); + } + if (0 == strcasecmp(argv[i+1], "taosc")) { + arguments->iface = TAOSC_IFACE; + } else if (0 == strcasecmp(argv[i+1], "rest")) { + arguments->iface = REST_IFACE; + } else if (0 == strcasecmp(argv[i+1], "stmt")) { + arguments->iface = STMT_IFACE; + } else { + errorPrintReqArg3(argv[0], "--interface"); + exit(EXIT_FAILURE); + } + i++; } else { - errorPrint("%s", "\n\t-I need a valid string following!\n"); + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - } else if (strcmp(argv[i], "-u") == 0) { - if (argc == i+1) { - printHelp(); - errorPrint("%s", "\n\t-u need a valid string following!\n"); + } else if ((0 == strncmp(argv[i], "-u", strlen("-u"))) + || (0 == strncmp(argv[i], "--user", strlen("--user")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "u"); + exit(EXIT_FAILURE); + } + arguments->user = argv[++i]; + } else if (0 == strncmp(argv[i], "-u", strlen("-u"))) { + arguments->user = (char *)(argv[i++] + strlen("-u")); + } else if (0 == strncmp(argv[i], "--user=", strlen("--user="))) { + arguments->user = (char *)(argv[i++] + strlen("--user=")); + } else if (strlen("--user") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--user"); + exit(EXIT_FAILURE); + } + arguments->user = argv[++i]; + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->user = argv[++i]; - } else if (strncmp(argv[i], "-p", 2) == 0) { - if (strlen(argv[i]) == 2) { + } else if ((0 == strncmp(argv[i], "-p", strlen("-p"))) + || (0 == strcmp(argv[i], "--password"))) { + if ((strlen(argv[i]) == 2) || (0 == strcmp(argv[i], "--password"))) { printf("Enter password: "); taosSetConsoleEcho(false); if (scanf("%s", arguments->password) > 1) { @@ -888,52 +1063,202 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { } else { tstrncpy(arguments->password, (char *)(argv[i] + 2), SHELL_MAX_PASSWORD_LEN); } - } else if (strcmp(argv[i], "-o") == 0) { - if (argc == i+1) { - printHelp(); - errorPrint("%s", "\n\t-o need a valid string following!\n"); + } else if ((0 == strncmp(argv[i], "-o", strlen("-o"))) + || (0 == strncmp(argv[i], "--output", strlen("--output")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--output"); + exit(EXIT_FAILURE); + } + arguments->output_file = argv[++i]; + } else if (0 == strncmp(argv[i], "--output=", strlen("--output="))) { + arguments->output_file = (char *)(argv[i++] + strlen("--output=")); + } else if (0 == strncmp(argv[i], "-o", strlen("-o"))) { + arguments->output_file = (char *)(argv[i++] + strlen("-o")); + } else if (strlen("--output") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--output"); + exit(EXIT_FAILURE); + } + arguments->output_file = argv[++i]; + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->output_file = argv[++i]; - } else if (strcmp(argv[i], "-s") == 0) { - if (argc == i+1) { - printHelp(); - errorPrint("%s", "\n\t-s need a valid string following!\n"); + } else if ((0 == strncmp(argv[i], "-s", strlen("-s"))) + || (0 == strncmp(argv[i], "--sql-file", strlen("--sql-file")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "s"); + exit(EXIT_FAILURE); + } + arguments->sqlFile = argv[++i]; + } else if (0 == strncmp(argv[i], "--sql-file=", strlen("--sql-file="))) { + arguments->host = (char *)(argv[i++] + strlen("--sql-file=")); + } else if (0 == strncmp(argv[i], "-s", strlen("-s"))) { + arguments->host = (char *)(argv[i++] + strlen("-s")); + } else if (strlen("--sql-file") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--sql-file"); + exit(EXIT_FAILURE); + } + arguments->sqlFile = argv[++i]; + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->sqlFile = argv[++i]; - } else if (strcmp(argv[i], "-q") == 0) { - if ((argc == i+1) - || (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-q need a number following!\nQuery mode -- 0: SYNC, not-0: ASYNC. Default is SYNC.\n"); + } else if ((0 == strncmp(argv[i], "-q", strlen("-q"))) + || (0 == strncmp(argv[i], "--query-mode", strlen("--query-mode")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "q"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "q"); + exit(EXIT_FAILURE); + } + arguments->async_mode = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--query-mode=", strlen("--query-mode="))) { + if (isStringNumber((char *)(argv[i] + strlen("--query-mode=")))) { + arguments->async_mode = atoi((char *)(argv[i]+strlen("--query-mode="))); + } else { + errorPrintReqArg2(argv[0], "--query-mode"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-q", strlen("-q"))) { + if (isStringNumber((char *)(argv[i] + strlen("-q")))) { + arguments->async_mode = atoi((char *)(argv[i]+strlen("-q"))); + } else { + errorPrintReqArg2(argv[0], "-q"); + exit(EXIT_FAILURE); + } + } else if (strlen("--query-mode") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--query-mode"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--query-mode"); + exit(EXIT_FAILURE); + } + arguments->async_mode = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->async_mode = atoi(argv[++i]); - } else if (strcmp(argv[i], "-T") == 0) { - if ((argc == i+1) - || (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-T need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-T", strlen("-T"))) + || (0 == strncmp(argv[i], "--threads", strlen("--threads")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "T"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "T"); + exit(EXIT_FAILURE); + } + arguments->num_of_threads = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--threads=", strlen("--threads="))) { + if (isStringNumber((char *)(argv[i] + strlen("--threads=")))) { + arguments->num_of_threads = atoi((char *)(argv[i]+strlen("--threads="))); + } else { + errorPrintReqArg2(argv[0], "--threads"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-T", strlen("-T"))) { + if (isStringNumber((char *)(argv[i] + strlen("-T")))) { + arguments->num_of_threads = atoi((char *)(argv[i]+strlen("-T"))); + } else { + errorPrintReqArg2(argv[0], "-T"); + exit(EXIT_FAILURE); + } + } else if (strlen("--threads") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--threads"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--threads"); + exit(EXIT_FAILURE); + } + arguments->num_of_threads = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->num_of_threads = atoi(argv[++i]); - } else if (strcmp(argv[i], "-i") == 0) { - if ((argc == i+1) || - (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-i need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-i", strlen("-i"))) + || (0 == strncmp(argv[i], "--insert-interval", strlen("--insert-interval")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "i"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "i"); + exit(EXIT_FAILURE); + } + arguments->insert_interval = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--insert-interval=", strlen("--insert-interval="))) { + if (isStringNumber((char *)(argv[i] + strlen("--insert-interval=")))) { + arguments->insert_interval = atoi((char *)(argv[i]+strlen("--insert-interval="))); + } else { + errorPrintReqArg3(argv[0], "--insert-innterval"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-i", strlen("-i"))) { + if (isStringNumber((char *)(argv[i] + strlen("-i")))) { + arguments->insert_interval = atoi((char *)(argv[i]+strlen("-i"))); + } else { + errorPrintReqArg3(argv[0], "-i"); + exit(EXIT_FAILURE); + } + } else if (strlen("--insert-interval")== strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--insert-interval"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--insert-interval"); + exit(EXIT_FAILURE); + } + arguments->insert_interval = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->insert_interval = atoi(argv[++i]); - } else if (strcmp(argv[i], "-S") == 0) { - if ((argc == i+1) || - (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("\n\t%s%s", argv[i], " need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-S", strlen("-S"))) + || (0 == strncmp(argv[i], "--time-step", strlen("--time-step")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "S"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "S"); + exit(EXIT_FAILURE); + } + arguments->async_mode = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--time-step=", strlen("--time-step="))) { + if (isStringNumber((char *)(argv[i] + strlen("--time-step=")))) { + arguments->async_mode = atoi((char *)(argv[i]+strlen("--time-step="))); + } else { + errorPrintReqArg2(argv[0], "--time-step"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-S", strlen("-S"))) { + if (isStringNumber((char *)(argv[i] + strlen("-S")))) { + arguments->async_mode = atoi((char *)(argv[i]+strlen("-S"))); + } else { + errorPrintReqArg2(argv[0], "-S"); + exit(EXIT_FAILURE); + } + } else if (strlen("--time-step") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--time-step"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--time-step"); + exit(EXIT_FAILURE); + } + arguments->async_mode = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->timestamp_step = atoi(argv[++i]); } else if (strcmp(argv[i], "-qt") == 0) { if ((argc == i+1) || (!isStringNumber(argv[i+1]))) { @@ -942,56 +1267,221 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { exit(EXIT_FAILURE); } arguments->query_times = atoi(argv[++i]); - } else if (strcmp(argv[i], "-B") == 0) { - if ((argc == i+1) - || (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-B need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-B", strlen("-B"))) + || (0 == strncmp(argv[i], "--interlace-rows", strlen("--interlace-rows")))) { + if (strlen("-B") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "B"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "B"); + exit(EXIT_FAILURE); + } + arguments->interlace_rows = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--interlace-rows=", strlen("--interlace-rows="))) { + if (isStringNumber((char *)(argv[i] + strlen("--interlace-rows=")))) { + arguments->interlace_rows = atoi((char *)(argv[i]+strlen("--interlace-rows="))); + } else { + errorPrintReqArg2(argv[0], "--interlace-rows"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-B", strlen("-B"))) { + if (isStringNumber((char *)(argv[i] + strlen("-B")))) { + arguments->interlace_rows = atoi((char *)(argv[i]+strlen("-B"))); + } else { + errorPrintReqArg2(argv[0], "-B"); + exit(EXIT_FAILURE); + } + } else if (strlen("--interlace-rows")== strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--interlace-rows"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--interlace-rows"); + exit(EXIT_FAILURE); + } + arguments->interlace_rows = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->interlace_rows = atoi(argv[++i]); - } else if (strcmp(argv[i], "-r") == 0) { - if ((argc == i+1) - || (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-r need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-r", strlen("-r"))) + || (0 == strncmp(argv[i], "--rec-per-req", 13))) { + if (strlen("-r") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "r"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "r"); + exit(EXIT_FAILURE); + } + arguments->num_of_RPR = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--rec-per-req=", strlen("--rec-per-req="))) { + if (isStringNumber((char *)(argv[i] + strlen("--rec-per-req=")))) { + arguments->num_of_RPR = atoi((char *)(argv[i]+strlen("--rec-per-req="))); + } else { + errorPrintReqArg2(argv[0], "--rec-per-req"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-r", strlen("-r"))) { + if (isStringNumber((char *)(argv[i] + strlen("-r")))) { + arguments->num_of_RPR = atoi((char *)(argv[i]+strlen("-r"))); + } else { + errorPrintReqArg2(argv[0], "-r"); + exit(EXIT_FAILURE); + } + } else if (strlen("--rec-per-req")== strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--rec-per-req"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--rec-per-req"); + exit(EXIT_FAILURE); + } + arguments->num_of_RPR = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->num_of_RPR = atoi(argv[++i]); - } else if (strcmp(argv[i], "-t") == 0) { - if ((argc == i+1) || - (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-t need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-t", strlen("-t"))) + || (0 == strncmp(argv[i], "--tables", strlen("--tables")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "t"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "t"); + exit(EXIT_FAILURE); + } + arguments->num_of_tables = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--tables=", strlen("--tables="))) { + if (isStringNumber((char *)(argv[i] + strlen("--tables=")))) { + arguments->num_of_tables = atoi((char *)(argv[i]+strlen("--tables="))); + } else { + errorPrintReqArg2(argv[0], "--tables"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-t", strlen("-t"))) { + if (isStringNumber((char *)(argv[i] + strlen("-t")))) { + arguments->num_of_tables = atoi((char *)(argv[i]+strlen("-t"))); + } else { + errorPrintReqArg2(argv[0], "-t"); + exit(EXIT_FAILURE); + } + } else if (strlen("--tables") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--tables"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--tables"); + exit(EXIT_FAILURE); + } + arguments->num_of_tables = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->num_of_tables = atoi(argv[++i]); + g_totalChildTables = arguments->num_of_tables; - } else if (strcmp(argv[i], "-n") == 0) { - if ((argc == i+1) || - (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-n need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-n", strlen("-n"))) + || (0 == strncmp(argv[i], "--records", strlen("--records")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "n"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "n"); + exit(EXIT_FAILURE); + } + arguments->num_of_DPT = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--records=", strlen("--records="))) { + if (isStringNumber((char *)(argv[i] + strlen("--records=")))) { + arguments->num_of_DPT = atoi((char *)(argv[i]+strlen("--records="))); + } else { + errorPrintReqArg2(argv[0], "--records"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-n", strlen("-n"))) { + if (isStringNumber((char *)(argv[i] + strlen("-n")))) { + arguments->num_of_DPT = atoi((char *)(argv[i]+strlen("-n"))); + } else { + errorPrintReqArg2(argv[0], "-n"); + exit(EXIT_FAILURE); + } + } else if (strlen("--records") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--records"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--records"); + exit(EXIT_FAILURE); + } + arguments->num_of_DPT = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->num_of_DPT = atoi(argv[++i]); - } else if (strcmp(argv[i], "-d") == 0) { - if (argc == i+1) { - printHelp(); - errorPrint("%s", "\n\t-d need a valid string following!\n"); + } else if ((0 == strncmp(argv[i], "-d", strlen("-d"))) + || (0 == strncmp(argv[i], "--database", strlen("--database")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "d"); + exit(EXIT_FAILURE); + } + arguments->database = argv[++i]; + } else if (0 == strncmp(argv[i], "--database=", strlen("--database="))) { + arguments->output_file = (char *)(argv[i] + strlen("--database=")); + } else if (0 == strncmp(argv[i], "-d", strlen("-d"))) { + arguments->output_file = (char *)(argv[i] + strlen("-d")); + } else if (strlen("--database") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--database"); + exit(EXIT_FAILURE); + } + arguments->database = argv[++i]; + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->database = argv[++i]; - } else if (strcmp(argv[i], "-l") == 0) { + } else if ((0 == strncmp(argv[i], "-l", strlen("-l"))) + || (0 == strncmp(argv[i], "--columns", strlen("--columns")))) { arguments->demo_mode = false; - if (argc == i+1) { - if (!isStringNumber(argv[i+1])) { - printHelp(); - errorPrint("%s", "\n\t-l need a number following!\n"); + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "l"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "l"); + exit(EXIT_FAILURE); + } + arguments->num_of_CPR = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--columns=", strlen("--columns="))) { + if (isStringNumber((char *)(argv[i] + strlen("--columns=")))) { + arguments->num_of_CPR = atoi((char *)(argv[i]+strlen("--columns="))); + } else { + errorPrintReqArg2(argv[0], "--columns"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-l", strlen("-l"))) { + if (isStringNumber((char *)(argv[i] + strlen("-l")))) { + arguments->num_of_CPR = atoi((char *)(argv[i]+strlen("-l"))); + } else { + errorPrintReqArg2(argv[0], "-l"); + exit(EXIT_FAILURE); + } + } else if (strlen("--columns")== strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--columns"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--columns"); exit(EXIT_FAILURE); } + arguments->num_of_CPR = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); + exit(EXIT_FAILURE); } - arguments->num_of_CPR = atoi(argv[++i]); if (arguments->num_of_CPR > MAX_NUM_COLUMNS) { printf("WARNING: max acceptible columns count is %d\n", MAX_NUM_COLUMNS); @@ -1005,36 +1495,54 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { for (int col = arguments->num_of_CPR; col < MAX_NUM_COLUMNS; col++) { arguments->datatype[col] = NULL; } - } else if (strcmp(argv[i], "-b") == 0) { + } else if ((0 == strncmp(argv[i], "-b", strlen("-b"))) + || (0 == strncmp(argv[i], "--data-type", strlen("--data-type")))) { arguments->demo_mode = false; - if (argc == i+1) { - printHelp(); - errorPrint("%s", "\n\t-b need valid string following!\n"); + + char *dataType; + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "b"); + exit(EXIT_FAILURE); + } + dataType = argv[++i]; + } else if (0 == strncmp(argv[i], "--data-type=", strlen("--data-type="))) { + dataType = (char *)(argv[i] + strlen("--data-type=")); + } else if (0 == strncmp(argv[i], "-b", strlen("-b"))) { + dataType = (char *)(argv[i] + strlen("-b")); + } else if (strlen("--data-type") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--data-type"); + exit(EXIT_FAILURE); + } + dataType = argv[++i]; + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - ++i; - if (strstr(argv[i], ",") == NULL) { + + if (strstr(dataType, ",") == NULL) { // only one col - if (strcasecmp(argv[i], "INT") - && strcasecmp(argv[i], "FLOAT") - && strcasecmp(argv[i], "TINYINT") - && strcasecmp(argv[i], "BOOL") - && strcasecmp(argv[i], "SMALLINT") - && strcasecmp(argv[i], "BIGINT") - && strcasecmp(argv[i], "DOUBLE") - && strcasecmp(argv[i], "BINARY") - && strcasecmp(argv[i], "TIMESTAMP") - && strcasecmp(argv[i], "NCHAR")) { + if (strcasecmp(dataType, "INT") + && strcasecmp(dataType, "FLOAT") + && strcasecmp(dataType, "TINYINT") + && strcasecmp(dataType, "BOOL") + && strcasecmp(dataType, "SMALLINT") + && strcasecmp(dataType, "BIGINT") + && strcasecmp(dataType, "DOUBLE") + && strcasecmp(dataType, "BINARY") + && strcasecmp(dataType, "TIMESTAMP") + && strcasecmp(dataType, "NCHAR")) { printHelp(); errorPrint("%s", "-b: Invalid data_type!\n"); exit(EXIT_FAILURE); } - arguments->datatype[0] = argv[i]; + arguments->datatype[0] = dataType; arguments->datatype[1] = NULL; } else { // more than one col int index = 0; - g_dupstr = strdup(argv[i]); + g_dupstr = strdup(dataType); char *running = g_dupstr; char *token = strsep(&running, ","); while(token != NULL) { @@ -1059,75 +1567,227 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { } arguments->datatype[index] = NULL; } - } else if (strcmp(argv[i], "-w") == 0) { - if ((argc == i+1) || - (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-w need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-w", strlen("-w"))) + || (0 == strncmp(argv[i], "--binwidth", strlen("--binwidth")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "w"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "w"); + exit(EXIT_FAILURE); + } + arguments->binwidth = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--binwidth=", strlen("--binwidth="))) { + if (isStringNumber((char *)(argv[i] + strlen("--binwidth=")))) { + arguments->binwidth = atoi((char *)(argv[i]+strlen("--binwidth="))); + } else { + errorPrintReqArg2(argv[0], "--binwidth"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-w", strlen("-w"))) { + if (isStringNumber((char *)(argv[i] + strlen("-w")))) { + arguments->binwidth = atoi((char *)(argv[i]+strlen("-w"))); + } else { + errorPrintReqArg2(argv[0], "-w"); + exit(EXIT_FAILURE); + } + } else if (strlen("--binwidth") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--binwidth"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--binwidth"); + exit(EXIT_FAILURE); + } + arguments->binwidth = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->len_of_binary = atoi(argv[++i]); - } else if (strcmp(argv[i], "-m") == 0) { - if ((argc == i+1) || - (isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-m need a letter-initial string following!\n"); + } else if ((0 == strncmp(argv[i], "-m", strlen("-m"))) + || (0 == strncmp(argv[i], "--table-prefix", strlen("--table-prefix")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "m"); + exit(EXIT_FAILURE); + } + arguments->tb_prefix = argv[++i]; + } else if (0 == strncmp(argv[i], "--table-prefix=", strlen("--table-prefix="))) { + arguments->tb_prefix = (char *)(argv[i] + strlen("--table-prefix=")); + } else if (0 == strncmp(argv[i], "-m", strlen("-m"))) { + arguments->tb_prefix = (char *)(argv[i] + strlen("-m")); + } else if (strlen("--table-prefix") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--table-prefix"); + exit(EXIT_FAILURE); + } + arguments->tb_prefix = argv[++i]; + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->tb_prefix = argv[++i]; - } else if (strcmp(argv[i], "-N") == 0) { + } else if ((strcmp(argv[i], "-N") == 0) + || (0 == strcmp(argv[i], "--normal-table"))) { arguments->use_metric = false; - } else if (strcmp(argv[i], "-M") == 0) { + } else if ((strcmp(argv[i], "-M") == 0) + || (0 == strcmp(argv[i], "--random"))) { arguments->demo_mode = false; - } else if (strcmp(argv[i], "-x") == 0) { + } else if ((strcmp(argv[i], "-x") == 0) + || (0 == strcmp(argv[i], "--no-insert"))) { arguments->insert_only = false; - } else if (strcmp(argv[i], "-y") == 0) { + } else if ((strcmp(argv[i], "-y") == 0) + || (0 == strcmp(argv[i], "--answer-yes"))) { arguments->answer_yes = true; - } else if (strcmp(argv[i], "-g") == 0) { + } else if ((strcmp(argv[i], "-g") == 0) + || (0 == strcmp(argv[i], "--debug"))) { arguments->debug_print = true; } else if (strcmp(argv[i], "-gg") == 0) { arguments->verbose_print = true; - } else if (strcmp(argv[i], "-PP") == 0) { - arguments->performance_print = true; - } else if (strcmp(argv[i], "-O") == 0) { - if ((argc == i+1) || - (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-O need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-O", strlen("-O"))) + || (0 == strncmp(argv[i], "--disorder", strlen("--disorder")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "O"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "O"); + exit(EXIT_FAILURE); + } + arguments->disorderRatio = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--disorder=", strlen("--disorder="))) { + if (isStringNumber((char *)(argv[i] + strlen("--disorder=")))) { + arguments->disorderRatio = atoi((char *)(argv[i]+strlen("--disorder="))); + } else { + errorPrintReqArg2(argv[0], "--disorder"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-O", strlen("-O"))) { + if (isStringNumber((char *)(argv[i] + strlen("-O")))) { + arguments->disorderRatio = atoi((char *)(argv[i]+strlen("-O"))); + } else { + errorPrintReqArg2(argv[0], "-O"); + exit(EXIT_FAILURE); + } + } else if (strlen("--disorder") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--disorder"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--disorder"); + exit(EXIT_FAILURE); + } + arguments->disorderRatio = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->disorderRatio = atoi(argv[++i]); - if (arguments->disorderRatio > 50) { + errorPrint("Invalid disorder ratio %d, will be set to %d\n", + arguments->disorderRatio, 50); arguments->disorderRatio = 50; } if (arguments->disorderRatio < 0) { + errorPrint("Invalid disorder ratio %d, will be set to %d\n", + arguments->disorderRatio, 0); arguments->disorderRatio = 0; } + } else if ((0 == strncmp(argv[i], "-R", strlen("-R"))) + || (0 == strncmp(argv[i], "--disorder-range", + strlen("--disorder-range")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "R"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "R"); + exit(EXIT_FAILURE); + } + arguments->disorderRange = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--disorder-range=", + strlen("--disorder-range="))) { + if (isStringNumber((char *)(argv[i] + strlen("--disorder-range=")))) { + arguments->disorderRange = + atoi((char *)(argv[i]+strlen("--disorder-rnage="))); + } else { + errorPrintReqArg2(argv[0], "--disorder-range"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-R", strlen("-R"))) { + if (isStringNumber((char *)(argv[i] + strlen("-R")))) { + arguments->disorderRange = + atoi((char *)(argv[i]+strlen("-R"))); + } else { + errorPrintReqArg2(argv[0], "-R"); + exit(EXIT_FAILURE); + } - } else if (strcmp(argv[i], "-R") == 0) { - if ((argc == i+1) || - (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-R need a number following!\n"); + if (arguments->disorderRange < 0) { + errorPrint("Invalid disorder range %d, will be set to %d\n", + arguments->disorderRange, 1000); + arguments->disorderRange = 1000; + } + } else if (strlen("--disorder-range") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--disorder-range"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--disorder-range"); + exit(EXIT_FAILURE); + } + arguments->disorderRange = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - - arguments->disorderRange = atoi(argv[++i]); - if (arguments->disorderRange < 0) - arguments->disorderRange = 1000; - - } else if (strcmp(argv[i], "-a") == 0) { - if ((argc == i+1) || - (!isStringNumber(argv[i+1]))) { - printHelp(); - errorPrint("%s", "\n\t-a need a number following!\n"); + } else if ((0 == strncmp(argv[i], "-a", strlen("-a"))) + || (0 == strncmp(argv[i], "--replica", + strlen("--replica")))) { + if (2 == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg(argv[0], "a"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "a"); + exit(EXIT_FAILURE); + } + arguments->replica = atoi(argv[++i]); + } else if (0 == strncmp(argv[i], "--replica=", + strlen("--replica="))) { + if (isStringNumber((char *)(argv[i] + strlen("--replica=")))) { + arguments->replica = + atoi((char *)(argv[i]+strlen("--replica="))); + } else { + errorPrintReqArg2(argv[0], "--replica"); + exit(EXIT_FAILURE); + } + } else if (0 == strncmp(argv[i], "-a", strlen("-a"))) { + if (isStringNumber((char *)(argv[i] + strlen("-a")))) { + arguments->replica = + atoi((char *)(argv[i]+strlen("-a"))); + } else { + errorPrintReqArg2(argv[0], "-a"); + exit(EXIT_FAILURE); + } + } else if (strlen("--replica") == strlen(argv[i])) { + if (argc == i+1) { + errorPrintReqArg3(argv[0], "--replica"); + exit(EXIT_FAILURE); + } else if (!isStringNumber(argv[i+1])) { + errorPrintReqArg2(argv[0], "--replica"); + exit(EXIT_FAILURE); + } + arguments->replica = atoi(argv[++i]); + } else { + errorUnreconized(argv[0], argv[i]); exit(EXIT_FAILURE); } - arguments->replica = atoi(argv[++i]); + if (arguments->replica > 3 || arguments->replica < 1) { + errorPrint("Invalid replica value %d, will be set to %d\n", + arguments->replica, 1); arguments->replica = 1; } } else if (strcmp(argv[i], "-D") == 0) { @@ -1136,16 +1796,40 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { errorPrint("%s", "\n\t-D need a valud (0~3) number following!\n"); exit(EXIT_FAILURE); } - } else if ((strcmp(argv[i], "--version") == 0) || - (strcmp(argv[i], "-V") == 0)) { + } else if ((strcmp(argv[i], "--version") == 0) + || (strcmp(argv[i], "-V") == 0)) { printVersion(); exit(0); - } else if (strcmp(argv[i], "--help") == 0) { + } else if ((strcmp(argv[i], "--help") == 0) + || (strcmp(argv[i], "-?") == 0)) { printHelp(); exit(0); + } else if (strcmp(argv[i], "--usage") == 0) { + printf(" Usage: taosdemo [-f JSONFILE] [-u USER] [-p PASSWORD] [-c CONFIG_DIR]\n\ + [-h HOST] [-P PORT] [-I INTERFACE] [-d DATABASE] [-a REPLICA]\n\ + [-m TABLEPREFIX] [-s SQLFILE] [-N] [-o OUTPUTFILE] [-q QUERYMODE]\n\ + [-b DATATYPES] [-w WIDTH_OF_BINARY] [-l COLUNNS] [-T THREADNUMBER]\n\ + [-i SLEEPTIME] [-S TIME_STEP] [-B INTERLACE_ROWS] [-t TABLES]\n\ + [-n RECORDS] [-M] [-x] [-y] [-O ORDERMODE] [-R RANGE] [-a REPLIcA][-g]\n\ + [--help] [--usage] [--version]\n"); + exit(0); } else { - printHelp(); - errorPrint("%s", "ERROR: wrong options\n"); + // to simulate argp_option output + if (strlen(argv[i]) > 2) { + if (0 == strncmp(argv[i], "--", 2)) { + fprintf(stderr, "%s: unrecognized options '%s'\n", argv[0], argv[i]); + } else if (0 == strncmp(argv[i], "-", 1)) { + char tmp[2] = {0}; + tstrncpy(tmp, argv[i]+1, 2); + fprintf(stderr, "%s: invalid options -- '%s'\n", argv[0], tmp); + } else { + fprintf(stderr, "%s: Too many arguments\n", argv[0]); + } + } else { + fprintf(stderr, "%s invalid options -- '%s'\n", argv[0], + (char *)((char *)argv[i])+1); + } + fprintf(stderr, "Try `taosdemo --help' or `taosdemo --usage' for more information.\n"); exit(EXIT_FAILURE); } } @@ -1162,7 +1846,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { } g_args.num_of_CPR = columnCount; - if (((arguments->debug_print) && (arguments->metaFile == NULL)) + if (((arguments->debug_print) && (NULL != arguments->metaFile)) || arguments->verbose_print) { printf("###################################################################\n"); printf("# meta file: %s\n", arguments->metaFile); @@ -1175,9 +1859,9 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { arguments->use_metric ? "true" : "false"); if (*(arguments->datatype)) { printf("# Specified data type: "); - for (int i = 0; i < MAX_NUM_COLUMNS; i++) - if (arguments->datatype[i]) - printf("%s,", arguments->datatype[i]); + for (int c = 0; c < MAX_NUM_COLUMNS; c++) + if (arguments->datatype[c]) + printf("%s,", arguments->datatype[c]); else break; printf("\n"); @@ -1188,7 +1872,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { arguments->num_of_RPR); printf("# Max SQL length: %"PRIu64"\n", arguments->max_sql_len); - printf("# Length of Binary: %d\n", arguments->len_of_binary); + printf("# Length of Binary: %d\n", arguments->binwidth); printf("# Number of Threads: %d\n", arguments->num_of_threads); printf("# Number of Tables: %"PRId64"\n", arguments->num_of_tables); @@ -1644,7 +2328,7 @@ static int printfInsertMeta() { printf("resultFile: \033[33m%s\033[0m\n", g_Dbs.resultFile); printf("thread num of insert data: \033[33m%d\033[0m\n", g_Dbs.threadCount); printf("thread num of create table: \033[33m%d\033[0m\n", - g_Dbs.threadCountByCreateTbl); + g_Dbs.threadCountForCreateTbl); printf("top insert interval: \033[33m%"PRIu64"\033[0m\n", g_args.insert_interval); printf("number of records per req: \033[33m%u\033[0m\n", @@ -1852,7 +2536,7 @@ static void printfInsertMetaToFile(FILE* fp) { fprintf(fp, "configDir: %s\n", configDir); fprintf(fp, "resultFile: %s\n", g_Dbs.resultFile); fprintf(fp, "thread num of insert data: %d\n", g_Dbs.threadCount); - fprintf(fp, "thread num of create table: %d\n", g_Dbs.threadCountByCreateTbl); + fprintf(fp, "thread num of create table: %d\n", g_Dbs.threadCountForCreateTbl); fprintf(fp, "number of records per req: %u\n", g_args.num_of_RPR); fprintf(fp, "max sql length: %"PRIu64"\n", g_args.max_sql_len); fprintf(fp, "database count: %d\n", g_Dbs.dbCount); @@ -3452,7 +4136,7 @@ static void createChildTables() { startMultiThreadCreateChildTable( g_Dbs.db[i].superTbls[j].colsOfCreateChildTable, - g_Dbs.threadCountByCreateTbl, + g_Dbs.threadCountForCreateTbl, startFrom, g_Dbs.db[i].superTbls[j].childTblCount, g_Dbs.db[i].dbName, &(g_Dbs.db[i].superTbls[j])); @@ -3466,7 +4150,7 @@ static void createChildTables() { || (strncasecmp(g_args.datatype[j], "NCHAR", strlen("NCHAR")) == 0)) { snprintf(tblColsBuf + len, TSDB_MAX_BYTES_PER_ROW - len, - ",C%d %s(%d)", j, g_args.datatype[j], g_args.len_of_binary); + ",C%d %s(%d)", j, g_args.datatype[j], g_args.binwidth); } else { snprintf(tblColsBuf + len, TSDB_MAX_BYTES_PER_ROW - len, ",C%d %s", j, g_args.datatype[j]); @@ -3481,7 +4165,7 @@ static void createChildTables() { g_Dbs.db[i].dbName, g_args.num_of_tables, tblColsBuf); startMultiThreadCreateChildTable( tblColsBuf, - g_Dbs.threadCountByCreateTbl, + g_Dbs.threadCountForCreateTbl, 0, g_args.num_of_tables, g_Dbs.db[i].dbName, @@ -3838,9 +4522,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { cJSON* threads2 = cJSON_GetObjectItem(root, "thread_count_create_tbl"); if (threads2 && threads2->type == cJSON_Number) { - g_Dbs.threadCountByCreateTbl = threads2->valueint; + g_Dbs.threadCountForCreateTbl = threads2->valueint; } else if (!threads2) { - g_Dbs.threadCountByCreateTbl = 1; + g_Dbs.threadCountForCreateTbl = 1; } else { errorPrint("%s", "failed to read json, threads2 not found\n"); goto PARSE_OVER; @@ -4202,7 +4886,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { if (batchCreateTbl && batchCreateTbl->type == cJSON_Number) { g_Dbs.db[i].superTbls[j].batchCreateTableNum = batchCreateTbl->valueint; } else if (!batchCreateTbl) { - g_Dbs.db[i].superTbls[j].batchCreateTableNum = 1000; + g_Dbs.db[i].superTbls[j].batchCreateTableNum = 10; } else { errorPrint("%s", "failed to read json, batch_create_tbl_num not found\n"); goto PARSE_OVER; @@ -5293,12 +5977,85 @@ static int64_t generateData(char *recBuf, char **data_type, return (int32_t)strlen(recBuf); } +static int generateSampleMemoryFromRand(SSuperTable *stbInfo) +{ + char data[MAX_DATA_SIZE]; + memset(data, 0, MAX_DATA_SIZE); + + char *buff = malloc(stbInfo->lenOfOneRow); + if (NULL == buff) { + errorPrint2("%s() LN%d, memory allocation %"PRId64" bytes failed\n", + __func__, __LINE__, stbInfo->lenOfOneRow); + exit(EXIT_FAILURE); + } + + for (int i=0; i < MAX_SAMPLES_ONCE_FROM_FILE; i++) { + uint64_t pos = 0; + memset(buff, 0, stbInfo->lenOfOneRow); + + for (int c = 0; c < stbInfo->columnCount; c++) { + char *tmp; + if (0 == strncasecmp(stbInfo->columns[c].dataType, + "BINARY", strlen("BINARY"))) { + rand_string(data, stbInfo->columns[c].dataLen); + pos += sprintf(buff + pos, "%s,", data); + } else if (0 == strncasecmp(stbInfo->columns[c].dataType, + "NCHAR", strlen("NCHAR"))) { + rand_string(data, stbInfo->columns[c].dataLen); + pos += sprintf(buff + pos, "%s,", data); + } else if (0 == strncasecmp(stbInfo->columns[c].dataType, + "INT", strlen("INT"))) { + if ((g_args.demo_mode) && (c == 1)) { + tmp = demo_voltage_int_str(); + } else { + tmp = rand_int_str(); + } + pos += sprintf(buff + pos, "%s,", tmp); + } else if (0 == strncasecmp(stbInfo->columns[c].dataType, + "BIGINT", strlen("BIGINT"))) { + pos += sprintf(buff + pos, "%s,", rand_bigint_str()); + } else if (0 == strncasecmp(stbInfo->columns[c].dataType, + "FLOAT", strlen("FLOAT"))) { + if (g_args.demo_mode) { + if (c == 0) { + tmp = demo_current_float_str(); + } else { + tmp = demo_phase_float_str(); + } + } else { + tmp = rand_float_str(); + } + pos += sprintf(buff + pos, "%s,", tmp); + } else if (0 == strncasecmp(stbInfo->columns[c].dataType, + "DOUBLE", strlen("DOUBLE"))) { + pos += sprintf(buff + pos, "%s,", rand_double_str()); + } else if (0 == strncasecmp(stbInfo->columns[c].dataType, + "SMALLINT", strlen("SMALLINT"))) { + pos += sprintf(buff + pos, "%s,", rand_smallint_str()); + } else if (0 == strncasecmp(stbInfo->columns[c].dataType, + "TINYINT", strlen("TINYINT"))) { + pos += sprintf(buff + pos, "%s,", rand_tinyint_str()); + } else if (0 == strncasecmp(stbInfo->columns[c].dataType, + "BOOL", strlen("BOOL"))) { + pos += sprintf(buff + pos, "%s,", rand_bool_str()); + } else if (0 == strncasecmp(stbInfo->columns[c].dataType, + "TIMESTAMP", strlen("TIMESTAMP"))) { + pos += sprintf(buff + pos, "%s,", rand_bigint_str()); + } + } + *(buff + pos - 1) = 0; + memcpy(stbInfo->sampleDataBuf + i * stbInfo->lenOfOneRow, buff, pos); + } + + free(buff); + return 0; +} + static int prepareSampleDataForSTable(SSuperTable *stbInfo) { - char* sampleDataBuf = NULL; - sampleDataBuf = calloc( + stbInfo->sampleDataBuf = calloc( stbInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE, 1); - if (sampleDataBuf == NULL) { + if (NULL == stbInfo->sampleDataBuf) { errorPrint2("%s() LN%d, Failed to calloc %"PRIu64" Bytes, reason:%s\n", __func__, __LINE__, stbInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE, @@ -5306,13 +6063,16 @@ static int prepareSampleDataForSTable(SSuperTable *stbInfo) { return -1; } - stbInfo->sampleDataBuf = sampleDataBuf; - int ret = readSampleFromCsvFileToMem(stbInfo); + int ret; + if (0 == strncasecmp(stbInfo->dataSource, "sample", strlen("sample"))) + ret = readSampleFromCsvFileToMem(stbInfo); + else + ret = generateSampleMemoryFromRand(stbInfo); if (0 != ret) { errorPrint2("%s() LN%d, read sample from csv file failed.\n", __func__, __LINE__); - tmfree(sampleDataBuf); + tmfree(stbInfo->sampleDataBuf); stbInfo->sampleDataBuf = NULL; return -1; } @@ -5430,7 +6190,7 @@ static int32_t generateDataTailWithoutStb( int64_t retLen = 0; char **data_type = g_args.datatype; - int lenOfBinary = g_args.len_of_binary; + int lenOfBinary = g_args.binwidth; if (g_args.disorderRatio) { retLen = generateData(data, data_type, @@ -6212,7 +6972,7 @@ static int32_t prepareStmtWithoutStb( if ( -1 == prepareStmtBindArrayByType( bind, data_type[i], - g_args.len_of_binary, + g_args.binwidth, pThreadInfo->time_precision, NULL)) { return -1; @@ -6246,7 +7006,7 @@ static int32_t prepareStbStmtBindTag( char *tagsVal, int32_t timePrec) { - char *bindBuffer = calloc(1, DOUBLE_BUFF_LEN); // g_args.len_of_binary); + char *bindBuffer = calloc(1, DOUBLE_BUFF_LEN); // g_args.binwidth); if (bindBuffer == NULL) { errorPrint2("%s() LN%d, Failed to allocate %d bind buffer\n", __func__, __LINE__, DOUBLE_BUFF_LEN); @@ -6278,7 +7038,7 @@ static int32_t prepareStbStmtBindRand( int64_t startTime, int32_t recSeq, int32_t timePrec) { - char *bindBuffer = calloc(1, DOUBLE_BUFF_LEN); // g_args.len_of_binary); + char *bindBuffer = calloc(1, DOUBLE_BUFF_LEN); // g_args.binwidth); if (bindBuffer == NULL) { errorPrint2("%s() LN%d, Failed to allocate %d bind buffer\n", __func__, __LINE__, DOUBLE_BUFF_LEN); @@ -7030,11 +7790,14 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) { pstr += len; remainderBufLen -= len; + // measure prepare + insert + startTs = taosGetTimestampUs(); + int32_t generated; if (stbInfo) { if (stbInfo->iface == STMT_IFACE) { if (sourceRand) { - generated = prepareStbStmtRand( +/* generated = prepareStbStmtRand( pThreadInfo, tableName, tableSeq, @@ -7042,6 +7805,14 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) { insertRows, i, start_time ); + */ + generated = prepareStbStmtWithSample( + pThreadInfo, + tableName, + tableSeq, + g_args.num_of_RPR, + insertRows, i, start_time, + &(pThreadInfo->samplePos)); } else { generated = prepareStbStmtWithSample( pThreadInfo, @@ -7086,7 +7857,8 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) { start_time += generated * timeStampStep; pThreadInfo->totalInsertRows += generated; - startTs = taosGetTimestampUs(); + // only measure insert + // startTs = taosGetTimestampUs(); int32_t affectedRows = execInsert(pThreadInfo, generated); @@ -7296,7 +8068,6 @@ static int parseSampleFileToStmt(SSuperTable *stbInfo, uint32_t timePrec) return -1; } - for (int i=0; i < MAX_SAMPLES_ONCE_FROM_FILE; i++) { char *bindArray = calloc(1, sizeof(TAOS_BIND) * (stbInfo->columnCount + 1)); if (bindArray == NULL) { @@ -7305,7 +8076,6 @@ static int parseSampleFileToStmt(SSuperTable *stbInfo, uint32_t timePrec) return -1; } - TAOS_BIND *bind; int cursor = 0; @@ -7389,16 +8159,13 @@ static void startMultiThreadInsertData(int threads, char* db_name, } } } else { - start_time = 1500000000000; + start_time = DEFAULT_START_TIME; } debugPrint("%s() LN%d, start_time= %"PRId64"\n", __func__, __LINE__, start_time); - int64_t start = taosGetTimestampMs(); - // read sample data from file first - if ((stbInfo) && (0 == strncasecmp(stbInfo->dataSource, - "sample", strlen("sample")))) { + if (stbInfo) { if (0 != prepareSampleDataForSTable(stbInfo)) { errorPrint2("%s() LN%d, prepare sample data for stable failed!\n", __func__, __LINE__); @@ -7546,8 +8313,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, debugPrint("%s() LN%d, stmtBuffer: %s", __func__, __LINE__, stmtBuffer); - if ((stbInfo) && (0 == strncasecmp(stbInfo->dataSource, - "sample", strlen("sample")))) { + if (stbInfo) { parseSampleFileToStmt(stbInfo, timePrec); } } @@ -7632,6 +8398,8 @@ static void startMultiThreadInsertData(int threads, char* db_name, free(stmtBuffer); + int64_t start = taosGetTimestampMs(); + for (int i = 0; i < threads; i++) { pthread_join(pids[i], NULL); } @@ -7674,22 +8442,22 @@ static void startMultiThreadInsertData(int threads, char* db_name, if (cntDelay == 0) cntDelay = 1; avgDelay = (double)totalDelay / cntDelay; - int64_t end = taosGetTimestampMs(); + int64_t end = taosGetTimestampMs(); int64_t t = end - start; - double tInMs = t/1000.0; + double tInMs = (double) t / 1000.0; if (stbInfo) { - fprintf(stderr, "Spent %.2f seconds to insert rows: %"PRIu64", affected rows: %"PRIu64" with %d thread(s) into %s.%s. %.2f records/second\n\n", + fprintf(stderr, "Spent %.4f seconds to insert rows: %"PRIu64", affected rows: %"PRIu64" with %d thread(s) into %s.%s. %.2f records/second\n\n", tInMs, stbInfo->totalInsertRows, stbInfo->totalAffectedRows, threads, db_name, stbInfo->sTblName, - (tInMs)? + (double) tInMs? (double)(stbInfo->totalInsertRows/tInMs):FLT_MAX); if (g_fpOfInsertResult) { fprintf(g_fpOfInsertResult, - "Spent %.2f seconds to insert rows: %"PRIu64", affected rows: %"PRIu64" with %d thread(s) into %s.%s. %.2f records/second\n\n", + "Spent %.4f seconds to insert rows: %"PRIu64", affected rows: %"PRIu64" with %d thread(s) into %s.%s. %.2f records/second\n\n", tInMs, stbInfo->totalInsertRows, stbInfo->totalAffectedRows, threads, db_name, stbInfo->sTblName, @@ -7697,7 +8465,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, (double)(stbInfo->totalInsertRows/tInMs):FLT_MAX); } } else { - fprintf(stderr, "Spent %.2f seconds to insert rows: %"PRIu64", affected rows: %"PRIu64" with %d thread(s) into %s %.2f records/second\n\n", + fprintf(stderr, "Spent %.4f seconds to insert rows: %"PRIu64", affected rows: %"PRIu64" with %d thread(s) into %s %.2f records/second\n\n", tInMs, g_args.totalInsertRows, g_args.totalAffectedRows, threads, db_name, @@ -7705,7 +8473,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, (double)(g_args.totalInsertRows/tInMs):FLT_MAX); if (g_fpOfInsertResult) { fprintf(g_fpOfInsertResult, - "Spent %.2f seconds to insert rows: %"PRIu64", affected rows: %"PRIu64" with %d thread(s) into %s %.2f records/second\n\n", + "Spent %.4f seconds to insert rows: %"PRIu64", affected rows: %"PRIu64" with %d thread(s) into %s %.2f records/second\n\n", tInMs, g_args.totalInsertRows, g_args.totalAffectedRows, threads, db_name, @@ -7944,11 +8712,11 @@ static int insertTestProcess() { if (g_totalChildTables > 0) { fprintf(stderr, "creating %"PRId64" table(s) with %d thread(s)\n\n", - g_totalChildTables, g_Dbs.threadCountByCreateTbl); + g_totalChildTables, g_Dbs.threadCountForCreateTbl); if (g_fpOfInsertResult) { fprintf(g_fpOfInsertResult, "creating %"PRId64" table(s) with %d thread(s)\n\n", - g_totalChildTables, g_Dbs.threadCountByCreateTbl); + g_totalChildTables, g_Dbs.threadCountForCreateTbl); } // create child tables @@ -7959,12 +8727,12 @@ static int insertTestProcess() { fprintf(stderr, "\nSpent %.4f seconds to create %"PRId64" table(s) with %d thread(s), actual %"PRId64" table(s) created\n\n", (end - start)/1000.0, g_totalChildTables, - g_Dbs.threadCountByCreateTbl, g_actualChildTables); + g_Dbs.threadCountForCreateTbl, g_actualChildTables); if (g_fpOfInsertResult) { fprintf(g_fpOfInsertResult, "\nSpent %.4f seconds to create %"PRId64" table(s) with %d thread(s), actual %"PRId64" table(s) created\n\n", (end - start)/1000.0, g_totalChildTables, - g_Dbs.threadCountByCreateTbl, g_actualChildTables); + g_Dbs.threadCountForCreateTbl, g_actualChildTables); } } @@ -8879,7 +9647,7 @@ static void setParaFromArg() { } g_Dbs.threadCount = g_args.num_of_threads; - g_Dbs.threadCountByCreateTbl = g_args.num_of_threads; + g_Dbs.threadCountForCreateTbl = g_args.num_of_threads; g_Dbs.dbCount = 1; g_Dbs.db[0].drop = true; @@ -8911,7 +9679,7 @@ static void setParaFromArg() { tstrncpy(g_Dbs.db[0].superTbls[0].sTblName, "meters", TSDB_TABLE_NAME_LEN); g_Dbs.db[0].superTbls[0].childTblCount = g_args.num_of_tables; g_Dbs.threadCount = g_args.num_of_threads; - g_Dbs.threadCountByCreateTbl = g_args.num_of_threads; + g_Dbs.threadCountForCreateTbl = g_args.num_of_threads; g_Dbs.asyncMode = g_args.async_mode; g_Dbs.db[0].superTbls[0].autoCreateTable = PRE_CREATE_SUBTBL; @@ -8942,7 +9710,7 @@ static void setParaFromArg() { tstrncpy(g_Dbs.db[0].superTbls[0].columns[i].dataType, data_type[i], min(DATATYPE_BUFF_LEN, strlen(data_type[i]) + 1)); - g_Dbs.db[0].superTbls[0].columns[i].dataLen = g_args.len_of_binary; + g_Dbs.db[0].superTbls[0].columns[i].dataLen = g_args.binwidth; g_Dbs.db[0].superTbls[0].columnCount++; } @@ -8964,10 +9732,10 @@ static void setParaFromArg() { tstrncpy(g_Dbs.db[0].superTbls[0].tags[1].dataType, "BINARY", min(DATATYPE_BUFF_LEN, strlen("BINARY") + 1)); - g_Dbs.db[0].superTbls[0].tags[1].dataLen = g_args.len_of_binary; + g_Dbs.db[0].superTbls[0].tags[1].dataLen = g_args.binwidth; g_Dbs.db[0].superTbls[0].tagCount = 2; } else { - g_Dbs.threadCountByCreateTbl = g_args.num_of_threads; + g_Dbs.threadCountForCreateTbl = g_args.num_of_threads; g_Dbs.db[0].superTbls[0].tagCount = 0; } } @@ -9089,7 +9857,7 @@ static void queryResult() { pthread_t read_id; threadInfo *pThreadInfo = calloc(1, sizeof(threadInfo)); assert(pThreadInfo); - pThreadInfo->start_time = 1500000000000; // 2017-07-14 10:40:00.000 + pThreadInfo->start_time = DEFAULT_START_TIME; // 2017-07-14 10:40:00.000 pThreadInfo->start_table_from = 0; //pThreadInfo->do_aggreFunc = g_Dbs.do_aggreFunc; @@ -9156,6 +9924,7 @@ int main(int argc, char *argv[]) { debugPrint("meta file: %s\n", g_args.metaFile); if (g_args.metaFile) { + g_totalChildTables = 0; initOfInsertMeta(); initOfQueryMeta(); diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index 30b5d91b10d3c67ad00d6be9716e81ac4ae581af..ae2193a82eb447f0e948abc1757c21cab46ccf34 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -225,16 +225,15 @@ static struct argp_option options[] = { {"password", 'p', 0, 0, "User password to connect to server. Default is taosdata.", 0}, #endif {"port", 'P', "PORT", 0, "Port to connect", 0}, - {"cversion", 'v', "CVERION", 0, "client version", 0}, {"mysqlFlag", 'q', "MYSQLFLAG", 0, "mysqlFlag, Default is 0", 0}, // input/output file {"outpath", 'o', "OUTPATH", 0, "Output file path.", 1}, {"inpath", 'i', "INPATH", 0, "Input file path.", 1}, {"resultFile", 'r', "RESULTFILE", 0, "DumpOut/In Result file path and name.", 1}, #ifdef _TD_POWER_ - {"config", 'c', "CONFIG_DIR", 0, "Configure directory. Default is /etc/power/taos.cfg.", 1}, + {"config-dir", 'c', "CONFIG_DIR", 0, "Configure directory. Default is /etc/power/taos.cfg.", 1}, #else - {"config", 'c', "CONFIG_DIR", 0, "Configure directory. Default is /etc/taos/taos.cfg.", 1}, + {"config-dir", 'c', "CONFIG_DIR", 0, "Configure directory. Default is /etc/taos/taos.cfg.", 1}, #endif {"encode", 'e', "ENCODE", 0, "Input file encoding.", 1}, // dump unit options @@ -244,7 +243,7 @@ static struct argp_option options[] = { // dump format options {"schemaonly", 's', 0, 0, "Only dump schema.", 2}, {"without-property", 'N', 0, 0, "Dump schema without properties.", 2}, - {"avro", 'V', 0, 0, "Dump apache avro format data file. By default, dump sql command sequence.", 2}, + {"avro", 'v', 0, 0, "Dump apache avro format data file. By default, dump sql command sequence.", 2}, {"start-time", 'S', "START_TIME", 0, "Start time to dump. Either epoch or ISO8601/RFC3339 format is acceptable. ISO8601 format example: 2017-10-01T00:00:00.000+0800 or 2017-10-0100:00:00:000+0800 or '2017-10-01 00:00:00.000+0800'", 4}, {"end-time", 'E', "END_TIME", 0, "End time to dump. Either epoch or ISO8601/RFC3339 format is acceptable. ISO8601 format example: 2017-10-01T00:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 5}, #if TSDB_SUPPORT_NANOSECOND == 1 @@ -267,7 +266,6 @@ typedef struct arguments { char *user; char password[SHELL_MAX_PASSWORD_LEN]; uint16_t port; - char cversion[12]; uint16_t mysqlFlag; // output file char outpath[MAX_FILE_NAME_LEN]; @@ -338,7 +336,6 @@ struct arguments g_args = { "taosdata", #endif 0, - "", 0, // outpath and inpath "", @@ -370,6 +367,24 @@ struct arguments g_args = { false // performance_print }; +static void errorPrintReqArg2(char *program, char *wrong_arg) +{ + fprintf(stderr, + "%s: option requires a number argument '-%s'\n", + program, wrong_arg); + fprintf(stderr, + "Try `taosdump --help' or `taosdump --usage' for more information.\n"); +} + +static void errorPrintReqArg3(char *program, char *wrong_arg) +{ + fprintf(stderr, + "%s: option '%s' requires an argument\n", + program, wrong_arg); + fprintf(stderr, + "Try `taosdump --help' or `taosdump --usage' for more information.\n"); +} + /* Parse a single option. */ static error_t parse_opt(int key, char *arg, struct argp_state *state) { /* Get the input argument from argp_parse, which we @@ -390,20 +405,15 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case 'p': break; case 'P': + if (!isStringNumber(arg)) { + errorPrintReqArg2("taosdump", "P"); + exit(EXIT_FAILURE); + } g_args.port = atoi(arg); break; case 'q': g_args.mysqlFlag = atoi(arg); break; - case 'v': - if (wordexp(arg, &full_path, 0) != 0) { - errorPrint("Invalid client vesion %s\n", arg); - return -1; - } - tstrncpy(g_args.cversion, full_path.we_wordv[0], 11); - wordfree(&full_path); - break; - // output file path case 'o': if (wordexp(arg, &full_path, 0) != 0) { errorPrint("Invalid path %s\n", arg); @@ -430,9 +440,13 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { g_args.resultFile = arg; break; case 'c': + if (0 == strlen(arg)) { + errorPrintReqArg3("taosdump", "-c or --config-dir"); + exit(EXIT_FAILURE); + } if (wordexp(arg, &full_path, 0) != 0) { errorPrint("Invalid path %s\n", arg); - return -1; + exit(EXIT_FAILURE); } tstrncpy(configDir, full_path.we_wordv[0], MAX_FILE_NAME_LEN); wordfree(&full_path); @@ -453,7 +467,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case 'N': g_args.with_property = false; break; - case 'V': + case 'v': g_args.avro = true; break; case 'S': @@ -660,6 +674,9 @@ static void parse_timestamp( } int main(int argc, char *argv[]) { + static char verType[32] = {0}; + sprintf(verType, "version: %s\n", version); + argp_program_version = verType; int ret = 0; /* Parse our arguments; every option seen by parse_opt will be @@ -686,7 +703,6 @@ int main(int argc, char *argv[]) { printf("user: %s\n", g_args.user); printf("password: %s\n", g_args.password); printf("port: %u\n", g_args.port); - printf("cversion: %s\n", g_args.cversion); printf("mysqlFlag: %d\n", g_args.mysqlFlag); printf("outpath: %s\n", g_args.outpath); printf("inpath: %s\n", g_args.inpath); @@ -715,11 +731,6 @@ int main(int argc, char *argv[]) { } } printf("==============================\n"); - - if (g_args.cversion[0] != 0){ - tstrncpy(version, g_args.cversion, 11); - } - if (taosCheckParam(&g_args) < 0) { exit(EXIT_FAILURE); } @@ -737,7 +748,6 @@ int main(int argc, char *argv[]) { fprintf(g_fpOfResult, "user: %s\n", g_args.user); fprintf(g_fpOfResult, "password: %s\n", g_args.password); fprintf(g_fpOfResult, "port: %u\n", g_args.port); - fprintf(g_fpOfResult, "cversion: %s\n", g_args.cversion); fprintf(g_fpOfResult, "mysqlFlag: %d\n", g_args.mysqlFlag); fprintf(g_fpOfResult, "outpath: %s\n", g_args.outpath); fprintf(g_fpOfResult, "inpath: %s\n", g_args.inpath); diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index a4ecf5d6f321dee531ed8175bf54aa45d27c1a65..68529ab8a240c2313ae9417bef9f4112759b0c9f 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1518,6 +1518,13 @@ static int32_t mnodeChangeSuperTableColumn(SMnodeMsg *pMsg) { // update SSchema *schema = (SSchema *) (pStable->schema + col); ASSERT(schema->type == TSDB_DATA_TYPE_BINARY || schema->type == TSDB_DATA_TYPE_NCHAR); + + if (pAlter->schema[0].bytes <= schema->bytes) { + mError("msg:%p, app:%p stable:%s, modify column len. column:%s, len from %d to %d", pMsg, pMsg->rpcMsg.ahandle, + pStable->info.tableId, name, schema->bytes, pAlter->schema[0].bytes); + return TSDB_CODE_MND_INVALID_COLUMN_LENGTH; + } + schema->bytes = pAlter->schema[0].bytes; pStable->sversion++; mInfo("msg:%p, app:%p stable %s, start to modify column %s len to %d", pMsg, pMsg->rpcMsg.ahandle, pStable->info.tableId, @@ -1548,6 +1555,12 @@ static int32_t mnodeChangeSuperTableTag(SMnodeMsg *pMsg) { // update SSchema *schema = (SSchema *) (pStable->schema + col + pStable->numOfColumns); ASSERT(schema->type == TSDB_DATA_TYPE_BINARY || schema->type == TSDB_DATA_TYPE_NCHAR); + if (pAlter->schema[0].bytes <= schema->bytes) { + mError("msg:%p, app:%p stable:%s, modify tag len. tag:%s, len from %d to %d", pMsg, pMsg->rpcMsg.ahandle, + pStable->info.tableId, name, schema->bytes, pAlter->schema[0].bytes); + return TSDB_CODE_MND_INVALID_TAG_LENGTH; + } + schema->bytes = pAlter->schema[0].bytes; pStable->tversion++; mInfo("msg:%p, app:%p stable %s, start to modify tag len %s to %d", pMsg, pMsg->rpcMsg.ahandle, pStable->info.tableId, diff --git a/src/plugins/http/CMakeLists.txt b/src/plugins/http/CMakeLists.txt index 57fc2ee3a2692c239d7fa36d6e55ddae738a2720..89fdc141b66adafb9f882dd6f59eca54053aff6c 100644 --- a/src/plugins/http/CMakeLists.txt +++ b/src/plugins/http/CMakeLists.txt @@ -6,6 +6,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) diff --git a/src/plugins/http/src/httpRestHandle.c b/src/plugins/http/src/httpRestHandle.c index a029adec0c792be16e5288893ef0a2ef26c81f9c..24e4f90244cf52799fde1a45054875a4bf3d1850 100644 --- a/src/plugins/http/src/httpRestHandle.c +++ b/src/plugins/http/src/httpRestHandle.c @@ -19,6 +19,7 @@ #include "httpLog.h" #include "httpRestHandle.h" #include "httpRestJson.h" +#include "tglobal.h" static HttpDecodeMethod restDecodeMethod = {"rest", restProcessRequest}; static HttpDecodeMethod restDecodeMethod2 = {"restful", restProcessRequest}; @@ -111,6 +112,14 @@ bool restProcessSqlRequest(HttpContext* pContext, int32_t timestampFmt) { pContext->db[0] = '\0'; HttpString *path = &pContext->parser->path[REST_USER_USEDB_URL_POS]; + if (tsHttpDbNameMandatory) { + if (path->pos == 0) { + httpError("context:%p, fd:%d, user:%s, database name is mandatory", pContext, pContext->fd, pContext->user); + httpSendErrorResp(pContext, TSDB_CODE_HTTP_INVALID_URL); + return false; + } + } + if (path->pos > 0 && !(strlen(sql) > 4 && (sql[0] == 'u' || sql[0] == 'U') && (sql[1] == 's' || sql[1] == 'S') && (sql[2] == 'e' || sql[2] == 'E') && sql[3] == ' ')) { diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 4c67a9b44e938629bf728a55db81bebfe10d067c..31db6492f69c35904970cc5f48cc4a10c9fecd39 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -221,6 +221,7 @@ typedef struct SQueryAttr { bool distinct; // distinct query or not bool stateWindow; // window State on sub/normal table bool createFilterOperator; // if filter operator is needed + bool multigroupResult; // multigroup result can exist in one SSDataBlock int32_t interBufSize; // intermediate buffer sizse int32_t havingNum; // having expr number @@ -467,16 +468,23 @@ typedef struct SLimitOperatorInfo { } SLimitOperatorInfo; typedef struct SSLimitOperatorInfo { - int64_t groupTotal; - int64_t currentGroupOffset; - - int64_t rowsTotal; - int64_t currentOffset; - SLimitVal limit; - SLimitVal slimit; - - char **prevRow; - SArray *orderColumnList; + int64_t groupTotal; + int64_t currentGroupOffset; + + int64_t rowsTotal; + int64_t currentOffset; + SLimitVal limit; + SLimitVal slimit; + + char **prevRow; + SArray *orderColumnList; + bool hasPrev; + bool ignoreCurrentGroup; + bool multigroupResult; + SSDataBlock *pRes; // result buffer + SSDataBlock *pPrevBlock; + int64_t capacity; + int64_t threshold; } SSLimitOperatorInfo; typedef struct SFilterOperatorInfo { @@ -488,8 +496,9 @@ typedef struct SFillOperatorInfo { SFillInfo *pFillInfo; SSDataBlock *pRes; int64_t totalInputRows; - + void **p; SSDataBlock *existNewGroupBlock; + bool multigroupResult; } SFillOperatorInfo; typedef struct SGroupbyOperatorInfo { @@ -551,9 +560,9 @@ typedef struct SMultiwayMergeInfo { bool hasDataBlockForNewGroup; SSDataBlock *pExistBlock; - bool hasPrev; - bool groupMix; SArray *udfInfo; + bool hasPrev; + bool multiGroupResults; } SMultiwayMergeInfo; // todo support the disk-based sort @@ -575,7 +584,7 @@ SOperatorInfo* createLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI SOperatorInfo* createTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createAllTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createSWindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); -SOperatorInfo* createFillOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); +SOperatorInfo* createFillOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, bool multigroupResult); SOperatorInfo* createGroupbyOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createMultiTableAggOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); @@ -584,10 +593,10 @@ SOperatorInfo* createTagScanOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SExprInf SOperatorInfo* createDistinctOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createTableBlockInfoScanOperator(void* pTsdbQueryHandle, SQueryRuntimeEnv* pRuntimeEnv); SOperatorInfo* createMultiwaySortOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput, - int32_t numOfRows, void* merger, bool groupMix); -SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, void* param, SArray* pUdfInfo); + int32_t numOfRows, void* merger); +SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, void* param, SArray* pUdfInfo, bool groupResultMixedUp); SOperatorInfo* createStatewindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput); -SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, void* merger); +SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, void* merger, bool multigroupResult); SOperatorInfo* createFilterOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, SColumnInfo* pCols, int32_t numOfFilter); diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index 531ff06565dba837c696c6069d409ccf536cbe8c..c231c90996e00d84a70c7141eac69c5a59e20254 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -80,6 +80,7 @@ typedef struct tVariantListItem { } tVariantListItem; typedef struct SIntervalVal { + int32_t token; SStrToken interval; SStrToken offset; } SIntervalVal; diff --git a/src/query/inc/qTableMeta.h b/src/query/inc/qTableMeta.h index d6b04b033062bd17e451c0f9af4d2bf8f84190a1..746c5f8569ac98c465e8283a2401e27c18cadcc4 100644 --- a/src/query/inc/qTableMeta.h +++ b/src/query/inc/qTableMeta.h @@ -165,6 +165,7 @@ typedef struct SQueryInfo { bool orderProjectQuery; bool stateWindow; bool globalMerge; + bool multigroupResult; } SQueryInfo; /** diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 8b43e55693c53fffb19e73b5b9ef7ccada4383a2..8466b7262ab43e49496b078dd3ca25985fe6605a 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -162,7 +162,10 @@ cmd ::= DESCRIBE ids(X) cpxName(Y). { X.n += Y.n; setDCLSqlElems(pInfo, TSDB_SQL_DESCRIBE_TABLE, 1, &X); } - +cmd ::= DESC ids(X) cpxName(Y). { + X.n += Y.n; + setDCLSqlElems(pInfo, TSDB_SQL_DESCRIBE_TABLE, 1, &X); +} /////////////////////////////////THE ALTER STATEMENT//////////////////////////////////////// cmd ::= ALTER USER ids(X) PASS ids(Y). { setAlterUserSql(pInfo, TSDB_ALTER_USER_PASSWD, &X, &Y, NULL); } cmd ::= ALTER USER ids(X) PRIVILEGE ids(Y). { setAlterUserSql(pInfo, TSDB_ALTER_USER_PRIVILEGES, &X, NULL, &Y);} @@ -479,7 +482,7 @@ tagitem(A) ::= PLUS(X) FLOAT(Y). { //////////////////////// The SELECT statement ///////////////////////////////// %type select {SSqlNode*} %destructor select {destroySqlNode($$);} -select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) sliding_opt(S) session_option(H) windowstate_option(D) fill_opt(F)groupby_opt(P) having_opt(N) orderby_opt(Z) slimit_opt(G) limit_opt(L). { +select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_option(K) sliding_opt(S) session_option(H) windowstate_option(D) fill_opt(F)groupby_opt(P) having_opt(N) orderby_opt(Z) slimit_opt(G) limit_opt(L). { A = tSetQuerySqlNode(&T, W, X, Y, P, Z, &K, &H, &D, &S, F, &L, &G, N); } @@ -493,7 +496,7 @@ union(Y) ::= union(Z) UNION ALL select(X). { Y = appendSelectClause(Z, X); } cmd ::= union(X). { setSqlInfo(pInfo, X, NULL, TSDB_SQL_SELECT); } // Support for the SQL exprssion without from & where subclauses, e.g., -// select current_database() +// select database() // select server_version() // select client_version() // select server_state() @@ -569,10 +572,14 @@ tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z) ids(F). { %type tmvar {SStrToken} tmvar(A) ::= VARIABLE(X). {A = X;} -%type interval_opt {SIntervalVal} -interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N.interval = E; N.offset.n = 0;} -interval_opt(N) ::= INTERVAL LP tmvar(E) COMMA tmvar(X) RP. {N.interval = E; N.offset = X;} -interval_opt(N) ::= . {memset(&N, 0, sizeof(N));} +%type interval_option {SIntervalVal} +interval_option(N) ::= intervalKey(A) LP tmvar(E) RP. {N.interval = E; N.offset.n = 0; N.token = A;} +interval_option(N) ::= intervalKey(A) LP tmvar(E) COMMA tmvar(X) RP. {N.interval = E; N.offset = X; N.token = A;} +interval_option(N) ::= . {memset(&N, 0, sizeof(N));} + +%type intervalKey {int32_t} +intervalKey(A) ::= INTERVAL. {A = TK_INTERVAL;} +intervalKey(A) ::= EVERY. {A = TK_EVERY; } %type session_option {SSessionWindowVal} session_option(X) ::= . {X.col.n = 0; X.gap.n = 0;} @@ -581,6 +588,7 @@ session_option(X) ::= SESSION LP ids(V) cpxName(Z) COMMA tmvar(Y) RP. { X.col = V; X.gap = Y; } + %type windowstate_option {SWindowStateVal} windowstate_option(X) ::= . { X.col.n = 0; X.col.z = NULL;} windowstate_option(X) ::= STATE_WINDOW LP ids(V) RP. { X.col = V; } diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index e6bd84459687ba65b173b1067e0d309356af3805..c0c6d7a1404dbef6bdb00bd676a30fcfc908671a 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -1214,6 +1214,31 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp DUPATE_DATA_WITHOUT_TS(pCtx, *(int64_t *)output, v, notNullElems, isMin); break; } + + case TSDB_DATA_TYPE_UTINYINT: { + uint8_t v = GET_UINT8_VAL(input); + DUPATE_DATA_WITHOUT_TS(pCtx, *(uint8_t *)output, v, notNullElems, isMin); + break; + } + + case TSDB_DATA_TYPE_USMALLINT: { + uint16_t v = GET_UINT16_VAL(input); + DUPATE_DATA_WITHOUT_TS(pCtx, *(uint16_t *)output, v, notNullElems, isMin); + break; + } + + case TSDB_DATA_TYPE_UINT: { + uint32_t v = GET_UINT32_VAL(input); + DUPATE_DATA_WITHOUT_TS(pCtx, *(uint32_t *)output, v, notNullElems, isMin); + break; + } + + case TSDB_DATA_TYPE_UBIGINT: { + uint64_t v = GET_UINT64_VAL(input); + DUPATE_DATA_WITHOUT_TS(pCtx, *(uint64_t *)output, v, notNullElems, isMin); + break; + } + default: break; } diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 6295387ddf662917bf68a3564df081b04f1cb48d..700cf17fd38f69d4f2363174109c3217891a3e26 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -38,15 +38,12 @@ #define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN) #define TSWINDOW_IS_EQUAL(t1, t2) (((t1).skey == (t2).skey) && ((t1).ekey == (t2).ekey)) - #define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC)) #define SDATA_BLOCK_INITIALIZER (SDataBlockInfo) {{0}, 0} #define MULTI_KEY_DELIM "-" -#define HASH_CAPACITY_LIMIT 10000000 - #define TIME_WINDOW_COPY(_dst, _src) do {\ (_dst).skey = (_src).skey;\ (_dst).ekey = (_src).ekey;\ @@ -233,6 +230,12 @@ static void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput); static void destroyAggOperatorInfo(void* param, int32_t numOfOutput); static void destroyOperatorInfo(SOperatorInfo* pOperator); +static void doSetOperatorCompleted(SOperatorInfo* pOperator) { + pOperator->status = OP_EXEC_DONE; + if (pOperator->pRuntimeEnv != NULL) { + setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); + } +} static int32_t doCopyToSDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SGroupResInfo* pGroupResInfo, int32_t orderType, SSDataBlock* pBlock); @@ -1334,7 +1337,7 @@ void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, } else { pCtx[k].start.ptr = (char *)pColInfo->pData + prevRowIndex * pColInfo->info.bytes; } - + pCtx[k].end.ptr = (char *)pColInfo->pData + curRowIndex * pColInfo->info.bytes; } } @@ -1623,7 +1626,7 @@ static void hashAllIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->pCtx, pResult, &win, startPos, forwardStep); doApplyFunctions(pRuntimeEnv, pInfo->pCtx, ascQuery ? &win : &preWin, startPos, forwardStep, tsCols, pSDataBlock->info.rows, numOfOutput); preWin = win; - + int32_t prevEndPos = (forwardStep - 1) * step + startPos; startPos = getNextQualifiedWindow(pQueryAttr, &win, &pSDataBlock->info, tsCols, binarySearchForKey, prevEndPos); if (startPos < 0) { @@ -2262,30 +2265,30 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf case OP_Fill: { SOperatorInfo* pInfo = pRuntimeEnv->proot; - pRuntimeEnv->proot = createFillOperatorInfo(pRuntimeEnv, pInfo, pInfo->pExpr, pInfo->numOfOutput); + pRuntimeEnv->proot = createFillOperatorInfo(pRuntimeEnv, pInfo, pInfo->pExpr, pInfo->numOfOutput, pQueryAttr->multigroupResult); break; } case OP_MultiwayMergeSort: { - bool groupMix = true; - if (pQueryAttr->slimit.offset != 0 || pQueryAttr->slimit.limit != -1) { - groupMix = false; - } - - pRuntimeEnv->proot = createMultiwaySortOperatorInfo(pRuntimeEnv, pQueryAttr->pExpr1, pQueryAttr->numOfOutput, - 4096, merger, groupMix); // TODO hack it + pRuntimeEnv->proot = createMultiwaySortOperatorInfo(pRuntimeEnv, pQueryAttr->pExpr1, pQueryAttr->numOfOutput, 4096, merger); break; } - case OP_GlobalAggregate: { + case OP_GlobalAggregate: { // If fill operator exists, the result rows of different group can not be in the same SSDataBlock. + bool multigroupResult = pQueryAttr->multigroupResult; + if (pQueryAttr->multigroupResult) { + multigroupResult = (pQueryAttr->fillType == TSDB_FILL_NONE); + } + pRuntimeEnv->proot = createGlobalAggregateOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr3, - pQueryAttr->numOfExpr3, merger, pQueryAttr->pUdfInfo); + pQueryAttr->numOfExpr3, merger, pQueryAttr->pUdfInfo, multigroupResult); break; } case OP_SLimit: { - pRuntimeEnv->proot = createSLimitOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr3, - pQueryAttr->numOfExpr3, merger); + int32_t num = pRuntimeEnv->proot->numOfOutput; + SExprInfo* pExpr = pRuntimeEnv->proot->pExpr; + pRuntimeEnv->proot = createSLimitOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pExpr, num, merger, pQueryAttr->multigroupResult); break; } @@ -3636,7 +3639,7 @@ void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOf SColumnInfoData *pColInfo = taosArrayGet(pDataBlock->pDataBlock, i); pBInfo->pCtx[i].pOutput = pColInfo->pData + pColInfo->info.bytes * pDataBlock->info.rows; - // re-estabilish output buffer pointer. + // set the correct pointer after the memory buffer reallocated. int32_t functionId = pBInfo->pCtx[i].functionId; if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF || functionId == TSDB_FUNC_DERIVATIVE) { @@ -4200,6 +4203,7 @@ static void toSSDataBlock(SGroupResInfo *pGroupResInfo, SQueryRuntimeEnv* pRunti // refactor : extract method SColumnInfoData* pInfoData = taosArrayGet(pBlock->pDataBlock, 0); + //add condition (pBlock->info.rows >= 1) just to runtime happy if (pInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP && pBlock->info.rows >= 1) { STimeWindow* w = &pBlock->info.window; @@ -4314,15 +4318,15 @@ static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data } } -int32_t doFillTimeIntervalGapsInResults(SFillInfo* pFillInfo, SSDataBlock *pOutput, int32_t capacity) { - void** p = calloc(pFillInfo->numOfCols, POINTER_BYTES); +int32_t doFillTimeIntervalGapsInResults(SFillInfo* pFillInfo, SSDataBlock *pOutput, int32_t capacity, void** p) { for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) { SColumnInfoData* pColInfoData = taosArrayGet(pOutput->pDataBlock, i); - p[i] = pColInfoData->pData; + p[i] = pColInfoData->pData + (pColInfoData->info.bytes * pOutput->info.rows); } - pOutput->info.rows = (int32_t)taosFillResultDataBlock(pFillInfo, p, capacity); - tfree(p); + int32_t numOfRows = (int32_t)taosFillResultDataBlock(pFillInfo, p, capacity - pOutput->info.rows); + pOutput->info.rows += numOfRows; + return pOutput->info.rows; } @@ -5366,11 +5370,12 @@ static void destroyGlobalAggOperatorInfo(void* param, int32_t numOfOutput) { static void destroySlimitOperatorInfo(void* param, int32_t numOfOutput) { SSLimitOperatorInfo *pInfo = (SSLimitOperatorInfo*) param; taosArrayDestroy(pInfo->orderColumnList); + pInfo->pRes = destroyOutputBuf(pInfo->pRes); tfree(pInfo->prevRow); } SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, - SExprInfo* pExpr, int32_t numOfOutput, void* param, SArray* pUdfInfo) { + SExprInfo* pExpr, int32_t numOfOutput, void* param, SArray* pUdfInfo, bool groupResultMixedUp) { SMultiwayMergeInfo* pInfo = calloc(1, sizeof(SMultiwayMergeInfo)); pInfo->resultRowFactor = @@ -5378,15 +5383,14 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, pRuntimeEnv->scanFlag = MERGE_STAGE; // TODO init when creating pCtx - pInfo->pMerge = param; - pInfo->bufCapacity = 4096; - pInfo->udfInfo = pUdfInfo; - - pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pInfo->bufCapacity * pInfo->resultRowFactor); - pInfo->binfo.pCtx = createSQLFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); - - pInfo->orderColumnList = getOrderCheckColumns(pRuntimeEnv->pQueryAttr); - pInfo->groupColumnList = getResultGroupCheckColumns(pRuntimeEnv->pQueryAttr); + pInfo->multiGroupResults = groupResultMixedUp; + pInfo->pMerge = param; + pInfo->bufCapacity = 4096; + pInfo->udfInfo = pUdfInfo; + pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pInfo->bufCapacity * pInfo->resultRowFactor); + pInfo->binfo.pCtx = createSQLFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); + pInfo->orderColumnList = getOrderCheckColumns(pRuntimeEnv->pQueryAttr); + pInfo->groupColumnList = getResultGroupCheckColumns(pRuntimeEnv->pQueryAttr); // TODO refactor int32_t len = 0; @@ -5439,17 +5443,15 @@ SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, } SOperatorInfo *createMultiwaySortOperatorInfo(SQueryRuntimeEnv *pRuntimeEnv, SExprInfo *pExpr, int32_t numOfOutput, - int32_t numOfRows, void *merger, bool groupMix) { + int32_t numOfRows, void *merger) { SMultiwayMergeInfo* pInfo = calloc(1, sizeof(SMultiwayMergeInfo)); - pInfo->pMerge = merger; - pInfo->groupMix = groupMix; - pInfo->bufCapacity = numOfRows; - + pInfo->pMerge = merger; + pInfo->bufCapacity = numOfRows; pInfo->orderColumnList = getResultGroupCheckColumns(pRuntimeEnv->pQueryAttr); - pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, numOfRows); + pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, numOfRows); - { + { // todo extract method to create prev compare buffer int32_t len = 0; for(int32_t i = 0; i < numOfOutput; ++i) { len += pExpr[i].base.colBytes; @@ -5457,8 +5459,8 @@ SOperatorInfo *createMultiwaySortOperatorInfo(SQueryRuntimeEnv *pRuntimeEnv, SEx int32_t numOfCols = (pInfo->orderColumnList != NULL)? (int32_t) taosArrayGetSize(pInfo->orderColumnList):0; pInfo->prevRow = calloc(1, (POINTER_BYTES * numOfCols + len)); - int32_t offset = POINTER_BYTES * numOfCols; + int32_t offset = POINTER_BYTES * numOfCols; for(int32_t i = 0; i < numOfCols; ++i) { pInfo->prevRow[i] = (char*)pInfo->prevRow + offset; @@ -5474,7 +5476,8 @@ SOperatorInfo *createMultiwaySortOperatorInfo(SQueryRuntimeEnv *pRuntimeEnv, SEx pOperator->status = OP_IN_EXECUTING; pOperator->info = pInfo; pOperator->pRuntimeEnv = pRuntimeEnv; - pOperator->numOfOutput = pRuntimeEnv->pQueryAttr->numOfCols; + pOperator->numOfOutput = numOfOutput; + pOperator->pExpr = pExpr; pOperator->exec = doMultiwayMergeSort; pOperator->cleanup = destroyGlobalAggOperatorInfo; return pOperator; @@ -5520,8 +5523,7 @@ static SSDataBlock* doSort(void* param, bool* newgroup) { // start to flush data into disk and try do multiway merge sort if (pBlock == NULL) { - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); break; } @@ -5632,8 +5634,7 @@ static SSDataBlock* doAggregate(void* param, bool* newgroup) { doAggregateImpl(pOperator, pQueryAttr->window.skey, pInfo->pCtx, pBlock); } - pOperator->status = OP_EXEC_DONE; - setQueryStatus(pRuntimeEnv, QUERY_COMPLETED); + doSetOperatorCompleted(pOperator); finalizeQueryResult(pOperator, pInfo->pCtx, &pInfo->resultRowInfo, pInfo->rowCellInfoOffset); pInfo->pRes->info.rows = getNumOfResult(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput); @@ -5709,7 +5710,7 @@ static SSDataBlock* doSTableAggregate(void* param, bool* newgroup) { toSSDataBlock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pInfo->pRes); if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); } return pInfo->pRes; @@ -5827,8 +5828,7 @@ static SSDataBlock* doLimit(void* param, bool* newgroup) { publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC); if (pBlock == NULL) { - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); return NULL; } @@ -5856,8 +5856,7 @@ static SSDataBlock* doLimit(void* param, bool* newgroup) { pBlock->info.rows = (int32_t)(pInfo->limit - pInfo->total); pInfo->total = pInfo->limit; - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); } else { pInfo->total += pBlock->info.rows; } @@ -5892,8 +5891,7 @@ static SSDataBlock* doFilter(void* param, bool* newgroup) { } } - setQueryStatus(pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); return NULL; } @@ -5908,9 +5906,8 @@ static SSDataBlock* doIntervalAgg(void* param, bool* newgroup) { SQueryRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; if (pOperator->status == OP_RES_TO_RETURN) { toSSDataBlock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); - if (pIntervalInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); } return pIntervalInfo->pRes; @@ -5951,7 +5948,7 @@ static SSDataBlock* doIntervalAgg(void* param, bool* newgroup) { toSSDataBlock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); if (pIntervalInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); } return pIntervalInfo->pRes->info.rows == 0? NULL:pIntervalInfo->pRes; @@ -5970,7 +5967,7 @@ static SSDataBlock* doAllIntervalAgg(void* param, bool* newgroup) { toSSDataBlock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); if (pIntervalInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); } return pIntervalInfo->pRes; @@ -6028,9 +6025,10 @@ static SSDataBlock* doSTableIntervalAgg(void* param, bool* newgroup) { if (pOperator->status == OP_RES_TO_RETURN) { int64_t st = taosGetTimestampUs(); + copyToSDataBlock(pRuntimeEnv, 3000, pIntervalInfo->pRes, pIntervalInfo->rowCellInfoOffset); if (pIntervalInfo->pRes->info.rows == 0 || !hasRemainData(&pRuntimeEnv->groupResInfo)) { - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); } SQInfo* pQInfo = pRuntimeEnv->qinfo; @@ -6390,19 +6388,13 @@ static SSDataBlock* hashGroupbyAggregate(void* param, bool* newgroup) { return pInfo->binfo.pRes; } -static SSDataBlock* doFill(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; - if (pOperator->status == OP_EXEC_DONE) { - return NULL; - } - - SFillOperatorInfo *pInfo = pOperator->info; - SQueryRuntimeEnv *pRuntimeEnv = pOperator->pRuntimeEnv; - +static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo *pInfo, SQueryRuntimeEnv *pRuntimeEnv, bool *newgroup) { if (taosFillHasMoreResults(pInfo->pFillInfo)) { *newgroup = false; - doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, (int32_t)pRuntimeEnv->resultInfo.capacity); - return pInfo->pRes; + doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, (int32_t)pRuntimeEnv->resultInfo.capacity, pInfo->p); + if (pInfo->pRes->info.rows > pRuntimeEnv->resultInfo.threshold || (!pInfo->multigroupResult)) { + return; + } } // handle the cached new group data block @@ -6414,11 +6406,47 @@ static SSDataBlock* doFill(void* param, bool* newgroup) { taosFillSetStartInfo(pInfo->pFillInfo, pInfo->existNewGroupBlock->info.rows, ekey); taosFillSetInputDataBlock(pInfo->pFillInfo, pInfo->existNewGroupBlock); - doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pRuntimeEnv->resultInfo.capacity); + doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pRuntimeEnv->resultInfo.capacity, pInfo->p); pInfo->existNewGroupBlock = NULL; *newgroup = true; - return (pInfo->pRes->info.rows > 0)? pInfo->pRes:NULL; } +} + +static SSDataBlock* doFill(void* param, bool* newgroup) { + SOperatorInfo* pOperator = (SOperatorInfo*) param; + + SFillOperatorInfo *pInfo = pOperator->info; + pInfo->pRes->info.rows = 0; + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + SQueryRuntimeEnv *pRuntimeEnv = pOperator->pRuntimeEnv; + doHandleRemainBlockFromNewGroup(pInfo, pRuntimeEnv, newgroup); + if (pInfo->pRes->info.rows > pRuntimeEnv->resultInfo.threshold || (!pInfo->multigroupResult && pInfo->pRes->info.rows > 0)) { + return pInfo->pRes; + } +// if (taosFillHasMoreResults(pInfo->pFillInfo)) { +// *newgroup = false; +// doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, (int32_t)pRuntimeEnv->resultInfo.capacity); +// return pInfo->pRes; +// } +// +// // handle the cached new group data block +// if (pInfo->existNewGroupBlock) { +// pInfo->totalInputRows = pInfo->existNewGroupBlock->info.rows; +// int64_t ekey = Q_STATUS_EQUAL(pRuntimeEnv->status, QUERY_COMPLETED)?pRuntimeEnv->pQueryAttr->window.ekey:pInfo->existNewGroupBlock->info.window.ekey; +// taosResetFillInfo(pInfo->pFillInfo, pInfo->pFillInfo->start); +// +// taosFillSetStartInfo(pInfo->pFillInfo, pInfo->existNewGroupBlock->info.rows, ekey); +// taosFillSetInputDataBlock(pInfo->pFillInfo, pInfo->existNewGroupBlock); +// +// doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pRuntimeEnv->resultInfo.capacity); +// pInfo->existNewGroupBlock = NULL; +// *newgroup = true; +// return (pInfo->pRes->info.rows > 0)? pInfo->pRes:NULL; +// } while(1) { publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC); @@ -6433,8 +6461,8 @@ static SSDataBlock* doFill(void* param, bool* newgroup) { pInfo->existNewGroupBlock = pBlock; *newgroup = false; - // fill the previous group data block - // before handle a new data block, close the fill operation for previous group data block + // Fill the previous group data block, before handle the data block of new group. + // Close the fill operation for previous group data block taosFillSetStartInfo(pInfo->pFillInfo, 0, pRuntimeEnv->pQueryAttr->window.ekey); } else { if (pBlock == NULL) { @@ -6446,28 +6474,61 @@ static SSDataBlock* doFill(void* param, bool* newgroup) { taosFillSetStartInfo(pInfo->pFillInfo, 0, pRuntimeEnv->pQueryAttr->window.ekey); } else { pInfo->totalInputRows += pBlock->info.rows; - - int64_t ekey = /*Q_STATUS_EQUAL(pRuntimeEnv->status, QUERY_COMPLETED) ? pRuntimeEnv->pQueryAttr->window.ekey - : */pBlock->info.window.ekey; - - taosFillSetStartInfo(pInfo->pFillInfo, pBlock->info.rows, ekey); + taosFillSetStartInfo(pInfo->pFillInfo, pBlock->info.rows, pBlock->info.window.ekey); taosFillSetInputDataBlock(pInfo->pFillInfo, pBlock); } } - doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pRuntimeEnv->resultInfo.capacity); - if (pInfo->pRes->info.rows > 0) { // current group has no more result to return - return pInfo->pRes; + doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pRuntimeEnv->resultInfo.capacity, pInfo->p); + + // current group has no more result to return + if (pInfo->pRes->info.rows > 0) { + // 1. The result in current group not reach the threshold of output result, continue + // 2. If multiple group results existing in one SSDataBlock is not allowed, return immediately + if (pInfo->pRes->info.rows > pRuntimeEnv->resultInfo.threshold || pBlock == NULL || (!pInfo->multigroupResult)) { + return pInfo->pRes; + } + + doHandleRemainBlockFromNewGroup(pInfo, pRuntimeEnv, newgroup); + if (pInfo->pRes->info.rows > pRuntimeEnv->resultInfo.threshold || pBlock == NULL) { + return pInfo->pRes; + } + +// if (taosFillHasMoreResults(pInfo->pFillInfo)) { +// *newgroup = false; +// doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, (int32_t)pRuntimeEnv->resultInfo.capacity); +// return pInfo->pRes; +// } +// +// // handle the cached new group data block +// if (pInfo->existNewGroupBlock) { +// pInfo->totalInputRows = pInfo->existNewGroupBlock->info.rows; +// int64_t ekey = Q_STATUS_EQUAL(pRuntimeEnv->status, QUERY_COMPLETED)?pRuntimeEnv->pQueryAttr->window.ekey:pInfo->existNewGroupBlock->info.window.ekey; +// taosResetFillInfo(pInfo->pFillInfo, pInfo->pFillInfo->start); +// +// taosFillSetStartInfo(pInfo->pFillInfo, pInfo->existNewGroupBlock->info.rows, ekey); +// taosFillSetInputDataBlock(pInfo->pFillInfo, pInfo->existNewGroupBlock); +// +// doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pRuntimeEnv->resultInfo.capacity); +// pInfo->existNewGroupBlock = NULL; +// *newgroup = true; +// +// if (pInfo->pRes->info.rows > pRuntimeEnv->resultInfo.threshold) { +// return pInfo->pRes; +// } +// +//// return (pInfo->pRes->info.rows > 0)? pInfo->pRes:NULL; +// } + } else if (pInfo->existNewGroupBlock) { // try next group pInfo->totalInputRows = pInfo->existNewGroupBlock->info.rows; - int64_t ekey = /*Q_STATUS_EQUAL(pRuntimeEnv->status, QUERY_COMPLETED) ? pRuntimeEnv->pQueryAttr->window.ekey - :*/ pInfo->existNewGroupBlock->info.window.ekey; + int64_t ekey = pInfo->existNewGroupBlock->info.window.ekey; taosResetFillInfo(pInfo->pFillInfo, pInfo->pFillInfo->start); taosFillSetStartInfo(pInfo->pFillInfo, pInfo->existNewGroupBlock->info.rows, ekey); taosFillSetInputDataBlock(pInfo->pFillInfo, pInfo->existNewGroupBlock); - doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pRuntimeEnv->resultInfo.capacity); + doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pRuntimeEnv->resultInfo.capacity, pInfo->p); pInfo->existNewGroupBlock = NULL; *newgroup = true; @@ -6475,7 +6536,6 @@ static SSDataBlock* doFill(void* param, bool* newgroup) { } else { return NULL; } - // return (pInfo->pRes->info.rows > 0)? pInfo->pRes:NULL; } } @@ -6576,6 +6636,7 @@ static void destroySFillOperatorInfo(void* param, int32_t numOfOutput) { SFillOperatorInfo* pInfo = (SFillOperatorInfo*) param; pInfo->pFillInfo = taosDestroyFillInfo(pInfo->pFillInfo); pInfo->pRes = destroyOutputBuf(pInfo->pRes); + tfree(pInfo->p); } static void destroyGroupbyOperatorInfo(void* param, int32_t numOfOutput) { @@ -6919,10 +6980,10 @@ SOperatorInfo* createGroupbyOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperato return pOperator; } -SOperatorInfo* createFillOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, - int32_t numOfOutput) { +SOperatorInfo* createFillOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, bool multigroupResult) { SFillOperatorInfo* pInfo = calloc(1, sizeof(SFillOperatorInfo)); pInfo->pRes = createOutputBuf(pExpr, numOfOutput, pRuntimeEnv->resultInfo.capacity); + pInfo->multigroupResult = multigroupResult; { SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; @@ -6937,6 +6998,8 @@ SOperatorInfo* createFillOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorIn taosCreateFillInfo(pQueryAttr->order.order, w.skey, 0, (int32_t)pRuntimeEnv->resultInfo.capacity, numOfOutput, pQueryAttr->interval.sliding, pQueryAttr->interval.slidingUnit, (int8_t)pQueryAttr->precision, pQueryAttr->fillType, pColInfo, pRuntimeEnv->qinfo); + + pInfo->p = calloc(pInfo->pFillInfo->numOfCols, POINTER_BYTES); } SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); @@ -6956,7 +7019,7 @@ SOperatorInfo* createFillOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorIn return pOperator; } -SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, void* pMerger) { +SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, void* pMerger, bool multigroupResult) { SSLimitOperatorInfo* pInfo = calloc(1, sizeof(SSLimitOperatorInfo)); SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; @@ -6964,9 +7027,11 @@ SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator pInfo->orderColumnList = getResultGroupCheckColumns(pQueryAttr); pInfo->slimit = pQueryAttr->slimit; pInfo->limit = pQueryAttr->limit; - + pInfo->capacity = pRuntimeEnv->resultInfo.capacity; + pInfo->threshold = (int64_t)(pInfo->capacity * 0.8); + pInfo->currentOffset = pQueryAttr->limit.offset; pInfo->currentGroupOffset = pQueryAttr->slimit.offset; - pInfo->currentOffset = pQueryAttr->limit.offset; + pInfo->multigroupResult= multigroupResult; // TODO refactor int32_t len = 0; @@ -6974,10 +7039,10 @@ SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator len += pExpr[i].base.resBytes; } - int32_t numOfCols = pInfo->orderColumnList != NULL? (int32_t) taosArrayGetSize(pInfo->orderColumnList):0; + int32_t numOfCols = (pInfo->orderColumnList != NULL)? (int32_t) taosArrayGetSize(pInfo->orderColumnList):0; pInfo->prevRow = calloc(1, (POINTER_BYTES * numOfCols + len)); - int32_t offset = POINTER_BYTES * numOfCols; + int32_t offset = POINTER_BYTES * numOfCols; for(int32_t i = 0; i < numOfCols; ++i) { pInfo->prevRow[i] = (char*)pInfo->prevRow + offset; @@ -6985,6 +7050,8 @@ SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator offset += pExpr[index->colIndex].base.resBytes; } + pInfo->pRes = createOutputBuf(pExpr, numOfOutput, pRuntimeEnv->resultInfo.capacity); + SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); pOperator->name = "SLimitOperator"; @@ -7220,13 +7287,11 @@ static SSDataBlock* hashDistinct(void* param, bool* newgroup) { publishOperatorProfEvent(pOperator->upstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC); if (pBlock == NULL) { - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); break; } if (!initMultiDistinctInfo(pInfo, pOperator, pBlock)) { - setQueryStatus(pOperator->pRuntimeEnv, QUERY_COMPLETED); - pOperator->status = OP_EXEC_DONE; + doSetOperatorCompleted(pOperator); break; } // ensure result output buf diff --git a/src/query/src/qFill.c b/src/query/src/qFill.c index 1a86bbae36697224585522b5be836c61394c7cc4..cdcc164152dddbc34d03508a2bdd7379d6e50892 100644 --- a/src/query/src/qFill.c +++ b/src/query/src/qFill.c @@ -430,7 +430,7 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput) SColumnInfoData* pColData = taosArrayGet(pInput->pDataBlock, i); pFillInfo->pData[i] = pColData->pData; - if (TSDB_COL_IS_TAG(pCol->flag)/* || IS_VAR_DATA_TYPE(pCol->col.type)*/) { // copy the tag value to tag value buffer + if (TSDB_COL_IS_TAG(pCol->flag)) { // copy the tag value to tag value buffer SFillTagColInfo* pTag = &pFillInfo->pTags[pCol->tagIndex]; assert (pTag->col.colId == pCol->col.colId); memcpy(pTag->tagVal, pColData->pData, pCol->col.bytes); // TODO not memcpy?? diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 011892fe93f3dc941b17ef7b22313c11fca23d74..d156230efbc75c46205637747bb58f86d13763fe 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -766,7 +766,7 @@ SSqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelNodeList, SRelat pSqlNode->pSortOrder = pSortOrder; pSqlNode->pWhere = pWhere; pSqlNode->fillType = pFill; - pSqlNode->pHaving = pHaving; + pSqlNode->pHaving = pHaving; if (pLimit != NULL) { pSqlNode->limit = *pLimit; diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 09be4c0cf09df7560b52fc0704a856369946cf38..16bb4e49a80fa7a263b7c6e0446cb4aa328343bb 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -23,9 +23,7 @@ ** input grammar file: */ #include -#include /************ Begin %include sections from the grammar ************************/ -#line 23 "sql.y" #include #include @@ -38,7 +36,6 @@ #include "ttokendef.h" #include "tutil.h" #include "tvariant.h" -#line 42 "sql.c" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols ** in a format understandable to "makeheaders". This section is blank unless @@ -79,10 +76,8 @@ ** zero the stack is dynamically sized using realloc() ** ParseARG_SDECL A static variable declaration for the %extra_argument ** ParseARG_PDECL A parameter declaration for the %extra_argument -** ParseARG_PARAM Code to pass %extra_argument as a subroutine parameter ** ParseARG_STORE Code to store %extra_argument into yypParser ** ParseARG_FETCH Code to extract %extra_argument from yypParser -** ParseCTX_* As ParseARG_ except for %extra_context ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** YYNSTATE the combined number of states. @@ -102,57 +97,50 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 275 +#define YYNOCODE 279 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SSessionWindowVal yy39; - SCreateDbInfo yy42; - int yy43; - tSqlExpr* yy46; - SCreatedTableInfo yy96; - SArray* yy131; - TAOS_FIELD yy163; - SSqlNode* yy256; - SCreateTableSql* yy272; - SLimitVal yy284; - SCreateAcctInfo yy341; - int64_t yy459; - tVariant yy516; - SIntervalVal yy530; - SWindowStateVal yy538; - SRelationInfo* yy544; + SRelationInfo* yy8; + SWindowStateVal yy40; + SSqlNode* yy56; + SCreateDbInfo yy90; + int yy96; + int32_t yy104; + SSessionWindowVal yy147; + SCreatedTableInfo yy152; + SLimitVal yy166; + SCreateAcctInfo yy171; + TAOS_FIELD yy183; + int64_t yy325; + SIntervalVal yy400; + SArray* yy421; + tVariant yy430; + SCreateTableSql* yy438; + tSqlExpr* yy439; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define ParseARG_SDECL SSqlInfo* pInfo; #define ParseARG_PDECL ,SSqlInfo* pInfo -#define ParseARG_PARAM ,pInfo -#define ParseARG_FETCH SSqlInfo* pInfo=yypParser->pInfo; -#define ParseARG_STORE yypParser->pInfo=pInfo; -#define ParseCTX_SDECL -#define ParseCTX_PDECL -#define ParseCTX_PARAM -#define ParseCTX_FETCH -#define ParseCTX_STORE +#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo +#define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 -#define YYNSTATE 362 -#define YYNRULE 289 -#define YYNRULE_WITH_ACTION 289 -#define YYNTOKEN 195 -#define YY_MAX_SHIFT 361 -#define YY_MIN_SHIFTREDUCE 567 -#define YY_MAX_SHIFTREDUCE 855 -#define YY_ERROR_ACTION 856 -#define YY_ACCEPT_ACTION 857 -#define YY_NO_ACTION 858 -#define YY_MIN_REDUCE 859 -#define YY_MAX_REDUCE 1147 +#define YYNSTATE 364 +#define YYNRULE 292 +#define YYNTOKEN 196 +#define YY_MAX_SHIFT 363 +#define YY_MIN_SHIFTREDUCE 572 +#define YY_MAX_SHIFTREDUCE 863 +#define YY_ERROR_ACTION 864 +#define YY_ACCEPT_ACTION 865 +#define YY_NO_ACTION 866 +#define YY_MIN_REDUCE 867 +#define YY_MAX_REDUCE 1158 /************* End control #defines *******************************************/ -#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) /* Define the yytestcase() macro to be a no-op if is not already defined ** otherwise. @@ -217,288 +205,289 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (754) +#define YY_ACTTAB_COUNT (759) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 207, 618, 246, 618, 618, 245, 360, 229, 160, 619, - /* 10 */ 1123, 619, 619, 56, 57, 1036, 60, 61, 857, 361, - /* 20 */ 249, 50, 618, 59, 318, 64, 62, 65, 63, 984, - /* 30 */ 619, 982, 983, 55, 54, 160, 985, 53, 52, 51, - /* 40 */ 986, 153, 987, 988, 356, 945, 654, 568, 569, 570, - /* 50 */ 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, - /* 60 */ 581, 151, 207, 230, 907, 207, 56, 57, 1027, 60, - /* 70 */ 61, 189, 1124, 249, 50, 1124, 59, 318, 64, 62, - /* 80 */ 65, 63, 1072, 1033, 271, 79, 55, 54, 3, 190, - /* 90 */ 53, 52, 51, 56, 57, 250, 60, 61, 702, 1027, - /* 100 */ 249, 50, 29, 59, 318, 64, 62, 65, 63, 91, - /* 110 */ 278, 277, 37, 55, 54, 232, 94, 53, 52, 51, - /* 120 */ 235, 120, 114, 125, 1014, 241, 338, 337, 124, 1014, - /* 130 */ 130, 133, 123, 56, 58, 794, 60, 61, 127, 85, - /* 140 */ 249, 50, 92, 59, 318, 64, 62, 65, 63, 997, - /* 150 */ 998, 34, 1001, 55, 54, 207, 80, 53, 52, 51, - /* 160 */ 57, 1010, 60, 61, 316, 1124, 249, 50, 263, 59, - /* 170 */ 318, 64, 62, 65, 63, 37, 44, 267, 266, 55, - /* 180 */ 54, 348, 243, 53, 52, 51, 1014, 160, 43, 314, - /* 190 */ 355, 354, 313, 312, 311, 353, 310, 309, 308, 352, - /* 200 */ 307, 351, 350, 976, 964, 965, 966, 967, 968, 969, - /* 210 */ 970, 971, 972, 973, 974, 975, 977, 978, 60, 61, - /* 220 */ 231, 160, 249, 50, 1011, 59, 318, 64, 62, 65, - /* 230 */ 63, 1008, 1027, 24, 258, 55, 54, 1000, 97, 53, - /* 240 */ 52, 51, 252, 248, 809, 175, 1013, 798, 233, 801, - /* 250 */ 210, 804, 248, 809, 1143, 917, 798, 216, 801, 292, - /* 260 */ 804, 90, 189, 135, 134, 215, 258, 55, 54, 323, - /* 270 */ 85, 53, 52, 51, 1002, 227, 228, 176, 242, 319, - /* 280 */ 5, 40, 179, 258, 227, 228, 23, 178, 103, 108, - /* 290 */ 99, 107, 204, 726, 1012, 1073, 723, 290, 724, 908, - /* 300 */ 725, 64, 62, 65, 63, 303, 189, 44, 257, 55, - /* 310 */ 54, 37, 37, 53, 52, 51, 800, 253, 803, 251, - /* 320 */ 316, 326, 325, 66, 254, 255, 198, 196, 194, 270, - /* 330 */ 37, 77, 66, 193, 139, 138, 137, 136, 223, 742, - /* 340 */ 799, 43, 802, 355, 354, 37, 37, 37, 353, 53, - /* 350 */ 52, 51, 352, 37, 351, 350, 239, 240, 810, 805, - /* 360 */ 1011, 1011, 272, 78, 37, 806, 122, 810, 805, 37, - /* 370 */ 37, 359, 358, 144, 806, 327, 38, 14, 348, 1011, - /* 380 */ 82, 93, 70, 259, 739, 256, 320, 333, 332, 83, - /* 390 */ 328, 329, 330, 73, 1011, 1011, 1011, 999, 334, 150, - /* 400 */ 148, 147, 1011, 1, 177, 775, 776, 727, 728, 335, - /* 410 */ 9, 96, 796, 1011, 336, 340, 758, 274, 1011, 1011, - /* 420 */ 1083, 766, 767, 746, 71, 712, 274, 295, 714, 297, - /* 430 */ 155, 713, 33, 74, 807, 67, 26, 830, 811, 38, - /* 440 */ 247, 38, 67, 95, 76, 67, 617, 16, 797, 15, - /* 450 */ 205, 25, 25, 113, 18, 112, 17, 731, 808, 732, - /* 460 */ 25, 6, 729, 211, 730, 298, 20, 119, 19, 118, - /* 470 */ 22, 1120, 21, 132, 131, 1119, 701, 1118, 225, 226, - /* 480 */ 208, 209, 1135, 212, 206, 213, 214, 813, 218, 219, - /* 490 */ 220, 217, 203, 1082, 237, 1079, 1078, 238, 339, 47, - /* 500 */ 1028, 268, 152, 1065, 1064, 1035, 149, 275, 1009, 279, - /* 510 */ 1046, 1043, 1044, 1048, 154, 159, 286, 171, 172, 273, - /* 520 */ 234, 1007, 173, 162, 174, 922, 300, 301, 302, 305, - /* 530 */ 306, 757, 1025, 45, 281, 201, 161, 283, 41, 317, - /* 540 */ 75, 916, 293, 72, 49, 324, 164, 1142, 291, 110, - /* 550 */ 1141, 1138, 163, 289, 180, 331, 1134, 116, 1133, 1130, - /* 560 */ 287, 285, 181, 942, 42, 39, 46, 202, 282, 904, - /* 570 */ 126, 902, 128, 129, 900, 899, 260, 280, 192, 897, - /* 580 */ 896, 895, 894, 893, 892, 891, 195, 197, 888, 886, - /* 590 */ 884, 882, 199, 48, 879, 200, 875, 304, 349, 81, - /* 600 */ 86, 284, 1066, 121, 341, 342, 343, 344, 345, 346, - /* 610 */ 347, 357, 855, 262, 261, 854, 224, 244, 299, 264, - /* 620 */ 265, 853, 836, 221, 222, 835, 269, 294, 104, 921, - /* 630 */ 920, 274, 105, 10, 276, 87, 84, 898, 734, 140, - /* 640 */ 30, 156, 141, 184, 890, 183, 943, 182, 185, 187, - /* 650 */ 186, 142, 188, 2, 889, 759, 143, 881, 980, 165, - /* 660 */ 880, 166, 167, 944, 168, 169, 170, 4, 990, 768, - /* 670 */ 157, 158, 762, 88, 236, 764, 89, 288, 31, 11, - /* 680 */ 32, 12, 13, 27, 296, 28, 96, 101, 98, 35, - /* 690 */ 100, 632, 36, 667, 102, 665, 664, 663, 661, 660, - /* 700 */ 659, 656, 622, 315, 106, 7, 321, 812, 322, 8, - /* 710 */ 814, 109, 111, 68, 69, 38, 704, 703, 115, 700, - /* 720 */ 117, 648, 646, 638, 644, 640, 642, 636, 634, 670, - /* 730 */ 669, 668, 666, 662, 658, 657, 191, 620, 585, 859, - /* 740 */ 858, 858, 858, 858, 858, 858, 858, 858, 858, 858, - /* 750 */ 858, 858, 145, 146, + /* 0 */ 171, 624, 248, 624, 624, 23, 362, 231, 162, 625, + /* 10 */ 247, 625, 625, 57, 58, 206, 61, 62, 282, 1045, + /* 20 */ 251, 51, 252, 60, 320, 65, 63, 66, 64, 993, + /* 30 */ 209, 991, 992, 56, 55, 162, 994, 54, 53, 52, + /* 40 */ 995, 1134, 996, 997, 155, 660, 79, 573, 574, 575, + /* 50 */ 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, + /* 60 */ 586, 153, 209, 232, 57, 58, 207, 61, 62, 1009, + /* 70 */ 209, 251, 51, 1135, 60, 320, 65, 63, 66, 64, + /* 80 */ 1008, 1135, 209, 1083, 56, 55, 80, 1042, 54, 53, + /* 90 */ 52, 57, 58, 1135, 61, 62, 237, 318, 251, 51, + /* 100 */ 1023, 60, 320, 65, 63, 66, 64, 708, 294, 86, + /* 110 */ 91, 56, 55, 280, 279, 54, 53, 52, 57, 59, + /* 120 */ 243, 61, 62, 350, 1023, 251, 51, 95, 60, 320, + /* 130 */ 65, 63, 66, 64, 802, 340, 339, 245, 56, 55, + /* 140 */ 213, 1023, 54, 53, 52, 58, 45, 61, 62, 767, + /* 150 */ 768, 251, 51, 318, 60, 320, 65, 63, 66, 64, + /* 160 */ 1006, 1007, 35, 1010, 56, 55, 865, 363, 54, 53, + /* 170 */ 52, 44, 316, 357, 356, 315, 314, 313, 355, 312, + /* 180 */ 311, 310, 354, 309, 353, 352, 985, 973, 974, 975, + /* 190 */ 976, 977, 978, 979, 980, 981, 982, 983, 984, 986, + /* 200 */ 987, 61, 62, 24, 1131, 251, 51, 624, 60, 320, + /* 210 */ 65, 63, 66, 64, 162, 625, 1036, 98, 56, 55, + /* 220 */ 212, 1036, 54, 53, 52, 56, 55, 218, 38, 54, + /* 230 */ 53, 52, 273, 137, 136, 135, 217, 234, 250, 817, + /* 240 */ 325, 86, 806, 1017, 809, 16, 812, 15, 250, 817, + /* 250 */ 123, 265, 806, 1011, 809, 748, 812, 5, 41, 180, + /* 260 */ 269, 268, 350, 1130, 179, 104, 109, 100, 108, 916, + /* 270 */ 229, 230, 1129, 233, 321, 227, 190, 1020, 45, 1036, + /* 280 */ 229, 230, 38, 305, 65, 63, 66, 64, 29, 1084, + /* 290 */ 244, 292, 56, 55, 260, 235, 54, 53, 52, 254, + /* 300 */ 272, 732, 78, 162, 729, 176, 730, 259, 731, 225, + /* 310 */ 260, 54, 53, 52, 228, 200, 198, 196, 808, 67, + /* 320 */ 811, 177, 195, 141, 140, 139, 138, 241, 807, 67, + /* 330 */ 810, 1020, 256, 257, 121, 115, 126, 152, 150, 149, + /* 340 */ 752, 125, 260, 131, 134, 124, 38, 38, 38, 361, + /* 350 */ 360, 146, 128, 1021, 818, 813, 44, 38, 357, 356, + /* 360 */ 38, 814, 38, 355, 818, 813, 1022, 354, 93, 353, + /* 370 */ 352, 814, 784, 38, 38, 255, 38, 253, 92, 328, + /* 380 */ 327, 38, 81, 261, 926, 258, 322, 335, 334, 745, + /* 390 */ 14, 190, 242, 329, 94, 1019, 1020, 1020, 71, 358, + /* 400 */ 954, 917, 330, 3, 191, 331, 1020, 332, 190, 1020, + /* 410 */ 34, 1020, 1, 178, 274, 9, 733, 734, 336, 337, + /* 420 */ 83, 338, 1020, 1020, 97, 1020, 342, 84, 39, 783, + /* 430 */ 1020, 764, 774, 74, 775, 718, 297, 815, 720, 299, + /* 440 */ 72, 719, 838, 300, 819, 157, 68, 816, 26, 39, + /* 450 */ 39, 804, 68, 96, 249, 68, 25, 276, 25, 114, + /* 460 */ 623, 113, 77, 18, 276, 17, 737, 735, 738, 736, + /* 470 */ 20, 210, 19, 75, 25, 120, 6, 119, 22, 211, + /* 480 */ 21, 133, 132, 214, 1154, 208, 215, 805, 821, 216, + /* 490 */ 220, 221, 222, 219, 707, 205, 1094, 1146, 48, 1093, + /* 500 */ 239, 1090, 1089, 240, 341, 270, 154, 1076, 1044, 1055, + /* 510 */ 1052, 1053, 151, 1037, 277, 1057, 156, 1075, 161, 288, + /* 520 */ 172, 173, 275, 1018, 281, 1016, 174, 168, 175, 165, + /* 530 */ 1034, 931, 763, 302, 303, 169, 167, 304, 307, 308, + /* 540 */ 46, 203, 42, 236, 319, 925, 326, 283, 285, 1153, + /* 550 */ 76, 73, 163, 111, 295, 164, 1152, 50, 293, 1149, + /* 560 */ 166, 181, 333, 1145, 117, 1144, 1141, 182, 951, 43, + /* 570 */ 291, 40, 47, 204, 913, 127, 289, 911, 129, 284, + /* 580 */ 130, 909, 908, 262, 193, 194, 905, 904, 903, 902, + /* 590 */ 901, 900, 899, 287, 197, 199, 896, 894, 892, 890, + /* 600 */ 201, 887, 306, 202, 883, 49, 351, 82, 87, 343, + /* 610 */ 286, 1077, 122, 344, 345, 346, 226, 246, 301, 347, + /* 620 */ 348, 349, 359, 863, 263, 264, 862, 223, 105, 930, + /* 630 */ 929, 224, 106, 266, 267, 861, 844, 271, 907, 843, + /* 640 */ 906, 296, 142, 276, 143, 185, 184, 952, 183, 186, + /* 650 */ 187, 189, 188, 144, 898, 897, 953, 145, 989, 889, + /* 660 */ 888, 10, 85, 740, 33, 170, 4, 30, 2, 278, + /* 670 */ 88, 999, 765, 158, 160, 776, 159, 238, 770, 89, + /* 680 */ 31, 772, 90, 290, 11, 32, 12, 13, 27, 298, + /* 690 */ 28, 97, 99, 102, 36, 101, 638, 37, 103, 673, + /* 700 */ 671, 670, 669, 667, 666, 665, 662, 628, 317, 107, + /* 710 */ 7, 323, 324, 822, 110, 820, 8, 112, 69, 70, + /* 720 */ 710, 39, 709, 116, 706, 118, 654, 652, 644, 650, + /* 730 */ 646, 648, 642, 640, 676, 675, 674, 672, 668, 664, + /* 740 */ 663, 192, 626, 590, 867, 866, 866, 866, 866, 866, + /* 750 */ 866, 866, 866, 866, 866, 866, 866, 147, 148, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 264, 1, 204, 1, 1, 204, 197, 198, 197, 9, - /* 10 */ 274, 9, 9, 13, 14, 197, 16, 17, 195, 196, - /* 20 */ 20, 21, 1, 23, 24, 25, 26, 27, 28, 221, - /* 30 */ 9, 223, 224, 33, 34, 197, 228, 37, 38, 39, - /* 40 */ 232, 197, 234, 235, 219, 220, 5, 45, 46, 47, + /* 0 */ 253, 1, 206, 1, 1, 266, 199, 200, 199, 9, + /* 10 */ 206, 9, 9, 13, 14, 266, 16, 17, 271, 199, + /* 20 */ 20, 21, 206, 23, 24, 25, 26, 27, 28, 223, + /* 30 */ 266, 225, 226, 33, 34, 199, 230, 37, 38, 39, + /* 40 */ 234, 277, 236, 237, 199, 5, 207, 45, 46, 47, /* 50 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - /* 60 */ 58, 59, 264, 61, 203, 264, 13, 14, 245, 16, - /* 70 */ 17, 210, 274, 20, 21, 274, 23, 24, 25, 26, - /* 80 */ 27, 28, 271, 265, 261, 85, 33, 34, 201, 202, - /* 90 */ 37, 38, 39, 13, 14, 204, 16, 17, 5, 245, - /* 100 */ 20, 21, 81, 23, 24, 25, 26, 27, 28, 271, - /* 110 */ 266, 267, 197, 33, 34, 261, 205, 37, 38, 39, - /* 120 */ 243, 62, 63, 64, 247, 243, 33, 34, 69, 247, - /* 130 */ 71, 72, 73, 13, 14, 82, 16, 17, 79, 81, - /* 140 */ 20, 21, 248, 23, 24, 25, 26, 27, 28, 238, - /* 150 */ 239, 240, 241, 33, 34, 264, 262, 37, 38, 39, - /* 160 */ 14, 246, 16, 17, 83, 274, 20, 21, 141, 23, - /* 170 */ 24, 25, 26, 27, 28, 197, 118, 150, 151, 33, - /* 180 */ 34, 89, 243, 37, 38, 39, 247, 197, 97, 98, - /* 190 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - /* 200 */ 109, 110, 111, 221, 222, 223, 224, 225, 226, 227, - /* 210 */ 228, 229, 230, 231, 232, 233, 234, 235, 16, 17, - /* 220 */ 242, 197, 20, 21, 246, 23, 24, 25, 26, 27, - /* 230 */ 28, 197, 245, 44, 197, 33, 34, 0, 205, 37, - /* 240 */ 38, 39, 68, 1, 2, 208, 247, 5, 261, 7, - /* 250 */ 61, 9, 1, 2, 247, 203, 5, 68, 7, 269, - /* 260 */ 9, 271, 210, 74, 75, 76, 197, 33, 34, 80, - /* 270 */ 81, 37, 38, 39, 241, 33, 34, 208, 244, 37, - /* 280 */ 62, 63, 64, 197, 33, 34, 264, 69, 70, 71, - /* 290 */ 72, 73, 264, 2, 208, 271, 5, 273, 7, 203, - /* 300 */ 9, 25, 26, 27, 28, 87, 210, 118, 68, 33, - /* 310 */ 34, 197, 197, 37, 38, 39, 5, 143, 7, 145, - /* 320 */ 83, 147, 148, 81, 33, 34, 62, 63, 64, 140, - /* 330 */ 197, 142, 81, 69, 70, 71, 72, 73, 149, 37, - /* 340 */ 5, 97, 7, 99, 100, 197, 197, 197, 104, 37, - /* 350 */ 38, 39, 108, 197, 110, 111, 242, 242, 116, 117, - /* 360 */ 246, 246, 82, 205, 197, 123, 77, 116, 117, 197, - /* 370 */ 197, 65, 66, 67, 123, 242, 96, 81, 89, 246, - /* 380 */ 82, 85, 96, 143, 96, 145, 15, 147, 148, 82, - /* 390 */ 242, 242, 242, 96, 246, 246, 246, 239, 242, 62, - /* 400 */ 63, 64, 246, 206, 207, 131, 132, 116, 117, 242, - /* 410 */ 122, 115, 1, 246, 242, 242, 82, 119, 246, 246, - /* 420 */ 237, 82, 82, 121, 138, 82, 119, 82, 82, 82, - /* 430 */ 96, 82, 81, 136, 123, 96, 96, 82, 82, 96, - /* 440 */ 60, 96, 96, 96, 81, 96, 82, 144, 37, 146, - /* 450 */ 264, 96, 96, 144, 144, 146, 146, 5, 123, 7, - /* 460 */ 96, 81, 5, 264, 7, 114, 144, 144, 146, 146, - /* 470 */ 144, 264, 146, 77, 78, 264, 113, 264, 264, 264, - /* 480 */ 264, 264, 247, 264, 264, 264, 264, 116, 264, 264, - /* 490 */ 264, 264, 264, 237, 237, 237, 237, 237, 237, 263, - /* 500 */ 245, 197, 197, 272, 272, 197, 60, 245, 245, 268, - /* 510 */ 197, 197, 197, 197, 197, 197, 197, 249, 197, 199, - /* 520 */ 268, 197, 197, 258, 197, 197, 197, 197, 197, 197, - /* 530 */ 197, 123, 260, 197, 268, 197, 259, 268, 197, 197, - /* 540 */ 135, 197, 129, 137, 134, 197, 256, 197, 133, 197, - /* 550 */ 197, 197, 257, 127, 197, 197, 197, 197, 197, 197, - /* 560 */ 126, 125, 197, 197, 197, 197, 197, 197, 128, 197, - /* 570 */ 197, 197, 197, 197, 197, 197, 197, 124, 197, 197, - /* 580 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 590 */ 197, 197, 197, 139, 197, 197, 197, 88, 112, 199, - /* 600 */ 199, 199, 199, 95, 94, 51, 91, 93, 55, 92, - /* 610 */ 90, 83, 5, 5, 152, 5, 199, 199, 199, 152, - /* 620 */ 5, 5, 99, 199, 199, 98, 141, 114, 205, 209, - /* 630 */ 209, 119, 205, 81, 96, 96, 120, 199, 82, 200, - /* 640 */ 81, 81, 200, 212, 199, 216, 218, 217, 215, 214, - /* 650 */ 213, 200, 211, 206, 199, 82, 200, 199, 236, 255, - /* 660 */ 199, 254, 253, 220, 252, 251, 250, 201, 236, 82, - /* 670 */ 81, 96, 82, 81, 1, 82, 81, 81, 96, 130, - /* 680 */ 96, 130, 81, 81, 114, 81, 115, 70, 77, 86, - /* 690 */ 85, 5, 86, 9, 85, 5, 5, 5, 5, 5, - /* 700 */ 5, 5, 84, 15, 77, 81, 24, 82, 59, 81, - /* 710 */ 116, 146, 146, 16, 16, 96, 5, 5, 146, 82, - /* 720 */ 146, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 730 */ 5, 5, 5, 5, 5, 5, 96, 84, 60, 0, - /* 740 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 750 */ 275, 275, 21, 21, 275, 275, 275, 275, 275, 275, - /* 760 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 770 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 780 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 790 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 800 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 810 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 820 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 830 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 840 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 850 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 860 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 870 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 880 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 890 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 900 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 910 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 920 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 930 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - /* 940 */ 275, 275, 275, 275, 275, 275, 275, 275, 275, + /* 60 */ 58, 59, 266, 61, 13, 14, 266, 16, 17, 0, + /* 70 */ 266, 20, 21, 277, 23, 24, 25, 26, 27, 28, + /* 80 */ 241, 277, 266, 274, 33, 34, 86, 267, 37, 38, + /* 90 */ 39, 13, 14, 277, 16, 17, 245, 84, 20, 21, + /* 100 */ 249, 23, 24, 25, 26, 27, 28, 5, 272, 82, + /* 110 */ 274, 33, 34, 268, 269, 37, 38, 39, 13, 14, + /* 120 */ 245, 16, 17, 90, 249, 20, 21, 207, 23, 24, + /* 130 */ 25, 26, 27, 28, 83, 33, 34, 245, 33, 34, + /* 140 */ 266, 249, 37, 38, 39, 14, 119, 16, 17, 125, + /* 150 */ 126, 20, 21, 84, 23, 24, 25, 26, 27, 28, + /* 160 */ 240, 241, 242, 243, 33, 34, 197, 198, 37, 38, + /* 170 */ 39, 98, 99, 100, 101, 102, 103, 104, 105, 106, + /* 180 */ 107, 108, 109, 110, 111, 112, 223, 224, 225, 226, + /* 190 */ 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, + /* 200 */ 237, 16, 17, 44, 266, 20, 21, 1, 23, 24, + /* 210 */ 25, 26, 27, 28, 199, 9, 247, 207, 33, 34, + /* 220 */ 61, 247, 37, 38, 39, 33, 34, 68, 199, 37, + /* 230 */ 38, 39, 263, 74, 75, 76, 77, 263, 1, 2, + /* 240 */ 81, 82, 5, 199, 7, 145, 9, 147, 1, 2, + /* 250 */ 78, 142, 5, 243, 7, 37, 9, 62, 63, 64, + /* 260 */ 151, 152, 90, 266, 69, 70, 71, 72, 73, 205, + /* 270 */ 33, 34, 266, 244, 37, 266, 212, 248, 119, 247, + /* 280 */ 33, 34, 199, 88, 25, 26, 27, 28, 82, 274, + /* 290 */ 246, 276, 33, 34, 199, 263, 37, 38, 39, 68, + /* 300 */ 141, 2, 143, 199, 5, 210, 7, 68, 9, 150, + /* 310 */ 199, 37, 38, 39, 266, 62, 63, 64, 5, 82, + /* 320 */ 7, 210, 69, 70, 71, 72, 73, 244, 5, 82, + /* 330 */ 7, 248, 33, 34, 62, 63, 64, 62, 63, 64, + /* 340 */ 122, 69, 199, 71, 72, 73, 199, 199, 199, 65, + /* 350 */ 66, 67, 80, 210, 117, 118, 98, 199, 100, 101, + /* 360 */ 199, 124, 199, 105, 117, 118, 249, 109, 250, 111, + /* 370 */ 112, 124, 76, 199, 199, 144, 199, 146, 274, 148, + /* 380 */ 149, 199, 264, 144, 205, 146, 15, 148, 149, 97, + /* 390 */ 82, 212, 244, 244, 86, 248, 248, 248, 97, 221, + /* 400 */ 222, 205, 244, 203, 204, 244, 248, 244, 212, 248, + /* 410 */ 82, 248, 208, 209, 83, 123, 117, 118, 244, 244, + /* 420 */ 83, 244, 248, 248, 116, 248, 244, 83, 97, 133, + /* 430 */ 248, 83, 83, 97, 83, 83, 83, 124, 83, 83, + /* 440 */ 139, 83, 83, 115, 83, 97, 97, 124, 97, 97, + /* 450 */ 97, 1, 97, 97, 60, 97, 97, 120, 97, 145, + /* 460 */ 83, 147, 82, 145, 120, 147, 5, 5, 7, 7, + /* 470 */ 145, 266, 147, 137, 97, 145, 82, 147, 145, 266, + /* 480 */ 147, 78, 79, 266, 249, 266, 266, 37, 117, 266, + /* 490 */ 266, 266, 266, 266, 114, 266, 239, 249, 265, 239, + /* 500 */ 239, 239, 239, 239, 239, 199, 199, 275, 199, 199, + /* 510 */ 199, 199, 60, 247, 247, 199, 199, 275, 199, 199, + /* 520 */ 251, 199, 201, 247, 270, 199, 199, 256, 199, 259, + /* 530 */ 262, 199, 124, 199, 199, 255, 257, 199, 199, 199, + /* 540 */ 199, 199, 199, 270, 199, 199, 199, 270, 270, 199, + /* 550 */ 136, 138, 261, 199, 131, 260, 199, 135, 134, 199, + /* 560 */ 258, 199, 199, 199, 199, 199, 199, 199, 199, 199, + /* 570 */ 129, 199, 199, 199, 199, 199, 128, 199, 199, 130, + /* 580 */ 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, + /* 590 */ 199, 199, 199, 127, 199, 199, 199, 199, 199, 199, + /* 600 */ 199, 199, 89, 199, 199, 140, 113, 201, 201, 95, + /* 610 */ 201, 201, 96, 51, 92, 94, 201, 201, 201, 55, + /* 620 */ 93, 91, 84, 5, 153, 5, 5, 201, 207, 211, + /* 630 */ 211, 201, 207, 153, 5, 5, 100, 142, 201, 99, + /* 640 */ 201, 115, 202, 120, 202, 214, 218, 220, 219, 217, + /* 650 */ 215, 213, 216, 202, 201, 201, 222, 202, 238, 201, + /* 660 */ 201, 82, 121, 83, 252, 254, 203, 82, 208, 97, + /* 670 */ 97, 238, 83, 82, 97, 83, 82, 1, 83, 82, + /* 680 */ 97, 83, 82, 82, 132, 97, 132, 82, 82, 115, + /* 690 */ 82, 116, 78, 70, 87, 86, 5, 87, 86, 9, + /* 700 */ 5, 5, 5, 5, 5, 5, 5, 85, 15, 78, + /* 710 */ 82, 24, 59, 117, 147, 83, 82, 147, 16, 16, + /* 720 */ 5, 97, 5, 147, 83, 147, 5, 5, 5, 5, + /* 730 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + /* 740 */ 5, 97, 85, 60, 0, 278, 278, 278, 278, 278, + /* 750 */ 278, 278, 278, 278, 278, 278, 278, 21, 21, 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, 278, 278, 278, 278, 278, + /* 800 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 810 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 820 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 830 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 840 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 850 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 860 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 870 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 880 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 890 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 900 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 910 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 920 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 930 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 940 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 950 */ 278, 278, 278, 278, 278, }; -#define YY_SHIFT_COUNT (361) +#define YY_SHIFT_COUNT (363) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (739) +#define YY_SHIFT_MAX (744) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 189, 91, 91, 244, 244, 81, 242, 251, 251, 21, + /* 0 */ 159, 73, 73, 258, 258, 13, 237, 247, 247, 206, /* 10 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 20 */ 3, 3, 3, 0, 2, 251, 291, 291, 291, 58, - /* 30 */ 58, 3, 3, 3, 237, 3, 3, 3, 3, 289, - /* 40 */ 81, 92, 92, 41, 754, 754, 754, 251, 251, 251, - /* 50 */ 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, - /* 60 */ 251, 251, 251, 251, 251, 251, 251, 291, 291, 291, - /* 70 */ 93, 93, 93, 93, 93, 93, 93, 3, 3, 3, - /* 80 */ 302, 3, 3, 3, 58, 58, 3, 3, 3, 3, - /* 90 */ 274, 274, 288, 58, 3, 3, 3, 3, 3, 3, + /* 20 */ 3, 3, 3, 0, 2, 247, 299, 299, 299, 27, + /* 30 */ 27, 3, 3, 24, 3, 69, 3, 3, 3, 3, + /* 40 */ 172, 13, 33, 33, 40, 759, 759, 759, 247, 247, + /* 50 */ 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, + /* 60 */ 247, 247, 247, 247, 247, 247, 247, 247, 299, 299, + /* 70 */ 299, 102, 102, 102, 102, 102, 102, 102, 3, 3, + /* 80 */ 3, 218, 3, 3, 3, 27, 27, 3, 3, 3, + /* 90 */ 3, 296, 296, 292, 27, 3, 3, 3, 3, 3, /* 100 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 110 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 120 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 130 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 140 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 150 */ 3, 3, 446, 446, 446, 408, 408, 408, 408, 446, - /* 160 */ 446, 405, 406, 413, 410, 415, 426, 434, 436, 440, - /* 170 */ 453, 454, 446, 446, 446, 509, 509, 486, 81, 81, - /* 180 */ 446, 446, 508, 510, 554, 515, 514, 553, 517, 520, - /* 190 */ 486, 41, 446, 528, 528, 446, 528, 446, 528, 446, - /* 200 */ 446, 754, 754, 53, 80, 80, 120, 80, 146, 202, - /* 210 */ 218, 276, 276, 276, 276, 59, 264, 234, 234, 234, - /* 220 */ 234, 174, 240, 27, 296, 312, 312, 311, 335, 306, - /* 230 */ 337, 280, 298, 307, 334, 339, 340, 286, 297, 343, - /* 240 */ 345, 346, 347, 349, 351, 355, 356, 411, 380, 371, - /* 250 */ 364, 303, 309, 310, 452, 457, 322, 323, 363, 326, - /* 260 */ 396, 607, 462, 608, 610, 467, 615, 616, 523, 527, - /* 270 */ 485, 512, 513, 552, 516, 556, 559, 538, 539, 573, - /* 280 */ 560, 587, 589, 590, 575, 592, 593, 595, 673, 596, - /* 290 */ 582, 549, 584, 551, 601, 513, 602, 570, 604, 571, - /* 300 */ 611, 603, 605, 617, 686, 606, 609, 684, 690, 691, - /* 310 */ 692, 693, 694, 695, 696, 618, 688, 627, 624, 625, - /* 320 */ 594, 628, 682, 649, 697, 565, 566, 619, 619, 619, - /* 330 */ 619, 698, 572, 574, 619, 619, 619, 711, 712, 637, - /* 340 */ 619, 716, 717, 718, 719, 720, 721, 722, 723, 724, - /* 350 */ 725, 726, 727, 728, 729, 730, 640, 653, 731, 732, - /* 360 */ 678, 739, + /* 150 */ 3, 3, 3, 3, 452, 452, 452, 408, 408, 408, + /* 160 */ 408, 452, 452, 414, 413, 423, 422, 424, 441, 448, + /* 170 */ 466, 449, 465, 452, 452, 452, 513, 513, 493, 13, + /* 180 */ 13, 452, 452, 516, 514, 562, 522, 521, 564, 527, + /* 190 */ 530, 493, 40, 452, 452, 538, 538, 452, 538, 452, + /* 200 */ 538, 452, 452, 759, 759, 51, 78, 78, 105, 78, + /* 210 */ 131, 185, 195, 259, 259, 259, 259, 272, 253, 192, + /* 220 */ 192, 192, 192, 231, 239, 109, 308, 274, 274, 313, + /* 230 */ 323, 284, 275, 331, 337, 344, 348, 349, 351, 301, + /* 240 */ 336, 352, 353, 355, 356, 358, 328, 359, 361, 450, + /* 250 */ 394, 371, 377, 100, 314, 318, 461, 462, 325, 330, + /* 260 */ 380, 333, 403, 618, 471, 620, 621, 480, 629, 630, + /* 270 */ 536, 540, 495, 523, 526, 579, 541, 580, 585, 572, + /* 280 */ 573, 589, 591, 592, 594, 595, 577, 597, 598, 600, + /* 290 */ 676, 601, 583, 552, 588, 554, 605, 526, 606, 574, + /* 300 */ 608, 575, 614, 607, 609, 623, 691, 610, 612, 690, + /* 310 */ 695, 696, 697, 698, 699, 700, 701, 622, 693, 631, + /* 320 */ 628, 632, 596, 634, 687, 653, 702, 567, 570, 624, + /* 330 */ 624, 624, 624, 703, 576, 578, 624, 624, 624, 715, + /* 340 */ 717, 641, 624, 721, 722, 723, 724, 725, 726, 727, + /* 350 */ 728, 729, 730, 731, 732, 733, 734, 735, 644, 657, + /* 360 */ 736, 737, 683, 744, }; -#define YY_REDUCE_COUNT (202) -#define YY_REDUCE_MIN (-264) -#define YY_REDUCE_MAX (466) +#define YY_REDUCE_COUNT (204) +#define YY_REDUCE_MIN (-261) +#define YY_REDUCE_MAX (463) static const short yy_reduce_ofst[] = { - /* 0 */ -177, -18, -18, -192, -192, -89, -202, -199, -109, -156, - /* 10 */ -22, 24, -10, 114, 115, 133, 148, 149, 150, 156, - /* 20 */ 167, 172, 173, -182, -191, -264, -123, -118, -61, -146, - /* 30 */ -13, -189, -162, 34, 33, 37, 69, 86, -85, -139, - /* 40 */ 158, 52, 96, -175, -106, 197, -113, 22, 28, 186, - /* 50 */ 199, 207, 211, 213, 214, 215, 216, 217, 219, 220, - /* 60 */ 221, 222, 224, 225, 226, 227, 228, -1, 7, 235, - /* 70 */ 183, 256, 257, 258, 259, 260, 261, 304, 305, 308, - /* 80 */ 236, 313, 314, 315, 255, 262, 316, 317, 318, 319, - /* 90 */ 231, 232, 268, 263, 321, 324, 325, 327, 328, 329, - /* 100 */ 330, 331, 332, 333, 336, 338, 341, 342, 344, 348, - /* 110 */ 350, 352, 353, 354, 357, 358, 359, 360, 361, 362, - /* 120 */ 365, 366, 367, 368, 369, 370, 372, 373, 374, 375, - /* 130 */ 376, 377, 378, 379, 381, 382, 383, 384, 385, 386, - /* 140 */ 387, 388, 389, 390, 391, 392, 393, 394, 395, 397, - /* 150 */ 398, 399, 320, 400, 401, 241, 252, 266, 269, 402, - /* 160 */ 403, 272, 277, 265, 295, 290, 404, 407, 409, 412, - /* 170 */ 414, 416, 417, 418, 419, 420, 421, 422, 423, 427, - /* 180 */ 424, 425, 428, 430, 429, 431, 433, 437, 435, 441, - /* 190 */ 432, 443, 438, 439, 442, 445, 451, 455, 456, 458, - /* 200 */ 461, 447, 466, + /* 0 */ -31, -37, -37, -194, -194, -80, -204, -196, -184, -155, + /* 10 */ 29, 15, -164, 83, 148, 149, 158, 161, 163, 174, + /* 20 */ 175, 177, 182, -180, -193, -236, -149, -125, -108, -26, + /* 30 */ 32, -191, 104, -253, 44, 10, 95, 111, 143, 147, + /* 40 */ 64, -161, 179, 196, 178, 118, 204, 200, -261, -251, + /* 50 */ -200, -126, -62, -3, 6, 9, 48, 205, 213, 217, + /* 60 */ 219, 220, 223, 224, 225, 226, 227, 229, 117, 235, + /* 70 */ 248, 257, 260, 261, 262, 263, 264, 265, 306, 307, + /* 80 */ 309, 233, 310, 311, 312, 266, 267, 316, 317, 319, + /* 90 */ 320, 232, 242, 269, 276, 322, 326, 327, 329, 332, + /* 100 */ 334, 335, 338, 339, 340, 341, 342, 343, 345, 346, + /* 110 */ 347, 350, 354, 357, 360, 362, 363, 364, 365, 366, + /* 120 */ 367, 368, 369, 370, 372, 373, 374, 375, 376, 378, + /* 130 */ 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, + /* 140 */ 390, 391, 392, 393, 395, 396, 397, 398, 399, 400, + /* 150 */ 401, 402, 404, 405, 321, 406, 407, 254, 273, 277, + /* 160 */ 278, 409, 410, 268, 291, 295, 270, 302, 279, 271, + /* 170 */ 280, 411, 412, 415, 416, 417, 418, 419, 420, 421, + /* 180 */ 425, 426, 430, 427, 429, 428, 431, 432, 435, 436, + /* 190 */ 438, 433, 434, 437, 439, 440, 442, 453, 451, 454, + /* 200 */ 455, 458, 459, 460, 463, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 856, 979, 918, 989, 905, 915, 1126, 1126, 1126, 856, - /* 10 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 20 */ 856, 856, 856, 1037, 876, 1126, 856, 856, 856, 856, - /* 30 */ 856, 856, 856, 856, 915, 856, 856, 856, 856, 925, - /* 40 */ 915, 925, 925, 856, 1032, 963, 981, 856, 856, 856, - /* 50 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 60 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 70 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 80 */ 1039, 1045, 1042, 856, 856, 856, 1047, 856, 856, 856, - /* 90 */ 1069, 1069, 1030, 856, 856, 856, 856, 856, 856, 856, - /* 100 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 110 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 120 */ 856, 856, 856, 856, 856, 856, 903, 856, 901, 856, - /* 130 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 140 */ 856, 856, 856, 856, 887, 856, 856, 856, 856, 856, - /* 150 */ 856, 874, 878, 878, 878, 856, 856, 856, 856, 878, - /* 160 */ 878, 1076, 1080, 1062, 1074, 1070, 1057, 1055, 1053, 1061, - /* 170 */ 1052, 1084, 878, 878, 878, 923, 923, 919, 915, 915, - /* 180 */ 878, 878, 941, 939, 937, 929, 935, 931, 933, 927, - /* 190 */ 906, 856, 878, 913, 913, 878, 913, 878, 913, 878, - /* 200 */ 878, 963, 981, 856, 1085, 1075, 856, 1125, 1115, 1114, - /* 210 */ 856, 1121, 1113, 1112, 1111, 856, 856, 1107, 1110, 1109, - /* 220 */ 1108, 856, 856, 856, 856, 1117, 1116, 856, 856, 856, - /* 230 */ 856, 856, 856, 856, 856, 856, 856, 1081, 1077, 856, - /* 240 */ 856, 856, 856, 856, 856, 856, 856, 856, 1087, 856, - /* 250 */ 856, 856, 856, 856, 856, 856, 856, 856, 991, 856, - /* 260 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 270 */ 856, 1029, 856, 856, 856, 856, 856, 1041, 1040, 856, - /* 280 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 290 */ 1071, 856, 1063, 856, 856, 1003, 856, 856, 856, 856, - /* 300 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 310 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 320 */ 856, 856, 856, 856, 856, 856, 856, 1144, 1139, 1140, - /* 330 */ 1137, 856, 856, 856, 1136, 1131, 1132, 856, 856, 856, - /* 340 */ 1129, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 350 */ 856, 856, 856, 856, 856, 856, 947, 856, 885, 883, - /* 360 */ 856, 856, + /* 0 */ 864, 988, 927, 998, 914, 924, 1137, 1137, 1137, 864, + /* 10 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 20 */ 864, 864, 864, 1046, 884, 1137, 864, 864, 864, 864, + /* 30 */ 864, 864, 864, 1061, 864, 924, 864, 864, 864, 864, + /* 40 */ 934, 924, 934, 934, 864, 1041, 972, 990, 864, 864, + /* 50 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 60 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 70 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 80 */ 864, 1048, 1054, 1051, 864, 864, 864, 1056, 864, 864, + /* 90 */ 864, 1080, 1080, 1039, 864, 864, 864, 864, 864, 864, + /* 100 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 110 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 120 */ 864, 864, 864, 864, 864, 864, 864, 912, 864, 910, + /* 130 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 140 */ 864, 864, 864, 864, 864, 864, 895, 864, 864, 864, + /* 150 */ 864, 864, 864, 882, 886, 886, 886, 864, 864, 864, + /* 160 */ 864, 886, 886, 1087, 1091, 1073, 1085, 1081, 1068, 1066, + /* 170 */ 1064, 1072, 1095, 886, 886, 886, 932, 932, 928, 924, + /* 180 */ 924, 886, 886, 950, 948, 946, 938, 944, 940, 942, + /* 190 */ 936, 915, 864, 886, 886, 922, 922, 886, 922, 886, + /* 200 */ 922, 886, 886, 972, 990, 864, 1096, 1086, 864, 1136, + /* 210 */ 1126, 1125, 864, 1132, 1124, 1123, 1122, 864, 864, 1118, + /* 220 */ 1121, 1120, 1119, 864, 864, 864, 864, 1128, 1127, 864, + /* 230 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 1092, + /* 240 */ 1088, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 250 */ 1098, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 260 */ 1000, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 270 */ 864, 864, 864, 1038, 864, 864, 864, 864, 864, 1050, + /* 280 */ 1049, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 290 */ 864, 864, 1082, 864, 1074, 864, 864, 1012, 864, 864, + /* 300 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 310 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 864, + /* 320 */ 864, 864, 864, 864, 864, 864, 864, 864, 864, 1155, + /* 330 */ 1150, 1151, 1148, 864, 864, 864, 1147, 1142, 1143, 864, + /* 340 */ 864, 864, 1140, 864, 864, 864, 864, 864, 864, 864, + /* 350 */ 864, 864, 864, 864, 864, 864, 864, 864, 956, 864, + /* 360 */ 893, 891, 864, 864, }; /********** End of lemon-generated parsing tables *****************************/ @@ -594,6 +583,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* ACCOUNT => nothing */ 0, /* USE => nothing */ 0, /* DESCRIBE => nothing */ + 1, /* DESC => ID */ 0, /* ALTER => nothing */ 0, /* PASS => nothing */ 0, /* PRIVILEGE => nothing */ @@ -643,6 +633,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* FROM => nothing */ 0, /* VARIABLE => nothing */ 0, /* INTERVAL => nothing */ + 0, /* EVERY => nothing */ 0, /* SESSION => nothing */ 0, /* STATE_WINDOW => nothing */ 0, /* FILL => nothing */ @@ -650,7 +641,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* ORDER => nothing */ 0, /* BY => nothing */ 1, /* ASC => ID */ - 1, /* DESC => ID */ 0, /* GROUP => nothing */ 0, /* HAVING => nothing */ 0, /* LIMIT => nothing */ @@ -752,7 +742,6 @@ struct yyParser { int yyerrcnt; /* Shifts left before out of the error */ #endif ParseARG_SDECL /* A place to hold %extra_argument */ - ParseCTX_SDECL /* A place to hold %extra_context */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ @@ -876,205 +865,208 @@ static const char *const yyTokenName[] = { /* 73 */ "ACCOUNT", /* 74 */ "USE", /* 75 */ "DESCRIBE", - /* 76 */ "ALTER", - /* 77 */ "PASS", - /* 78 */ "PRIVILEGE", - /* 79 */ "LOCAL", - /* 80 */ "COMPACT", - /* 81 */ "LP", - /* 82 */ "RP", - /* 83 */ "IF", - /* 84 */ "EXISTS", - /* 85 */ "AS", - /* 86 */ "OUTPUTTYPE", - /* 87 */ "AGGREGATE", - /* 88 */ "BUFSIZE", - /* 89 */ "PPS", - /* 90 */ "TSERIES", - /* 91 */ "DBS", - /* 92 */ "STORAGE", - /* 93 */ "QTIME", - /* 94 */ "CONNS", - /* 95 */ "STATE", - /* 96 */ "COMMA", - /* 97 */ "KEEP", - /* 98 */ "CACHE", - /* 99 */ "REPLICA", - /* 100 */ "QUORUM", - /* 101 */ "DAYS", - /* 102 */ "MINROWS", - /* 103 */ "MAXROWS", - /* 104 */ "BLOCKS", - /* 105 */ "CTIME", - /* 106 */ "WAL", - /* 107 */ "FSYNC", - /* 108 */ "COMP", - /* 109 */ "PRECISION", - /* 110 */ "UPDATE", - /* 111 */ "CACHELAST", - /* 112 */ "PARTITIONS", - /* 113 */ "UNSIGNED", - /* 114 */ "TAGS", - /* 115 */ "USING", - /* 116 */ "NULL", - /* 117 */ "NOW", - /* 118 */ "SELECT", - /* 119 */ "UNION", - /* 120 */ "ALL", - /* 121 */ "DISTINCT", - /* 122 */ "FROM", - /* 123 */ "VARIABLE", - /* 124 */ "INTERVAL", - /* 125 */ "SESSION", - /* 126 */ "STATE_WINDOW", - /* 127 */ "FILL", - /* 128 */ "SLIDING", - /* 129 */ "ORDER", - /* 130 */ "BY", - /* 131 */ "ASC", - /* 132 */ "DESC", - /* 133 */ "GROUP", - /* 134 */ "HAVING", - /* 135 */ "LIMIT", - /* 136 */ "OFFSET", - /* 137 */ "SLIMIT", - /* 138 */ "SOFFSET", - /* 139 */ "WHERE", - /* 140 */ "RESET", - /* 141 */ "QUERY", - /* 142 */ "SYNCDB", - /* 143 */ "ADD", - /* 144 */ "COLUMN", - /* 145 */ "MODIFY", - /* 146 */ "TAG", - /* 147 */ "CHANGE", - /* 148 */ "SET", - /* 149 */ "KILL", - /* 150 */ "CONNECTION", - /* 151 */ "STREAM", - /* 152 */ "COLON", - /* 153 */ "ABORT", - /* 154 */ "AFTER", - /* 155 */ "ATTACH", - /* 156 */ "BEFORE", - /* 157 */ "BEGIN", - /* 158 */ "CASCADE", - /* 159 */ "CLUSTER", - /* 160 */ "CONFLICT", - /* 161 */ "COPY", - /* 162 */ "DEFERRED", - /* 163 */ "DELIMITERS", - /* 164 */ "DETACH", - /* 165 */ "EACH", - /* 166 */ "END", - /* 167 */ "EXPLAIN", - /* 168 */ "FAIL", - /* 169 */ "FOR", - /* 170 */ "IGNORE", - /* 171 */ "IMMEDIATE", - /* 172 */ "INITIALLY", - /* 173 */ "INSTEAD", - /* 174 */ "MATCH", - /* 175 */ "KEY", - /* 176 */ "OF", - /* 177 */ "RAISE", - /* 178 */ "REPLACE", - /* 179 */ "RESTRICT", - /* 180 */ "ROW", - /* 181 */ "STATEMENT", - /* 182 */ "TRIGGER", - /* 183 */ "VIEW", - /* 184 */ "IPTOKEN", - /* 185 */ "SEMI", - /* 186 */ "NONE", - /* 187 */ "PREV", - /* 188 */ "LINEAR", - /* 189 */ "IMPORT", - /* 190 */ "TBNAME", - /* 191 */ "JOIN", - /* 192 */ "INSERT", - /* 193 */ "INTO", - /* 194 */ "VALUES", - /* 195 */ "program", - /* 196 */ "cmd", - /* 197 */ "ids", - /* 198 */ "dbPrefix", - /* 199 */ "cpxName", - /* 200 */ "ifexists", - /* 201 */ "alter_db_optr", - /* 202 */ "alter_topic_optr", - /* 203 */ "acct_optr", - /* 204 */ "exprlist", - /* 205 */ "ifnotexists", - /* 206 */ "db_optr", - /* 207 */ "topic_optr", - /* 208 */ "typename", - /* 209 */ "bufsize", - /* 210 */ "pps", - /* 211 */ "tseries", - /* 212 */ "dbs", - /* 213 */ "streams", - /* 214 */ "storage", - /* 215 */ "qtime", - /* 216 */ "users", - /* 217 */ "conns", - /* 218 */ "state", - /* 219 */ "intitemlist", - /* 220 */ "intitem", - /* 221 */ "keep", - /* 222 */ "cache", - /* 223 */ "replica", - /* 224 */ "quorum", - /* 225 */ "days", - /* 226 */ "minrows", - /* 227 */ "maxrows", - /* 228 */ "blocks", - /* 229 */ "ctime", - /* 230 */ "wal", - /* 231 */ "fsync", - /* 232 */ "comp", - /* 233 */ "prec", - /* 234 */ "update", - /* 235 */ "cachelast", - /* 236 */ "partitions", - /* 237 */ "signed", - /* 238 */ "create_table_args", - /* 239 */ "create_stable_args", - /* 240 */ "create_table_list", - /* 241 */ "create_from_stable", - /* 242 */ "columnlist", - /* 243 */ "tagitemlist", - /* 244 */ "tagNamelist", - /* 245 */ "select", - /* 246 */ "column", - /* 247 */ "tagitem", - /* 248 */ "selcollist", - /* 249 */ "from", - /* 250 */ "where_opt", - /* 251 */ "interval_opt", - /* 252 */ "sliding_opt", - /* 253 */ "session_option", - /* 254 */ "windowstate_option", - /* 255 */ "fill_opt", - /* 256 */ "groupby_opt", - /* 257 */ "having_opt", - /* 258 */ "orderby_opt", - /* 259 */ "slimit_opt", - /* 260 */ "limit_opt", - /* 261 */ "union", - /* 262 */ "sclp", - /* 263 */ "distinct", - /* 264 */ "expr", - /* 265 */ "as", - /* 266 */ "tablelist", - /* 267 */ "sub", - /* 268 */ "tmvar", - /* 269 */ "sortlist", - /* 270 */ "sortitem", - /* 271 */ "item", - /* 272 */ "sortorder", - /* 273 */ "grouplist", - /* 274 */ "expritem", + /* 76 */ "DESC", + /* 77 */ "ALTER", + /* 78 */ "PASS", + /* 79 */ "PRIVILEGE", + /* 80 */ "LOCAL", + /* 81 */ "COMPACT", + /* 82 */ "LP", + /* 83 */ "RP", + /* 84 */ "IF", + /* 85 */ "EXISTS", + /* 86 */ "AS", + /* 87 */ "OUTPUTTYPE", + /* 88 */ "AGGREGATE", + /* 89 */ "BUFSIZE", + /* 90 */ "PPS", + /* 91 */ "TSERIES", + /* 92 */ "DBS", + /* 93 */ "STORAGE", + /* 94 */ "QTIME", + /* 95 */ "CONNS", + /* 96 */ "STATE", + /* 97 */ "COMMA", + /* 98 */ "KEEP", + /* 99 */ "CACHE", + /* 100 */ "REPLICA", + /* 101 */ "QUORUM", + /* 102 */ "DAYS", + /* 103 */ "MINROWS", + /* 104 */ "MAXROWS", + /* 105 */ "BLOCKS", + /* 106 */ "CTIME", + /* 107 */ "WAL", + /* 108 */ "FSYNC", + /* 109 */ "COMP", + /* 110 */ "PRECISION", + /* 111 */ "UPDATE", + /* 112 */ "CACHELAST", + /* 113 */ "PARTITIONS", + /* 114 */ "UNSIGNED", + /* 115 */ "TAGS", + /* 116 */ "USING", + /* 117 */ "NULL", + /* 118 */ "NOW", + /* 119 */ "SELECT", + /* 120 */ "UNION", + /* 121 */ "ALL", + /* 122 */ "DISTINCT", + /* 123 */ "FROM", + /* 124 */ "VARIABLE", + /* 125 */ "INTERVAL", + /* 126 */ "EVERY", + /* 127 */ "SESSION", + /* 128 */ "STATE_WINDOW", + /* 129 */ "FILL", + /* 130 */ "SLIDING", + /* 131 */ "ORDER", + /* 132 */ "BY", + /* 133 */ "ASC", + /* 134 */ "GROUP", + /* 135 */ "HAVING", + /* 136 */ "LIMIT", + /* 137 */ "OFFSET", + /* 138 */ "SLIMIT", + /* 139 */ "SOFFSET", + /* 140 */ "WHERE", + /* 141 */ "RESET", + /* 142 */ "QUERY", + /* 143 */ "SYNCDB", + /* 144 */ "ADD", + /* 145 */ "COLUMN", + /* 146 */ "MODIFY", + /* 147 */ "TAG", + /* 148 */ "CHANGE", + /* 149 */ "SET", + /* 150 */ "KILL", + /* 151 */ "CONNECTION", + /* 152 */ "STREAM", + /* 153 */ "COLON", + /* 154 */ "ABORT", + /* 155 */ "AFTER", + /* 156 */ "ATTACH", + /* 157 */ "BEFORE", + /* 158 */ "BEGIN", + /* 159 */ "CASCADE", + /* 160 */ "CLUSTER", + /* 161 */ "CONFLICT", + /* 162 */ "COPY", + /* 163 */ "DEFERRED", + /* 164 */ "DELIMITERS", + /* 165 */ "DETACH", + /* 166 */ "EACH", + /* 167 */ "END", + /* 168 */ "EXPLAIN", + /* 169 */ "FAIL", + /* 170 */ "FOR", + /* 171 */ "IGNORE", + /* 172 */ "IMMEDIATE", + /* 173 */ "INITIALLY", + /* 174 */ "INSTEAD", + /* 175 */ "MATCH", + /* 176 */ "KEY", + /* 177 */ "OF", + /* 178 */ "RAISE", + /* 179 */ "REPLACE", + /* 180 */ "RESTRICT", + /* 181 */ "ROW", + /* 182 */ "STATEMENT", + /* 183 */ "TRIGGER", + /* 184 */ "VIEW", + /* 185 */ "IPTOKEN", + /* 186 */ "SEMI", + /* 187 */ "NONE", + /* 188 */ "PREV", + /* 189 */ "LINEAR", + /* 190 */ "IMPORT", + /* 191 */ "TBNAME", + /* 192 */ "JOIN", + /* 193 */ "INSERT", + /* 194 */ "INTO", + /* 195 */ "VALUES", + /* 196 */ "error", + /* 197 */ "program", + /* 198 */ "cmd", + /* 199 */ "ids", + /* 200 */ "dbPrefix", + /* 201 */ "cpxName", + /* 202 */ "ifexists", + /* 203 */ "alter_db_optr", + /* 204 */ "alter_topic_optr", + /* 205 */ "acct_optr", + /* 206 */ "exprlist", + /* 207 */ "ifnotexists", + /* 208 */ "db_optr", + /* 209 */ "topic_optr", + /* 210 */ "typename", + /* 211 */ "bufsize", + /* 212 */ "pps", + /* 213 */ "tseries", + /* 214 */ "dbs", + /* 215 */ "streams", + /* 216 */ "storage", + /* 217 */ "qtime", + /* 218 */ "users", + /* 219 */ "conns", + /* 220 */ "state", + /* 221 */ "intitemlist", + /* 222 */ "intitem", + /* 223 */ "keep", + /* 224 */ "cache", + /* 225 */ "replica", + /* 226 */ "quorum", + /* 227 */ "days", + /* 228 */ "minrows", + /* 229 */ "maxrows", + /* 230 */ "blocks", + /* 231 */ "ctime", + /* 232 */ "wal", + /* 233 */ "fsync", + /* 234 */ "comp", + /* 235 */ "prec", + /* 236 */ "update", + /* 237 */ "cachelast", + /* 238 */ "partitions", + /* 239 */ "signed", + /* 240 */ "create_table_args", + /* 241 */ "create_stable_args", + /* 242 */ "create_table_list", + /* 243 */ "create_from_stable", + /* 244 */ "columnlist", + /* 245 */ "tagitemlist", + /* 246 */ "tagNamelist", + /* 247 */ "select", + /* 248 */ "column", + /* 249 */ "tagitem", + /* 250 */ "selcollist", + /* 251 */ "from", + /* 252 */ "where_opt", + /* 253 */ "interval_option", + /* 254 */ "sliding_opt", + /* 255 */ "session_option", + /* 256 */ "windowstate_option", + /* 257 */ "fill_opt", + /* 258 */ "groupby_opt", + /* 259 */ "having_opt", + /* 260 */ "orderby_opt", + /* 261 */ "slimit_opt", + /* 262 */ "limit_opt", + /* 263 */ "union", + /* 264 */ "sclp", + /* 265 */ "distinct", + /* 266 */ "expr", + /* 267 */ "as", + /* 268 */ "tablelist", + /* 269 */ "sub", + /* 270 */ "tmvar", + /* 271 */ "intervalKey", + /* 272 */ "sortlist", + /* 273 */ "sortitem", + /* 274 */ "item", + /* 275 */ "sortorder", + /* 276 */ "grouplist", + /* 277 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1122,255 +1114,258 @@ static const char *const yyRuleName[] = { /* 37 */ "cmd ::= DROP ACCOUNT ids", /* 38 */ "cmd ::= USE ids", /* 39 */ "cmd ::= DESCRIBE ids cpxName", - /* 40 */ "cmd ::= ALTER USER ids PASS ids", - /* 41 */ "cmd ::= ALTER USER ids PRIVILEGE ids", - /* 42 */ "cmd ::= ALTER DNODE ids ids", - /* 43 */ "cmd ::= ALTER DNODE ids ids ids", - /* 44 */ "cmd ::= ALTER LOCAL ids", - /* 45 */ "cmd ::= ALTER LOCAL ids ids", - /* 46 */ "cmd ::= ALTER DATABASE ids alter_db_optr", - /* 47 */ "cmd ::= ALTER TOPIC ids alter_topic_optr", - /* 48 */ "cmd ::= ALTER ACCOUNT ids acct_optr", - /* 49 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", - /* 50 */ "cmd ::= COMPACT VNODES IN LP exprlist RP", - /* 51 */ "ids ::= ID", - /* 52 */ "ids ::= STRING", - /* 53 */ "ifexists ::= IF EXISTS", - /* 54 */ "ifexists ::=", - /* 55 */ "ifnotexists ::= IF NOT EXISTS", - /* 56 */ "ifnotexists ::=", - /* 57 */ "cmd ::= CREATE DNODE ids", - /* 58 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", - /* 59 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", - /* 60 */ "cmd ::= CREATE TOPIC ifnotexists ids topic_optr", - /* 61 */ "cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", - /* 62 */ "cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", - /* 63 */ "cmd ::= CREATE USER ids PASS ids", - /* 64 */ "bufsize ::=", - /* 65 */ "bufsize ::= BUFSIZE INTEGER", - /* 66 */ "pps ::=", - /* 67 */ "pps ::= PPS INTEGER", - /* 68 */ "tseries ::=", - /* 69 */ "tseries ::= TSERIES INTEGER", - /* 70 */ "dbs ::=", - /* 71 */ "dbs ::= DBS INTEGER", - /* 72 */ "streams ::=", - /* 73 */ "streams ::= STREAMS INTEGER", - /* 74 */ "storage ::=", - /* 75 */ "storage ::= STORAGE INTEGER", - /* 76 */ "qtime ::=", - /* 77 */ "qtime ::= QTIME INTEGER", - /* 78 */ "users ::=", - /* 79 */ "users ::= USERS INTEGER", - /* 80 */ "conns ::=", - /* 81 */ "conns ::= CONNS INTEGER", - /* 82 */ "state ::=", - /* 83 */ "state ::= STATE ids", - /* 84 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", - /* 85 */ "intitemlist ::= intitemlist COMMA intitem", - /* 86 */ "intitemlist ::= intitem", - /* 87 */ "intitem ::= INTEGER", - /* 88 */ "keep ::= KEEP intitemlist", - /* 89 */ "cache ::= CACHE INTEGER", - /* 90 */ "replica ::= REPLICA INTEGER", - /* 91 */ "quorum ::= QUORUM INTEGER", - /* 92 */ "days ::= DAYS INTEGER", - /* 93 */ "minrows ::= MINROWS INTEGER", - /* 94 */ "maxrows ::= MAXROWS INTEGER", - /* 95 */ "blocks ::= BLOCKS INTEGER", - /* 96 */ "ctime ::= CTIME INTEGER", - /* 97 */ "wal ::= WAL INTEGER", - /* 98 */ "fsync ::= FSYNC INTEGER", - /* 99 */ "comp ::= COMP INTEGER", - /* 100 */ "prec ::= PRECISION STRING", - /* 101 */ "update ::= UPDATE INTEGER", - /* 102 */ "cachelast ::= CACHELAST INTEGER", - /* 103 */ "partitions ::= PARTITIONS INTEGER", - /* 104 */ "db_optr ::=", - /* 105 */ "db_optr ::= db_optr cache", - /* 106 */ "db_optr ::= db_optr replica", - /* 107 */ "db_optr ::= db_optr quorum", - /* 108 */ "db_optr ::= db_optr days", - /* 109 */ "db_optr ::= db_optr minrows", - /* 110 */ "db_optr ::= db_optr maxrows", - /* 111 */ "db_optr ::= db_optr blocks", - /* 112 */ "db_optr ::= db_optr ctime", - /* 113 */ "db_optr ::= db_optr wal", - /* 114 */ "db_optr ::= db_optr fsync", - /* 115 */ "db_optr ::= db_optr comp", - /* 116 */ "db_optr ::= db_optr prec", - /* 117 */ "db_optr ::= db_optr keep", - /* 118 */ "db_optr ::= db_optr update", - /* 119 */ "db_optr ::= db_optr cachelast", - /* 120 */ "topic_optr ::= db_optr", - /* 121 */ "topic_optr ::= topic_optr partitions", - /* 122 */ "alter_db_optr ::=", - /* 123 */ "alter_db_optr ::= alter_db_optr replica", - /* 124 */ "alter_db_optr ::= alter_db_optr quorum", - /* 125 */ "alter_db_optr ::= alter_db_optr keep", - /* 126 */ "alter_db_optr ::= alter_db_optr blocks", - /* 127 */ "alter_db_optr ::= alter_db_optr comp", - /* 128 */ "alter_db_optr ::= alter_db_optr update", - /* 129 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 130 */ "alter_topic_optr ::= alter_db_optr", - /* 131 */ "alter_topic_optr ::= alter_topic_optr partitions", - /* 132 */ "typename ::= ids", - /* 133 */ "typename ::= ids LP signed RP", - /* 134 */ "typename ::= ids UNSIGNED", - /* 135 */ "signed ::= INTEGER", - /* 136 */ "signed ::= PLUS INTEGER", - /* 137 */ "signed ::= MINUS INTEGER", - /* 138 */ "cmd ::= CREATE TABLE create_table_args", - /* 139 */ "cmd ::= CREATE TABLE create_stable_args", - /* 140 */ "cmd ::= CREATE STABLE create_stable_args", - /* 141 */ "cmd ::= CREATE TABLE create_table_list", - /* 142 */ "create_table_list ::= create_from_stable", - /* 143 */ "create_table_list ::= create_table_list create_from_stable", - /* 144 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 145 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 146 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", - /* 147 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", - /* 148 */ "tagNamelist ::= tagNamelist COMMA ids", - /* 149 */ "tagNamelist ::= ids", - /* 150 */ "create_table_args ::= ifnotexists ids cpxName AS select", - /* 151 */ "columnlist ::= columnlist COMMA column", - /* 152 */ "columnlist ::= column", - /* 153 */ "column ::= ids typename", - /* 154 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 155 */ "tagitemlist ::= tagitem", - /* 156 */ "tagitem ::= INTEGER", - /* 157 */ "tagitem ::= FLOAT", - /* 158 */ "tagitem ::= STRING", - /* 159 */ "tagitem ::= BOOL", - /* 160 */ "tagitem ::= NULL", - /* 161 */ "tagitem ::= NOW", - /* 162 */ "tagitem ::= MINUS INTEGER", - /* 163 */ "tagitem ::= MINUS FLOAT", - /* 164 */ "tagitem ::= PLUS INTEGER", - /* 165 */ "tagitem ::= PLUS FLOAT", - /* 166 */ "select ::= SELECT selcollist from where_opt interval_opt sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", - /* 167 */ "select ::= LP select RP", - /* 168 */ "union ::= select", - /* 169 */ "union ::= union UNION ALL select", - /* 170 */ "cmd ::= union", - /* 171 */ "select ::= SELECT selcollist", - /* 172 */ "sclp ::= selcollist COMMA", - /* 173 */ "sclp ::=", - /* 174 */ "selcollist ::= sclp distinct expr as", - /* 175 */ "selcollist ::= sclp STAR", - /* 176 */ "as ::= AS ids", - /* 177 */ "as ::= ids", - /* 178 */ "as ::=", - /* 179 */ "distinct ::= DISTINCT", - /* 180 */ "distinct ::=", - /* 181 */ "from ::= FROM tablelist", - /* 182 */ "from ::= FROM sub", - /* 183 */ "sub ::= LP union RP", - /* 184 */ "sub ::= LP union RP ids", - /* 185 */ "sub ::= sub COMMA LP union RP ids", - /* 186 */ "tablelist ::= ids cpxName", - /* 187 */ "tablelist ::= ids cpxName ids", - /* 188 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 189 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 190 */ "tmvar ::= VARIABLE", - /* 191 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 192 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", - /* 193 */ "interval_opt ::=", - /* 194 */ "session_option ::=", - /* 195 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 196 */ "windowstate_option ::=", - /* 197 */ "windowstate_option ::= STATE_WINDOW LP ids RP", - /* 198 */ "fill_opt ::=", - /* 199 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 200 */ "fill_opt ::= FILL LP ID RP", - /* 201 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 202 */ "sliding_opt ::=", - /* 203 */ "orderby_opt ::=", - /* 204 */ "orderby_opt ::= ORDER BY sortlist", - /* 205 */ "sortlist ::= sortlist COMMA item sortorder", - /* 206 */ "sortlist ::= item sortorder", - /* 207 */ "item ::= ids cpxName", - /* 208 */ "sortorder ::= ASC", - /* 209 */ "sortorder ::= DESC", - /* 210 */ "sortorder ::=", - /* 211 */ "groupby_opt ::=", - /* 212 */ "groupby_opt ::= GROUP BY grouplist", - /* 213 */ "grouplist ::= grouplist COMMA item", - /* 214 */ "grouplist ::= item", - /* 215 */ "having_opt ::=", - /* 216 */ "having_opt ::= HAVING expr", - /* 217 */ "limit_opt ::=", - /* 218 */ "limit_opt ::= LIMIT signed", - /* 219 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 220 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 221 */ "slimit_opt ::=", - /* 222 */ "slimit_opt ::= SLIMIT signed", - /* 223 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 224 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 225 */ "where_opt ::=", - /* 226 */ "where_opt ::= WHERE expr", - /* 227 */ "expr ::= LP expr RP", - /* 228 */ "expr ::= ID", - /* 229 */ "expr ::= ID DOT ID", - /* 230 */ "expr ::= ID DOT STAR", - /* 231 */ "expr ::= INTEGER", - /* 232 */ "expr ::= MINUS INTEGER", - /* 233 */ "expr ::= PLUS INTEGER", - /* 234 */ "expr ::= FLOAT", - /* 235 */ "expr ::= MINUS FLOAT", - /* 236 */ "expr ::= PLUS FLOAT", - /* 237 */ "expr ::= STRING", - /* 238 */ "expr ::= NOW", - /* 239 */ "expr ::= VARIABLE", - /* 240 */ "expr ::= PLUS VARIABLE", - /* 241 */ "expr ::= MINUS VARIABLE", - /* 242 */ "expr ::= BOOL", - /* 243 */ "expr ::= NULL", - /* 244 */ "expr ::= ID LP exprlist RP", - /* 245 */ "expr ::= ID LP STAR RP", - /* 246 */ "expr ::= expr IS NULL", - /* 247 */ "expr ::= expr IS NOT NULL", - /* 248 */ "expr ::= expr LT expr", - /* 249 */ "expr ::= expr GT expr", - /* 250 */ "expr ::= expr LE expr", - /* 251 */ "expr ::= expr GE expr", - /* 252 */ "expr ::= expr NE expr", - /* 253 */ "expr ::= expr EQ expr", - /* 254 */ "expr ::= expr BETWEEN expr AND expr", - /* 255 */ "expr ::= expr AND expr", - /* 256 */ "expr ::= expr OR expr", - /* 257 */ "expr ::= expr PLUS expr", - /* 258 */ "expr ::= expr MINUS expr", - /* 259 */ "expr ::= expr STAR expr", - /* 260 */ "expr ::= expr SLASH expr", - /* 261 */ "expr ::= expr REM expr", - /* 262 */ "expr ::= expr LIKE expr", - /* 263 */ "expr ::= expr IN LP exprlist RP", - /* 264 */ "exprlist ::= exprlist COMMA expritem", - /* 265 */ "exprlist ::= expritem", - /* 266 */ "expritem ::= expr", - /* 267 */ "expritem ::=", - /* 268 */ "cmd ::= RESET QUERY CACHE", - /* 269 */ "cmd ::= SYNCDB ids REPLICA", - /* 270 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 271 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 272 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 273 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 274 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 275 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 276 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 277 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 278 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 279 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 280 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 281 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 282 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 283 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 284 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 285 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 286 */ "cmd ::= KILL CONNECTION INTEGER", - /* 287 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 288 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 40 */ "cmd ::= DESC ids cpxName", + /* 41 */ "cmd ::= ALTER USER ids PASS ids", + /* 42 */ "cmd ::= ALTER USER ids PRIVILEGE ids", + /* 43 */ "cmd ::= ALTER DNODE ids ids", + /* 44 */ "cmd ::= ALTER DNODE ids ids ids", + /* 45 */ "cmd ::= ALTER LOCAL ids", + /* 46 */ "cmd ::= ALTER LOCAL ids ids", + /* 47 */ "cmd ::= ALTER DATABASE ids alter_db_optr", + /* 48 */ "cmd ::= ALTER TOPIC ids alter_topic_optr", + /* 49 */ "cmd ::= ALTER ACCOUNT ids acct_optr", + /* 50 */ "cmd ::= ALTER ACCOUNT ids PASS ids acct_optr", + /* 51 */ "cmd ::= COMPACT VNODES IN LP exprlist RP", + /* 52 */ "ids ::= ID", + /* 53 */ "ids ::= STRING", + /* 54 */ "ifexists ::= IF EXISTS", + /* 55 */ "ifexists ::=", + /* 56 */ "ifnotexists ::= IF NOT EXISTS", + /* 57 */ "ifnotexists ::=", + /* 58 */ "cmd ::= CREATE DNODE ids", + /* 59 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", + /* 60 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", + /* 61 */ "cmd ::= CREATE TOPIC ifnotexists ids topic_optr", + /* 62 */ "cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", + /* 63 */ "cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", + /* 64 */ "cmd ::= CREATE USER ids PASS ids", + /* 65 */ "bufsize ::=", + /* 66 */ "bufsize ::= BUFSIZE INTEGER", + /* 67 */ "pps ::=", + /* 68 */ "pps ::= PPS INTEGER", + /* 69 */ "tseries ::=", + /* 70 */ "tseries ::= TSERIES INTEGER", + /* 71 */ "dbs ::=", + /* 72 */ "dbs ::= DBS INTEGER", + /* 73 */ "streams ::=", + /* 74 */ "streams ::= STREAMS INTEGER", + /* 75 */ "storage ::=", + /* 76 */ "storage ::= STORAGE INTEGER", + /* 77 */ "qtime ::=", + /* 78 */ "qtime ::= QTIME INTEGER", + /* 79 */ "users ::=", + /* 80 */ "users ::= USERS INTEGER", + /* 81 */ "conns ::=", + /* 82 */ "conns ::= CONNS INTEGER", + /* 83 */ "state ::=", + /* 84 */ "state ::= STATE ids", + /* 85 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", + /* 86 */ "intitemlist ::= intitemlist COMMA intitem", + /* 87 */ "intitemlist ::= intitem", + /* 88 */ "intitem ::= INTEGER", + /* 89 */ "keep ::= KEEP intitemlist", + /* 90 */ "cache ::= CACHE INTEGER", + /* 91 */ "replica ::= REPLICA INTEGER", + /* 92 */ "quorum ::= QUORUM INTEGER", + /* 93 */ "days ::= DAYS INTEGER", + /* 94 */ "minrows ::= MINROWS INTEGER", + /* 95 */ "maxrows ::= MAXROWS INTEGER", + /* 96 */ "blocks ::= BLOCKS INTEGER", + /* 97 */ "ctime ::= CTIME INTEGER", + /* 98 */ "wal ::= WAL INTEGER", + /* 99 */ "fsync ::= FSYNC INTEGER", + /* 100 */ "comp ::= COMP INTEGER", + /* 101 */ "prec ::= PRECISION STRING", + /* 102 */ "update ::= UPDATE INTEGER", + /* 103 */ "cachelast ::= CACHELAST INTEGER", + /* 104 */ "partitions ::= PARTITIONS INTEGER", + /* 105 */ "db_optr ::=", + /* 106 */ "db_optr ::= db_optr cache", + /* 107 */ "db_optr ::= db_optr replica", + /* 108 */ "db_optr ::= db_optr quorum", + /* 109 */ "db_optr ::= db_optr days", + /* 110 */ "db_optr ::= db_optr minrows", + /* 111 */ "db_optr ::= db_optr maxrows", + /* 112 */ "db_optr ::= db_optr blocks", + /* 113 */ "db_optr ::= db_optr ctime", + /* 114 */ "db_optr ::= db_optr wal", + /* 115 */ "db_optr ::= db_optr fsync", + /* 116 */ "db_optr ::= db_optr comp", + /* 117 */ "db_optr ::= db_optr prec", + /* 118 */ "db_optr ::= db_optr keep", + /* 119 */ "db_optr ::= db_optr update", + /* 120 */ "db_optr ::= db_optr cachelast", + /* 121 */ "topic_optr ::= db_optr", + /* 122 */ "topic_optr ::= topic_optr partitions", + /* 123 */ "alter_db_optr ::=", + /* 124 */ "alter_db_optr ::= alter_db_optr replica", + /* 125 */ "alter_db_optr ::= alter_db_optr quorum", + /* 126 */ "alter_db_optr ::= alter_db_optr keep", + /* 127 */ "alter_db_optr ::= alter_db_optr blocks", + /* 128 */ "alter_db_optr ::= alter_db_optr comp", + /* 129 */ "alter_db_optr ::= alter_db_optr update", + /* 130 */ "alter_db_optr ::= alter_db_optr cachelast", + /* 131 */ "alter_topic_optr ::= alter_db_optr", + /* 132 */ "alter_topic_optr ::= alter_topic_optr partitions", + /* 133 */ "typename ::= ids", + /* 134 */ "typename ::= ids LP signed RP", + /* 135 */ "typename ::= ids UNSIGNED", + /* 136 */ "signed ::= INTEGER", + /* 137 */ "signed ::= PLUS INTEGER", + /* 138 */ "signed ::= MINUS INTEGER", + /* 139 */ "cmd ::= CREATE TABLE create_table_args", + /* 140 */ "cmd ::= CREATE TABLE create_stable_args", + /* 141 */ "cmd ::= CREATE STABLE create_stable_args", + /* 142 */ "cmd ::= CREATE TABLE create_table_list", + /* 143 */ "create_table_list ::= create_from_stable", + /* 144 */ "create_table_list ::= create_table_list create_from_stable", + /* 145 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", + /* 146 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", + /* 147 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", + /* 148 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", + /* 149 */ "tagNamelist ::= tagNamelist COMMA ids", + /* 150 */ "tagNamelist ::= ids", + /* 151 */ "create_table_args ::= ifnotexists ids cpxName AS select", + /* 152 */ "columnlist ::= columnlist COMMA column", + /* 153 */ "columnlist ::= column", + /* 154 */ "column ::= ids typename", + /* 155 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 156 */ "tagitemlist ::= tagitem", + /* 157 */ "tagitem ::= INTEGER", + /* 158 */ "tagitem ::= FLOAT", + /* 159 */ "tagitem ::= STRING", + /* 160 */ "tagitem ::= BOOL", + /* 161 */ "tagitem ::= NULL", + /* 162 */ "tagitem ::= NOW", + /* 163 */ "tagitem ::= MINUS INTEGER", + /* 164 */ "tagitem ::= MINUS FLOAT", + /* 165 */ "tagitem ::= PLUS INTEGER", + /* 166 */ "tagitem ::= PLUS FLOAT", + /* 167 */ "select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", + /* 168 */ "select ::= LP select RP", + /* 169 */ "union ::= select", + /* 170 */ "union ::= union UNION ALL select", + /* 171 */ "cmd ::= union", + /* 172 */ "select ::= SELECT selcollist", + /* 173 */ "sclp ::= selcollist COMMA", + /* 174 */ "sclp ::=", + /* 175 */ "selcollist ::= sclp distinct expr as", + /* 176 */ "selcollist ::= sclp STAR", + /* 177 */ "as ::= AS ids", + /* 178 */ "as ::= ids", + /* 179 */ "as ::=", + /* 180 */ "distinct ::= DISTINCT", + /* 181 */ "distinct ::=", + /* 182 */ "from ::= FROM tablelist", + /* 183 */ "from ::= FROM sub", + /* 184 */ "sub ::= LP union RP", + /* 185 */ "sub ::= LP union RP ids", + /* 186 */ "sub ::= sub COMMA LP union RP ids", + /* 187 */ "tablelist ::= ids cpxName", + /* 188 */ "tablelist ::= ids cpxName ids", + /* 189 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 190 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 191 */ "tmvar ::= VARIABLE", + /* 192 */ "interval_option ::= intervalKey LP tmvar RP", + /* 193 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", + /* 194 */ "interval_option ::=", + /* 195 */ "intervalKey ::= INTERVAL", + /* 196 */ "intervalKey ::= EVERY", + /* 197 */ "session_option ::=", + /* 198 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 199 */ "windowstate_option ::=", + /* 200 */ "windowstate_option ::= STATE_WINDOW LP ids RP", + /* 201 */ "fill_opt ::=", + /* 202 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 203 */ "fill_opt ::= FILL LP ID RP", + /* 204 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 205 */ "sliding_opt ::=", + /* 206 */ "orderby_opt ::=", + /* 207 */ "orderby_opt ::= ORDER BY sortlist", + /* 208 */ "sortlist ::= sortlist COMMA item sortorder", + /* 209 */ "sortlist ::= item sortorder", + /* 210 */ "item ::= ids cpxName", + /* 211 */ "sortorder ::= ASC", + /* 212 */ "sortorder ::= DESC", + /* 213 */ "sortorder ::=", + /* 214 */ "groupby_opt ::=", + /* 215 */ "groupby_opt ::= GROUP BY grouplist", + /* 216 */ "grouplist ::= grouplist COMMA item", + /* 217 */ "grouplist ::= item", + /* 218 */ "having_opt ::=", + /* 219 */ "having_opt ::= HAVING expr", + /* 220 */ "limit_opt ::=", + /* 221 */ "limit_opt ::= LIMIT signed", + /* 222 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 223 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 224 */ "slimit_opt ::=", + /* 225 */ "slimit_opt ::= SLIMIT signed", + /* 226 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 227 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 228 */ "where_opt ::=", + /* 229 */ "where_opt ::= WHERE expr", + /* 230 */ "expr ::= LP expr RP", + /* 231 */ "expr ::= ID", + /* 232 */ "expr ::= ID DOT ID", + /* 233 */ "expr ::= ID DOT STAR", + /* 234 */ "expr ::= INTEGER", + /* 235 */ "expr ::= MINUS INTEGER", + /* 236 */ "expr ::= PLUS INTEGER", + /* 237 */ "expr ::= FLOAT", + /* 238 */ "expr ::= MINUS FLOAT", + /* 239 */ "expr ::= PLUS FLOAT", + /* 240 */ "expr ::= STRING", + /* 241 */ "expr ::= NOW", + /* 242 */ "expr ::= VARIABLE", + /* 243 */ "expr ::= PLUS VARIABLE", + /* 244 */ "expr ::= MINUS VARIABLE", + /* 245 */ "expr ::= BOOL", + /* 246 */ "expr ::= NULL", + /* 247 */ "expr ::= ID LP exprlist RP", + /* 248 */ "expr ::= ID LP STAR RP", + /* 249 */ "expr ::= expr IS NULL", + /* 250 */ "expr ::= expr IS NOT NULL", + /* 251 */ "expr ::= expr LT expr", + /* 252 */ "expr ::= expr GT expr", + /* 253 */ "expr ::= expr LE expr", + /* 254 */ "expr ::= expr GE expr", + /* 255 */ "expr ::= expr NE expr", + /* 256 */ "expr ::= expr EQ expr", + /* 257 */ "expr ::= expr BETWEEN expr AND expr", + /* 258 */ "expr ::= expr AND expr", + /* 259 */ "expr ::= expr OR expr", + /* 260 */ "expr ::= expr PLUS expr", + /* 261 */ "expr ::= expr MINUS expr", + /* 262 */ "expr ::= expr STAR expr", + /* 263 */ "expr ::= expr SLASH expr", + /* 264 */ "expr ::= expr REM expr", + /* 265 */ "expr ::= expr LIKE expr", + /* 266 */ "expr ::= expr IN LP exprlist RP", + /* 267 */ "exprlist ::= exprlist COMMA expritem", + /* 268 */ "exprlist ::= expritem", + /* 269 */ "expritem ::= expr", + /* 270 */ "expritem ::=", + /* 271 */ "cmd ::= RESET QUERY CACHE", + /* 272 */ "cmd ::= SYNCDB ids REPLICA", + /* 273 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 274 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 275 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 276 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 277 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 278 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 279 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 280 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 281 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 282 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 283 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 284 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 285 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 286 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 287 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 288 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 289 */ "cmd ::= KILL CONNECTION INTEGER", + /* 290 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 291 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1419,29 +1414,28 @@ static int yyGrowStack(yyParser *p){ /* Initialize a new parser that has already been allocated. */ -void ParseInit(void *yypRawParser ParseCTX_PDECL){ - yyParser *yypParser = (yyParser*)yypRawParser; - ParseCTX_STORE +void ParseInit(void *yypParser){ + yyParser *pParser = (yyParser*)yypParser; #ifdef YYTRACKMAXSTACKDEPTH - yypParser->yyhwm = 0; + pParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 - yypParser->yytos = NULL; - yypParser->yystack = NULL; - yypParser->yystksz = 0; - if( yyGrowStack(yypParser) ){ - yypParser->yystack = &yypParser->yystk0; - yypParser->yystksz = 1; + pParser->yytos = NULL; + pParser->yystack = NULL; + pParser->yystksz = 0; + if( yyGrowStack(pParser) ){ + pParser->yystack = &pParser->yystk0; + pParser->yystksz = 1; } #endif #ifndef YYNOERRORRECOVERY - yypParser->yyerrcnt = -1; + pParser->yyerrcnt = -1; #endif - yypParser->yytos = yypParser->yystack; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; + pParser->yytos = pParser->yystack; + pParser->yystack[0].stateno = 0; + pParser->yystack[0].major = 0; #if YYSTACKDEPTH>0 - yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; + pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1]; #endif } @@ -1458,14 +1452,11 @@ void ParseInit(void *yypRawParser ParseCTX_PDECL){ ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ -void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){ - yyParser *yypParser; - yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); - if( yypParser ){ - ParseCTX_STORE - ParseInit(yypParser ParseCTX_PARAM); - } - return (void*)yypParser; +void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ + yyParser *pParser; + pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); + if( pParser ) ParseInit(pParser); + return pParser; } #endif /* Parse_ENGINEALWAYSONSTACK */ @@ -1482,8 +1473,7 @@ static void yy_destructor( YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen @@ -1496,76 +1486,60 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 204: /* exprlist */ - case 248: /* selcollist */ - case 262: /* sclp */ + case 206: /* exprlist */ + case 250: /* selcollist */ + case 264: /* sclp */ { -#line 750 "sql.y" -tSqlExprListDestroy((yypminor->yy131)); -#line 1506 "sql.c" +tSqlExprListDestroy((yypminor->yy421)); } break; - case 219: /* intitemlist */ - case 221: /* keep */ - case 242: /* columnlist */ - case 243: /* tagitemlist */ - case 244: /* tagNamelist */ - case 255: /* fill_opt */ - case 256: /* groupby_opt */ - case 258: /* orderby_opt */ - case 269: /* sortlist */ - case 273: /* grouplist */ -{ -#line 253 "sql.y" -taosArrayDestroy((yypminor->yy131)); -#line 1522 "sql.c" + case 221: /* intitemlist */ + case 223: /* keep */ + case 244: /* columnlist */ + case 245: /* tagitemlist */ + case 246: /* tagNamelist */ + case 257: /* fill_opt */ + case 258: /* groupby_opt */ + case 260: /* orderby_opt */ + case 272: /* sortlist */ + case 276: /* grouplist */ +{ +taosArrayDestroy((yypminor->yy421)); } break; - case 240: /* create_table_list */ + case 242: /* create_table_list */ { -#line 361 "sql.y" -destroyCreateTableSql((yypminor->yy272)); -#line 1529 "sql.c" +destroyCreateTableSql((yypminor->yy438)); } break; - case 245: /* select */ + case 247: /* select */ { -#line 481 "sql.y" -destroySqlNode((yypminor->yy256)); -#line 1536 "sql.c" +destroySqlNode((yypminor->yy56)); } break; - case 249: /* from */ - case 266: /* tablelist */ - case 267: /* sub */ + case 251: /* from */ + case 268: /* tablelist */ + case 269: /* sub */ { -#line 536 "sql.y" -destroyRelationInfo((yypminor->yy544)); -#line 1545 "sql.c" +destroyRelationInfo((yypminor->yy8)); } break; - case 250: /* where_opt */ - case 257: /* having_opt */ - case 264: /* expr */ - case 274: /* expritem */ + case 252: /* where_opt */ + case 259: /* having_opt */ + case 266: /* expr */ + case 277: /* expritem */ { -#line 683 "sql.y" -tSqlExprDestroy((yypminor->yy46)); -#line 1555 "sql.c" +tSqlExprDestroy((yypminor->yy439)); } break; - case 261: /* union */ + case 263: /* union */ { -#line 489 "sql.y" -destroyAllSqlNode((yypminor->yy131)); -#line 1562 "sql.c" +destroyAllSqlNode((yypminor->yy421)); } break; - case 270: /* sortitem */ + case 273: /* sortitem */ { -#line 616 "sql.y" -tVariantDestroy(&(yypminor->yy516)); -#line 1569 "sql.c" +tVariantDestroy(&(yypminor->yy430)); } break; /********* End destructor definitions *****************************************/ @@ -1677,12 +1651,13 @@ int ParseCoverage(FILE *out){ ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ -static YYACTIONTYPE yy_find_shift_action( - YYCODETYPE iLookAhead, /* The look-ahead token */ - YYACTIONTYPE stateno /* Current state number */ +static unsigned int yy_find_shift_action( + yyParser *pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; - + int stateno = pParser->yytos->stateno; + if( stateno>YY_MAX_SHIFT ) return stateno; assert( stateno <= YY_SHIFT_COUNT ); #if defined(YYCOVERAGE) @@ -1690,19 +1665,15 @@ static YYACTIONTYPE yy_find_shift_action( #endif do{ i = yy_shift_ofst[stateno]; - assert( i>=0 ); - assert( i<=YY_ACTTAB_COUNT ); - assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); + assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - assert( i<(int)YY_NLOOKAHEAD ); if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - assert( iLookAhead %s\n", @@ -1717,8 +1688,15 @@ static YYACTIONTYPE yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); - if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ + if( +#if YY_SHIFT_MIN+YYWILDCARD<0 + j>=0 && +#endif +#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT + j0 + ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -1732,7 +1710,6 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && iyytos; - yytos->stateno = yyNewState; - yytos->major = yyMajor; + yytos->stateno = (YYACTIONTYPE)yyNewState; + yytos->major = (YYCODETYPE)yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } -/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side -** of that rule */ -static const YYCODETYPE yyRuleInfoLhs[] = { - 195, /* (0) program ::= cmd */ - 196, /* (1) cmd ::= SHOW DATABASES */ - 196, /* (2) cmd ::= SHOW TOPICS */ - 196, /* (3) cmd ::= SHOW FUNCTIONS */ - 196, /* (4) cmd ::= SHOW MNODES */ - 196, /* (5) cmd ::= SHOW DNODES */ - 196, /* (6) cmd ::= SHOW ACCOUNTS */ - 196, /* (7) cmd ::= SHOW USERS */ - 196, /* (8) cmd ::= SHOW MODULES */ - 196, /* (9) cmd ::= SHOW QUERIES */ - 196, /* (10) cmd ::= SHOW CONNECTIONS */ - 196, /* (11) cmd ::= SHOW STREAMS */ - 196, /* (12) cmd ::= SHOW VARIABLES */ - 196, /* (13) cmd ::= SHOW SCORES */ - 196, /* (14) cmd ::= SHOW GRANTS */ - 196, /* (15) cmd ::= SHOW VNODES */ - 196, /* (16) cmd ::= SHOW VNODES ids */ - 198, /* (17) dbPrefix ::= */ - 198, /* (18) dbPrefix ::= ids DOT */ - 199, /* (19) cpxName ::= */ - 199, /* (20) cpxName ::= DOT ids */ - 196, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ - 196, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ - 196, /* (23) cmd ::= SHOW CREATE DATABASE ids */ - 196, /* (24) cmd ::= SHOW dbPrefix TABLES */ - 196, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - 196, /* (26) cmd ::= SHOW dbPrefix STABLES */ - 196, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - 196, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ - 196, /* (29) cmd ::= SHOW dbPrefix VGROUPS ids */ - 196, /* (30) cmd ::= DROP TABLE ifexists ids cpxName */ - 196, /* (31) cmd ::= DROP STABLE ifexists ids cpxName */ - 196, /* (32) cmd ::= DROP DATABASE ifexists ids */ - 196, /* (33) cmd ::= DROP TOPIC ifexists ids */ - 196, /* (34) cmd ::= DROP FUNCTION ids */ - 196, /* (35) cmd ::= DROP DNODE ids */ - 196, /* (36) cmd ::= DROP USER ids */ - 196, /* (37) cmd ::= DROP ACCOUNT ids */ - 196, /* (38) cmd ::= USE ids */ - 196, /* (39) cmd ::= DESCRIBE ids cpxName */ - 196, /* (40) cmd ::= ALTER USER ids PASS ids */ - 196, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ - 196, /* (42) cmd ::= ALTER DNODE ids ids */ - 196, /* (43) cmd ::= ALTER DNODE ids ids ids */ - 196, /* (44) cmd ::= ALTER LOCAL ids */ - 196, /* (45) cmd ::= ALTER LOCAL ids ids */ - 196, /* (46) cmd ::= ALTER DATABASE ids alter_db_optr */ - 196, /* (47) cmd ::= ALTER TOPIC ids alter_topic_optr */ - 196, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ - 196, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - 196, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ - 197, /* (51) ids ::= ID */ - 197, /* (52) ids ::= STRING */ - 200, /* (53) ifexists ::= IF EXISTS */ - 200, /* (54) ifexists ::= */ - 205, /* (55) ifnotexists ::= IF NOT EXISTS */ - 205, /* (56) ifnotexists ::= */ - 196, /* (57) cmd ::= CREATE DNODE ids */ - 196, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - 196, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - 196, /* (60) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - 196, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - 196, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - 196, /* (63) cmd ::= CREATE USER ids PASS ids */ - 209, /* (64) bufsize ::= */ - 209, /* (65) bufsize ::= BUFSIZE INTEGER */ - 210, /* (66) pps ::= */ - 210, /* (67) pps ::= PPS INTEGER */ - 211, /* (68) tseries ::= */ - 211, /* (69) tseries ::= TSERIES INTEGER */ - 212, /* (70) dbs ::= */ - 212, /* (71) dbs ::= DBS INTEGER */ - 213, /* (72) streams ::= */ - 213, /* (73) streams ::= STREAMS INTEGER */ - 214, /* (74) storage ::= */ - 214, /* (75) storage ::= STORAGE INTEGER */ - 215, /* (76) qtime ::= */ - 215, /* (77) qtime ::= QTIME INTEGER */ - 216, /* (78) users ::= */ - 216, /* (79) users ::= USERS INTEGER */ - 217, /* (80) conns ::= */ - 217, /* (81) conns ::= CONNS INTEGER */ - 218, /* (82) state ::= */ - 218, /* (83) state ::= STATE ids */ - 203, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - 219, /* (85) intitemlist ::= intitemlist COMMA intitem */ - 219, /* (86) intitemlist ::= intitem */ - 220, /* (87) intitem ::= INTEGER */ - 221, /* (88) keep ::= KEEP intitemlist */ - 222, /* (89) cache ::= CACHE INTEGER */ - 223, /* (90) replica ::= REPLICA INTEGER */ - 224, /* (91) quorum ::= QUORUM INTEGER */ - 225, /* (92) days ::= DAYS INTEGER */ - 226, /* (93) minrows ::= MINROWS INTEGER */ - 227, /* (94) maxrows ::= MAXROWS INTEGER */ - 228, /* (95) blocks ::= BLOCKS INTEGER */ - 229, /* (96) ctime ::= CTIME INTEGER */ - 230, /* (97) wal ::= WAL INTEGER */ - 231, /* (98) fsync ::= FSYNC INTEGER */ - 232, /* (99) comp ::= COMP INTEGER */ - 233, /* (100) prec ::= PRECISION STRING */ - 234, /* (101) update ::= UPDATE INTEGER */ - 235, /* (102) cachelast ::= CACHELAST INTEGER */ - 236, /* (103) partitions ::= PARTITIONS INTEGER */ - 206, /* (104) db_optr ::= */ - 206, /* (105) db_optr ::= db_optr cache */ - 206, /* (106) db_optr ::= db_optr replica */ - 206, /* (107) db_optr ::= db_optr quorum */ - 206, /* (108) db_optr ::= db_optr days */ - 206, /* (109) db_optr ::= db_optr minrows */ - 206, /* (110) db_optr ::= db_optr maxrows */ - 206, /* (111) db_optr ::= db_optr blocks */ - 206, /* (112) db_optr ::= db_optr ctime */ - 206, /* (113) db_optr ::= db_optr wal */ - 206, /* (114) db_optr ::= db_optr fsync */ - 206, /* (115) db_optr ::= db_optr comp */ - 206, /* (116) db_optr ::= db_optr prec */ - 206, /* (117) db_optr ::= db_optr keep */ - 206, /* (118) db_optr ::= db_optr update */ - 206, /* (119) db_optr ::= db_optr cachelast */ - 207, /* (120) topic_optr ::= db_optr */ - 207, /* (121) topic_optr ::= topic_optr partitions */ - 201, /* (122) alter_db_optr ::= */ - 201, /* (123) alter_db_optr ::= alter_db_optr replica */ - 201, /* (124) alter_db_optr ::= alter_db_optr quorum */ - 201, /* (125) alter_db_optr ::= alter_db_optr keep */ - 201, /* (126) alter_db_optr ::= alter_db_optr blocks */ - 201, /* (127) alter_db_optr ::= alter_db_optr comp */ - 201, /* (128) alter_db_optr ::= alter_db_optr update */ - 201, /* (129) alter_db_optr ::= alter_db_optr cachelast */ - 202, /* (130) alter_topic_optr ::= alter_db_optr */ - 202, /* (131) alter_topic_optr ::= alter_topic_optr partitions */ - 208, /* (132) typename ::= ids */ - 208, /* (133) typename ::= ids LP signed RP */ - 208, /* (134) typename ::= ids UNSIGNED */ - 237, /* (135) signed ::= INTEGER */ - 237, /* (136) signed ::= PLUS INTEGER */ - 237, /* (137) signed ::= MINUS INTEGER */ - 196, /* (138) cmd ::= CREATE TABLE create_table_args */ - 196, /* (139) cmd ::= CREATE TABLE create_stable_args */ - 196, /* (140) cmd ::= CREATE STABLE create_stable_args */ - 196, /* (141) cmd ::= CREATE TABLE create_table_list */ - 240, /* (142) create_table_list ::= create_from_stable */ - 240, /* (143) create_table_list ::= create_table_list create_from_stable */ - 238, /* (144) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - 239, /* (145) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - 241, /* (146) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - 241, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - 244, /* (148) tagNamelist ::= tagNamelist COMMA ids */ - 244, /* (149) tagNamelist ::= ids */ - 238, /* (150) create_table_args ::= ifnotexists ids cpxName AS select */ - 242, /* (151) columnlist ::= columnlist COMMA column */ - 242, /* (152) columnlist ::= column */ - 246, /* (153) column ::= ids typename */ - 243, /* (154) tagitemlist ::= tagitemlist COMMA tagitem */ - 243, /* (155) tagitemlist ::= tagitem */ - 247, /* (156) tagitem ::= INTEGER */ - 247, /* (157) tagitem ::= FLOAT */ - 247, /* (158) tagitem ::= STRING */ - 247, /* (159) tagitem ::= BOOL */ - 247, /* (160) tagitem ::= NULL */ - 247, /* (161) tagitem ::= NOW */ - 247, /* (162) tagitem ::= MINUS INTEGER */ - 247, /* (163) tagitem ::= MINUS FLOAT */ - 247, /* (164) tagitem ::= PLUS INTEGER */ - 247, /* (165) tagitem ::= PLUS FLOAT */ - 245, /* (166) select ::= SELECT selcollist from where_opt interval_opt sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - 245, /* (167) select ::= LP select RP */ - 261, /* (168) union ::= select */ - 261, /* (169) union ::= union UNION ALL select */ - 196, /* (170) cmd ::= union */ - 245, /* (171) select ::= SELECT selcollist */ - 262, /* (172) sclp ::= selcollist COMMA */ - 262, /* (173) sclp ::= */ - 248, /* (174) selcollist ::= sclp distinct expr as */ - 248, /* (175) selcollist ::= sclp STAR */ - 265, /* (176) as ::= AS ids */ - 265, /* (177) as ::= ids */ - 265, /* (178) as ::= */ - 263, /* (179) distinct ::= DISTINCT */ - 263, /* (180) distinct ::= */ - 249, /* (181) from ::= FROM tablelist */ - 249, /* (182) from ::= FROM sub */ - 267, /* (183) sub ::= LP union RP */ - 267, /* (184) sub ::= LP union RP ids */ - 267, /* (185) sub ::= sub COMMA LP union RP ids */ - 266, /* (186) tablelist ::= ids cpxName */ - 266, /* (187) tablelist ::= ids cpxName ids */ - 266, /* (188) tablelist ::= tablelist COMMA ids cpxName */ - 266, /* (189) tablelist ::= tablelist COMMA ids cpxName ids */ - 268, /* (190) tmvar ::= VARIABLE */ - 251, /* (191) interval_opt ::= INTERVAL LP tmvar RP */ - 251, /* (192) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 251, /* (193) interval_opt ::= */ - 253, /* (194) session_option ::= */ - 253, /* (195) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 254, /* (196) windowstate_option ::= */ - 254, /* (197) windowstate_option ::= STATE_WINDOW LP ids RP */ - 255, /* (198) fill_opt ::= */ - 255, /* (199) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - 255, /* (200) fill_opt ::= FILL LP ID RP */ - 252, /* (201) sliding_opt ::= SLIDING LP tmvar RP */ - 252, /* (202) sliding_opt ::= */ - 258, /* (203) orderby_opt ::= */ - 258, /* (204) orderby_opt ::= ORDER BY sortlist */ - 269, /* (205) sortlist ::= sortlist COMMA item sortorder */ - 269, /* (206) sortlist ::= item sortorder */ - 271, /* (207) item ::= ids cpxName */ - 272, /* (208) sortorder ::= ASC */ - 272, /* (209) sortorder ::= DESC */ - 272, /* (210) sortorder ::= */ - 256, /* (211) groupby_opt ::= */ - 256, /* (212) groupby_opt ::= GROUP BY grouplist */ - 273, /* (213) grouplist ::= grouplist COMMA item */ - 273, /* (214) grouplist ::= item */ - 257, /* (215) having_opt ::= */ - 257, /* (216) having_opt ::= HAVING expr */ - 260, /* (217) limit_opt ::= */ - 260, /* (218) limit_opt ::= LIMIT signed */ - 260, /* (219) limit_opt ::= LIMIT signed OFFSET signed */ - 260, /* (220) limit_opt ::= LIMIT signed COMMA signed */ - 259, /* (221) slimit_opt ::= */ - 259, /* (222) slimit_opt ::= SLIMIT signed */ - 259, /* (223) slimit_opt ::= SLIMIT signed SOFFSET signed */ - 259, /* (224) slimit_opt ::= SLIMIT signed COMMA signed */ - 250, /* (225) where_opt ::= */ - 250, /* (226) where_opt ::= WHERE expr */ - 264, /* (227) expr ::= LP expr RP */ - 264, /* (228) expr ::= ID */ - 264, /* (229) expr ::= ID DOT ID */ - 264, /* (230) expr ::= ID DOT STAR */ - 264, /* (231) expr ::= INTEGER */ - 264, /* (232) expr ::= MINUS INTEGER */ - 264, /* (233) expr ::= PLUS INTEGER */ - 264, /* (234) expr ::= FLOAT */ - 264, /* (235) expr ::= MINUS FLOAT */ - 264, /* (236) expr ::= PLUS FLOAT */ - 264, /* (237) expr ::= STRING */ - 264, /* (238) expr ::= NOW */ - 264, /* (239) expr ::= VARIABLE */ - 264, /* (240) expr ::= PLUS VARIABLE */ - 264, /* (241) expr ::= MINUS VARIABLE */ - 264, /* (242) expr ::= BOOL */ - 264, /* (243) expr ::= NULL */ - 264, /* (244) expr ::= ID LP exprlist RP */ - 264, /* (245) expr ::= ID LP STAR RP */ - 264, /* (246) expr ::= expr IS NULL */ - 264, /* (247) expr ::= expr IS NOT NULL */ - 264, /* (248) expr ::= expr LT expr */ - 264, /* (249) expr ::= expr GT expr */ - 264, /* (250) expr ::= expr LE expr */ - 264, /* (251) expr ::= expr GE expr */ - 264, /* (252) expr ::= expr NE expr */ - 264, /* (253) expr ::= expr EQ expr */ - 264, /* (254) expr ::= expr BETWEEN expr AND expr */ - 264, /* (255) expr ::= expr AND expr */ - 264, /* (256) expr ::= expr OR expr */ - 264, /* (257) expr ::= expr PLUS expr */ - 264, /* (258) expr ::= expr MINUS expr */ - 264, /* (259) expr ::= expr STAR expr */ - 264, /* (260) expr ::= expr SLASH expr */ - 264, /* (261) expr ::= expr REM expr */ - 264, /* (262) expr ::= expr LIKE expr */ - 264, /* (263) expr ::= expr IN LP exprlist RP */ - 204, /* (264) exprlist ::= exprlist COMMA expritem */ - 204, /* (265) exprlist ::= expritem */ - 274, /* (266) expritem ::= expr */ - 274, /* (267) expritem ::= */ - 196, /* (268) cmd ::= RESET QUERY CACHE */ - 196, /* (269) cmd ::= SYNCDB ids REPLICA */ - 196, /* (270) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - 196, /* (271) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - 196, /* (272) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - 196, /* (273) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - 196, /* (274) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - 196, /* (275) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - 196, /* (276) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - 196, /* (277) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - 196, /* (278) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - 196, /* (279) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - 196, /* (280) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - 196, /* (281) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - 196, /* (282) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - 196, /* (283) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - 196, /* (284) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - 196, /* (285) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - 196, /* (286) cmd ::= KILL CONNECTION INTEGER */ - 196, /* (287) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - 196, /* (288) cmd ::= KILL QUERY INTEGER COLON INTEGER */ -}; - -/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number -** of symbols on the right-hand side of that rule. */ -static const signed char yyRuleInfoNRhs[] = { - -1, /* (0) program ::= cmd */ - -2, /* (1) cmd ::= SHOW DATABASES */ - -2, /* (2) cmd ::= SHOW TOPICS */ - -2, /* (3) cmd ::= SHOW FUNCTIONS */ - -2, /* (4) cmd ::= SHOW MNODES */ - -2, /* (5) cmd ::= SHOW DNODES */ - -2, /* (6) cmd ::= SHOW ACCOUNTS */ - -2, /* (7) cmd ::= SHOW USERS */ - -2, /* (8) cmd ::= SHOW MODULES */ - -2, /* (9) cmd ::= SHOW QUERIES */ - -2, /* (10) cmd ::= SHOW CONNECTIONS */ - -2, /* (11) cmd ::= SHOW STREAMS */ - -2, /* (12) cmd ::= SHOW VARIABLES */ - -2, /* (13) cmd ::= SHOW SCORES */ - -2, /* (14) cmd ::= SHOW GRANTS */ - -2, /* (15) cmd ::= SHOW VNODES */ - -3, /* (16) cmd ::= SHOW VNODES ids */ - 0, /* (17) dbPrefix ::= */ - -2, /* (18) dbPrefix ::= ids DOT */ - 0, /* (19) cpxName ::= */ - -2, /* (20) cpxName ::= DOT ids */ - -5, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ - -5, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ - -4, /* (23) cmd ::= SHOW CREATE DATABASE ids */ - -3, /* (24) cmd ::= SHOW dbPrefix TABLES */ - -5, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - -3, /* (26) cmd ::= SHOW dbPrefix STABLES */ - -5, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - -3, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ - -4, /* (29) cmd ::= SHOW dbPrefix VGROUPS ids */ - -5, /* (30) cmd ::= DROP TABLE ifexists ids cpxName */ - -5, /* (31) cmd ::= DROP STABLE ifexists ids cpxName */ - -4, /* (32) cmd ::= DROP DATABASE ifexists ids */ - -4, /* (33) cmd ::= DROP TOPIC ifexists ids */ - -3, /* (34) cmd ::= DROP FUNCTION ids */ - -3, /* (35) cmd ::= DROP DNODE ids */ - -3, /* (36) cmd ::= DROP USER ids */ - -3, /* (37) cmd ::= DROP ACCOUNT ids */ - -2, /* (38) cmd ::= USE ids */ - -3, /* (39) cmd ::= DESCRIBE ids cpxName */ - -5, /* (40) cmd ::= ALTER USER ids PASS ids */ - -5, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ - -4, /* (42) cmd ::= ALTER DNODE ids ids */ - -5, /* (43) cmd ::= ALTER DNODE ids ids ids */ - -3, /* (44) cmd ::= ALTER LOCAL ids */ - -4, /* (45) cmd ::= ALTER LOCAL ids ids */ - -4, /* (46) cmd ::= ALTER DATABASE ids alter_db_optr */ - -4, /* (47) cmd ::= ALTER TOPIC ids alter_topic_optr */ - -4, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ - -6, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - -6, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ - -1, /* (51) ids ::= ID */ - -1, /* (52) ids ::= STRING */ - -2, /* (53) ifexists ::= IF EXISTS */ - 0, /* (54) ifexists ::= */ - -3, /* (55) ifnotexists ::= IF NOT EXISTS */ - 0, /* (56) ifnotexists ::= */ - -3, /* (57) cmd ::= CREATE DNODE ids */ - -6, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - -5, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - -5, /* (60) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - -8, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - -9, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - -5, /* (63) cmd ::= CREATE USER ids PASS ids */ - 0, /* (64) bufsize ::= */ - -2, /* (65) bufsize ::= BUFSIZE INTEGER */ - 0, /* (66) pps ::= */ - -2, /* (67) pps ::= PPS INTEGER */ - 0, /* (68) tseries ::= */ - -2, /* (69) tseries ::= TSERIES INTEGER */ - 0, /* (70) dbs ::= */ - -2, /* (71) dbs ::= DBS INTEGER */ - 0, /* (72) streams ::= */ - -2, /* (73) streams ::= STREAMS INTEGER */ - 0, /* (74) storage ::= */ - -2, /* (75) storage ::= STORAGE INTEGER */ - 0, /* (76) qtime ::= */ - -2, /* (77) qtime ::= QTIME INTEGER */ - 0, /* (78) users ::= */ - -2, /* (79) users ::= USERS INTEGER */ - 0, /* (80) conns ::= */ - -2, /* (81) conns ::= CONNS INTEGER */ - 0, /* (82) state ::= */ - -2, /* (83) state ::= STATE ids */ - -9, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - -3, /* (85) intitemlist ::= intitemlist COMMA intitem */ - -1, /* (86) intitemlist ::= intitem */ - -1, /* (87) intitem ::= INTEGER */ - -2, /* (88) keep ::= KEEP intitemlist */ - -2, /* (89) cache ::= CACHE INTEGER */ - -2, /* (90) replica ::= REPLICA INTEGER */ - -2, /* (91) quorum ::= QUORUM INTEGER */ - -2, /* (92) days ::= DAYS INTEGER */ - -2, /* (93) minrows ::= MINROWS INTEGER */ - -2, /* (94) maxrows ::= MAXROWS INTEGER */ - -2, /* (95) blocks ::= BLOCKS INTEGER */ - -2, /* (96) ctime ::= CTIME INTEGER */ - -2, /* (97) wal ::= WAL INTEGER */ - -2, /* (98) fsync ::= FSYNC INTEGER */ - -2, /* (99) comp ::= COMP INTEGER */ - -2, /* (100) prec ::= PRECISION STRING */ - -2, /* (101) update ::= UPDATE INTEGER */ - -2, /* (102) cachelast ::= CACHELAST INTEGER */ - -2, /* (103) partitions ::= PARTITIONS INTEGER */ - 0, /* (104) db_optr ::= */ - -2, /* (105) db_optr ::= db_optr cache */ - -2, /* (106) db_optr ::= db_optr replica */ - -2, /* (107) db_optr ::= db_optr quorum */ - -2, /* (108) db_optr ::= db_optr days */ - -2, /* (109) db_optr ::= db_optr minrows */ - -2, /* (110) db_optr ::= db_optr maxrows */ - -2, /* (111) db_optr ::= db_optr blocks */ - -2, /* (112) db_optr ::= db_optr ctime */ - -2, /* (113) db_optr ::= db_optr wal */ - -2, /* (114) db_optr ::= db_optr fsync */ - -2, /* (115) db_optr ::= db_optr comp */ - -2, /* (116) db_optr ::= db_optr prec */ - -2, /* (117) db_optr ::= db_optr keep */ - -2, /* (118) db_optr ::= db_optr update */ - -2, /* (119) db_optr ::= db_optr cachelast */ - -1, /* (120) topic_optr ::= db_optr */ - -2, /* (121) topic_optr ::= topic_optr partitions */ - 0, /* (122) alter_db_optr ::= */ - -2, /* (123) alter_db_optr ::= alter_db_optr replica */ - -2, /* (124) alter_db_optr ::= alter_db_optr quorum */ - -2, /* (125) alter_db_optr ::= alter_db_optr keep */ - -2, /* (126) alter_db_optr ::= alter_db_optr blocks */ - -2, /* (127) alter_db_optr ::= alter_db_optr comp */ - -2, /* (128) alter_db_optr ::= alter_db_optr update */ - -2, /* (129) alter_db_optr ::= alter_db_optr cachelast */ - -1, /* (130) alter_topic_optr ::= alter_db_optr */ - -2, /* (131) alter_topic_optr ::= alter_topic_optr partitions */ - -1, /* (132) typename ::= ids */ - -4, /* (133) typename ::= ids LP signed RP */ - -2, /* (134) typename ::= ids UNSIGNED */ - -1, /* (135) signed ::= INTEGER */ - -2, /* (136) signed ::= PLUS INTEGER */ - -2, /* (137) signed ::= MINUS INTEGER */ - -3, /* (138) cmd ::= CREATE TABLE create_table_args */ - -3, /* (139) cmd ::= CREATE TABLE create_stable_args */ - -3, /* (140) cmd ::= CREATE STABLE create_stable_args */ - -3, /* (141) cmd ::= CREATE TABLE create_table_list */ - -1, /* (142) create_table_list ::= create_from_stable */ - -2, /* (143) create_table_list ::= create_table_list create_from_stable */ - -6, /* (144) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - -10, /* (145) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - -10, /* (146) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - -13, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - -3, /* (148) tagNamelist ::= tagNamelist COMMA ids */ - -1, /* (149) tagNamelist ::= ids */ - -5, /* (150) create_table_args ::= ifnotexists ids cpxName AS select */ - -3, /* (151) columnlist ::= columnlist COMMA column */ - -1, /* (152) columnlist ::= column */ - -2, /* (153) column ::= ids typename */ - -3, /* (154) tagitemlist ::= tagitemlist COMMA tagitem */ - -1, /* (155) tagitemlist ::= tagitem */ - -1, /* (156) tagitem ::= INTEGER */ - -1, /* (157) tagitem ::= FLOAT */ - -1, /* (158) tagitem ::= STRING */ - -1, /* (159) tagitem ::= BOOL */ - -1, /* (160) tagitem ::= NULL */ - -1, /* (161) tagitem ::= NOW */ - -2, /* (162) tagitem ::= MINUS INTEGER */ - -2, /* (163) tagitem ::= MINUS FLOAT */ - -2, /* (164) tagitem ::= PLUS INTEGER */ - -2, /* (165) tagitem ::= PLUS FLOAT */ - -14, /* (166) select ::= SELECT selcollist from where_opt interval_opt sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - -3, /* (167) select ::= LP select RP */ - -1, /* (168) union ::= select */ - -4, /* (169) union ::= union UNION ALL select */ - -1, /* (170) cmd ::= union */ - -2, /* (171) select ::= SELECT selcollist */ - -2, /* (172) sclp ::= selcollist COMMA */ - 0, /* (173) sclp ::= */ - -4, /* (174) selcollist ::= sclp distinct expr as */ - -2, /* (175) selcollist ::= sclp STAR */ - -2, /* (176) as ::= AS ids */ - -1, /* (177) as ::= ids */ - 0, /* (178) as ::= */ - -1, /* (179) distinct ::= DISTINCT */ - 0, /* (180) distinct ::= */ - -2, /* (181) from ::= FROM tablelist */ - -2, /* (182) from ::= FROM sub */ - -3, /* (183) sub ::= LP union RP */ - -4, /* (184) sub ::= LP union RP ids */ - -6, /* (185) sub ::= sub COMMA LP union RP ids */ - -2, /* (186) tablelist ::= ids cpxName */ - -3, /* (187) tablelist ::= ids cpxName ids */ - -4, /* (188) tablelist ::= tablelist COMMA ids cpxName */ - -5, /* (189) tablelist ::= tablelist COMMA ids cpxName ids */ - -1, /* (190) tmvar ::= VARIABLE */ - -4, /* (191) interval_opt ::= INTERVAL LP tmvar RP */ - -6, /* (192) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - 0, /* (193) interval_opt ::= */ - 0, /* (194) session_option ::= */ - -7, /* (195) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 0, /* (196) windowstate_option ::= */ - -4, /* (197) windowstate_option ::= STATE_WINDOW LP ids RP */ - 0, /* (198) fill_opt ::= */ - -6, /* (199) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - -4, /* (200) fill_opt ::= FILL LP ID RP */ - -4, /* (201) sliding_opt ::= SLIDING LP tmvar RP */ - 0, /* (202) sliding_opt ::= */ - 0, /* (203) orderby_opt ::= */ - -3, /* (204) orderby_opt ::= ORDER BY sortlist */ - -4, /* (205) sortlist ::= sortlist COMMA item sortorder */ - -2, /* (206) sortlist ::= item sortorder */ - -2, /* (207) item ::= ids cpxName */ - -1, /* (208) sortorder ::= ASC */ - -1, /* (209) sortorder ::= DESC */ - 0, /* (210) sortorder ::= */ - 0, /* (211) groupby_opt ::= */ - -3, /* (212) groupby_opt ::= GROUP BY grouplist */ - -3, /* (213) grouplist ::= grouplist COMMA item */ - -1, /* (214) grouplist ::= item */ - 0, /* (215) having_opt ::= */ - -2, /* (216) having_opt ::= HAVING expr */ - 0, /* (217) limit_opt ::= */ - -2, /* (218) limit_opt ::= LIMIT signed */ - -4, /* (219) limit_opt ::= LIMIT signed OFFSET signed */ - -4, /* (220) limit_opt ::= LIMIT signed COMMA signed */ - 0, /* (221) slimit_opt ::= */ - -2, /* (222) slimit_opt ::= SLIMIT signed */ - -4, /* (223) slimit_opt ::= SLIMIT signed SOFFSET signed */ - -4, /* (224) slimit_opt ::= SLIMIT signed COMMA signed */ - 0, /* (225) where_opt ::= */ - -2, /* (226) where_opt ::= WHERE expr */ - -3, /* (227) expr ::= LP expr RP */ - -1, /* (228) expr ::= ID */ - -3, /* (229) expr ::= ID DOT ID */ - -3, /* (230) expr ::= ID DOT STAR */ - -1, /* (231) expr ::= INTEGER */ - -2, /* (232) expr ::= MINUS INTEGER */ - -2, /* (233) expr ::= PLUS INTEGER */ - -1, /* (234) expr ::= FLOAT */ - -2, /* (235) expr ::= MINUS FLOAT */ - -2, /* (236) expr ::= PLUS FLOAT */ - -1, /* (237) expr ::= STRING */ - -1, /* (238) expr ::= NOW */ - -1, /* (239) expr ::= VARIABLE */ - -2, /* (240) expr ::= PLUS VARIABLE */ - -2, /* (241) expr ::= MINUS VARIABLE */ - -1, /* (242) expr ::= BOOL */ - -1, /* (243) expr ::= NULL */ - -4, /* (244) expr ::= ID LP exprlist RP */ - -4, /* (245) expr ::= ID LP STAR RP */ - -3, /* (246) expr ::= expr IS NULL */ - -4, /* (247) expr ::= expr IS NOT NULL */ - -3, /* (248) expr ::= expr LT expr */ - -3, /* (249) expr ::= expr GT expr */ - -3, /* (250) expr ::= expr LE expr */ - -3, /* (251) expr ::= expr GE expr */ - -3, /* (252) expr ::= expr NE expr */ - -3, /* (253) expr ::= expr EQ expr */ - -5, /* (254) expr ::= expr BETWEEN expr AND expr */ - -3, /* (255) expr ::= expr AND expr */ - -3, /* (256) expr ::= expr OR expr */ - -3, /* (257) expr ::= expr PLUS expr */ - -3, /* (258) expr ::= expr MINUS expr */ - -3, /* (259) expr ::= expr STAR expr */ - -3, /* (260) expr ::= expr SLASH expr */ - -3, /* (261) expr ::= expr REM expr */ - -3, /* (262) expr ::= expr LIKE expr */ - -5, /* (263) expr ::= expr IN LP exprlist RP */ - -3, /* (264) exprlist ::= exprlist COMMA expritem */ - -1, /* (265) exprlist ::= expritem */ - -1, /* (266) expritem ::= expr */ - 0, /* (267) expritem ::= */ - -3, /* (268) cmd ::= RESET QUERY CACHE */ - -3, /* (269) cmd ::= SYNCDB ids REPLICA */ - -7, /* (270) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (271) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - -7, /* (272) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (273) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - -7, /* (274) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - -8, /* (275) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (276) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (277) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - -7, /* (278) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (279) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - -7, /* (280) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (281) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - -7, /* (282) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - -8, /* (283) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (284) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (285) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - -3, /* (286) cmd ::= KILL CONNECTION INTEGER */ - -5, /* (287) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - -5, /* (288) cmd ::= KILL QUERY INTEGER COLON INTEGER */ +/* The following table contains information about every rule that +** is used during the reduce. +*/ +static const struct { + YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + signed char nrhs; /* Negative of the number of RHS symbols in the rule */ +} yyRuleInfo[] = { + { 197, -1 }, /* (0) program ::= cmd */ + { 198, -2 }, /* (1) cmd ::= SHOW DATABASES */ + { 198, -2 }, /* (2) cmd ::= SHOW TOPICS */ + { 198, -2 }, /* (3) cmd ::= SHOW FUNCTIONS */ + { 198, -2 }, /* (4) cmd ::= SHOW MNODES */ + { 198, -2 }, /* (5) cmd ::= SHOW DNODES */ + { 198, -2 }, /* (6) cmd ::= SHOW ACCOUNTS */ + { 198, -2 }, /* (7) cmd ::= SHOW USERS */ + { 198, -2 }, /* (8) cmd ::= SHOW MODULES */ + { 198, -2 }, /* (9) cmd ::= SHOW QUERIES */ + { 198, -2 }, /* (10) cmd ::= SHOW CONNECTIONS */ + { 198, -2 }, /* (11) cmd ::= SHOW STREAMS */ + { 198, -2 }, /* (12) cmd ::= SHOW VARIABLES */ + { 198, -2 }, /* (13) cmd ::= SHOW SCORES */ + { 198, -2 }, /* (14) cmd ::= SHOW GRANTS */ + { 198, -2 }, /* (15) cmd ::= SHOW VNODES */ + { 198, -3 }, /* (16) cmd ::= SHOW VNODES ids */ + { 200, 0 }, /* (17) dbPrefix ::= */ + { 200, -2 }, /* (18) dbPrefix ::= ids DOT */ + { 201, 0 }, /* (19) cpxName ::= */ + { 201, -2 }, /* (20) cpxName ::= DOT ids */ + { 198, -5 }, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ + { 198, -5 }, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ + { 198, -4 }, /* (23) cmd ::= SHOW CREATE DATABASE ids */ + { 198, -3 }, /* (24) cmd ::= SHOW dbPrefix TABLES */ + { 198, -5 }, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ + { 198, -3 }, /* (26) cmd ::= SHOW dbPrefix STABLES */ + { 198, -5 }, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ + { 198, -3 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ + { 198, -4 }, /* (29) cmd ::= SHOW dbPrefix VGROUPS ids */ + { 198, -5 }, /* (30) cmd ::= DROP TABLE ifexists ids cpxName */ + { 198, -5 }, /* (31) cmd ::= DROP STABLE ifexists ids cpxName */ + { 198, -4 }, /* (32) cmd ::= DROP DATABASE ifexists ids */ + { 198, -4 }, /* (33) cmd ::= DROP TOPIC ifexists ids */ + { 198, -3 }, /* (34) cmd ::= DROP FUNCTION ids */ + { 198, -3 }, /* (35) cmd ::= DROP DNODE ids */ + { 198, -3 }, /* (36) cmd ::= DROP USER ids */ + { 198, -3 }, /* (37) cmd ::= DROP ACCOUNT ids */ + { 198, -2 }, /* (38) cmd ::= USE ids */ + { 198, -3 }, /* (39) cmd ::= DESCRIBE ids cpxName */ + { 198, -3 }, /* (40) cmd ::= DESC ids cpxName */ + { 198, -5 }, /* (41) cmd ::= ALTER USER ids PASS ids */ + { 198, -5 }, /* (42) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 198, -4 }, /* (43) cmd ::= ALTER DNODE ids ids */ + { 198, -5 }, /* (44) cmd ::= ALTER DNODE ids ids ids */ + { 198, -3 }, /* (45) cmd ::= ALTER LOCAL ids */ + { 198, -4 }, /* (46) cmd ::= ALTER LOCAL ids ids */ + { 198, -4 }, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 198, -4 }, /* (48) cmd ::= ALTER TOPIC ids alter_topic_optr */ + { 198, -4 }, /* (49) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 198, -6 }, /* (50) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 198, -6 }, /* (51) cmd ::= COMPACT VNODES IN LP exprlist RP */ + { 199, -1 }, /* (52) ids ::= ID */ + { 199, -1 }, /* (53) ids ::= STRING */ + { 202, -2 }, /* (54) ifexists ::= IF EXISTS */ + { 202, 0 }, /* (55) ifexists ::= */ + { 207, -3 }, /* (56) ifnotexists ::= IF NOT EXISTS */ + { 207, 0 }, /* (57) ifnotexists ::= */ + { 198, -3 }, /* (58) cmd ::= CREATE DNODE ids */ + { 198, -6 }, /* (59) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 198, -5 }, /* (60) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 198, -5 }, /* (61) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ + { 198, -8 }, /* (62) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + { 198, -9 }, /* (63) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + { 198, -5 }, /* (64) cmd ::= CREATE USER ids PASS ids */ + { 211, 0 }, /* (65) bufsize ::= */ + { 211, -2 }, /* (66) bufsize ::= BUFSIZE INTEGER */ + { 212, 0 }, /* (67) pps ::= */ + { 212, -2 }, /* (68) pps ::= PPS INTEGER */ + { 213, 0 }, /* (69) tseries ::= */ + { 213, -2 }, /* (70) tseries ::= TSERIES INTEGER */ + { 214, 0 }, /* (71) dbs ::= */ + { 214, -2 }, /* (72) dbs ::= DBS INTEGER */ + { 215, 0 }, /* (73) streams ::= */ + { 215, -2 }, /* (74) streams ::= STREAMS INTEGER */ + { 216, 0 }, /* (75) storage ::= */ + { 216, -2 }, /* (76) storage ::= STORAGE INTEGER */ + { 217, 0 }, /* (77) qtime ::= */ + { 217, -2 }, /* (78) qtime ::= QTIME INTEGER */ + { 218, 0 }, /* (79) users ::= */ + { 218, -2 }, /* (80) users ::= USERS INTEGER */ + { 219, 0 }, /* (81) conns ::= */ + { 219, -2 }, /* (82) conns ::= CONNS INTEGER */ + { 220, 0 }, /* (83) state ::= */ + { 220, -2 }, /* (84) state ::= STATE ids */ + { 205, -9 }, /* (85) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 221, -3 }, /* (86) intitemlist ::= intitemlist COMMA intitem */ + { 221, -1 }, /* (87) intitemlist ::= intitem */ + { 222, -1 }, /* (88) intitem ::= INTEGER */ + { 223, -2 }, /* (89) keep ::= KEEP intitemlist */ + { 224, -2 }, /* (90) cache ::= CACHE INTEGER */ + { 225, -2 }, /* (91) replica ::= REPLICA INTEGER */ + { 226, -2 }, /* (92) quorum ::= QUORUM INTEGER */ + { 227, -2 }, /* (93) days ::= DAYS INTEGER */ + { 228, -2 }, /* (94) minrows ::= MINROWS INTEGER */ + { 229, -2 }, /* (95) maxrows ::= MAXROWS INTEGER */ + { 230, -2 }, /* (96) blocks ::= BLOCKS INTEGER */ + { 231, -2 }, /* (97) ctime ::= CTIME INTEGER */ + { 232, -2 }, /* (98) wal ::= WAL INTEGER */ + { 233, -2 }, /* (99) fsync ::= FSYNC INTEGER */ + { 234, -2 }, /* (100) comp ::= COMP INTEGER */ + { 235, -2 }, /* (101) prec ::= PRECISION STRING */ + { 236, -2 }, /* (102) update ::= UPDATE INTEGER */ + { 237, -2 }, /* (103) cachelast ::= CACHELAST INTEGER */ + { 238, -2 }, /* (104) partitions ::= PARTITIONS INTEGER */ + { 208, 0 }, /* (105) db_optr ::= */ + { 208, -2 }, /* (106) db_optr ::= db_optr cache */ + { 208, -2 }, /* (107) db_optr ::= db_optr replica */ + { 208, -2 }, /* (108) db_optr ::= db_optr quorum */ + { 208, -2 }, /* (109) db_optr ::= db_optr days */ + { 208, -2 }, /* (110) db_optr ::= db_optr minrows */ + { 208, -2 }, /* (111) db_optr ::= db_optr maxrows */ + { 208, -2 }, /* (112) db_optr ::= db_optr blocks */ + { 208, -2 }, /* (113) db_optr ::= db_optr ctime */ + { 208, -2 }, /* (114) db_optr ::= db_optr wal */ + { 208, -2 }, /* (115) db_optr ::= db_optr fsync */ + { 208, -2 }, /* (116) db_optr ::= db_optr comp */ + { 208, -2 }, /* (117) db_optr ::= db_optr prec */ + { 208, -2 }, /* (118) db_optr ::= db_optr keep */ + { 208, -2 }, /* (119) db_optr ::= db_optr update */ + { 208, -2 }, /* (120) db_optr ::= db_optr cachelast */ + { 209, -1 }, /* (121) topic_optr ::= db_optr */ + { 209, -2 }, /* (122) topic_optr ::= topic_optr partitions */ + { 203, 0 }, /* (123) alter_db_optr ::= */ + { 203, -2 }, /* (124) alter_db_optr ::= alter_db_optr replica */ + { 203, -2 }, /* (125) alter_db_optr ::= alter_db_optr quorum */ + { 203, -2 }, /* (126) alter_db_optr ::= alter_db_optr keep */ + { 203, -2 }, /* (127) alter_db_optr ::= alter_db_optr blocks */ + { 203, -2 }, /* (128) alter_db_optr ::= alter_db_optr comp */ + { 203, -2 }, /* (129) alter_db_optr ::= alter_db_optr update */ + { 203, -2 }, /* (130) alter_db_optr ::= alter_db_optr cachelast */ + { 204, -1 }, /* (131) alter_topic_optr ::= alter_db_optr */ + { 204, -2 }, /* (132) alter_topic_optr ::= alter_topic_optr partitions */ + { 210, -1 }, /* (133) typename ::= ids */ + { 210, -4 }, /* (134) typename ::= ids LP signed RP */ + { 210, -2 }, /* (135) typename ::= ids UNSIGNED */ + { 239, -1 }, /* (136) signed ::= INTEGER */ + { 239, -2 }, /* (137) signed ::= PLUS INTEGER */ + { 239, -2 }, /* (138) signed ::= MINUS INTEGER */ + { 198, -3 }, /* (139) cmd ::= CREATE TABLE create_table_args */ + { 198, -3 }, /* (140) cmd ::= CREATE TABLE create_stable_args */ + { 198, -3 }, /* (141) cmd ::= CREATE STABLE create_stable_args */ + { 198, -3 }, /* (142) cmd ::= CREATE TABLE create_table_list */ + { 242, -1 }, /* (143) create_table_list ::= create_from_stable */ + { 242, -2 }, /* (144) create_table_list ::= create_table_list create_from_stable */ + { 240, -6 }, /* (145) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 241, -10 }, /* (146) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 243, -10 }, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + { 243, -13 }, /* (148) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + { 246, -3 }, /* (149) tagNamelist ::= tagNamelist COMMA ids */ + { 246, -1 }, /* (150) tagNamelist ::= ids */ + { 240, -5 }, /* (151) create_table_args ::= ifnotexists ids cpxName AS select */ + { 244, -3 }, /* (152) columnlist ::= columnlist COMMA column */ + { 244, -1 }, /* (153) columnlist ::= column */ + { 248, -2 }, /* (154) column ::= ids typename */ + { 245, -3 }, /* (155) tagitemlist ::= tagitemlist COMMA tagitem */ + { 245, -1 }, /* (156) tagitemlist ::= tagitem */ + { 249, -1 }, /* (157) tagitem ::= INTEGER */ + { 249, -1 }, /* (158) tagitem ::= FLOAT */ + { 249, -1 }, /* (159) tagitem ::= STRING */ + { 249, -1 }, /* (160) tagitem ::= BOOL */ + { 249, -1 }, /* (161) tagitem ::= NULL */ + { 249, -1 }, /* (162) tagitem ::= NOW */ + { 249, -2 }, /* (163) tagitem ::= MINUS INTEGER */ + { 249, -2 }, /* (164) tagitem ::= MINUS FLOAT */ + { 249, -2 }, /* (165) tagitem ::= PLUS INTEGER */ + { 249, -2 }, /* (166) tagitem ::= PLUS FLOAT */ + { 247, -14 }, /* (167) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + { 247, -3 }, /* (168) select ::= LP select RP */ + { 263, -1 }, /* (169) union ::= select */ + { 263, -4 }, /* (170) union ::= union UNION ALL select */ + { 198, -1 }, /* (171) cmd ::= union */ + { 247, -2 }, /* (172) select ::= SELECT selcollist */ + { 264, -2 }, /* (173) sclp ::= selcollist COMMA */ + { 264, 0 }, /* (174) sclp ::= */ + { 250, -4 }, /* (175) selcollist ::= sclp distinct expr as */ + { 250, -2 }, /* (176) selcollist ::= sclp STAR */ + { 267, -2 }, /* (177) as ::= AS ids */ + { 267, -1 }, /* (178) as ::= ids */ + { 267, 0 }, /* (179) as ::= */ + { 265, -1 }, /* (180) distinct ::= DISTINCT */ + { 265, 0 }, /* (181) distinct ::= */ + { 251, -2 }, /* (182) from ::= FROM tablelist */ + { 251, -2 }, /* (183) from ::= FROM sub */ + { 269, -3 }, /* (184) sub ::= LP union RP */ + { 269, -4 }, /* (185) sub ::= LP union RP ids */ + { 269, -6 }, /* (186) sub ::= sub COMMA LP union RP ids */ + { 268, -2 }, /* (187) tablelist ::= ids cpxName */ + { 268, -3 }, /* (188) tablelist ::= ids cpxName ids */ + { 268, -4 }, /* (189) tablelist ::= tablelist COMMA ids cpxName */ + { 268, -5 }, /* (190) tablelist ::= tablelist COMMA ids cpxName ids */ + { 270, -1 }, /* (191) tmvar ::= VARIABLE */ + { 253, -4 }, /* (192) interval_option ::= intervalKey LP tmvar RP */ + { 253, -6 }, /* (193) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + { 253, 0 }, /* (194) interval_option ::= */ + { 271, -1 }, /* (195) intervalKey ::= INTERVAL */ + { 271, -1 }, /* (196) intervalKey ::= EVERY */ + { 255, 0 }, /* (197) session_option ::= */ + { 255, -7 }, /* (198) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 256, 0 }, /* (199) windowstate_option ::= */ + { 256, -4 }, /* (200) windowstate_option ::= STATE_WINDOW LP ids RP */ + { 257, 0 }, /* (201) fill_opt ::= */ + { 257, -6 }, /* (202) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 257, -4 }, /* (203) fill_opt ::= FILL LP ID RP */ + { 254, -4 }, /* (204) sliding_opt ::= SLIDING LP tmvar RP */ + { 254, 0 }, /* (205) sliding_opt ::= */ + { 260, 0 }, /* (206) orderby_opt ::= */ + { 260, -3 }, /* (207) orderby_opt ::= ORDER BY sortlist */ + { 272, -4 }, /* (208) sortlist ::= sortlist COMMA item sortorder */ + { 272, -2 }, /* (209) sortlist ::= item sortorder */ + { 274, -2 }, /* (210) item ::= ids cpxName */ + { 275, -1 }, /* (211) sortorder ::= ASC */ + { 275, -1 }, /* (212) sortorder ::= DESC */ + { 275, 0 }, /* (213) sortorder ::= */ + { 258, 0 }, /* (214) groupby_opt ::= */ + { 258, -3 }, /* (215) groupby_opt ::= GROUP BY grouplist */ + { 276, -3 }, /* (216) grouplist ::= grouplist COMMA item */ + { 276, -1 }, /* (217) grouplist ::= item */ + { 259, 0 }, /* (218) having_opt ::= */ + { 259, -2 }, /* (219) having_opt ::= HAVING expr */ + { 262, 0 }, /* (220) limit_opt ::= */ + { 262, -2 }, /* (221) limit_opt ::= LIMIT signed */ + { 262, -4 }, /* (222) limit_opt ::= LIMIT signed OFFSET signed */ + { 262, -4 }, /* (223) limit_opt ::= LIMIT signed COMMA signed */ + { 261, 0 }, /* (224) slimit_opt ::= */ + { 261, -2 }, /* (225) slimit_opt ::= SLIMIT signed */ + { 261, -4 }, /* (226) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 261, -4 }, /* (227) slimit_opt ::= SLIMIT signed COMMA signed */ + { 252, 0 }, /* (228) where_opt ::= */ + { 252, -2 }, /* (229) where_opt ::= WHERE expr */ + { 266, -3 }, /* (230) expr ::= LP expr RP */ + { 266, -1 }, /* (231) expr ::= ID */ + { 266, -3 }, /* (232) expr ::= ID DOT ID */ + { 266, -3 }, /* (233) expr ::= ID DOT STAR */ + { 266, -1 }, /* (234) expr ::= INTEGER */ + { 266, -2 }, /* (235) expr ::= MINUS INTEGER */ + { 266, -2 }, /* (236) expr ::= PLUS INTEGER */ + { 266, -1 }, /* (237) expr ::= FLOAT */ + { 266, -2 }, /* (238) expr ::= MINUS FLOAT */ + { 266, -2 }, /* (239) expr ::= PLUS FLOAT */ + { 266, -1 }, /* (240) expr ::= STRING */ + { 266, -1 }, /* (241) expr ::= NOW */ + { 266, -1 }, /* (242) expr ::= VARIABLE */ + { 266, -2 }, /* (243) expr ::= PLUS VARIABLE */ + { 266, -2 }, /* (244) expr ::= MINUS VARIABLE */ + { 266, -1 }, /* (245) expr ::= BOOL */ + { 266, -1 }, /* (246) expr ::= NULL */ + { 266, -4 }, /* (247) expr ::= ID LP exprlist RP */ + { 266, -4 }, /* (248) expr ::= ID LP STAR RP */ + { 266, -3 }, /* (249) expr ::= expr IS NULL */ + { 266, -4 }, /* (250) expr ::= expr IS NOT NULL */ + { 266, -3 }, /* (251) expr ::= expr LT expr */ + { 266, -3 }, /* (252) expr ::= expr GT expr */ + { 266, -3 }, /* (253) expr ::= expr LE expr */ + { 266, -3 }, /* (254) expr ::= expr GE expr */ + { 266, -3 }, /* (255) expr ::= expr NE expr */ + { 266, -3 }, /* (256) expr ::= expr EQ expr */ + { 266, -5 }, /* (257) expr ::= expr BETWEEN expr AND expr */ + { 266, -3 }, /* (258) expr ::= expr AND expr */ + { 266, -3 }, /* (259) expr ::= expr OR expr */ + { 266, -3 }, /* (260) expr ::= expr PLUS expr */ + { 266, -3 }, /* (261) expr ::= expr MINUS expr */ + { 266, -3 }, /* (262) expr ::= expr STAR expr */ + { 266, -3 }, /* (263) expr ::= expr SLASH expr */ + { 266, -3 }, /* (264) expr ::= expr REM expr */ + { 266, -3 }, /* (265) expr ::= expr LIKE expr */ + { 266, -5 }, /* (266) expr ::= expr IN LP exprlist RP */ + { 206, -3 }, /* (267) exprlist ::= exprlist COMMA expritem */ + { 206, -1 }, /* (268) exprlist ::= expritem */ + { 277, -1 }, /* (269) expritem ::= expr */ + { 277, 0 }, /* (270) expritem ::= */ + { 198, -3 }, /* (271) cmd ::= RESET QUERY CACHE */ + { 198, -3 }, /* (272) cmd ::= SYNCDB ids REPLICA */ + { 198, -7 }, /* (273) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 198, -7 }, /* (274) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 198, -7 }, /* (275) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + { 198, -7 }, /* (276) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 198, -7 }, /* (277) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 198, -8 }, /* (278) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 198, -9 }, /* (279) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 198, -7 }, /* (280) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + { 198, -7 }, /* (281) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 198, -7 }, /* (282) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 198, -7 }, /* (283) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + { 198, -7 }, /* (284) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 198, -7 }, /* (285) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 198, -8 }, /* (286) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 198, -9 }, /* (287) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + { 198, -7 }, /* (288) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + { 198, -3 }, /* (289) cmd ::= KILL CONNECTION INTEGER */ + { 198, -5 }, /* (290) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 198, -5 }, /* (291) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2451,34 +2139,30 @@ static void yy_accept(yyParser*); /* Forward Declaration */ ** only called from one place, optimizing compilers will in-line it, which ** means that the extra parameters have no performance impact. */ -static YYACTIONTYPE yy_reduce( +static void yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno, /* Number of the rule by which to reduce */ int yyLookahead, /* Lookahead token, or YYNOCODE if none */ ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ - ParseCTX_PDECL /* %extra_context */ ){ int yygoto; /* The next state */ - YYACTIONTYPE yyact; /* The next action */ + int yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ - ParseARG_FETCH + ParseARG_FETCH; (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfoNRhs[yyruleno]; + yysize = yyRuleInfo[yyruleno].nrhs; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -2496,19 +2180,13 @@ static YYACTIONTYPE yy_reduce( #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; + return; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; + return; } yymsp = yypParser->yytos; } @@ -2527,1344 +2205,946 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 138: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==138); - case 139: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==139); - case 140: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==140); -#line 63 "sql.y" + case 139: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==139); + case 140: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==140); + case 141: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==141); {} -#line 2536 "sql.c" break; case 1: /* cmd ::= SHOW DATABASES */ -#line 66 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_DB, 0, 0);} -#line 2541 "sql.c" break; case 2: /* cmd ::= SHOW TOPICS */ -#line 67 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_TP, 0, 0);} -#line 2546 "sql.c" break; case 3: /* cmd ::= SHOW FUNCTIONS */ -#line 68 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_FUNCTION, 0, 0);} -#line 2551 "sql.c" break; case 4: /* cmd ::= SHOW MNODES */ -#line 69 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_MNODE, 0, 0);} -#line 2556 "sql.c" break; case 5: /* cmd ::= SHOW DNODES */ -#line 70 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_DNODE, 0, 0);} -#line 2561 "sql.c" break; case 6: /* cmd ::= SHOW ACCOUNTS */ -#line 71 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_ACCT, 0, 0);} -#line 2566 "sql.c" break; case 7: /* cmd ::= SHOW USERS */ -#line 72 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_USER, 0, 0);} -#line 2571 "sql.c" break; case 8: /* cmd ::= SHOW MODULES */ -#line 74 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_MODULE, 0, 0); } -#line 2576 "sql.c" break; case 9: /* cmd ::= SHOW QUERIES */ -#line 75 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_QUERIES, 0, 0); } -#line 2581 "sql.c" break; case 10: /* cmd ::= SHOW CONNECTIONS */ -#line 76 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_CONNS, 0, 0);} -#line 2586 "sql.c" break; case 11: /* cmd ::= SHOW STREAMS */ -#line 77 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_STREAMS, 0, 0); } -#line 2591 "sql.c" break; case 12: /* cmd ::= SHOW VARIABLES */ -#line 78 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_VARIABLES, 0, 0); } -#line 2596 "sql.c" break; case 13: /* cmd ::= SHOW SCORES */ -#line 79 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_SCORES, 0, 0); } -#line 2601 "sql.c" break; case 14: /* cmd ::= SHOW GRANTS */ -#line 80 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0); } -#line 2606 "sql.c" break; case 15: /* cmd ::= SHOW VNODES */ -#line 82 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); } -#line 2611 "sql.c" break; case 16: /* cmd ::= SHOW VNODES ids */ -#line 83 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &yymsp[0].minor.yy0, 0); } -#line 2616 "sql.c" break; case 17: /* dbPrefix ::= */ -#line 87 "sql.y" {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.type = 0;} -#line 2621 "sql.c" break; case 18: /* dbPrefix ::= ids DOT */ -#line 88 "sql.y" {yylhsminor.yy0 = yymsp[-1].minor.yy0; } -#line 2626 "sql.c" yymsp[-1].minor.yy0 = yylhsminor.yy0; break; case 19: /* cpxName ::= */ -#line 91 "sql.y" {yymsp[1].minor.yy0.n = 0; } -#line 2632 "sql.c" break; case 20: /* cpxName ::= DOT ids */ -#line 92 "sql.y" {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n += 1; } -#line 2637 "sql.c" break; case 21: /* cmd ::= SHOW CREATE TABLE ids cpxName */ -#line 94 "sql.y" { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_TABLE, 1, &yymsp[-1].minor.yy0); } -#line 2645 "sql.c" break; case 22: /* cmd ::= SHOW CREATE STABLE ids cpxName */ -#line 98 "sql.y" { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_STABLE, 1, &yymsp[-1].minor.yy0); } -#line 2653 "sql.c" break; case 23: /* cmd ::= SHOW CREATE DATABASE ids */ -#line 103 "sql.y" { setDCLSqlElems(pInfo, TSDB_SQL_SHOW_CREATE_DATABASE, 1, &yymsp[0].minor.yy0); } -#line 2660 "sql.c" break; case 24: /* cmd ::= SHOW dbPrefix TABLES */ -#line 107 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &yymsp[-1].minor.yy0, 0); } -#line 2667 "sql.c" break; case 25: /* cmd ::= SHOW dbPrefix TABLES LIKE ids */ -#line 111 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_TABLE, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); } -#line 2674 "sql.c" break; case 26: /* cmd ::= SHOW dbPrefix STABLES */ -#line 115 "sql.y" { setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &yymsp[-1].minor.yy0, 0); } -#line 2681 "sql.c" break; case 27: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */ -#line 119 "sql.y" { SStrToken token; tSetDbName(&token, &yymsp[-3].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &yymsp[0].minor.yy0); } -#line 2690 "sql.c" break; case 28: /* cmd ::= SHOW dbPrefix VGROUPS */ -#line 125 "sql.y" { SStrToken token; tSetDbName(&token, &yymsp[-1].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0); } -#line 2699 "sql.c" break; case 29: /* cmd ::= SHOW dbPrefix VGROUPS ids */ -#line 131 "sql.y" { SStrToken token; tSetDbName(&token, &yymsp[-2].minor.yy0); setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &yymsp[0].minor.yy0); } -#line 2708 "sql.c" break; case 30: /* cmd ::= DROP TABLE ifexists ids cpxName */ -#line 138 "sql.y" { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0, -1, -1); } -#line 2716 "sql.c" break; case 31: /* cmd ::= DROP STABLE ifexists ids cpxName */ -#line 144 "sql.y" { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &yymsp[-1].minor.yy0, &yymsp[-2].minor.yy0, -1, TSDB_SUPER_TABLE); } -#line 2724 "sql.c" break; case 32: /* cmd ::= DROP DATABASE ifexists ids */ -#line 149 "sql.y" { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0, TSDB_DB_TYPE_DEFAULT, -1); } -#line 2729 "sql.c" break; case 33: /* cmd ::= DROP TOPIC ifexists ids */ -#line 150 "sql.y" { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &yymsp[0].minor.yy0, &yymsp[-1].minor.yy0, TSDB_DB_TYPE_TOPIC, -1); } -#line 2734 "sql.c" break; case 34: /* cmd ::= DROP FUNCTION ids */ -#line 151 "sql.y" { setDropFuncInfo(pInfo, TSDB_SQL_DROP_FUNCTION, &yymsp[0].minor.yy0); } -#line 2739 "sql.c" break; case 35: /* cmd ::= DROP DNODE ids */ -#line 153 "sql.y" { setDCLSqlElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &yymsp[0].minor.yy0); } -#line 2744 "sql.c" break; case 36: /* cmd ::= DROP USER ids */ -#line 154 "sql.y" { setDCLSqlElems(pInfo, TSDB_SQL_DROP_USER, 1, &yymsp[0].minor.yy0); } -#line 2749 "sql.c" break; case 37: /* cmd ::= DROP ACCOUNT ids */ -#line 155 "sql.y" { setDCLSqlElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &yymsp[0].minor.yy0); } -#line 2754 "sql.c" break; case 38: /* cmd ::= USE ids */ -#line 158 "sql.y" { setDCLSqlElems(pInfo, TSDB_SQL_USE_DB, 1, &yymsp[0].minor.yy0);} -#line 2759 "sql.c" break; case 39: /* cmd ::= DESCRIBE ids cpxName */ -#line 161 "sql.y" + case 40: /* cmd ::= DESC ids cpxName */ yytestcase(yyruleno==40); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; setDCLSqlElems(pInfo, TSDB_SQL_DESCRIBE_TABLE, 1, &yymsp[-1].minor.yy0); } -#line 2767 "sql.c" break; - case 40: /* cmd ::= ALTER USER ids PASS ids */ -#line 167 "sql.y" + case 41: /* cmd ::= ALTER USER ids PASS ids */ { setAlterUserSql(pInfo, TSDB_ALTER_USER_PASSWD, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, NULL); } -#line 2772 "sql.c" break; - case 41: /* cmd ::= ALTER USER ids PRIVILEGE ids */ -#line 168 "sql.y" + case 42: /* cmd ::= ALTER USER ids PRIVILEGE ids */ { setAlterUserSql(pInfo, TSDB_ALTER_USER_PRIVILEGES, &yymsp[-2].minor.yy0, NULL, &yymsp[0].minor.yy0);} -#line 2777 "sql.c" break; - case 42: /* cmd ::= ALTER DNODE ids ids */ -#line 169 "sql.y" + case 43: /* cmd ::= ALTER DNODE ids ids */ { setDCLSqlElems(pInfo, TSDB_SQL_CFG_DNODE, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 2782 "sql.c" break; - case 43: /* cmd ::= ALTER DNODE ids ids ids */ -#line 170 "sql.y" + case 44: /* 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); } -#line 2787 "sql.c" break; - case 44: /* cmd ::= ALTER LOCAL ids */ -#line 171 "sql.y" + case 45: /* cmd ::= ALTER LOCAL ids */ { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &yymsp[0].minor.yy0); } -#line 2792 "sql.c" break; - case 45: /* cmd ::= ALTER LOCAL ids ids */ -#line 172 "sql.y" + case 46: /* cmd ::= ALTER LOCAL ids ids */ { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 2797 "sql.c" - break; - case 46: /* cmd ::= ALTER DATABASE ids alter_db_optr */ - case 47: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==47); -#line 173 "sql.y" -{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy42, &t);} -#line 2803 "sql.c" - break; - case 48: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -#line 176 "sql.y" -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy341);} -#line 2808 "sql.c" - break; - case 49: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -#line 177 "sql.y" -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy341);} -#line 2813 "sql.c" - break; - case 50: /* cmd ::= COMPACT VNODES IN LP exprlist RP */ -#line 181 "sql.y" -{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy131);} -#line 2818 "sql.c" - break; - case 51: /* ids ::= ID */ - case 52: /* ids ::= STRING */ yytestcase(yyruleno==52); -#line 187 "sql.y" + break; + case 47: /* cmd ::= ALTER DATABASE ids alter_db_optr */ + case 48: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==48); +{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy90, &t);} + break; + case 49: /* cmd ::= ALTER ACCOUNT ids acct_optr */ +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy171);} + break; + case 50: /* 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.yy171);} + break; + case 51: /* cmd ::= COMPACT VNODES IN LP exprlist RP */ +{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy421);} + break; + case 52: /* ids ::= ID */ + case 53: /* ids ::= STRING */ yytestcase(yyruleno==53); {yylhsminor.yy0 = yymsp[0].minor.yy0; } -#line 2824 "sql.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 53: /* ifexists ::= IF EXISTS */ -#line 191 "sql.y" + case 54: /* ifexists ::= IF EXISTS */ { yymsp[-1].minor.yy0.n = 1;} -#line 2830 "sql.c" break; - case 54: /* ifexists ::= */ - case 56: /* ifnotexists ::= */ yytestcase(yyruleno==56); - case 180: /* distinct ::= */ yytestcase(yyruleno==180); -#line 192 "sql.y" + case 55: /* ifexists ::= */ + case 57: /* ifnotexists ::= */ yytestcase(yyruleno==57); + case 181: /* distinct ::= */ yytestcase(yyruleno==181); { yymsp[1].minor.yy0.n = 0;} -#line 2837 "sql.c" break; - case 55: /* ifnotexists ::= IF NOT EXISTS */ -#line 195 "sql.y" + case 56: /* ifnotexists ::= IF NOT EXISTS */ { yymsp[-2].minor.yy0.n = 1;} -#line 2842 "sql.c" break; - case 57: /* cmd ::= CREATE DNODE ids */ -#line 200 "sql.y" + case 58: /* cmd ::= CREATE DNODE ids */ { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} -#line 2847 "sql.c" - break; - case 58: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -#line 202 "sql.y" -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy341);} -#line 2852 "sql.c" - break; - case 59: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - case 60: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==60); -#line 203 "sql.y" -{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy42, &yymsp[-2].minor.yy0);} -#line 2858 "sql.c" - break; - case 61: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -#line 205 "sql.y" -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy163, &yymsp[0].minor.yy0, 1);} -#line 2863 "sql.c" - break; - case 62: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -#line 206 "sql.y" -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy163, &yymsp[0].minor.yy0, 2);} -#line 2868 "sql.c" - break; - case 63: /* cmd ::= CREATE USER ids PASS ids */ -#line 207 "sql.y" + break; + case 59: /* 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.yy171);} + break; + case 60: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + case 61: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==61); +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy90, &yymsp[-2].minor.yy0);} + break; + case 62: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy183, &yymsp[0].minor.yy0, 1);} + break; + case 63: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy183, &yymsp[0].minor.yy0, 2);} + break; + case 64: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} -#line 2873 "sql.c" - break; - case 64: /* bufsize ::= */ - case 66: /* pps ::= */ yytestcase(yyruleno==66); - case 68: /* tseries ::= */ yytestcase(yyruleno==68); - case 70: /* dbs ::= */ yytestcase(yyruleno==70); - case 72: /* streams ::= */ yytestcase(yyruleno==72); - case 74: /* storage ::= */ yytestcase(yyruleno==74); - case 76: /* qtime ::= */ yytestcase(yyruleno==76); - case 78: /* users ::= */ yytestcase(yyruleno==78); - case 80: /* conns ::= */ yytestcase(yyruleno==80); - case 82: /* state ::= */ yytestcase(yyruleno==82); -#line 209 "sql.y" + break; + case 65: /* bufsize ::= */ + case 67: /* pps ::= */ yytestcase(yyruleno==67); + case 69: /* tseries ::= */ yytestcase(yyruleno==69); + case 71: /* dbs ::= */ yytestcase(yyruleno==71); + case 73: /* streams ::= */ yytestcase(yyruleno==73); + case 75: /* storage ::= */ yytestcase(yyruleno==75); + case 77: /* qtime ::= */ yytestcase(yyruleno==77); + case 79: /* users ::= */ yytestcase(yyruleno==79); + case 81: /* conns ::= */ yytestcase(yyruleno==81); + case 83: /* state ::= */ yytestcase(yyruleno==83); { yymsp[1].minor.yy0.n = 0; } -#line 2887 "sql.c" - break; - case 65: /* bufsize ::= BUFSIZE INTEGER */ - case 67: /* pps ::= PPS INTEGER */ yytestcase(yyruleno==67); - case 69: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==69); - case 71: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==71); - case 73: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==73); - case 75: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==75); - case 77: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==77); - case 79: /* users ::= USERS INTEGER */ yytestcase(yyruleno==79); - case 81: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==81); - case 83: /* state ::= STATE ids */ yytestcase(yyruleno==83); -#line 210 "sql.y" + break; + case 66: /* bufsize ::= BUFSIZE INTEGER */ + case 68: /* pps ::= PPS INTEGER */ yytestcase(yyruleno==68); + case 70: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==70); + case 72: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==72); + case 74: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==74); + case 76: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==76); + case 78: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==78); + case 80: /* users ::= USERS INTEGER */ yytestcase(yyruleno==80); + case 82: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==82); + case 84: /* state ::= STATE ids */ yytestcase(yyruleno==84); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } -#line 2901 "sql.c" break; - case 84: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ -#line 240 "sql.y" -{ - yylhsminor.yy341.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy341.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy341.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy341.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy341.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy341.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy341.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy341.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy341.stat = yymsp[0].minor.yy0; -} -#line 2916 "sql.c" - yymsp[-8].minor.yy341 = yylhsminor.yy341; - break; - case 85: /* intitemlist ::= intitemlist COMMA intitem */ - case 154: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==154); -#line 256 "sql.y" -{ yylhsminor.yy131 = tVariantListAppend(yymsp[-2].minor.yy131, &yymsp[0].minor.yy516, -1); } -#line 2923 "sql.c" - yymsp[-2].minor.yy131 = yylhsminor.yy131; - break; - case 86: /* intitemlist ::= intitem */ - case 155: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==155); -#line 257 "sql.y" -{ yylhsminor.yy131 = tVariantListAppend(NULL, &yymsp[0].minor.yy516, -1); } -#line 2930 "sql.c" - yymsp[0].minor.yy131 = yylhsminor.yy131; - break; - case 87: /* intitem ::= INTEGER */ - case 156: /* tagitem ::= INTEGER */ yytestcase(yyruleno==156); - case 157: /* tagitem ::= FLOAT */ yytestcase(yyruleno==157); - case 158: /* tagitem ::= STRING */ yytestcase(yyruleno==158); - case 159: /* tagitem ::= BOOL */ yytestcase(yyruleno==159); -#line 259 "sql.y" -{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy516, &yymsp[0].minor.yy0); } -#line 2940 "sql.c" - yymsp[0].minor.yy516 = yylhsminor.yy516; - break; - case 88: /* keep ::= KEEP intitemlist */ -#line 263 "sql.y" -{ yymsp[-1].minor.yy131 = yymsp[0].minor.yy131; } -#line 2946 "sql.c" - break; - case 89: /* cache ::= CACHE INTEGER */ - case 90: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==90); - case 91: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==91); - case 92: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==92); - case 93: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==93); - case 94: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==94); - case 95: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==95); - case 96: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==96); - case 97: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==97); - case 98: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==98); - case 99: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==99); - case 100: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==100); - case 101: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==101); - case 102: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==102); - case 103: /* partitions ::= PARTITIONS INTEGER */ yytestcase(yyruleno==103); -#line 265 "sql.y" + case 85: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ +{ + yylhsminor.yy171.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy171.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy171.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy171.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy171.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy171.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy171.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy171.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy171.stat = yymsp[0].minor.yy0; +} + yymsp[-8].minor.yy171 = yylhsminor.yy171; + break; + case 86: /* intitemlist ::= intitemlist COMMA intitem */ + case 155: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==155); +{ yylhsminor.yy421 = tVariantListAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy430, -1); } + yymsp[-2].minor.yy421 = yylhsminor.yy421; + break; + case 87: /* intitemlist ::= intitem */ + case 156: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==156); +{ yylhsminor.yy421 = tVariantListAppend(NULL, &yymsp[0].minor.yy430, -1); } + yymsp[0].minor.yy421 = yylhsminor.yy421; + break; + case 88: /* intitem ::= INTEGER */ + case 157: /* tagitem ::= INTEGER */ yytestcase(yyruleno==157); + case 158: /* tagitem ::= FLOAT */ yytestcase(yyruleno==158); + case 159: /* tagitem ::= STRING */ yytestcase(yyruleno==159); + case 160: /* tagitem ::= BOOL */ yytestcase(yyruleno==160); +{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy430, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy430 = yylhsminor.yy430; + break; + case 89: /* keep ::= KEEP intitemlist */ +{ yymsp[-1].minor.yy421 = yymsp[0].minor.yy421; } + break; + case 90: /* cache ::= CACHE INTEGER */ + case 91: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==91); + case 92: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==92); + case 93: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==93); + case 94: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==94); + case 95: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==95); + case 96: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==96); + case 97: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==97); + case 98: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==98); + case 99: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==99); + case 100: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==100); + case 101: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==101); + case 102: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==102); + case 103: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==103); + case 104: /* partitions ::= PARTITIONS INTEGER */ yytestcase(yyruleno==104); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } -#line 2965 "sql.c" - break; - case 104: /* db_optr ::= */ -#line 282 "sql.y" -{setDefaultCreateDbOption(&yymsp[1].minor.yy42); yymsp[1].minor.yy42.dbType = TSDB_DB_TYPE_DEFAULT;} -#line 2970 "sql.c" - break; - case 105: /* db_optr ::= db_optr cache */ -#line 284 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 2975 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 106: /* db_optr ::= db_optr replica */ - case 123: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==123); -#line 285 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 2982 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 107: /* db_optr ::= db_optr quorum */ - case 124: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==124); -#line 286 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 2989 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 108: /* db_optr ::= db_optr days */ -#line 287 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 2995 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 109: /* db_optr ::= db_optr minrows */ -#line 288 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } -#line 3001 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 110: /* db_optr ::= db_optr maxrows */ -#line 289 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } -#line 3007 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 111: /* db_optr ::= db_optr blocks */ - case 126: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==126); -#line 290 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3014 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 112: /* db_optr ::= db_optr ctime */ -#line 291 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3020 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 113: /* db_optr ::= db_optr wal */ -#line 292 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3026 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 114: /* db_optr ::= db_optr fsync */ -#line 293 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3032 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 115: /* db_optr ::= db_optr comp */ - case 127: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==127); -#line 294 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3039 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 116: /* db_optr ::= db_optr prec */ -#line 295 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.precision = yymsp[0].minor.yy0; } -#line 3045 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 117: /* db_optr ::= db_optr keep */ - case 125: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==125); -#line 296 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.keep = yymsp[0].minor.yy131; } -#line 3052 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 118: /* db_optr ::= db_optr update */ - case 128: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==128); -#line 297 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3059 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 119: /* db_optr ::= db_optr cachelast */ - case 129: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==129); -#line 298 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3066 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 120: /* topic_optr ::= db_optr */ - case 130: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==130); -#line 302 "sql.y" -{ yylhsminor.yy42 = yymsp[0].minor.yy42; yylhsminor.yy42.dbType = TSDB_DB_TYPE_TOPIC; } -#line 3073 "sql.c" - yymsp[0].minor.yy42 = yylhsminor.yy42; - break; - case 121: /* topic_optr ::= topic_optr partitions */ - case 131: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==131); -#line 303 "sql.y" -{ yylhsminor.yy42 = yymsp[-1].minor.yy42; yylhsminor.yy42.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3080 "sql.c" - yymsp[-1].minor.yy42 = yylhsminor.yy42; - break; - case 122: /* alter_db_optr ::= */ -#line 306 "sql.y" -{ setDefaultCreateDbOption(&yymsp[1].minor.yy42); yymsp[1].minor.yy42.dbType = TSDB_DB_TYPE_DEFAULT;} -#line 3086 "sql.c" - break; - case 132: /* typename ::= ids */ -#line 326 "sql.y" + break; + case 105: /* db_optr ::= */ +{setDefaultCreateDbOption(&yymsp[1].minor.yy90); yymsp[1].minor.yy90.dbType = TSDB_DB_TYPE_DEFAULT;} + break; + case 106: /* db_optr ::= db_optr cache */ +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 107: /* db_optr ::= db_optr replica */ + case 124: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==124); +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 108: /* db_optr ::= db_optr quorum */ + case 125: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==125); +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 109: /* db_optr ::= db_optr days */ +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 110: /* db_optr ::= db_optr minrows */ +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 111: /* db_optr ::= db_optr maxrows */ +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 112: /* db_optr ::= db_optr blocks */ + case 127: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==127); +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 113: /* db_optr ::= db_optr ctime */ +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 114: /* db_optr ::= db_optr wal */ +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 115: /* db_optr ::= db_optr fsync */ +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 116: /* db_optr ::= db_optr comp */ + case 128: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==128); +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 117: /* db_optr ::= db_optr prec */ +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 118: /* db_optr ::= db_optr keep */ + case 126: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==126); +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.keep = yymsp[0].minor.yy421; } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 119: /* db_optr ::= db_optr update */ + case 129: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==129); +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 120: /* db_optr ::= db_optr cachelast */ + case 130: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==130); +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 121: /* topic_optr ::= db_optr */ + case 131: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==131); +{ yylhsminor.yy90 = yymsp[0].minor.yy90; yylhsminor.yy90.dbType = TSDB_DB_TYPE_TOPIC; } + yymsp[0].minor.yy90 = yylhsminor.yy90; + break; + case 122: /* topic_optr ::= topic_optr partitions */ + case 132: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==132); +{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy90 = yylhsminor.yy90; + break; + case 123: /* alter_db_optr ::= */ +{ setDefaultCreateDbOption(&yymsp[1].minor.yy90); yymsp[1].minor.yy90.dbType = TSDB_DB_TYPE_DEFAULT;} + break; + case 133: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy163, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy183, &yymsp[0].minor.yy0); } -#line 3094 "sql.c" - yymsp[0].minor.yy163 = yylhsminor.yy163; + yymsp[0].minor.yy183 = yylhsminor.yy183; break; - case 133: /* typename ::= ids LP signed RP */ -#line 332 "sql.y" + case 134: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy459 <= 0) { + if (yymsp[-1].minor.yy325 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy163, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy183, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy459; // negative value of name length - tSetColumnType(&yylhsminor.yy163, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy325; // negative value of name length + tSetColumnType(&yylhsminor.yy183, &yymsp[-3].minor.yy0); } } -#line 3108 "sql.c" - yymsp[-3].minor.yy163 = yylhsminor.yy163; + yymsp[-3].minor.yy183 = yylhsminor.yy183; break; - case 134: /* typename ::= ids UNSIGNED */ -#line 343 "sql.y" + case 135: /* 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); - tSetColumnType (&yylhsminor.yy163, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy183, &yymsp[-1].minor.yy0); } -#line 3118 "sql.c" - yymsp[-1].minor.yy163 = yylhsminor.yy163; - break; - case 135: /* signed ::= INTEGER */ -#line 350 "sql.y" -{ yylhsminor.yy459 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3124 "sql.c" - yymsp[0].minor.yy459 = yylhsminor.yy459; - break; - case 136: /* signed ::= PLUS INTEGER */ -#line 351 "sql.y" -{ yymsp[-1].minor.yy459 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } -#line 3130 "sql.c" - break; - case 137: /* signed ::= MINUS INTEGER */ -#line 352 "sql.y" -{ yymsp[-1].minor.yy459 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} -#line 3135 "sql.c" - break; - case 141: /* cmd ::= CREATE TABLE create_table_list */ -#line 358 "sql.y" -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy272;} -#line 3140 "sql.c" - break; - case 142: /* create_table_list ::= create_from_stable */ -#line 362 "sql.y" + yymsp[-1].minor.yy183 = yylhsminor.yy183; + break; + case 136: /* signed ::= INTEGER */ +{ yylhsminor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy325 = yylhsminor.yy325; + break; + case 137: /* signed ::= PLUS INTEGER */ +{ yymsp[-1].minor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + break; + case 138: /* signed ::= MINUS INTEGER */ +{ yymsp[-1].minor.yy325 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} + break; + case 142: /* cmd ::= CREATE TABLE create_table_list */ +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy438;} + break; + case 143: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy96); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy152); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy272 = pCreateTable; + yylhsminor.yy438 = pCreateTable; } -#line 3152 "sql.c" - yymsp[0].minor.yy272 = yylhsminor.yy272; + yymsp[0].minor.yy438 = yylhsminor.yy438; break; - case 143: /* create_table_list ::= create_table_list create_from_stable */ -#line 371 "sql.y" + case 144: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy272->childTableInfo, &yymsp[0].minor.yy96); - yylhsminor.yy272 = yymsp[-1].minor.yy272; + taosArrayPush(yymsp[-1].minor.yy438->childTableInfo, &yymsp[0].minor.yy152); + yylhsminor.yy438 = yymsp[-1].minor.yy438; } -#line 3161 "sql.c" - yymsp[-1].minor.yy272 = yylhsminor.yy272; + yymsp[-1].minor.yy438 = yylhsminor.yy438; break; - case 144: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ -#line 377 "sql.y" + case 145: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy272 = tSetCreateTableInfo(yymsp[-1].minor.yy131, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy272, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-1].minor.yy421, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); } -#line 3173 "sql.c" - yymsp[-5].minor.yy272 = yylhsminor.yy272; + yymsp[-5].minor.yy438 = yylhsminor.yy438; break; - case 145: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ -#line 387 "sql.y" + case 146: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy272 = tSetCreateTableInfo(yymsp[-5].minor.yy131, yymsp[-1].minor.yy131, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy272, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } -#line 3185 "sql.c" - yymsp[-9].minor.yy272 = yylhsminor.yy272; + yymsp[-9].minor.yy438 = yylhsminor.yy438; break; - case 146: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ -#line 398 "sql.y" + case 147: /* 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.yy96 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy131, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy152 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy421, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } -#line 3195 "sql.c" - yymsp[-9].minor.yy96 = yylhsminor.yy96; + yymsp[-9].minor.yy152 = yylhsminor.yy152; break; - case 147: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ -#line 404 "sql.y" + case 148: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; - yylhsminor.yy96 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy131, yymsp[-1].minor.yy131, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy152 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } -#line 3205 "sql.c" - yymsp[-12].minor.yy96 = yylhsminor.yy96; - break; - case 148: /* tagNamelist ::= tagNamelist COMMA ids */ -#line 412 "sql.y" -{taosArrayPush(yymsp[-2].minor.yy131, &yymsp[0].minor.yy0); yylhsminor.yy131 = yymsp[-2].minor.yy131; } -#line 3211 "sql.c" - yymsp[-2].minor.yy131 = yylhsminor.yy131; - break; - case 149: /* tagNamelist ::= ids */ -#line 413 "sql.y" -{yylhsminor.yy131 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy131, &yymsp[0].minor.yy0);} -#line 3217 "sql.c" - yymsp[0].minor.yy131 = yylhsminor.yy131; - break; - case 150: /* create_table_args ::= ifnotexists ids cpxName AS select */ -#line 417 "sql.y" + yymsp[-12].minor.yy152 = yylhsminor.yy152; + break; + case 149: /* tagNamelist ::= tagNamelist COMMA ids */ +{taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); yylhsminor.yy421 = yymsp[-2].minor.yy421; } + yymsp[-2].minor.yy421 = yylhsminor.yy421; + break; + case 150: /* tagNamelist ::= ids */ +{yylhsminor.yy421 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy421 = yylhsminor.yy421; + break; + case 151: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy272 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy256, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy272, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy438 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy56, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); } -#line 3229 "sql.c" - yymsp[-4].minor.yy272 = yylhsminor.yy272; - break; - case 151: /* columnlist ::= columnlist COMMA column */ -#line 428 "sql.y" -{taosArrayPush(yymsp[-2].minor.yy131, &yymsp[0].minor.yy163); yylhsminor.yy131 = yymsp[-2].minor.yy131; } -#line 3235 "sql.c" - yymsp[-2].minor.yy131 = yylhsminor.yy131; - break; - case 152: /* columnlist ::= column */ -#line 429 "sql.y" -{yylhsminor.yy131 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy131, &yymsp[0].minor.yy163);} -#line 3241 "sql.c" - yymsp[0].minor.yy131 = yylhsminor.yy131; - break; - case 153: /* column ::= ids typename */ -#line 433 "sql.y" + yymsp[-4].minor.yy438 = yylhsminor.yy438; + break; + case 152: /* 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; + break; + case 153: /* columnlist ::= column */ +{yylhsminor.yy421 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy183);} + yymsp[0].minor.yy421 = yylhsminor.yy421; + break; + case 154: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy163, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy163); + tSetColumnInfo(&yylhsminor.yy183, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy183); } -#line 3249 "sql.c" - yymsp[-1].minor.yy163 = yylhsminor.yy163; - break; - case 160: /* tagitem ::= NULL */ -#line 448 "sql.y" -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy516, &yymsp[0].minor.yy0); } -#line 3255 "sql.c" - yymsp[0].minor.yy516 = yylhsminor.yy516; - break; - case 161: /* tagitem ::= NOW */ -#line 449 "sql.y" -{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&yylhsminor.yy516, &yymsp[0].minor.yy0);} -#line 3261 "sql.c" - yymsp[0].minor.yy516 = yylhsminor.yy516; - break; - case 162: /* tagitem ::= MINUS INTEGER */ - case 163: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==163); - case 164: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==164); - case 165: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==165); -#line 451 "sql.y" + yymsp[-1].minor.yy183 = yylhsminor.yy183; + break; + case 161: /* tagitem ::= NULL */ +{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy430, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy430 = yylhsminor.yy430; + break; + case 162: /* tagitem ::= NOW */ +{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&yylhsminor.yy430, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy430 = yylhsminor.yy430; + break; + case 163: /* tagitem ::= MINUS INTEGER */ + case 164: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==164); + case 165: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==165); + case 166: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==166); { 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.yy516, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy430, &yymsp[-1].minor.yy0); } -#line 3275 "sql.c" - yymsp[-1].minor.yy516 = yylhsminor.yy516; + yymsp[-1].minor.yy430 = yylhsminor.yy430; break; - case 166: /* select ::= SELECT selcollist from where_opt interval_opt sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ -#line 482 "sql.y" + case 167: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { - yylhsminor.yy256 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy131, yymsp[-11].minor.yy544, yymsp[-10].minor.yy46, yymsp[-4].minor.yy131, yymsp[-2].minor.yy131, &yymsp[-9].minor.yy530, &yymsp[-7].minor.yy39, &yymsp[-6].minor.yy538, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy131, &yymsp[0].minor.yy284, &yymsp[-1].minor.yy284, yymsp[-3].minor.yy46); + yylhsminor.yy56 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy421, yymsp[-11].minor.yy8, yymsp[-10].minor.yy439, yymsp[-4].minor.yy421, yymsp[-2].minor.yy421, &yymsp[-9].minor.yy400, &yymsp[-7].minor.yy147, &yymsp[-6].minor.yy40, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy421, &yymsp[0].minor.yy166, &yymsp[-1].minor.yy166, yymsp[-3].minor.yy439); } -#line 3283 "sql.c" - yymsp[-13].minor.yy256 = yylhsminor.yy256; - break; - case 167: /* select ::= LP select RP */ -#line 486 "sql.y" -{yymsp[-2].minor.yy256 = yymsp[-1].minor.yy256;} -#line 3289 "sql.c" - break; - case 168: /* union ::= select */ -#line 490 "sql.y" -{ yylhsminor.yy131 = setSubclause(NULL, yymsp[0].minor.yy256); } -#line 3294 "sql.c" - yymsp[0].minor.yy131 = yylhsminor.yy131; - break; - case 169: /* union ::= union UNION ALL select */ -#line 491 "sql.y" -{ yylhsminor.yy131 = appendSelectClause(yymsp[-3].minor.yy131, yymsp[0].minor.yy256); } -#line 3300 "sql.c" - yymsp[-3].minor.yy131 = yylhsminor.yy131; - break; - case 170: /* cmd ::= union */ -#line 493 "sql.y" -{ setSqlInfo(pInfo, yymsp[0].minor.yy131, NULL, TSDB_SQL_SELECT); } -#line 3306 "sql.c" - break; - case 171: /* select ::= SELECT selcollist */ -#line 500 "sql.y" + yymsp[-13].minor.yy56 = yylhsminor.yy56; + break; + case 168: /* select ::= LP select RP */ +{yymsp[-2].minor.yy56 = yymsp[-1].minor.yy56;} + break; + case 169: /* union ::= select */ +{ yylhsminor.yy421 = setSubclause(NULL, yymsp[0].minor.yy56); } + yymsp[0].minor.yy421 = yylhsminor.yy421; + break; + case 170: /* union ::= union UNION ALL select */ +{ yylhsminor.yy421 = appendSelectClause(yymsp[-3].minor.yy421, yymsp[0].minor.yy56); } + yymsp[-3].minor.yy421 = yylhsminor.yy421; + break; + case 171: /* cmd ::= union */ +{ setSqlInfo(pInfo, yymsp[0].minor.yy421, NULL, TSDB_SQL_SELECT); } + break; + case 172: /* select ::= SELECT selcollist */ { - yylhsminor.yy256 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy131, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy56 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy421, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } -#line 3313 "sql.c" - yymsp[-1].minor.yy256 = yylhsminor.yy256; - break; - case 172: /* sclp ::= selcollist COMMA */ -#line 512 "sql.y" -{yylhsminor.yy131 = yymsp[-1].minor.yy131;} -#line 3319 "sql.c" - yymsp[-1].minor.yy131 = yylhsminor.yy131; - break; - case 173: /* sclp ::= */ - case 203: /* orderby_opt ::= */ yytestcase(yyruleno==203); -#line 513 "sql.y" -{yymsp[1].minor.yy131 = 0;} -#line 3326 "sql.c" - break; - case 174: /* selcollist ::= sclp distinct expr as */ -#line 514 "sql.y" + yymsp[-1].minor.yy56 = yylhsminor.yy56; + break; + case 173: /* sclp ::= selcollist COMMA */ +{yylhsminor.yy421 = yymsp[-1].minor.yy421;} + yymsp[-1].minor.yy421 = yylhsminor.yy421; + break; + case 174: /* sclp ::= */ + case 206: /* orderby_opt ::= */ yytestcase(yyruleno==206); +{yymsp[1].minor.yy421 = 0;} + break; + case 175: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy131 = tSqlExprListAppend(yymsp[-3].minor.yy131, yymsp[-1].minor.yy46, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy421 = tSqlExprListAppend(yymsp[-3].minor.yy421, yymsp[-1].minor.yy439, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } -#line 3333 "sql.c" - yymsp[-3].minor.yy131 = yylhsminor.yy131; + yymsp[-3].minor.yy421 = yylhsminor.yy421; break; - case 175: /* selcollist ::= sclp STAR */ -#line 518 "sql.y" + case 176: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); - yylhsminor.yy131 = tSqlExprListAppend(yymsp[-1].minor.yy131, pNode, 0, 0); + yylhsminor.yy421 = tSqlExprListAppend(yymsp[-1].minor.yy421, pNode, 0, 0); } -#line 3342 "sql.c" - yymsp[-1].minor.yy131 = yylhsminor.yy131; + yymsp[-1].minor.yy421 = yylhsminor.yy421; break; - case 176: /* as ::= AS ids */ -#line 526 "sql.y" + case 177: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } -#line 3348 "sql.c" break; - case 177: /* as ::= ids */ -#line 527 "sql.y" + case 178: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } -#line 3353 "sql.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 178: /* as ::= */ -#line 528 "sql.y" + case 179: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } -#line 3359 "sql.c" break; - case 179: /* distinct ::= DISTINCT */ -#line 531 "sql.y" + case 180: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } -#line 3364 "sql.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 181: /* from ::= FROM tablelist */ - case 182: /* from ::= FROM sub */ yytestcase(yyruleno==182); -#line 537 "sql.y" -{yymsp[-1].minor.yy544 = yymsp[0].minor.yy544;} -#line 3371 "sql.c" - break; - case 183: /* sub ::= LP union RP */ -#line 542 "sql.y" -{yymsp[-2].minor.yy544 = addSubqueryElem(NULL, yymsp[-1].minor.yy131, NULL);} -#line 3376 "sql.c" - break; - case 184: /* sub ::= LP union RP ids */ -#line 543 "sql.y" -{yymsp[-3].minor.yy544 = addSubqueryElem(NULL, yymsp[-2].minor.yy131, &yymsp[0].minor.yy0);} -#line 3381 "sql.c" - break; - case 185: /* sub ::= sub COMMA LP union RP ids */ -#line 544 "sql.y" -{yylhsminor.yy544 = addSubqueryElem(yymsp[-5].minor.yy544, yymsp[-2].minor.yy131, &yymsp[0].minor.yy0);} -#line 3386 "sql.c" - yymsp[-5].minor.yy544 = yylhsminor.yy544; - break; - case 186: /* tablelist ::= ids cpxName */ -#line 548 "sql.y" + case 182: /* from ::= FROM tablelist */ + case 183: /* from ::= FROM sub */ yytestcase(yyruleno==183); +{yymsp[-1].minor.yy8 = yymsp[0].minor.yy8;} + break; + case 184: /* sub ::= LP union RP */ +{yymsp[-2].minor.yy8 = addSubqueryElem(NULL, yymsp[-1].minor.yy421, NULL);} + break; + case 185: /* sub ::= LP union RP ids */ +{yymsp[-3].minor.yy8 = addSubqueryElem(NULL, yymsp[-2].minor.yy421, &yymsp[0].minor.yy0);} + break; + case 186: /* sub ::= sub COMMA LP union RP ids */ +{yylhsminor.yy8 = addSubqueryElem(yymsp[-5].minor.yy8, yymsp[-2].minor.yy421, &yymsp[0].minor.yy0);} + yymsp[-5].minor.yy8 = yylhsminor.yy8; + break; + case 187: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy544 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy8 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } -#line 3395 "sql.c" - yymsp[-1].minor.yy544 = yylhsminor.yy544; + yymsp[-1].minor.yy8 = yylhsminor.yy8; break; - case 187: /* tablelist ::= ids cpxName ids */ -#line 553 "sql.y" + case 188: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy544 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy8 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } -#line 3404 "sql.c" - yymsp[-2].minor.yy544 = yylhsminor.yy544; + yymsp[-2].minor.yy8 = yylhsminor.yy8; break; - case 188: /* tablelist ::= tablelist COMMA ids cpxName */ -#line 558 "sql.y" + case 189: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy544 = setTableNameList(yymsp[-3].minor.yy544, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy8 = setTableNameList(yymsp[-3].minor.yy8, &yymsp[-1].minor.yy0, NULL); } -#line 3413 "sql.c" - yymsp[-3].minor.yy544 = yylhsminor.yy544; + yymsp[-3].minor.yy8 = yylhsminor.yy8; break; - case 189: /* tablelist ::= tablelist COMMA ids cpxName ids */ -#line 563 "sql.y" + case 190: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy544 = setTableNameList(yymsp[-4].minor.yy544, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy8 = setTableNameList(yymsp[-4].minor.yy8, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } -#line 3422 "sql.c" - yymsp[-4].minor.yy544 = yylhsminor.yy544; + yymsp[-4].minor.yy8 = yylhsminor.yy8; break; - case 190: /* tmvar ::= VARIABLE */ -#line 570 "sql.y" + case 191: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} -#line 3428 "sql.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 191: /* interval_opt ::= INTERVAL LP tmvar RP */ -#line 573 "sql.y" -{yymsp[-3].minor.yy530.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy530.offset.n = 0;} -#line 3434 "sql.c" + case 192: /* interval_option ::= intervalKey LP tmvar RP */ +{yylhsminor.yy400.interval = yymsp[-1].minor.yy0; yylhsminor.yy400.offset.n = 0; yylhsminor.yy400.token = yymsp[-3].minor.yy104;} + yymsp[-3].minor.yy400 = yylhsminor.yy400; + break; + case 193: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ +{yylhsminor.yy400.interval = yymsp[-3].minor.yy0; yylhsminor.yy400.offset = yymsp[-1].minor.yy0; yylhsminor.yy400.token = yymsp[-5].minor.yy104;} + yymsp[-5].minor.yy400 = yylhsminor.yy400; + break; + case 194: /* interval_option ::= */ +{memset(&yymsp[1].minor.yy400, 0, sizeof(yymsp[1].minor.yy400));} break; - case 192: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ -#line 574 "sql.y" -{yymsp[-5].minor.yy530.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy530.offset = yymsp[-1].minor.yy0;} -#line 3439 "sql.c" + case 195: /* intervalKey ::= INTERVAL */ +{yymsp[0].minor.yy104 = TK_INTERVAL;} break; - case 193: /* interval_opt ::= */ -#line 575 "sql.y" -{memset(&yymsp[1].minor.yy530, 0, sizeof(yymsp[1].minor.yy530));} -#line 3444 "sql.c" + case 196: /* intervalKey ::= EVERY */ +{yymsp[0].minor.yy104 = TK_EVERY; } break; - case 194: /* session_option ::= */ -#line 578 "sql.y" -{yymsp[1].minor.yy39.col.n = 0; yymsp[1].minor.yy39.gap.n = 0;} -#line 3449 "sql.c" + case 197: /* session_option ::= */ +{yymsp[1].minor.yy147.col.n = 0; yymsp[1].minor.yy147.gap.n = 0;} break; - case 195: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ -#line 579 "sql.y" + case 198: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy39.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy39.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy147.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy147.gap = yymsp[-1].minor.yy0; } -#line 3458 "sql.c" break; - case 196: /* windowstate_option ::= */ -#line 585 "sql.y" -{ yymsp[1].minor.yy538.col.n = 0; yymsp[1].minor.yy538.col.z = NULL;} -#line 3463 "sql.c" + case 199: /* windowstate_option ::= */ +{ yymsp[1].minor.yy40.col.n = 0; yymsp[1].minor.yy40.col.z = NULL;} break; - case 197: /* windowstate_option ::= STATE_WINDOW LP ids RP */ -#line 586 "sql.y" -{ yymsp[-3].minor.yy538.col = yymsp[-1].minor.yy0; } -#line 3468 "sql.c" + case 200: /* windowstate_option ::= STATE_WINDOW LP ids RP */ +{ yymsp[-3].minor.yy40.col = yymsp[-1].minor.yy0; } break; - case 198: /* fill_opt ::= */ -#line 590 "sql.y" -{ yymsp[1].minor.yy131 = 0; } -#line 3473 "sql.c" + case 201: /* fill_opt ::= */ +{ yymsp[1].minor.yy421 = 0; } break; - case 199: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ -#line 591 "sql.y" + case 202: /* 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.yy131, &A, -1, 0); - yymsp[-5].minor.yy131 = yymsp[-1].minor.yy131; + tVariantListInsert(yymsp[-1].minor.yy421, &A, -1, 0); + yymsp[-5].minor.yy421 = yymsp[-1].minor.yy421; } -#line 3485 "sql.c" break; - case 200: /* fill_opt ::= FILL LP ID RP */ -#line 600 "sql.y" + case 203: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy131 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy421 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } -#line 3493 "sql.c" break; - case 201: /* sliding_opt ::= SLIDING LP tmvar RP */ -#line 606 "sql.y" + case 204: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } -#line 3498 "sql.c" break; - case 202: /* sliding_opt ::= */ -#line 607 "sql.y" + case 205: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } -#line 3503 "sql.c" break; - case 204: /* orderby_opt ::= ORDER BY sortlist */ -#line 619 "sql.y" -{yymsp[-2].minor.yy131 = yymsp[0].minor.yy131;} -#line 3508 "sql.c" + case 207: /* orderby_opt ::= ORDER BY sortlist */ +{yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} break; - case 205: /* sortlist ::= sortlist COMMA item sortorder */ -#line 621 "sql.y" + case 208: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy131 = tVariantListAppend(yymsp[-3].minor.yy131, &yymsp[-1].minor.yy516, yymsp[0].minor.yy43); + yylhsminor.yy421 = tVariantListAppend(yymsp[-3].minor.yy421, &yymsp[-1].minor.yy430, yymsp[0].minor.yy96); } -#line 3515 "sql.c" - yymsp[-3].minor.yy131 = yylhsminor.yy131; + yymsp[-3].minor.yy421 = yylhsminor.yy421; break; - case 206: /* sortlist ::= item sortorder */ -#line 625 "sql.y" + case 209: /* sortlist ::= item sortorder */ { - yylhsminor.yy131 = tVariantListAppend(NULL, &yymsp[-1].minor.yy516, yymsp[0].minor.yy43); + yylhsminor.yy421 = tVariantListAppend(NULL, &yymsp[-1].minor.yy430, yymsp[0].minor.yy96); } -#line 3523 "sql.c" - yymsp[-1].minor.yy131 = yylhsminor.yy131; + yymsp[-1].minor.yy421 = yylhsminor.yy421; break; - case 207: /* item ::= ids cpxName */ -#line 630 "sql.y" + case 210: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - tVariantCreate(&yylhsminor.yy516, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy430, &yymsp[-1].minor.yy0); } -#line 3534 "sql.c" - yymsp[-1].minor.yy516 = yylhsminor.yy516; - break; - case 208: /* sortorder ::= ASC */ -#line 638 "sql.y" -{ yymsp[0].minor.yy43 = TSDB_ORDER_ASC; } -#line 3540 "sql.c" - break; - case 209: /* sortorder ::= DESC */ -#line 639 "sql.y" -{ yymsp[0].minor.yy43 = TSDB_ORDER_DESC;} -#line 3545 "sql.c" - break; - case 210: /* sortorder ::= */ -#line 640 "sql.y" -{ yymsp[1].minor.yy43 = TSDB_ORDER_ASC; } -#line 3550 "sql.c" - break; - case 211: /* groupby_opt ::= */ -#line 648 "sql.y" -{ yymsp[1].minor.yy131 = 0;} -#line 3555 "sql.c" - break; - case 212: /* groupby_opt ::= GROUP BY grouplist */ -#line 649 "sql.y" -{ yymsp[-2].minor.yy131 = yymsp[0].minor.yy131;} -#line 3560 "sql.c" - break; - case 213: /* grouplist ::= grouplist COMMA item */ -#line 651 "sql.y" + yymsp[-1].minor.yy430 = yylhsminor.yy430; + break; + case 211: /* sortorder ::= ASC */ +{ yymsp[0].minor.yy96 = TSDB_ORDER_ASC; } + break; + case 212: /* sortorder ::= DESC */ +{ yymsp[0].minor.yy96 = TSDB_ORDER_DESC;} + break; + case 213: /* sortorder ::= */ +{ yymsp[1].minor.yy96 = TSDB_ORDER_ASC; } + break; + case 214: /* groupby_opt ::= */ +{ yymsp[1].minor.yy421 = 0;} + break; + case 215: /* groupby_opt ::= GROUP BY grouplist */ +{ yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} + break; + case 216: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy131 = tVariantListAppend(yymsp[-2].minor.yy131, &yymsp[0].minor.yy516, -1); + yylhsminor.yy421 = tVariantListAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy430, -1); } -#line 3567 "sql.c" - yymsp[-2].minor.yy131 = yylhsminor.yy131; + yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 214: /* grouplist ::= item */ -#line 655 "sql.y" + case 217: /* grouplist ::= item */ { - yylhsminor.yy131 = tVariantListAppend(NULL, &yymsp[0].minor.yy516, -1); + yylhsminor.yy421 = tVariantListAppend(NULL, &yymsp[0].minor.yy430, -1); } -#line 3575 "sql.c" - yymsp[0].minor.yy131 = yylhsminor.yy131; - break; - case 215: /* having_opt ::= */ - case 225: /* where_opt ::= */ yytestcase(yyruleno==225); - case 267: /* expritem ::= */ yytestcase(yyruleno==267); -#line 662 "sql.y" -{yymsp[1].minor.yy46 = 0;} -#line 3583 "sql.c" - break; - case 216: /* having_opt ::= HAVING expr */ - case 226: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==226); -#line 663 "sql.y" -{yymsp[-1].minor.yy46 = yymsp[0].minor.yy46;} -#line 3589 "sql.c" - break; - case 217: /* limit_opt ::= */ - case 221: /* slimit_opt ::= */ yytestcase(yyruleno==221); -#line 667 "sql.y" -{yymsp[1].minor.yy284.limit = -1; yymsp[1].minor.yy284.offset = 0;} -#line 3595 "sql.c" - break; - case 218: /* limit_opt ::= LIMIT signed */ - case 222: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==222); -#line 668 "sql.y" -{yymsp[-1].minor.yy284.limit = yymsp[0].minor.yy459; yymsp[-1].minor.yy284.offset = 0;} -#line 3601 "sql.c" - break; - case 219: /* limit_opt ::= LIMIT signed OFFSET signed */ -#line 670 "sql.y" -{ yymsp[-3].minor.yy284.limit = yymsp[-2].minor.yy459; yymsp[-3].minor.yy284.offset = yymsp[0].minor.yy459;} -#line 3606 "sql.c" - break; - case 220: /* limit_opt ::= LIMIT signed COMMA signed */ -#line 672 "sql.y" -{ yymsp[-3].minor.yy284.limit = yymsp[0].minor.yy459; yymsp[-3].minor.yy284.offset = yymsp[-2].minor.yy459;} -#line 3611 "sql.c" - break; - case 223: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -#line 678 "sql.y" -{yymsp[-3].minor.yy284.limit = yymsp[-2].minor.yy459; yymsp[-3].minor.yy284.offset = yymsp[0].minor.yy459;} -#line 3616 "sql.c" - break; - case 224: /* slimit_opt ::= SLIMIT signed COMMA signed */ -#line 680 "sql.y" -{yymsp[-3].minor.yy284.limit = yymsp[0].minor.yy459; yymsp[-3].minor.yy284.offset = yymsp[-2].minor.yy459;} -#line 3621 "sql.c" - break; - case 227: /* expr ::= LP expr RP */ -#line 693 "sql.y" -{yylhsminor.yy46 = yymsp[-1].minor.yy46; yylhsminor.yy46->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy46->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} -#line 3626 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 228: /* expr ::= ID */ -#line 695 "sql.y" -{ yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} -#line 3632 "sql.c" - yymsp[0].minor.yy46 = yylhsminor.yy46; - break; - case 229: /* expr ::= ID DOT ID */ -#line 696 "sql.y" -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} -#line 3638 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 230: /* expr ::= ID DOT STAR */ -#line 697 "sql.y" -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} -#line 3644 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 231: /* expr ::= INTEGER */ -#line 699 "sql.y" -{ yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} -#line 3650 "sql.c" - yymsp[0].minor.yy46 = yylhsminor.yy46; - break; - case 232: /* expr ::= MINUS INTEGER */ - case 233: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==233); -#line 700 "sql.y" -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} -#line 3657 "sql.c" - yymsp[-1].minor.yy46 = yylhsminor.yy46; - break; - case 234: /* expr ::= FLOAT */ -#line 702 "sql.y" -{ yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} -#line 3663 "sql.c" - yymsp[0].minor.yy46 = yylhsminor.yy46; - break; - case 235: /* expr ::= MINUS FLOAT */ - case 236: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==236); -#line 703 "sql.y" -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} -#line 3670 "sql.c" - yymsp[-1].minor.yy46 = yylhsminor.yy46; - break; - case 237: /* expr ::= STRING */ -#line 705 "sql.y" -{ yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} -#line 3676 "sql.c" - yymsp[0].minor.yy46 = yylhsminor.yy46; - break; - case 238: /* expr ::= NOW */ -#line 706 "sql.y" -{ yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } -#line 3682 "sql.c" - yymsp[0].minor.yy46 = yylhsminor.yy46; - break; - case 239: /* expr ::= VARIABLE */ -#line 707 "sql.y" -{ yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} -#line 3688 "sql.c" - yymsp[0].minor.yy46 = yylhsminor.yy46; - break; - case 240: /* expr ::= PLUS VARIABLE */ - case 241: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==241); -#line 708 "sql.y" -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} -#line 3695 "sql.c" - yymsp[-1].minor.yy46 = yylhsminor.yy46; - break; - case 242: /* expr ::= BOOL */ -#line 710 "sql.y" -{ yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} -#line 3701 "sql.c" - yymsp[0].minor.yy46 = yylhsminor.yy46; - break; - case 243: /* expr ::= NULL */ -#line 711 "sql.y" -{ yylhsminor.yy46 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} -#line 3707 "sql.c" - yymsp[0].minor.yy46 = yylhsminor.yy46; - break; - case 244: /* expr ::= ID LP exprlist RP */ -#line 714 "sql.y" -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy46 = tSqlExprCreateFunction(yymsp[-1].minor.yy131, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } -#line 3713 "sql.c" - yymsp[-3].minor.yy46 = yylhsminor.yy46; - break; - case 245: /* expr ::= ID LP STAR RP */ -#line 717 "sql.y" -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy46 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } -#line 3719 "sql.c" - yymsp[-3].minor.yy46 = yylhsminor.yy46; - break; - case 246: /* expr ::= expr IS NULL */ -#line 720 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, NULL, TK_ISNULL);} -#line 3725 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 247: /* expr ::= expr IS NOT NULL */ -#line 721 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-3].minor.yy46, NULL, TK_NOTNULL);} -#line 3731 "sql.c" - yymsp[-3].minor.yy46 = yylhsminor.yy46; - break; - case 248: /* expr ::= expr LT expr */ -#line 724 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_LT);} -#line 3737 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 249: /* expr ::= expr GT expr */ -#line 725 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_GT);} -#line 3743 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 250: /* expr ::= expr LE expr */ -#line 726 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_LE);} -#line 3749 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 251: /* expr ::= expr GE expr */ -#line 727 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_GE);} -#line 3755 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 252: /* expr ::= expr NE expr */ -#line 728 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_NE);} -#line 3761 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 253: /* expr ::= expr EQ expr */ -#line 729 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_EQ);} -#line 3767 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 254: /* expr ::= expr BETWEEN expr AND expr */ -#line 731 "sql.y" -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy46); yylhsminor.yy46 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy46, yymsp[-2].minor.yy46, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy46, TK_LE), TK_AND);} -#line 3773 "sql.c" - yymsp[-4].minor.yy46 = yylhsminor.yy46; - break; - case 255: /* expr ::= expr AND expr */ -#line 733 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_AND);} -#line 3779 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 256: /* expr ::= expr OR expr */ -#line 734 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_OR); } -#line 3785 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 257: /* expr ::= expr PLUS expr */ -#line 737 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_PLUS); } -#line 3791 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 258: /* expr ::= expr MINUS expr */ -#line 738 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_MINUS); } -#line 3797 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 259: /* expr ::= expr STAR expr */ -#line 739 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_STAR); } -#line 3803 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 260: /* expr ::= expr SLASH expr */ -#line 740 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_DIVIDE);} -#line 3809 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 261: /* expr ::= expr REM expr */ -#line 741 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_REM); } -#line 3815 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 262: /* expr ::= expr LIKE expr */ -#line 744 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-2].minor.yy46, yymsp[0].minor.yy46, TK_LIKE); } -#line 3821 "sql.c" - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 263: /* expr ::= expr IN LP exprlist RP */ -#line 747 "sql.y" -{yylhsminor.yy46 = tSqlExprCreate(yymsp[-4].minor.yy46, (tSqlExpr*)yymsp[-1].minor.yy131, TK_IN); } -#line 3827 "sql.c" - yymsp[-4].minor.yy46 = yylhsminor.yy46; - break; - case 264: /* exprlist ::= exprlist COMMA expritem */ -#line 755 "sql.y" -{yylhsminor.yy131 = tSqlExprListAppend(yymsp[-2].minor.yy131,yymsp[0].minor.yy46,0, 0);} -#line 3833 "sql.c" - yymsp[-2].minor.yy131 = yylhsminor.yy131; - break; - case 265: /* exprlist ::= expritem */ -#line 756 "sql.y" -{yylhsminor.yy131 = tSqlExprListAppend(0,yymsp[0].minor.yy46,0, 0);} -#line 3839 "sql.c" - yymsp[0].minor.yy131 = yylhsminor.yy131; - break; - case 266: /* expritem ::= expr */ -#line 757 "sql.y" -{yylhsminor.yy46 = yymsp[0].minor.yy46;} -#line 3845 "sql.c" - yymsp[0].minor.yy46 = yylhsminor.yy46; - break; - case 268: /* cmd ::= RESET QUERY CACHE */ -#line 761 "sql.y" + yymsp[0].minor.yy421 = yylhsminor.yy421; + break; + case 218: /* having_opt ::= */ + case 228: /* where_opt ::= */ yytestcase(yyruleno==228); + case 270: /* expritem ::= */ yytestcase(yyruleno==270); +{yymsp[1].minor.yy439 = 0;} + break; + case 219: /* having_opt ::= HAVING expr */ + case 229: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==229); +{yymsp[-1].minor.yy439 = yymsp[0].minor.yy439;} + break; + case 220: /* limit_opt ::= */ + case 224: /* slimit_opt ::= */ yytestcase(yyruleno==224); +{yymsp[1].minor.yy166.limit = -1; yymsp[1].minor.yy166.offset = 0;} + break; + case 221: /* limit_opt ::= LIMIT signed */ + case 225: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==225); +{yymsp[-1].minor.yy166.limit = yymsp[0].minor.yy325; yymsp[-1].minor.yy166.offset = 0;} + break; + case 222: /* limit_opt ::= LIMIT signed OFFSET signed */ +{ yymsp[-3].minor.yy166.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy166.offset = yymsp[0].minor.yy325;} + break; + case 223: /* limit_opt ::= LIMIT signed COMMA signed */ +{ yymsp[-3].minor.yy166.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy166.offset = yymsp[-2].minor.yy325;} + break; + case 226: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ +{yymsp[-3].minor.yy166.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy166.offset = yymsp[0].minor.yy325;} + break; + case 227: /* slimit_opt ::= SLIMIT signed COMMA signed */ +{yymsp[-3].minor.yy166.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy166.offset = yymsp[-2].minor.yy325;} + break; + case 230: /* expr ::= LP expr RP */ +{yylhsminor.yy439 = yymsp[-1].minor.yy439; yylhsminor.yy439->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy439->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 231: /* expr ::= ID */ +{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy439 = yylhsminor.yy439; + break; + case 232: /* expr ::= ID DOT ID */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 233: /* expr ::= ID DOT STAR */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 234: /* expr ::= INTEGER */ +{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy439 = yylhsminor.yy439; + break; + case 235: /* expr ::= MINUS INTEGER */ + case 236: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==236); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy439 = yylhsminor.yy439; + break; + case 237: /* expr ::= FLOAT */ +{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy439 = yylhsminor.yy439; + break; + case 238: /* expr ::= MINUS FLOAT */ + case 239: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==239); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy439 = yylhsminor.yy439; + break; + case 240: /* expr ::= STRING */ +{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy439 = yylhsminor.yy439; + break; + case 241: /* expr ::= NOW */ +{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy439 = yylhsminor.yy439; + break; + case 242: /* expr ::= VARIABLE */ +{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy439 = yylhsminor.yy439; + break; + case 243: /* expr ::= PLUS VARIABLE */ + case 244: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==244); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy439 = yylhsminor.yy439; + break; + case 245: /* expr ::= BOOL */ +{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy439 = yylhsminor.yy439; + break; + case 246: /* expr ::= NULL */ +{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy439 = yylhsminor.yy439; + break; + case 247: /* expr ::= ID LP exprlist RP */ +{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy439 = tSqlExprCreateFunction(yymsp[-1].minor.yy421, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy439 = yylhsminor.yy439; + break; + case 248: /* expr ::= ID LP STAR RP */ +{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy439 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy439 = yylhsminor.yy439; + break; + case 249: /* expr ::= expr IS NULL */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, NULL, TK_ISNULL);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 250: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-3].minor.yy439, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy439 = yylhsminor.yy439; + break; + case 251: /* expr ::= expr LT expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LT);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 252: /* expr ::= expr GT expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_GT);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 253: /* expr ::= expr LE expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LE);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 254: /* expr ::= expr GE expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_GE);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 255: /* expr ::= expr NE expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_NE);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 256: /* expr ::= expr EQ expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_EQ);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 257: /* expr ::= expr BETWEEN expr AND expr */ +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy439); yylhsminor.yy439 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy439, yymsp[-2].minor.yy439, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy439, TK_LE), TK_AND);} + yymsp[-4].minor.yy439 = yylhsminor.yy439; + break; + case 258: /* expr ::= expr AND expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_AND);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 259: /* expr ::= expr OR expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_OR); } + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 260: /* expr ::= expr PLUS expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_PLUS); } + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 261: /* expr ::= expr MINUS expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_MINUS); } + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 262: /* expr ::= expr STAR expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_STAR); } + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 263: /* expr ::= expr SLASH expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_DIVIDE);} + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 264: /* expr ::= expr REM expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_REM); } + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 265: /* expr ::= expr LIKE expr */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LIKE); } + yymsp[-2].minor.yy439 = yylhsminor.yy439; + break; + case 266: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy439 = tSqlExprCreate(yymsp[-4].minor.yy439, (tSqlExpr*)yymsp[-1].minor.yy421, TK_IN); } + yymsp[-4].minor.yy439 = yylhsminor.yy439; + break; + case 267: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy421 = tSqlExprListAppend(yymsp[-2].minor.yy421,yymsp[0].minor.yy439,0, 0);} + yymsp[-2].minor.yy421 = yylhsminor.yy421; + break; + case 268: /* exprlist ::= expritem */ +{yylhsminor.yy421 = tSqlExprListAppend(0,yymsp[0].minor.yy439,0, 0);} + yymsp[0].minor.yy421 = yylhsminor.yy421; + break; + case 269: /* expritem ::= expr */ +{yylhsminor.yy439 = yymsp[0].minor.yy439;} + yymsp[0].minor.yy439 = yylhsminor.yy439; + break; + case 271: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} -#line 3851 "sql.c" break; - case 269: /* cmd ::= SYNCDB ids REPLICA */ -#line 764 "sql.y" + case 272: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} -#line 3856 "sql.c" break; - case 270: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ -#line 767 "sql.y" + case 273: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3865 "sql.c" break; - case 271: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ -#line 773 "sql.y" + case 274: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3874,28 +3154,22 @@ static YYACTIONTYPE yy_reduce( SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3878 "sql.c" break; - case 272: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ -#line 783 "sql.y" + case 275: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3887 "sql.c" break; - case 273: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ -#line 790 "sql.y" + case 276: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3896 "sql.c" break; - case 274: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ -#line 795 "sql.y" + case 277: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3905,10 +3179,8 @@ static YYACTIONTYPE yy_reduce( SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3909 "sql.c" break; - case 275: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ -#line 805 "sql.y" + case 278: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3921,42 +3193,34 @@ static YYACTIONTYPE yy_reduce( SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3925 "sql.c" break; - case 276: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ -#line 818 "sql.y" + case 279: /* 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.yy516, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy430, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3939 "sql.c" break; - case 277: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ -#line 829 "sql.y" + case 280: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3948 "sql.c" break; - case 278: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ -#line 836 "sql.y" + case 281: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3957 "sql.c" break; - case 279: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ -#line 842 "sql.y" + case 282: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3966,28 +3230,22 @@ static YYACTIONTYPE yy_reduce( SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3970 "sql.c" break; - case 280: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ -#line 852 "sql.y" + case 283: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3979 "sql.c" break; - case 281: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ -#line 859 "sql.y" + case 284: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 3988 "sql.c" break; - case 282: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ -#line 864 "sql.y" + case 285: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3997,10 +3255,8 @@ static YYACTIONTYPE yy_reduce( SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 4001 "sql.c" break; - case 283: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ -#line 874 "sql.y" + case 286: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -4013,53 +3269,42 @@ static YYACTIONTYPE yy_reduce( SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-5].minor.yy0, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 4017 "sql.c" break; - case 284: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ -#line 887 "sql.y" + case 287: /* cmd ::= ALTER STABLE 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.yy516, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy430, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 4031 "sql.c" break; - case 285: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ -#line 898 "sql.y" + case 288: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy131, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } -#line 4040 "sql.c" break; - case 286: /* cmd ::= KILL CONNECTION INTEGER */ -#line 905 "sql.y" + case 289: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} -#line 4045 "sql.c" break; - case 287: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ -#line 906 "sql.y" + case 290: /* 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);} -#line 4050 "sql.c" break; - case 288: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ -#line 907 "sql.y" + case 291: /* 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);} -#line 4055 "sql.c" break; default: break; /********** End reduce actions ************************************************/ }; - assert( yyrulenostateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact, "... then shift"); - return yyact; } /* @@ -4084,8 +3328,7 @@ static YYACTIONTYPE yy_reduce( static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); @@ -4096,8 +3339,7 @@ static void yy_parse_failed( ** parser fails */ /************ Begin %parse_failure code ***************************************/ /************ End %parse_failure code *****************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } #endif /* YYNOERRORRECOVERY */ @@ -4109,11 +3351,9 @@ static void yy_syntax_error( int yymajor, /* The major type of the error token */ ParseTOKENTYPE yyminor /* The minor type of the error token */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ -#line 37 "sql.y" pInfo->valid = false; int32_t outputBufLen = tListLen(pInfo->msg); @@ -4136,10 +3376,8 @@ static void yy_syntax_error( } assert(len <= outputBufLen); -#line 4140 "sql.c" /************ End %syntax_error code ******************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* @@ -4148,8 +3386,7 @@ static void yy_syntax_error( static void yy_accept( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); @@ -4162,11 +3399,9 @@ static void yy_accept( /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ -#line 61 "sql.y" -#line 4167 "sql.c" + /*********** End %parse_accept code *******************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. @@ -4195,47 +3430,45 @@ void Parse( ParseARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; - YYACTIONTYPE yyact; /* The parser action. */ + unsigned int yyact; /* The parser action. */ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ #endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif - yyParser *yypParser = (yyParser*)yyp; /* The parser */ - ParseCTX_FETCH - ParseARG_STORE + yyParser *yypParser; /* The parser */ + yypParser = (yyParser*)yyp; assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); #endif + ParseARG_STORE; - yyact = yypParser->yytos->stateno; #ifndef NDEBUG if( yyTraceFILE ){ - if( yyact < YY_MIN_REDUCE ){ + int stateno = yypParser->yytos->stateno; + if( stateno < YY_MIN_REDUCE ){ fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", - yyTracePrompt,yyTokenName[yymajor],yyact); + yyTracePrompt,yyTokenName[yymajor],stateno); }else{ fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", - yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); + yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE); } } #endif do{ - assert( yyact==yypParser->yytos->stateno ); - yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); + yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); if( yyact >= YY_MIN_REDUCE ){ - yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, - yyminor ParseCTX_PARAM); + yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ - yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); + yy_shift(yypParser,yyact,yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; #endif - break; + yymajor = YYNOCODE; }else if( yyact==YY_ACCEPT_ACTION ){ yypParser->yytos--; yy_accept(yypParser); @@ -4286,9 +3519,10 @@ void Parse( yymajor = YYNOCODE; }else{ while( yypParser->yytos >= yypParser->yystack + && yymx != YYERRORSYMBOL && (yyact = yy_find_reduce_action( yypParser->yytos->stateno, - YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE + YYERRORSYMBOL)) >= YY_MIN_REDUCE ){ yy_pop_parser_stack(yypParser); } @@ -4305,8 +3539,6 @@ void Parse( } yypParser->yyerrcnt = 3; yyerrorhit = 1; - if( yymajor==YYNOCODE ) break; - yyact = yypParser->yytos->stateno; #elif defined(YYNOERRORRECOVERY) /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax @@ -4317,7 +3549,8 @@ void Parse( */ yy_syntax_error(yypParser,yymajor, yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - break; + yymajor = YYNOCODE; + #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** @@ -4339,10 +3572,10 @@ void Parse( yypParser->yyerrcnt = -1; #endif } - break; + yymajor = YYNOCODE; #endif } - }while( yypParser->yytos>yypParser->yystack ); + }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; @@ -4357,17 +3590,3 @@ void Parse( #endif return; } - -/* -** Return the fallback token corresponding to canonical token iToken, or -** 0 if iToken has no fallback. -*/ -int ParseFallback(int iToken){ -#ifdef YYFALLBACK - assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); - return yyFallback[iToken]; -#else - (void)iToken; - return 0; -#endif -} diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 71a9009c4581dae86861a67de850e275cae352f7..e3ad254bbb1a4ce0a3c504e9a799a109b7e1159a 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -3474,19 +3474,19 @@ void filterPrepare(void* expr, void* param) { if (pInfo->optr == TSDB_RELATION_IN) { int dummy = -1; - SHashObj *pObj = NULL; + SHashObj *pObj = NULL; if (pInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) { pObj = taosHashInit(256, taosGetDefaultHashFunction(pInfo->sch.type), true, false); SArray *arr = (SArray *)(pCond->arr); for (size_t i = 0; i < taosArrayGetSize(arr); i++) { char* p = taosArrayGetP(arr, i); - strtolower(varDataVal(p), varDataVal(p)); - taosHashPut(pObj, varDataVal(p),varDataLen(p), &dummy, sizeof(dummy)); + strntolower_s(varDataVal(p), varDataVal(p), varDataLen(p)); + taosHashPut(pObj, varDataVal(p), varDataLen(p), &dummy, sizeof(dummy)); } } else { buildFilterSetFromBinary((void **)&pObj, pCond->pz, pCond->nLen); } - pInfo->q = (char *)pObj; + pInfo->q = (char *)pObj; } else if (pCond != NULL) { uint32_t size = pCond->nLen * TSDB_NCHAR_SIZE; if (size < (uint32_t)pSchema->bytes) { diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index 7c8fd2ed8353a086ec9f145aaaa30f4db57113cb..6bcfb5de295c5719032b81c23d16ec2b1476349e 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -32,6 +32,7 @@ char * strnchr(char *haystack, char needle, int32_t len, bool skipquote); char ** strsplit(char *src, const char *delim, int32_t *num); char * strtolower(char *dst, const char *src); char * strntolower(char *dst, const char *src, int32_t n); +char * strntolower_s(char *dst, const char *src, int32_t n); int64_t strnatoi(char *num, int32_t len); char * strbetween(char *string, char *begin, char *end); char * paGetToken(char *src, char **token, int32_t *tokenLen); diff --git a/src/util/src/terror.c b/src/util/src/terror.c index 49e46cdde8f7689083b65f747df35a13318c4e46..311abe70df65f6090aa06b4857adb434f4d2f9a0 100644 --- a/src/util/src/terror.c +++ b/src/util/src/terror.c @@ -112,6 +112,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_EXCEED_SQL_LIMIT, "SQL statement too lon TAOS_DEFINE_ERROR(TSDB_CODE_TSC_FILE_EMPTY, "File is empty") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_LINE_SYNTAX_ERROR, "Syntax error in Line") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_META_CACHED, "No table meta cached") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DUP_COL_NAMES, "duplicated column names") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TAG_LENGTH, "Invalid tag length") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_COLUMN_LENGTH, "Invalid column length") // mnode TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, "Message not processed") @@ -194,6 +197,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_FUNC_ALREADY_EXIST, "Func already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_FUNC, "Invalid func") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_FUNC_BUFSIZE, "Invalid func bufSize") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TAG_LENGTH, "invalid tag length") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_COLUMN_LENGTH, "invalid column length") + TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_NOT_SELECTED, "Database not specified or available") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_ALREADY_EXIST, "Database already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB_OPTION, "Invalid database options") diff --git a/src/util/src/ttokenizer.c b/src/util/src/ttokenizer.c index c4d05b2d5a851ee4c2a8232095dd6ea5567213ab..2d4e3aa743a250b618d9c9e80ffa312af1feba12 100644 --- a/src/util/src/ttokenizer.c +++ b/src/util/src/ttokenizer.c @@ -137,6 +137,7 @@ static SKeyword keywordTable[] = { {"COMMA", TK_COMMA}, {"NULL", TK_NULL}, {"SELECT", TK_SELECT}, + {"EVERY", TK_EVERY}, {"FROM", TK_FROM}, {"VARIABLE", TK_VARIABLE}, {"INTERVAL", TK_INTERVAL}, diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index 7bcdb69cf2f786aba504c65d20a79fe7668770dc..5f8c92898fc5f0abc4c733c0558befd68ac3cac7 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -165,6 +165,8 @@ char *strnchr(char *haystack, char needle, int32_t len, bool skipquote) { return NULL; } + + char* strtolower(char *dst, const char *src) { int esc = 0; char quote = 0, *p = dst, c; @@ -200,7 +202,7 @@ char* strntolower(char *dst, const char *src, int32_t n) { if (n == 0) { *p = 0; return dst; - } + } for (c = *src++; n-- > 0; c = *src++) { if (esc) { esc = 0; @@ -222,6 +224,26 @@ char* strntolower(char *dst, const char *src, int32_t n) { return dst; } +char* strntolower_s(char *dst, const char *src, int32_t n) { + char *p = dst, c; + + assert(dst != NULL); + if (n == 0) { + return NULL; + } + + while (n-- > 0) { + c = *src; + if (c >= 'A' && c <= 'Z') { + c -= 'A' - 'a'; + } + *p++ = c; + src++; + } + + return dst; +} + char *paGetToken(char *string, char **token, int32_t *tokenLen) { char quote = 0; diff --git a/tests/examples/c/schemaless.c b/tests/examples/c/schemaless.c index 3ea199c9144950526e4bbf59b9356753e2a88da6..1a551cc5f7bd600ccaf87701953f7109743e8302 100644 --- a/tests/examples/c/schemaless.c +++ b/tests/examples/c/schemaless.c @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) { time_t ct = time(0); int64_t ts = ct * 1000; - char* lineFormat = "sta%d,t0=true,t1=127i8,t2=32767i16,t3=%di32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=255u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" %lldms"; + char* lineFormat = "sta%d,t0=true,t1=127i8,t2=32767i16,t3=%di32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=254u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" %lldms"; char** lines = calloc(numSuperTables * numChildTables * numRowsPerChildTable, sizeof(char*)); int l = 0; @@ -75,7 +75,7 @@ int main(int argc, char* argv[]) { } } } - shuffle(lines, numSuperTables * numChildTables * numRowsPerChildTable); + //shuffle(lines, numSuperTables * numChildTables * numRowsPerChildTable); printf("%s\n", "begin taos_insert_lines"); int64_t begin = getTimeInUs(); @@ -83,119 +83,5 @@ int main(int argc, char* argv[]) { int64_t end = getTimeInUs(); printf("code: %d, %s. time used: %"PRId64"\n", code, tstrerror(code), end-begin); - char* lines_000_0[] = { - "sta1,id=sta1_1,t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=255u8,t6=32770u16,t7=2147483699u32,t8=9223372036854775899u64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=255u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" 1626006833639000us" - }; - - code = taos_insert_lines(taos, lines_000_0 , sizeof(lines_000_0)/sizeof(char*)); - if (0 == code) { - printf("taos_insert_lines() lines_000_0 should return error\n"); - return -1; - } - - char* lines_000_1[] = { - "sta2,id=\"sta2_1\",t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=255u8,t6=32770u16,t7=2147483699u32,t8=9223372036854775899u64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=255u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" 1626006833639001" - }; - - code = taos_insert_lines(taos, lines_000_1 , sizeof(lines_000_1)/sizeof(char*)); - if (0 == code) { - printf("taos_insert_lines() lines_000_1 should return error\n"); - return -1; - } - - char* lines_000_2[] = { - "sta3,id=\"sta3_1\",t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=255u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" 0" - }; - - code = taos_insert_lines(taos, lines_000_2 , sizeof(lines_000_2)/sizeof(char*)); - if (0 != code) { - printf("taos_insert_lines() lines_000_2 return code:%d (%s)\n", code, (char*)tstrerror(code)); - return -1; - } - - char* lines_001_0[] = { - "sta4,t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" 1626006833639000us", - - }; - - code = taos_insert_lines(taos, lines_001_0 , sizeof(lines_001_0)/sizeof(char*)); - if (0 != code) { - printf("taos_insert_lines() lines_001_0 return code:%d (%s)\n", code, (char*)tstrerror(code)); - return -1; - } - - char* lines_001_1[] = { - "sta5,id=\"sta5_1\",t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" 1626006833639001" - }; - - code = taos_insert_lines(taos, lines_001_1 , sizeof(lines_001_1)/sizeof(char*)); - if (0 != code) { - printf("taos_insert_lines() lines_001_1 return code:%d (%s)\n", code, (char*)tstrerror(code)); - return -1; - } - - char* lines_001_2[] = { - "sta6,id=\"sta6_1\",t0=true,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c9=11.12345f32,c10=22.123456789f64,c11=\"binaryValue\",c12=L\"ncharValue\" 0" - }; - - code = taos_insert_lines(taos, lines_001_2 , sizeof(lines_001_2)/sizeof(char*)); - if (0 != code) { - printf("taos_insert_lines() lines_001_2 return code:%d (%s)\n", code, (char*)tstrerror(code)); - return -1; - } - - char* lines_002[] = { - "stb,id=\"stb_1\",t20=t,t21=T,t22=true,t23=True,t24=TRUE,t25=f,t26=F,t27=false,t28=False,t29=FALSE,t10=33.12345,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c20=t,c21=T,c22=true,c23=True,c24=TRUE,c25=f,c26=F,c27=false,c28=False,c29=FALSE,c10=33.12345,c11=\"binaryValue\",c12=L\"ncharValue\" 1626006833639000000ns", - "stc,id=\"stc_1\",t20=t,t21=T,t22=true,t23=True,t24=TRUE,t25=f,t26=F,t27=false,t28=False,t29=FALSE,t10=33.12345,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c20=t,c21=T,c22=true,c23=True,c24=TRUE,c25=f,c26=F,c27=false,c28=False,c29=FALSE,c10=33.12345,c11=\"binaryValue\",c12=L\"ncharValue\" 1626006833639019us", - "stc,id=\"stc_1\",t20=t,t21=T,t22=true,t23=True,t24=TRUE,t25=f,t26=F,t27=false,t28=False,t29=FALSE,t10=33.12345,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c20=t,c21=T,c22=true,c23=True,c24=TRUE,c25=f,c26=F,c27=false,c28=False,c29=FALSE,c10=33.12345,c11=\"binaryValue\",c12=L\"ncharValue\" 1626006833640ms", - "stc,id=\"stc_1\",t20=t,t21=T,t22=true,t23=True,t24=TRUE,t25=f,t26=F,t27=false,t28=False,t29=FALSE,t10=33.12345,t11=\"binaryTagValue\",t12=L\"ncharTagValue\" c20=t,c21=T,c22=true,c23=True,c24=TRUE,c25=f,c26=F,c27=false,c28=False,c29=FALSE,c10=33.12345,c11=\"binaryValue\",c12=L\"ncharValue\" 1626006834s" - }; - - code = taos_insert_lines(taos, lines_002 , sizeof(lines_002)/sizeof(char*)); - if (0 != code) { - printf("taos_insert_lines() lines_002 return code:%d (%s)\n", code, (char*)tstrerror(code)); - return -1; - } - - //Duplicate key check; - char* lines_003_1[] = { - "std,id=\"std_3_1\",t1=4i64,Id=\"std\",t2=true c1=true 1626006834s" - }; - - code = taos_insert_lines(taos, lines_003_1 , sizeof(lines_003_1)/sizeof(char*)); - if (0 == code) { - printf("taos_insert_lines() lines_003_1 return code:%d (%s)\n", code, (char*)tstrerror(code)); - return -1; - } - - char* lines_003_2[] = { - "std,id=\"std_3_2\",tag1=4i64,Tag2=true,tAg3=2,TaG2=\"dup!\" c1=true 1626006834s" - }; - - code = taos_insert_lines(taos, lines_003_2 , sizeof(lines_003_2)/sizeof(char*)); - if (0 == code) { - printf("taos_insert_lines() lines_003_2 return code:%d (%s)\n", code, (char*)tstrerror(code)); - return -1; - } - - char* lines_003_3[] = { - "std,id=\"std_3_3\",tag1=4i64 field1=true,Field2=2,FIElD1=\"dup!\",fIeLd4=true 1626006834s" - }; - - code = taos_insert_lines(taos, lines_003_3 , sizeof(lines_003_3)/sizeof(char*)); - if (0 == code) { - printf("taos_insert_lines() lines_003_3 return code:%d (%s)\n", code, (char*)tstrerror(code)); - return -1; - } - - char* lines_003_4[] = { - "std,id=\"std_3_4\",tag1=4i64,dupkey=4i16,tag2=T field1=true,dUpkEy=1e3f32,field2=\"1234\" 1626006834s" - }; - - code = taos_insert_lines(taos, lines_003_4 , sizeof(lines_003_4)/sizeof(char*)); - if (0 == code) { - printf("taos_insert_lines() lines_003_4 return code:%d (%s)\n", code, (char*)tstrerror(code)); - return -1; - } return 0; } diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index f1894966a240a0470a8ffad8cb2ec621b0c3b45c..886e2a365e26dca4912ad2b52a5cd01e5385faa6 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -172,6 +172,10 @@ python3 test.py -f tools/taosdemoTestSampleData.py python3 test.py -f tools/taosdemoTestInterlace.py python3 test.py -f tools/taosdemoTestQuery.py +# restful test for python +python3 test.py -f restful/restful_bind_db1.py +python3 test.py -f restful/restful_bind_db2.py + # nano support python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py python3 test.py -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py @@ -385,6 +389,7 @@ python3 ./test.py -f insert/schemalessInsert.py python3 ./test.py -f alter/alterColMultiTimes.py python3 ./test.py -f query/queryWildcardLength.py python3 ./test.py -f query/queryTbnameUpperLower.py +python3 ./test.py -f query/query.py #======================p4-end=============== diff --git a/tests/pytest/functions/function_interp.py b/tests/pytest/functions/function_interp.py index 41215f15ebea082c96ec54d86ad77db93b99461e..87d001d9e586fdfccb28e6fe9c8a04510d6f3fb1 100644 --- a/tests/pytest/functions/function_interp.py +++ b/tests/pytest/functions/function_interp.py @@ -57,15 +57,15 @@ class TDTestCase: tdSql.checkRows(0) tdSql.query("select interp(pav) from ap1 where ts = '2021-07-25 02:19:54' FILL (LINEAR)") tdSql.checkRows(0) - tdSql.query("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' INTERVAL(1000a) FILL (LINEAR)") + tdSql.query("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1000a) FILL (LINEAR)") tdSql.checkRows(6) - tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' INTERVAL(1000a) FILL (NEXT)") + tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1000a) FILL (NEXT)") tdSql.checkRows(6) tdSql.checkData(0,1,2.90799) - tdSql.query("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' INTERVAL(1000a) FILL (PREV)") + tdSql.query("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' every(1000a) FILL (PREV)") tdSql.checkRows(7) tdSql.checkData(1,1,1.47885) - tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' INTERVAL(1000a) FILL (LINEAR)") + tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' every(1000a) FILL (LINEAR)") tdSql.checkRows(7) # check desc order @@ -74,13 +74,13 @@ class TDTestCase: tdSql.checkRows(0) tdSql.query("select interp(pav) from ap1 where ts = '2021-07-25 02:19:54' FILL (LINEAR) order by ts desc") tdSql.checkRows(0) - tdSql.query("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' INTERVAL(1000a) FILL (LINEAR) order by ts desc") + tdSql.query("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1000a) FILL (LINEAR) order by ts desc") tdSql.checkRows(6) - tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' INTERVAL(1000a) FILL (NEXT) order by ts desc") + tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1000a) FILL (NEXT) order by ts desc") tdSql.checkRows(6) tdSql.checkData(0,1,4.60900) - tdSql.error("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' INTERVAL(1000a) FILL (PREV) order by ts desc") - tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' INTERVAL(1000a) FILL (LINEAR) order by ts desc") + tdSql.error("select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' every(1000a) FILL (PREV) order by ts desc") + tdSql.query("select interp(pav) from ap1 where ts>= '2021-07-25 02:19:54' and ts <= '2021-07-25 02:20:00' every(1000a) FILL (LINEAR) order by ts desc") tdSql.checkRows(7) # check exception @@ -88,7 +88,7 @@ class TDTestCase: tdSql.error("select interp(*) from ap1 FILL(NEXT)") tdSql.error("select interp(*) from ap1 ts >= '2021-07-25 02:19:54' FILL(NEXT)") tdSql.error("select interp(*) from ap1 ts <= '2021-07-25 02:19:54' FILL(NEXT)") - tdSql.error("select interp(*) from ap1 where ts >'2021-07-25 02:19:59.938' and ts < now interval(1s) fill(next)") + tdSql.error("select interp(*) from ap1 where ts >'2021-07-25 02:19:59.938' and ts < now every(1s) fill(next)") def stop(self): tdSql.close() diff --git a/tests/pytest/query/last_row_cache.py b/tests/pytest/query/last_row_cache.py index 83153841496b9ef4e0b7d919b44cf0a9e05b02c6..0e11e3d60c08362c0114166dcf071990893689f8 100644 --- a/tests/pytest/query/last_row_cache.py +++ b/tests/pytest/query/last_row_cache.py @@ -25,7 +25,7 @@ class TDTestCase: self.tables = 10 self.rows = 20 - self.columns = 5 + self.columns = 100 self.perfix = 't' self.ts = 1601481600000 @@ -33,8 +33,8 @@ class TDTestCase: print("==============step1") sql = "create table st(ts timestamp, " for i in range(self.columns - 1): - sql += "c%d int, " % (i + 1) - sql += "c5 int) tags(t1 int)" + sql += "c%d bigint, " % (i + 1) + sql += "c100 bigint) tags(t1 int)" tdSql.execute(sql) for i in range(self.tables): diff --git a/tests/pytest/query/query.py b/tests/pytest/query/query.py index 8cec38780e5e873cb07d8ade45ef56b5d4ee43f7..c759e7766827e9b8e30f1b9ceb812c755fb057ae 100644 --- a/tests/pytest/query/query.py +++ b/tests/pytest/query/query.py @@ -25,6 +25,18 @@ class TDTestCase: self.ts = 1538548685000 + def bug_6387(self): + tdSql.execute("create database bug6387 ") + tdSql.execute("use bug6387 ") + tdSql.execute("create table test(ts timestamp, c1 int) tags(t1 int)") + for i in range(5000): + sql = "insert into t%d using test tags(1) values " % i + for j in range(21): + sql = sql + "(now+%ds,%d)" % (j ,j ) + tdSql.execute(sql) + tdSql.query("select count(*) from test interval(1s) group by tbname") + tdSql.checkData(0,1,1) + def run(self): tdSql.prepare() @@ -121,6 +133,9 @@ class TDTestCase: tdSql.query("select * from tb0") tdSql.checkRows(1) + + #For jira: https://jira.taosdata.com:18080/browse/TD-6387 + self.bug_6387() def stop(self): diff --git a/tests/pytest/query/queryDiffColsOr.py b/tests/pytest/query/queryDiffColsOr.py new file mode 100644 index 0000000000000000000000000000000000000000..feeab84a7ec577c9b48f19416400bcc7b348d543 --- /dev/null +++ b/tests/pytest/query/queryDiffColsOr.py @@ -0,0 +1,545 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from copy import deepcopy +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.common import tdCom + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def insertData(self, tb_name): + insert_sql_list = [f'insert into {tb_name} values ("2021-01-01 12:00:00", 1, 1, 1, 3, 1.1, 1.1, "binary", "nchar", true, 1)', + f'insert into {tb_name} values ("2021-01-05 12:00:00", 2, 2, 1, 3, 1.1, 1.1, "binary", "nchar", true, 2)', + f'insert into {tb_name} values ("2021-01-07 12:00:00", 1, 3, 1, 2, 1.1, 1.1, "binary", "nchar", true, 3)', + f'insert into {tb_name} values ("2021-01-09 12:00:00", 1, 2, 4, 3, 1.1, 1.1, "binary", "nchar", true, 4)', + f'insert into {tb_name} values ("2021-01-11 12:00:00", 1, 2, 5, 5, 1.1, 1.1, "binary", "nchar", true, 5)', + f'insert into {tb_name} values ("2021-01-13 12:00:00", 1, 2, 1, 3, 6.6, 1.1, "binary", "nchar", true, 6)', + f'insert into {tb_name} values ("2021-01-15 12:00:00", 1, 2, 1, 3, 1.1, 7.7, "binary", "nchar", true, 7)', + f'insert into {tb_name} values ("2021-01-17 12:00:00", 1, 2, 1, 3, 1.1, 1.1, "binary8", "nchar", true, 8)', + f'insert into {tb_name} values ("2021-01-19 12:00:00", 1, 2, 1, 3, 1.1, 1.1, "binary", "nchar9", true, 9)', + f'insert into {tb_name} values ("2021-01-21 12:00:00", 1, 2, 1, 3, 1.1, 1.1, "binary", "nchar", false, 10)', + f'insert into {tb_name} values ("2021-01-23 12:00:00", 1, 3, 1, 3, 1.1, 1.1, Null, Null, false, 11)' + ] + for sql in insert_sql_list: + tdSql.execute(sql) + + def initTb(self): + tdCom.cleanTb() + tb_name = tdCom.getLongName(8, "letters") + tdSql.execute( + f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 int)") + self.insertData(tb_name) + return tb_name + + def initStb(self): + tdCom.cleanTb() + tb_name = tdCom.getLongName(8, "letters") + tdSql.execute( + f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 int) tags (t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 binary(100), t8 nchar(200), t9 bool, t10 int)") + tdSql.execute( + f'CREATE TABLE {tb_name}_sub using {tb_name} tags (1, 1, 1, 3, 1.1, 1.1, "binary", "nchar", true, 1)') + self.insertData(f'{tb_name}_sub') + return tb_name + + def queryLastC10(self, query_sql, multi=False): + if multi: + res = tdSql.query(query_sql.replace('c10', 'last(*)'), True) + else: + res = tdSql.query(query_sql.replace('*', 'last(*)'), True) + return int(res[0][-1]) + + def queryFullColType(self, tb_name): + ## ts + query_sql = f'select * from {tb_name} where ts > "2021-01-11 12:00:00" or ts < "2021-01-13 12:00:00"' + tdSql.query(query_sql) + tdSql.checkRows(11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## != or + query_sql = f'select * from {tb_name} where c1 != 1 or c2 = 3' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## <> or + query_sql = f'select * from {tb_name} where c1 <> 1 or c3 = 3' + tdSql.query(query_sql) + tdSql.checkRows(1) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) + + ## >= or + query_sql = f'select * from {tb_name} where c1 >= 2 or c3 = 4' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) + + ## <= or + query_sql = f'select * from {tb_name} where c1 <= 1 or c3 = 4' + tdSql.query(query_sql) + tdSql.checkRows(10) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## <> or is Null + query_sql = f'select * from {tb_name} where c1 <> 1 or c7 is Null' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## > or is not Null + query_sql = f'select * from {tb_name} where c2 > 2 or c8 is not Null' + tdSql.query(query_sql) + tdSql.checkRows(11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## > or < or >= or <= or != or <> or = Null + query_sql = f'select * from {tb_name} where c1 > 1 or c2 < 2 or c3 >= 4 or c4 <= 2 or c5 != 1.1 or c6 <> 1.1 or c7 is Null' + tdSql.query(query_sql) + tdSql.checkRows(8) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## tiny small int big or + query_sql = f'select * from {tb_name} where c1 = 2 or c2 = 3 or c3 = 4 or c4 = 5' + tdSql.query(query_sql) + tdSql.checkRows(5) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## float double binary nchar bool or + query_sql = f'select * from {tb_name} where c5=6.6 or c6=7.7 or c7="binary8" or c8="nchar9" or c9=false' + tdSql.query(query_sql) + tdSql.checkRows(6) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## all types or + query_sql = f'select * from {tb_name} where c1=2 or c2=3 or c3=4 or c4=5 or c5=6.6 or c6=7.7 or c7="binary8" or c8="nchar9" or c9=false' + tdSql.query(query_sql) + tdSql.checkRows(10) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + def queryMultiExpression(self, tb_name): + ## condition_A and condition_B or condition_C (> < >=) + query_sql = f'select * from {tb_name} where c1 > 2 and c2 < 4 or c3 >= 4' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + ## (condition_A and condition_B) or condition_C (<= != <>) + query_sql = f'select * from {tb_name} where (c1 <= 1 and c2 != 2) or c4 <> 3' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## condition_A and (condition_B or condition_C) (Null not Null) + query_sql = f'select * from {tb_name} where c1 is not Null and (c6 = 7.7 or c8 is Null)' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## condition_A or condition_B and condition_C (> < >=) + query_sql = f'select * from {tb_name} where c1 > 2 or c2 < 4 and c3 >= 4' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + ## (condition_A or condition_B) and condition_C (<= != <>) + query_sql = f'select * from {tb_name} where (c1 <= 1 or c2 != 2) and c4 <> 3' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + ## condition_A or (condition_B and condition_C) (Null not Null) + query_sql = f'select * from {tb_name} where c6 >= 7.7 or (c1 is not Null and c3 =5)' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) + + ## condition_A or (condition_B and condition_C) or condition_D (> != < Null) + query_sql = f'select * from {tb_name} where c1 != 1 or (c2 >2 and c3 < 1) or c7 is Null' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## condition_A and (condition_B or condition_C) and condition_D (>= = <= not Null) + query_sql = f'select * from {tb_name} where c4 >= 4 and (c1 = 2 or c5 <= 1.1) and c7 is not Null' + tdSql.query(query_sql) + tdSql.checkRows(1) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + ## (condition_A and condition_B) or (condition_C or condition_D) (Null >= > =) + query_sql = f'select * from {tb_name} where (c8 is Null and c1 >= 1) or (c3 > 3 or c4 =2)' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## (condition_A or condition_B) or condition_C or (condition_D and condition_E) (>= <= = not Null <>) + query_sql = f'select * from {tb_name} where (c1 >= 2 or c2 <= 1) or c3 = 4 or (c7 is not Null and c6 <> 1.1)' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) + + ## condition_A or (condition_B and condition_C) or (condition_D and condition_E) and condition_F + query_sql = f'select * from {tb_name} where c1 != 1 or (c2 <= 1 and c3 <4) or (c3 >= 4 or c7 is not Null) and c9 <> true' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## (condition_A or (condition_B and condition_C) or (condition_D and condition_E)) and condition_F + query_sql = f'select * from {tb_name} where (c1 != 1 or (c2 <= 2 and c3 >= 4) or (c3 >= 4 or c7 is not Null)) and c9 != false' + tdSql.query(query_sql) + tdSql.checkRows(9) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + ## (condition_A or condition_B) or (condition_C or condition_D) and (condition_E or condition_F or condition_G) + query_sql = f'select * from {tb_name} where c1 != 1 or (c2 <= 3 and c3 > 4) and c3 <= 5 and (c7 is not Null and c9 != false)' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) + + def queryMultiIn(self, tb_name): + ## in and in + query_sql = f'select * from {tb_name} where c7 in ("binary") and c8 in ("nchar")' + tdSql.query(query_sql) + tdSql.checkRows(8) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## in or in + query_sql = f'select * from {tb_name} where c1 in (2, 4) or c2 in (1, 4)' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) + + ## in and in or condition_A + query_sql = f'select * from {tb_name} where c7 in ("binary") and c8 in ("nchar") or c10 != 10' + tdSql.query(query_sql) + tdSql.checkRows(11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## in or in and condition_A + query_sql = f'select * from {tb_name} where c7 in ("binary") or c8 in ("nchar") and c10 != 10' + tdSql.query(query_sql) + tdSql.checkRows(10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## in or in or condition_A + query_sql = f'select * from {tb_name} where c1 in (2, 4) or c2 in (3, 4) or c9 != true' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## in or in or in or in + query_sql = f'select * from {tb_name} where c1 in (2, 4) or c2 in (3, 4) or c9 in (false) or c10 in (5, 6 ,22)' + tdSql.query(query_sql) + tdSql.checkRows(6) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## in or in and in or in + query_sql = f'select * from {tb_name} where c1 in (2, 4) or c2 in (3, 4) and c9 in (false) or c10 in (5, 6 ,22)' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## condition_A or in or condition_B and in + query_sql = f'select * from {tb_name} where c1 = 2 or c2 in (2, 4) and c9 = false or c10 in (6 ,22)' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## in and condition_A or in and in and condition_B + query_sql = f'select * from {tb_name} where c1 in (2, 3) and c2 <> 3 or c10 <= 4 and c10 in (4 ,22) and c9 != false' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) + + ## (in and condition_A or in) and in and condition_B + query_sql = f'select * from {tb_name} where (c1 in (2, 3) and c2 <> 3 or c10 <= 4) and c10 in (4 ,22) and c9 != false' + tdSql.query(query_sql) + tdSql.checkRows(1) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) + + def queryMultiLike(self, tb_name): + ## like and like + query_sql = f'select * from {tb_name} where c7 like "bi%" and c8 like ("ncha_")' + tdSql.query(query_sql) + tdSql.checkRows(9) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## like or like + query_sql = f'select * from {tb_name} where c7 like "binar12345" or c8 like "nchar_"' + tdSql.query(query_sql) + tdSql.checkRows(1) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + ## like and like or condition_A + query_sql = f'select * from {tb_name} where c7 like "binary_" and c8 like "ncha_" or c1 != 1' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) + + ## like or like and condition_A + query_sql = f'select * from {tb_name} where c7 like ("binar_") or c8 like ("nchar_") and c10 != 8' + tdSql.query(query_sql) + tdSql.checkRows(9) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) + + ## like or like or condition_A + query_sql = f'select * from {tb_name} where c7 like ("binary_") or c8 like ("nchar_") or c10 = 6' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + ## like or like or like or like + query_sql = f'select * from {tb_name} where c7 like ("binary_") or c8 like ("nchar_") or c10 = 6 or c7 is Null' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) + + ## like or like and like or like + query_sql = f'select * from {tb_name} where c7 like ("binary_") or c8 like ("ncha_") and c10 = 6 or c10 = 9' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + ## condition_A or like or condition_B and like + query_sql = f'select * from {tb_name} where c1 = 2 or c7 like "binary_" or c10 = 3 and c8 like "ncha%"' + tdSql.query(query_sql) + tdSql.checkRows(3) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) + + ## like and condition_A or like and like and condition_B + query_sql = f'select * from {tb_name} where c7 like "bin%" and c2 = 3 or c10 <= 4 and c7 like "binar_" and c8 like "ncha_"' + tdSql.query(query_sql) + tdSql.checkRows(4) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) + + ## (like and condition_A or like) and like and condition_B + query_sql = f'select * from {tb_name} where (c7 like "bin%" and c2 = 3 or c8 like "nchar_") and c7 like "binar_" and c9 != false' + tdSql.query(query_sql) + tdSql.checkRows(2) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) + + def queryPreCal(self, tb_name): + ## avg sum condition_A or condition_B + query_sql = f'select avg(c3), sum(c3) from {tb_name} where c10 = 5 or c8 is Null' + res = tdSql.query(query_sql, True)[0] + tdSql.checkEqual(int(res[0]), 3) + tdSql.checkEqual(int(res[1]), 6) + + ## avg sum condition_A or condition_B or condition_C + query_sql = f'select avg(c3), sum(c3) from {tb_name} where c10 = 4 or c8 is Null or c9 = false ' + res = tdSql.query(query_sql, True)[0] + tdSql.checkEqual(int(res[0]), 2) + tdSql.checkEqual(int(res[1]), 6) + + ## count avg sum condition_A or condition_B or condition_C interval + query_sql = f'select count(*), avg(c3), sum(c3) from {tb_name} where c10 = 4 or c8 is Null or c9 = false interval(16d)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(2) + tdSql.checkEqual(int(res[0][1]), 1) + tdSql.checkEqual(int(res[0][2]), 4) + tdSql.checkEqual(int(res[0][3]), 4) + tdSql.checkEqual(int(res[1][1]), 2) + tdSql.checkEqual(int(res[1][2]), 1) + tdSql.checkEqual(int(res[1][3]), 2) + + ## count avg sum condition_A or condition_B or in and like or condition_C interval + query_sql = f'select count(*), sum(c3) from {tb_name} where c10 = 4 or c8 is Null or c2 in (1, 2) and c7 like "binary_" or c1 <> 1 interval(16d)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(2) + tdSql.checkEqual(int(res[0][1]), 2) + tdSql.checkEqual(int(res[0][2]), 5) + tdSql.checkEqual(int(res[1][1]), 2) + tdSql.checkEqual(int(res[1][2]), 2) + + def queryMultiTb(self, tb_name): + ## select from (condition_A or condition_B) + query_sql = f'select c10 from (select * from {tb_name} where c1 >1 or c2 >=3)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(3) + tdSql.checkEqual(int(res[2][0]), 11) + + ## select from (condition_A or condition_B) where condition_A or condition_B + query_sql = f'select c10 from (select * from {tb_name} where c1 >1 or c2 >=3) where c1 =2 or c4 = 2' + res = tdSql.query(query_sql, True) + tdSql.checkRows(2) + tdSql.checkEqual(int(res[1][0]), 3) + + ## select from (condition_A or condition_B and like and in) where condition_A or condition_B or like and in + query_sql = f'select c10 from (select * from {tb_name} where c1 >1 or c2 = 2 and c7 like "binar_" and c4 in (3, 5)) where c1 != 2 or c3 = 1 or c8 like "ncha_" and c9 in (true)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(7) + tdSql.checkEqual(int(res[6][0]), 10) + + ## select count avg sum from (condition_A or condition_B and like and in) where condition_A or condition_B or like and in interval + query_sql = f'select count(*), avg(c6), sum(c3) from (select * from {tb_name} where c1 >1 or c2 = 2 and c7 like "binar_" and c4 in (3, 5)) where c1 != 2 or c3 = 1 or c8 like "ncha_" and c9 in (true) interval(8d)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(3) + tdSql.checkEqual(int(res[0][1]), 3) + tdSql.checkEqual(int(res[0][2]), 1) + tdSql.checkEqual(int(res[0][3]), 10) + tdSql.checkEqual(int(res[1][1]), 3) + tdSql.checkEqual(int(res[1][2]), 3) + tdSql.checkEqual(int(res[1][3]), 3) + tdSql.checkEqual(int(res[2][1]), 1) + tdSql.checkEqual(int(res[2][2]), 1) + tdSql.checkEqual(int(res[2][3]), 1) + + ## cname + query_sql = f'select c10 from (select * from {tb_name} where c1 >1 or c2 = 2 and c7 like "binar_" and c4 in (3, 5)) a where a.c1 != 2 or a.c3 = 1 or a.c8 like "ncha_" and a.c9 in (true)' + res = tdSql.query(query_sql, True) + tdSql.checkRows(7) + tdSql.checkEqual(int(res[6][0]), 10) + + ## multi cname + query_sql = f'select b.c10 from (select * from {tb_name} where c9 = true or c2 = 2) a, (select * from {tb_name} where c7 like "binar_" or c4 in (3, 5)) b where a.ts = b.ts' + res = tdSql.query(query_sql, True) + tdSql.checkRows(10) + tdSql.checkEqual(int(res[9][0]), 10) + + def checkTbColTypeOperator(self): + ''' + Ordinary table full column type and operator + ''' + tb_name = self.initTb() + self.queryFullColType(tb_name) + + def checkStbColTypeOperator(self): + ''' + Super table full column type and operator + ''' + tb_name = self.initStb() + self.queryFullColType(tb_name) + + def checkTbMultiExpression(self): + ''' + Ordinary table multiExpression + ''' + tb_name = self.initTb() + self.queryMultiExpression(tb_name) + + def checkStbMultiExpression(self): + ''' + Super table multiExpression + ''' + tb_name = self.initStb() + self.queryMultiExpression(tb_name) + + def checkTbMultiIn(self): + ''' + Ordinary table multiIn + ''' + tb_name = self.initTb() + self.queryMultiIn(tb_name) + + def checkStbMultiIn(self): + ''' + Super table multiIn + ''' + tb_name = self.initStb() + self.queryMultiIn(tb_name) + + def checkTbMultiLike(self): + ''' + Ordinary table multiLike + ''' + tb_name = self.initTb() + self.queryMultiLike(tb_name) + + def checkStbMultiLike(self): + ''' + Super table multiLike + ''' + tb_name = self.initStb() + self.queryMultiLike(tb_name) + + def checkTbPreCal(self): + ''' + Ordinary table precal + ''' + tb_name = self.initTb() + self.queryPreCal(tb_name) + + def checkStbPreCal(self): + ''' + Super table precal + ''' + tb_name = self.initStb() + self.queryPreCal(tb_name) + + def checkMultiTb(self): + ''' + test "or" in multi ordinary table + ''' + tb_name = self.initTb() + self.queryMultiTb(tb_name) + + def checkMultiStb(self): + ''' + test "or" in multi super table + ''' + tb_name = self.initStb() + self.queryMultiTb(tb_name) + + + # tb_name1 = tdCom.getLongName(8, "letters") + # tb_name2 = tdCom.getLongName(8, "letters") + # tb_name3 = tdCom.getLongName(8, "letters") + # tdSql.execute( + # f"CREATE TABLE {tb_name1} (ts timestamp, c1 tinyint, c2 smallint, c3 int)") + # tdSql.execute( + # f"CREATE TABLE {tb_name2} (ts timestamp, c1 tinyint, c2 smallint, c3 int)") + # tdSql.execute( + # f"CREATE TABLE {tb_name3} (ts timestamp, c1 tinyint, c2 smallint, c3 int)") + # insert_sql_list = [f'insert into {tb_name1} values ("2021-01-01 12:00:00", 1, 5, 1)', + # f'insert into {tb_name1} values ("2021-01-03 12:00:00", 2, 4, 1)', + # f'insert into {tb_name1} values ("2021-01-05 12:00:00", 3, 2, 1)', + # f'insert into {tb_name2} values ("2021-01-01 12:00:00", 4, 2, 1)', + # f'insert into {tb_name2} values ("2021-01-02 12:00:00", 5, 1, 1)', + # f'insert into {tb_name2} values ("2021-01-04 12:00:00", 1, 2, 1)', + # f'insert into {tb_name3} values ("2021-01-02 12:00:00", 4, 2, 1)', + # f'insert into {tb_name3} values ("2021-01-06 12:00:00", 5, 1, 1)', + # f'insert into {tb_name3} values ("2021-01-07 12:00:00", 1, 2, 1)', + # ] + # for sql in insert_sql_list: + # tdSql.execute(sql) + # tdSql.query( + # f'select * from {tb_name1} t1, {tb_name2}, {tb_name3} t3 t2 where (t1.ts=t2.ts or t2.ts=t3.ts)') + # tdSql.checkRows(4) + + + def run(self): + tdSql.prepare() + self.checkTbColTypeOperator() + self.checkStbColTypeOperator() + self.checkTbMultiExpression() + self.checkStbMultiExpression() + self.checkTbMultiIn() + self.checkStbMultiIn() + self.checkTbMultiLike() + self.checkStbMultiLike() + self.checkTbPreCal() + self.checkStbPreCal() + self.checkMultiTb() + self.checkMultiStb() + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/queryLike.py b/tests/pytest/query/queryLike.py index 3c3b030f8f718371867f323f2496fb17b6b962e1..2bcd5906a8eaa505e1702cefce7f8b2594f53f43 100644 --- a/tests/pytest/query/queryLike.py +++ b/tests/pytest/query/queryLike.py @@ -17,7 +17,6 @@ from util.log import * from util.cases import * from util.sql import * - class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) @@ -25,7 +24,8 @@ class TDTestCase: def run(self): tdSql.prepare() - + tdSql.execute("drop database db ") + tdSql.execute("create database if not exists db ") tdSql.execute("create table cars(ts timestamp, c nchar(2)) tags(t1 nchar(2))") tdSql.execute("insert into car0 using cars tags('aa') values(now, 'bb');") tdSql.query("select count(*) from cars where t1 like '%50 90 30 04 00 00%'") @@ -35,6 +35,132 @@ class TDTestCase: tdSql.execute("insert into car1 using test_cars tags('150 90 30 04 00 002') values(now, 'bb');") tdSql.query("select * from test_cars where t1 like '%50 90 30 04 00 00%'") tdSql.checkRows(1) + + tdSql.execute("create stable st (ts timestamp , id int , name binary(20), data double ) tags (ind int , tagg binary(20)) ") + + # check escape about tbname by show tables like + + tdSql.execute("create table tb_ using st tags (1 , 'tag_' ) ") + tdSql.execute("insert into tb_ values( now , 1 , 'tbname_' , 1.0)") + tdSql.execute("create table tba using st tags (1 , 'taga' ) ") + tdSql.execute("insert into tba values( now , 1 , 'tbnamea' , 1.0)") + tdSql.query("show tables like 'tb_'") + tdSql.checkRows(2) + tdSql.query("show tables like 'tb\_'") + tdSql.checkRows(1) + + # check escape about tbname by show tables like + tdSql.query("select * from st where tbname like 'tb\_'") + tdSql.checkRows(1) + + # check escape about regular cols + tdSql.query("select * from st where name like 'tbname\_';") + tdSql.checkRows(1) + + # check escape about tags + tdSql.query("select * from st where tagg like 'tag\_';") + tdSql.checkRows(1) + + # ======================= check multi escape =================== + + tdSql.execute("create table tb_1 using st tags (1 , 'tag_1' ) ") + tdSql.execute("insert into tb_1 values( now , 1 , 'tbname_1' , 1.0)") + tdSql.execute("create table tb_2 using st tags (2 , 'tag_2' )") + tdSql.execute("insert into tb_2 values( now , 2 , 'tbname_2' , 2.0)") + tdSql.execute("create table tb__ using st tags (3 , 'tag__' )") + tdSql.execute("insert into tb__ values( now , 3 , 'tbname__' , 2.0)") + tdSql.execute("create table tb__1 using st tags (3 , 'tag__1' )") + tdSql.execute("insert into tb__1 values( now , 1 , 'tbname__1' , 1.0)") + tdSql.execute("create table tb__2 using st tags (4 , 'tag__2' )") + tdSql.execute("create table tb___ using st tags (5 , 'tag___' )") + tdSql.execute("insert into tb___ values( now , 1 , 'tbname___' , 1.0)") + tdSql.execute("create table tb_d_ using st tags (5 , 'tag_d_' )") + tdSql.execute("insert into tb_d_ values( now , 1 , 'tbname_d_' , 1.0)") + + tdSql.execute("create table tb_d__ using st tags (5 , 'tag_d__' )") + tdSql.execute("insert into tb_d__ values( now , 1 , 'tbname_d__' , 1.0)") + tdSql.execute("create table tb____ using st tags (5 , 'tag____' )") + tdSql.execute("insert into tb____ values( now , 1 , 'tbname____' , 1.0)") + tdSql.execute("create table tb__a_ using st tags (5 , 'tag__a_' )") + tdSql.execute("insert into tb__a_ values( now , 1 , 'tbname__a_' , 1.0)") + tdSql.execute("create table tb__ab__ using st tags (5 , 'tag__ab__' )") + tdSql.execute("insert into tb__ab__ values( now , 1 , 'tbname__ab__' , 1.0)") + + # check escape about tbname by show tables like + tdSql.query("select * from st where tbname like 'tb__'") + tdSql.checkRows(3) + tdSql.query("select * from st where tbname like 'tb_\_'") + tdSql.checkRows(1) + tdSql.query("select * from st where tbname like 'tb___'") + tdSql.checkRows(4) + tdSql.query("select * from st where tbname like 'tb_\__'") + tdSql.checkRows(3) + tdSql.query("select * from st where tbname like 'tb_\_\_'") + tdSql.checkRows(1) + tdSql.query("select * from st where tbname like 'tb\__\_'") + tdSql.checkRows(1) + tdSql.query("select * from st where tbname like 'tb\__\__'") + tdSql.checkRows(2) + tdSql.query("select * from st where tbname like 'tb\__\_\_'") + tdSql.checkRows(2) + tdSql.query("select * from st where tbname like 'tb\____'") + tdSql.checkRows(3) + tdSql.query("select * from st where tbname like 'tb\_\__\_'") + tdSql.checkRows(2) + tdSql.query("select * from st where tbname like 'tb\_\_\_\_'") + tdSql.checkRows(1) + + # check escape about regular cols + tdSql.query("select * from st where name like 'tbname\_\_';") + tdSql.checkRows(1) + tdSql.query("select * from st where name like 'tbname\__';") + tdSql.checkRows(3) + tdSql.query("select * from st where name like 'tbname___';") + tdSql.checkRows(4) + tdSql.query("select * from st where name like 'tbname_\__';") + tdSql.checkRows(3) + tdSql.query("select * from st where name like 'tbname_\_\_';") + tdSql.checkRows(1) + tdSql.query("select * from st where name like 'tbname\_\__';") + tdSql.checkRows(2) + tdSql.query("select * from st where name like 'tbname____';") + tdSql.checkRows(3) + tdSql.query("select * from st where name like 'tbname\_\___';") + tdSql.checkRows(2) + tdSql.query("select * from st where name like 'tbname\_\_\__';") + tdSql.checkRows(1) + tdSql.query("select * from st where name like 'tbname\_\__\_';") + tdSql.checkRows(2) + tdSql.query("select name from st where name like 'tbname\_\_\__';") + tdSql.checkData(0,0 "tbname____") + + # check escape about tags + tdSql.query("select * from st where tagg like 'tag\_';") + tdSql.checkRows(1) + tdSql.query("select * from st where tagg like 'tag\_\_';") + tdSql.checkRows(1) + tdSql.query("select * from st where tagg like 'tag\__';") + tdSql.checkRows(3) + tdSql.query("select * from st where tagg like 'tag___';") + tdSql.checkRows(4) + tdSql.query("select * from st where tagg like 'tag_\__';") + tdSql.checkRows(3) + tdSql.query("select * from st where tagg like 'tag_\_\_';") + tdSql.checkRows(1) + tdSql.query("select * from st where tagg like 'tag\_\__';") + tdSql.checkRows(2) + tdSql.query("select * from st where tagg like 'tag____';") + tdSql.checkRows(3) + tdSql.query("select * from st where tagg like 'tag\_\___';") + tdSql.checkRows(2) + tdSql.query("select * from st where tagg like 'tag\_\_\__';") + tdSql.checkRows(1) + tdSql.query("select * from st where tagg like 'tag\_\__\_';") + tdSql.checkRows(2) + tdSql.query("select * from st where tagg like 'tag\_\__\_';") + tdSql.checkData(0,0 "tag__a_") + + os.system("rm -rf ./*.py.sql") def stop(self): tdSql.close() diff --git a/tests/pytest/restful/restful_bind_db1.py b/tests/pytest/restful/restful_bind_db1.py new file mode 100644 index 0000000000000000000000000000000000000000..9620535fd7c9388d08d0ebae9237b243fc0a099c --- /dev/null +++ b/tests/pytest/restful/restful_bind_db1.py @@ -0,0 +1,123 @@ +# ################################################################# +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. + +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao + +# ################################################################# + +# -*- coding: utf-8 -*- + +# TODO: after TD-4518 and TD-4510 is resolved, add the exception test case for these situations + +from distutils.log import error +import sys + +from requests.api import head +from requests.models import Response +from util.log import * +from util.cases import * +from util.sql import * +import time, datetime +import requests, json +import threading +import string +import random + + +def check_unbind_db(url, data, header): + resp = requests.post(url, data, headers = header ) + resp.encoding='utf-8' + resp = eval(resp.text) + status = resp['status'] + desc = resp['desc'] + sqls = data + if status=="error" and desc == "invalid url format": + print(" %s : check pass" %sqls) + else: + printf(" error occured , ") + sys.exit() + +def check_bind_db(url, data, header): + resp = requests.post(url, data, headers = header ) + resp.encoding='utf-8' + resp_dict = eval(resp.text) + status = resp_dict['status'] + if status =="succ": + print("%s run success!"%data) + # print(resp.text) + else : + print("%s run failed !"%data) + print(resp.text) + sys.exit() + +class TDTestCase(): + updatecfgDict={'httpDbNameMandatory':1} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists test') + tdSql.execute('drop database if exists db') + tdSql.execute('drop database if exists des') + tdSql.execute('create database test') + tdSql.execute('create database des') + + header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + url = "http://127.0.0.1:6041/rest/sql/" + + # test with no bind databases + + sqls = ["show databases;", + "use test", + "show tables;", + "show dnodes;", + "show vgroups;", + "create database db;", + "drop database db;", + "select client_version();" , + "use test", + "ALTER DATABASE test COMP 2;", + "create table tb (ts timestamp, id int , data double)", + "insert into tb values (now , 1, 1.0) ", + "select * from tb", + "show test.tables", + "show tables", + "insert into tb values (now , 2, 2.0) ", + "create table test.tb (ts timestamp, id int , data double)", + "insert into test.tb values (now , 2, 2.0) ", + "select * from tb", + "select * from test.tb"] + + for sql in sqls: + print("===================") + check_unbind_db(url,sql,header) + + print("==================="*5) + print(" check bind db about restful ") + print("==================="*5) + url = "http://127.0.0.1:6041/rest/sql/des" + for sql in sqls: + print("===================") + check_bind_db(url,sql,header) + # check data + tdSql.query("select * from test.tb") + tdSql.checkRows(1) + tdSql.query("select * from des.tb") + tdSql.checkRows(2) + + os.system('sudo timedatectl set-ntp on') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/restful/restful_bind_db2.py b/tests/pytest/restful/restful_bind_db2.py new file mode 100644 index 0000000000000000000000000000000000000000..35aa1408a7690798d66bc0303e64fe4843dab0d8 --- /dev/null +++ b/tests/pytest/restful/restful_bind_db2.py @@ -0,0 +1,133 @@ +# ################################################################# +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. + +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao + +# ################################################################# + +# -*- coding: utf-8 -*- + +# TODO: after TD-4518 and TD-4510 is resolved, add the exception test case for these situations + +from distutils.log import error +import sys + +from requests.api import head +from requests.models import Response +from util.log import * +from util.cases import * +from util.sql import * +import time, datetime +import requests, json +import threading +import string +import random + +def check_res(url, data, header): + resp = requests.post(url, data, headers = header ) + resp.encoding='utf-8' + resp_dict = eval(resp.text) + status = resp_dict['status'] + if status =="succ": + print("%s run success!"%data) + # print(resp.text) + else : + print("%s run failed !"%data) + print(resp.text) + sys.exit() + +class TDTestCase(): + # updatecfgDict={'httpDbNameMandatory':0} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists test') + tdSql.execute('drop database if exists db') + tdSql.execute('drop database if exists des') + tdSql.execute('create database test') + tdSql.execute('create database des') + header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + url = "http://127.0.0.1:6041/rest/sql/" + + # test with no bind databases + + sqls = ["show databases;", + "use test", + "show tables;", + "show dnodes;", + "show vgroups;", + "create database db;", + "drop database db;", + "select client_version();" , + "use test", + "ALTER DATABASE test COMP 2;", + "create table tb (ts timestamp, id int , data double)", + "insert into tb values (now , 1, 1.0) ", + "select * from tb", + "show test.tables", + "show tables", + "insert into tb values (now , 2, 2.0) ", + "create table test.tb (ts timestamp, id int , data double)", + "insert into test.tb values (now , 3, 3.0) ", + "select * from tb", + "select * from test.tb", + "create table des.tb (ts timestamp, id int , data double)", + "insert into des.tb values (now , 3, 3.0)"] + for sql in sqls: + print("===================") + if sql == "create table test.tb (ts timestamp, id int , data double)": + resp = requests.post(url, sql, headers = header ) + print(resp.text) + print ("%s run occur error as expect ,check pass!" %(sql)) + else: + check_res(url,sql,header) + + tdSql.query("select * from test.tb") + tdSql.checkRows(3) + tdSql.query("select * from des.tb") + tdSql.checkRows(1) + + print("==================="*5) + print(" check bind db about restful ") + print("==================="*5) + + tdSql.execute('reset query cache') + tdSql.execute('drop database if exists test') + tdSql.execute('drop database if exists db') + tdSql.execute('drop database if exists des') + tdSql.execute('create database test') + tdSql.execute('create database des') + + url = "http://127.0.0.1:6041/rest/sql/des" + for sql in sqls: + print("===================") + if sql in ["create table des.tb (ts timestamp, id int , data double)"]: + resp = requests.post(url, sql, headers = header ) + print(resp.text) + print ("%s run occur error as expect ,check pass!" %(sql)) + else: + check_res(url,sql,header) + # check data + tdSql.query("select * from test.tb") + tdSql.checkRows(1) + tdSql.query("select * from des.tb") + tdSql.checkRows(3) + + os.system('sudo timedatectl set-ntp on') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/schemalessInsertPerformance.py b/tests/pytest/tools/schemalessInsertPerformance.py new file mode 100644 index 0000000000000000000000000000000000000000..5e009a21296bb09c7210a7109aea9dd43bf7a847 --- /dev/null +++ b/tests/pytest/tools/schemalessInsertPerformance.py @@ -0,0 +1,301 @@ +################################################################### +# Copyright (c) 2021 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import traceback +import random +import string +from taos.error import LinesError +import datetime +import time +from copy import deepcopy +import numpy as np +from util.log import * +from util.cases import * +from util.sql import * +from util.common import tdCom +import threading + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + + def genRandomTs(self): + year = random.randint(2000, 2021) + month = random.randint(10, 12) + day = random.randint(10, 29) + hour = random.randint(10, 24) + minute = random.randint(10, 59) + second = random.randint(10, 59) + m_second = random.randint(101, 199) + date_time = f'{year}-{month}-{day} {hour}:{minute}:{second}' + print(date_time) + timeArray = time.strptime(date_time, "%Y-%m-%d %H:%M:%S") + ts = int(time.mktime(timeArray)) + print("------", ts) + # timestamp = time.mktime(datetime.datetime.strptime(date_time, "%Y-%m-%d %H:%M:%S.%f").timetuple()) + return f'{ts}s' + + def genMultiColStr(self, int_count=4, double_count=0, binary_count=0): + """ + genType must be tag/col + """ + col_str = "" + if double_count == 0 and binary_count == 0: + for i in range(0, int_count): + if i < (int_count-1): + col_str += f'c{i}={random.randint(0, 255)}i32,' + else: + col_str += f'c{i}={random.randint(0, 255)}i32 ' + elif double_count > 0 and binary_count == 0: + for i in range(0, int_count): + col_str += f'c{i}={random.randint(0, 255)}i32,' + for i in range(0, double_count): + if i < (double_count-1): + col_str += f'c{i+int_count}={random.randint(1, 255)}.{i}f64,' + else: + col_str += f'c{i+int_count}={random.randint(1, 255)}.{i}f64 ' + elif double_count == 0 and binary_count > 0: + for i in range(0, int_count): + col_str += f'c{i}={random.randint(0, 255)}i32,' + for i in range(0, binary_count): + if i < (binary_count-1): + col_str += f'c{i+int_count}=\"{tdCom.getLongName(5, "letters")}\",' + else: + col_str += f'c{i+int_count}=\"{tdCom.getLongName(5, "letters")}\" ' + elif double_count > 0 and binary_count > 0: + for i in range(0, int_count): + col_str += f'c{i}={random.randint(0, 255)}i32,' + for i in range(0, double_count): + col_str += f'c{i+int_count}={random.randint(1, 255)}.{i}f64,' + for i in range(0, binary_count): + if i < (binary_count-1): + col_str += f'c{i+int_count+double_count}=\"{tdCom.getLongName(5, "letters")}\",' + else: + col_str += f'c{i+int_count+double_count}=\"{tdCom.getLongName(5, "letters")}\" ' + return col_str + + def genLongSql(self, int_count=4, double_count=0, binary_count=0, init=False): + if init: + tag_str = f'id="init",t0={random.randint(0, 65535)}i32,t1=\"{tdCom.getLongName(10, "letters")}\"' + else: + tag_str = f'id="sub_{tdCom.getLongName(5, "letters")}_{tdCom.getLongName(5, "letters")}",t0={random.randint(0, 65535)}i32,t1=\"{tdCom.getLongName(10, "letters")}\"' + col_str = self.genMultiColStr(int_count, double_count, binary_count) + long_sql = 'stb' + ',' + tag_str + ' ' + col_str + '0' + return long_sql + + def getPerfSql(self, count=4, init=False): + if count == 4: + input_sql = self.genLongSql(init=init) + elif count == 1000: + input_sql = self.genLongSql(400, 400, 200, init=init) + elif count == 4000: + input_sql = self.genLongSql(1900, 1900, 200, init=init) + return input_sql + + def tableGenerator(self, count=4, table_count=1000): + for i in range(table_count): + yield self.getPerfSql(count) + + + + + + + + def genTableList(self, count=4, table_count=10000): + table_list = list() + for i in range(1, table_count+1): + table_list.append(self.getPerfSql(count)) + return table_list + + def splitTableList(self, count=4, thread_count=10, table_count=1000): + per_list_len = int(table_count/thread_count) + table_list = self.genTableList(count=count) + # ts = int(time.time()) + list_of_group = zip(*(iter(table_list),) *per_list_len) + end_list = [list(i) for i in list_of_group] # i is a tuple + count = len(table_list) % per_list_len + end_list.append(table_list[-count:]) if count !=0 else end_list + return table_list, end_list + + def rowsGenerator(self, end_list): + ts = int(time.time()) + input_sql_list = list() + for elm_list in end_list: + for elm in elm_list: + for i in range(1, 10000): + ts -= 1 + elm_new = self.replaceLastStr(elm, str(ts)) + 's' + input_sql_list.append(elm_new) + yield input_sql_list + + # def insertRows(self, count=4, thread_count=10): + # table_list = self.splitTableList(count=count, thread_count=thread_count)[0] + # for + + + def replaceLastStr(self, str, new): + list_ori = list(str) + list_ori[-1] = new + return ''.join(list_ori) + + def genDataList(self, table_list, row_count=10): + data_list = list() + ts = int(time.time()) + for table_str in table_list: + for i in range(1, row_count+1): + ts -= 1 + table_str_new = self.replaceLastStr(table_str, f'{str(ts)}s') + data_list.append(table_str_new) + print(data_list) + return data_list + + + def insertRows(self, count=4, table_count=1000): + table_generator = self.tableGenerator(count=count, table_count=table_count) + for table_name in table_generator: + pass + + def perfTableInsert(self): + table_generator = self.tableGenerator() + for input_sql in table_generator: + self._conn.insert_lines([input_sql]) + # for i in range(10): + # self._conn.insert_lines([input_sql]) + + def perfDataInsert(self, count=4): + table_generator = self.tableGenerator(count=count) + ts = int(time.time()) + for input_sql in table_generator: + print("input_sql-----------", input_sql) + self._conn.insert_lines([input_sql]) + for i in range(100000): + ts -= 1 + input_sql_new = self.replaceLastStr(input_sql, str(ts)) + 's' + print("input_sql_new---------", input_sql_new) + self._conn.insert_lines([input_sql_new]) + + def batchInsertTable(self, batch_list): + for insert_list in batch_list: + print(threading.current_thread().name, "length=", len(insert_list)) + print(threading.current_thread().name, 'firstline', insert_list[0]) + print(threading.current_thread().name, 'lastline:', insert_list[-1]) + self._conn.insert_lines(insert_list) + print(threading.current_thread().name, 'end') + + def genTableThread(self, thread_count=10): + threads = list() + for i in range(thread_count): + t = threading.Thread(target=self.perfTableInsert) + threads.append(t) + return threads + + def genMultiThread(self, count, thread_count=10): + threads = list() + for i in range(thread_count): + t = threading.Thread(target=self.perfDataInsert,args=(count,)) + threads.append(t) + return threads + + def multiThreadRun(self, threads): + for t in threads: + t.start() + for t in threads: + t.join() + + def createStb(self, count=4): + input_sql = self.getPerfSql(count=count, init=True) + self._conn.insert_lines([input_sql]) + + def threadInsertTable(self, end_list, thread_count=10): + threads = list() + for i in range(thread_count): + t = threading.Thread(target=self.batchInsertTable, args=(end_list,)) + threads.append(t) + return threads + + + def finalRun(self): + self.createStb() + table_list, end_list = self.splitTableList() + batchInsertTableThread = self.threadInsertTable(end_list=end_list) + self.multiThreadRun(batchInsertTableThread) + # print(end_list) + + # def createTb(self, count=4): + # input_sql = self.getPerfSql(count=count) + # for i in range(10000): + # self._conn.insert_lines([input_sql]) + + # def createTb1(self, count=4): + # start_time = time.time() + # self.multiThreadRun(self.genMultiThread(input_sql)) + # end_time = time.time() + # return end_time - start_time + + # def calInsertTableTime(self): + # start_time = time.time() + # self.createStb() + # self.multiThreadRun(self.genMultiThread()) + # end_time = time.time() + # return end_time - start_time + + def calRunTime(self, count=4): + start_time = time.time() + self.createStb() + self.multiThreadRun(self.genMultiThread(count=count)) + end_time = time.time() + return end_time - start_time + + def calRunTime1(self, count=4): + start_time = time.time() + self.createStb() + self.multiThreadRun(self.perfTableInsert()) + # self.perfTableInsert() + + # def schemalessInsertPerfTest(self, count=4): + # input_sql = self.getPerfSql(count) + # self.calRunTime(input_sql) + + # def test(self): + # sql1 = 'stb,id="init",t0=14865i32,t1="tvnqbjuqck" c0=37i32,c1=217i32,c2=3i32,c3=88i32 1626006833640ms' + # sql2 = 'stb,id="init",t0=14865i32,t1="tvnqbjuqck" c0=38i32,c1=217i32,c2=3i32,c3=88i32 1626006833641ms' + # self._conn.insert_lines([sql1]) + # self._conn.insert_lines([sql2]) + + def run(self): + print("running {}".format(__file__)) + tdSql.prepare() + self.finalRun() + # print(self.calRunTime1(count=4)) + # print(self.calRunTime(count=4)) + # print(self.genRandomTs()) + # self.calInsertTableTime() + # self.test() + # table_list = self.splitTableList()[0] + # data_list = self.genDataList(table_list) + # print(len(data_list)) + # end_list = [['stb,id="sub_vzvfx_dbuxp",t0=9961i32,t1="zjjfayhfep" c0=83i32,c1=169i32,c2=177i32,c3=4i32 0','stb,id="sub_vzvfx_dbuxp",t0=9961i32,t1="zjjfayhfep" c0=83i32,c1=169i32,c2=177i32,c3=4i32 0'], ['stb,id="sub_vzvfx_dbuxp",t0=9961i32,t1="zjjfayhfep" c0=83i32,c1=169i32,c2=177i32,c3=4i32 0','stb,id="sub_vzvfx_dbuxp",t0=9961i32,t1="zjjfayhfep" c0=83i32,c1=169i32,c2=177i32,c3=4i32 0']] + # rowsGenerator = self.rowsGenerator(end_list) + # for i in rowsGenerator: + # print(i) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 1c7d94a8a4c8cd454d41c6d4d4d89b8377ec88b7..35abc4802f9de2080a6b6a166daf833c9cf04578 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -1,4 +1,4 @@ -################################################################### +################################################################### # Copyright (c) 2016 by TAOS Technologies, Inc. # All rights reserved. # @@ -50,4 +50,4 @@ class TDCom: def close(self): self.cursor.close() -tdCom = TDCom() \ No newline at end of file +tdCom = TDCom() diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 2abb8f5ee730ed187b28f4bff6c28a90b9186411..0208f884b691a20e4b4456fe8165797969305674 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -123,7 +123,7 @@ class TDDnode: "charset":"UTF-8", "asyncLog":"0", "anyIp":"0", - "tsEnableTelemetryReporting":"0", + "telemetryReporting":"0", "dDebugFlag":"135", "tsdbDebugFlag":"135", "mDebugFlag":"135", diff --git a/tests/script/general/http/restful_dbname.sim b/tests/script/general/http/restful_dbname.sim new file mode 100644 index 0000000000000000000000000000000000000000..75cd198507dda306c736cbcdeef4a044f66da9de --- /dev/null +++ b/tests/script/general/http/restful_dbname.sim @@ -0,0 +1,124 @@ +system sh/stop_dnodes.sh +sleep 2000 +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c http -v 1 +system sh/cfg.sh -n dnode1 -c httpDbNameMandatory -v 1 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect +sql drop database if exists db + +print ============================ dnode1 start + +print =============== step1 - login + +system_content curl 127.0.0.1:7111/rest/login/root/taosdata +print curl 127.0.0.1:7111/rest/login/root/taosdata -----> $system_content + +if $system_content != @{"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}@ then + return -1 +endi + +print =============== step2 - execute sql without db_name + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql + +if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database if not exists db' 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database if not exists db' 127.0.0.1:7111/rest/sql + +if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create table table_rest (ts timestamp, i int)' 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create table table_rest (ts timestamp, i int)' 127.0.0.1:7111/rest/sql + +if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into table_rest (now, 1)' 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into table_rest values (now, 1)' 127.0.0.1:7111/rest/sql + +if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from table_rest' 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from table_rest' 127.0.0.1:7111/rest/sql + +if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'drop database if exists db' 127.0.0.1:7111/rest/sql + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'drop database if exists db' 127.0.0.1:7111/rest/sql + +if $system_content != @{"status":"error","code":4354,"desc":"invalid url format"}@ then + return -1 +endi + +print =============== step3 - execute sql with db_name + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql/databases + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:7111/rest/sql/databases + +if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[],"rows":0}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database if not exists db' 127.0.0.1:7111/rest/sql/db + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database if not exists db' 127.0.0.1:7111/rest/sql/db + +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create table table_rest (ts timestamp, i int)' 127.0.0.1:7111/rest/sql/db + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create table table_rest (ts timestamp, i int)' 127.0.0.1:7111/rest/sql/db + +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into table_rest (now, 1)' 127.0.0.1:7111/rest/sql/db + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into table_rest values (1629904789233, 1)' 127.0.0.1:7111/rest/sql/db + +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[1]],"rows":1}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from table_rest' 127.0.0.1:7111/rest/sql/db + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from table_rest' 127.0.0.1:7111/rest/sql/db + +if $system_content != @{"status":"succ","head":["ts","i"],"column_meta":[["ts",9,8],["i",4,4]],"data":[["2021-08-25 23:19:49.233",1]],"rows":1}@ then + return -1 +endi + +print curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'drop database if exists db' 127.0.0.1:7111/rest/sql/db + +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'drop database if exists db' 127.0.0.1:7111/rest/sql/db + +if $system_content != @{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"data":[[0]],"rows":1}@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/columnValue_float.sim b/tests/script/general/parser/columnValue_float.sim index c7008d0b132e1d82b32a773555c638e71340b731..1832f7f84746bd8f0e94c463db04c38e2c01e273 100644 --- a/tests/script/general/parser/columnValue_float.sim +++ b/tests/script/general/parser/columnValue_float.sim @@ -150,13 +150,13 @@ if $data00 != 0.00150 then print expect 0.00150, actual: $data00 return -1 endi -sql create table st_float_15_0 using mt_float tags (3.40282347e+38) -sql select tagname from st_float_15_0 +#sql create table st_float_15_0 using mt_float tags (3.40282347e+38) +#sql select tagname from st_float_15_0 #if $data00 != 0.001500 then # return -1 #endi -sql create table st_float_16_0 using mt_float tags (-3.40282347e+38) -sql select tagname from st_float_16_0 +#sql create table st_float_16_0 using mt_float tags (-3.40282347e+38) +#sql select tagname from st_float_16_0 #if $data00 != 0.001500 then # return -1 #endi diff --git a/tests/script/general/parser/interp_test.sim b/tests/script/general/parser/interp_test.sim index 5a2021dcfc0d961abfcdc4768545091092786e3c..8eac8a41d391508737232a3f068c477922bf77aa 100644 --- a/tests/script/general/parser/interp_test.sim +++ b/tests/script/general/parser/interp_test.sim @@ -23,562 +23,563 @@ sql use $db ##### select interp from table print ====== select intp from table $tb = $tbPrefix . 0 - ## interp(*) from tb - sql select interp(*) from $tb where ts = $ts0 - if $rows != 1 then - return -1 - endi - if $data00 != @18-09-17 09:00:00.000@ then - return -1 - endi - if $data01 != 0 then - return -1 - endi - if $data02 != 0 then - return -1 - endi - - ## interp + limit offset - sql select interp(*) from $tb where ts = $ts0 limit 5 offset 1 - if $rows != 0 then - return -1 - endi - - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 - if $rows != 1 then - return -1 - endi - if $data00 != @18-09-17 09:00:00.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 - - ## intp + aggregation functions - #$t = $ts0 + $delta - #$t = $t + $delta - #sql_error select interp(ts), max(c1), min(c2), count(c3), sum(c4), avg(c5), stddev(c6), first(c7), last(c8), interp(c9) from $tb where ts = $t - - ### illegal queries on a table - sql_error select interp(ts), c1 from $tb where ts = $ts0 - sql_error select interp(ts) from $tb where ts >= $ts0 - sql_error select interp(ts), max(c1), min(c2), count(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(NULL) - - ### interp from tb + fill - $t = $ts0 + 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t - if $rows != 0 then - return -1 - endi - - ## fill(none) - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) - if $rows != 0 then - return -1 - endi - $t = $tsu + 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) - if $rows != 0 then - return -1 - endi - - ## fill(NULL) - $t = $tsu - 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, NULL) order by ts asc - if $rows != 1 then - return -1 - endi - if $data00 != @18-11-25 19:29:59.000@ then - return -1 - endi - if $data01 != NULL then - print expect NULL, actual $data01 - return -1 - endi - if $data02 != NULL then - return -1 - endi - if $data03 != NULL then - return -1 - endi - if $data04 != NULL then - return -1 - endi - if $data05 != NULL then - return -1 - endi - if $data06 != NULL 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 - - $t = $tsu + 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) - if $rows != 0 then - return -1 - endi - - ## fill(prev) - $t = $ts0 + 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) - if $rows != 1 then - return -1 - endi - - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(prev) - if $rows != 1 then - return -1 - endi - if $data00 != @18-09-17 09:00:00.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 - - $t = $ts0 - 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) - if $rows != 0 then - return -1 - endi - - $t = $ts0 + 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $t fill(prev) - if $rows != 1 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 != NULL then - return -1 - endi - if $data03 != 0.00000 then - print expect 0.00000, actual:$data03 - return -1 - endi +## interp(*) from tb +sql select interp(*) from $tb where ts = $ts0 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi + +## interp + limit offset +sql select interp(*) from $tb where ts = $ts0 limit 5 offset 1 +if $rows != 0 then + return -1 +endi + +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.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 + +## intp + aggregation functions +$t = $ts0 + $delta +$t = $t + $delta +sql_error select interp(ts), max(c1), min(c2), count(c3), sum(c4), avg(c5), stddev(c6), first(c7), last(c8), interp(c9) from $tb where ts = $t +sql_error select interp(ts) from $tb where ts=$ts0 interval(1s) + +### illegal queries on a table +sql_error select interp(ts), c1 from $tb where ts = $ts0 +sql_error select interp(ts) from $tb where ts >= $ts0 +sql_error select interp(ts), max(c1), min(c2), count(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(NULL) + +### interp from tb + fill +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t +if $rows != 0 then + return -1 +endi + +## fill(none) +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) +if $rows != 0 then + return -1 +endi +$t = $tsu + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) +if $rows != 0 then + return -1 +endi + +## fill(NULL) +$t = $tsu - 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, NULL) order by ts asc +if $rows != 1 then + return -1 +endi +if $data00 != @18-11-25 19:29:59.000@ then + return -1 +endi +if $data01 != NULL then + print expect NULL, actual $data01 + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != NULL then + return -1 +endi +if $data04 != NULL then + return -1 +endi +if $data05 != NULL then + return -1 +endi +if $data06 != NULL 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 + +$t = $tsu + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(none) +if $rows != 0 then + return -1 +endi + +## fill(prev) +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) +if $rows != 1 then + return -1 +endi + +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(prev) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.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 + +$t = $ts0 - 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) +if $rows != 0 then + return -1 +endi + +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $t fill(prev) +if $rows != 1 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 != NULL then + return -1 +endi +if $data03 != 0.00000 then + print expect 0.00000, actual:$data03 + return -1 +endi # if $data04 != NULL then # return -1 # endi - $t = $tsu + 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) - if $rows != 0 then - return -1 - endi - - ## fill(linear) - $t = $ts0 + 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) - print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 - if $rows != 1 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 - print $data03 - 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 - # columns contain NULL values - $t = $ts0 + 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $t fill(linear) - print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 - if $rows != 1 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 != NULL then - return -1 - endi - if $data03 != 0.00167 then - return -1 - endi - if $data04 != NULL 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 - - print select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(linear) - - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(linear) - if $rows != 1 then - return -1 - endi - if $data00 != @18-09-17 09:00:00.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 - # columns contain NULL values - - print select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(linear) - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(linear) - if $rows != 1 then - return -1 - endi - if $data00 != @18-09-17 09:00:00.000@ then - return -1 - endi - if $data01 != 0 then - return -1 - endi - if $data02 != NULL then - return -1 - endi - if $data03 != 0.00000 then - return -1 - endi - if $data04 != NULL 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 - - $t = $ts0 - 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) - if $rows != 0 then - return -1 - endi - - $t = $tsu + 1000 - print select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) - if $rows != 0 then - return -1 - endi +$t = $tsu + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(prev) +if $rows != 0 then + return -1 +endi + +## fill(linear) +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +if $rows != 1 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 +print $data03 +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 +# columns contain NULL values +$t = $ts0 + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $t fill(linear) +print ====== 0:$data00, 1:$data01, 2:$data02, 3:$data03, 4:$data04, 5:$data05, 6:$data06, 7:$data07, 8:$data08, 9:$data09 +if $rows != 1 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 != NULL then + return -1 +endi +if $data03 != 0.00167 then + return -1 +endi +if $data04 != NULL 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 + +print select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(linear) + +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(linear) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.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 +# columns contain NULL values + +print select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(linear) +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(linear) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != NULL 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 + +$t = $ts0 - 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) +if $rows != 0 then + return -1 +endi + +$t = $tsu + 1000 +print select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(linear) +if $rows != 0 then + return -1 +endi ## fill(value) - $t = $ts0 + 1000 - print 91 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) - if $rows != 1 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 - - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(value, -1, -2, -3) - if $rows != 1 then - return -1 - endi - if $data00 != @18-09-17 09:00:00.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 - - # table has NULL columns - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(value, -1, -2, -3) - if $rows != 1 then - return -1 - endi - if $data00 != @18-09-17 09:00:00.000@ then - return -1 - endi - if $data01 != 0 then - return -1 - endi - if $data02 != NULL then - return -1 - endi - if $data03 != 0.00000 then - return -1 - endi - if $data04 != NULL then - return -1 - endi - - $t = $ts0 - 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) - if $rows != 0 then - return -1 - endi - - $t = $tsu + 1000 - sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) - if $rows != 0 then - return -1 - endi - -##### select interp from stable - ## interp(*) from stb - print select interp(*) from $stb where ts = $ts0 - sql select interp(*) from $stb where ts = $ts0 - if $rows != 1 then - return -1 - endi - $t = $ts0 + 1000 - print 92 - - sql select interp(*) from $stb where ts = $t - if $rows != 0 then - return -1 - endi - ## interp(*) from stb + group by - sql select interp(ts, c1, c2, c3, c4, c5, c7, c9) from $stb where ts = $ts0 group by tbname order by tbname asc - print ====== select interp(ts, c1, c2, c3, c4, c5, c7, c9) from $stb where ts = $ts0 group by tbname order by tbname asc - 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:00.000@ then - return -1 - endi - if $data01 != 0 then - return -1 - endi - if $data02 != 0 then - return -1 - endi - if $data04 != 0.000000000 then - return -1 - endi - if $data08 != intp_tb0 then - return -1 - endi - if $data22 != NULL then - return -1 - endi - if $data24 != NULL then - return -1 - endi - if $data28 != intp_tb2 then - return -1 - endi - - ## interp(*) from stb + group by + limit offset - sql select interp(*) from $stb where ts = $ts0 group by tbname limit 0 - if $rows != 0 then - return -1 - endi - sql select interp(*) from $stb where ts = $ts0 group by tbname limit 0 offset 1 - - ## interp(*) from stb + group by + fill(none) - $t = $ts0 + 1000 - sql select interp(*) from $stb where ts = $t fill(none) group by tbname - if $rows != 0 then - return -1 - endi - - sql select interp(*) from $stb where ts = $ts0 fill(none) group by tbname - if $rows != 4 then - return -1 - endi - if $data01 != 0 then - return -1 - endi - if $data02 != 0 then - return -1 - endi - if $data21 != 0 then - return -1 - endi - if $data22 != NULL then - return -1 - endi - if $data24 != NULL then - return -1 - endi - - ## interp(*) from stb + group by + fill(none) - $t = $ts0 + 1000 +$t = $ts0 + 1000 +print 91 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) +if $rows != 1 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 + +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $ts0 fill(value, -1, -2, -3) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.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 + +# table has NULL columns +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(value, -1, -2, -3) +if $rows != 1 then + return -1 +endi +if $data00 != @18-09-17 09:00:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != NULL then + return -1 +endi +if $data03 != 0.00000 then + return -1 +endi +if $data04 != NULL then + return -1 +endi + +$t = $ts0 - 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) +if $rows != 0 then + return -1 +endi + +$t = $tsu + 1000 +sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, -1, -2) +if $rows != 0 then + return -1 +endi + +### select interp from stable +## interp(*) from stb +print select interp(*) from $stb where ts = $ts0 +sql select interp(*) from $stb where ts = $ts0 +if $rows != 1 then + return -1 +endi +$t = $ts0 + 1000 +print 92 + +sql select interp(*) from $stb where ts = $t +if $rows != 0 then + return -1 +endi +## interp(*) from stb + group by +sql select interp(ts, c1, c2, c3, c4, c5, c7, c9) from $stb where ts = $ts0 group by tbname order by tbname asc +print ====== select interp(ts, c1, c2, c3, c4, c5, c7, c9) from $stb where ts = $ts0 group by tbname order by tbname asc +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:00.000@ then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data04 != 0.000000000 then + return -1 +endi +if $data08 != intp_tb0 then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data24 != NULL then + return -1 +endi +if $data28 != intp_tb2 then + return -1 +endi + +## interp(*) from stb + group by + limit offset +sql select interp(*) from $stb where ts = $ts0 group by tbname limit 0 +if $rows != 0 then + return -1 +endi +sql select interp(*) from $stb where ts = $ts0 group by tbname limit 0 offset 1 + +## interp(*) from stb + group by + fill(none) +$t = $ts0 + 1000 +sql select interp(*) from $stb where ts = $t fill(none) group by tbname +if $rows != 0 then + return -1 +endi + +sql select interp(*) from $stb where ts = $ts0 fill(none) group by tbname +if $rows != 4 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data02 != 0 then + return -1 +endi +if $data21 != 0 then + return -1 +endi +if $data22 != NULL then + return -1 +endi +if $data24 != NULL then + return -1 +endi + +## interp(*) from stb + group by + fill(none) +$t = $ts0 + 1000 sql select interp(*) from $stb where ts = $t fill(NULL) group by tbname if $rows != $tbNum then return -1 @@ -846,12 +847,12 @@ if $data29 != NULL then 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); +sql select interp(ts,c1) from intp_tb0 where ts>'2018-11-25 19:19:00' and ts<'2018-11-25 19:19:12' every(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); +sql select interp(c1) from intp_tb0 where ts>'2018-11-25 18:09:00' and ts<'2018-11-25 19:20:12' every(18m); if $rows != 1 then return -1 endi @@ -864,7 +865,7 @@ 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) +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' every(18m) fill(linear) if $rows != 5 then return -1 endi @@ -930,7 +931,7 @@ if $data44 != @18-11-25 19:06:00.000@ then endi -sql select interp(c1) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:42:00.000' interval(1m) fill(linear); +sql select interp(c1) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:42:00.000' every(1m) fill(linear); if $rows != 8 then return -1 endi @@ -984,7 +985,7 @@ if $data71 != NULL then endi -sql select interp(c1) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:42:00.000' interval(1m) fill(linear) order by ts desc; +sql select interp(c1) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:42:00.000' every(1m) fill(linear) order by ts desc; if $rows != 8 then return -1 endi @@ -1037,7 +1038,7 @@ if $data71 != NULL then return -1 endi -sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' interval(2m) fill(linear) order by ts; +sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' every(2m) fill(linear) order by ts; if $rows != 9 then return -1 endi @@ -1097,7 +1098,7 @@ if $data81 != 1.00000 then endi -sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' interval(3m) fill(linear) order by ts; +sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' every(3m) fill(linear) order by ts; if $rows != 6 then return -1 endi @@ -1138,7 +1139,7 @@ if $data51 != 0.80000 then return -1 endi -sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' interval(3m) fill(linear) order by ts desc; +sql select interp(c3) from intp_stb0 where ts >= '2018-09-17 20:35:00.000' and ts <= '2018-09-17 20:50:00.000' every(3m) fill(linear) order by ts desc; if $rows != 6 then return -1 endi @@ -1181,7 +1182,7 @@ endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' interval(1s) fill(linear); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(linear); if $rows != 6 then return -1 endi @@ -1222,7 +1223,7 @@ if $data51 != 9.87500 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' interval(1s) fill(value, 1); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(value, 1); if $rows != 6 then return -1 endi @@ -1263,7 +1264,7 @@ if $data51 != 1.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' interval(1s) fill(NULL); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(NULL); if $rows != 6 then return -1 endi @@ -1304,7 +1305,7 @@ if $data51 != NULL then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' interval(1s) fill(prev); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(prev); if $rows != 6 then return -1 endi @@ -1345,7 +1346,7 @@ if $data51 != 9.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' interval(1s) fill(next); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:00' every(1s) fill(next); if $rows != 6 then return -1 endi @@ -1387,11 +1388,11 @@ if $data51 != 10.00000 then endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:56' interval(1s) fill(linear); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:56' every(1s) fill(linear); if $rows != 0 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:56' interval(1s) fill(prev); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:56' every(1s) fill(prev); if $rows != 2 then return -1 endi @@ -1408,7 +1409,7 @@ if $data11 != 3.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:56' interval(1s) fill(next); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:56' every(1s) fill(next); if $rows != 2 then return -1 endi @@ -1425,7 +1426,7 @@ if $data11 != NULL then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:57' interval(1s) fill(linear); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:57' every(1s) fill(linear); if $rows != 3 then return -1 endi @@ -1448,7 +1449,7 @@ if $data21 != 3.77273 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:57' interval(1s) fill(prev); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:57' every(1s) fill(prev); if $rows != 3 then return -1 endi @@ -1471,7 +1472,7 @@ if $data21 != 3.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:57' interval(1s) fill(next); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:19:57' every(1s) fill(next); if $rows != 3 then return -1 endi @@ -1494,7 +1495,7 @@ if $data21 != 4.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:03' interval(1s) fill(linear); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:03' every(1s) fill(linear); if $rows != 10 then return -1 endi @@ -1559,7 +1560,7 @@ if $data91 != NULL then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:03' interval(1s) fill(prev); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:03' every(1s) fill(prev); if $rows != 10 then return -1 endi @@ -1624,7 +1625,7 @@ if $data91 != 14.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:03' interval(1s) fill(next); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:03' every(1s) fill(next); if $rows != 10 then return -1 endi @@ -1689,7 +1690,7 @@ if $data91 != NULL then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:05' interval(1s) fill(linear); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:05' every(1s) fill(linear); if $rows != 12 then return -1 endi @@ -1742,7 +1743,7 @@ if $data71 != 15.29412 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:05' interval(1s) fill(prev); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:05' every(1s) fill(prev); if $rows != 12 then return -1 endi @@ -1807,7 +1808,7 @@ if $data91 != 14.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:05' interval(1s) fill(next); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:05' every(1s) fill(next); if $rows != 12 then return -1 endi @@ -1872,7 +1873,7 @@ if $data91 != 20.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:20:02' and ts<='2021-07-25 02:20:05' interval(1s) fill(value, 1); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:20:02' and ts<='2021-07-25 02:20:05' every(1s) fill(value, 1); if $rows != 4 then return -1 endi @@ -1901,7 +1902,7 @@ if $data31 != 20.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:20:02' and ts<='2021-07-25 02:20:05' interval(1s) fill(null); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:20:02' and ts<='2021-07-25 02:20:05' every(1s) fill(null); if $rows != 4 then return -1 endi @@ -1931,7 +1932,7 @@ if $data31 != 20.00000 then endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:25' interval(1s) fill(linear); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:25' every(1s) fill(linear); if $rows != 32 then return -1 endi @@ -1984,7 +1985,7 @@ if $data71 != 15.29412 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:25' interval(1s) fill(prev); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:25' every(1s) fill(prev); if $rows != 32 then return -1 endi @@ -2049,7 +2050,7 @@ if $data91 != 14.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:25' interval(1s) fill(next); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:20:25' every(1s) fill(next); if $rows != 32 then return -1 endi @@ -2115,7 +2116,7 @@ if $data91 != 20.00000 then endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:25:00' interval(1s) fill(linear); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:25:00' every(1s) fill(linear); if $rows != 307 then return -1 endi @@ -2168,7 +2169,7 @@ if $data71 != 15.29412 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:25:00' interval(1s) fill(prev); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:25:00' every(1s) fill(prev); if $rows != 307 then return -1 endi @@ -2233,7 +2234,7 @@ if $data91 != 14.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:25:00' interval(1s) fill(next); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 02:25:00' every(1s) fill(next); if $rows != 307 then return -1 endi @@ -2298,7 +2299,7 @@ if $data91 != 20.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 03:25:00' interval(1s) fill(linear); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 03:25:00' every(1s) fill(linear); if $rows != 3907 then return -1 endi @@ -2352,7 +2353,7 @@ if $data71 != 15.29412 then endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 03:25:00' interval(1s) fill(prev); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 03:25:00' every(1s) fill(prev); if $rows != 3907 then return -1 endi @@ -2417,7 +2418,7 @@ if $data91 != 14.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 03:25:00' interval(1s) fill(next); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<='2021-07-25 03:25:00' every(1s) fill(next); if $rows != 3907 then return -1 endi @@ -2482,7 +2483,7 @@ if $data91 != 20.00000 then return -1 endi -sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:07' interval(1s); +sql select interp(pav) from ap1 where ts> '2021-07-25 02:19:54' and ts<'2021-07-25 02:20:07' every(1s); if $rows != 1 then return -1 endi