diff --git a/.gitignore b/.gitignore index d1f1dc4dedb31da5b41a1046d7a4419881746071..b0a36fdeddeb2815d5ff5ba1c6a2241f13f678f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ build/ .ycm_extra_conf.py .vscode/ +.cache/ +compile_commands.json .idea/ cmake-build-debug/ cmake-build-release/ +cmake-build-relwithdebinfo/ cscope.out cscope.files tags diff --git a/Jenkinsfile2 b/Jenkinsfile2 index c270b6c4c06573880c639333ebcae803ded1d2e6..bf81ab5ded6d683f2b5088f6f6edd823f79b108c 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -23,31 +23,31 @@ def sync_source() { sh ''' cd ${WKC} git clean -fxd - git checkout master + git checkout -f master ''' } else if (env.CHANGE_TARGET == '2.0') { sh ''' cd ${WKC} git clean -fxd - git checkout 2.0 + git checkout -f 2.0 ''' } else if (env.CHANGE_TARGET == '2.4') { sh ''' cd ${WKC} git clean -fxd - git checkout 2.4 + git checkout -f 2.4 ''' } else if (env.CHANGE_TARGET == '2.6') { sh ''' cd ${WKC} git clean -fxd - git checkout 2.6 + git checkout -f 2.6 ''' } else { sh ''' cd ${WKC} git clean -fxd - git checkout develop + git checkout -f develop ''' } } @@ -79,7 +79,7 @@ def sync_source() { } else if (env.CHANGE_TARGET == '2.6') { sh ''' cd ${WK} - git checkout 2.6 + git checkout -f 2.6 ''' } else { sh ''' @@ -194,47 +194,47 @@ def pre_test_win(){ if (env.CHANGE_TARGET == 'master') { bat ''' cd %WIN_INTERNAL_ROOT% - git checkout master + git checkout -f master ''' bat ''' cd %WIN_COMMUNITY_ROOT% - git checkout master + git checkout -f master ''' } else if (env.CHANGE_TARGET == '2.0') { bat ''' cd %WIN_INTERNAL_ROOT% - git checkout 2.0 + git checkout -f 2.0 ''' bat ''' cd %WIN_COMMUNITY_ROOT% - git checkout 2.0 + git checkout -f 2.0 ''' } else if (env.CHANGE_TARGET == '2.4') { bat ''' cd %WIN_INTERNAL_ROOT% - git checkout 2.4 + git checkout -f 2.4 ''' bat ''' cd %WIN_COMMUNITY_ROOT% - git checkout 2.4 + git checkout -f 2.4 ''' } else if (env.CHANGE_TARGET == '2.6') { bat ''' cd %WIN_INTERNAL_ROOT% - git checkout 2.6 + git checkout -f 2.6 ''' bat ''' cd %WIN_COMMUNITY_ROOT% - git checkout 2.6 + git checkout -f 2.6 ''' } else { bat ''' cd %WIN_INTERNAL_ROOT% - git checkout develop + git checkout -f develop ''' bat ''' cd %WIN_COMMUNITY_ROOT% - git checkout develop + git checkout -f develop ''' } } diff --git a/docs/en/12-taos-sql/02-database.md b/docs/en/12-taos-sql/02-database.md index c2961d62415cd7d23b031777082801426b221190..0af8c36f669ea1de988ce200ce11037d85674c26 100644 --- a/docs/en/12-taos-sql/02-database.md +++ b/docs/en/12-taos-sql/02-database.md @@ -20,20 +20,20 @@ CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [DAYS days] [UPDATE 1]; 3. The maximum length of database name is 33 bytes. 4. The maximum length of a SQL statement is 65,480 bytes. 5. Below are the parameters that can be used when creating a database - - cache: [Description](/reference/config/#cache) - - blocks: [Description](/reference/config/#blocks) - - days: [Description](/reference/config/#days) - - keep: [Description](/reference/config/#keep) - - minRows: [Description](/reference/config/#minrows) - - maxRows: [Description](/reference/config/#maxrows) - - wal: [Description](/reference/config/#wallevel) - - fsync: [Description](/reference/config/#fsync) - - update: [Description](/reference/config/#update) - - cacheLast: [Description](/reference/config/#cachelast) - - replica: [Description](/reference/config/#replica) - - quorum: [Description](/reference/config/#quorum) - - comp: [Description](/reference/config/#comp) - - precision: [Description](/reference/config/#precision) + - cache: [Description](../../reference/config/#cache) + - blocks: [Description](../../reference/config/#blocks) + - days: [Description](../../reference/config/#days) + - keep: [Description](../../reference/config/#keep) + - minRows: [Description](../../reference/config/#minrows) + - maxRows: [Description](../../reference/config/#maxrows) + - wal: [Description](../../reference/config/#wallevel) + - fsync: [Description](../../reference/config/#fsync) + - update: [Description](../../reference/config/#update) + - cacheLast: [Description](../../reference/config/#cachelast) + - replica: [Description](../../reference/config/#replica) + - quorum: [Description](../../reference/config/#quorum) + - comp: [Description](../../reference/config/#comp) + - precision: [Description](../../reference/config/#precision) 6. Please note that all of the parameters mentioned in this section are configured in configuration file `taos.cfg` on the TDengine server. If not specified in the `create database` statement, the values from taos.cfg are used by default. To override default parameters, they must be specified in the `create database` statement. ::: diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index 86ff5a58ce31a357d6e247294ffdac791cb0c032..c49fb428ef0c93f52b5e4048f5e05ad807910adf 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -191,7 +191,7 @@ Query OK, 1 row(s) in set (0.000921s) SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence. It can't be used on timestamp column or tags. +**Description**:The value which has the highest frequency of occurrence. One random value is returned if there are multiple values which have highest frequency of occurrence. It can't be used on timestamp column or tags. **Return value type**:Same as the data type of the column being operated upon diff --git a/docs/en/14-reference/05-taosbenchmark.md b/docs/en/14-reference/05-taosbenchmark.md index 0951717f5ae5f17676bd4aaefcd24f0da829c12c..71b4a707b4a0fa7b150cc129a2b30a874d4c2ffc 100644 --- a/docs/en/14-reference/05-taosbenchmark.md +++ b/docs/en/14-reference/05-taosbenchmark.md @@ -214,7 +214,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) The parameters listed in this section apply to all function modes. - **filetype** : The function to be tested, with optional values `insert`, `query` and `subscribe`. These correspond to the insert, query, and subscribe functions, respectively. Users can specify only one of these in each configuration file. -**cfgdir**: specify the TDengine cluster configuration file's directory. The default path is /etc/taos. +**cfgdir**: specify the TDengine client configuration file's directory. The default path is /etc/taos. - **host**: Specify the FQDN of the TDengine server to connect. The default value is `localhost`. @@ -234,7 +234,7 @@ The parameters related to database creation are configured in `dbinfo` in the js - **name**: specify the name of the database. -- **drop**: indicate whether to delete the database before inserting. The default is true. +- **drop**: indicate whether to delete the database before inserting. The value can be 'yes' or 'no'. No means do not drop. The default is to drop. - **replica**: specify the number of replicas when creating the database. diff --git a/docs/zh/12-taos-sql/02-database.md b/docs/zh/12-taos-sql/02-database.md index e3a0aa7c87461fd1621a38093871a1542e3dbf98..ebe6a66a2ab0b36845e39021c9c278599a736c64 100644 --- a/docs/zh/12-taos-sql/02-database.md +++ b/docs/zh/12-taos-sql/02-database.md @@ -20,20 +20,20 @@ CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [DAYS days] [UPDATE 1]; 3. 数据库名最大长度为 33; 4. 一条 SQL 语句的最大长度为 65480 个字符; 5. 创建数据库时可用的参数有: - - cache: [详细说明](/reference/config/#cache) - - blocks: [详细说明](/reference/config/#blocks) - - days: [详细说明](/reference/config/#days) - - keep: [详细说明](/reference/config/#keep) - - minRows: [详细说明](/reference/config/#minrows) - - maxRows: [详细说明](/reference/config/#maxrows) - - wal: [详细说明](/reference/config/#wallevel) - - fsync: [详细说明](/reference/config/#fsync) - - update: [详细说明](/reference/config/#update) - - cacheLast: [详细说明](/reference/config/#cachelast) - - replica: [详细说明](/reference/config/#replica) - - quorum: [详细说明](/reference/config/#quorum) - - comp: [详细说明](/reference/config/#comp) - - precision: [详细说明](/reference/config/#precision) + - cache: [详细说明](../../reference/config/#cache) + - blocks: [详细说明](../../reference/config/#blocks) + - days: [详细说明](../../reference/config/#days) + - keep: [详细说明](../../reference/config/#keep) + - minRows: [详细说明](../../reference/config/#minrows) + - maxRows: [详细说明](../../reference/config/#maxrows) + - wal: [详细说明](../../reference/config/#wallevel) + - fsync: [详细说明](../../reference/config/#fsync) + - update: [详细说明](../../reference/config/#update) + - cacheLast: [详细说明](../../reference/config/#cachelast) + - replica: [详细说明](../../reference/config/#replica) + - quorum: [详细说明](../../reference/config/#quorum) + - comp: [详细说明](../../reference/config/#comp) + - precision: [详细说明](../../reference/config/#precision) 6. 请注意上面列出的所有参数都可以配置在配置文件 `taosd.cfg` 中作为创建数据库时使用的默认配置, `create database` 的参数中明确指定的会覆盖配置文件中的设置。 ::: @@ -86,7 +86,7 @@ REPLICA 参数是指修改数据库副本数,取值范围 [1, 3]。在集群 ALTER DATABASE db_name KEEP 365; ``` -KEEP 参数是指修改数据文件保存的天数,缺省值为 3650,取值范围 [days, 365000],必须大于或等于 days 参数值。 +KEEP 参数是指修改数据文件保存的天数,缺省值为 3650,取值范围 [days, 36500],必须大于或等于 days 参数值。 ``` ALTER DATABASE db_name QUORUM 2; diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 2349e6aa3c02eb62fba1fc7e4eef15e08e3924d1..c134a54a532f222e7eb5bb2e5d6969966f49d433 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -193,7 +193,7 @@ Query OK, 1 row(s) in set (0.000921s) SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出空。不能匹配标签、时间戳输出。 +**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,则随机输出其中某个值。不能匹配标签、时间戳输出。 **返回数据类型**:同应用的字段。 diff --git a/docs/zh/14-reference/05-taosbenchmark.md b/docs/zh/14-reference/05-taosbenchmark.md index 6b694543b1db435f507b5e2fb325cebe76261b48..ef971db6df739c5459bd90a480a56a5f5b02db30 100644 --- a/docs/zh/14-reference/05-taosbenchmark.md +++ b/docs/zh/14-reference/05-taosbenchmark.md @@ -211,7 +211,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) 本节所列参数适用于所有功能模式。 - **filetype** : 要测试的功能,可选值为 `insert`, `query` 和 `subscribe`。分别对应插入、查询和订阅功能。每个配置文件中只能指定其中之一。 -- **cfgdir** : TDengine 集群配置文件所在的目录,默认路径是 /etc/taos 。 +- **cfgdir** : TDengine 客户端配置文件所在的目录,默认路径是 /etc/taos 。 - **host** : 指定要连接的 TDengine 服务端的 FQDN,默认值为 localhost。 @@ -231,7 +231,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) - **name** : 数据库名。 -- **drop** : 插入前是否删除数据库,默认为 true。 +- **drop** : 插入前是否删除数据库,可选项为 "yes" 或者 "no", 为 "no" 时不创建。默认删除。 - **replica** : 创建数据库时指定的副本数。 diff --git a/examples/c/apitest.c b/examples/c/apitest.c index 597a108a2686b4dd501513ea895c25a2de1b8dad..c5867fc4f83c9b7bec54f27ee534f153277035cb 100644 --- a/examples/c/apitest.c +++ b/examples/c/apitest.c @@ -279,7 +279,8 @@ void verify_schema_less(TAOS* taos) { int code = 0, affected_rows = 0; char* lines[] = { - "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", + // test support \n \t \r + "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"aaa\tbbb\nccc\\\\tddd\\\\neee\\nfff\\rggg\\thhh\",c2=false,c4=4f64 1626006833639000000", "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000", "ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532", "st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000", diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 7d77a0b23e70782f1a8a0160812820c91640f9dc..197ee5d297f584cefe76ca89e36a20bb498a9a33 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -11,7 +11,7 @@ # local fully qualified domain name (FQDN) # fqdn hostname -# first port number for the connection (12 continuous UDP/TCP port number are used) +# first port number for the connection (12 continuous UDP/TCP port number are used) # serverPort 6030 # log file's directory @@ -23,8 +23,8 @@ # temporary file's directory # tempDir /tmp/ -# the arbitrator's fully qualified domain name (FQDN) for TDengine system, for cluster only -# arbitrator arbitrator_hostname:6042 +# the arbitrator's fully qualified domain name (FQDN) for TDengine system, for cluster only +# arbitrator arbitrator_hostname:6042 # number of threads per CPU core # numOfThreadsPerCore 1.0 @@ -60,19 +60,19 @@ keepColumnName 1 # max timer control blocks # maxTmrCtrl 512 -# time interval of system monitor, seconds +# time interval of system monitor, seconds # monitorInterval 30 -# number of seconds allowed for a dnode to be offline, for cluster only +# number of seconds allowed for a dnode to be offline, for cluster only # offlineThreshold 864000 # RPC re-try timer, millisecond # rpcTimer 300 -# RPC maximum time for ack, seconds. +# RPC maximum time for ack, seconds. # rpcMaxTime 600 -# time interval of dnode status reporting to mnode, seconds, for cluster only +# time interval of dnode status reporting to mnode, seconds, for cluster only # statusInterval 1 # time interval of heart beat from shell to dnode, seconds @@ -121,7 +121,7 @@ keepColumnName 1 # maxRows 4096 # the number of acknowledgments required for successful data writing -# quorum 1 +# quorum 1 # enable/disable compression # comp 2 @@ -132,7 +132,7 @@ keepColumnName 1 # if walLevel is set to 2, the cycle of fsync being executed, if set to 0, fsync is called right away # fsync 3000 -# number of replications, for cluster only +# number of replications, for cluster only # replica 1 # the compressed rpc message, option: @@ -188,9 +188,12 @@ keepColumnName 1 # enbale/disable http service # http 1 -# enable/disable system monitor +# enable/disable system monitor # monitor 1 +# enable/disable system audit +# audit 0 + # enable/disable recording the SQL statements via restful interface # httpEnableRecordSql 0 @@ -219,7 +222,7 @@ keepColumnName 1 # The following parameters are used for debug purpose only. # debugFlag 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR -# 131: output warning and error +# 131: output warning and error # 135: output debug, warning and error # 143: output trace, debug, warning and error to log # 199: output debug, warning and error to both screen and file @@ -243,13 +246,13 @@ keepColumnName 1 # debug flag for SDB # sdbDebugFlag 135 -# debug flag for RPC +# debug flag for RPC # rpcDebugFlag 131 # debug flag for TAOS TIMER # tmrDebugFlag 131 -# debug flag for TDengine client +# debug flag for TDengine client # cDebugFlag 131 # debug flag for JNI @@ -302,7 +305,7 @@ keepColumnName 1 # default string type used for storing JSON String, options can be binary/nchar, default is nchar # defaultJSONStrType nchar -# force TCP transmission +# force TCP transmission # rpcForceTcp 0 # unit MB. Flush vnode wal file if walSize > walFlushSize and walSize > cache*0.5*blocks @@ -310,3 +313,12 @@ keepColumnName 1 # unit Hour. Latency of data migration # keepTimeOffset 0 + +# taosc write batch size, maximum 4096, suggested value 64 ~ 512, default 0, 0 means disable write batching. +# writeBatchSize 0 + +# taosc write batch timeout in milliseconds, maximum 2048, suggested value 2 ~ 100, default 10. +# writeBatchTimeout 10 + +# using thread local write batching. this option is not available when writeBatchSize = 0. +# writeBatchThreadLocal 0 diff --git a/packaging/release.sh b/packaging/release.sh index 0ad8d9b1bfaa09a4be51c8448c2494feff2cdbf7..117be9911a74b2ae971e3b45ee759a8981c9773c 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -3,7 +3,7 @@ # Generate the deb package for ubuntu, or rpm package for centos, or tar.gz package for other linux os set -e -#set -x +# set -x # release.sh -v [cluster | edge] # -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] @@ -263,7 +263,7 @@ if [ "$osType" != "Darwin" ]; then if [[ "$pagMode" == "full" ]]; then if [ -d ${top_dir}/src/kit/taos-tools/packaging/deb ]; then cd ${top_dir}/src/kit/taos-tools/packaging/deb - taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}') + taos_tools_ver=$(git tag |grep -v taos | sort | tail -1) [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" ${csudo}./make-taos-tools-deb.sh ${top_dir} \ @@ -288,7 +288,7 @@ if [ "$osType" != "Darwin" ]; then if [[ "$pagMode" == "full" ]]; then if [ -d ${top_dir}/src/kit/taos-tools/packaging/rpm ]; then cd ${top_dir}/src/kit/taos-tools/packaging/rpm - taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}' | sed -e 's/-/_/g') + taos_tools_ver=$(git tag |grep -v taos | sort | tail -1) [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" ${csudo}./make-taos-tools-rpm.sh ${top_dir} \ diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index d74a962210318f59f4afc9a369f95503b342bbd2..6e64d77525f33c41b1c0af05ab624f9d15bdbf43 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -105,6 +105,10 @@ elif echo $osinfo | grep -qwi "debian"; then elif echo $osinfo | grep -qwi "Kylin"; then # echo "This is Kylin system" os_type=1 +elif echo $osinfo | grep -qwi "KylinSec"; then + # echo "This is KylinSec system" + os_type=2 + csudo="" elif echo $osinfo | grep -qwi "Red"; then # echo "This is Red Hat system" os_type=1 diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 8c45b0a7d12485d3e95554f7d2223790366f3401..b93ea11f45dfde847970bd4cfe0d5b6685d3a910 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -47,7 +47,7 @@ if [ -d ${top_dir}/src/kit/taos-tools/packaging/deb ]; then cd ${top_dir}/src/kit/taos-tools/packaging/deb [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" - taostools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}') + taostools_ver=$(git tag |grep -v taos | sort | tail -1) taostools_install_dir="${release_dir}/${clientName}Tools-${taostools_ver}" cd ${curr_dir} diff --git a/src/client/inc/tscBatchMerge.h b/src/client/inc/tscBatchMerge.h new file mode 100644 index 0000000000000000000000000000000000000000..12fe66c9cf6df4ee1d0be24def41d7e05efd8b82 --- /dev/null +++ b/src/client/inc/tscBatchMerge.h @@ -0,0 +1,274 @@ +/* +* Copyright (c) 2019 TAOS Data, Inc. +* +* This program is free software: you can use, redistribute, and/or modify +* it under the terms of the GNU Affero General Public License, version 3 +* or later ("AGPL"), as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +*/ + +#ifndef TDENGINE_TSCBATCHMERGE_H +#define TDENGINE_TSCBATCHMERGE_H + +#include "hash.h" +#include "taosmsg.h" +#include "tarray.h" +#include "tscUtil.h" +#include "tsclient.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A builder of SSubmitBlk. + */ +typedef struct SSubmitBlkBuilder { + // the metadata of the SSubmitBlk. + SSubmitBlk* metadata; + + // the array stores all the rows in a table, aka SArray. + SArray* rows; + +} SSubmitBlkBuilder; + +/** + * The builder to build SSubmitMsg::blocks. + */ +typedef struct SSubmitMsgBlocksBuilder { + // SHashObj. + SHashObj* blockBuilders; + int64_t vgId; +} SSubmitMsgBlocksBuilder; + +/** + * STableDataBlocksBuilder is a tool to build data blocks by append the existing data blocks in a vnode. + */ +typedef struct STableDataBlocksBuilder { + SSubmitMsgBlocksBuilder* blocksBuilder; + STableDataBlocks* firstBlock; + int64_t vgId; +} STableDataBlocksBuilder; + +/** + * STableDataBlocksListBuilder is a tool to build vnode data blocks list by appending exist data blocks. + */ +typedef struct STableDataBlocksListBuilder { + SHashObj* dataBlocksBuilders; +} STableDataBlocksListBuilder; + +/** + * A Builder to build SInsertStatementParam::pTableNameList. + */ +typedef struct STableNameListBuilder { + // store the unsorted table names, SArray. + SArray* pTableNameList; +} STableNameListBuilder; + +/** + * Create a SSubmitBlkBuilder using exist metadata. + * + * @param metadata the metadata. + * @return the SSubmitBlkBuilder. + */ +SSubmitBlkBuilder* createSSubmitBlkBuilder(SSubmitBlk* metadata); + +/** + * Destroy the SSubmitBlkBuilder. + * + * @param builder the SSubmitBlkBuilder. + */ +void destroySSubmitBlkBuilder(SSubmitBlkBuilder* builder); + +/** + * Append a SSubmitBlk* to the builder. The table uid in pBlock must be the same with the builder's. + * + * @param builder the SSubmitBlkBuilder. + * @param pBlock the pBlock to append. + * @return whether the append is success. + */ +bool appendSSubmitBlkBuilder(SSubmitBlkBuilder* builder, SSubmitBlk *pBlock); + + +/** + * Build and write SSubmitBlk to `target` + * + * @param builder the SSubmitBlkBuilder. + * @param target the target to write. + * @param nRows the number of rows in SSubmitBlk*. + * @return the writen bytes. + */ +size_t writeSSubmitBlkBuilder(SSubmitBlkBuilder* builder, SSubmitBlk* target, size_t* nRows); + +/** + * Get the expected writen bytes of `writeSSubmitBlkBuilder`. + * + * @param builder the SSubmitBlkBuilder. + * @return the expected writen bytes of `writeSSubmitBlkBuilder`. + */ +size_t nWriteSSubmitBlkBuilder(SSubmitBlkBuilder* builder); + +/** + * Create a SSubmitMsgBuilder. + * + * @param vgId the vgId of SSubmitMsg. + * @return the SSubmitMsgBuilder. + */ +SSubmitMsgBlocksBuilder* createSSubmitMsgBuilder(int64_t vgId); + +/** + * Get the expected writen bytes of `writeSSubmitMsgBlocksBuilder`. + * + * @param builder the SSubmitMsgBlocksBuilder. + * @return the expected writen bytes of `writeSSubmitMsgBlocksBuilder`. + */ +size_t nWriteSSubmitMsgBuilder(SSubmitMsgBlocksBuilder* builder); + +/** + * Build and write SSubmitMsg::blocks to `pBlocks` + * + * @param builder the SSubmitBlkBuilder. + * @param pBlocks the target to write. + * @param nRows the number of row in SSubmitMsg::blocks. + * @return the writen bytes. + */ +size_t writeSSubmitMsgBlocksBuilder(SSubmitMsgBlocksBuilder* builder, SSubmitBlk* pBlocks, size_t* nRows); + +/** + * Get the number of block in SSubmitMsgBlocksBuilder. + * @param builder the SSubmitMsgBlocksBuilder. + * @return the number of SSubmitBlk block. + */ +size_t nBlockSSubmitMsgBlocksBuilder(SSubmitMsgBlocksBuilder* builder); + +/** + * Destroy the SSubmitMsgBlocksBuilder. + * + * @param builder the SSubmitMsgBlocksBuilder to destroy. + */ +void destroySSubmitMsgBuilder(SSubmitMsgBlocksBuilder* builder); + +/** + * Append SSubmitMsg* to the SSubmitMsgBlocksBuilder. + * + * @param builder the SSubmitMsgBlocksBuilder. + * @param pBlocks the SSubmitBlk in SSubmitMsg::blocks. + * @param nBlocks the number of blocks in SSubmitMsg. + * @return whether the append is success. + */ +bool appendSSubmitMsgBlocks(SSubmitMsgBlocksBuilder* builder, SSubmitBlk* pBlocks, size_t nBlocks); + +/** + * Create the STableDataBlocksBuilder. + * + * @param vgId the vgId of STableDataBlocksBuilder. + * @return the STableDataBlocksBuilder. + */ +STableDataBlocksBuilder* createSTableDataBlocksBuilder(int64_t vgId); + +/** + * Destroy the STableDataBlocksBuilder. + * @param builder the STableDataBlocksBuilder. + */ +void destroySTableDataBlocksBuilder(STableDataBlocksBuilder *builder); + +/** + * Append a data blocks to STableDataBlocksBuilder. + * @param builder the STableDataBlocksBuilder. + * @param dataBlocks the dataBlocks to append. the vgId of dataBlocks must be same with the STableDataBlocksBuilder. + * @return whether the append is success. + */ +bool appendSTableDataBlocksBuilder(STableDataBlocksBuilder* builder, STableDataBlocks* dataBlocks); + +/** + * Build the data blocks for single vnode. + * @param builder the STableDataBlocksBuilder. + * @param nRows the number of row in STableDataBlocks. + * @return the data blocks for single vnode. + */ +STableDataBlocks* buildSTableDataBlocksBuilder(STableDataBlocksBuilder* builder, size_t* nRows); + +/** + * Create the STableDataBlocksListBuilder. + * + * @return the STableDataBlocksListBuilder. + */ +STableDataBlocksListBuilder* createSTableDataBlocksListBuilder(); + +/** + * Destroy the STableDataBlocksListBuilder. + * + * @param builder the STableDataBlocksListBuilder. + */ +void destroySTableDataBlocksListBuilder(STableDataBlocksListBuilder* builder); + +/** + * Append a data blocks to STableDataBlocksListBuilder. + * + * @param builder the STableDataBlocksListBuilder. + * @param dataBlocks the data blocks. + * @return whether the append is success. + */ +bool appendSTableDataBlocksListBuilder(STableDataBlocksListBuilder* builder, STableDataBlocks* dataBlocks); + +/** + * Build the vnode data blocks list. + * + * @param builder the STableDataBlocksListBuilder. + * @param nTables the number of table in vnode data blocks list. + * @param nRows the number of row in vnode data blocks list. + * @return the vnode data blocks list. + */ +SArray* buildSTableDataBlocksListBuilder(STableDataBlocksListBuilder* builder, size_t* nTables, size_t* nRows); + +/** + * Create STableNameListBuilder. + */ +STableNameListBuilder* createSTableNameListBuilder(); + +/** + * Destroy the STableNameListBuilder. + * @param builder the STableNameListBuilder. + */ +void destroySTableNameListBuilder(STableNameListBuilder* builder); + +/** + * Insert a SName to builder. + * + * @param builder the STableNameListBuilder. + * @param name the table name. + * @return whether it is success. + */ +bool insertSTableNameListBuilder(STableNameListBuilder* builder, SName* name); + +/** + * Build the STable name list. + * + * @param builder the STableNameListBuilder. + * @param numOfTables the number of table. + * @return the STable name list. + */ +SName** buildSTableNameListBuilder(STableNameListBuilder* builder, size_t* numOfTables); + +/** + * Merge the KV-PayLoad SQL objects into single one. + * The statements here must be an insertion statement and no schema attached. + * + * @param polls the array of SSqlObj*. + * @param nPolls the number of SSqlObj* in the array. + * @param result the returned result. result is not null! + * @return the status code. + */ +int32_t tscMergeSSqlObjs(SSqlObj** polls, size_t nPolls, SSqlObj *result); + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_TSCBATCHMERGE_H diff --git a/src/client/inc/tscBatchWrite.h b/src/client/inc/tscBatchWrite.h new file mode 100644 index 0000000000000000000000000000000000000000..0e7d0136b068c30ced3cbe158bc0e60bc660cae4 --- /dev/null +++ b/src/client/inc/tscBatchWrite.h @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_TSCBATCHWRITE_H +#define TDENGINE_TSCBATCHWRITE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "tthread.h" + +// forward declaration. +typedef struct STscObj STscObj; +typedef struct SSqlObj SSqlObj; +typedef struct SDispatcherTimeoutManager SDispatcherTimeoutManager; + +/** + * SAsyncBatchWriteDispatcher is an async batching write dispatcher (ABWD). ABWD accepts the recent SQL requests and put + * them in a queue waiting to be scheduled. When the number of requests in the queue reaches batch_size, it merges the + * requests in the queue and sends them to the server, thus reducing the network overhead caused by multiple + * communications to the server and directly improving the throughput of small object asynchronous writes. + */ +typedef struct SAsyncBatchWriteDispatcher { + // the client object. + STscObj* pClient; + + // the timeout manager. + SDispatcherTimeoutManager* timeoutManager; + + // the mutex to protect the dispatcher. + pthread_mutex_t bufferMutex; + + // the cond to signal when buffer not full. + pthread_cond_t notFull; + + // the maximum number of insertion rows in a batch. + int32_t batchSize; + + // the number of insertion rows in the buffer. + int32_t currentSize; + + // the number of items in the buffer. + int32_t bufferSize; + + // whether the dispatcher is shutdown. + bool shutdown; + + SSqlObj* buffer[]; +} SAsyncBatchWriteDispatcher; + +/** + * The manager of SAsyncBatchWriteDispatcher. Call dispatcherAcquire(...) to get the SAsyncBatchWriteDispatcher + * instance. SDispatcherManager will manage the life cycle of SAsyncBatchWriteDispatcher. + */ +typedef struct SDispatcherManager { + pthread_key_t key; + + // the maximum number of insertion rows in a batch. + int32_t batchSize; + + // the batching timeout in milliseconds. + int32_t timeoutMs; + + // specifies whether the dispatcher is thread local, if the dispatcher is not + // thread local, we will use the global dispatcher below. + bool isThreadLocal; + + // the global dispatcher, if thread local enabled, global will be set to NULL. + SAsyncBatchWriteDispatcher* pGlobal; + + // the client object. + STscObj* pClient; + +} SDispatcherManager; + +/** + * Control the timeout of the dispatcher queue. + */ +typedef struct SDispatcherTimeoutManager { + // the dispatcher that timeout manager belongs to. + SAsyncBatchWriteDispatcher* dispatcher; + + // the background thread. + pthread_t background; + + // the mutex to sleep the background thread. + pthread_mutex_t sleepMutex; + + // the cond to signal to background thread. + pthread_cond_t timeout; + + // the batching timeout in milliseconds. + int32_t timeoutMs; + + // whether the timeout manager is shutdown. + bool shutdown; +} SDispatcherTimeoutManager; + +/** + * A batch that polls from SAsyncBatchWriteDispatcher::buffer. + */ +typedef struct SBatchRequest { + size_t nRequests; + SSqlObj* pRequests[]; +} SBatchRequest; + +/** + * Create the dispatcher timeout manager. + */ +SDispatcherTimeoutManager* createSDispatcherTimeoutManager(SAsyncBatchWriteDispatcher* dispatcher, int32_t timeoutMs); + +/** + * Destroy the dispatcher timeout manager. + */ +void destroySDispatcherTimeoutManager(SDispatcherTimeoutManager* manager); + +/** + * Check if the timeout manager is shutdown. + * @param manager the timeout manager. + * @return whether the timeout manager is shutdown. + */ +bool isShutdownSDispatcherTimeoutManager(SDispatcherTimeoutManager* manager); + +/** + * Shutdown the SDispatcherTimeoutManager. + * @param manager the SDispatcherTimeoutManager. + */ +void shutdownSDispatcherTimeoutManager(SDispatcherTimeoutManager* manager); + +/** + * Merge SSqlObjs into single SSqlObj. + * + * @param pRequest the batch request. + * @param batch the batch SSqlObj*. + * @return the status code. + */ +int32_t dispatcherBatchBuilder(SBatchRequest* pRequest, SSqlObj** batch); + +/** + * Merge the sql statements and execute the merged sql statement asynchronously. + * + * @param pRequest the batch request. the request will be promised to free after calling this function. + */ +void dispatcherAsyncExecute(SBatchRequest* pRequest); + +/** + * Merge the sql statements and execute the merged sql statement. + * + * @param pRequest the batch request. you must call free(pRequest) after calling this function. + */ +void dispatcherExecute(SBatchRequest* pRequest); + +/** + * Create the async batch write dispatcher. + * + * @param pClient the client object. + * @param batchSize When user submit an insert sql to `taos_query_a`, the SSqlObj* will be buffered instead of executing + * it. If the number of the buffered rows reach `batchSize`, all the SSqlObj* will be merged and sent to vnodes. + * @param timeout The SSqlObj* will be sent to vnodes no more than `timeout` milliseconds. But the actual time + * vnodes received the SSqlObj* depends on the network quality. + */ +SAsyncBatchWriteDispatcher* createSAsyncBatchWriteDispatcher(STscObj* pClient, int32_t batchSize, int32_t timeoutMs); + +/** + * Destroy the async auto batch dispatcher. + */ +void destroySAsyncBatchWriteDispatcher(SAsyncBatchWriteDispatcher* dispatcher); + +/** + * Check if the current sql object can be dispatch by ABWD. + * 1. auto batch feature on the sql object must be enabled. + * 2. must be an `insert into ... value ...` statement. + * 3. the payload type must be kv payload. + * 4. no schema attached. + * + * @param dispatcher the dispatcher. + * @param pSql the sql object to check. + * @return returns true if the sql object can be dispatch by ABWD. + */ +bool dispatcherCanDispatch(SAsyncBatchWriteDispatcher* dispatcher, SSqlObj* pSql); + +/** + * Try to offer the SSqlObj* to the dispatcher. If the number of row reach `batchSize`, the function + * will merge the SSqlObj* in the buffer and send them to the vnodes. + * + * @param pSql the insert statement to offer. + * @return if offer success, returns true. + */ +bool dispatcherTryDispatch(SAsyncBatchWriteDispatcher* dispatcher, SSqlObj* pSql); + +/** + * Create the manager of SAsyncBatchWriteDispatcher. + * + * @param pClient the client object. + * @param batchSize the batchSize of SAsyncBatchWriteDispatcher. + * @param timeoutMs the timeoutMs of SAsyncBatchWriteDispatcher. + * @param isThreadLocal specifies whether the dispatcher is thread local. + * @return the SAsyncBatchWriteDispatcher manager. + */ +SDispatcherManager* createDispatcherManager(STscObj* pClient, int32_t batchSize, int32_t timeoutMs, bool isThreadLocal); + +/** + * Destroy the SDispatcherManager. + * (will destroy all the instances of SAsyncBatchWriteDispatcher in the thread local variable) + * + * @param manager the SDispatcherManager. + */ +void destroyDispatcherManager(SDispatcherManager* manager); + +/** + * Get an instance of SAsyncBatchWriteDispatcher. + * + * @param manager the SDispatcherManager. + * @return the SAsyncBatchWriteDispatcher instance. + */ +SAsyncBatchWriteDispatcher* dispatcherAcquire(SDispatcherManager* manager); + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_TSCBATCHWRITE_H diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 553dd3977d8ec0d6bca005cc20abe7c81350892b..c96cc8c1710cb33b298d272cde56ed65ee7ff072 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -144,6 +144,8 @@ void doRetrieveSubqueryData(SSchedMsg *pMsg); SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, uint16_t bytes, uint32_t offset); +void destroySTableDataBlocksList(SArray* pDataBlocks); +void destroySTableDataBlocks(STableDataBlocks* pDataBlocks); void* tscDestroyBlockArrayList(SSqlObj* pSql, SArray* pDataBlockList); void* tscDestroyUdfArrayList(SArray* pUdfList); void* tscDestroyBlockHashTable(SSqlObj* pSql, SHashObj* pBlockHashTable, bool removeMeta); diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 07b44d205ebba3109ca42a37edc2685e8e606f47..3598d8f81fa2269d916f1953258cbe9373713165 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -45,6 +45,7 @@ typedef enum { // forward declaration struct SSqlInfo; +typedef struct SDispatcherManager SDispatcherManager; typedef void (*__async_cb_func_t)(void *param, TAOS_RES *tres, int32_t numOfRows); typedef void (*_freeSqlSupporter)(void **); @@ -256,7 +257,7 @@ typedef struct SInsertStatementParam { int32_t batchSize; // for parameter ('?') binding and batch processing int32_t numOfParams; - + int32_t numOfRows; int32_t numOfFiles; char msg[512]; // error message @@ -352,7 +353,8 @@ typedef struct STscObj { SRpcCorEpSet *tscCorMgmtEpSet; pthread_mutex_t mutex; int32_t numOfObj; // number of sqlObj from this tscObj - + + SDispatcherManager*dispatcherManager; SReqOrigin from; } STscObj; @@ -400,9 +402,10 @@ typedef struct SSqlObj { struct SSqlObj *prev, *next; int64_t self; - // connect alive + int64_t lastAlive; void * pPrevContext; + bool enableBatch; } SSqlObj; typedef struct SSqlStream { @@ -503,7 +506,7 @@ void tscCloseTscObj(void *pObj); TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, TAOS **taos); TAOS_RES* taos_query_h(TAOS* taos, const char *sqlstr, int64_t* res); -TAOS_RES * taos_query_ra(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *param); +TAOS_RES * taos_query_ra(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *param, bool enableBatch); // get taos connection unused session number int32_t taos_unused_session(TAOS* taos); diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index e75ce8dc0106bafa53411f585ad8b708c1c1bf99..c8ef467da4a15feebd3d76976679a3c22e8a091f 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -13,16 +13,19 @@ * along with this program. If not, see . */ + #include "os.h" +#include "osAtomic.h" +#include "tarray.h" #include "tutil.h" +#include "qTableMeta.h" #include "tnote.h" #include "trpc.h" +#include "tscBatchWrite.h" #include "tscLog.h" #include "tscSubquery.h" #include "tscUtil.h" -#include "tsched.h" -#include "qTableMeta.h" #include "tsclient.h" static void tscAsyncQueryRowsForNextVnode(void *param, TAOS_RES *tres, int numOfRows); @@ -334,6 +337,26 @@ bool appendTagsFilter(SSqlObj* pSql) { return false; } + // check tags is blank or '' + char* p1 = pTscObj->tags; + if (strcmp(p1, "\'\'") == 0) { + tscDebug("TAGS 0x%" PRIx64 " tags is empty. user=%s", pSql->self, pTscObj->user); + return false; + } + bool blank = true; + while(*p1 != 0) { + if(*p1 != ' ') { + blank = false; + break; + } + ++p1; + } + // result + if(blank) { + tscDebug("TAGS 0x%" PRIx64 " tags is all blank. user=%s", pSql->self, pTscObj->user); + return false; + } + char * p = insertTags(pSql->sqlstr, pTscObj->tags); if(p == NULL) { return false; @@ -378,7 +401,6 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para pCmd->resColumnId = TSDB_RES_COL_ID; taosAcquireRef(tscObjRef, pSql->self); - int32_t code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { @@ -392,18 +414,27 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para taosReleaseRef(tscObjRef, pSql->self); return; } - - SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); + + if (pObj->dispatcherManager != NULL) { + SAsyncBatchWriteDispatcher * dispatcher = dispatcherAcquire(pObj->dispatcherManager); + if (dispatcherTryDispatch(dispatcher, pSql)) { + taosReleaseRef(tscObjRef, pSql->self); + tscDebug("sql obj %p has been buffer in insert buffer", pSql); + return; + } + } + + SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd); executeQuery(pSql, pQueryInfo); taosReleaseRef(tscObjRef, pSql->self); } // TODO return the correct error code to client in tscQueueAsyncError void taos_query_a(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *param) { - taos_query_ra(taos, sqlstr, fp, param); + taos_query_ra(taos, sqlstr, fp, param, tsWriteBatchSize > 0); } -TAOS_RES * taos_query_ra(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *param) { +TAOS_RES * taos_query_ra(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *param, bool enableBatch) { STscObj *pObj = (STscObj *)taos; if (pObj == NULL || pObj->signature != pObj) { tscError("pObj:%p is NULL or freed", pObj); @@ -429,6 +460,8 @@ TAOS_RES * taos_query_ra(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, v return NULL; } + pSql->enableBatch = enableBatch; + doAsyncQuery(pObj, pSql, fp, param, sqlstr, sqlLen); return pSql; diff --git a/src/client/src/tscBatchMerge.c b/src/client/src/tscBatchMerge.c new file mode 100644 index 0000000000000000000000000000000000000000..177de143f9ab26ba63c7b9db6819e137876220e0 --- /dev/null +++ b/src/client/src/tscBatchMerge.c @@ -0,0 +1,554 @@ +/* +* Copyright (c) 2019 TAOS Data, Inc. +* +* This program is free software: you can use, redistribute, and/or modify +* it under the terms of the GNU Affero General Public License, version 3 +* or later ("AGPL"), as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +*/ + +#include "tscBatchMerge.h" + +/** + * A util function to compare two SName. + */ +static int32_t compareSName(const void *left, const void *right) { + if (left == right) { + return 0; + } + SName* x = *(SName** ) left; + SName* y = *(SName** ) right; + return memcmp(x, y, sizeof(SName)); +} + +/** + * A util function to sort SArray by key. + */ +static int32_t compareSMemRow(const void *x, const void *y) { + TSKEY left = memRowKey(*(void **) x); + TSKEY right = memRowKey(*(void **) y); + if (left == right) { + return 0; + } else { + return left > right ? 1 : -1; + } +} + +/** + * If the SSubmitBlkBuilder of pBlock->uid is present, returns it. Otherwise, build a new SSubmitBlkBuilder. + * + * @param builder the SSubmitMsgBlocksBuilder. + * @param pBlock the SSubmitBlk. + * @return the SSubmitBlkBuilder (NULL means failure). + */ +inline static SSubmitBlkBuilder* computeIfAbsentSSubmitBlkBuilder(SSubmitMsgBlocksBuilder* builder, SSubmitBlk* pBlock) { + SSubmitBlkBuilder** iter = taosHashGet(builder->blockBuilders, &pBlock->uid, sizeof(pBlock->uid)); + SSubmitBlkBuilder* blocksBuilder = NULL; + if (iter) { + return *iter; + } + + blocksBuilder = createSSubmitBlkBuilder(pBlock); + if (!blocksBuilder) { + return NULL; + } + + if (taosHashPut(builder->blockBuilders, &pBlock->uid, sizeof(pBlock->uid), &blocksBuilder, sizeof(SArray*))) { + destroySSubmitBlkBuilder(blocksBuilder); + return NULL; + } + + return blocksBuilder; +} + +SName** buildSTableNameListBuilder(STableNameListBuilder* builder, size_t* nTables) { + if (!taosArrayGetSize(builder->pTableNameList)) { + *nTables = 0; + return NULL; + } + + // sort and unique. + taosArraySort(builder->pTableNameList, compareSName); + size_t tail = 0; + size_t nNames = taosArrayGetSize(builder->pTableNameList); + for (size_t i = 1; i < nNames; ++i) { + SName* last = taosArrayGetP(builder->pTableNameList, tail); + SName* current = taosArrayGetP(builder->pTableNameList, i); + if (memcmp(last, current, sizeof(SName)) != 0) { + ++tail; + taosArraySet(builder->pTableNameList, tail, ¤t); + } + } + + // build table names list. + SName** tableNames = calloc(tail + 1, sizeof(SName*)); + if (!tableNames) { + return NULL; + } + + // clone data. + for (size_t i = 0; i <= tail; ++i) { + SName* clone = malloc(sizeof(SName)); + if (!clone) { + goto error; + } + memcpy(clone, taosArrayGetP(builder->pTableNameList, i), sizeof(SName)); + tableNames[i] = clone; + } + + *nTables = tail + 1; + return tableNames; + +error: + for (size_t i = 0; i <= tail; ++i) { + if (tableNames[i]) { + free(tableNames[i]); + } + } + free(tableNames); + return NULL; +} + +SSubmitBlkBuilder* createSSubmitBlkBuilder(SSubmitBlk* metadata) { + SSubmitBlkBuilder* builder = calloc(1, sizeof(SSubmitBlkBuilder)); + if (!builder) { + return NULL; + } + + builder->rows = taosArrayInit(1, sizeof(SMemRow)); + if (!builder->rows) { + free(builder); + return NULL; + } + + builder->metadata = calloc(1, sizeof(SSubmitBlk)); + if (!builder->metadata) { + taosArrayDestroy(&builder->rows); + free(builder); + return NULL; + } + memcpy(builder->metadata, metadata, sizeof(SSubmitBlk)); + + return builder; +} + +void destroySSubmitBlkBuilder(SSubmitBlkBuilder* builder) { + if (!builder) { + return; + } + taosArrayDestroy(&builder->rows); + free(builder->metadata); + free(builder); +} + +bool appendSSubmitBlkBuilder(SSubmitBlkBuilder* builder, SSubmitBlk* pBlock) { + assert(pBlock->uid == builder->metadata->uid); + assert(pBlock->schemaLen == 0); + + // shadow copy all the SMemRow to SSubmitBlkBuilder::rows. + char* pRow = pBlock->data; + char* pEnd = pBlock->data + htonl(pBlock->dataLen); + while (pRow < pEnd) { + if (!taosArrayPush(builder->rows, &pRow)) { + return false; + } + pRow += memRowTLen(pRow); + } + + return true; +} + +size_t writeSSubmitBlkBuilder(SSubmitBlkBuilder* builder, SSubmitBlk* target, size_t* nRows) { + memcpy(target, builder->metadata, sizeof(SSubmitBlk)); + + // sort SSubmitBlkBuilder::rows by timestamp. + uint32_t dataLen = 0; + taosArraySort(builder->rows, compareSMemRow); + + // deep copy all the SMemRow to target. + size_t nMemRows = taosArrayGetSize(builder->rows); + for (int i = 0; i < nMemRows; ++i) { + char* pRow = taosArrayGetP(builder->rows, i); + memcpy(POINTER_SHIFT(target->data, dataLen), pRow, memRowTLen(pRow)); + dataLen += memRowTLen(pRow); + } + + *nRows = nMemRows; + + target->schemaLen = 0; + target->dataLen = (int32_t) htonl(dataLen); + target->numOfRows = (int16_t) htons(*nRows); + + return dataLen + sizeof(SSubmitBlk); +} + +size_t nWriteSSubmitBlkBuilder(SSubmitBlkBuilder* builder) { + size_t dataLen = 0; + size_t nRows = taosArrayGetSize(builder->rows); + for (int i = 0; i < nRows; ++i) { + char* pRow = taosArrayGetP(builder->rows, i); + dataLen += memRowTLen(pRow); + } + return dataLen + sizeof(SSubmitBlk); +} + +SSubmitMsgBlocksBuilder* createSSubmitMsgBuilder(int64_t vgId) { + SSubmitMsgBlocksBuilder* builder = calloc(1, sizeof(SSubmitMsgBlocksBuilder)); + if (!builder) { + return NULL; + } + builder->vgId = vgId; + + builder->blockBuilders = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); + if (!builder->blockBuilders) { + free(builder); + return NULL; + } + return builder; +} + +size_t nWriteSSubmitMsgBuilder(SSubmitMsgBlocksBuilder* builder) { + size_t nWrite = 0; + SSubmitBlkBuilder** iter = taosHashIterate(builder->blockBuilders, NULL); + while (iter) { + SSubmitBlkBuilder* blocksBuilder = *iter; + nWrite += nWriteSSubmitBlkBuilder(blocksBuilder); + iter = taosHashIterate(builder->blockBuilders, iter); + } + return nWrite; +} + +size_t writeSSubmitMsgBlocksBuilder(SSubmitMsgBlocksBuilder* builder, SSubmitBlk* pBlocks, size_t* nRows) { + size_t nWrite = 0; + SSubmitBlkBuilder** iter = taosHashIterate(builder->blockBuilders, NULL); + + // copy all the SSubmitBlk to pBlocks. + while (iter) { + size_t nSubRows = 0; + SSubmitBlkBuilder* blocksBuilder = *iter; + SSubmitBlk* pBlock = POINTER_SHIFT(pBlocks, nWrite); + nWrite += writeSSubmitBlkBuilder(blocksBuilder, pBlock, &nSubRows); + *nRows += nSubRows; + iter = taosHashIterate(builder->blockBuilders, iter); + } + return nWrite; +} + +size_t nBlockSSubmitMsgBlocksBuilder(SSubmitMsgBlocksBuilder* builder) { + return taosHashGetSize(builder->blockBuilders); +} + +void destroySSubmitMsgBuilder(SSubmitMsgBlocksBuilder* builder) { + if (!builder) { + return; + } + + SSubmitBlkBuilder** iter = taosHashIterate(builder->blockBuilders, NULL); + while (iter) { + destroySSubmitBlkBuilder(*iter); + iter = taosHashIterate(builder->blockBuilders, iter); + } + taosHashCleanup(builder->blockBuilders); + free(builder); +} + +bool appendSSubmitMsgBlocks(SSubmitMsgBlocksBuilder* builder, SSubmitBlk* pBlocks, size_t nBlocks) { + SSubmitBlk* pBlock = pBlocks; + for (size_t i = 0; i < nBlocks; ++i) { + // not support SSubmitBlk with schema. + assert(pBlock->schemaLen == 0); + + // get the builder of specific table (by pBlock->uid). + SSubmitBlkBuilder* blocksBuilder = computeIfAbsentSSubmitBlkBuilder(builder, pBlock); + if (!blocksBuilder) { + return false; + } + + if (!appendSSubmitBlkBuilder(blocksBuilder, pBlock)) { + return false; + } + + // go to next block. + size_t blockSize = sizeof (SSubmitBlk) + htonl(pBlock->dataLen); + pBlock = POINTER_SHIFT(pBlock, blockSize); + } + return true; +} + +STableDataBlocksBuilder* createSTableDataBlocksBuilder(int64_t vgId) { + STableDataBlocksBuilder* builder = calloc(1, sizeof(STableDataBlocksBuilder)); + if (!builder) { + return NULL; + } + + builder->blocksBuilder = createSSubmitMsgBuilder(vgId); + if (!builder->blocksBuilder) { + free(builder); + return NULL; + } + + builder->vgId = vgId; + builder->firstBlock = NULL; + return builder; +} + +void destroySTableDataBlocksBuilder(STableDataBlocksBuilder* builder) { + if (!builder) { + return; + } + + destroySSubmitMsgBuilder(builder->blocksBuilder); + free(builder); +} + +bool appendSTableDataBlocksBuilder(STableDataBlocksBuilder* builder, STableDataBlocks* dataBlocks) { + // the data blocks vgId must be same with builder vgId. + if (!dataBlocks || dataBlocks->vgId != builder->vgId) { + return false; + } + + if (!builder->firstBlock) { + builder->firstBlock = dataBlocks; + } + + SSubmitBlk* pBlocks = (SSubmitBlk *)(dataBlocks->pData + dataBlocks->headerSize); + return appendSSubmitMsgBlocks(builder->blocksBuilder, pBlocks, dataBlocks->numOfTables); +} + +STableDataBlocks* buildSTableDataBlocksBuilder(STableDataBlocksBuilder* builder, size_t* nRows) { + SSubmitMsgBlocksBuilder* blocksBuilder = builder->blocksBuilder; + STableDataBlocks *firstBlock = builder->firstBlock; + if (!firstBlock) { + return NULL; + } + + size_t nWriteSize = nWriteSSubmitMsgBuilder(builder->blocksBuilder); + size_t nHeaderSize = firstBlock->headerSize; + size_t nAllocSize = nWriteSize + nHeaderSize; + + // allocate data blocks. + STableDataBlocks* dataBlocks = NULL; + int32_t code = tscCreateDataBlock(nAllocSize, 0, (int32_t) nHeaderSize, &firstBlock->tableName, firstBlock->pTableMeta, &dataBlocks); + if (code != TSDB_CODE_SUCCESS) { + return NULL; + } + + // build the header (using first block). + dataBlocks->size = nHeaderSize; + memcpy(dataBlocks->pData, firstBlock->pData, nHeaderSize); + + // build the SSubmitMsg::blocks. + dataBlocks->size += writeSSubmitMsgBlocksBuilder(blocksBuilder, (SSubmitBlk *) (dataBlocks->pData + nHeaderSize), nRows); + dataBlocks->numOfTables = (int32_t) nBlockSSubmitMsgBlocksBuilder(blocksBuilder); + return dataBlocks; +} + +STableDataBlocksListBuilder* createSTableDataBlocksListBuilder() { + STableDataBlocksListBuilder* builder = calloc(1, sizeof(STableDataBlocksListBuilder)); + if (!builder) { + return NULL; + } + + builder->dataBlocksBuilders = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); + if (!builder->dataBlocksBuilders) { + free(builder); + return NULL; + } + + return builder; +} + +void destroySTableDataBlocksListBuilder(STableDataBlocksListBuilder* builder) { + if (!builder) { + return; + } + + STableDataBlocksBuilder** iter = taosHashIterate(builder->dataBlocksBuilders, NULL); + while (iter) { + destroySTableDataBlocksBuilder(*iter); + iter = taosHashIterate(builder->dataBlocksBuilders, iter); + } + taosHashCleanup(builder->dataBlocksBuilders); + free(builder); +} + +bool appendSTableDataBlocksListBuilder(STableDataBlocksListBuilder* builder, STableDataBlocks* dataBlocks) { + // get the data blocks builder of specific vgId. + STableDataBlocksBuilder** item = taosHashGet(builder->dataBlocksBuilders, &dataBlocks->vgId, sizeof(dataBlocks->vgId)); + STableDataBlocksBuilder* blocksBuilder = NULL; + if (item) { + blocksBuilder = *item; + } else { + blocksBuilder = createSTableDataBlocksBuilder(dataBlocks->vgId); + if (!blocksBuilder) { + return false; + } + + if (taosHashPut(builder->dataBlocksBuilders, &dataBlocks->vgId, sizeof(dataBlocks->vgId), &blocksBuilder, sizeof(STableDataBlocksBuilder*))) { + destroySTableDataBlocksBuilder(blocksBuilder); + return false; + } + } + + // append to this builder. + return appendSTableDataBlocksBuilder(blocksBuilder, dataBlocks); +} + +SArray* buildSTableDataBlocksListBuilder(STableDataBlocksListBuilder* builder, size_t* nTables, size_t* nRows) { + SArray* pVnodeDataBlockList = taosArrayInit(taosHashGetSize(builder->dataBlocksBuilders), sizeof(STableDataBlocks*)); + if (!pVnodeDataBlockList) { + return NULL; + } + + // build data blocks of each vgId. + STableDataBlocksBuilder** iter = taosHashIterate(builder->dataBlocksBuilders, NULL); + while (iter) { + size_t nSubRows = 0; + STableDataBlocksBuilder* dataBlocksBuilder = *iter; + STableDataBlocks* dataBlocks = buildSTableDataBlocksBuilder(dataBlocksBuilder, &nSubRows); + if (!dataBlocks) { + goto error; + } + *nTables += dataBlocks->numOfTables; + *nRows += nSubRows; + + taosArrayPush(pVnodeDataBlockList, &dataBlocks); + iter = taosHashIterate(builder->dataBlocksBuilders, iter); + } + return pVnodeDataBlockList; + +error: + for (int i = 0; i < taosArrayGetSize(pVnodeDataBlockList); ++i) { + STableDataBlocks* dataBlocks = taosArrayGetP(pVnodeDataBlockList, i); + tscDestroyDataBlock(NULL, dataBlocks, false); + } + taosArrayDestroy(&pVnodeDataBlockList); + return NULL; +} + +STableNameListBuilder* createSTableNameListBuilder() { + STableNameListBuilder* builder = calloc(1, sizeof(STableNameListBuilder)); + if (!builder) { + return NULL; + } + + builder->pTableNameList = taosArrayInit(1, sizeof(SName*)); + if (!builder->pTableNameList) { + free(builder); + return NULL; + } + + return builder; +} + +void destroySTableNameListBuilder(STableNameListBuilder* builder) { + if (!builder) { + return; + } + taosArrayDestroy(&builder->pTableNameList); + free(builder); +} + +bool insertSTableNameListBuilder(STableNameListBuilder* builder, SName* name) { + return taosArrayPush(builder->pTableNameList, &name); +} + +int32_t tscMergeSSqlObjs(SSqlObj** polls, size_t nPolls, SSqlObj* result) { + // statement array is empty. + if (!polls || !nPolls) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + STableDataBlocksListBuilder* builder = createSTableDataBlocksListBuilder(); + if (!builder) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + STableNameListBuilder* nameListBuilder = createSTableNameListBuilder(); + if (!nameListBuilder) { + destroySTableDataBlocksListBuilder(builder); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + // append the existing data blocks to builder. + for (size_t i = 0; i < nPolls; ++i) { + SSqlObj *pSql = polls[i]; + SInsertStatementParam* pInsertParam = &pSql->cmd.insertParam; + if (!pInsertParam->pDataBlocks) { + continue; + } + + assert(pInsertParam->payloadType == PAYLOAD_TYPE_KV); + assert(!pInsertParam->schemaAttached); + + // append each vnode data block to the builder. + size_t nBlocks = taosArrayGetSize(pInsertParam->pDataBlocks); + for (size_t j = 0; j < nBlocks; ++j) { + STableDataBlocks* tableBlock = taosArrayGetP(pInsertParam->pDataBlocks, j); + if (!appendSTableDataBlocksListBuilder(builder, tableBlock)) { + destroySTableDataBlocksListBuilder(builder); + destroySTableNameListBuilder(nameListBuilder); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + for (int k = 0; k < pInsertParam->numOfTables; ++k) { + if (!insertSTableNameListBuilder(nameListBuilder, pInsertParam->pTableNameList[k])) { + destroySTableDataBlocksListBuilder(builder); + destroySTableNameListBuilder(nameListBuilder); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + } + } + } + + // build the vnode data blocks. + size_t nBlocks = 0; + size_t nRows = 0; + SInsertStatementParam* pInsertParam = &result->cmd.insertParam; + SArray* pVnodeDataBlocksList = buildSTableDataBlocksListBuilder(builder, &nBlocks, &nRows); + if (!pVnodeDataBlocksList) { + destroySTableDataBlocksListBuilder(builder); + destroySTableNameListBuilder(nameListBuilder); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + // build the table name list. + size_t nTables = 0; + SName** pTableNameList = buildSTableNameListBuilder(nameListBuilder, &nTables); + if (!pTableNameList) { + destroySTableDataBlocksListBuilder(builder); + destroySTableNameListBuilder(nameListBuilder); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + if (nTables != nBlocks) { + destroySTableDataBlocksListBuilder(builder); + destroySTableNameListBuilder(nameListBuilder); + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + // replace table name list. + if (pInsertParam->pTableNameList) { + destroyTableNameList(pInsertParam); + } + pInsertParam->pTableNameList = pTableNameList; + pInsertParam->numOfTables = (int32_t) nTables; + + // replace vnode data blocks. + if (pInsertParam->pDataBlocks) { + tscDestroyBlockArrayList(result, pInsertParam->pDataBlocks); + } + pInsertParam->pDataBlocks = pVnodeDataBlocksList; + pInsertParam->numOfRows = (int32_t) nRows; + + // clean up. + destroySTableDataBlocksListBuilder(builder); + destroySTableNameListBuilder(nameListBuilder); + return TSDB_CODE_SUCCESS; +} diff --git a/src/client/src/tscBatchWrite.c b/src/client/src/tscBatchWrite.c new file mode 100644 index 0000000000000000000000000000000000000000..7c1c7b14157c54675ac5f5df060e68c3843226e5 --- /dev/null +++ b/src/client/src/tscBatchWrite.c @@ -0,0 +1,603 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "osAtomic.h" + +#include "tscBatchMerge.h" +#include "tscBatchWrite.h" +#include "tscLog.h" +#include "tscSubquery.h" +#include "tsclient.h" + +/** + * Represents the callback function and its context. + */ +typedef struct { + __async_cb_func_t fp; + void* param; +} SCallbackHandler; + +/** + * The context of `batchResultCallback`. + */ +typedef struct { + size_t nHandlers; + SCallbackHandler handler[]; +} SBatchCallbackContext; + +/** + * Get the number of insertion row in the sql statement. + * + * @param pSql the sql statement. + * @return int32_t the number of insertion row. + */ +inline static int32_t statementGetInsertionRows(SSqlObj* pSql) { return pSql->cmd.insertParam.numOfRows; } + +/** + * Return the error result to the callback function, and release the sql object. + * + * @param pSql the sql object. + * @param code the error code of the error result. + */ +inline static void tscReturnsError(SSqlObj* pSql, int code) { + if (pSql == NULL) { + return; + } + + pSql->res.code = code; + tscAsyncResultOnError(pSql); +} + +/** + * Proxy function to perform sequentially insert operation. + * + * @param param the context of `batchResultCallback`. + * @param tres the result object. + * @param code the error code. + */ +static void batchResultCallback(void* param, TAOS_RES* tres, int32_t code) { + SBatchCallbackContext* context = param; + SSqlObj* res = tres; + + // handle corner case [context == null]. + if (context == NULL) { + tscError("context in `batchResultCallback` is null, which should not happen"); + if (tres) { + taosReleaseRef(tscObjRef, res->self); + } + return; + } + + // handle corner case [res == null]. + if (res == NULL) { + tscError("tres in `batchResultCallback` is null, which should not happen"); + free(context); + return; + } + + // handle results. + tscDebug("async batch result callback, number of item: %zu", context->nHandlers); + for (int i = 0; i < context->nHandlers; ++i) { + // the result object is shared by many sql objects. + // therefore, we need to increase the ref count. + taosAcquireRef(tscObjRef, res->self); + + SCallbackHandler* handler = &context->handler[i]; + handler->fp(handler->param, res, code); + } + + taosReleaseRef(tscObjRef, res->self); + free(context); +} + +int32_t dispatcherBatchBuilder(SBatchRequest* pRequest, SSqlObj** batch) { + assert(pRequest); + assert(pRequest->pRequests); + assert(pRequest->nRequests); + + // create the callback context. + SBatchCallbackContext* context = + calloc(1, sizeof(SBatchCallbackContext) + pRequest->nRequests * sizeof(SCallbackHandler)); + if (context == NULL) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + tscDebug("create batch call back context: %p", context); + + // initialize the callback context. + context->nHandlers = pRequest->nRequests; + for (size_t i = 0; i < pRequest->nRequests; ++i) { + SSqlObj* pSql = pRequest->pRequests[i]; + context->handler[i].fp = pSql->fp; + context->handler[i].param = pSql->param; + } + + // merge the statements into single one. + tscDebug("start to merge %zu sql objs", pRequest->nRequests); + SSqlObj* pFirst = pRequest->pRequests[0]; + int32_t code = tscMergeSSqlObjs(pRequest->pRequests, pRequest->nRequests, pFirst); + if (code != TSDB_CODE_SUCCESS) { + const char* msg = tstrerror(code); + tscDebug("failed to merge sql objects: %s", msg); + free(context); + return code; + } + + pFirst->fp = batchResultCallback; + pFirst->param = context; + pFirst->fetchFp = pFirst->fp; + taosAcquireRef(tscObjRef, pFirst->self); + *batch = pFirst; + + for (int i = 0; i < pRequest->nRequests; ++i) { + SSqlObj* pSql = pRequest->pRequests[i]; + taosReleaseRef(tscObjRef, pSql->self); + } + return code; +} + +/** + * Poll all the SSqlObj* in the dispatcher's buffer (No Lock). After call this function, + * you need to notify dispatcher->notFull by yourself. + * + * @param dispatcher the dispatcher. + * @param nPolls the number of polled SSqlObj*. + * @return all the SSqlObj* in the buffer. + */ +inline static SBatchRequest* dispatcherPollAll(SAsyncBatchWriteDispatcher* dispatcher) { + if (!dispatcher->bufferSize) { + return NULL; + } + + SBatchRequest* pRequest = malloc(sizeof(SBatchRequest) + sizeof(SSqlObj*) * dispatcher->bufferSize); + if (pRequest == NULL) { + tscError("failed to poll all items: out of memory"); + return NULL; + } + + memcpy(pRequest->pRequests, dispatcher->buffer, sizeof(SSqlObj*) * dispatcher->bufferSize); + pRequest->nRequests = dispatcher->bufferSize; + dispatcher->currentSize = 0; + dispatcher->bufferSize = 0; + return pRequest; +} + +/** + * Poll all the SSqlObj* in the dispatcher's buffer. + * + * @param dispatcher the dispatcher. + * @return all the SSqlObj* in the buffer. + */ +inline static SBatchRequest* dispatcherLockPollAll(SAsyncBatchWriteDispatcher* dispatcher) { + SBatchRequest* pRequest = NULL; + pthread_mutex_lock(&dispatcher->bufferMutex); + pRequest = dispatcherPollAll(dispatcher); + pthread_cond_broadcast(&dispatcher->notFull); + pthread_mutex_unlock(&dispatcher->bufferMutex); + return pRequest; +} + +/** + * @brief Try to offer the SSqlObj* to the dispatcher. + * + * @param dispatcher the async bulk write dispatcher. + * @param pSql the sql object to offer. + * @return return whether offer success. + */ +inline static bool dispatcherTryOffer(SAsyncBatchWriteDispatcher* dispatcher, SSqlObj* pSql) { + pthread_mutex_lock(&dispatcher->bufferMutex); + + // if dispatcher is shutdown, must fail back to normal insertion. + // usually not happen, unless taos_query_a(...) after taos_close(...). + if (atomic_load_8(&dispatcher->shutdown)) { + pthread_mutex_unlock(&dispatcher->bufferMutex); + return false; + } + + // the buffer is full. + while (dispatcher->currentSize >= dispatcher->batchSize) { + if (pthread_cond_wait(&dispatcher->notFull, &dispatcher->bufferMutex)) { + pthread_mutex_unlock(&dispatcher->bufferMutex); + return false; + } + } + + dispatcher->buffer[dispatcher->bufferSize++] = pSql; + dispatcher->currentSize += statementGetInsertionRows(pSql); + tscDebug("sql obj %p has been write to insert buffer", pSql); + + if (dispatcher->currentSize < dispatcher->batchSize) { + pthread_mutex_unlock(&dispatcher->bufferMutex); + return true; + } + + // the dispatcher reaches batch size. + SBatchRequest* pRequest = dispatcherPollAll(dispatcher); + pthread_cond_broadcast(&dispatcher->notFull); + pthread_mutex_unlock(&dispatcher->bufferMutex); + + if (pRequest) { + dispatcherAsyncExecute(pRequest); + } + return true; +} + +void dispatcherExecute(SBatchRequest* pRequest) { + int32_t code = TSDB_CODE_SUCCESS; + // no item in the buffer (items has been taken by other threads). + if (!pRequest) { + return; + } + + assert(pRequest->pRequests); + assert(pRequest->nRequests); + + // merge the statements into single one. + SSqlObj* pSql = NULL; + code = dispatcherBatchBuilder(pRequest, &pSql); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + tscDebug("merging %zu sql objs into %p", pRequest->nRequests, pSql); + tscHandleMultivnodeInsert(pSql); + return; +_error: + tscError("send async batch sql obj failed, reason: %s", tstrerror(code)); + + // handling the failures. + for (size_t i = 0; i < pRequest->nRequests; ++i) { + SSqlObj* item = pRequest->pRequests[i]; + tscReturnsError(item, code); + } +} + +/** + * Get the timespec after `millis` ms + * + * @param t the timespec. + * @param millis the duration in milliseconds. + * @return the timespec after `millis` ms. + */ +static inline void afterMillis(struct timespec* t, int32_t millis) { + t->tv_nsec += millis * 1000000L; + t->tv_sec += t->tv_nsec / 1000000000L; + t->tv_nsec %= 1000000000L; +} + +/** + * Sleep until `timeout` timespec. When dispatcherShutdown(...) called, the function will return immediately. + * + * @param dispatcher the dispatcher thread to sleep. + * @param timeout the timeout in CLOCK_REALTIME. + */ +inline static void timeoutManagerSleepUntil(SDispatcherTimeoutManager* manager, struct timespec* timeout) { + pthread_mutex_lock(&manager->sleepMutex); + while (true) { + // notified by dispatcherShutdown(...). + if (isShutdownSDispatcherTimeoutManager(manager)) { + break; + } + if (pthread_cond_timedwait(&manager->timeout, &manager->sleepMutex, timeout)) { + fflush(stdout); + break; + } + } + pthread_mutex_unlock(&manager->sleepMutex); +} + +/** + * The thread to manage batching timeout. + */ +static void* timeoutManagerCallback(void* arg) { + SDispatcherTimeoutManager* manager = arg; + setThreadName("tscAsyncBackground"); + + while (!isShutdownSDispatcherTimeoutManager(manager)) { + struct timespec timeout; + clock_gettime(CLOCK_REALTIME, &timeout); + afterMillis(&timeout, manager->timeoutMs); + + SBatchRequest* pRequest = dispatcherLockPollAll(manager->dispatcher); + if (pRequest) { + dispatcherAsyncExecute(pRequest); + } + + // Similar to scheduleAtFixedRate in Java, if the execution time exceed + // `timeoutMs` milliseconds, then there will be no sleep. + timeoutManagerSleepUntil(manager, &timeout); + } + return NULL; +} + +SAsyncBatchWriteDispatcher* createSAsyncBatchWriteDispatcher(STscObj* pClient, int32_t batchSize, int32_t timeoutMs) { + SAsyncBatchWriteDispatcher* dispatcher = calloc(1, sizeof(SAsyncBatchWriteDispatcher) + batchSize * sizeof(SSqlObj*)); + if (!dispatcher) { + return NULL; + } + + assert(pClient != NULL); + + dispatcher->pClient = pClient; + dispatcher->currentSize = 0; + dispatcher->bufferSize = 0; + dispatcher->batchSize = batchSize; + atomic_store_8(&dispatcher->shutdown, false); + + // init the mutex and the cond. + pthread_mutex_init(&dispatcher->bufferMutex, NULL); + pthread_cond_init(&dispatcher->notFull, NULL); + + // init timeout manager. + dispatcher->timeoutManager = createSDispatcherTimeoutManager(dispatcher, timeoutMs); + if (!dispatcher->timeoutManager) { + pthread_mutex_destroy(&dispatcher->bufferMutex); + pthread_cond_destroy(&dispatcher->notFull); + free(dispatcher); + return NULL; + } + + return dispatcher; +} + +/** + * Shutdown the dispatcher and join the timeout thread. + * + * @param dispatcher the dispatcher. + */ +inline static void dispatcherShutdown(SAsyncBatchWriteDispatcher* dispatcher) { + atomic_store_8(&dispatcher->shutdown, true); + if (dispatcher->timeoutManager) { + shutdownSDispatcherTimeoutManager(dispatcher->timeoutManager); + } +} + +void destroySAsyncBatchWriteDispatcher(SAsyncBatchWriteDispatcher* dispatcher) { + if (dispatcher == NULL) { + return; + } + + dispatcherShutdown(dispatcher); + + // poll and send all the statements in the buffer. + while (true) { + SBatchRequest* pRequest = dispatcherLockPollAll(dispatcher); + if (!pRequest) { + break; + } + dispatcherExecute(pRequest); + free(pRequest); + } + // destroy the timeout manager. + destroySDispatcherTimeoutManager(dispatcher->timeoutManager); + + // destroy the mutex. + pthread_mutex_destroy(&dispatcher->bufferMutex); + pthread_cond_destroy(&dispatcher->notFull); + + free(dispatcher); +} + +bool dispatcherCanDispatch(SAsyncBatchWriteDispatcher* dispatcher, SSqlObj* pSql) { + if (pSql == NULL || !pSql->enableBatch) { + return false; + } + + SSqlCmd* pCmd = &pSql->cmd; + SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); + + // only support insert statement. + if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT)) { + return false; + } + + SInsertStatementParam* pInsertParam = &pCmd->insertParam; + + // file insert not support. + if (TSDB_QUERY_HAS_TYPE(pInsertParam->insertType, TSDB_QUERY_TYPE_FILE_INSERT)) { + return false; + } + + // only support kv payload. + if (pInsertParam->payloadType != PAYLOAD_TYPE_KV) { + return false; + } + + // no schema attached. + if (pInsertParam->schemaAttached) { + return false; + } + + // too many insertion rows, fail back to normal insertion. + if (statementGetInsertionRows(pSql) >= dispatcher->batchSize) { + return false; + } + + return true; +} + +bool dispatcherTryDispatch(SAsyncBatchWriteDispatcher* dispatcher, SSqlObj* pSql) { + if (atomic_load_8(&dispatcher->shutdown)) { + return false; + } + + // the sql object doesn't support bulk insertion. + if (!dispatcherCanDispatch(dispatcher, pSql)) { + return false; + } + + // try to offer pSql to the buffer. + return dispatcherTryOffer(dispatcher, pSql); +} + +/** + * Destroy the SAsyncBatchWriteDispatcher create by SDispatcherManager. + * @param arg the thread local SAsyncBatchWriteDispatcher. + */ +static void destroyDispatcher(void* arg) { + SAsyncBatchWriteDispatcher* dispatcher = arg; + if (!dispatcher) { + return; + } + + destroySAsyncBatchWriteDispatcher(dispatcher); +} + +SDispatcherManager* createDispatcherManager(STscObj* pClient, int32_t batchSize, int32_t timeoutMs, + bool isThreadLocal) { + SDispatcherManager* dispatcher = calloc(1, sizeof(SDispatcherManager)); + if (!dispatcher) { + return NULL; + } + + assert(pClient != NULL); + + dispatcher->pClient = pClient; + dispatcher->batchSize = batchSize; + dispatcher->timeoutMs = timeoutMs; + dispatcher->isThreadLocal = isThreadLocal; + + if (isThreadLocal) { + if (pthread_key_create(&dispatcher->key, destroyDispatcher)) { + free(dispatcher); + return NULL; + } + } else { + dispatcher->pGlobal = createSAsyncBatchWriteDispatcher(pClient, batchSize, timeoutMs); + if (!dispatcher->pGlobal) { + free(dispatcher); + return NULL; + } + } + return dispatcher; +} + +SAsyncBatchWriteDispatcher* dispatcherAcquire(SDispatcherManager* manager) { + if (!manager->isThreadLocal) { + return manager->pGlobal; + } + + SAsyncBatchWriteDispatcher* value = pthread_getspecific(manager->key); + if (value) { + return value; + } + + value = createSAsyncBatchWriteDispatcher(manager->pClient, manager->batchSize, manager->timeoutMs); + if (value) { + pthread_setspecific(manager->key, value); + return value; + } + + return NULL; +} + +void destroyDispatcherManager(SDispatcherManager* manager) { + if (manager) { + if (manager->isThreadLocal) { + pthread_key_delete(manager->key); + } + + if (manager->pGlobal) { + destroySAsyncBatchWriteDispatcher(manager->pGlobal); + } + free(manager); + } +} + +SDispatcherTimeoutManager* createSDispatcherTimeoutManager(SAsyncBatchWriteDispatcher* dispatcher, int32_t timeoutMs) { + SDispatcherTimeoutManager* manager = calloc(1, sizeof(SDispatcherTimeoutManager)); + if (!manager) { + return NULL; + } + + manager->timeoutMs = timeoutMs; + manager->dispatcher = dispatcher; + atomic_store_8(&manager->shutdown, false); + + pthread_mutex_init(&manager->sleepMutex, NULL); + pthread_cond_init(&manager->timeout, NULL); + + // init background thread. + if (pthread_create(&manager->background, NULL, timeoutManagerCallback, manager)) { + pthread_mutex_destroy(&manager->sleepMutex); + pthread_cond_destroy(&manager->timeout); + free(manager); + return NULL; + } + return manager; +} + +void destroySDispatcherTimeoutManager(SDispatcherTimeoutManager* manager) { + if (!manager) { + return; + } + + shutdownSDispatcherTimeoutManager(manager); + manager->dispatcher->timeoutManager = NULL; + + pthread_mutex_destroy(&manager->sleepMutex); + pthread_cond_destroy(&manager->timeout); + free(manager); +} + +void shutdownSDispatcherTimeoutManager(SDispatcherTimeoutManager* manager) { + // mark shutdown, signal shutdown to timeout thread. + pthread_mutex_lock(&manager->sleepMutex); + atomic_store_8(&manager->shutdown, true); + pthread_cond_broadcast(&manager->timeout); + pthread_mutex_unlock(&manager->sleepMutex); + + // make sure the timeout thread exit. + pthread_join(manager->background, NULL); +} + +bool isShutdownSDispatcherTimeoutManager(SDispatcherTimeoutManager* manager) { + if (!manager) { + return true; + } + return atomic_load_8(&manager->shutdown); +} + +/** + * The proxy function to call `dispatcherExecute`. + * + * @param pMsg the schedule message. + */ +static void dispatcherExecuteProxy(struct SSchedMsg* pMsg) { + SBatchRequest* pRequest = pMsg->ahandle; + if (!pRequest) { + return; + } + + pMsg->ahandle = NULL; + dispatcherExecute(pRequest); + free(pRequest); +} + +void dispatcherAsyncExecute(SBatchRequest* pRequest) { + if (!pRequest) { + return; + } + + assert(pRequest->pRequests); + assert(pRequest->nRequests); + + SSchedMsg schedMsg = {0}; + schedMsg.fp = dispatcherExecuteProxy; + schedMsg.ahandle = (void*) pRequest; + schedMsg.thandle = (void*) 1; + schedMsg.msg = 0; + taosScheduleTask(tscQhandle, &schedMsg); +} diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 38aee8a6787d5ae99b1d98ec0b2fadd42208ac5a..750d670d1be0f00d011f05e8ff960ef875d85519 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1569,7 +1569,7 @@ int tsParseInsertSql(SSqlObj *pSql) { if (pInsertParam->numOfParams > 0) { goto _clean; } - + // merge according to vgId if (!TSDB_QUERY_HAS_TYPE(pInsertParam->insertType, TSDB_QUERY_TYPE_STMT_INSERT) && taosHashGetSize(pInsertParam->pTableBlockHashList) > 0) { if ((code = tscMergeTableDataBlocks(pSql, pInsertParam, true)) != TSDB_CODE_SUCCESS) { @@ -1577,6 +1577,7 @@ int tsParseInsertSql(SSqlObj *pSql) { } } + pCmd->insertParam.numOfRows = totalNum; code = TSDB_CODE_SUCCESS; goto _clean; diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 39514b08892f99f5da0365303f23677e9d029f0d..68610d8486c0578836c5870b9998de744ec0fec5 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -757,25 +757,25 @@ 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; - SSmlSTableSchema* stableSchema = taosArrayGet(stableSchemas, point->schemaIdx); - - for (int j = 0; j < point->tagNum; ++j) { - TAOS_SML_KV* kv = point->tags + j; - if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { - int64_t ts = *(int64_t*)(kv->value); - ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, stableSchema->precision); - *(int64_t*)(kv->value) = ts; - } - } - - for (int j = 0; j < point->fieldNum; ++j) { - TAOS_SML_KV* kv = point->fields + j; - if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { - int64_t ts = *(int64_t*)(kv->value); - ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, stableSchema->precision); - *(int64_t*)(kv->value) = ts; - } - } +// SSmlSTableSchema* stableSchema = taosArrayGet(stableSchemas, point->schemaIdx); + +// for (int j = 0; j < point->tagNum; ++j) { +// TAOS_SML_KV* kv = point->tags + j; +// if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { +// int64_t ts = *(int64_t*)(kv->value); +// ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, stableSchema->precision); +// *(int64_t*)(kv->value) = ts; +// } +// } +// +// for (int j = 0; j < point->fieldNum; ++j) { +// TAOS_SML_KV* kv = point->fields + j; +// if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { +// int64_t ts = *(int64_t*)(kv->value); +// ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, stableSchema->precision); +// *(int64_t*)(kv->value) = ts; +// } +// } SArray* cTablePoints = NULL; SArray** pCTablePoints = taosHashGet(cname2points, point->childTableName, strlen(point->childTableName)); @@ -860,7 +860,14 @@ static int32_t addChildTableDataPointsToInsertSql(char* cTableName, char* sTable TAOS_SML_KV* kv = tagKVs[i]; size_t beforeLen = totalLen; int32_t len = 0; - converToStr(sql + beforeLen, kv->type, kv->value, kv->length, &len); + + if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { + int64_t ts = *(int64_t*)(kv->value); + ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, sTableSchema->precision); + converToStr(sql + beforeLen, kv->type, &ts, kv->length, &len); + }else{ + converToStr(sql + beforeLen, kv->type, kv->value, kv->length, &len); + } totalLen += len; ret = smlSnprintf(sql, &totalLen, capacity, ","); @@ -914,7 +921,13 @@ static int32_t addChildTableDataPointsToInsertSql(char* cTableName, char* sTable TAOS_SML_KV* kv = colKVs[i]; size_t beforeLen = totalLen; int32_t len = 0; - converToStr(sql + beforeLen, kv->type, kv->value, kv->length, &len); + if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { + int64_t ts = *(int64_t*)(kv->value); + ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, sTableSchema->precision); + converToStr(sql + beforeLen, kv->type, &ts, kv->length, &len); + }else{ + converToStr(sql + beforeLen, kv->type, kv->value, kv->length, &len); + } totalLen += len; ret = smlSnprintf(sql, &totalLen, capacity, ","); if (ret != 0) { @@ -965,7 +978,7 @@ static void insertCallback(void *param, TAOS_RES *res, int32_t notUsedCode) { batch->tryAgain = true; } - if (code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) { + if (code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID || code == TSDB_CODE_MND_INVALID_TABLE_NAME) { batch->resetQueryCache = true; if (batch->tryAgain) { batch->sleep = true; @@ -1105,6 +1118,9 @@ static int32_t applyDataPointsWithSqlInsert(TAOS* taos, TAOS_SML_DATA_POINT* poi SSmlSqlInsertBatch* b = info->batches + i; if (b->code != 0) { code = b->code; + if(code == TSDB_CODE_MND_INVALID_TABLE_NAME){ + break; + } } } @@ -1221,42 +1237,52 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine info->affectedRows = 0; - if (numPoint == 1) { - TAOS_SML_DATA_POINT* point = points + 0; - code = doSmlInsertOneDataPoint(taos, point, info); - if (code == TSDB_CODE_SUCCESS) { - return code; + int32_t tableNotExistTryTimes = 3; + while(tableNotExistTryTimes){ + if (numPoint == 1) { + TAOS_SML_DATA_POINT* point = points + 0; + code = doSmlInsertOneDataPoint(taos, point, info); + if (code == TSDB_CODE_SUCCESS) { + return code; + } } - } - tscDebug("SML:0x%"PRIx64" build data point schemas", info->id); - SArray* stableSchemas = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray - code = buildDataPointSchemas(points, numPoint, stableSchemas, info); - if (code != 0) { - tscError("SML:0x%"PRIx64" error building data point schemas : %s", info->id, tstrerror(code)); - goto clean_up; - } + tscDebug("SML:0x%"PRIx64" build data point schemas", info->id); + SArray* stableSchemas = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray + code = buildDataPointSchemas(points, numPoint, stableSchemas, info); + if (code != 0) { + tscError("SML:0x%"PRIx64" error building data point schemas : %s", info->id, tstrerror(code)); + goto clean_up; + } - tscDebug("SML:0x%"PRIx64" modify db schemas", info->id); - code = modifyDBSchemas(taos, stableSchemas, info); - if (code != 0) { - tscError("SML:0x%"PRIx64" error change db schema : %s", info->id, tstrerror(code)); - goto clean_up; - } + tscDebug("SML:0x%"PRIx64" modify db schemas", info->id); + code = modifyDBSchemas(taos, stableSchemas, info); + if (code != 0) { + tscError("SML:0x%"PRIx64" error change db schema : %s", info->id, tstrerror(code)); + goto clean_up; + } - tscDebug("SML:0x%"PRIx64" apply data points", info->id); - code = applyDataPointsWithSqlInsert(taos, points, numPoint, stableSchemas, info); - if (code != 0) { - tscError("SML:0x%"PRIx64" error apply data points : %s", info->id, tstrerror(code)); - } + tscDebug("SML:0x%"PRIx64" apply data points", info->id); + code = applyDataPointsWithSqlInsert(taos, points, numPoint, stableSchemas, info); + if (code != 0) { + tscError("SML:0x%"PRIx64" error apply data points : %s", info->id, tstrerror(code)); + } -clean_up: - for (int i = 0; i < taosArrayGetSize(stableSchemas); ++i) { - SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i); - taosArrayDestroy(&schema->fields); - taosArrayDestroy(&schema->tags); + clean_up: + for (int i = 0; i < taosArrayGetSize(stableSchemas); ++i) { + SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i); + taosArrayDestroy(&schema->fields); + taosArrayDestroy(&schema->tags); + } + taosArrayDestroy(&stableSchemas); + + if(code == TSDB_CODE_MND_INVALID_TABLE_NAME){ + tableNotExistTryTimes--; + }else{ + tableNotExistTryTimes = 0; + } } - taosArrayDestroy(&stableSchemas); + return code; } @@ -2090,7 +2116,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **idx, int32_t sqlLen, switch (tag_state) { case tag_common: if (back_slash == true) { - if (*cur != ',' && *cur != '=' && *cur != ' ' && *cur != 'n' ) { + if (*cur != ',' && *cur != '=' && *cur != ' ' && *cur != 'n' && *cur != 't' && *cur != 'r') { tscError("SML:0x%"PRIx64" tag value: state(%d), incorrect character(%c) escaped", info->id, tag_state, *cur); ret = TSDB_CODE_TSC_LINE_SYNTAX_ERROR; goto error; @@ -2150,7 +2176,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **idx, int32_t sqlLen, break; case tag_lqoute: if (back_slash == true) { - if (*cur != ',' && *cur != '=' && *cur != ' ' && *cur != 'n') { + if (*cur != ',' && *cur != '=' && *cur != ' ' && *cur != 'n' && *cur != 't' && *cur != 'r') { tscError("SML:0x%"PRIx64" tag value: state(%d), incorrect character(%c) escaped", info->id, tag_state, *cur); ret = TSDB_CODE_TSC_LINE_SYNTAX_ERROR; goto error; @@ -2205,7 +2231,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **idx, int32_t sqlLen, switch (val_state) { case val_common: if (back_slash == true) { - if (*cur != '\\' && *cur != '"' && *cur != 'n') { + if (*cur != '\\' && *cur != '"' && *cur != 'n' && *cur != 't' && *cur != 'r') { tscError("SML:0x%"PRIx64" field value: state(%d), incorrect character(%c) escaped", info->id, val_state, *cur); ret = TSDB_CODE_TSC_LINE_SYNTAX_ERROR; goto error; @@ -2293,7 +2319,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **idx, int32_t sqlLen, break; case val_lqoute: if (back_slash == true) { - if (*cur != '\\' && *cur != '"' && *cur != 'n') { + if (*cur != '\\' && *cur != '"' && *cur != 'n' && *cur != 't' && *cur != 'r') { tscError("SML:0x%"PRIx64" field value: state(%d), incorrect character(%c) escaped", info->id, val_state, *cur); ret = TSDB_CODE_TSC_LINE_SYNTAX_ERROR; goto error; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 8ba3f20f6e62495ed7787ca62e03100ff14f9944..452888ace23186591339d95695045490bbe82d45 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -862,7 +862,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { const char* msg3 = "name too long"; const char* msg5 = "invalid user rights"; const char* msg7 = "not support options"; - const char* msg8 = "tags filter length must over 3 bytes."; + const char* msg8 = "tags filter string length must less than 255 bytes."; pCmd->command = pInfo->type; @@ -903,15 +903,14 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } } else if (pUser->type == TSDB_ALTER_USER_TAGS) { SStrToken* pTags = &pUser->tags; - if(pTags->n < 4) - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); - } else { + if (pTags->n > TSDB_TAGS_LEN - 1 ) return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); + } else { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); } } - break; - } + break; + } case TSDB_SQL_CFG_LOCAL: { SMiscInfo *pMiscInfo = pInfo->pMiscInfo; @@ -7340,18 +7339,19 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { bool dbIncluded = false; SStrToken tmpToken = pAlterSQL->name; - tmpToken.z= strndup(pAlterSQL->name.z, pAlterSQL->name.n); + char* z0 = strndup(pAlterSQL->name.z, pAlterSQL->name.n); + tmpToken.z = z0; if (tscValidateName(&tmpToken, true, &dbIncluded) != TSDB_CODE_SUCCESS) { - free(tmpToken.z); + free(z0); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } code = tscSetTableFullName(&pTableMetaInfo->name, &tmpToken, pSql, dbIncluded); if (code != TSDB_CODE_SUCCESS) { - free(tmpToken.z); + free(z0); return code; } - free(tmpToken.z); + free(z0); code = tscGetTableMeta(pSql, pTableMetaInfo); if (code != TSDB_CODE_SUCCESS) { diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index cc035677e7502272f338a953c52088201706aff1..933334a5c8e61fefe27390f780bccfa757749d11 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2953,6 +2953,12 @@ int tscProcessQueryRsp(SSqlObj *pSql) { SSqlRes *pRes = &pSql->res; SQueryTableRsp *pQueryAttr = (SQueryTableRsp *)pRes->pRsp; + + if (pQueryAttr == NULL) { + pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; + return pRes->code; + } + pQueryAttr->qId = htobe64(pQueryAttr->qId); pRes->qId = pQueryAttr->qId; @@ -3056,7 +3062,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) { int32_t numOfCols = pQueryInfo->fieldsInfo.numOfOutput; TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, numOfCols - 1); - int16_t offset = tscFieldInfoGetOffset(pQueryInfo, numOfCols - 1); + int32_t offset = tscFieldInfoGetOffset(pQueryInfo, numOfCols - 1); char* p = pRes->data + (pField->bytes + offset) * pRes->numOfRows; @@ -3393,7 +3399,7 @@ int tscRenewTableMeta(SSqlObj *pSql) { SSqlCmd* pCmd2 = &pSql->rootObj->cmd; SHashObj *pmap = pCmd2->pTableMetaMap; if (pmap == atomic_val_compare_exchange_ptr(&pCmd2->pTableMetaMap, pmap, NULL)) { - tscCleanupTableMetaMap(pCmd2->pTableMetaMap); + tscCleanupTableMetaMap(pmap); } pCmd2->pTableMetaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 409c41fb1a2d0952090ff2ef90581e37007e3679..7dd1c71fb69b94d95d83a0a9fd782a802b74724f 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -21,6 +21,7 @@ #include "tnote.h" #include "trpc.h" #include "tscLog.h" +#include "tscBatchWrite.h" #include "tscSubquery.h" #include "tscUtil.h" #include "tsclient.h" @@ -163,15 +164,30 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa pSql->fp = fp; pSql->param = param; pSql->cmd.command = TSDB_SQL_CONNECT; - + + pObj->dispatcherManager = NULL; + if (tsWriteBatchSize > 1 && !tscEmbedded) { + pObj->dispatcherManager = createDispatcherManager(pObj, tsWriteBatchSize, tsWriteBatchTimeout, tsWriteBatchThreadLocal); + if (!pObj->dispatcherManager) { + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscReleaseRpc(pRpcObj); + free(pSql); + free(pObj); + return NULL; + } + } + if (TSDB_CODE_SUCCESS != tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) { terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + if (pObj->dispatcherManager) { + destroyDispatcherManager(pObj->dispatcherManager); + } tscReleaseRpc(pRpcObj); free(pSql); free(pObj); return NULL; } - + if (taos != NULL) { *taos = pObj; } diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 7ea24ce8290fe5c5fda2841e836d2cdf82e2bd40..fedb4b90f8bc34aaa6e6176a17c2d009d3936eca 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -264,7 +264,7 @@ static void tscStreamFillTimeGap(SSqlStream* pStream, TSKEY ts) { pStream->stime += pStream->slidingTime; *(TSKEY*)row[0] = pStream->stime; for (int32_t i = 1; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) { - int16_t offset = tscFieldInfoGetOffset(pQueryInfo, i); + int32_t offset = tscFieldInfoGetOffset(pQueryInfo, i); TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); assignVal(pSql->res.data + offset, (char *)(&pQueryInfo->fillVal[i]), pField->bytes, pField->type); row[i] = pSql->res.data + offset; @@ -339,7 +339,7 @@ bool sqlBufSend(TAOS *taos, char *sqlBuf) { } while(++sleepCnt < 20); strcat(sqlBuf, ";"); - taos_query_ra(taos, sqlBuf, cbSendValues, NULL); + taos_query_ra(taos, sqlBuf, cbSendValues, NULL, false); return true; } diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 944b85e996db3364181d9a2ce4132e827cc3f406..50c7ceb733ed405b89b9fc8d4fe3491aa7fd89ec 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -14,18 +14,19 @@ */ #include "os.h" +#include "qScript.h" #include "taosmsg.h" +#include "tconfig.h" +#include "tglobal.h" +#include "tnote.h" #include "tref.h" #include "trpc.h" -#include "tnote.h" -#include "ttimer.h" -#include "tsched.h" +#include "tscBatchWrite.h" #include "tscLog.h" +#include "tsched.h" #include "tsclient.h" -#include "tglobal.h" -#include "tconfig.h" +#include "ttimer.h" #include "ttimezone.h" -#include "qScript.h" // global, not configurable #define TSC_VAR_NOT_RELEASE 1 @@ -319,6 +320,49 @@ void taos_cleanup(void) { taosTmrCleanUp(p); } +/** + * Set the option value (int32, uint16, int16, int8). + * @param cfg the config. + * @param str the value string. + * @return whether is set or not. + */ +static bool taos_set_option_int(SGlobalCfg * cfg, const char* str) { + if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) { + char* p = NULL; + errno = 0; + long value = strtol(str, &p, 10); + + if (errno != 0 || p == str) { + tscError("failed to parse option: %s, value: %s", cfg->option, str); + return false; + } + + if ((float) value < cfg->minValue || (float) value > cfg->maxValue) { + tscError("failed to set option: %s, setValue: %ld, minValue: %f, maxValue: %f", cfg->option, value, cfg->minValue, cfg->maxValue); + return false; + } + + if (cfg->valType == TAOS_CFG_VTYPE_INT32) { + *((int32_t*) cfg->ptr) = (int32_t) value; + } else if (cfg->valType == TAOS_CFG_VTYPE_UINT16) { + *((uint16_t*) cfg->ptr) = (uint16_t) value; + } else if (cfg->valType == TAOS_CFG_VTYPE_INT16) { + *((int16_t*) cfg->ptr) = (int16_t) value; + } else if (cfg->valType == TAOS_CFG_VTYPE_INT8) { + *((int8_t*) cfg->ptr) = (int8_t) value; + } else { + tscError("failed to set option: %s, type expected %d", cfg->option, cfg->valType); + return false; + } + + cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION; + tscDebug("config option: %s has set to %s", cfg->option, str); + return true; + } + tscWarn("config option: %s, is configured by %s", cfg->option, tsCfgStatusStr[cfg->cfgStatus]); + return false; +} + static int taos_options_imp(TSDB_OPTION option, const char *pStr) { SGlobalCfg *cfg = NULL; @@ -473,6 +517,27 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) { tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr); } break; + + case TSDB_WRITE_BATCH_SIZE: { + cfg = taosGetConfigOption("writeBatchSize"); + assert(cfg != NULL); + taos_set_option_int(cfg, pStr); + break; + } + + case TSDB_WRITE_BATCH_TIMEOUT: { + cfg = taosGetConfigOption("writeBatchTimeout"); + assert(cfg != NULL); + taos_set_option_int(cfg, pStr); + break; + } + + case TSDB_WRITE_BATCH_THREAD_LOCAL: { + cfg = taosGetConfigOption("writeBatchThreadLocal"); + assert(cfg != NULL); + taos_set_option_int(cfg, pStr); + break; + } default: // TODO return the correct error code to client in the format for taos_errstr() diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 6eeb8aedc5f87f838fbe3390842f19a6f6f44643..200c3298aafbd6fd9e9c15c0af64a02497dd4ee5 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -20,6 +20,7 @@ #include "texpr.h" #include "tkey.h" #include "tmd5.h" +#include "tscBatchWrite.h" #include "tscGlobalmerge.h" #include "tscLog.h" #include "tscProfile.h" @@ -1372,6 +1373,10 @@ void convertQueryResult(SSqlRes* pRes, SQueryInfo* pQueryInfo, uint64_t objId, b // set the correct result SSDataBlock* p = pQueryInfo->pQInfo->runtimeEnv.outputBuf; pRes->numOfRows = (p != NULL)? p->info.rows: 0; + bool completed = pRes->numOfRows == 0; + if (p && pRes->numOfRows == 0 && tsAggAlways) { + pRes->numOfRows = 1; + } if (pRes->code == TSDB_CODE_SUCCESS && pRes->numOfRows > 0) { tscCreateResPointerInfo(pRes, pQueryInfo); @@ -1380,7 +1385,7 @@ void convertQueryResult(SSqlRes* pRes, SQueryInfo* pQueryInfo, uint64_t objId, b tscDebug("0x%"PRIx64" retrieve result in pRes, numOfRows:%d", objId, pRes->numOfRows); pRes->row = 0; - pRes->completed = (pRes->numOfRows == 0); + pRes->completed = completed; } /* @@ -1649,7 +1654,7 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta, uint64_t id) { tscFreeQueryInfo(pCmd, clearCachedMeta, id); SHashObj *pmap = pCmd->pTableMetaMap; if (pmap == atomic_val_compare_exchange_ptr(&pCmd->pTableMetaMap, pmap, NULL)) { - tscCleanupTableMetaMap(pCmd->pTableMetaMap); + tscCleanupTableMetaMap(pmap); } taosReleaseRef(tscObjRef, id); } @@ -1837,32 +1842,36 @@ void tscDestroyBoundColumnInfo(SParsedDataColInfo* pColInfo) { tfree(pColInfo->colIdxInfo); } -void tscDestroyDataBlock(SSqlObj *pSql, STableDataBlocks* pDataBlock, bool removeMeta) { - if (pDataBlock == NULL) { +void destroySTableDataBlocks(STableDataBlocks* pDataBlocks) { + if (!pDataBlocks) { return; } + tfree(pDataBlocks->pData); + if (!pDataBlocks->cloned) { + tfree(pDataBlocks->params); + + // free the refcount for metermeta + if (pDataBlocks->pTableMeta != NULL) { + tfree(pDataBlocks->pTableMeta); + } - tfree(pDataBlock->pData); + tscDestroyBoundColumnInfo(&pDataBlocks->boundColumnInfo); + } + tfree(pDataBlocks); +} +void tscDestroyDataBlock(SSqlObj *pSql, STableDataBlocks* pDataBlock, bool removeMeta) { + if (pDataBlock == NULL) { + return; + } + if (removeMeta) { char name[TSDB_TABLE_FNAME_LEN] = {0}; tNameExtractFullName(&pDataBlock->tableName, name); - taosHashRemove(UTIL_GET_TABLEMETA(pSql), name, strnlen(name, TSDB_TABLE_FNAME_LEN)); } - if (!pDataBlock->cloned) { - tfree(pDataBlock->params); - - // free the refcount for metermeta - if (pDataBlock->pTableMeta != NULL) { - tfree(pDataBlock->pTableMeta); - } - - tscDestroyBoundColumnInfo(&pDataBlock->boundColumnInfo); - } - - tfree(pDataBlock); + destroySTableDataBlocks(pDataBlock); } SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, uint16_t bytes, @@ -1889,18 +1898,22 @@ SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint return param; } -void* tscDestroyBlockArrayList(SSqlObj *pSql, SArray* pDataBlockList) { - if (pDataBlockList == NULL) { - return NULL; +void destroySTableDataBlocksList(SArray* pDataBlocks) { + if (!pDataBlocks) { + return; } - - size_t size = taosArrayGetSize(pDataBlockList); - for (int32_t i = 0; i < size; i++) { - void* d = taosArrayGetP(pDataBlockList, i); - tscDestroyDataBlock(pSql, d, false); + size_t nBlocks = taosArrayGetSize(pDataBlocks); + for (size_t i = 0; i < nBlocks; ++i) { + STableDataBlocks * pDataBlock = taosArrayGetP(pDataBlocks, i); + if (pDataBlock) { + destroySTableDataBlocks(pDataBlock); + } } + taosArrayDestroy(&pDataBlocks); +} - taosArrayDestroy(&pDataBlockList); +void* tscDestroyBlockArrayList(SSqlObj *pSql, SArray* pDataBlockList) { + destroySTableDataBlocksList(pDataBlockList); return NULL; } @@ -2198,42 +2211,35 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) { return result; } -static void extractTableNameList(SSqlObj *pSql, SInsertStatementParam *pInsertParam, bool freeBlockMap) { - pInsertParam->numOfTables = (int32_t) taosHashGetSize(pInsertParam->pTableBlockHashList); - if (pInsertParam->pTableNameList == NULL) { - pInsertParam->pTableNameList = malloc(pInsertParam->numOfTables * POINTER_BYTES); - } - - STableDataBlocks **p1 = taosHashIterate(pInsertParam->pTableBlockHashList, NULL); - int32_t i = 0; - while(p1) { - STableDataBlocks* pBlocks = *p1; - //tfree(pInsertParam->pTableNameList[i]); - - pInsertParam->pTableNameList[i++] = tNameDup(&pBlocks->tableName); - p1 = taosHashIterate(pInsertParam->pTableBlockHashList, p1); - } - - if (freeBlockMap) { - pInsertParam->pTableBlockHashList = tscDestroyBlockHashTable(pSql, pInsertParam->pTableBlockHashList, false); - } -} - int32_t tscMergeTableDataBlocks(SSqlObj *pSql, SInsertStatementParam *pInsertParam, bool freeBlockMap) { const int INSERT_HEAD_SIZE = sizeof(SMsgDesc) + sizeof(SSubmitMsg); int code = 0; bool isRawPayload = IS_RAW_PAYLOAD(pInsertParam->payloadType); - void* pVnodeDataBlockHashList = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); + size_t initialSize = taosHashGetSize(pInsertParam->pTableBlockHashList); + initialSize = initialSize > 128 ? 128 : initialSize; + + void* pVnodeDataBlockHashList = taosHashInit(initialSize, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); SArray* pVnodeDataBlockList = taosArrayInit(8, POINTER_BYTES); - - STableDataBlocks** p = taosHashIterate(pInsertParam->pTableBlockHashList, NULL); - - STableDataBlocks* pOneTableBlock = *p; - + + // alloc table name list. + size_t numOfTables = taosHashGetSize(pInsertParam->pTableBlockHashList); + if (pInsertParam->pTableNameList) { + destroyTableNameList(pInsertParam); + } + pInsertParam->pTableNameList = calloc(numOfTables, sizeof(SName*)); + pInsertParam->numOfTables = (int32_t) numOfTables; + + size_t tail = 0; SBlockKeyInfo blkKeyInfo = {0}; // share by pOneTableBlock - - while(pOneTableBlock) { + STableDataBlocks** iter = taosHashIterate(pInsertParam->pTableBlockHashList, NULL); + while (iter) { + STableDataBlocks* pOneTableBlock = *iter; SSubmitBlk* pBlocks = (SSubmitBlk*) pOneTableBlock->pData; + iter = taosHashIterate(pInsertParam->pTableBlockHashList, iter); + + // extract table name list. + pInsertParam->pTableNameList[tail++] = tNameDup(&pOneTableBlock->tableName); + if (pBlocks->numOfRows > 0) { // the maximum expanded size in byte when a row-wise data is converted to SDataRow format int32_t expandSize = isRawPayload ? getRowExpandSize(pOneTableBlock->pTableMeta) : 0; @@ -2316,19 +2322,19 @@ int32_t tscMergeTableDataBlocks(SSqlObj *pSql, SInsertStatementParam *pInsertPar dataBuf->numOfTables += 1; pBlocks->numOfRows = 0; - }else { + } else { tscDebug("0x%"PRIx64" table %s data block is empty", pInsertParam->objectId, pOneTableBlock->tableName.tname); } - - p = taosHashIterate(pInsertParam->pTableBlockHashList, p); - if (p == NULL) { - break; + + if (freeBlockMap) { + tscDestroyDataBlock(pSql, pOneTableBlock, false); } - - pOneTableBlock = *p; } - - extractTableNameList(pSql, pInsertParam, freeBlockMap); + + if (freeBlockMap) { + taosHashCleanup(pInsertParam->pTableBlockHashList); + pInsertParam->pTableBlockHashList = NULL; + } // free the table data blocks; pInsertParam->pDataBlocks = pVnodeDataBlockList; @@ -2349,6 +2355,9 @@ void tscCloseTscObj(void *param) { tscReleaseRpc(pObj->pRpcObj); pthread_mutex_destroy(&pObj->mutex); tscReleaseClusterInfo(pObj->clusterId); + + destroyDispatcherManager(pObj->dispatcherManager); + pObj->dispatcherManager = NULL; tfree(pObj); } @@ -5238,6 +5247,8 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt STableMetaInfo* pTableMetaInfo = pQueryInfo->pTableMetaInfo[0]; + pQueryAttr->precision = pTableMetaInfo->pTableMeta->tableInfo.precision; + if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) { pQueryAttr->pGroupbyExpr = calloc(1, sizeof(SGroupbyExpr)); *(pQueryAttr->pGroupbyExpr) = pQueryInfo->groupbyExpr; diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 650bb6bb4e6acd013bcfe3e9a43e67309ce0f570..bcc0d68f95cbd9ec884df5e87b3ec10bd5463883 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -92,6 +92,9 @@ extern int32_t tsRetryStreamCompDelay; extern float tsStreamComputDelayRatio; // the delayed computing ration of the whole time window extern int32_t tsProjectExecInterval; extern int64_t tsMaxRetentWindow; +extern bool tsWriteBatchThreadLocal; +extern int32_t tsWriteBatchSize; +extern int32_t tsWriteBatchTimeout; // db parameters in client extern int32_t tsCacheBlockSize; @@ -151,6 +154,10 @@ extern char tsMonitorDbName[]; extern char tsInternalPass[]; extern int32_t tsMonitorInterval; +// audit +extern int8_t tsEnableAudit; +extern char tsAuditDbName[]; + // stream extern int8_t tsEnableStream; @@ -219,6 +226,7 @@ extern int32_t cqDebugFlag; extern int32_t debugFlag; extern int8_t tsClientMerge; +extern int8_t tsAggAlways; // probe alive connection extern int32_t tsProbeSeconds; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 6260b22c81112647e605247621fdecb0524c43ff..e49ed4caa54a73e79bbb2ee745dfb4a4b96360c5 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -127,6 +127,11 @@ int8_t tsSortWhenGroupBy = 1; int32_t tsProjectExecInterval = 10000; // every 10sec, the projection will be executed once int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance +// The tsc async write batching feature (using ABWD). +bool tsWriteBatchThreadLocal = false; // if thread local enable, each thread will allocate a dispatcher. +int32_t tsWriteBatchSize = 0; // suggest: 64 - 512, default 0, 0 means disable batching. +int32_t tsWriteBatchTimeout = 10; // suggest: 2 - 100 (unit: milliseconds) + // the maximum allowed query buffer size during query processing for each data node. // -1 no limit (default) // 0 no query allowed, queries are disabled @@ -200,6 +205,10 @@ char tsMonitorDbName[TSDB_DB_NAME_LEN] = "log"; char tsInternalPass[] = "secretkey"; int32_t tsMonitorInterval = 30; // seconds +// audit +int8_t tsEnableAudit = 0; +char tsAuditDbName[TSDB_DB_NAME_LEN] = "audit"; + // stream int8_t tsEnableStream = 1; @@ -273,6 +282,7 @@ int32_t cqDebugFlag = 131; int32_t fsDebugFlag = 135; int8_t tsClientMerge = 0; +int8_t tsAggAlways = 0; // Agg function always return value even if zero row // probe alive connection int32_t tsProbeSeconds = 5 * 60; // start probe link alive after tsProbeSeconds from starting query @@ -1286,6 +1296,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "audit"; + cfg.ptr = &tsEnableAudit; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 1; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "stream"; cfg.ptr = &tsEnableStream; cfg.valType = TAOS_CFG_VTYPE_INT8; @@ -1690,6 +1710,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "aggAlways"; + cfg.ptr = &tsAggAlways; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 1; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + // default JSON string type option "binary"/"nchar" cfg.option = "defaultJSONStrType"; cfg.ptr = tsDefaultJSONStrType; @@ -1849,6 +1879,37 @@ static void doInitGlobalConfig(void) { cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + + cfg.option = "writeBatchThreadLocal"; + cfg.ptr = &tsWriteBatchThreadLocal; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + + cfg.option = "writeBatchSize"; + cfg.ptr = &tsWriteBatchSize; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = 0; + cfg.maxValue = 4096; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + + cfg.option = "writeBatchTimeout"; + cfg.ptr = &tsWriteBatchTimeout; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = 1; + cfg.maxValue = 2048; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + assert(tsGlobalConfigNum == TSDB_CFG_MAX_NUM); #else // if TD_TSZ macro define, have 5 count configs, so must add 5 diff --git a/src/inc/monitor.h b/src/inc/monitor.h index 6033f91ee72acb09f23f07fc32e6a40cf0136d76..e9c893f8e3e6ecdb89b85a78a157373c570c09d9 100644 --- a/src/inc/monitor.h +++ b/src/inc/monitor.h @@ -27,6 +27,27 @@ extern "C" { monSaveDnodeLog(level, __VA_ARGS__); \ } +typedef enum { + // create + MON_DDL_CMD_CREATE_DATABASE, + MON_DDL_CMD_CREATE_TABLE, + MON_DDL_CMD_CREATE_CHILD_TABLE, + MON_DDL_CMD_CREATE_SUPER_TABLE, + // drop + MON_DDL_CMD_DROP_DATABASE, + MON_DDL_CMD_DROP_TABLE, + MON_DDL_CMD_DROP_CHILD_TABLE, + MON_DDL_CMD_DROP_SUPER_TABLE, + // alter + MON_DDL_CMD_ALTER_DATABASE, + MON_DDL_CMD_ADD_COLUMN, + MON_DDL_CMD_DROP_COLUMN, + MON_DDL_CMD_MODIFY_COLUMN, + MON_DDL_CMD_ADD_TAG, + MON_DDL_CMD_DROP_TAG, + MON_DDL_CMD_CHANGE_TAG, +} EMonDDLCmdType; + typedef struct { const char * name; int32_t code; @@ -62,6 +83,7 @@ int32_t monInitSystem(); int32_t monStartSystem(); void monStopSystem(); void monCleanupSystem(); +void monSaveAuditLog(int8_t type, const char *user, const char *obj, bool result); void monSaveAcctLog(SAcctMonitorObj *pMonObj); void monSaveLog(int32_t level, const char *const format, ...); void monSaveDnodeLog(int32_t level, const char *const format, ...); diff --git a/src/inc/taos.h b/src/inc/taos.h index 60c81db5e614e26e4628f56efdbe86e6b16bfacc..322177bdba1278baec5b585e2c00eea0ffa3c9c2 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -60,7 +60,10 @@ typedef enum { TSDB_OPTION_TIMEZONE, TSDB_OPTION_CONFIGDIR, TSDB_OPTION_SHELL_ACTIVITY_TIMER, - TSDB_MAX_OPTIONS + TSDB_MAX_OPTIONS, + TSDB_WRITE_BATCH_SIZE, + TSDB_WRITE_BATCH_TIMEOUT, + TSDB_WRITE_BATCH_THREAD_LOCAL } TSDB_OPTION; typedef struct taosField { diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index a105cfcb9fd5a95d2ef24750217893b050642e7f..b25626c10f4f830ea12b45d7e8b247f2966952af 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -256,12 +256,12 @@ do { \ #define TSDB_VERSION_LEN 12 #define TSDB_LOCALE_LEN 64 #define TSDB_TIMEZONE_LEN 96 -#define TSDB_LABEL_LEN 8 +#define TSDB_LABEL_LEN 8 #define TSDB_CLUSTER_ID_LEN 40 #define TSDB_FQDN_LEN 128 #define TSDB_EP_LEN (TSDB_FQDN_LEN+6) -#define TSDB_IPv4ADDR_LEN 16 +#define TSDB_IPv4ADDR_LEN 16 #define TSDB_FILENAME_LEN 128 #define TSDB_SHOW_SQL_LEN 512 #define TSDB_SHOW_SUBQUERY_LEN 1000 @@ -325,7 +325,7 @@ do { \ #define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default #define TSDB_MIN_DAYS_PER_FILE 1 -#define TSDB_MAX_DAYS_PER_FILE 3650 +#define TSDB_MAX_DAYS_PER_FILE 3650 #define TSDB_DEFAULT_DAYS_PER_FILE 10 #define TSDB_MIN_KEEP 1 // data in db to be reserved. @@ -429,7 +429,7 @@ do { \ #define TSDB_ORDER_ASC 1 #define TSDB_ORDER_DESC 2 - + #define TSDB_DEFAULT_CLUSTER_HASH_SIZE 1 #define TSDB_DEFAULT_MNODES_HASH_SIZE 5 #define TSDB_DEFAULT_DNODES_HASH_SIZE 10 diff --git a/src/inc/twal.h b/src/inc/twal.h index daea34daed43a7a47ca0c50aaf759e3cb905cfef..ad308d427b7fdf254f47c7a4428ae536bb62f3f8 100644 --- a/src/inc/twal.h +++ b/src/inc/twal.h @@ -19,6 +19,9 @@ extern "C" { #endif +#define WAL_SIGNATURE ((uint32_t)(0xFAFBFDFE)) +#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead) + 16) + typedef enum { TAOS_WAL_NOLOG = 0, TAOS_WAL_WRITE = 1, diff --git a/src/kit/shell/src/shellAuto.c b/src/kit/shell/src/shellAuto.c index fc78361f95d5e9f8a5689be9cfb6bd49ae33aa1f..a96aa3f5810e69bef42242e9d26d9528c8f8ce3e 100644 --- a/src/kit/shell/src/shellAuto.c +++ b/src/kit/shell/src/shellAuto.c @@ -31,7 +31,7 @@ // extern function -void insertChar(Command *cmd, char *c, int size); +void insertStr(Command *cmd, char *str, int size); typedef struct SAutoPtr { @@ -337,24 +337,23 @@ int cntDel = 0; // delete byte count after next press tab // show auto tab introduction void printfIntroduction() { - printf(" **************************** How To Use TAB Key ********************************\n"); - printf(" * TDengine Command Line supports pressing TAB key to complete word, *\n"); - printf(" * including database name, table name, function name and keywords. *\n"); - printf(" * Press TAB key anywhere, you'll get surprise. *\n"); - printf(" * KEYBOARD SHORTCUT: *\n"); - printf(" * [ TAB ] ...... Complete the word or show help if no input *\n"); - printf(" * [ Ctrl + A ] ...... move cursor to [A]head of line *\n"); - printf(" * [ Ctrl + E ] ...... move cursor to [E]nd of line *\n"); - printf(" * [ Ctrl + W ] ...... move cursor to line of middle *\n"); - printf(" * [ Ctrl + L ] ...... clean screen *\n"); - printf(" * [ Ctrl + K ] ...... clean after cursor *\n"); - printf(" * [ Ctrl + U ] ...... clean before cursor *\n"); - printf(" * *\n"); - printf(" **********************************************************************************\n\n"); + printf(" ****************************** Tab Completion **********************************\n"); + printf(" * The TDengine CLI supports tab completion for a variety of items, *\n"); + printf(" * including database names, table names, function names and keywords. *\n"); + printf(" * The full list of shortcut keys is as follows: *\n"); + printf(" * [ TAB ] ...... complete the current word *\n"); + printf(" * ...... if used on a blank line, display all valid commands *\n"); + printf(" * [ Ctrl + A ] ...... move cursor to the st[A]rt of the line *\n"); + printf(" * [ Ctrl + E ] ...... move cursor to the [E]nd of the line *\n"); + printf(" * [ Ctrl + W ] ...... move cursor to the middle of the line *\n"); + printf(" * [ Ctrl + L ] ...... clear the entire screen *\n"); + printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n"); + printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n"); + printf(" **********************************************************************************\n\n"); } void showHelp() { - printf("\nThe following are supported commands for TDengine Command Line:"); + printf("\nFThe TDengine CLI supports the following commands:"); printf("\n\ ----- A ----- \n\ alter database \n\ @@ -534,26 +533,16 @@ void parseCommand(SWords * command, bool pattern) { } // free Command -void freeCommand(SWords * command) { - SWord * word = command->head; - if (word == NULL) { - return ; - } - - // loop - while (word->next) { - SWord * tmp = word; - word = word->next; +void freeCommand(SWords* command) { + SWord* item = command->head; + // loop + while (item) { + SWord* tmp = item; + item = item->next; // if malloc need free - if(tmp->free && tmp->word) - free(tmp->word); + if (tmp->free && tmp->word) free(tmp->word); free(tmp); } - - // if malloc need free - if(word->free && word->word) - free(word->word); - free(word); } void GenerateVarType(int type, char** p, int count) { @@ -1088,7 +1077,7 @@ void printScreen(TAOS * con, Command * cmd, SWords * match) { } // insert new - insertChar(cmd, (char *)str, strLen); + insertStr(cmd, (char *)str, strLen); } @@ -1179,11 +1168,11 @@ bool nextMatchCommand(TAOS * con, Command * cmd, SWords * firstMatch) { printScreen(con, cmd, match); // free + freeCommand(input); if (input->source) { free(input->source); input->source = NULL; } - freeCommand(input); free(input); return true; @@ -1203,7 +1192,7 @@ bool fillWithType(TAOS * con, Command * cmd, char* pre, int type) { // show int count = strlen(part); - insertChar(cmd, part, count); + insertStr(cmd, part, count); cntDel = count; // next press tab delete current append count free(str); @@ -1231,7 +1220,7 @@ bool fillTableName(TAOS * con, Command * cmd, char* pre) { // show int count = strlen(part); - insertChar(cmd, part, count); + insertStr(cmd, part, count); cntDel = count; // next press tab delete current append count free(str); @@ -1251,7 +1240,7 @@ char * lastWord(char * p) { char * p2 = strrchr(p, ','); if (p1 && p2) { - return p1 > p2 ? p1 : p2 + 1; + return p1 > p2 ? p1 + 1 : p2 + 1; } else if (p1) { return p1 + 1; } else if(p2) { @@ -1355,7 +1344,7 @@ bool appendAfterSelect(TAOS * con, Command * cmd, char* sql, int32_t len) { bool fieldEnd = fieldsInputEnd(p); // cheeck fields input end then insert from keyword if (fieldEnd && p[len-1] == ' ') { - insertChar(cmd, "from", 4); + insertStr(cmd, "from", 4); free(p); return true; } @@ -1538,7 +1527,7 @@ bool matchOther(TAOS * con, Command * cmd) { if (p[len - 1] == '\\') { // append '\G' char a[] = "G;"; - insertChar(cmd, a, 2); + insertStr(cmd, a, 2); return true; } diff --git a/src/kit/shell/src/shellCheck.c b/src/kit/shell/src/shellCheck.c index dfc5d83b9fc820f7c5e08e5a26d2475f82d16040..593bb5caeb0288613c56bf6112ccad484de185c1 100644 --- a/src/kit/shell/src/shellCheck.c +++ b/src/kit/shell/src/shellCheck.c @@ -131,7 +131,7 @@ static void *shellCheckThreadFp(void *arg) { char *tbname = tbNames[t]; if (tbname == NULL) break; - snprintf(sql, SHELL_SQL_LEN, "select count(*) from %s;", tbname); + snprintf(sql, SHELL_SQL_LEN, "select last_row(_c0) from `%s`;", tbname); TAOS_RES *pSql = taos_query(pThread->taos, sql); int32_t code = taos_errno(pSql); diff --git a/src/kit/shell/src/shellCommand.c b/src/kit/shell/src/shellCommand.c index 2fe09691e3285c2e3031672404b0aa6ed7bac244..a14eeb5e9482e804d636e37a2842c8a58b221ee3 100644 --- a/src/kit/shell/src/shellCommand.c +++ b/src/kit/shell/src/shellCommand.c @@ -79,11 +79,22 @@ void insertChar(Command *cmd, char *c, int size) { /* update the values */ cmd->commandSize += size; cmd->cursorOffset += size; - for (int i = 0; i < size; i++) { - mbtowc(&wc, c + i, size); - cmd->screenOffset += wcwidth(wc); - cmd->endOffset += wcwidth(wc); - } + cmd->screenOffset += wcwidth(wc); + cmd->endOffset += wcwidth(wc); + showOnScreen(cmd); +} + +void insertStr(Command *cmd, char *str, int size) { + clearScreen(cmd->endOffset + prompt_size, cmd->screenOffset + prompt_size); + /* update the buffer */ + memmove(cmd->command + cmd->cursorOffset + size, cmd->command + cmd->cursorOffset, + cmd->commandSize - cmd->cursorOffset); + memcpy(cmd->command + cmd->cursorOffset, str, size); + /* update the values */ + cmd->commandSize += size; + cmd->cursorOffset += size; + cmd->screenOffset += size; + cmd->endOffset += size; showOnScreen(cmd); } diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index dcd1261a06386e7bd5e6ed1395e125d4d1b3a555..277765351757fcecaffe9ec63e4dbcad9147ee50 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -192,9 +192,15 @@ static int32_t shellRunSingleCommand(TAOS *con, char *command) { if (regex_match(command, "^[ \t]*source[\t ]+[^ ]+[ \t;]*$", REG_EXTENDED | REG_ICASE)) { /* If source file. */ char *c_ptr = strtok(command, " ;"); - assert(c_ptr != NULL); + if (c_ptr == NULL) { + shellRunCommandOnServer(con, command); + return 0; + } c_ptr = strtok(NULL, " ;"); - assert(c_ptr != NULL); + if (c_ptr == NULL) { + shellRunCommandOnServer(con, command); + return 0; + } source_file(con, c_ptr); return 0; } @@ -371,7 +377,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { } else { int num_rows_affacted = taos_affected_rows(pSql); et = taosGetTimestampUs(); - printf("Query OK, %d of %d row(s) in database (%.6fs)\n", num_rows_affacted, num_rows_affacted, (et - st) / 1E6); + printf("Query OK, %d row(s) affected(%.6fs)\n", num_rows_affacted, (et - st) / 1E6); #ifndef WINDOWS // call auto tab diff --git a/src/kit/shell/src/tire.c b/src/kit/shell/src/tire.c index b4dc7976bd53f11cccbac2f5db600edeeee861d5..30bb664dcc3b0b63013a68d87de046fc40b02d63 100644 --- a/src/kit/shell/src/tire.c +++ b/src/kit/shell/src/tire.c @@ -325,30 +325,26 @@ void matchPrefixFromTree(STire* tire, char* prefix, SMatch* match) { } SMatch* matchPrefix(STire* tire, char* prefix, SMatch* match) { - if(match == NULL) { - match = (SMatch* )tmalloc(sizeof(SMatch)); - memset(match, 0, sizeof(SMatch)); - } - - switch (tire->type) { - case TIRE_TREE: - matchPrefixFromTree(tire, prefix, match); - case TIRE_LIST: - matchPrefixFromList(tire, prefix, match); - default: - break; - } - - // return if need - if (match->count == 0) { - freeMatch(match); - match = NULL; - } - - return match; + SMatch* rMatch = match; // define return match + if (rMatch == NULL) { + rMatch = (SMatch*)malloc(sizeof(SMatch)); + memset(rMatch, 0, sizeof(SMatch)); + } + + switch (tire->type) { + case TIRE_TREE: + matchPrefixFromTree(tire, prefix, rMatch); + break; + case TIRE_LIST: + matchPrefixFromList(tire, prefix, rMatch); + break; + default: + break; + } + + return rMatch; } - // get all items from tires tree void enumFromList(STire* tire, SMatch* match) { StrName * item = tire->head; @@ -395,8 +391,10 @@ SMatch* enumAll(STire* tire) { switch (tire->type) { case TIRE_TREE: enumFromTree(tire, match); + break; case TIRE_LIST: enumFromList(tire, match); + break; default: break; } diff --git a/src/kit/taos-tools b/src/kit/taos-tools index 85179e99785182bb630832216f887ef84ca23474..64350feba73d584f920474d8abcd913491081897 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit 85179e99785182bb630832216f887ef84ca23474 +Subproject commit 64350feba73d584f920474d8abcd913491081897 diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index 6aa60c3cfb6388593132975b2e11ab91f92eddcc..3997a1155f0494656a6ece5011e955ec1852c882 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -57,7 +57,7 @@ typedef struct SDnodeObj { int8_t alternativeRole; // from dnode status msg, 0-any, 1-mgmt, 2-dnode int8_t status; // set in balance function int8_t isMgmt; - int8_t reserve1[11]; + int8_t reserve1[11]; int8_t updateEnd[4]; int32_t refCount; uint32_t moduleStatus; @@ -90,7 +90,7 @@ typedef struct STableObj { } STableObj; typedef struct SSTableObj { - STableObj info; + STableObj info; int8_t reserved0[9]; // for fill struct STableObj to 4byte align int16_t nextColId; int32_t sversion; @@ -107,10 +107,10 @@ typedef struct SSTableObj { } SSTableObj; typedef struct { - STableObj info; + STableObj info; int8_t reserved0[9]; // for fill struct STableObj to 4byte align int16_t nextColId; //used by normal table - int32_t sversion; //used by normal table + int32_t sversion; //used by normal table uint64_t uid; uint64_t suid; int64_t createdTime; @@ -195,7 +195,7 @@ typedef struct SDbObj { int32_t numOfVgroups; int32_t numOfTables; int32_t numOfSuperTables; - int32_t vgListSize; + int32_t vgListSize; int32_t vgListIndex; SVgObj **vgList; struct SAcctObj *pAcct; diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index cc0b18c9b7047a718f6244cbe20ce76789a21a4c..5d88485271f772957aad0c1665e9b47c7b459ce0 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -160,7 +160,7 @@ static int32_t mnodeDbActionEncode(SSdbRow *pRow) { static int32_t mnodeDbActionDecode(SSdbRow *pRow) { SDbObj *pDb = (SDbObj *) calloc(1, sizeof(SDbObj)); if (pDb == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY; - + memcpy(pDb, pRow->rowData, tsDbUpdateSize); pRow->pObj = pDb; return TSDB_CODE_SUCCESS; @@ -205,8 +205,8 @@ int32_t mnodeInitDbs() { mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_DB, mnodeGetDbMeta); mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_DB, mnodeRetrieveDbs); mnodeAddShowFreeIterHandle(TSDB_MGMT_TABLE_DB, mnodeCancelGetNextDb); - - + + mDebug("table:dbs table is created"); return tpInit(); } @@ -224,11 +224,11 @@ SDbObj *mnodeGetDb(char *db) { } void mnodeIncDbRef(SDbObj *pDb) { - sdbIncRef(tsDbSdb, pDb); + sdbIncRef(tsDbSdb, pDb); } -void mnodeDecDbRef(SDbObj *pDb) { - sdbDecRef(tsDbSdb, pDb); +void mnodeDecDbRef(SDbObj *pDb) { + sdbDecRef(tsDbSdb, pDb); } SDbObj *mnodeGetDbByTableName(char *tableName) { @@ -409,6 +409,7 @@ static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) { } else { mError("db:%s, failed to create by %s, reason:%s", pDb->name, mnodeGetUserFromMsg(pMsg), tstrerror(code)); } + monSaveAuditLog(MON_DDL_CMD_CREATE_DATABASE, mnodeGetUserFromMsg(pMsg), pDb->name, !code); return code; } @@ -419,7 +420,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg * SDbObj *pDb = mnodeGetDb(pCreate->db); if (pDb != NULL) { - mnodeDecDbRef(pDb); + mnodeDecDbRef(pDb); if (pCreate->ignoreExist) { mDebug("db:%s, already exist, ignore exist is set", pCreate->db); return TSDB_CODE_SUCCESS; @@ -434,8 +435,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg * pDb = calloc(1, sizeof(SDbObj)); tstrncpy(pDb->name, pCreate->db, sizeof(pDb->name)); - tstrncpy(pDb->acct, pAcct->user, sizeof(pDb->acct)); - pDb->createdTime = taosGetTimestampMs(); + tstrncpy(pDb->acct, pAcct->user, sizeof(pDb->acct)); + pDb->createdTime = taosGetTimestampMs(); pDb->cfg = (SDbCfg) { .cacheBlockSize = pCreate->cacheBlockSize, .totalBlocks = pCreate->totalBlocks, @@ -499,7 +500,7 @@ bool mnodeCheckIsMonitorDB(char *db, char *monitordb) { #if 0 void mnodePrintVgroups(SDbObj *pDb, char *row) { - mInfo("db:%s, vgroup link from head, row:%s", pDb->name, row); + mInfo("db:%s, vgroup link from head, row:%s", pDb->name, row); SVgObj *pVgroup = pDb->pHead; while (pVgroup != NULL) { mInfo("vgId:%d", pVgroup->vgId); @@ -621,7 +622,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn pShow->bytes[cols] = 24 + VARSTR_HEADER_SIZE; pSchema[cols].type = TSDB_DATA_TYPE_BINARY; -#ifdef _STORAGE +#ifdef _STORAGE strcpy(pSchema[cols].name, "keep0,keep1,keep2"); #else strcpy(pSchema[cols].name, "keep"); @@ -638,13 +639,13 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn strcpy(pSchema[cols].name, "cache(MB)"); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - + pShow->bytes[cols] = 4; pSchema[cols].type = TSDB_DATA_TYPE_INT; strcpy(pSchema[cols].name, "blocks"); pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - + pShow->bytes[cols] = 4; pSchema[cols].type = TSDB_DATA_TYPE_INT; strcpy(pSchema[cols].name, "minrows"); @@ -743,7 +744,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void cols = 0; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; char* name = mnodeGetDbStr(pDb->name); if (name != NULL) { STR_WITH_MAXSIZE_TO_VARSTR(pWrite, name, pShow->bytes[cols]); @@ -789,10 +790,10 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void #endif pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - + char tmp[128] = {0}; -#ifdef _STORAGE - if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) { +#ifdef _STORAGE + if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) { sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2, pDb->cfg.daysToKeep0); } else { sprintf(tmp, "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2); @@ -821,7 +822,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int32_t *)pWrite = pDb->cfg.maxRowsPerFileBlock; cols++; - + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int8_t *)pWrite = pDb->cfg.walLevel; cols++; @@ -912,7 +913,7 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb) { } static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) { - SCreateDbMsg *pCreate = pMsg->rpcMsg.pCont; + SCreateDbMsg *pCreate = pMsg->rpcMsg.pCont; pCreate->maxTables = htonl(pCreate->maxTables); pCreate->cacheBlockSize = htonl(pCreate->cacheBlockSize); pCreate->totalBlocks = htonl(pCreate->totalBlocks); @@ -925,7 +926,7 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) { pCreate->partitions = htons(pCreate->partitions); pCreate->minRowsPerFileBlock = htonl(pCreate->minRowsPerFileBlock); pCreate->maxRowsPerFileBlock = htonl(pCreate->maxRowsPerFileBlock); - + int32_t code; #ifdef GRANT_CHECK_WRITE if (grantCheck(TSDB_GRANT_TIME) != TSDB_CODE_SUCCESS) { @@ -963,7 +964,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { int8_t cacheLastRow = pAlter->cacheLastRow; int8_t dbType = pAlter->dbType; int16_t partitions = htons(pAlter->partitions); - + terrno = TSDB_CODE_SUCCESS; //UPGRATE FROM LOW VERSION, reorder it @@ -1013,9 +1014,9 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { newCfg.daysToKeep2 = daysToKeep2; } - if (minRows > 0 && minRows != pDb->cfg.minRowsPerFileBlock) { - mError("db:%s, can't alter minRows option", pDb->name); - terrno = TSDB_CODE_MND_INVALID_DB_OPTION; + if (minRows >= 0 && minRows != pDb->cfg.minRowsPerFileBlock) { + mDebug("db:%s, minRows:%d change to %d", pDb->name, pDb->cfg.minRowsPerFileBlock, minRows); + newCfg.minRowsPerFileBlock = minRows; } if (maxRows > 0 && maxRows != pDb->cfg.maxRowsPerFileBlock) { @@ -1127,6 +1128,8 @@ static int32_t mnodeAlterDbFp(SMnodeMsg *pMsg) { mDebug("db:%s, all vgroups is altered", pDb->name); mLInfo("db:%s, is alterd by %s", pDb->name, mnodeGetUserFromMsg(pMsg)); + monSaveAuditLog(MON_DDL_CMD_ALTER_DATABASE, mnodeGetUserFromMsg(pMsg), pDb->name, true); + // in case there is no vnode for this db currently(no table in db,etc.) if (pMsg->expected == 0) { SSdbRow row = { @@ -1183,7 +1186,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) { if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("db:%s, failed to alter, reason:%s", pDb->name, tstrerror(code)); } -} + } return code; } @@ -1197,7 +1200,7 @@ int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) { mError("db:%s, failed to alter, invalid db", pAlter->db); return TSDB_CODE_MND_INVALID_DB; } - + if (pMsg->pDb->status != TSDB_DB_STATUS_READY) { mError("db:%s, status:%d, in dropping", pAlter->db, pMsg->pDb->status); return TSDB_CODE_MND_DB_IN_DROPPING; @@ -1213,13 +1216,14 @@ static int32_t mnodeDropDbCb(SMnodeMsg *pMsg, int32_t code) { } else { mLInfo("db:%s, is dropped by %s", pDb->name, mnodeGetUserFromMsg(pMsg)); } + monSaveAuditLog(MON_DDL_CMD_DROP_DATABASE, mnodeGetUserFromMsg(pMsg), pDb->name, !code); return code; } static int32_t mnodeDropDb(SMnodeMsg *pMsg) { if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR; - + SDbObj *pDb = pMsg->pDb; mInfo("db:%s, drop db from sdb", pDb->name); @@ -1259,7 +1263,7 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg) { mError("db:%s, can't drop monitor database", pDrop->db); return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN; } -#endif +#endif int32_t code = mnodeSetDbDropping(pMsg->pDb); if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { @@ -1292,15 +1296,15 @@ static int32_t mnodeSyncDb(SDbObj *pDb, SMnodeMsg *pMsg) { static int32_t mnodeCompact(SDbObj *pDb, SCompactMsg *pCompactMsg) { - int32_t count = ntohs(pCompactMsg->numOfVgroup); - int32_t *buf = malloc(sizeof(int32_t) * count); + int32_t count = ntohs(pCompactMsg->numOfVgroup); + int32_t *buf = malloc(sizeof(int32_t) * count); if (buf == NULL) { return TSDB_CODE_MND_OUT_OF_MEMORY; } for (int32_t i = 0; i < count; i++) { buf[i] = ntohs(pCompactMsg->vgid[i]); } - + // copy from mnodeSyncDb, so ugly for (int32_t i = 0; i < count; i++) { SVgObj *pVgroup = NULL; @@ -1312,7 +1316,7 @@ static int32_t mnodeCompact(SDbObj *pDb, SCompactMsg *pCompactMsg) { if (pVgroup->pDb == pDb && pVgroup->vgId == buf[i]) { mnodeSendCompactVgroupMsg(pVgroup); mnodeDecVgroupRef(pVgroup); - valid = true; + valid = true; break; } mnodeDecVgroupRef(pVgroup); @@ -1321,7 +1325,7 @@ static int32_t mnodeCompact(SDbObj *pDb, SCompactMsg *pCompactMsg) { mLError("db:%s, cannot find valid vgId: %d", pDb->name, buf[i]); } } - free(buf); + free(buf); mLInfo("db:%s, trigger compact", pDb->name); return TSDB_CODE_SUCCESS; @@ -1352,14 +1356,14 @@ static int32_t mnodeProcessSyncDbMsg(SMnodeMsg *pMsg) { static int32_t mnodeProcessCompactMsg(SMnodeMsg *pMsg) { SCompactMsg *pCompact = pMsg->rpcMsg.pCont; mDebug("db:%s, compact is received from thandle:%p", pCompact->db, pMsg->rpcMsg.handle); - + if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(pCompact->db); if (pMsg->pDb == NULL) return TSDB_CODE_MND_DB_NOT_SELECTED; - + if (pMsg->pDb->status != TSDB_DB_STATUS_READY) { mError("db:%s, status:%d, in dropping, ignore compact request", pCompact->db, pMsg->pDb->status); return TSDB_CODE_MND_DB_IN_DROPPING; - } + } return mnodeCompact(pMsg->pDb, pCompact); } @@ -1382,7 +1386,7 @@ void mnodeDropAllDbs(SAcctObj *pAcct) { .pTable = tsDbSdb, .pObj = pDb }; - + sdbDeleteRow(&row); numOfDbs++; } @@ -1410,11 +1414,11 @@ int32_t mnodeCompactDbs() { }; mInfo("compact dbs %s", pDb->name); - + sdbInsertCompactRow(&row); } mInfo("end to compact dbs table..."); - return 0; + return 0; } diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index f32d7841d3fb52cd73f87b53c79242d12b617258..6adb3e26ed30f3436ca00ecaddea50e6c0b36361 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -38,6 +38,7 @@ #include "mnodeSdb.h" #include "mnodeShow.h" #include "mnodeTable.h" +#include "mnodeUser.h" #include "mnodeVgroup.h" #include "mnodeWrite.h" #include "mnodeRead.h" @@ -1047,7 +1048,7 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) { if (code == TSDB_CODE_SUCCESS) { mLInfo("stable:%s, is created in sdb, uid:%" PRIu64, pTable->info.tableId, pTable->uid); if(pMsg->pBatchMasterMsg) - pMsg->pBatchMasterMsg->successed ++; + pMsg->pBatchMasterMsg->successed ++; } else { mError("msg:%p, app:%p stable:%s, failed to create in sdb, reason:%s", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId, tstrerror(code)); @@ -1056,11 +1057,12 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) { if(pMsg->pBatchMasterMsg) pMsg->pBatchMasterMsg->received ++; } + monSaveAuditLog(MON_DDL_CMD_CREATE_SUPER_TABLE, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, !code); // if super table create by batch msg, check done and send finished to client if(pMsg->pBatchMasterMsg) { if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received >= pMsg->pBatchMasterMsg->expected) - dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code); + dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code); } return code; @@ -1171,11 +1173,12 @@ static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) { SSTableObj *pTable = (SSTableObj *)pMsg->pTable; if (code != TSDB_CODE_SUCCESS) { mError("msg:%p, app:%p stable:%s, failed to drop, sdb error", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId); - + monSaveAuditLog(MON_DDL_CMD_DROP_SUPER_TABLE, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, false); return code; } mLInfo("msg:%p, app:%p stable:%s, is dropped from sdb", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId); + monSaveAuditLog(MON_DDL_CMD_DROP_SUPER_TABLE, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, true); SSTableObj *pStable = (SSTableObj *)pMsg->pTable; if (pStable->vgHash != NULL /*pStable->numOfTables != 0*/) { @@ -1250,6 +1253,8 @@ static int32_t mnodeAddSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) { if (code == TSDB_CODE_SUCCESS) { code = mnodeGetSuperTableMeta(pMsg); } + monSaveAuditLog(MON_DDL_CMD_ADD_TAG, mnodeGetUserFromMsg(pMsg), pStable->info.tableId, !code); + return code; } @@ -1308,6 +1313,8 @@ static int32_t mnodeDropSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) { if (code == TSDB_CODE_SUCCESS) { code = mnodeGetSuperTableMeta(pMsg); } + monSaveAuditLog(MON_DDL_CMD_DROP_TAG, mnodeGetUserFromMsg(pMsg), pStable->info.tableId, !code); + return code; } @@ -1345,6 +1352,8 @@ static int32_t mnodeModifySuperTableTagNameCb(SMnodeMsg *pMsg, int32_t code) { if (code == TSDB_CODE_SUCCESS) { code = mnodeGetSuperTableMeta(pMsg); } + monSaveAuditLog(MON_DDL_CMD_CHANGE_TAG, mnodeGetUserFromMsg(pMsg), pStable->info.tableId, !code); + return code; } @@ -1403,6 +1412,8 @@ static int32_t mnodeAddSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) { if (code == TSDB_CODE_SUCCESS) { code = mnodeGetSuperTableMeta(pMsg); } + + monSaveAuditLog(MON_DDL_CMD_ADD_COLUMN, mnodeGetUserFromMsg(pMsg), pStable->info.tableId, !code); return code; } @@ -1474,6 +1485,8 @@ static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) { if (code == TSDB_CODE_SUCCESS) { code = mnodeGetSuperTableMeta(pMsg); } + monSaveAuditLog(MON_DDL_CMD_DROP_COLUMN, mnodeGetUserFromMsg(pMsg), pStable->info.tableId, !code); + return code; } @@ -1522,6 +1535,8 @@ static int32_t mnodeChangeSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) { if (code == TSDB_CODE_SUCCESS) { code = mnodeGetSuperTableMeta(pMsg); } + monSaveAuditLog(MON_DDL_CMD_MODIFY_COLUMN, mnodeGetUserFromMsg(pMsg), pStable->info.tableId, !code); + return code; } @@ -2073,6 +2088,9 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) { SCreateTableMsg *pCreate = (SCreateTableMsg*) ((char*)pMsg->rpcMsg.pCont + sizeof(SCMCreateTableMsg)); assert(pTable); + monSaveAuditLog((pTable->info.type == TSDB_CHILD_TABLE) ? MON_DDL_CMD_CREATE_CHILD_TABLE : MON_DDL_CMD_CREATE_TABLE, + mnodeGetUserFromMsg(pMsg), pTable->info.tableId, !code); + if (code == TSDB_CODE_SUCCESS) { if (pCreate->getMeta) { mDebug("msg:%p, app:%p table:%s, created in dnode and continue to get meta, thandle:%p", pMsg, @@ -2101,6 +2119,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) { } else { mError("msg:%p, app:%p table:%s, failed to create table sid:%d, uid:%" PRIu64 ", reason:%s", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId, pTable->tid, pTable->uid, tstrerror(code)); + SSdbRow desc = {.type = SDB_OPER_GLOBAL, .pObj = pTable, .pTable = tsChildTableSdb}; sdbDeleteRow(&desc); @@ -2294,6 +2313,8 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) { if (pDrop == NULL) { mError("msg:%p, app:%p ctable:%s, failed to drop ctable, no enough memory", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId); + monSaveAuditLog((pTable->info.type == TSDB_CHILD_TABLE) ? MON_DDL_CMD_DROP_CHILD_TABLE : MON_DDL_CMD_DROP_TABLE, + mnodeGetUserFromMsg(pMsg), pTable->info.tableId, false); return TSDB_CODE_MND_OUT_OF_MEMORY; } @@ -2308,6 +2329,9 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) { mInfo("msg:%p, app:%p ctable:%s, send drop ctable msg, vgId:%d sid:%d uid:%" PRIu64, pMsg, pMsg->rpcMsg.ahandle, pDrop->tableFname, pTable->vgId, pTable->tid, pTable->uid); + monSaveAuditLog((pTable->info.type == TSDB_CHILD_TABLE) ? MON_DDL_CMD_DROP_CHILD_TABLE : MON_DDL_CMD_DROP_TABLE, + mnodeGetUserFromMsg(pMsg), pTable->info.tableId, true); + SRpcMsg rpcMsg = { .ahandle = pMsg, .pCont = pDrop, @@ -2327,6 +2351,8 @@ static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) { if (code != TSDB_CODE_SUCCESS) { SCTableObj *pTable = (SCTableObj *)pMsg->pTable; mError("msg:%p, app:%p ctable:%s, failed to drop, sdb error", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId); + monSaveAuditLog((pTable->info.type == TSDB_CHILD_TABLE) ? MON_DDL_CMD_DROP_CHILD_TABLE : MON_DDL_CMD_DROP_TABLE, + mnodeGetUserFromMsg(pMsg), pTable->info.tableId, false); return code; } @@ -2414,6 +2440,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3 SDbObj *pDb = pMsg->pDb; if (ncols <= 0) { mError("msg:%p, app:%p ctable:%s, add column, ncols:%d <= 0", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId, ncols); + monSaveAuditLog(MON_DDL_CMD_ADD_COLUMN, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, false); return TSDB_CODE_MND_APP_ERROR; } @@ -2421,6 +2448,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3 if (mnodeFindNormalTableColumnIndex(pTable, schema[i].name) > 0) { mError("msg:%p, app:%p ctable:%s, add column, column:%s already exist", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId, schema[i].name); + monSaveAuditLog(MON_DDL_CMD_ADD_COLUMN, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, false); return TSDB_CODE_MND_FIELD_ALREAY_EXIST; } } @@ -2445,6 +2473,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3 } mInfo("msg:%p, app:%p ctable %s, start to add column", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId); + monSaveAuditLog(MON_DDL_CMD_ADD_COLUMN, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, true); SSdbRow row = { .type = SDB_OPER_GLOBAL, @@ -2464,6 +2493,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) { if (col <= 0) { mError("msg:%p, app:%p ctable:%s, drop column, column:%s not exist", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId, colName); + monSaveAuditLog(MON_DDL_CMD_DROP_COLUMN, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, false); return TSDB_CODE_MND_FIELD_NOT_EXIST; } @@ -2478,6 +2508,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) { } mInfo("msg:%p, app:%p ctable %s, start to drop column %s", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId, colName); + monSaveAuditLog(MON_DDL_CMD_DROP_COLUMN, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, true); SSdbRow row = { .type = SDB_OPER_GLOBAL, @@ -2498,15 +2529,18 @@ static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg) { if (col < 0) { mError("msg:%p, app:%p ctable:%s, change column, name: %s", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId, name); + monSaveAuditLog(MON_DDL_CMD_MODIFY_COLUMN, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, false); return TSDB_CODE_MND_FIELD_NOT_EXIST; } SSchema *schema = (SSchema *) (pTable->schema + col); ASSERT(schema->type == TSDB_DATA_TYPE_BINARY || schema->type == TSDB_DATA_TYPE_NCHAR); schema->bytes = pAlter->schema[0].bytes; + ++pTable->sversion; mInfo("msg:%p, app:%p ctable %s, start to modify column %s len to %d", pMsg, pMsg->rpcMsg.ahandle, pTable->info.tableId, name, schema->bytes); + monSaveAuditLog(MON_DDL_CMD_MODIFY_COLUMN, mnodeGetUserFromMsg(pMsg), pTable->info.tableId, true); SSdbRow row = { .type = SDB_OPER_GLOBAL, @@ -3558,7 +3592,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pTable->sql, pShow->bytes[cols]); + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pTable->sql, pShow->bytes[cols]); cols++; numOfRows++; @@ -3593,13 +3627,13 @@ static int32_t mnodeCompactSuperTables() { }; //mInfo("compact super %" PRIu64, pTable->uid); - + sdbInsertCompactRow(&row); } mInfo("end to compact super table..."); - return 0; + return 0; } static int32_t mnodeCompactChildTables() { @@ -3619,13 +3653,13 @@ static int32_t mnodeCompactChildTables() { }; //mInfo("compact child %" PRIu64 ":%d", pTable->uid, pTable->tid); - + sdbInsertCompactRow(&row); } mInfo("end to compact child table..."); - return 0; + return 0; } int32_t mnodeCompactTables() { diff --git a/src/mnode/src/mnodeUser.c b/src/mnode/src/mnodeUser.c index 6d6ccb933e414fd8d07c5282753685603a7e1be2..85f20b6d24990c9229fb47e5744d232b96508d8b 100644 --- a/src/mnode/src/mnodeUser.c +++ b/src/mnode/src/mnodeUser.c @@ -97,7 +97,7 @@ static int32_t mnodeUserActionDecode(SSdbRow *pRow) { SUserObj *pUser = (SUserObj *)calloc(1, sizeof(SUserObj)); if (pUser == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY; - memcpy(pUser, pRow->rowData, tsUserUpdateSize); + memcpy(pUser, pRow->rowData, pRow->rowSize); pRow->pObj = pUser; return TSDB_CODE_SUCCESS; } @@ -108,7 +108,7 @@ static void mnodePrintUserAuth() { mDebug("failed to auth.txt for write"); return; } - + void * pIter = NULL; SUserObj *pUser = NULL; @@ -181,7 +181,7 @@ int32_t mnodeInitUsers() { mnodeAddShowFreeIterHandle(TSDB_MGMT_TABLE_USER, mnodeCancelGetNextUser); mnodeAddPeerMsgHandle(TSDB_MSG_TYPE_DM_AUTH, mnodeProcessAuthMsg); - + mDebug("table:%s, hash is created", desc.name); return 0; } @@ -195,20 +195,20 @@ SUserObj *mnodeGetUser(char *name) { return (SUserObj *)sdbGetRow(tsUserSdb, name); } -void *mnodeGetNextUser(void *pIter, SUserObj **pUser) { - return sdbFetchRow(tsUserSdb, pIter, (void **)pUser); +void *mnodeGetNextUser(void *pIter, SUserObj **pUser) { + return sdbFetchRow(tsUserSdb, pIter, (void **)pUser); } void mnodeCancelGetNextUser(void *pIter) { sdbFreeIter(tsUserSdb, pIter); } -void mnodeIncUserRef(SUserObj *pUser) { - sdbIncRef(tsUserSdb, pUser); +void mnodeIncUserRef(SUserObj *pUser) { + sdbIncRef(tsUserSdb, pUser); } -void mnodeDecUserRef(SUserObj *pUser) { - sdbDecRef(tsUserSdb, pUser); +void mnodeDecUserRef(SUserObj *pUser) { + sdbDecRef(tsUserSdb, pUser); } static int32_t mnodeUpdateUser(SUserObj *pUser, void *pMsg) { @@ -464,7 +464,7 @@ char *mnodeGetUserFromMsg(void *pMsg) { static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) { SUserObj *pOperUser = pMsg->pUser; - + if (pOperUser->superAuth) { SCreateUserMsg *pCreate = pMsg->rpcMsg.pCont; return mnodeCreateUser(pOperUser->pAcct, pCreate->user, pCreate->pass, pCreate->tags, pMsg); @@ -477,7 +477,7 @@ static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) { static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg) { int32_t code; SUserObj *pOperUser = pMsg->pUser; - + SAlterUserMsg *pAlter = pMsg->rpcMsg.pCont; SUserObj *pUser = mnodeGetUser(pAlter->user); if (pUser == NULL) { @@ -686,10 +686,10 @@ int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, cha static int32_t mnodeProcessAuthMsg(SMnodeMsg *pMsg) { SAuthMsg *pAuthMsg = pMsg->rpcMsg.pCont; SAuthRsp *pAuthRsp = rpcMallocCont(sizeof(SAuthRsp)); - + pMsg->rpcRsp.rsp = pAuthRsp; pMsg->rpcRsp.len = sizeof(SAuthRsp); - + return mnodeRetriveAuth(pAuthMsg->user, &pAuthRsp->spi, &pAuthRsp->encrypt, pAuthRsp->secret, pAuthRsp->ckey); } @@ -711,7 +711,7 @@ int32_t mnodeCompactUsers() { }; mInfo("compact users %s", pUser->user); - + sdbInsertCompactRow(&row); } diff --git a/src/os/src/detail/osSocket.c b/src/os/src/detail/osSocket.c index 7ce9d6eb06621f0a691699020cff13b9c15a9a88..0b6cda29b4a53d8e6893513a4b8a478e37eb2e39 100644 --- a/src/os/src/detail/osSocket.c +++ b/src/os/src/detail/osSocket.c @@ -71,9 +71,13 @@ int32_t taosSetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *op return setsockopt(socketfd, level, optname, optval, (socklen_t)optlen); } +#endif + +#if !defined(_TD_DARWIN_32) + int32_t taosGetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *optval, int32_t* optlen) { return getsockopt(socketfd, level, optname, optval, (socklen_t *)optlen); -} +} #endif diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index 6af0d2bf0afe2c0fe2289f847a3f4da200cbc7ff..f92abc3cf196228d9a7b3bf018120d5ff1bbd229 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -41,6 +41,9 @@ #define DNODE_INFO_LEN 128 #define QUERY_ID_LEN 24 #define CHECK_INTERVAL 1000 +#define AUDIT_MAX_RETRIES 10 +#define MAX_DDL_TYPE_LEN 32 +#define MAX_DDL_OBJ_LEN 512 #define SQL_STR_FMT "\"%s\"" @@ -161,6 +164,7 @@ typedef struct { } SMonStat; static void *monHttpStatusHashTable; +static void *auditConn; static SMonConn tsMonitor = {0}; static SMonStat tsMonStat = {{0}}; @@ -175,16 +179,24 @@ static void monSaveDisksInfo(); static void monSaveGrantsInfo(); static void monSaveHttpReqInfo(); static void monGetSysStats(); -static void *monThreadFunc(void *param); +static void *monThreadFunc(void *param); +static void *monAuditFunc(void *param); static void monBuildMonitorSql(char *sql, int32_t cmd); -static void monInitHttpStatusHashTable(); -static void monCleanupHttpStatusHashTable(); +static void monInitHttpStatusHashTable(); +static void monCleanupHttpStatusHashTable(); extern int32_t (*monStartSystemFp)(); extern void (*monStopSystemFp)(); extern void (*monExecuteSQLFp)(char *sql); extern char * strptime(const char *buf, const char *fmt, struct tm *tm); //make the compilation pass +#ifdef _STORAGE + char *keepValue = "30,30,30"; +#else + char *keepValue = "30"; +#endif + + int32_t monInitSystem() { if (tsMonitor.ep[0] == 0) { strcpy(tsMonitor.ep, tsLocalEp); @@ -203,12 +215,20 @@ int32_t monInitSystem() { pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE); if (pthread_create(&tsMonitor.thread, &thAttr, monThreadFunc, NULL)) { - monError("failed to create thread to for monitor module, reason:%s", strerror(errno)); + monError("failed to create thread for monitor module, reason:%s", strerror(errno)); + return -1; + } + monDebug("monitor thread is launched"); + + pthread_t auditThread; + pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_DETACHED); + if (pthread_create(&auditThread, &thAttr, monAuditFunc, NULL)) { + monError("failed to create audit thread, reason:%s", strerror(errno)); return -1; } + monDebug("audit thread is launched"); pthread_attr_destroy(&thAttr); - monDebug("monitor thread is launched"); monStartSystemFp = monStartSystem; monStopSystemFp = monStopSystem; @@ -250,6 +270,70 @@ SMonHttpStatus *monGetHttpStatusHashTableEntry(int32_t code) { return (SMonHttpStatus*)taosHashGet(monHttpStatusHashTable, &code, sizeof(int32_t)); } +static void *monAuditFunc(void *param) { + if (!tsEnableAudit) { + return NULL; + } + + monDebug("starting to initialize audit database..."); + setThreadName("audit"); + taosMsleep(1000); + + int32_t try = 0; + for (; try < AUDIT_MAX_RETRIES; ++try) { + auditConn = taos_connect(NULL, "monitor", tsInternalPass, "", 0); + if (auditConn == NULL) { + monDebug("audit retry connect, tries: %d", try); + taosMsleep(1000); + } else { + monDebug("audit successfuly connect to database"); + break; + } + } + + if (try == AUDIT_MAX_RETRIES) { + monError("audit failed to connect to database, reason:%s", tstrerror(terrno)); + return NULL; + } + + // create database + char sql[512] = {0}; + snprintf(sql, sizeof(sql), + "create database if not exists %s replica 1 days 10 keep %s cache %d " + "blocks %d precision 'us'", + tsAuditDbName, keepValue, TSDB_MIN_CACHE_BLOCK_SIZE, TSDB_MIN_TOTAL_BLOCKS); + + void *res = taos_query(auditConn, sql); + int32_t code = taos_errno(res); + taos_free_result(res); + + if (code != 0) { + monError("failed to create database: %s, sql:%s, reason:%s", tsAuditDbName, sql, tstrerror(code)); + return NULL; + } + + // create table + memset(sql, 0, sizeof(sql)); + snprintf(sql, sizeof(sql), + "create table if not exists %s.ddl(ts timestamp" + ", user_name binary(%d), ip_addr binary(%d), type binary(%d)" + ", object binary(%d), result binary(10)" + ")", + tsAuditDbName, TSDB_USER_LEN, IP_LEN_STR, + MAX_DDL_TYPE_LEN, MAX_DDL_OBJ_LEN); + + res = taos_query(auditConn, sql); + code = taos_errno(res); + taos_free_result(res); + + if (code != 0) { + monError("failed to create table: ddl, exec sql:%s, reason:%s", sql, tstrerror(code)); + return NULL; + } + + return NULL; +} + static void *monThreadFunc(void *param) { monDebug("starting to initialize monitor module ..."); setThreadName("monitor"); @@ -335,12 +419,6 @@ static void *monThreadFunc(void *param) { static void monBuildMonitorSql(char *sql, int32_t cmd) { memset(sql, 0, SQL_LENGTH); -#ifdef _STORAGE - char *keepValue = "30,30,30"; -#else - char *keepValue = "30"; -#endif - if (cmd == MON_CMD_CREATE_DB) { snprintf(sql, SQL_LENGTH, "create database if not exists %s replica %d days 10 keep %s cache %d " @@ -494,6 +572,11 @@ void monCleanupSystem() { pthread_join(tsMonitor.thread, NULL); } + if (auditConn != NULL) { + taos_close(tsMonitor.conn); + auditConn = NULL; + } + if (tsMonitor.conn != NULL) { taos_close(tsMonitor.conn); tsMonitor.conn = NULL; @@ -1323,6 +1406,116 @@ static void monExecSqlCb(void *param, TAOS_RES *result, int32_t code) { taos_free_result(result); } +static bool monConvDDLType2Str(int8_t type, char *buf, int32_t len) { + if (buf == NULL) { + return false; + } + + switch (type) { + case MON_DDL_CMD_CREATE_DATABASE: { + strncpy(buf, "CREATE DATABASE", len); + break; + } + case MON_DDL_CMD_CREATE_TABLE: { + strncpy(buf, "CREATE TABLE", len); + break; + } + case MON_DDL_CMD_CREATE_CHILD_TABLE: { + strncpy(buf, "CREATE CHILD TABLE", len); + break; + } + case MON_DDL_CMD_CREATE_SUPER_TABLE: { + strncpy(buf, "CREATE SUPER TABLE", len); + break; + } + case MON_DDL_CMD_DROP_DATABASE: { + strncpy(buf, "DROP DATABASE", len); + break; + } + case MON_DDL_CMD_DROP_TABLE: { + strncpy(buf, "DROP TABLE", len); + break; + } + case MON_DDL_CMD_DROP_CHILD_TABLE: { + strncpy(buf, "DROP CHILD TABLE", len); + break; + } + case MON_DDL_CMD_DROP_SUPER_TABLE: { + strncpy(buf, "DROP SUPER TABLE", len); + break; + } + case MON_DDL_CMD_DROP_COLUMN: { + strncpy(buf, "DROP COLUMN", len); + break; + } + case MON_DDL_CMD_DROP_TAG: { + strncpy(buf, "DROP TAG", len); + break; + } + case MON_DDL_CMD_ALTER_DATABASE: { + strncpy(buf, "ALTER DATABASE", len); + break; + } + case MON_DDL_CMD_ADD_COLUMN: { + strncpy(buf, "ADD COLUMN", len); + break; + } + case MON_DDL_CMD_ADD_TAG: { + strncpy(buf, "ADD TAG", len); + break; + } + case MON_DDL_CMD_MODIFY_COLUMN: { + strncpy(buf, "MODIFY COLUMN/TAG LENGTH", len); + break; + } + case MON_DDL_CMD_CHANGE_TAG: { + strncpy(buf, "CHANGE TAG NAME", len); + break; + } + default: { + return false; + } + } + return true; +} + +void monSaveAuditLog(int8_t type, const char *user, const char *obj, bool result) { + if (tsEnableAudit == 0) { //audit not enabled + return; + } + + char sql[1024] = {0}; + char typeStr[64] = {0}; + + if (!monConvDDLType2Str(type, typeStr, (int32_t)sizeof(typeStr))) { + monError("unknown DDL type: %d ", type); + return; + } + + snprintf(sql, 1023, + "insert into %s.ddl values(now, " + SQL_STR_FMT", "SQL_STR_FMT", " + SQL_STR_FMT", "SQL_STR_FMT", " + SQL_STR_FMT")", + tsAuditDbName, + (user != NULL) ? user : "NULL", + tsLocalEp, + typeStr, + (obj != NULL) ? obj : "NULL", + result ? "success" : "fail"); + + monDebug("save ddl info, sql:%s", sql); + void *res = taos_query(auditConn, sql); + int32_t code = taos_errno(res); + taos_free_result(res); + + if (code != 0) { + monError("failed to save audit ddl info, reason:%s, sql:%s", tstrerror(code), sql); + } else { + monDebug("successfully save audit ddl info, sql:%s", sql); + } +} + void monSaveAcctLog(SAcctMonitorObj *pMon) { if (tsMonitor.state != MON_STATE_INITED) return; @@ -1399,6 +1592,7 @@ void monSaveDnodeLog(int32_t level, const char *const format, ...) { taos_query_a(tsMonitor.conn, sql, monExecSqlCb, "log"); } + void monExecuteSQL(char *sql) { if (tsMonitor.state != MON_STATE_INITED) return; diff --git a/src/plugins/taosadapter b/src/plugins/taosadapter index 07950e62e576dbf96344d757ef0dd3fabd9570d9..1b1a07e8477a37be6d61a7fc907479ec5ebd05b7 160000 --- a/src/plugins/taosadapter +++ b/src/plugins/taosadapter @@ -1 +1 @@ -Subproject commit 07950e62e576dbf96344d757ef0dd3fabd9570d9 +Subproject commit 1b1a07e8477a37be6d61a7fc907479ec5ebd05b7 diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 64b22009c34a13c973f3a24fd36e8d992d8d145c..46f94faf189398e879623ff099f210f6bf126f53 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -311,6 +311,7 @@ alter_db_optr(Y) ::= alter_db_optr(Z) blocks(X). { Y = Z; Y.numOfBlocks = s alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); } +alter_db_optr(Y) ::= alter_db_optr(Z) minrows(X). { Y = Z; Y.minRowsPerBlock = strtol(X.z, NULL, 10); } // dynamically update the following two parameters are not allowed. //alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); } diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index d12bb28ab819cad0c041828ceeaa72ea924fe4f1..80926e1bb0f3217f3ebff977c1a9634bc573c888 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -30,6 +30,7 @@ #include "qUdf.h" #include "tcompare.h" #include "hashfunc.h" +#include "tglobal.h" #define GET_INPUT_DATA_LIST(x) ((char *)((x)->pInput)) #define GET_INPUT_DATA(x, y) (GET_INPUT_DATA_LIST(x) + (y) * (x)->inputBytes) @@ -1952,7 +1953,7 @@ static void stddev_function(SQLFunctionCtx *pCtx) { pStd->avg = GET_DOUBLE_VAL(pCtx->pOutput); assert((isnan(pAvg->sum) && pAvg->num == 0) || (pStd->num == pAvg->num && pStd->avg == pAvg->sum)); } - + if (pStd->stage == 0) { // the first stage is to calculate average value avg_function(pCtx); @@ -1961,7 +1962,7 @@ static void stddev_function(SQLFunctionCtx *pCtx) { // if pStd->num == 0, there are no numbers in the first round check. No need to do the second round double *retVal = &pStd->res; double avg = pStd->avg; - + void *pData = GET_INPUT_DATA_LIST(pCtx); int32_t num = 0; @@ -2015,14 +2016,14 @@ static void stddev_function(SQLFunctionCtx *pCtx) { default: qError("stddev function not support data type:%d", pCtx->inputType); } - + SET_VAL(pCtx, 1, 1); } } static void stddev_finalizer(SQLFunctionCtx *pCtx) { SStddevInfo *pStd = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - + if (pStd->num <= 0) { setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); } else { @@ -2030,7 +2031,7 @@ static void stddev_finalizer(SQLFunctionCtx *pCtx) { SET_DOUBLE_VAL(retValue, sqrt(pStd->res / pStd->num)); SET_VAL(pCtx, 1, 1); } - + doFinalizer(pCtx); } @@ -2183,11 +2184,11 @@ static bool first_last_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* if (!function_setup(pCtx, pResInfo)) { return false; } - + // used to keep the timestamp for comparison pCtx->param[1].nType = 0; pCtx->param[1].i64 = 0; - + return true; } @@ -2216,7 +2217,7 @@ static void first_function(SQLFunctionCtx *pCtx) { if (pCtx->hasNull && isNull(data, pCtx->inputType)) { continue; } - + memcpy(pCtx->pOutput, data, pCtx->inputBytes); if (pCtx->ptsList != NULL) { TSKEY k = GET_TS_DATA(pCtx, i); @@ -2226,7 +2227,7 @@ static void first_function(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pInfo = GET_RES_INFO(pCtx); pInfo->hasResult = DATA_SET_FLAG; pInfo->complete = true; - + notNullElems++; break; } @@ -2257,14 +2258,14 @@ static void first_function(SQLFunctionCtx *pCtx) { static void first_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t idx) { int64_t *timestamp = GET_TS_LIST(pCtx); - + SFirstLastInfo *pInfo = (SFirstLastInfo *)(pCtx->pOutput + pCtx->inputBytes); - + if (pInfo->hasResult != DATA_SET_FLAG || timestamp[idx] < pInfo->ts) { memcpy(pCtx->pOutput, pData, pCtx->inputBytes); pInfo->hasResult = DATA_SET_FLAG; pInfo->ts = timestamp[idx]; - + DO_UPDATE_TAG_COLUMNS(pCtx, pInfo->ts); } } @@ -2282,7 +2283,7 @@ static void first_dist_function(SQLFunctionCtx *pCtx) { if (pCtx->order == TSDB_ORDER_DESC/* || pCtx->preAggVals.dataBlockLoaded == false*/) { return; } - + int32_t notNullElems = 0; // find the first not null value @@ -2291,16 +2292,16 @@ static void first_dist_function(SQLFunctionCtx *pCtx) { if (pCtx->hasNull && isNull(data, pCtx->inputType)) { continue; } - + first_data_assign_impl(pCtx, data, i); - + SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; - + notNullElems++; break; } - + SET_VAL(pCtx, notNullElems, 1); } @@ -2312,16 +2313,16 @@ static void first_dist_func_merge(SQLFunctionCtx *pCtx) { if (pInput->hasResult != DATA_SET_FLAG) { return; } - + // The param[1] is used to keep the initial value of max ts value if (pCtx->param[1].nType != pCtx->outputType || pCtx->param[1].i64 > pInput->ts) { memcpy(pCtx->pOutput, pData, pCtx->outputBytes); pCtx->param[1].i64 = pInput->ts; pCtx->param[1].nType = pCtx->outputType; - + DO_UPDATE_TAG_COLUMNS(pCtx, pInput->ts); } - + SET_VAL(pCtx, 1, 1); GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG; } @@ -2395,18 +2396,18 @@ static void last_function(SQLFunctionCtx *pCtx) { static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t idx) { int64_t *timestamp = GET_TS_LIST(pCtx); - + SFirstLastInfo *pInfo = (SFirstLastInfo *)(pCtx->pOutput + pCtx->inputBytes); - + if (pInfo->hasResult != DATA_SET_FLAG || pInfo->ts < timestamp[idx]) { #if defined(_DEBUG_VIEW) qDebug("assign index:%d, ts:%" PRId64 ", val:%d, ", idx, timestamp[idx], *(int32_t *)pData); #endif - + memcpy(pCtx->pOutput, pData, pCtx->inputBytes); pInfo->hasResult = DATA_SET_FLAG; pInfo->ts = timestamp[idx]; - + DO_UPDATE_TAG_COLUMNS(pCtx, pInfo->ts); } } @@ -2425,19 +2426,19 @@ static void last_dist_function(SQLFunctionCtx *pCtx) { char *data = GET_INPUT_DATA(pCtx, i); if (pCtx->hasNull && isNull(data, pCtx->inputType)) { if (!pCtx->requireNull) { - continue; + continue; } } - + last_data_assign_impl(pCtx, data, i); - + SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; - + notNullElems++; break; } - + SET_VAL(pCtx, notNullElems, 1); } @@ -2448,12 +2449,12 @@ static void last_dist_function(SQLFunctionCtx *pCtx) { */ static void last_dist_func_merge(SQLFunctionCtx *pCtx) { char *pData = GET_INPUT_DATA_LIST(pCtx); - + SFirstLastInfo *pInput = (SFirstLastInfo*) (pData + pCtx->outputBytes); if (pInput->hasResult != DATA_SET_FLAG) { return; } - + /* * param[1] used to keep the corresponding timestamp to decide if current result is * the true last result @@ -2462,10 +2463,10 @@ static void last_dist_func_merge(SQLFunctionCtx *pCtx) { memcpy(pCtx->pOutput, pData, pCtx->outputBytes); pCtx->param[1].i64 = pInput->ts; pCtx->param[1].nType = pCtx->outputType; - + DO_UPDATE_TAG_COLUMNS(pCtx, pInput->ts); } - + SET_VAL(pCtx, 1, 1); GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG; } @@ -2480,16 +2481,16 @@ static void last_row_function(SQLFunctionCtx *pCtx) { // assign the last element in current data block assignVal(pCtx->pOutput, pData + (pCtx->size - 1) * pCtx->inputBytes, pCtx->inputBytes, pCtx->inputType); - + SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; - + // set the result to final result buffer in case of super table query if (pCtx->stableQuery) { SLastrowInfo *pInfo1 = (SLastrowInfo *)(pCtx->pOutput + pCtx->inputBytes); pInfo1->ts = GET_TS_DATA(pCtx, pCtx->size - 1); pInfo1->hasResult = DATA_SET_FLAG; - + DO_UPDATE_TAG_COLUMNS(pCtx, pInfo1->ts); } else { TSKEY ts = GET_TS_DATA(pCtx, pCtx->size - 1); @@ -2506,7 +2507,7 @@ static void last_row_finalizer(SQLFunctionCtx *pCtx) { setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); return; } - + GET_RES_INFO(pCtx)->numOfRes = 1; doFinalizer(pCtx); } @@ -2517,7 +2518,7 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6 dst->v.nType = type; dst->v.i64 = *(int64_t *)val; dst->timestamp = tsKey; - + int32_t size = 0; if (stage == MERGE_STAGE) { memcpy(dst->pTags, pTags, (size_t)pTagInfo->tagsLen); @@ -2528,7 +2529,7 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6 ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; ctx->tag.i64 = tsKey; } - + tVariantDump(&ctx->tag, dst->pTags + size, ctx->tag.nType, true); size += pTagInfo->pTagCtxList[i]->outputBytes; } @@ -2589,7 +2590,7 @@ static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, SExtTagsInfo *pTagInfo, char *pTags, int16_t stage) { tVariant val = {0}; tVariantCreateFromBinary(&val, pData, tDataTypes[type].bytes, type); - + tValuePair **pList = pInfo->res; assert(pList != NULL); @@ -2597,7 +2598,7 @@ static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, valuePairAssign(pList[pInfo->num], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); taosheapsort((void *) pList, sizeof(tValuePair **), pInfo->num + 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 0); - + pInfo->num++; } else { if ((IS_SIGNED_NUMERIC_TYPE(type) && val.i64 > pList[0]->v.i64) || @@ -2636,7 +2637,7 @@ static void do_bottom_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pDa static int32_t resAscComparFn(const void *pLeft, const void *pRight) { tValuePair *pLeftElem = *(tValuePair **)pLeft; tValuePair *pRightElem = *(tValuePair **)pRight; - + if (pLeftElem->timestamp == pRightElem->timestamp) { return 0; } else { @@ -2649,7 +2650,7 @@ static int32_t resDescComparFn(const void *pLeft, const void *pRight) { return - static int32_t resDataAscComparFn(const void *pLeft, const void *pRight) { tValuePair *pLeftElem = *(tValuePair **)pLeft; tValuePair *pRightElem = *(tValuePair **)pRight; - + if (IS_FLOAT_TYPE(pLeftElem->v.nType)) { if (pLeftElem->v.dKey == pRightElem->v.dKey) { return 0; @@ -2676,9 +2677,9 @@ static int32_t resDataDescComparFn(const void *pLeft, const void *pRight) { retu static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); STopBotInfo *pRes = GET_ROWCELL_INTERBUF(pResInfo); - + tValuePair **tvp = pRes->res; - + int32_t step = QUERY_ASC_FORWARD_STEP; int32_t len = (int32_t)(GET_RES_INFO(pCtx)->numOfRes); @@ -2734,13 +2735,13 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) { return; } } - + // set the output timestamp of each record. TSKEY *output = pCtx->ptsOutputBuf; for (int32_t i = 0; i < len; ++i, output += step) { *output = tvp[i]->timestamp; } - + // set the corresponding tag data for each record // todo check malloc failure if (pCtx->tagInfo.numOfTagCols == 0) { @@ -2751,7 +2752,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) { for (int32_t i = 0; i < pCtx->tagInfo.numOfTagCols; ++i) { pData[i] = pCtx->tagInfo.pTagCtxList[i]->pOutput; } - + for (int32_t i = 0; i < len; ++i, output += step) { int16_t offset = 0; for (int32_t j = 0; j < pCtx->tagInfo.numOfTagCols; ++j) { @@ -2760,7 +2761,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) { pData[j] += pCtx->tagInfo.pTagCtxList[j]->outputBytes; } } - + tfree(pData); } @@ -2791,18 +2792,18 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const cha } STopBotInfo *pTopBotInfo = getOutputInfo(pCtx); - + // required number of results are not reached, continue load data block if (pTopBotInfo->num < pCtx->param[0].i64) { return true; } - + if ((void *)pTopBotInfo->res[0] != (void *)((char *)pTopBotInfo + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { buildTopBotStruct(pTopBotInfo, pCtx); } tValuePair **pRes = (tValuePair**) pTopBotInfo->res; - + if (pCtx->functionId == TSDB_FUNC_TOP) { switch (pCtx->inputType) { case TSDB_DATA_TYPE_TINYINT: @@ -2844,7 +2845,7 @@ static bool top_bottom_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* if (!function_setup(pCtx, pResInfo)) { return false; } - + STopBotInfo *pInfo = getOutputInfo(pCtx); buildTopBotStruct(pInfo, pCtx); return true; @@ -2859,27 +2860,27 @@ static void top_function(SQLFunctionCtx *pCtx) { if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { buildTopBotStruct(pRes, pCtx); } - + for (int32_t i = 0; i < pCtx->size; ++i) { char *data = GET_INPUT_DATA(pCtx, i); if (pCtx->hasNull && isNull(data, pCtx->inputType)) { continue; } - + notNullElems++; // NOTE: Set the default timestamp if it is missing [todo refactor] TSKEY ts = (pCtx->ptsList != NULL)? GET_TS_DATA(pCtx, i):0; do_top_function_add(pRes, (int32_t)pCtx->param[0].i64, data, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); } - + if (!pCtx->hasNull) { assert(pCtx->size == notNullElems); } - + // treat the result as only one result SET_VAL(pCtx, notNullElems, 1); - + if (notNullElems > 0) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; @@ -2888,21 +2889,21 @@ static void top_function(SQLFunctionCtx *pCtx) { static void top_func_merge(SQLFunctionCtx *pCtx) { STopBotInfo *pInput = (STopBotInfo *)GET_INPUT_DATA_LIST(pCtx); - + // construct the input data struct from binary data buildTopBotStruct(pInput, pCtx); - + STopBotInfo *pOutput = getOutputInfo(pCtx); - + // the intermediate result is binary, we only use the output data type for (int32_t i = 0; i < pInput->num; ++i) { int16_t type = (pCtx->outputType == TSDB_DATA_TYPE_FLOAT)? TSDB_DATA_TYPE_DOUBLE:pCtx->outputType; do_top_function_add(pOutput, (int32_t)pCtx->param[0].i64, &pInput->res[i]->v.i64, pInput->res[i]->timestamp, type, &pCtx->tagInfo, pInput->res[i]->pTags, pCtx->currentStage); } - + SET_VAL(pCtx, pInput->num, pOutput->num); - + if (pOutput->num > 0) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; @@ -2911,9 +2912,9 @@ static void top_func_merge(SQLFunctionCtx *pCtx) { static void bottom_function(SQLFunctionCtx *pCtx) { int32_t notNullElems = 0; - + STopBotInfo *pRes = getOutputInfo(pCtx); - + if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { buildTopBotStruct(pRes, pCtx); } @@ -2929,14 +2930,14 @@ static void bottom_function(SQLFunctionCtx *pCtx) { TSKEY ts = (pCtx->ptsList != NULL)? GET_TS_DATA(pCtx, i):0; do_bottom_function_add(pRes, (int32_t)pCtx->param[0].i64, data, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); } - + if (!pCtx->hasNull) { assert(pCtx->size == notNullElems); } - + // treat the result as only one result SET_VAL(pCtx, notNullElems, 1); - + if (notNullElems > 0) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; @@ -2945,12 +2946,12 @@ static void bottom_function(SQLFunctionCtx *pCtx) { static void bottom_func_merge(SQLFunctionCtx *pCtx) { STopBotInfo *pInput = (STopBotInfo *)GET_INPUT_DATA_LIST(pCtx); - + // construct the input data struct from binary data buildTopBotStruct(pInput, pCtx); - + STopBotInfo *pOutput = getOutputInfo(pCtx); - + // the intermediate result is binary, we only use the output data type for (int32_t i = 0; i < pInput->num; ++i) { int16_t type = (pCtx->outputType == TSDB_DATA_TYPE_FLOAT) ? TSDB_DATA_TYPE_DOUBLE : pCtx->outputType; @@ -2959,7 +2960,7 @@ static void bottom_func_merge(SQLFunctionCtx *pCtx) { } SET_VAL(pCtx, pInput->num, pOutput->num); - + if (pOutput->num > 0) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; @@ -2968,17 +2969,17 @@ static void bottom_func_merge(SQLFunctionCtx *pCtx) { static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - + // data in temporary list is less than the required number of results, not enough qualified number of results STopBotInfo *pRes = GET_ROWCELL_INTERBUF(pResInfo); if (pRes->num == 0) { // no result assert(pResInfo->hasResult != DATA_SET_FLAG); // TODO: } - + GET_RES_INFO(pCtx)->numOfRes = pRes->num; tValuePair **tvp = pRes->res; - + // user specify the order of output by sort the result according to timestamp if (pCtx->param[2].i64 == PRIMARYKEY_TIMESTAMP_COL_INDEX) { __compar_fn_t comparator = (pCtx->param[3].i64 == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn; @@ -2987,10 +2988,10 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) { __compar_fn_t comparator = (pCtx->param[3].i64 == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn; qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator); } - + GET_TRUE_DATA_TYPE(); copyTopBotRes(pCtx, type); - + doFinalizer(pCtx); } @@ -3011,7 +3012,7 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* static void percentile_function(SQLFunctionCtx *pCtx) { int32_t notNullElems = 0; - + SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); SPercentileInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); @@ -3021,7 +3022,7 @@ static void percentile_function(SQLFunctionCtx *pCtx) { // all data are null, set it completed if (pInfo->numOfElems == 0) { pResInfo->complete = true; - + return; } else { pInfo->pMemBucket = tMemBucketCreate(pCtx->inputBytes, pCtx->inputType, pInfo->minval, pInfo->maxval); @@ -3085,18 +3086,18 @@ static void percentile_function(SQLFunctionCtx *pCtx) { if (pCtx->hasNull && isNull(data, pCtx->inputType)) { continue; } - + notNullElems += 1; tMemBucketPut(pInfo->pMemBucket, data, 1); } - + SET_VAL(pCtx, notNullElems, 1); pResInfo->hasResult = DATA_SET_FLAG; } static void percentile_finalizer(SQLFunctionCtx *pCtx) { double v = pCtx->param[0].nType == TSDB_DATA_TYPE_INT ? pCtx->param[0].i64 : pCtx->param[0].dKey; - + SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); SPercentileInfo* ppInfo = (SPercentileInfo *) GET_ROWCELL_INTERBUF(pResInfo); @@ -3108,7 +3109,7 @@ static void percentile_finalizer(SQLFunctionCtx *pCtx) { } else { SET_DOUBLE_VAL((double *)pCtx->pOutput, getPercentile(pMemBucket, v)); } - + tMemBucketDestroy(pMemBucket); doFinalizer(pCtx); } @@ -3128,7 +3129,7 @@ static bool tdigest_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo *pResultInfo) if (!function_setup(pCtx, pResultInfo)) { return false; } - + // new TDigest SAPercentileInfo *pInfo = getOutputInfo(pCtx); char *tmp = (char *)pInfo + sizeof(SAPercentileInfo); @@ -3155,7 +3156,7 @@ static void tdigest_do(SQLFunctionCtx *pCtx) { } notNullElems += 1; - double v = 0; // value + double v = 0; // value long long w = 1; // weigth GET_TYPED_DATA(v, double, pCtx->inputType, data); tdigestAdd(pAPerc->pTDigest, v, w); @@ -3189,7 +3190,7 @@ static void tdigest_merge(SQLFunctionCtx *pCtx) { } else { tdigestMerge(pOutput->pTDigest, pInput->pTDigest); } - + SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; SET_VAL(pCtx, 1, 1); @@ -3242,10 +3243,10 @@ static bool apercentile_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* if (!function_setup(pCtx, pResultInfo)) { return false; } - + SAPercentileInfo *pInfo = getOutputInfo(pCtx); buildHistogramInfo(pInfo); - + char *tmp = (char *)pInfo + sizeof(SAPercentileInfo); pInfo->pHisto = tHistogramCreateFrom(tmp, MAX_HISTOGRAM_BIN); return true; @@ -3258,32 +3259,32 @@ static void apercentile_function(SQLFunctionCtx *pCtx) { } int32_t notNullElems = 0; - + SResultRowCellInfo * pResInfo = GET_RES_INFO(pCtx); SAPercentileInfo *pInfo = getOutputInfo(pCtx); buildHistogramInfo(pInfo); assert(pInfo->pHisto->elems != NULL); - + for (int32_t i = 0; i < pCtx->size; ++i) { char *data = GET_INPUT_DATA(pCtx, i); if (pCtx->hasNull && isNull(data, pCtx->inputType)) { continue; } - + notNullElems += 1; double v = 0; GET_TYPED_DATA(v, double, pCtx->inputType, data); tHistogramAdd(&pInfo->pHisto, v); } - + if (!pCtx->hasNull) { assert(pCtx->size == notNullElems); } - + SET_VAL(pCtx, notNullElems, 1); - + if (notNullElems > 0) { pResInfo->hasResult = DATA_SET_FLAG; } @@ -3296,23 +3297,23 @@ static void apercentile_func_merge(SQLFunctionCtx *pCtx) { } SAPercentileInfo *pInput = (SAPercentileInfo *)GET_INPUT_DATA_LIST(pCtx); - + pInput->pHisto = (SHistogramInfo*) ((char *)pInput + sizeof(SAPercentileInfo)); pInput->pHisto->elems = (SHistBin*) ((char *)pInput->pHisto + sizeof(SHistogramInfo)); if (pInput->pHisto->numOfElems <= 0) { return; } - + SAPercentileInfo *pOutput = getOutputInfo(pCtx); buildHistogramInfo(pOutput); SHistogramInfo *pHisto = pOutput->pHisto; - + if (pHisto->numOfElems <= 0) { memcpy(pHisto, pInput->pHisto, sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1)); pHisto->elems = (SHistBin*) ((char *)pHisto + sizeof(SHistogramInfo)); } else { - //TODO(dengyihao): avoid memcpy + //TODO(dengyihao): avoid memcpy pHisto->elems = (SHistBin*) ((char *)pHisto + sizeof(SHistogramInfo)); SHistogramInfo *pRes = tHistogramMerge(pHisto, pInput->pHisto, MAX_HISTOGRAM_BIN); memcpy(pHisto, pRes, sizeof(SHistogramInfo) + sizeof(SHistBin) * MAX_HISTOGRAM_BIN); @@ -3332,17 +3333,17 @@ static void apercentile_finalizer(SQLFunctionCtx *pCtx) { } double v = (pCtx->param[0].nType == TSDB_DATA_TYPE_INT) ? pCtx->param[0].i64 : pCtx->param[0].dKey; - + SResultRowCellInfo * pResInfo = GET_RES_INFO(pCtx); SAPercentileInfo *pOutput = GET_ROWCELL_INTERBUF(pResInfo); if (pCtx->currentStage == MERGE_STAGE) { if (pResInfo->hasResult == DATA_SET_FLAG) { // check for null assert(pOutput->pHisto->numOfElems > 0); - + double ratio[] = {v}; double *res = tHistogramUniform(pOutput->pHisto, ratio, 1); - + memcpy(pCtx->pOutput, res, sizeof(double)); free(res); } else { @@ -3352,7 +3353,7 @@ static void apercentile_finalizer(SQLFunctionCtx *pCtx) { } else { if (pOutput->pHisto->numOfElems > 0) { double ratio[] = {v}; - + double *res = tHistogramUniform(pOutput->pHisto, ratio, 1); memcpy(pCtx->pOutput, res, sizeof(double)); free(res); @@ -3361,7 +3362,7 @@ static void apercentile_finalizer(SQLFunctionCtx *pCtx) { return; } } - + doFinalizer(pCtx); } @@ -3372,7 +3373,7 @@ static bool leastsquares_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo } SLeastsquaresInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); - + // 2*3 matrix pInfo->startVal = pCtx->param[0].dKey; return true; @@ -3399,12 +3400,12 @@ static bool leastsquares_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo static void leastsquares_function(SQLFunctionCtx *pCtx) { SResultRowCellInfo * pResInfo = GET_RES_INFO(pCtx); SLeastsquaresInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); - + double(*param)[3] = pInfo->mat; double x = pInfo->startVal; - + void *pData = GET_INPUT_DATA_LIST(pCtx); - + int32_t numOfElem = 0; switch (pCtx->inputType) { case TSDB_DATA_TYPE_INT: { @@ -3414,12 +3415,12 @@ static void leastsquares_function(SQLFunctionCtx *pCtx) { if (pCtx->hasNull && isNull((const char*) p, pCtx->inputType)) { continue; } - + param[0][0] += x * x; param[0][1] += x; param[0][2] += x * p[i]; param[1][2] += p[i]; - + x += pCtx->param[1].dKey; numOfElem++; } @@ -3471,14 +3472,14 @@ static void leastsquares_function(SQLFunctionCtx *pCtx) { break; } } - + pInfo->startVal = x; pInfo->num += numOfElem; - + if (pInfo->num > 0) { pResInfo->hasResult = DATA_SET_FLAG; } - + SET_VAL(pCtx, numOfElem, 1); } @@ -3486,30 +3487,30 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) { // no data in query SResultRowCellInfo * pResInfo = GET_RES_INFO(pCtx); SLeastsquaresInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); - + if (pInfo->num == 0) { setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); return; } - + double(*param)[3] = pInfo->mat; - + param[1][1] = (double)pInfo->num; param[1][0] = param[0][1]; - + param[0][0] -= param[1][0] * (param[0][1] / param[1][1]); param[0][2] -= param[1][2] * (param[0][1] / param[1][1]); param[0][1] = 0; param[1][2] -= param[0][2] * (param[1][0] / param[0][0]); param[1][0] = 0; param[0][2] /= param[0][0]; - + param[1][2] /= param[1][1]; - + int32_t maxOutputSize = TSDB_AVG_FUNCTION_INTER_BUFFER_SIZE - VARSTR_HEADER_SIZE; size_t n = snprintf(varDataVal(pCtx->pOutput), maxOutputSize, "{slop:%.6lf, intercept:%.6lf}", param[0][2], param[1][2]); - + varDataSetLen(pCtx->pOutput, n); doFinalizer(pCtx); } @@ -3562,7 +3563,7 @@ static void col_project_function(SQLFunctionCtx *pCtx) { */ static void tag_project_function(SQLFunctionCtx *pCtx) { INC_INIT_VAL(pCtx, pCtx->size); - + assert(pCtx->inputBytes == pCtx->outputBytes); tVariantDump(&pCtx->tag, pCtx->pOutput, pCtx->outputType, true); @@ -3597,7 +3598,7 @@ static void tag_function(SQLFunctionCtx *pCtx) { static void copy_function(SQLFunctionCtx *pCtx) { SET_VAL(pCtx, pCtx->size, 1); - + char *pData = GET_INPUT_DATA_LIST(pCtx); assignVal(pCtx->pOutput, pData, pCtx->inputBytes, pCtx->inputType); } @@ -3668,7 +3669,7 @@ static void row_copy_function(SQLFunctionCtx *pCtx) { static void full_copy_function(SQLFunctionCtx *pCtx) { copy_function(pCtx); - + for (int t = 0; t < pCtx->tagInfo.numOfTagCols; ++t) { SQLFunctionCtx* tagCtx = pCtx->tagInfo.pTagCtxList[t]; if (tagCtx->functionId == TSDB_FUNC_TAG_DUMMY) { @@ -3682,7 +3683,7 @@ static bool diff_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResIn if (!function_setup(pCtx, pResInfo)) { return false; } - + SDiffFuncInfo* pDiffInfo = GET_ROWCELL_INTERBUF(pResInfo); pDiffInfo->valueAssigned = false; pDiffInfo->i64Prev = 0; @@ -3997,10 +3998,10 @@ static void diff_function(SQLFunctionCtx *pCtx) { continue; } - if (pDiffInfo->valueAssigned) { + if (pDiffInfo->valueAssigned) { float diff = (float)(pData[i] - pDiffInfo->d64Prev); if (diff >= 0 || !pDiffInfo->ignoreNegative) { - *pOutput = diff; + *pOutput = diff; *pTimestamp = (tsList != NULL)? tsList[i]:0; pOutput += 1; pTimestamp += 1; @@ -4084,7 +4085,7 @@ static void diff_function(SQLFunctionCtx *pCtx) { char *getScalarExprColumnData(void *param, const char* name, int32_t colId) { SScalarExprSupport *pSupport = (SScalarExprSupport *)param; - + int32_t idx = -1; for (int32_t i = 0; i < pSupport->numOfCols; ++i) { if (colId == pSupport->colList[i].colId) { @@ -4092,7 +4093,7 @@ char *getScalarExprColumnData(void *param, const char* name, int32_t colId) { break; } } - + assert(idx >= 0); return pSupport->data[idx] + pSupport->offset * pSupport->colList[idx].bytes; } @@ -4127,9 +4128,9 @@ static bool spread_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pRes if (!function_setup(pCtx, pResInfo)) { return false; } - + SSpreadInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); - + // this is the server-side setup function in client-side, the secondary merge do not need this procedure if (pCtx->currentStage == MERGE_STAGE) { pCtx->param[0].dKey = DBL_MAX; @@ -4138,21 +4139,21 @@ static bool spread_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pRes pInfo->min = DBL_MAX; pInfo->max = -DBL_MAX; } - + return true; } static void spread_function(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); SSpreadInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); - + int32_t numOfElems = 0; // todo : opt with pre-calculated result // column missing cause the hasNull to be true if (pCtx->preAggVals.isSet) { numOfElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; - + // all data are null in current data block, ignore current data block if (numOfElems == 0) { goto _spread_over; @@ -4171,18 +4172,18 @@ static void spread_function(SQLFunctionCtx *pCtx) { if (pInfo->min > GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.min))) { pInfo->min = GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.min)); } - + if (pInfo->max < GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.max))) { pInfo->max = GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.max)); } } - + goto _spread_over; } - + void *pData = GET_INPUT_DATA_LIST(pCtx); numOfElems = 0; - + if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) { LIST_MINMAX_N(pCtx, pInfo->min, pInfo->max, pCtx->size, pData, int8_t, pCtx->inputType, numOfElems); } else if (pCtx->inputType == TSDB_DATA_TYPE_SMALLINT) { @@ -4204,19 +4205,19 @@ static void spread_function(SQLFunctionCtx *pCtx) { } else if (pCtx->inputType == TSDB_DATA_TYPE_UBIGINT) { LIST_MINMAX_N(pCtx, pInfo->min, pInfo->max, pCtx->size, pData, uint64_t, pCtx->inputType, numOfElems); } - + if (!pCtx->hasNull) { assert(pCtx->size == numOfElems); } - + _spread_over: SET_VAL(pCtx, numOfElems, 1); - + if (numOfElems > 0) { pResInfo->hasResult = DATA_SET_FLAG; pInfo->hasResult = DATA_SET_FLAG; } - + // keep the data into the final output buffer for super table query since this execution may be the last one if (pCtx->stableQuery) { memcpy(pCtx->pOutput, GET_ROWCELL_INTERBUF(pResInfo), sizeof(SSpreadInfo)); @@ -4232,15 +4233,15 @@ void spread_func_merge(SQLFunctionCtx *pCtx) { if (pData->hasResult != DATA_SET_FLAG) { return; } - + if (pCtx->param[0].dKey > pData->min) { pCtx->param[0].dKey = pData->min; } - + if (pCtx->param[3].dKey < pData->max) { pCtx->param[3].dKey = pData->max; } - + GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG; } @@ -4253,25 +4254,25 @@ void spread_function_finalizer(SQLFunctionCtx *pCtx) { if (pCtx->currentStage == MERGE_STAGE) { assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); - + if (pResInfo->hasResult != DATA_SET_FLAG) { setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); return; } - + SET_DOUBLE_VAL((double *)pCtx->pOutput, pCtx->param[3].dKey - pCtx->param[0].dKey); } else { assert(IS_NUMERIC_TYPE(pCtx->inputType) || (pCtx->inputType == TSDB_DATA_TYPE_TIMESTAMP)); - + SSpreadInfo *pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); if (pInfo->hasResult != DATA_SET_FLAG) { setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); return; } - + SET_DOUBLE_VAL((double *)pCtx->pOutput, pInfo->max - pInfo->min); } - + GET_RES_INFO(pCtx)->numOfRes = 1; // todo add test case doFinalizer(pCtx); } @@ -4354,7 +4355,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size SPoint1 st; st.key = tsList[i]; st.val = val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4366,14 +4367,14 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size if (pCtx->hasNull && isNull((const char*) &val[i], pCtx->inputType)) { continue; } - + #ifndef _TD_NINGSI_60 SPoint1 st = {.key = tsList[i], .val = val[i]}; #else SPoint1 st; st.key = tsList[i]; st.val = val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4385,14 +4386,14 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size if (pCtx->hasNull && isNull((const char*) &val[i], pCtx->inputType)) { continue; } - + #ifndef _TD_NINGSI_60 SPoint1 st = {.key = tsList[i], .val = val[i]}; #else SPoint1 st; st.key = tsList[i]; st.val = val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4404,14 +4405,14 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size if (pCtx->hasNull && isNull((const char*) &val[i], pCtx->inputType)) { continue; } - + #ifndef _TD_NINGSI_60 SPoint1 st = {.key = tsList[i], .val = (double) val[i]}; #else SPoint1 st; st.key = tsList[i]; st.val = (double)val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4423,14 +4424,14 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size if (pCtx->hasNull && isNull((const char*) &val[i], pCtx->inputType)) { continue; } - + #ifndef _TD_NINGSI_60 SPoint1 st = {.key = tsList[i], .val = val[i]}; #else SPoint1 st; st.key = tsList[i]; st.val = (double)val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4442,14 +4443,14 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size if (pCtx->hasNull && isNull((const char*) &val[i], pCtx->inputType)) { continue; } - + #ifndef _TD_NINGSI_60 SPoint1 st = {.key = tsList[i], .val = val[i]}; #else SPoint1 st; st.key = tsList[i]; st.val = val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4468,7 +4469,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size SPoint1 st; st.key = tsList[i]; st.val = val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4487,7 +4488,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size SPoint1 st; st.key = tsList[i]; st.val = val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4506,7 +4507,7 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size SPoint1 st; st.key = tsList[i]; st.val = val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4518,14 +4519,14 @@ static int32_t twa_function_impl(SQLFunctionCtx* pCtx, int32_t idx, int32_t size if (pCtx->hasNull && isNull((const char*) &val[i], pCtx->inputType)) { continue; } - + #ifndef _TD_NINGSI_60 SPoint1 st = {.key = tsList[i], .val = (double) val[i]}; #else SPoint1 st; st.key = tsList[i]; st.val = (double) val[i]; -#endif +#endif pInfo->dOutput += twa_get_area(pInfo->p, st); pInfo->p = st; } @@ -4549,7 +4550,7 @@ static void twa_function(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); STwaInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); - + // skip null value int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order); int32_t i = (pCtx->order == TSDB_ORDER_ASC)? 0:(pCtx->size - 1); @@ -4563,11 +4564,11 @@ static void twa_function(SQLFunctionCtx *pCtx) { } SET_VAL(pCtx, notNullElems, 1); - + if (notNullElems > 0) { pResInfo->hasResult = DATA_SET_FLAG; } - + if (pCtx->stableQuery) { memcpy(pCtx->pOutput, pInfo, sizeof(STwaInfo)); } @@ -4581,14 +4582,14 @@ static void twa_function(SQLFunctionCtx *pCtx) { void twa_function_copy(SQLFunctionCtx *pCtx) { assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - + memcpy(GET_ROWCELL_INTERBUF(pResInfo), pCtx->pInput, (size_t)pCtx->inputBytes); pResInfo->hasResult = ((STwaInfo *)pCtx->pInput)->hasResult; } void twa_function_finalizer(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - + STwaInfo *pInfo = (STwaInfo *)GET_ROWCELL_INTERBUF(pResInfo); if (pInfo->hasResult != DATA_SET_FLAG) { setNull(pCtx->pOutput, TSDB_DATA_TYPE_DOUBLE, sizeof(double)); @@ -4601,7 +4602,7 @@ void twa_function_finalizer(SQLFunctionCtx *pCtx) { } else { SET_DOUBLE_VAL((double *)pCtx->pOutput , pInfo->dOutput / (pInfo->win.ekey - pInfo->win.skey)); } - + GET_RES_INFO(pCtx)->numOfRes = 1; doFinalizer(pCtx); } @@ -4612,27 +4613,27 @@ static void interp_function(SQLFunctionCtx *pCtx) { if (pCtx->start.key == pCtx->startTs) { assert(pCtx->start.key != INT64_MIN); - + COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->start.val); - - goto interp_success_exit; + + goto interp_success_exit; } else if (pCtx->end.key == pCtx->startTs && pCtx->end.key != INT64_MIN && fillType == TSDB_FILL_NEXT) { COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->end.val); - - goto interp_success_exit; + + goto interp_success_exit; } switch (fillType) { case TSDB_FILL_NULL: setNull(pCtx->pOutput, pCtx->outputType, pCtx->outputBytes); break; - + case TSDB_FILL_SET_VALUE: tVariantDump(&pCtx->param[1], pCtx->pOutput, pCtx->inputType, true); break; - + case TSDB_FILL_LINEAR: - if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs + if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs || pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) { goto interp_exit; } @@ -4640,7 +4641,7 @@ static void interp_function(SQLFunctionCtx *pCtx) { double v1 = -1, v2 = -1; GET_TYPED_DATA(v1, double, pCtx->inputType, &pCtx->start.val); GET_TYPED_DATA(v2, double, pCtx->inputType, &pCtx->end.val); - + SPoint point1 = {.key = pCtx->start.key, .val = &v1}; SPoint point2 = {.key = pCtx->end.key, .val = &v2}; SPoint point = {.key = pCtx->startTs, .val = pCtx->pOutput}; @@ -4653,7 +4654,7 @@ static void interp_function(SQLFunctionCtx *pCtx) { taosGetLinearInterpolationVal(&point, pCtx->outputType, &point1, &point2, TSDB_DATA_TYPE_DOUBLE, &exceedMax, &exceedMin); if (exceedMax || exceedMin) { __compar_fn_t func = getComparFunc((int32_t)pCtx->inputType, 0); - if (func(&pCtx->start.val, &pCtx->end.val) <= 0) { + if (func(&pCtx->start.val, &pCtx->end.val) <= 0) { COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->start.val : &pCtx->end.val); } else { COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->end.val : &pCtx->start.val); @@ -4674,7 +4675,7 @@ static void interp_function(SQLFunctionCtx *pCtx) { if (pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) { goto interp_exit; } - + COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, &pCtx->end.val); break; @@ -4684,7 +4685,7 @@ static void interp_function(SQLFunctionCtx *pCtx) { } -interp_success_exit: +interp_success_exit: *(TSKEY*)pCtx->ptsOutputBuf = pCtx->startTs; @@ -4713,9 +4714,9 @@ static bool ts_comp_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pRe static void ts_comp_function(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); STSBuf * pTSbuf = ((STSCompInfo *)(GET_ROWCELL_INTERBUF(pResInfo)))->pTSBuf; - + const char *input = GET_INPUT_DATA_LIST(pCtx); - + // primary ts must be existed, so no need to check its existance if (pCtx->order == TSDB_ORDER_ASC) { tsBufAppend(pTSbuf, (int32_t)pCtx->param[0].i64, &pCtx->tag, input, pCtx->size * TSDB_KEYSIZE); @@ -4725,17 +4726,17 @@ static void ts_comp_function(SQLFunctionCtx *pCtx) { tsBufAppend(pTSbuf, (int32_t)pCtx->param[0].i64, &pCtx->tag, d, (int32_t)TSDB_KEYSIZE); } } - + SET_VAL(pCtx, pCtx->size, 1); pResInfo->hasResult = DATA_SET_FLAG; } static void ts_comp_finalize(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - + STSCompInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); STSBuf * pTSbuf = pInfo->pTSBuf; - + tsBufFlush(pTSbuf); qDebug("total timestamp :%"PRId64, pTSbuf->numOfTotal); @@ -4778,7 +4779,7 @@ static double do_calc_rate(const SRateInfo* pRateInfo, double tickPerSec) { return 0; } } - + int64_t duration = pRateInfo->lastKey - pRateInfo->firstKey; if (duration == 0) { return 0; @@ -4791,7 +4792,7 @@ static bool rate_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResIn if (!function_setup(pCtx, pResInfo)) { return false; } - + SRateInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo); pInfo->correctionValue = 0; pInfo->firstKey = INT64_MIN; @@ -4806,51 +4807,51 @@ static bool rate_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResIn static void rate_function(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); - + int32_t notNullElems = 0; SRateInfo *pRateInfo = (SRateInfo *)GET_ROWCELL_INTERBUF(pResInfo); TSKEY *primaryKey = GET_TS_LIST(pCtx); - + qDebug("%p rate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull); - + for (int32_t i = 0; i < pCtx->size; ++i) { char *pData = GET_INPUT_DATA(pCtx, i); if (pCtx->hasNull && isNull(pData, pCtx->inputType)) { qDebug("%p rate_function() index of null data:%d", pCtx, i); continue; } - + notNullElems++; - + double v = 0; GET_TYPED_DATA(v, double, pCtx->inputType, pData); - + if ((INT64_MIN == pRateInfo->firstValue) || (INT64_MIN == pRateInfo->firstKey)) { pRateInfo->firstValue = v; pRateInfo->firstKey = primaryKey[i]; } - + if (INT64_MIN == pRateInfo->lastValue) { pRateInfo->lastValue = v; } else if (v < pRateInfo->lastValue) { pRateInfo->correctionValue += pRateInfo->lastValue; } - + pRateInfo->lastValue = v; pRateInfo->lastKey = primaryKey[i]; } - + if (!pCtx->hasNull) { assert(pCtx->size == notNullElems); } - + SET_VAL(pCtx, notNullElems, 1); - + if (notNullElems > 0) { pRateInfo->hasResult = DATA_SET_FLAG; pResInfo->hasResult = DATA_SET_FLAG; } - + // keep the data into the final output buffer for super table query since this execution may be the last one if (pCtx->stableQuery) { memcpy(pCtx->pOutput, GET_ROWCELL_INTERBUF(pResInfo), sizeof(SRateInfo)); @@ -4859,7 +4860,7 @@ static void rate_function(SQLFunctionCtx *pCtx) { static void rate_func_copy(SQLFunctionCtx *pCtx) { assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); - + SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); memcpy(GET_ROWCELL_INTERBUF(pResInfo), pCtx->pInput, (size_t)pCtx->inputBytes); pResInfo->hasResult = ((SRateInfo*)pCtx->pInput)->hasResult; @@ -4873,13 +4874,13 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) { setNull(pCtx->pOutput, TSDB_DATA_TYPE_DOUBLE, sizeof(double)); return; } - + SET_DOUBLE_VAL((double*) pCtx->pOutput, do_calc_rate(pRateInfo, (double) TSDB_TICK_PER_SECOND(pCtx->param[0].i64))); // cannot set the numOfIteratedElems again since it is set during previous iteration pResInfo->numOfRes = 1; pResInfo->hasResult = DATA_SET_FLAG; - + doFinalizer(pCtx); } @@ -4895,9 +4896,9 @@ static void irate_function(SQLFunctionCtx *pCtx) { if (pCtx->hasNull && isNull(pData, pCtx->inputType)) { continue; } - + notNullElems++; - + double v = 0; GET_TYPED_DATA(v, double, pCtx->inputType, pData); @@ -4915,24 +4916,24 @@ static void irate_function(SQLFunctionCtx *pCtx) { pRateInfo->lastValue = v; pRateInfo->lastKey = primaryKey[i]; - + continue; } - + if ((INT64_MIN == pRateInfo->firstKey) || primaryKey[i] > pRateInfo->firstKey) { pRateInfo->firstValue = v; pRateInfo->firstKey = primaryKey[i]; break; } } - + SET_VAL(pCtx, notNullElems, 1); - + if (notNullElems > 0) { pRateInfo->hasResult = DATA_SET_FLAG; pResInfo->hasResult = DATA_SET_FLAG; } - + // keep the data into the final output buffer for super table query since this execution may be the last one if (pCtx->stableQuery) { memcpy(pCtx->pOutput, GET_ROWCELL_INTERBUF(pResInfo), sizeof(SRateInfo)); @@ -5508,7 +5509,7 @@ static void elapsedFunction(SQLFunctionCtx *pCtx) { elapsedOver: SET_VAL(pCtx, pCtx->size, 1); - + if (pCtx->size > 0) { GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG; pInfo->hasResult = DATA_SET_FLAG; @@ -5901,16 +5902,21 @@ static void mode_func_finalizer(SQLFunctionCtx *pCtx) { int32_t type = 0; if (pCtx->currentStage == MERGE_STAGE) { bytes = pCtx->outputBytes; - type = pCtx->outputType; + type = pCtx->outputType; assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); } else { bytes = pCtx->inputBytes; - type = pCtx->inputType; + type = pCtx->inputType; } SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); SModeFuncInfo *pRes = GET_ROWCELL_INTERBUF(pResInfo); + if (pRes->num == 0) { + setNull(pCtx->pOutput, type, 0); + goto _mode_over; + } + size_t size = sizeof(ModeUnit) + bytes; char *tvp = pRes->res; @@ -5918,20 +5924,18 @@ static void mode_func_finalizer(SQLFunctionCtx *pCtx) { int64_t maxCount = 0; for (int32_t i = 0; i < pRes->num; ++i) { int64_t count = ((ModeUnit*)tvp)->count; - if (count > maxCount){ + if (count >= maxCount){ maxCount = count; result = tvp; - }else if(count == maxCount){ - result = NULL; } + tvp += size; } - if (result){ - memcpy(pCtx->pOutput, result + sizeof(ModeUnit), bytes); - }else{ - setNull(pCtx->pOutput, type, 0); - } + memcpy(pCtx->pOutput, result + sizeof(ModeUnit), bytes); + +_mode_over: + pResInfo->numOfRes = 1; doFinalizer(pCtx); } diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index e7885b98994bb82303cd3ee424f4062f3b8507f4..2efdbcc99a1bd330f9dc5d6314404d212d8194dd 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -318,10 +318,10 @@ static int32_t getColDataFromGroupRes(SGroupResInfo* pGroupResInfo, SQueryRuntim for (int32_t i = 0; i < numRows; ++i) { SResultRow* row = taosArrayGetP(pGroupResInfo->pRows, i); row->groupIndex = i; - tFilePage* page = getResBufPage(pRuntimeEnv->pResultBuf, row->pageId); - int32_t rowsToCopy = 1; - char* out = colData + numOfResult * colBytes; - char* in = getPosInResultPage(pRuntimeEnv->pQueryAttr, page, row->offset, colDataOffset); + tFilePage* page = getResBufPage(pRuntimeEnv->pResultBuf, row->pageId); + int32_t rowsToCopy = 1; + char* out = colData + numOfResult * colBytes; + char* in = getPosInResultPage(pRuntimeEnv->pQueryAttr, page, row->offset, colDataOffset); memcpy(out, in, colBytes * rowsToCopy); numOfResult += rowsToCopy; } @@ -2837,6 +2837,10 @@ static bool isCachedLastQuery(SQueryAttr* pQueryAttr) { return false; } + if (pQueryAttr->pFilters != NULL || pQueryAttr->pFilterInfo != NULL) { + return false; + } + return true; } @@ -3165,7 +3169,7 @@ static bool overlapWithTimeWindow(SQueryAttr* pQueryAttr, SDataBlockInfo* pBlock return true; } - while(w.skey < pBlockInfo->window.ekey) { + while (w.skey < pBlockInfo->window.ekey) { // add one slding if (pQueryAttr->interval.slidingUnit == 'n' || pQueryAttr->interval.slidingUnit == 'y') ekey = taosTimeAdd(ekey, pQueryAttr->interval.sliding, pQueryAttr->interval.slidingUnit, pQueryAttr->precision); @@ -3180,7 +3184,7 @@ static bool overlapWithTimeWindow(SQueryAttr* pQueryAttr, SDataBlockInfo* pBlock getAlignQueryTimeWindow(pQueryAttr, ekey, sk, ek, &w); } - while(1) { + while (1) { if (w.ekey < pBlockInfo->window.skey) { break; } @@ -6339,7 +6343,7 @@ SOperatorInfo* createOrderOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI SColumnInfoData col = {{0}}; col.info.colId = pExpr[i].base.colInfo.colId; col.info.bytes = pExpr[i].base.resBytes; - col.info.type = pExpr[i].base.resType; + col.info.type = pExpr[i].base.resType; taosArrayPush(pDataBlock->pDataBlock, &col); if (!found && col.info.colId == pOrderVal->orderColId) { @@ -6625,7 +6629,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) { } copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput); clearNumOfRes(pInfo->pCtx, pOperator->numOfOutput); - return (pInfo->pRes->info.rows > 0) ? pInfo->pRes : NULL; + return pInfo->pRes; } static SSDataBlock* doLimit(void* param, bool* newgroup) { @@ -6874,18 +6878,18 @@ static bool doEveryInterpolation(SOperatorInfo* pOperatorInfo, SSDataBlock* pBlo break; } } - + if (pCtx == NULL) { goto group_finished_exit; } - + TSKEY* tsCols = NULL; if (pBlock && pBlock->pDataBlock != NULL) { SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, 0); tsCols = (int64_t*)pColDataInfo->pData; assert(tsCols[0] == pBlock->info.window.skey && tsCols[pBlock->info.rows - 1] == pBlock->info.window.ekey); } - + if (pCtx->startTs == INT64_MIN) { if (pQueryAttr->range.skey == INT64_MIN) { if (NULL == tsCols) { @@ -6984,7 +6988,7 @@ static bool doEveryInterpolation(SOperatorInfo* pOperatorInfo, SSDataBlock* pBlo return false; } int32_t nRows = pBlock ? pBlock->info.rows : 0; - int32_t startPos = binarySearchForKey((char*) tsCols, nRows, pCtx->startTs, pQueryAttr->order.order); + int32_t startPos = binarySearchForKey((char*)tsCols, nRows, pCtx->startTs, pQueryAttr->order.order); if (ascQuery && pQueryAttr->fillType != TSDB_FILL_NEXT && pCtx->start.key == INT64_MIN) { if (startPos < 0) { @@ -8522,18 +8526,18 @@ SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator SColIndex* idx = taosArrayGet(pInfo->orderColumnList, i); offset += pExpr[idx->colIndex].base.resBytes; } - + SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); if (pOperator == NULL) { goto _clean; } - + pInfo->pRes = createOutputBuf(pExpr, numOfOutput, pRuntimeEnv->resultInfo.capacity); if (pInfo->pRes == NULL) { tfree(pOperator); goto _clean; } - + pOperator->name = "SLimitOperator"; pOperator->operatorType = OP_SLimit; pOperator->blockingOptr = false; @@ -10172,7 +10176,8 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S pTableqinfo->pGroupList = taosArrayInit(numOfGroups, POINTER_BYTES); pTableqinfo->numOfTables = pTableGroupInfo->numOfTables; - pTableqinfo->map = taosHashInit(pTableGroupInfo->numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); + pTableqinfo->map = taosHashInit(pTableGroupInfo->numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, + HASH_ENTRY_LOCK); } pQInfo->pBuf = calloc(pTableGroupInfo->numOfTables, sizeof(STableQueryInfo)); @@ -10374,7 +10379,7 @@ static void doDestroyTableQueryInfo(STableGroupInfo* pTableqinfoGroupInfo) { taosArrayDestroy(&pTableqinfoGroupInfo->pGroupList); - SHashObj *pmap = pTableqinfoGroupInfo->map; + SHashObj* pmap = pTableqinfoGroupInfo->map; if (pmap == atomic_val_compare_exchange_ptr(&pTableqinfoGroupInfo->map, pmap, NULL)) { taosHashCleanup(pmap); } diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index 7187637b705a0adb39b1da08a90989964139c746..cb89649c3cc93f00021bd9a1c747d44b5e699a23 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -338,6 +338,45 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex return code; } +bool qFitAlwaysValue(SQInfo * pQInfo) { + // must agg query + if (!pQInfo->query.simpleAgg) + return false; + + // must not include ts column + SSDataBlock* pBlock = pQInfo->runtimeEnv.outputBuf; + if (pBlock == NULL || pBlock->pDataBlock == NULL) + return false; + + SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, 0); + if (pColInfoData == NULL) + return false; + // must not first column is timestamp + if (pColInfoData->info.type == TSDB_DATA_TYPE_TIMESTAMP) + return false; + + // fit ok + return true; +} + +bool doFillResultWithNull(SQInfo* pQInfo, char * data, size_t numOfRows) { + SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv; + SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; + SSDataBlock* pRes = pRuntimeEnv->outputBuf; + + int32_t numOfCols = pQueryAttr->numOfOutput; + for (int32_t i = 0; i < numOfCols; ++i) { + int16_t functionId = pQueryAttr->pExpr1[i].base.functionId; + // col + SColumnInfoData* pCol = taosArrayGet(pRes->pDataBlock, i); + if (functionId != TSDB_FUNC_COUNT) + setNull(data, pCol->info.type, pCol->info.bytes); + data += pCol->info.bytes * numOfRows; + } + + return true; +} + int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *contLen, bool* continueExec) { SQInfo *pQInfo = (SQInfo *)qinfo; int32_t compLen = 0; @@ -350,6 +389,14 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv; int32_t s = GET_NUM_OF_RESULTS(pRuntimeEnv); + bool fillNull = false; + if (s == 0 && tsAggAlways) { + if (qFitAlwaysValue(pQInfo)) { + s = 1; + fillNull = true; + } + } + size_t size = pQueryAttr->resultRowSize * s; size += sizeof(int32_t); size += sizeof(STableIdInfo) * taosHashGetSize(pRuntimeEnv->pTableRetrieveTsMap); @@ -378,6 +425,9 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co if (GET_NUM_OF_RESULTS(&(pQInfo->runtimeEnv)) > 0 && pQInfo->code == TSDB_CODE_SUCCESS) { doDumpQueryResult(pQInfo, (*pRsp)->data, (*pRsp)->compressed, &compLen); } else { + if (fillNull) { + doFillResultWithNull(pQInfo, (*pRsp)->data, 1); + } setQueryStatus(pRuntimeEnv, QUERY_OVER); } diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 2ae20c7ae52cd6ce9bafcdebbef97cc578f53116..3beae806b06674a966fa6361d1bd115f24d3dcd0 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -76,8 +76,10 @@ ** 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. @@ -97,51 +99,59 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 294 +#define YYNOCODE 292 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SLimitVal yy24; - SCreateTableSql* yy74; - SCreatedTableInfo yy110; - SWindowStateVal yy204; - SRangeVal yy214; - int yy274; - TAOS_FIELD yy307; - SArray* yy367; - SSessionWindowVal yy373; - tSqlExpr* yy378; - tVariant yy410; - SSqlNode* yy426; - int64_t yy443; - SIntervalVal yy478; - SRelationInfo* yy480; - SCreateAcctInfo yy563; - SCreateDbInfo yy564; - int32_t yy586; + tVariant yy42; + int32_t yy44; + SCreateTableSql* yy78; + SRangeVal yy132; + int yy133; + SSqlNode* yy144; + SLimitVal yy190; + tSqlExpr* yy194; + SIntervalVal yy200; + SSessionWindowVal yy235; + SWindowStateVal yy248; + TAOS_FIELD yy263; + int64_t yy277; + SCreateAcctInfo yy299; + SArray* yy333; + SCreateDbInfo yy342; + SCreatedTableInfo yy400; + SRelationInfo* yy516; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define ParseARG_SDECL SSqlInfo* pInfo; #define ParseARG_PDECL ,SSqlInfo* pInfo -#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo -#define ParseARG_STORE yypParser->pInfo = 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 YYFALLBACK 1 #define YYNSTATE 417 -#define YYNRULE 329 +#define YYNRULE 330 +#define YYNRULE_WITH_ACTION 330 #define YYNTOKEN 206 #define YY_MAX_SHIFT 416 -#define YY_MIN_SHIFTREDUCE 647 -#define YY_MAX_SHIFTREDUCE 975 -#define YY_ERROR_ACTION 976 -#define YY_ACCEPT_ACTION 977 -#define YY_NO_ACTION 978 -#define YY_MIN_REDUCE 979 -#define YY_MAX_REDUCE 1307 +#define YY_MIN_SHIFTREDUCE 648 +#define YY_MAX_SHIFTREDUCE 977 +#define YY_ERROR_ACTION 978 +#define YY_ACCEPT_ACTION 979 +#define YY_NO_ACTION 980 +#define YY_MIN_REDUCE 981 +#define YY_MAX_REDUCE 1310 /************* 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. @@ -206,336 +216,339 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (930) +#define YY_ACTTAB_COUNT (942) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 230, 699, 1139, 175, 1216, 65, 1217, 332, 699, 700, - /* 10 */ 1280, 270, 1282, 1164, 43, 44, 700, 47, 48, 415, - /* 20 */ 261, 283, 32, 31, 30, 736, 65, 46, 366, 51, + /* 0 */ 230, 700, 1142, 175, 1219, 65, 1220, 332, 700, 701, + /* 10 */ 1283, 270, 1285, 1167, 43, 44, 701, 47, 48, 415, + /* 20 */ 261, 283, 32, 31, 30, 737, 65, 46, 365, 51, /* 30 */ 49, 52, 50, 37, 36, 35, 34, 33, 42, 41, - /* 40 */ 268, 24, 40, 39, 38, 43, 44, 1140, 47, 48, - /* 50 */ 263, 1280, 283, 32, 31, 30, 314, 1137, 46, 366, + /* 40 */ 268, 24, 40, 39, 38, 43, 44, 1143, 47, 48, + /* 50 */ 263, 1283, 283, 32, 31, 30, 314, 1140, 46, 365, /* 60 */ 51, 49, 52, 50, 37, 36, 35, 34, 33, 42, - /* 70 */ 41, 273, 228, 40, 39, 38, 313, 312, 1137, 275, - /* 80 */ 43, 44, 1280, 47, 48, 1161, 1140, 283, 32, 31, - /* 90 */ 30, 362, 95, 46, 366, 51, 49, 52, 50, 37, - /* 100 */ 36, 35, 34, 33, 42, 41, 229, 1270, 40, 39, - /* 110 */ 38, 43, 44, 401, 47, 48, 1280, 1280, 283, 32, - /* 120 */ 31, 30, 1122, 64, 46, 366, 51, 49, 52, 50, - /* 130 */ 37, 36, 35, 34, 33, 42, 41, 1302, 234, 40, - /* 140 */ 39, 38, 277, 43, 45, 784, 47, 48, 1280, 1140, - /* 150 */ 283, 32, 31, 30, 65, 898, 46, 366, 51, 49, - /* 160 */ 52, 50, 37, 36, 35, 34, 33, 42, 41, 858, - /* 170 */ 859, 40, 39, 38, 44, 298, 47, 48, 391, 390, - /* 180 */ 283, 32, 31, 30, 302, 301, 46, 366, 51, 49, - /* 190 */ 52, 50, 37, 36, 35, 34, 33, 42, 41, 699, - /* 200 */ 141, 40, 39, 38, 47, 48, 1136, 700, 283, 32, - /* 210 */ 31, 30, 362, 401, 46, 366, 51, 49, 52, 50, - /* 220 */ 37, 36, 35, 34, 33, 42, 41, 371, 190, 40, - /* 230 */ 39, 38, 73, 360, 408, 407, 359, 358, 357, 406, - /* 240 */ 356, 355, 354, 405, 353, 404, 403, 322, 648, 649, - /* 250 */ 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, - /* 260 */ 660, 661, 169, 101, 262, 1098, 1086, 1087, 1088, 1089, - /* 270 */ 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1099, 1100, + /* 70 */ 41, 273, 228, 40, 39, 38, 313, 312, 1140, 275, + /* 80 */ 43, 44, 1283, 47, 48, 1164, 1143, 283, 32, 31, + /* 90 */ 30, 361, 95, 46, 365, 51, 49, 52, 50, 37, + /* 100 */ 36, 35, 34, 33, 42, 41, 229, 1273, 40, 39, + /* 110 */ 38, 43, 44, 400, 47, 48, 1283, 1283, 283, 32, + /* 120 */ 31, 30, 1125, 64, 46, 365, 51, 49, 52, 50, + /* 130 */ 37, 36, 35, 34, 33, 42, 41, 1305, 234, 40, + /* 140 */ 39, 38, 277, 43, 45, 786, 47, 48, 1283, 1143, + /* 150 */ 283, 32, 31, 30, 65, 900, 46, 365, 51, 49, + /* 160 */ 52, 50, 37, 36, 35, 34, 33, 42, 41, 860, + /* 170 */ 861, 40, 39, 38, 44, 298, 47, 48, 390, 389, + /* 180 */ 283, 32, 31, 30, 302, 301, 46, 365, 51, 49, + /* 190 */ 52, 50, 37, 36, 35, 34, 33, 42, 41, 700, + /* 200 */ 141, 40, 39, 38, 47, 48, 1139, 701, 283, 32, + /* 210 */ 31, 30, 361, 400, 46, 365, 51, 49, 52, 50, + /* 220 */ 37, 36, 35, 34, 33, 42, 41, 115, 190, 40, + /* 230 */ 39, 38, 73, 359, 408, 407, 358, 406, 357, 405, + /* 240 */ 356, 355, 354, 404, 353, 403, 402, 322, 649, 650, + /* 250 */ 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, + /* 260 */ 661, 662, 169, 1127, 262, 1100, 1088, 1089, 1090, 1091, + /* 270 */ 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1101, 1102, /* 280 */ 25, 51, 49, 52, 50, 37, 36, 35, 34, 33, - /* 290 */ 42, 41, 115, 699, 40, 39, 38, 244, 235, 254, - /* 300 */ 914, 700, 74, 902, 246, 905, 281, 908, 1280, 1028, - /* 310 */ 156, 155, 154, 245, 1155, 112, 211, 236, 374, 101, - /* 320 */ 37, 36, 35, 34, 33, 42, 41, 1280, 1124, 40, - /* 330 */ 39, 38, 264, 977, 416, 919, 258, 259, 254, 914, - /* 340 */ 368, 1214, 902, 1215, 905, 29, 908, 901, 1119, 1120, - /* 350 */ 61, 1123, 5, 68, 201, 40, 39, 38, 74, 200, - /* 360 */ 122, 127, 118, 126, 247, 812, 336, 107, 809, 106, - /* 370 */ 810, 904, 811, 907, 1280, 258, 259, 409, 1067, 349, - /* 380 */ 57, 305, 280, 91, 29, 1155, 53, 42, 41, 286, - /* 390 */ 255, 40, 39, 38, 295, 248, 292, 139, 133, 144, - /* 400 */ 1294, 288, 289, 306, 143, 1280, 149, 153, 142, 315, - /* 410 */ 221, 219, 217, 82, 65, 279, 146, 216, 160, 159, - /* 420 */ 158, 157, 915, 909, 911, 53, 73, 365, 408, 407, - /* 430 */ 65, 846, 284, 406, 903, 849, 906, 405, 1130, 404, - /* 440 */ 403, 1106, 1155, 1104, 1105, 1227, 226, 910, 1107, 65, - /* 450 */ 364, 830, 1108, 65, 1109, 1110, 1280, 83, 1283, 274, - /* 460 */ 265, 915, 909, 911, 318, 319, 1137, 282, 65, 287, - /* 470 */ 65, 285, 65, 377, 376, 378, 294, 13, 291, 230, - /* 480 */ 386, 385, 1137, 65, 65, 276, 910, 813, 290, 1280, - /* 490 */ 6, 1283, 912, 827, 379, 1226, 230, 249, 380, 250, - /* 500 */ 271, 1137, 152, 151, 150, 1137, 1280, 1280, 1283, 1280, - /* 510 */ 114, 93, 109, 381, 108, 387, 1223, 388, 1, 199, - /* 520 */ 1137, 10, 1137, 251, 1137, 414, 412, 675, 389, 393, - /* 530 */ 168, 166, 165, 1280, 1266, 1137, 1137, 1265, 1264, 834, - /* 540 */ 256, 92, 257, 293, 1280, 878, 232, 1280, 1280, 233, - /* 550 */ 1280, 266, 1280, 237, 197, 913, 1280, 231, 238, 1280, - /* 560 */ 239, 241, 242, 1280, 243, 98, 240, 1280, 1280, 227, - /* 570 */ 1280, 1280, 1280, 293, 1280, 1121, 1280, 293, 293, 1280, - /* 580 */ 1038, 110, 99, 307, 198, 1029, 855, 211, 367, 1138, - /* 590 */ 3, 212, 211, 317, 316, 865, 96, 66, 866, 364, - /* 600 */ 177, 85, 1222, 794, 309, 877, 370, 272, 340, 77, - /* 610 */ 796, 342, 54, 795, 949, 343, 335, 66, 60, 193, - /* 620 */ 916, 309, 66, 698, 77, 113, 89, 77, 9, 369, - /* 630 */ 819, 15, 820, 14, 9, 392, 132, 9, 131, 17, - /* 640 */ 817, 16, 818, 86, 383, 382, 19, 171, 18, 138, - /* 650 */ 303, 137, 173, 21, 174, 20, 1135, 1163, 783, 26, - /* 660 */ 1174, 1171, 1172, 1156, 310, 1176, 176, 181, 328, 194, - /* 670 */ 1206, 1205, 1204, 1203, 192, 1131, 1129, 195, 196, 1044, - /* 680 */ 345, 346, 347, 348, 351, 1307, 167, 352, 75, 224, - /* 690 */ 71, 410, 363, 1037, 845, 375, 1301, 129, 1300, 1297, - /* 700 */ 202, 27, 321, 87, 1153, 384, 267, 323, 325, 1293, - /* 710 */ 135, 1292, 1289, 203, 1064, 84, 72, 67, 337, 76, - /* 720 */ 225, 1025, 145, 183, 1023, 147, 148, 1021, 28, 1020, - /* 730 */ 333, 331, 1019, 186, 184, 260, 214, 215, 1016, 329, - /* 740 */ 182, 1015, 1014, 327, 1013, 1012, 1011, 324, 1010, 218, - /* 750 */ 220, 1002, 222, 999, 223, 995, 320, 94, 170, 350, - /* 760 */ 90, 308, 402, 1133, 140, 97, 394, 102, 326, 395, - /* 770 */ 396, 397, 398, 399, 88, 400, 278, 172, 344, 974, - /* 780 */ 296, 297, 973, 300, 299, 252, 253, 972, 955, 954, - /* 790 */ 123, 1042, 1041, 124, 309, 304, 339, 11, 100, 822, - /* 800 */ 311, 1018, 58, 1017, 1009, 210, 205, 1065, 206, 204, - /* 810 */ 207, 208, 161, 209, 162, 2, 163, 164, 1008, 103, - /* 820 */ 1102, 185, 338, 1066, 1001, 1000, 854, 59, 187, 188, - /* 830 */ 189, 191, 4, 80, 852, 848, 847, 1112, 81, 180, - /* 840 */ 856, 851, 178, 269, 867, 179, 69, 861, 104, 369, - /* 850 */ 863, 105, 330, 334, 111, 70, 12, 22, 23, 55, - /* 860 */ 341, 56, 114, 117, 116, 62, 120, 714, 749, 747, - /* 870 */ 746, 745, 743, 119, 742, 741, 63, 121, 738, 703, - /* 880 */ 125, 946, 7, 944, 361, 918, 947, 917, 945, 920, - /* 890 */ 8, 372, 373, 78, 128, 130, 66, 79, 134, 786, - /* 900 */ 136, 785, 782, 730, 728, 720, 726, 722, 724, 718, - /* 910 */ 816, 716, 815, 752, 751, 750, 748, 744, 740, 739, - /* 920 */ 213, 665, 979, 701, 674, 672, 978, 411, 978, 413, + /* 290 */ 42, 41, 235, 700, 40, 39, 38, 244, 236, 254, + /* 300 */ 916, 701, 1283, 904, 246, 907, 1297, 910, 1283, 92, + /* 310 */ 156, 155, 154, 245, 112, 979, 416, 247, 373, 101, + /* 320 */ 37, 36, 35, 34, 33, 42, 41, 1283, 315, 40, + /* 330 */ 39, 38, 336, 107, 101, 106, 258, 259, 254, 916, + /* 340 */ 367, 248, 904, 1124, 907, 29, 910, 1122, 1123, 61, + /* 350 */ 1126, 1283, 5, 68, 201, 1217, 280, 1218, 74, 200, + /* 360 */ 122, 127, 118, 126, 249, 814, 1133, 1158, 811, 1158, + /* 370 */ 812, 1230, 813, 74, 1283, 258, 259, 293, 848, 349, + /* 380 */ 57, 305, 851, 91, 29, 306, 53, 264, 197, 65, + /* 390 */ 255, 369, 286, 73, 295, 408, 407, 65, 406, 292, + /* 400 */ 405, 288, 289, 65, 404, 293, 403, 402, 139, 133, + /* 410 */ 144, 318, 319, 276, 368, 143, 198, 149, 153, 142, + /* 420 */ 226, 279, 917, 911, 913, 53, 1108, 146, 1106, 1107, + /* 430 */ 1283, 1113, 1286, 1109, 274, 284, 906, 1110, 909, 1111, + /* 440 */ 1112, 1140, 377, 221, 219, 217, 250, 912, 378, 1140, + /* 450 */ 216, 160, 159, 158, 157, 1140, 1283, 1229, 65, 13, + /* 460 */ 271, 917, 911, 913, 42, 41, 364, 65, 40, 39, + /* 470 */ 38, 65, 287, 65, 285, 65, 376, 375, 905, 294, + /* 480 */ 908, 291, 1226, 385, 384, 230, 912, 815, 290, 363, + /* 490 */ 65, 363, 114, 93, 251, 1283, 832, 1286, 266, 230, + /* 500 */ 414, 412, 676, 379, 1283, 109, 282, 108, 335, 1283, + /* 510 */ 1140, 1286, 380, 40, 39, 38, 386, 293, 387, 1140, + /* 520 */ 388, 1, 199, 1140, 1269, 1140, 1158, 1140, 366, 6, + /* 530 */ 1268, 152, 151, 150, 1283, 392, 168, 166, 165, 1267, + /* 540 */ 1283, 256, 1140, 880, 265, 257, 409, 1069, 232, 1283, + /* 550 */ 233, 1283, 237, 231, 238, 1283, 239, 914, 1283, 241, + /* 560 */ 1283, 98, 1283, 1283, 1283, 242, 1283, 243, 293, 1283, + /* 570 */ 240, 1030, 227, 829, 110, 1283, 1040, 1283, 211, 1141, + /* 580 */ 1283, 1031, 1283, 211, 836, 99, 3, 212, 211, 96, + /* 590 */ 307, 317, 316, 857, 867, 868, 82, 85, 796, 915, + /* 600 */ 309, 10, 340, 879, 66, 798, 342, 177, 77, 54, + /* 610 */ 343, 797, 66, 60, 281, 951, 66, 918, 370, 77, + /* 620 */ 113, 699, 382, 381, 309, 77, 89, 1225, 15, 9, + /* 630 */ 14, 9, 132, 272, 131, 9, 17, 193, 16, 86, + /* 640 */ 83, 821, 819, 822, 820, 19, 138, 18, 137, 21, + /* 650 */ 391, 20, 171, 303, 173, 903, 26, 174, 785, 1138, + /* 660 */ 1166, 1177, 1159, 1174, 1175, 310, 1179, 176, 181, 328, + /* 670 */ 1209, 1208, 1207, 192, 1206, 1134, 194, 1310, 410, 167, + /* 680 */ 321, 267, 323, 1132, 195, 196, 325, 1046, 345, 346, + /* 690 */ 847, 347, 348, 351, 352, 75, 224, 71, 362, 1156, + /* 700 */ 184, 182, 183, 87, 27, 1039, 374, 1304, 129, 337, + /* 710 */ 1303, 1300, 84, 185, 28, 202, 383, 333, 1296, 135, + /* 720 */ 1295, 329, 1292, 203, 331, 327, 921, 1066, 72, 67, + /* 730 */ 324, 76, 225, 186, 187, 1027, 320, 145, 1025, 147, + /* 740 */ 94, 148, 1023, 1022, 1021, 260, 350, 214, 215, 1018, + /* 750 */ 1017, 1016, 1015, 1014, 1013, 1012, 218, 220, 1004, 222, + /* 760 */ 1001, 401, 223, 997, 140, 393, 394, 170, 395, 90, + /* 770 */ 308, 1136, 97, 102, 396, 326, 397, 398, 399, 172, + /* 780 */ 976, 297, 975, 88, 278, 296, 188, 344, 300, 299, + /* 790 */ 974, 957, 252, 253, 956, 123, 1044, 124, 1043, 309, + /* 800 */ 304, 11, 339, 824, 100, 311, 58, 103, 856, 1020, + /* 810 */ 80, 1019, 854, 853, 161, 1067, 206, 204, 205, 208, + /* 820 */ 207, 209, 210, 162, 2, 1011, 338, 1104, 1010, 1068, + /* 830 */ 163, 164, 1003, 59, 189, 1002, 191, 850, 4, 849, + /* 840 */ 81, 180, 858, 178, 1115, 869, 179, 269, 863, 104, + /* 850 */ 69, 865, 105, 330, 368, 22, 334, 70, 111, 12, + /* 860 */ 23, 55, 56, 341, 114, 116, 120, 117, 715, 750, + /* 870 */ 748, 747, 62, 119, 746, 63, 744, 742, 121, 739, + /* 880 */ 704, 125, 948, 360, 946, 7, 949, 947, 920, 919, + /* 890 */ 8, 922, 371, 372, 818, 128, 78, 130, 66, 79, + /* 900 */ 134, 136, 788, 787, 784, 731, 729, 721, 727, 723, + /* 910 */ 725, 719, 717, 817, 753, 752, 751, 749, 745, 743, + /* 920 */ 741, 740, 213, 666, 702, 981, 675, 673, 980, 980, + /* 930 */ 411, 980, 980, 980, 980, 980, 980, 980, 980, 980, + /* 940 */ 980, 413, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 280, 1, 262, 209, 288, 209, 290, 291, 1, 9, - /* 10 */ 290, 1, 292, 209, 14, 15, 9, 17, 18, 209, - /* 20 */ 210, 21, 22, 23, 24, 5, 209, 27, 28, 29, + /* 0 */ 279, 1, 261, 208, 287, 208, 289, 290, 1, 9, + /* 10 */ 289, 1, 291, 208, 14, 15, 9, 17, 18, 208, + /* 20 */ 209, 21, 22, 23, 24, 5, 208, 27, 28, 29, /* 30 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - /* 40 */ 255, 280, 42, 43, 44, 14, 15, 262, 17, 18, - /* 50 */ 254, 290, 21, 22, 23, 24, 285, 261, 27, 28, + /* 40 */ 254, 279, 42, 43, 44, 14, 15, 261, 17, 18, + /* 50 */ 253, 289, 21, 22, 23, 24, 284, 260, 27, 28, /* 60 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - /* 70 */ 39, 254, 280, 42, 43, 44, 282, 283, 261, 255, - /* 80 */ 14, 15, 290, 17, 18, 281, 262, 21, 22, 23, + /* 70 */ 39, 253, 279, 42, 43, 44, 281, 282, 260, 254, + /* 80 */ 14, 15, 289, 17, 18, 280, 261, 21, 22, 23, /* 90 */ 24, 90, 92, 27, 28, 29, 30, 31, 32, 33, - /* 100 */ 34, 35, 36, 37, 38, 39, 280, 280, 42, 43, - /* 110 */ 44, 14, 15, 96, 17, 18, 290, 290, 21, 22, + /* 100 */ 34, 35, 36, 37, 38, 39, 279, 279, 42, 43, + /* 110 */ 44, 14, 15, 96, 17, 18, 289, 289, 21, 22, /* 120 */ 23, 24, 0, 92, 27, 28, 29, 30, 31, 32, - /* 130 */ 33, 34, 35, 36, 37, 38, 39, 262, 280, 42, - /* 140 */ 43, 44, 255, 14, 15, 5, 17, 18, 290, 262, - /* 150 */ 21, 22, 23, 24, 209, 89, 27, 28, 29, 30, + /* 130 */ 33, 34, 35, 36, 37, 38, 39, 261, 279, 42, + /* 140 */ 43, 44, 254, 14, 15, 5, 17, 18, 289, 261, + /* 150 */ 21, 22, 23, 24, 208, 89, 27, 28, 29, 30, /* 160 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 133, /* 170 */ 134, 42, 43, 44, 15, 151, 17, 18, 38, 39, /* 180 */ 21, 22, 23, 24, 160, 161, 27, 28, 29, 30, /* 190 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 1, - /* 200 */ 83, 42, 43, 44, 17, 18, 261, 9, 21, 22, + /* 200 */ 83, 42, 43, 44, 17, 18, 260, 9, 21, 22, /* 210 */ 23, 24, 90, 96, 27, 28, 29, 30, 31, 32, - /* 220 */ 33, 34, 35, 36, 37, 38, 39, 16, 267, 42, + /* 220 */ 33, 34, 35, 36, 37, 38, 39, 216, 266, 42, /* 230 */ 43, 44, 104, 105, 106, 107, 108, 109, 110, 111, - /* 240 */ 112, 113, 114, 115, 116, 117, 118, 286, 50, 51, + /* 240 */ 112, 113, 114, 115, 116, 117, 118, 285, 50, 51, /* 250 */ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - /* 260 */ 62, 63, 64, 88, 66, 233, 234, 235, 236, 237, - /* 270 */ 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, + /* 260 */ 62, 63, 64, 252, 66, 232, 233, 234, 235, 236, + /* 270 */ 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, /* 280 */ 49, 29, 30, 31, 32, 33, 34, 35, 36, 37, - /* 290 */ 38, 39, 217, 1, 42, 43, 44, 66, 280, 1, - /* 300 */ 2, 9, 127, 5, 73, 7, 1, 9, 290, 215, - /* 310 */ 79, 80, 81, 82, 259, 217, 222, 280, 87, 88, - /* 320 */ 33, 34, 35, 36, 37, 38, 39, 290, 253, 42, - /* 330 */ 43, 44, 277, 207, 208, 124, 38, 39, 1, 2, - /* 340 */ 42, 288, 5, 290, 7, 47, 9, 42, 250, 251, - /* 350 */ 252, 253, 67, 68, 69, 42, 43, 44, 127, 74, - /* 360 */ 75, 76, 77, 78, 280, 2, 287, 288, 5, 290, - /* 370 */ 7, 5, 9, 7, 290, 38, 39, 231, 232, 94, - /* 380 */ 88, 150, 216, 152, 47, 259, 88, 38, 39, 73, - /* 390 */ 159, 42, 43, 44, 163, 280, 73, 67, 68, 69, - /* 400 */ 262, 38, 39, 277, 74, 290, 76, 77, 78, 285, - /* 410 */ 67, 68, 69, 103, 209, 216, 86, 74, 75, 76, - /* 420 */ 77, 78, 124, 125, 126, 88, 104, 25, 106, 107, - /* 430 */ 209, 5, 216, 111, 5, 9, 7, 115, 209, 117, - /* 440 */ 118, 233, 259, 235, 236, 249, 280, 149, 240, 209, - /* 450 */ 48, 42, 244, 209, 246, 247, 290, 147, 292, 254, - /* 460 */ 277, 124, 125, 126, 38, 39, 261, 65, 209, 153, - /* 470 */ 209, 155, 209, 157, 158, 254, 153, 88, 155, 280, - /* 480 */ 157, 158, 261, 209, 209, 256, 149, 124, 125, 290, - /* 490 */ 88, 292, 126, 103, 254, 249, 280, 280, 254, 280, - /* 500 */ 249, 261, 83, 84, 85, 261, 290, 290, 292, 290, - /* 510 */ 121, 122, 288, 254, 290, 254, 249, 254, 218, 219, - /* 520 */ 261, 131, 261, 280, 261, 70, 71, 72, 254, 254, - /* 530 */ 67, 68, 69, 290, 280, 261, 261, 280, 280, 130, - /* 540 */ 280, 217, 280, 209, 290, 81, 280, 290, 290, 280, - /* 550 */ 290, 125, 290, 280, 220, 126, 290, 280, 280, 290, - /* 560 */ 280, 280, 280, 290, 280, 89, 280, 290, 290, 280, - /* 570 */ 290, 290, 290, 209, 290, 251, 290, 209, 209, 290, - /* 580 */ 215, 263, 89, 89, 220, 215, 89, 222, 220, 220, - /* 590 */ 213, 214, 222, 38, 39, 89, 278, 103, 89, 48, - /* 600 */ 103, 103, 249, 89, 128, 141, 25, 249, 89, 103, - /* 610 */ 89, 89, 103, 89, 89, 85, 65, 103, 88, 257, - /* 620 */ 89, 128, 103, 89, 103, 103, 88, 103, 103, 48, - /* 630 */ 5, 154, 7, 156, 103, 249, 154, 103, 156, 154, - /* 640 */ 5, 156, 7, 145, 38, 39, 154, 209, 156, 154, - /* 650 */ 209, 156, 209, 154, 209, 156, 209, 209, 120, 279, - /* 660 */ 209, 209, 209, 259, 259, 209, 209, 209, 209, 209, - /* 670 */ 289, 289, 289, 289, 264, 259, 209, 209, 209, 209, - /* 680 */ 209, 209, 209, 209, 209, 265, 65, 209, 209, 209, - /* 690 */ 209, 90, 209, 209, 126, 209, 209, 209, 209, 209, - /* 700 */ 209, 148, 284, 144, 276, 209, 284, 284, 284, 209, - /* 710 */ 209, 209, 209, 209, 209, 146, 209, 209, 139, 209, - /* 720 */ 209, 209, 209, 274, 209, 209, 209, 209, 143, 209, - /* 730 */ 142, 137, 209, 271, 273, 209, 209, 209, 209, 136, - /* 740 */ 275, 209, 209, 135, 209, 209, 209, 138, 209, 209, - /* 750 */ 209, 209, 209, 209, 209, 209, 132, 123, 211, 95, - /* 760 */ 212, 211, 119, 211, 102, 211, 101, 211, 211, 56, - /* 770 */ 98, 100, 60, 99, 211, 97, 211, 131, 211, 5, - /* 780 */ 162, 5, 5, 5, 162, 211, 211, 5, 106, 105, - /* 790 */ 217, 221, 221, 217, 128, 151, 85, 88, 129, 89, - /* 800 */ 103, 211, 88, 211, 211, 223, 228, 230, 224, 229, - /* 810 */ 227, 225, 212, 226, 212, 218, 212, 212, 211, 103, - /* 820 */ 248, 272, 258, 232, 211, 211, 89, 266, 270, 269, - /* 830 */ 268, 265, 213, 103, 126, 5, 5, 248, 88, 103, - /* 840 */ 89, 126, 88, 1, 89, 88, 103, 89, 88, 48, - /* 850 */ 89, 88, 88, 1, 92, 103, 88, 140, 140, 88, - /* 860 */ 85, 88, 121, 83, 85, 93, 75, 5, 9, 5, - /* 870 */ 5, 5, 5, 92, 5, 5, 93, 92, 5, 91, - /* 880 */ 83, 9, 88, 9, 16, 89, 9, 89, 9, 124, - /* 890 */ 88, 28, 64, 17, 156, 156, 103, 17, 156, 5, - /* 900 */ 156, 5, 89, 5, 5, 5, 5, 5, 5, 5, - /* 910 */ 126, 5, 126, 5, 5, 5, 5, 5, 5, 5, - /* 920 */ 103, 65, 0, 91, 9, 9, 293, 22, 293, 22, - /* 930 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 940 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 950 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 960 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 970 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 980 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 990 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1000 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1010 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1020 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1030 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1040 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1050 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1060 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1070 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1080 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1090 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1100 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1110 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1120 */ 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, - /* 1130 */ 293, 293, 293, 293, 293, 293, + /* 290 */ 38, 39, 279, 1, 42, 43, 44, 66, 279, 1, + /* 300 */ 2, 9, 289, 5, 73, 7, 261, 9, 289, 216, + /* 310 */ 79, 80, 81, 82, 216, 206, 207, 279, 87, 88, + /* 320 */ 33, 34, 35, 36, 37, 38, 39, 289, 284, 42, + /* 330 */ 43, 44, 286, 287, 88, 289, 38, 39, 1, 2, + /* 340 */ 42, 279, 5, 250, 7, 47, 9, 249, 250, 251, + /* 350 */ 252, 289, 67, 68, 69, 287, 215, 289, 127, 74, + /* 360 */ 75, 76, 77, 78, 279, 2, 208, 258, 5, 258, + /* 370 */ 7, 248, 9, 127, 289, 38, 39, 208, 5, 94, + /* 380 */ 88, 150, 9, 152, 47, 276, 88, 276, 219, 208, + /* 390 */ 159, 25, 73, 104, 163, 106, 107, 208, 109, 73, + /* 400 */ 111, 38, 39, 208, 115, 208, 117, 118, 67, 68, + /* 410 */ 69, 38, 39, 255, 48, 74, 219, 76, 77, 78, + /* 420 */ 279, 215, 124, 125, 126, 88, 232, 86, 234, 235, + /* 430 */ 289, 237, 291, 239, 253, 215, 5, 243, 7, 245, + /* 440 */ 246, 260, 253, 67, 68, 69, 279, 149, 253, 260, + /* 450 */ 74, 75, 76, 77, 78, 260, 289, 248, 208, 88, + /* 460 */ 248, 124, 125, 126, 38, 39, 25, 208, 42, 43, + /* 470 */ 44, 208, 153, 208, 155, 208, 157, 158, 5, 153, + /* 480 */ 7, 155, 248, 157, 158, 279, 149, 124, 125, 48, + /* 490 */ 208, 48, 121, 122, 279, 289, 42, 291, 125, 279, + /* 500 */ 70, 71, 72, 253, 289, 287, 65, 289, 65, 289, + /* 510 */ 260, 291, 253, 42, 43, 44, 253, 208, 253, 260, + /* 520 */ 253, 217, 218, 260, 279, 260, 258, 260, 219, 88, + /* 530 */ 279, 83, 84, 85, 289, 253, 67, 68, 69, 279, + /* 540 */ 289, 279, 260, 81, 276, 279, 230, 231, 279, 289, + /* 550 */ 279, 289, 279, 279, 279, 289, 279, 126, 289, 279, + /* 560 */ 289, 89, 289, 289, 289, 279, 289, 279, 208, 289, + /* 570 */ 279, 214, 279, 103, 262, 289, 214, 289, 221, 219, + /* 580 */ 289, 214, 289, 221, 130, 89, 212, 213, 221, 277, + /* 590 */ 89, 38, 39, 89, 89, 89, 103, 103, 89, 126, + /* 600 */ 128, 131, 89, 141, 103, 89, 89, 103, 103, 103, + /* 610 */ 85, 89, 103, 88, 1, 89, 103, 89, 16, 103, + /* 620 */ 103, 89, 38, 39, 128, 103, 88, 248, 154, 103, + /* 630 */ 156, 103, 154, 248, 156, 103, 154, 256, 156, 145, + /* 640 */ 147, 5, 5, 7, 7, 154, 154, 156, 156, 154, + /* 650 */ 248, 156, 208, 208, 208, 42, 278, 208, 120, 208, + /* 660 */ 208, 208, 258, 208, 208, 258, 208, 208, 208, 208, + /* 670 */ 288, 288, 288, 263, 288, 258, 208, 264, 90, 65, + /* 680 */ 283, 283, 283, 208, 208, 208, 283, 208, 208, 208, + /* 690 */ 126, 208, 208, 208, 208, 208, 208, 208, 208, 275, + /* 700 */ 272, 274, 273, 144, 148, 208, 208, 208, 208, 139, + /* 710 */ 208, 208, 146, 271, 143, 208, 208, 142, 208, 208, + /* 720 */ 208, 136, 208, 208, 137, 135, 124, 208, 208, 208, + /* 730 */ 138, 208, 208, 270, 269, 208, 132, 208, 208, 208, + /* 740 */ 123, 208, 208, 208, 208, 208, 95, 208, 208, 208, + /* 750 */ 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + /* 760 */ 208, 119, 208, 208, 102, 101, 56, 210, 98, 211, + /* 770 */ 210, 210, 210, 210, 100, 210, 60, 99, 97, 131, + /* 780 */ 5, 5, 5, 210, 210, 162, 268, 210, 5, 162, + /* 790 */ 5, 106, 210, 210, 105, 216, 220, 216, 220, 128, + /* 800 */ 151, 88, 85, 89, 129, 103, 88, 103, 89, 210, + /* 810 */ 103, 210, 126, 126, 211, 229, 223, 228, 227, 224, + /* 820 */ 226, 225, 222, 211, 217, 210, 257, 247, 210, 231, + /* 830 */ 211, 211, 210, 265, 267, 210, 264, 5, 212, 5, + /* 840 */ 88, 103, 89, 88, 247, 89, 88, 1, 89, 88, + /* 850 */ 103, 89, 88, 88, 48, 140, 1, 103, 92, 88, + /* 860 */ 140, 88, 88, 85, 121, 85, 75, 83, 5, 9, + /* 870 */ 5, 5, 93, 92, 5, 93, 5, 5, 92, 5, + /* 880 */ 91, 83, 9, 16, 9, 88, 9, 9, 89, 89, + /* 890 */ 88, 124, 28, 64, 126, 156, 17, 156, 103, 17, + /* 900 */ 156, 156, 5, 5, 89, 5, 5, 5, 5, 5, + /* 910 */ 5, 5, 5, 126, 5, 5, 5, 5, 5, 5, + /* 920 */ 5, 5, 103, 65, 91, 0, 9, 9, 292, 292, + /* 930 */ 22, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 940 */ 292, 22, 292, 292, 292, 292, 292, 292, 292, 292, + /* 950 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 960 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 970 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 980 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 990 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1000 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1010 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1020 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1030 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1040 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1050 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1060 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1070 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1080 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1090 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1100 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1110 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1120 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1130 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 1140 */ 292, 292, 292, 292, 292, 292, 292, 292, }; #define YY_SHIFT_COUNT (416) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (922) +#define YY_SHIFT_MAX (925) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 231, 128, 128, 322, 322, 1, 298, 337, 337, 337, + /* 0 */ 231, 128, 128, 289, 289, 1, 298, 337, 337, 337, /* 10 */ 292, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* 20 */ 7, 7, 10, 10, 0, 198, 337, 337, 337, 337, /* 30 */ 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, /* 40 */ 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, - /* 50 */ 337, 337, 337, 337, 363, 363, 363, 175, 175, 36, + /* 50 */ 337, 337, 337, 337, 363, 363, 363, 246, 246, 36, /* 60 */ 7, 122, 7, 7, 7, 7, 7, 117, 1, 10, - /* 70 */ 10, 17, 17, 20, 930, 930, 930, 363, 363, 363, - /* 80 */ 426, 426, 140, 140, 140, 140, 140, 140, 389, 140, - /* 90 */ 7, 7, 7, 7, 7, 7, 409, 7, 7, 7, - /* 100 */ 175, 175, 7, 7, 7, 7, 464, 464, 464, 464, - /* 110 */ 390, 175, 7, 7, 7, 7, 7, 7, 7, 7, + /* 70 */ 10, 17, 17, 20, 942, 942, 942, 363, 363, 363, + /* 80 */ 373, 373, 140, 140, 140, 140, 140, 140, 371, 140, + /* 90 */ 7, 7, 7, 7, 7, 7, 454, 7, 7, 7, + /* 100 */ 246, 246, 7, 7, 7, 7, 462, 462, 462, 462, + /* 110 */ 470, 246, 7, 7, 7, 7, 7, 7, 7, 7, /* 120 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* 130 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* 140 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* 150 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* 160 */ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - /* 170 */ 553, 621, 601, 621, 621, 621, 621, 568, 568, 568, - /* 180 */ 568, 621, 559, 569, 579, 585, 588, 594, 603, 608, - /* 190 */ 609, 624, 553, 634, 621, 621, 621, 664, 664, 643, - /* 200 */ 1, 1, 621, 621, 662, 665, 713, 672, 671, 712, - /* 210 */ 674, 678, 643, 20, 621, 621, 601, 601, 621, 601, - /* 220 */ 621, 601, 621, 621, 930, 930, 31, 66, 97, 97, + /* 170 */ 556, 614, 588, 614, 614, 614, 614, 564, 564, 564, + /* 180 */ 564, 614, 559, 566, 570, 571, 575, 587, 585, 590, + /* 190 */ 592, 604, 556, 617, 614, 614, 614, 651, 651, 642, + /* 200 */ 1, 1, 614, 614, 662, 664, 710, 670, 674, 716, + /* 210 */ 678, 681, 642, 20, 614, 614, 588, 588, 614, 588, + /* 220 */ 614, 588, 614, 614, 942, 942, 31, 66, 97, 97, /* 230 */ 97, 129, 159, 187, 252, 252, 252, 252, 252, 252, - /* 240 */ 287, 287, 287, 287, 285, 330, 343, 349, 349, 349, - /* 250 */ 349, 349, 316, 323, 402, 24, 313, 313, 366, 429, - /* 260 */ 419, 455, 463, 494, 476, 493, 555, 497, 506, 509, - /* 270 */ 551, 310, 498, 514, 519, 521, 522, 524, 530, 525, - /* 280 */ 531, 581, 305, 211, 534, 477, 482, 485, 625, 635, - /* 290 */ 606, 492, 495, 538, 499, 646, 774, 618, 776, 777, - /* 300 */ 622, 778, 782, 682, 684, 644, 666, 711, 709, 669, - /* 310 */ 710, 714, 697, 716, 737, 730, 708, 715, 830, 831, - /* 320 */ 750, 751, 754, 755, 757, 758, 736, 760, 761, 763, - /* 330 */ 842, 764, 743, 717, 801, 852, 752, 718, 762, 768, - /* 340 */ 711, 771, 775, 773, 741, 779, 780, 772, 781, 791, - /* 350 */ 862, 783, 785, 859, 864, 865, 866, 867, 869, 870, - /* 360 */ 873, 788, 868, 797, 872, 874, 794, 796, 798, 877, - /* 370 */ 879, 765, 802, 863, 828, 876, 738, 739, 793, 793, - /* 380 */ 793, 793, 784, 786, 880, 742, 744, 793, 793, 793, - /* 390 */ 894, 896, 813, 793, 898, 899, 900, 901, 902, 903, - /* 400 */ 904, 906, 908, 909, 910, 911, 912, 913, 914, 817, - /* 410 */ 832, 915, 905, 916, 907, 856, 922, + /* 240 */ 287, 287, 287, 287, 285, 341, 376, 426, 426, 426, + /* 250 */ 426, 426, 319, 326, 441, 24, 471, 471, 431, 473, + /* 260 */ 448, 430, 469, 501, 472, 496, 553, 504, 505, 506, + /* 270 */ 443, 493, 494, 509, 513, 516, 517, 522, 525, 526, + /* 280 */ 528, 366, 613, 602, 532, 474, 478, 482, 636, 637, + /* 290 */ 584, 491, 492, 538, 495, 648, 775, 623, 776, 777, + /* 300 */ 627, 783, 785, 685, 689, 649, 671, 717, 713, 675, + /* 310 */ 714, 718, 702, 704, 719, 707, 686, 687, 832, 834, + /* 320 */ 752, 753, 755, 756, 758, 759, 738, 761, 762, 764, + /* 330 */ 846, 765, 747, 715, 806, 855, 754, 720, 766, 771, + /* 340 */ 717, 773, 778, 774, 743, 780, 784, 779, 781, 791, + /* 350 */ 863, 782, 786, 860, 865, 866, 869, 871, 872, 874, + /* 360 */ 789, 867, 798, 873, 875, 797, 799, 800, 877, 878, + /* 370 */ 767, 802, 864, 829, 879, 739, 741, 795, 795, 795, + /* 380 */ 795, 768, 787, 882, 744, 745, 795, 795, 795, 897, + /* 390 */ 898, 815, 795, 900, 901, 902, 903, 904, 905, 906, + /* 400 */ 907, 909, 910, 911, 912, 913, 914, 915, 916, 819, + /* 410 */ 833, 917, 908, 918, 919, 858, 925, }; #define YY_REDUCE_COUNT (225) -#define YY_REDUCE_MIN (-284) -#define YY_REDUCE_MAX (619) +#define YY_REDUCE_MIN (-283) +#define YY_REDUCE_MAX (626) static const short yy_reduce_ofst[] = { - /* 0 */ 126, 32, 32, 208, 208, 98, 166, 199, 216, -280, - /* 10 */ -206, -204, -183, 205, 221, 240, 244, 259, 261, 263, - /* 20 */ 274, 275, -284, 79, -196, -190, -239, -208, -174, -173, - /* 30 */ -142, 18, 37, 84, 115, 217, 219, 243, 254, 257, - /* 40 */ 258, 260, 262, 266, 269, 273, 277, 278, 280, 281, - /* 50 */ 282, 284, 286, 289, -215, -176, -113, 55, 183, -39, - /* 60 */ 229, 75, 334, 364, 368, 369, -55, 94, 324, 53, - /* 70 */ 224, 365, 370, 146, 318, 300, 377, -260, -125, 138, - /* 80 */ -229, 124, 196, 246, 251, 267, 353, 358, 362, 386, - /* 90 */ 438, 441, 443, 445, 447, 448, 380, 451, 452, 453, - /* 100 */ 404, 405, 456, 457, 458, 459, 381, 382, 383, 384, - /* 110 */ 410, 416, 460, 467, 468, 469, 470, 471, 472, 473, - /* 120 */ 474, 475, 478, 479, 480, 481, 483, 484, 486, 487, - /* 130 */ 488, 489, 490, 491, 496, 500, 501, 502, 503, 504, - /* 140 */ 505, 507, 508, 510, 511, 512, 513, 515, 516, 517, - /* 150 */ 518, 520, 523, 526, 527, 528, 529, 532, 533, 535, - /* 160 */ 536, 537, 539, 540, 541, 542, 543, 544, 545, 546, - /* 170 */ 420, 547, 548, 550, 552, 554, 556, 418, 422, 423, - /* 180 */ 424, 557, 428, 465, 449, 461, 549, 462, 558, 560, - /* 190 */ 562, 561, 566, 564, 563, 565, 567, 570, 571, 572, - /* 200 */ 573, 576, 574, 575, 577, 580, 578, 584, 583, 586, - /* 210 */ 587, 582, 589, 591, 590, 592, 600, 602, 593, 604, - /* 220 */ 607, 605, 613, 614, 597, 619, + /* 0 */ 109, 33, 33, 194, 194, 98, 141, 206, 220, -279, + /* 10 */ -205, -203, -182, 181, 189, 195, 250, 259, 263, 265, + /* 20 */ 267, 282, -283, 46, -195, -189, -238, -207, -173, -172, + /* 30 */ -141, 13, 19, 38, 62, 85, 167, 215, 245, 251, + /* 40 */ 260, 262, 266, 269, 271, 273, 274, 275, 277, 280, + /* 50 */ 286, 288, 291, 293, -214, -175, -112, 111, 268, -38, + /* 60 */ 158, 11, 169, 197, 309, 360, -54, 357, 93, 68, + /* 70 */ 218, 362, 367, 316, 312, 304, 374, -259, -124, 45, + /* 80 */ -228, 44, 123, 209, 212, 234, 379, 385, 381, 402, + /* 90 */ 444, 445, 446, 449, 451, 452, 378, 453, 455, 456, + /* 100 */ 404, 407, 458, 459, 460, 461, 382, 383, 384, 386, + /* 110 */ 410, 417, 468, 475, 476, 477, 479, 480, 481, 483, + /* 120 */ 484, 485, 486, 487, 488, 489, 490, 497, 498, 499, + /* 130 */ 500, 502, 503, 507, 508, 510, 511, 512, 514, 515, + /* 140 */ 519, 520, 521, 523, 524, 527, 529, 530, 531, 533, + /* 150 */ 534, 535, 536, 537, 539, 540, 541, 542, 543, 544, + /* 160 */ 545, 546, 547, 548, 549, 550, 551, 552, 554, 555, + /* 170 */ 413, 557, 558, 560, 561, 562, 563, 397, 398, 399, + /* 180 */ 403, 565, 424, 427, 429, 428, 442, 463, 465, 518, + /* 190 */ 567, 568, 572, 569, 573, 574, 577, 576, 578, 580, + /* 200 */ 579, 581, 582, 583, 586, 589, 591, 593, 594, 595, + /* 210 */ 596, 600, 597, 598, 599, 601, 603, 612, 615, 619, + /* 220 */ 618, 620, 622, 625, 607, 626, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 976, 1101, 1039, 1111, 1026, 1036, 1285, 1285, 1285, 1285, - /* 10 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 20 */ 976, 976, 976, 976, 1165, 996, 976, 976, 976, 976, - /* 30 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 40 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 50 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 1189, - /* 60 */ 976, 1036, 976, 976, 976, 976, 976, 1047, 1036, 976, - /* 70 */ 976, 1047, 1047, 976, 1160, 1085, 1103, 976, 976, 976, - /* 80 */ 976, 976, 976, 976, 976, 976, 976, 976, 1132, 976, - /* 90 */ 976, 976, 976, 976, 976, 976, 1167, 1173, 1170, 976, - /* 100 */ 976, 976, 1175, 976, 976, 976, 1211, 1211, 1211, 1211, - /* 110 */ 1158, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 120 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 130 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 140 */ 976, 976, 976, 976, 976, 1024, 976, 1022, 976, 976, - /* 150 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 160 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 994, - /* 170 */ 1228, 998, 1034, 998, 998, 998, 998, 976, 976, 976, - /* 180 */ 976, 998, 1220, 1224, 1201, 1218, 1212, 1196, 1194, 1192, - /* 190 */ 1200, 1185, 1228, 1134, 998, 998, 998, 1045, 1045, 1040, - /* 200 */ 1036, 1036, 998, 998, 1063, 1061, 1059, 1051, 1057, 1053, - /* 210 */ 1055, 1049, 1027, 976, 998, 998, 1034, 1034, 998, 1034, - /* 220 */ 998, 1034, 998, 998, 1085, 1103, 1284, 976, 1229, 1219, - /* 230 */ 1284, 976, 1261, 1260, 1275, 1274, 1273, 1259, 1258, 1257, - /* 240 */ 1253, 1256, 1255, 1254, 976, 976, 976, 1272, 1271, 1269, - /* 250 */ 1268, 1267, 976, 976, 1231, 976, 1263, 1262, 976, 976, - /* 260 */ 976, 976, 976, 976, 976, 976, 1182, 976, 976, 976, - /* 270 */ 1207, 1225, 1221, 976, 976, 976, 976, 976, 976, 976, - /* 280 */ 976, 1232, 976, 976, 976, 976, 976, 976, 976, 976, - /* 290 */ 1146, 976, 976, 1113, 976, 976, 976, 976, 976, 976, - /* 300 */ 976, 976, 976, 976, 976, 976, 1157, 976, 976, 976, - /* 310 */ 976, 976, 1169, 1168, 976, 976, 976, 976, 976, 976, - /* 320 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 330 */ 976, 976, 1213, 976, 1208, 976, 1202, 976, 976, 976, - /* 340 */ 1125, 976, 976, 976, 976, 1043, 976, 976, 976, 976, - /* 350 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 360 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - /* 370 */ 976, 976, 976, 976, 976, 976, 976, 976, 1303, 1298, - /* 380 */ 1299, 1296, 976, 976, 976, 976, 976, 1295, 1290, 1291, - /* 390 */ 976, 976, 976, 1288, 976, 976, 976, 976, 976, 976, - /* 400 */ 976, 976, 976, 976, 976, 976, 976, 976, 976, 1069, - /* 410 */ 976, 976, 1005, 976, 1003, 976, 976, + /* 0 */ 978, 1103, 1041, 1114, 1028, 1038, 1288, 1288, 1288, 1288, + /* 10 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 20 */ 978, 978, 978, 978, 1168, 998, 978, 978, 978, 978, + /* 30 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 40 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 50 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 1192, + /* 60 */ 978, 1038, 978, 978, 978, 978, 978, 1049, 1038, 978, + /* 70 */ 978, 1049, 1049, 978, 1163, 1087, 1105, 978, 978, 978, + /* 80 */ 978, 978, 978, 978, 978, 978, 978, 978, 1135, 978, + /* 90 */ 978, 978, 978, 978, 978, 978, 1170, 1176, 1173, 978, + /* 100 */ 978, 978, 1178, 978, 978, 978, 1214, 1214, 1214, 1214, + /* 110 */ 1161, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 120 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 130 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 140 */ 978, 978, 978, 978, 978, 1026, 978, 1024, 978, 978, + /* 150 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 160 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 996, + /* 170 */ 1231, 1000, 1036, 1000, 1000, 1000, 1000, 978, 978, 978, + /* 180 */ 978, 1000, 1223, 1227, 1204, 1221, 1215, 1199, 1197, 1195, + /* 190 */ 1203, 1188, 1231, 1137, 1000, 1000, 1000, 1047, 1047, 1042, + /* 200 */ 1038, 1038, 1000, 1000, 1065, 1063, 1061, 1053, 1059, 1055, + /* 210 */ 1057, 1051, 1029, 978, 1000, 1000, 1036, 1036, 1000, 1036, + /* 220 */ 1000, 1036, 1000, 1000, 1087, 1105, 1287, 978, 1232, 1222, + /* 230 */ 1287, 978, 1264, 1263, 1278, 1277, 1276, 1262, 1261, 1260, + /* 240 */ 1256, 1259, 1258, 1257, 978, 978, 978, 1275, 1274, 1272, + /* 250 */ 1271, 1270, 978, 978, 1234, 978, 1266, 1265, 978, 978, + /* 260 */ 978, 978, 978, 978, 978, 978, 1185, 978, 978, 978, + /* 270 */ 1210, 1228, 1224, 978, 978, 978, 978, 978, 978, 978, + /* 280 */ 978, 1235, 978, 978, 978, 978, 978, 978, 978, 978, + /* 290 */ 1149, 978, 978, 1116, 978, 978, 978, 978, 978, 978, + /* 300 */ 978, 978, 978, 978, 978, 978, 1160, 978, 978, 978, + /* 310 */ 978, 978, 1172, 1171, 978, 978, 978, 978, 978, 978, + /* 320 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 330 */ 978, 978, 1216, 978, 1211, 978, 1205, 978, 978, 978, + /* 340 */ 1128, 978, 978, 978, 978, 1045, 978, 978, 978, 978, + /* 350 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 360 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 978, + /* 370 */ 978, 978, 978, 978, 978, 978, 978, 1306, 1301, 1302, + /* 380 */ 1299, 978, 978, 978, 978, 978, 1298, 1293, 1294, 978, + /* 390 */ 978, 978, 1291, 978, 978, 978, 978, 978, 978, 978, + /* 400 */ 978, 978, 978, 978, 978, 978, 978, 978, 978, 1071, + /* 410 */ 978, 978, 1007, 978, 1005, 978, 978, }; /********** End of lemon-generated parsing tables *****************************/ @@ -800,6 +813,7 @@ 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 */ @@ -1053,93 +1067,92 @@ static const char *const yyTokenName[] = { /* 203 */ "INTO", /* 204 */ "VALUES", /* 205 */ "FILE", - /* 206 */ "error", - /* 207 */ "program", - /* 208 */ "cmd", - /* 209 */ "ids", - /* 210 */ "dbPrefix", - /* 211 */ "cpxName", - /* 212 */ "ifexists", - /* 213 */ "alter_db_optr", - /* 214 */ "alter_topic_optr", - /* 215 */ "acct_optr", - /* 216 */ "exprlist", - /* 217 */ "ifnotexists", - /* 218 */ "db_optr", - /* 219 */ "topic_optr", - /* 220 */ "typename", - /* 221 */ "bufsize", - /* 222 */ "pps", - /* 223 */ "tseries", - /* 224 */ "dbs", - /* 225 */ "streams", - /* 226 */ "storage", - /* 227 */ "qtime", - /* 228 */ "users", - /* 229 */ "conns", - /* 230 */ "state", - /* 231 */ "intitemlist", - /* 232 */ "intitem", - /* 233 */ "keep", - /* 234 */ "cache", - /* 235 */ "replica", - /* 236 */ "quorum", - /* 237 */ "days", - /* 238 */ "minrows", - /* 239 */ "maxrows", - /* 240 */ "blocks", - /* 241 */ "ctime", - /* 242 */ "wal", - /* 243 */ "fsync", - /* 244 */ "comp", - /* 245 */ "prec", - /* 246 */ "update", - /* 247 */ "cachelast", - /* 248 */ "partitions", - /* 249 */ "signed", - /* 250 */ "create_table_args", - /* 251 */ "create_stable_args", - /* 252 */ "create_table_list", - /* 253 */ "create_from_stable", - /* 254 */ "columnlist", - /* 255 */ "tagitemlist", - /* 256 */ "tagNamelist", - /* 257 */ "to_opt", - /* 258 */ "split_opt", - /* 259 */ "select", - /* 260 */ "to_split", - /* 261 */ "column", - /* 262 */ "tagitem", - /* 263 */ "selcollist", - /* 264 */ "from", - /* 265 */ "where_opt", - /* 266 */ "range_option", - /* 267 */ "interval_option", - /* 268 */ "sliding_opt", - /* 269 */ "session_option", - /* 270 */ "windowstate_option", - /* 271 */ "fill_opt", - /* 272 */ "groupby_opt", - /* 273 */ "having_opt", - /* 274 */ "orderby_opt", - /* 275 */ "slimit_opt", - /* 276 */ "limit_opt", - /* 277 */ "union", - /* 278 */ "sclp", - /* 279 */ "distinct", - /* 280 */ "expr", - /* 281 */ "as", - /* 282 */ "tablelist", - /* 283 */ "sub", - /* 284 */ "tmvar", - /* 285 */ "timestamp", - /* 286 */ "intervalKey", - /* 287 */ "sortlist", - /* 288 */ "item", - /* 289 */ "sortorder", - /* 290 */ "arrow", - /* 291 */ "grouplist", - /* 292 */ "expritem", + /* 206 */ "program", + /* 207 */ "cmd", + /* 208 */ "ids", + /* 209 */ "dbPrefix", + /* 210 */ "cpxName", + /* 211 */ "ifexists", + /* 212 */ "alter_db_optr", + /* 213 */ "alter_topic_optr", + /* 214 */ "acct_optr", + /* 215 */ "exprlist", + /* 216 */ "ifnotexists", + /* 217 */ "db_optr", + /* 218 */ "topic_optr", + /* 219 */ "typename", + /* 220 */ "bufsize", + /* 221 */ "pps", + /* 222 */ "tseries", + /* 223 */ "dbs", + /* 224 */ "streams", + /* 225 */ "storage", + /* 226 */ "qtime", + /* 227 */ "users", + /* 228 */ "conns", + /* 229 */ "state", + /* 230 */ "intitemlist", + /* 231 */ "intitem", + /* 232 */ "keep", + /* 233 */ "cache", + /* 234 */ "replica", + /* 235 */ "quorum", + /* 236 */ "days", + /* 237 */ "minrows", + /* 238 */ "maxrows", + /* 239 */ "blocks", + /* 240 */ "ctime", + /* 241 */ "wal", + /* 242 */ "fsync", + /* 243 */ "comp", + /* 244 */ "prec", + /* 245 */ "update", + /* 246 */ "cachelast", + /* 247 */ "partitions", + /* 248 */ "signed", + /* 249 */ "create_table_args", + /* 250 */ "create_stable_args", + /* 251 */ "create_table_list", + /* 252 */ "create_from_stable", + /* 253 */ "columnlist", + /* 254 */ "tagitemlist", + /* 255 */ "tagNamelist", + /* 256 */ "to_opt", + /* 257 */ "split_opt", + /* 258 */ "select", + /* 259 */ "to_split", + /* 260 */ "column", + /* 261 */ "tagitem", + /* 262 */ "selcollist", + /* 263 */ "from", + /* 264 */ "where_opt", + /* 265 */ "range_option", + /* 266 */ "interval_option", + /* 267 */ "sliding_opt", + /* 268 */ "session_option", + /* 269 */ "windowstate_option", + /* 270 */ "fill_opt", + /* 271 */ "groupby_opt", + /* 272 */ "having_opt", + /* 273 */ "orderby_opt", + /* 274 */ "slimit_opt", + /* 275 */ "limit_opt", + /* 276 */ "union", + /* 277 */ "sclp", + /* 278 */ "distinct", + /* 279 */ "expr", + /* 280 */ "as", + /* 281 */ "tablelist", + /* 282 */ "sub", + /* 283 */ "tmvar", + /* 284 */ "timestamp", + /* 285 */ "intervalKey", + /* 286 */ "sortlist", + /* 287 */ "item", + /* 288 */ "sortorder", + /* 289 */ "arrow", + /* 290 */ "grouplist", + /* 291 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1279,203 +1292,204 @@ static const char *const yyRuleName[] = { /* 129 */ "alter_db_optr ::= alter_db_optr comp", /* 130 */ "alter_db_optr ::= alter_db_optr update", /* 131 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 132 */ "alter_topic_optr ::= alter_db_optr", - /* 133 */ "alter_topic_optr ::= alter_topic_optr partitions", - /* 134 */ "typename ::= ids", - /* 135 */ "typename ::= ids LP signed RP", - /* 136 */ "typename ::= ids UNSIGNED", - /* 137 */ "signed ::= INTEGER", - /* 138 */ "signed ::= PLUS INTEGER", - /* 139 */ "signed ::= MINUS INTEGER", - /* 140 */ "cmd ::= CREATE TABLE create_table_args", - /* 141 */ "cmd ::= CREATE TABLE create_stable_args", - /* 142 */ "cmd ::= CREATE STABLE create_stable_args", - /* 143 */ "cmd ::= CREATE TABLE create_table_list", - /* 144 */ "create_table_list ::= create_from_stable", - /* 145 */ "create_table_list ::= create_table_list create_from_stable", - /* 146 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 147 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 148 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", - /* 149 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", - /* 150 */ "tagNamelist ::= tagNamelist COMMA ids", - /* 151 */ "tagNamelist ::= ids", - /* 152 */ "create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select", - /* 153 */ "to_opt ::=", - /* 154 */ "to_opt ::= TO ids cpxName", - /* 155 */ "split_opt ::=", - /* 156 */ "split_opt ::= SPLIT ids", - /* 157 */ "columnlist ::= columnlist COMMA column", - /* 158 */ "columnlist ::= column", - /* 159 */ "column ::= ids typename", - /* 160 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 161 */ "tagitemlist ::= tagitem", - /* 162 */ "tagitem ::= INTEGER", - /* 163 */ "tagitem ::= FLOAT", - /* 164 */ "tagitem ::= STRING", - /* 165 */ "tagitem ::= BOOL", - /* 166 */ "tagitem ::= NULL", - /* 167 */ "tagitem ::= NOW", - /* 168 */ "tagitem ::= NOW PLUS VARIABLE", - /* 169 */ "tagitem ::= NOW MINUS VARIABLE", - /* 170 */ "tagitem ::= MINUS INTEGER", - /* 171 */ "tagitem ::= MINUS FLOAT", - /* 172 */ "tagitem ::= PLUS INTEGER", - /* 173 */ "tagitem ::= PLUS FLOAT", - /* 174 */ "select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", - /* 175 */ "select ::= LP select RP", - /* 176 */ "union ::= select", - /* 177 */ "union ::= union UNION ALL select", - /* 178 */ "cmd ::= union", - /* 179 */ "select ::= SELECT selcollist", - /* 180 */ "sclp ::= selcollist COMMA", - /* 181 */ "sclp ::=", - /* 182 */ "selcollist ::= sclp distinct expr as", - /* 183 */ "selcollist ::= sclp STAR", - /* 184 */ "as ::= AS ids", - /* 185 */ "as ::= ids", - /* 186 */ "as ::=", - /* 187 */ "distinct ::= DISTINCT", - /* 188 */ "distinct ::=", - /* 189 */ "from ::= FROM tablelist", - /* 190 */ "from ::= FROM sub", - /* 191 */ "sub ::= LP union RP", - /* 192 */ "sub ::= LP union RP ids", - /* 193 */ "sub ::= sub COMMA LP union RP ids", - /* 194 */ "tablelist ::= ids cpxName", - /* 195 */ "tablelist ::= ids cpxName ids", - /* 196 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 197 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 198 */ "tmvar ::= VARIABLE", - /* 199 */ "timestamp ::= INTEGER", - /* 200 */ "timestamp ::= MINUS INTEGER", - /* 201 */ "timestamp ::= PLUS INTEGER", - /* 202 */ "timestamp ::= STRING", - /* 203 */ "timestamp ::= NOW", - /* 204 */ "timestamp ::= NOW PLUS VARIABLE", - /* 205 */ "timestamp ::= NOW MINUS VARIABLE", - /* 206 */ "range_option ::=", - /* 207 */ "range_option ::= RANGE LP timestamp COMMA timestamp RP", - /* 208 */ "interval_option ::= intervalKey LP tmvar RP", - /* 209 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", - /* 210 */ "interval_option ::=", - /* 211 */ "intervalKey ::= INTERVAL", - /* 212 */ "intervalKey ::= EVERY", - /* 213 */ "session_option ::=", - /* 214 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 215 */ "windowstate_option ::=", - /* 216 */ "windowstate_option ::= STATE_WINDOW LP ids RP", - /* 217 */ "fill_opt ::=", - /* 218 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 219 */ "fill_opt ::= FILL LP ID RP", - /* 220 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 221 */ "sliding_opt ::=", - /* 222 */ "orderby_opt ::=", - /* 223 */ "orderby_opt ::= ORDER BY sortlist", - /* 224 */ "sortlist ::= sortlist COMMA item sortorder", - /* 225 */ "sortlist ::= sortlist COMMA arrow sortorder", - /* 226 */ "sortlist ::= item sortorder", - /* 227 */ "sortlist ::= arrow sortorder", - /* 228 */ "item ::= ID", - /* 229 */ "item ::= ID DOT ID", - /* 230 */ "sortorder ::= ASC", - /* 231 */ "sortorder ::= DESC", - /* 232 */ "sortorder ::=", - /* 233 */ "groupby_opt ::=", - /* 234 */ "groupby_opt ::= GROUP BY grouplist", - /* 235 */ "grouplist ::= grouplist COMMA item", - /* 236 */ "grouplist ::= grouplist COMMA arrow", - /* 237 */ "grouplist ::= item", - /* 238 */ "grouplist ::= arrow", - /* 239 */ "having_opt ::=", - /* 240 */ "having_opt ::= HAVING expr", - /* 241 */ "limit_opt ::=", - /* 242 */ "limit_opt ::= LIMIT signed", - /* 243 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 244 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 245 */ "slimit_opt ::=", - /* 246 */ "slimit_opt ::= SLIMIT signed", - /* 247 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 248 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 249 */ "where_opt ::=", - /* 250 */ "where_opt ::= WHERE expr", - /* 251 */ "expr ::= LP expr RP", - /* 252 */ "expr ::= ID", - /* 253 */ "expr ::= ID DOT ID", - /* 254 */ "expr ::= ID DOT STAR", - /* 255 */ "expr ::= INTEGER", - /* 256 */ "expr ::= MINUS INTEGER", - /* 257 */ "expr ::= PLUS INTEGER", - /* 258 */ "expr ::= FLOAT", - /* 259 */ "expr ::= MINUS FLOAT", - /* 260 */ "expr ::= PLUS FLOAT", - /* 261 */ "expr ::= STRING", - /* 262 */ "expr ::= NOW", - /* 263 */ "expr ::= TODAY", - /* 264 */ "expr ::= VARIABLE", - /* 265 */ "expr ::= PLUS VARIABLE", - /* 266 */ "expr ::= MINUS VARIABLE", - /* 267 */ "expr ::= BOOL", - /* 268 */ "expr ::= NULL", - /* 269 */ "expr ::= ID LP exprlist RP", - /* 270 */ "expr ::= ID LP STAR RP", - /* 271 */ "expr ::= ID LP expr AS typename RP", - /* 272 */ "expr ::= expr IS NULL", - /* 273 */ "expr ::= expr IS NOT NULL", - /* 274 */ "expr ::= expr LT expr", - /* 275 */ "expr ::= expr GT expr", - /* 276 */ "expr ::= expr LE expr", - /* 277 */ "expr ::= expr GE expr", - /* 278 */ "expr ::= expr NE expr", - /* 279 */ "expr ::= expr EQ expr", - /* 280 */ "expr ::= expr BETWEEN expr AND expr", - /* 281 */ "expr ::= expr AND expr", - /* 282 */ "expr ::= expr OR expr", - /* 283 */ "expr ::= expr PLUS expr", - /* 284 */ "expr ::= expr MINUS expr", - /* 285 */ "expr ::= expr STAR expr", - /* 286 */ "expr ::= expr SLASH expr", - /* 287 */ "expr ::= expr REM expr", - /* 288 */ "expr ::= expr BITAND expr", - /* 289 */ "expr ::= expr BITOR expr", - /* 290 */ "expr ::= expr BITXOR expr", - /* 291 */ "expr ::= BITNOT expr", - /* 292 */ "expr ::= expr LSHIFT expr", - /* 293 */ "expr ::= expr RSHIFT expr", - /* 294 */ "expr ::= expr LIKE expr", - /* 295 */ "expr ::= expr MATCH expr", - /* 296 */ "expr ::= expr NMATCH expr", - /* 297 */ "expr ::= ID CONTAINS STRING", - /* 298 */ "expr ::= ID DOT ID CONTAINS STRING", - /* 299 */ "arrow ::= ID ARROW STRING", - /* 300 */ "arrow ::= ID DOT ID ARROW STRING", - /* 301 */ "expr ::= arrow", - /* 302 */ "expr ::= expr IN LP exprlist RP", - /* 303 */ "exprlist ::= exprlist COMMA expritem", - /* 304 */ "exprlist ::= expritem", - /* 305 */ "expritem ::= expr", - /* 306 */ "expritem ::=", - /* 307 */ "cmd ::= RESET QUERY CACHE", - /* 308 */ "cmd ::= SYNCDB ids REPLICA", - /* 309 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 310 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 311 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 312 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 313 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 314 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 315 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 316 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 317 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 318 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 319 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 320 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 321 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 322 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 323 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 324 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 325 */ "cmd ::= KILL CONNECTION INTEGER", - /* 326 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 327 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", - /* 328 */ "cmd ::= DELETE FROM ifexists ids cpxName where_opt", + /* 132 */ "alter_db_optr ::= alter_db_optr minrows", + /* 133 */ "alter_topic_optr ::= alter_db_optr", + /* 134 */ "alter_topic_optr ::= alter_topic_optr partitions", + /* 135 */ "typename ::= ids", + /* 136 */ "typename ::= ids LP signed RP", + /* 137 */ "typename ::= ids UNSIGNED", + /* 138 */ "signed ::= INTEGER", + /* 139 */ "signed ::= PLUS INTEGER", + /* 140 */ "signed ::= MINUS INTEGER", + /* 141 */ "cmd ::= CREATE TABLE create_table_args", + /* 142 */ "cmd ::= CREATE TABLE create_stable_args", + /* 143 */ "cmd ::= CREATE STABLE create_stable_args", + /* 144 */ "cmd ::= CREATE TABLE create_table_list", + /* 145 */ "create_table_list ::= create_from_stable", + /* 146 */ "create_table_list ::= create_table_list create_from_stable", + /* 147 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", + /* 148 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", + /* 149 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", + /* 150 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", + /* 151 */ "tagNamelist ::= tagNamelist COMMA ids", + /* 152 */ "tagNamelist ::= ids", + /* 153 */ "create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select", + /* 154 */ "to_opt ::=", + /* 155 */ "to_opt ::= TO ids cpxName", + /* 156 */ "split_opt ::=", + /* 157 */ "split_opt ::= SPLIT ids", + /* 158 */ "columnlist ::= columnlist COMMA column", + /* 159 */ "columnlist ::= column", + /* 160 */ "column ::= ids typename", + /* 161 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 162 */ "tagitemlist ::= tagitem", + /* 163 */ "tagitem ::= INTEGER", + /* 164 */ "tagitem ::= FLOAT", + /* 165 */ "tagitem ::= STRING", + /* 166 */ "tagitem ::= BOOL", + /* 167 */ "tagitem ::= NULL", + /* 168 */ "tagitem ::= NOW", + /* 169 */ "tagitem ::= NOW PLUS VARIABLE", + /* 170 */ "tagitem ::= NOW MINUS VARIABLE", + /* 171 */ "tagitem ::= MINUS INTEGER", + /* 172 */ "tagitem ::= MINUS FLOAT", + /* 173 */ "tagitem ::= PLUS INTEGER", + /* 174 */ "tagitem ::= PLUS FLOAT", + /* 175 */ "select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", + /* 176 */ "select ::= LP select RP", + /* 177 */ "union ::= select", + /* 178 */ "union ::= union UNION ALL select", + /* 179 */ "cmd ::= union", + /* 180 */ "select ::= SELECT selcollist", + /* 181 */ "sclp ::= selcollist COMMA", + /* 182 */ "sclp ::=", + /* 183 */ "selcollist ::= sclp distinct expr as", + /* 184 */ "selcollist ::= sclp STAR", + /* 185 */ "as ::= AS ids", + /* 186 */ "as ::= ids", + /* 187 */ "as ::=", + /* 188 */ "distinct ::= DISTINCT", + /* 189 */ "distinct ::=", + /* 190 */ "from ::= FROM tablelist", + /* 191 */ "from ::= FROM sub", + /* 192 */ "sub ::= LP union RP", + /* 193 */ "sub ::= LP union RP ids", + /* 194 */ "sub ::= sub COMMA LP union RP ids", + /* 195 */ "tablelist ::= ids cpxName", + /* 196 */ "tablelist ::= ids cpxName ids", + /* 197 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 198 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 199 */ "tmvar ::= VARIABLE", + /* 200 */ "timestamp ::= INTEGER", + /* 201 */ "timestamp ::= MINUS INTEGER", + /* 202 */ "timestamp ::= PLUS INTEGER", + /* 203 */ "timestamp ::= STRING", + /* 204 */ "timestamp ::= NOW", + /* 205 */ "timestamp ::= NOW PLUS VARIABLE", + /* 206 */ "timestamp ::= NOW MINUS VARIABLE", + /* 207 */ "range_option ::=", + /* 208 */ "range_option ::= RANGE LP timestamp COMMA timestamp RP", + /* 209 */ "interval_option ::= intervalKey LP tmvar RP", + /* 210 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", + /* 211 */ "interval_option ::=", + /* 212 */ "intervalKey ::= INTERVAL", + /* 213 */ "intervalKey ::= EVERY", + /* 214 */ "session_option ::=", + /* 215 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 216 */ "windowstate_option ::=", + /* 217 */ "windowstate_option ::= STATE_WINDOW LP ids RP", + /* 218 */ "fill_opt ::=", + /* 219 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 220 */ "fill_opt ::= FILL LP ID RP", + /* 221 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 222 */ "sliding_opt ::=", + /* 223 */ "orderby_opt ::=", + /* 224 */ "orderby_opt ::= ORDER BY sortlist", + /* 225 */ "sortlist ::= sortlist COMMA item sortorder", + /* 226 */ "sortlist ::= sortlist COMMA arrow sortorder", + /* 227 */ "sortlist ::= item sortorder", + /* 228 */ "sortlist ::= arrow sortorder", + /* 229 */ "item ::= ID", + /* 230 */ "item ::= ID DOT ID", + /* 231 */ "sortorder ::= ASC", + /* 232 */ "sortorder ::= DESC", + /* 233 */ "sortorder ::=", + /* 234 */ "groupby_opt ::=", + /* 235 */ "groupby_opt ::= GROUP BY grouplist", + /* 236 */ "grouplist ::= grouplist COMMA item", + /* 237 */ "grouplist ::= grouplist COMMA arrow", + /* 238 */ "grouplist ::= item", + /* 239 */ "grouplist ::= arrow", + /* 240 */ "having_opt ::=", + /* 241 */ "having_opt ::= HAVING expr", + /* 242 */ "limit_opt ::=", + /* 243 */ "limit_opt ::= LIMIT signed", + /* 244 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 245 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 246 */ "slimit_opt ::=", + /* 247 */ "slimit_opt ::= SLIMIT signed", + /* 248 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 249 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 250 */ "where_opt ::=", + /* 251 */ "where_opt ::= WHERE expr", + /* 252 */ "expr ::= LP expr RP", + /* 253 */ "expr ::= ID", + /* 254 */ "expr ::= ID DOT ID", + /* 255 */ "expr ::= ID DOT STAR", + /* 256 */ "expr ::= INTEGER", + /* 257 */ "expr ::= MINUS INTEGER", + /* 258 */ "expr ::= PLUS INTEGER", + /* 259 */ "expr ::= FLOAT", + /* 260 */ "expr ::= MINUS FLOAT", + /* 261 */ "expr ::= PLUS FLOAT", + /* 262 */ "expr ::= STRING", + /* 263 */ "expr ::= NOW", + /* 264 */ "expr ::= TODAY", + /* 265 */ "expr ::= VARIABLE", + /* 266 */ "expr ::= PLUS VARIABLE", + /* 267 */ "expr ::= MINUS VARIABLE", + /* 268 */ "expr ::= BOOL", + /* 269 */ "expr ::= NULL", + /* 270 */ "expr ::= ID LP exprlist RP", + /* 271 */ "expr ::= ID LP STAR RP", + /* 272 */ "expr ::= ID LP expr AS typename RP", + /* 273 */ "expr ::= expr IS NULL", + /* 274 */ "expr ::= expr IS NOT NULL", + /* 275 */ "expr ::= expr LT expr", + /* 276 */ "expr ::= expr GT expr", + /* 277 */ "expr ::= expr LE expr", + /* 278 */ "expr ::= expr GE expr", + /* 279 */ "expr ::= expr NE expr", + /* 280 */ "expr ::= expr EQ expr", + /* 281 */ "expr ::= expr BETWEEN expr AND expr", + /* 282 */ "expr ::= expr AND expr", + /* 283 */ "expr ::= expr OR expr", + /* 284 */ "expr ::= expr PLUS expr", + /* 285 */ "expr ::= expr MINUS expr", + /* 286 */ "expr ::= expr STAR expr", + /* 287 */ "expr ::= expr SLASH expr", + /* 288 */ "expr ::= expr REM expr", + /* 289 */ "expr ::= expr BITAND expr", + /* 290 */ "expr ::= expr BITOR expr", + /* 291 */ "expr ::= expr BITXOR expr", + /* 292 */ "expr ::= BITNOT expr", + /* 293 */ "expr ::= expr LSHIFT expr", + /* 294 */ "expr ::= expr RSHIFT expr", + /* 295 */ "expr ::= expr LIKE expr", + /* 296 */ "expr ::= expr MATCH expr", + /* 297 */ "expr ::= expr NMATCH expr", + /* 298 */ "expr ::= ID CONTAINS STRING", + /* 299 */ "expr ::= ID DOT ID CONTAINS STRING", + /* 300 */ "arrow ::= ID ARROW STRING", + /* 301 */ "arrow ::= ID DOT ID ARROW STRING", + /* 302 */ "expr ::= arrow", + /* 303 */ "expr ::= expr IN LP exprlist RP", + /* 304 */ "exprlist ::= exprlist COMMA expritem", + /* 305 */ "exprlist ::= expritem", + /* 306 */ "expritem ::= expr", + /* 307 */ "expritem ::=", + /* 308 */ "cmd ::= RESET QUERY CACHE", + /* 309 */ "cmd ::= SYNCDB ids REPLICA", + /* 310 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 311 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 312 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 313 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 314 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 315 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 316 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 317 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 318 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 319 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 320 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 321 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 322 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 323 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 324 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 325 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 326 */ "cmd ::= KILL CONNECTION INTEGER", + /* 327 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 328 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 329 */ "cmd ::= DELETE FROM ifexists ids cpxName where_opt", }; #endif /* NDEBUG */ @@ -1524,28 +1538,29 @@ static int yyGrowStack(yyParser *p){ /* Initialize a new parser that has already been allocated. */ -void ParseInit(void *yypParser){ - yyParser *pParser = (yyParser*)yypParser; +void ParseInit(void *yypRawParser ParseCTX_PDECL){ + yyParser *yypParser = (yyParser*)yypRawParser; + ParseCTX_STORE #ifdef YYTRACKMAXSTACKDEPTH - pParser->yyhwm = 0; + yypParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 - pParser->yytos = NULL; - pParser->yystack = NULL; - pParser->yystksz = 0; - if( yyGrowStack(pParser) ){ - pParser->yystack = &pParser->yystk0; - pParser->yystksz = 1; + yypParser->yytos = NULL; + yypParser->yystack = NULL; + yypParser->yystksz = 0; + if( yyGrowStack(yypParser) ){ + yypParser->yystack = &yypParser->yystk0; + yypParser->yystksz = 1; } #endif #ifndef YYNOERRORRECOVERY - pParser->yyerrcnt = -1; + yypParser->yyerrcnt = -1; #endif - pParser->yytos = pParser->yystack; - pParser->yystack[0].stateno = 0; - pParser->yystack[0].major = 0; + yypParser->yytos = yypParser->yystack; + yypParser->yystack[0].stateno = 0; + yypParser->yystack[0].major = 0; #if YYSTACKDEPTH>0 - pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1]; + yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; #endif } @@ -1562,11 +1577,14 @@ void ParseInit(void *yypParser){ ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ -void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ - yyParser *pParser; - pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); - if( pParser ) ParseInit(pParser); - return pParser; +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; } #endif /* Parse_ENGINEALWAYSONSTACK */ @@ -1583,7 +1601,8 @@ static void yy_destructor( YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ - ParseARG_FETCH; + ParseARG_FETCH + ParseCTX_FETCH switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen @@ -1596,57 +1615,57 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 216: /* exprlist */ - case 263: /* selcollist */ - case 278: /* sclp */ + case 215: /* exprlist */ + case 262: /* selcollist */ + case 277: /* sclp */ { -tSqlExprListDestroy((yypminor->yy367)); +tSqlExprListDestroy((yypminor->yy333)); } break; - case 231: /* intitemlist */ - case 233: /* keep */ - case 254: /* columnlist */ - case 255: /* tagitemlist */ - case 256: /* tagNamelist */ - case 271: /* fill_opt */ - case 272: /* groupby_opt */ - case 274: /* orderby_opt */ - case 287: /* sortlist */ - case 291: /* grouplist */ -{ -taosArrayDestroy(&(yypminor->yy367)); + case 230: /* intitemlist */ + case 232: /* keep */ + case 253: /* columnlist */ + case 254: /* tagitemlist */ + case 255: /* tagNamelist */ + case 270: /* fill_opt */ + case 271: /* groupby_opt */ + case 273: /* orderby_opt */ + case 286: /* sortlist */ + case 290: /* grouplist */ +{ +taosArrayDestroy(&(yypminor->yy333)); } break; - case 252: /* create_table_list */ + case 251: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy74)); +destroyCreateTableSql((yypminor->yy78)); } break; - case 259: /* select */ + case 258: /* select */ { -destroySqlNode((yypminor->yy426)); +destroySqlNode((yypminor->yy144)); } break; - case 264: /* from */ - case 282: /* tablelist */ - case 283: /* sub */ + case 263: /* from */ + case 281: /* tablelist */ + case 282: /* sub */ { -destroyRelationInfo((yypminor->yy480)); +destroyRelationInfo((yypminor->yy516)); } break; - case 265: /* where_opt */ - case 273: /* having_opt */ - case 280: /* expr */ - case 285: /* timestamp */ - case 290: /* arrow */ - case 292: /* expritem */ + case 264: /* where_opt */ + case 272: /* having_opt */ + case 279: /* expr */ + case 284: /* timestamp */ + case 289: /* arrow */ + case 291: /* expritem */ { -tSqlExprDestroy((yypminor->yy378)); +tSqlExprDestroy((yypminor->yy194)); } break; - case 277: /* union */ + case 276: /* union */ { -destroyAllSqlNode((yypminor->yy367)); +destroyAllSqlNode((yypminor->yy333)); } break; /********* End destructor definitions *****************************************/ @@ -1758,13 +1777,12 @@ int ParseCoverage(FILE *out){ ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ -static unsigned int yy_find_shift_action( - yyParser *pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ +static YYACTIONTYPE yy_find_shift_action( + YYCODETYPE iLookAhead, /* The look-ahead token */ + YYACTIONTYPE stateno /* Current state number */ ){ int i; - int stateno = pParser->yytos->stateno; - + if( stateno>YY_MAX_SHIFT ) return stateno; assert( stateno <= YY_SHIFT_COUNT ); #if defined(YYCOVERAGE) @@ -1772,15 +1790,19 @@ static unsigned int yy_find_shift_action( #endif do{ i = yy_shift_ofst[stateno]; - assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) ); + assert( i>=0 ); + assert( i<=YY_ACTTAB_COUNT ); + assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; + assert( i<(int)YY_NLOOKAHEAD ); if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - if( iLookAhead %s\n", @@ -1795,15 +1817,8 @@ static unsigned int yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - if( -#if YY_SHIFT_MIN+YYWILDCARD<0 - j>=0 && -#endif -#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j0 - ){ + assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); + if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -1817,6 +1832,7 @@ static unsigned int yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ + assert( i>=0 && iyytos; - yytos->stateno = (YYACTIONTYPE)yyNewState; - yytos->major = (YYCODETYPE)yyMajor; + yytos->stateno = yyNewState; + yytos->major = yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } -/* 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[] = { - { 207, -1 }, /* (0) program ::= cmd */ - { 208, -2 }, /* (1) cmd ::= SHOW DATABASES */ - { 208, -2 }, /* (2) cmd ::= SHOW TOPICS */ - { 208, -2 }, /* (3) cmd ::= SHOW FUNCTIONS */ - { 208, -2 }, /* (4) cmd ::= SHOW MNODES */ - { 208, -2 }, /* (5) cmd ::= SHOW DNODES */ - { 208, -2 }, /* (6) cmd ::= SHOW ACCOUNTS */ - { 208, -2 }, /* (7) cmd ::= SHOW USERS */ - { 208, -2 }, /* (8) cmd ::= SHOW MODULES */ - { 208, -2 }, /* (9) cmd ::= SHOW QUERIES */ - { 208, -2 }, /* (10) cmd ::= SHOW CONNECTIONS */ - { 208, -2 }, /* (11) cmd ::= SHOW STREAMS */ - { 208, -2 }, /* (12) cmd ::= SHOW VARIABLES */ - { 208, -2 }, /* (13) cmd ::= SHOW SCORES */ - { 208, -2 }, /* (14) cmd ::= SHOW GRANTS */ - { 208, -2 }, /* (15) cmd ::= SHOW VNODES */ - { 208, -3 }, /* (16) cmd ::= SHOW VNODES ids */ - { 210, 0 }, /* (17) dbPrefix ::= */ - { 210, -2 }, /* (18) dbPrefix ::= ids DOT */ - { 211, 0 }, /* (19) cpxName ::= */ - { 211, -2 }, /* (20) cpxName ::= DOT ids */ - { 208, -5 }, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ - { 208, -5 }, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ - { 208, -4 }, /* (23) cmd ::= SHOW CREATE DATABASE ids */ - { 208, -3 }, /* (24) cmd ::= SHOW dbPrefix TABLES */ - { 208, -5 }, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE STRING */ - { 208, -3 }, /* (26) cmd ::= SHOW dbPrefix STABLES */ - { 208, -5 }, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE STRING */ - { 208, -3 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ - { 208, -5 }, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ - { 208, -5 }, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ - { 208, -4 }, /* (31) cmd ::= DROP DATABASE ifexists ids */ - { 208, -4 }, /* (32) cmd ::= DROP TOPIC ifexists ids */ - { 208, -3 }, /* (33) cmd ::= DROP FUNCTION ids */ - { 208, -3 }, /* (34) cmd ::= DROP DNODE ids */ - { 208, -3 }, /* (35) cmd ::= DROP USER ids */ - { 208, -3 }, /* (36) cmd ::= DROP ACCOUNT ids */ - { 208, -2 }, /* (37) cmd ::= USE ids */ - { 208, -3 }, /* (38) cmd ::= DESCRIBE ids cpxName */ - { 208, -3 }, /* (39) cmd ::= DESC ids cpxName */ - { 208, -5 }, /* (40) cmd ::= ALTER USER ids PASS ids */ - { 208, -5 }, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ - { 208, -5 }, /* (42) cmd ::= ALTER USER ids TAGS ids */ - { 208, -4 }, /* (43) cmd ::= ALTER DNODE ids ids */ - { 208, -5 }, /* (44) cmd ::= ALTER DNODE ids ids ids */ - { 208, -3 }, /* (45) cmd ::= ALTER LOCAL ids */ - { 208, -4 }, /* (46) cmd ::= ALTER LOCAL ids ids */ - { 208, -4 }, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */ - { 208, -4 }, /* (48) cmd ::= ALTER TOPIC ids alter_topic_optr */ - { 208, -4 }, /* (49) cmd ::= ALTER ACCOUNT ids acct_optr */ - { 208, -6 }, /* (50) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - { 208, -6 }, /* (51) cmd ::= COMPACT VNODES IN LP exprlist RP */ - { 209, -1 }, /* (52) ids ::= ID */ - { 209, -1 }, /* (53) ids ::= STRING */ - { 212, -2 }, /* (54) ifexists ::= IF EXISTS */ - { 212, 0 }, /* (55) ifexists ::= */ - { 217, -3 }, /* (56) ifnotexists ::= IF NOT EXISTS */ - { 217, 0 }, /* (57) ifnotexists ::= */ - { 208, -3 }, /* (58) cmd ::= CREATE DNODE ids */ - { 208, -6 }, /* (59) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - { 208, -5 }, /* (60) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - { 208, -5 }, /* (61) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - { 208, -8 }, /* (62) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - { 208, -9 }, /* (63) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - { 208, -5 }, /* (64) cmd ::= CREATE USER ids PASS ids */ - { 208, -7 }, /* (65) cmd ::= CREATE USER ids PASS ids TAGS ids */ - { 221, 0 }, /* (66) bufsize ::= */ - { 221, -2 }, /* (67) bufsize ::= BUFSIZE INTEGER */ - { 222, 0 }, /* (68) pps ::= */ - { 222, -2 }, /* (69) pps ::= PPS INTEGER */ - { 223, 0 }, /* (70) tseries ::= */ - { 223, -2 }, /* (71) tseries ::= TSERIES INTEGER */ - { 224, 0 }, /* (72) dbs ::= */ - { 224, -2 }, /* (73) dbs ::= DBS INTEGER */ - { 225, 0 }, /* (74) streams ::= */ - { 225, -2 }, /* (75) streams ::= STREAMS INTEGER */ - { 226, 0 }, /* (76) storage ::= */ - { 226, -2 }, /* (77) storage ::= STORAGE INTEGER */ - { 227, 0 }, /* (78) qtime ::= */ - { 227, -2 }, /* (79) qtime ::= QTIME INTEGER */ - { 228, 0 }, /* (80) users ::= */ - { 228, -2 }, /* (81) users ::= USERS INTEGER */ - { 229, 0 }, /* (82) conns ::= */ - { 229, -2 }, /* (83) conns ::= CONNS INTEGER */ - { 230, 0 }, /* (84) state ::= */ - { 230, -2 }, /* (85) state ::= STATE ids */ - { 215, -9 }, /* (86) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - { 231, -3 }, /* (87) intitemlist ::= intitemlist COMMA intitem */ - { 231, -1 }, /* (88) intitemlist ::= intitem */ - { 232, -1 }, /* (89) intitem ::= INTEGER */ - { 233, -2 }, /* (90) keep ::= KEEP intitemlist */ - { 234, -2 }, /* (91) cache ::= CACHE INTEGER */ - { 235, -2 }, /* (92) replica ::= REPLICA INTEGER */ - { 236, -2 }, /* (93) quorum ::= QUORUM INTEGER */ - { 237, -2 }, /* (94) days ::= DAYS INTEGER */ - { 238, -2 }, /* (95) minrows ::= MINROWS INTEGER */ - { 239, -2 }, /* (96) maxrows ::= MAXROWS INTEGER */ - { 240, -2 }, /* (97) blocks ::= BLOCKS INTEGER */ - { 241, -2 }, /* (98) ctime ::= CTIME INTEGER */ - { 242, -2 }, /* (99) wal ::= WAL INTEGER */ - { 243, -2 }, /* (100) fsync ::= FSYNC INTEGER */ - { 244, -2 }, /* (101) comp ::= COMP INTEGER */ - { 245, -2 }, /* (102) prec ::= PRECISION STRING */ - { 246, -2 }, /* (103) update ::= UPDATE INTEGER */ - { 247, -2 }, /* (104) cachelast ::= CACHELAST INTEGER */ - { 248, -2 }, /* (105) partitions ::= PARTITIONS INTEGER */ - { 218, 0 }, /* (106) db_optr ::= */ - { 218, -2 }, /* (107) db_optr ::= db_optr cache */ - { 218, -2 }, /* (108) db_optr ::= db_optr replica */ - { 218, -2 }, /* (109) db_optr ::= db_optr quorum */ - { 218, -2 }, /* (110) db_optr ::= db_optr days */ - { 218, -2 }, /* (111) db_optr ::= db_optr minrows */ - { 218, -2 }, /* (112) db_optr ::= db_optr maxrows */ - { 218, -2 }, /* (113) db_optr ::= db_optr blocks */ - { 218, -2 }, /* (114) db_optr ::= db_optr ctime */ - { 218, -2 }, /* (115) db_optr ::= db_optr wal */ - { 218, -2 }, /* (116) db_optr ::= db_optr fsync */ - { 218, -2 }, /* (117) db_optr ::= db_optr comp */ - { 218, -2 }, /* (118) db_optr ::= db_optr prec */ - { 218, -2 }, /* (119) db_optr ::= db_optr keep */ - { 218, -2 }, /* (120) db_optr ::= db_optr update */ - { 218, -2 }, /* (121) db_optr ::= db_optr cachelast */ - { 219, -1 }, /* (122) topic_optr ::= db_optr */ - { 219, -2 }, /* (123) topic_optr ::= topic_optr partitions */ - { 213, 0 }, /* (124) alter_db_optr ::= */ - { 213, -2 }, /* (125) alter_db_optr ::= alter_db_optr replica */ - { 213, -2 }, /* (126) alter_db_optr ::= alter_db_optr quorum */ - { 213, -2 }, /* (127) alter_db_optr ::= alter_db_optr keep */ - { 213, -2 }, /* (128) alter_db_optr ::= alter_db_optr blocks */ - { 213, -2 }, /* (129) alter_db_optr ::= alter_db_optr comp */ - { 213, -2 }, /* (130) alter_db_optr ::= alter_db_optr update */ - { 213, -2 }, /* (131) alter_db_optr ::= alter_db_optr cachelast */ - { 214, -1 }, /* (132) alter_topic_optr ::= alter_db_optr */ - { 214, -2 }, /* (133) alter_topic_optr ::= alter_topic_optr partitions */ - { 220, -1 }, /* (134) typename ::= ids */ - { 220, -4 }, /* (135) typename ::= ids LP signed RP */ - { 220, -2 }, /* (136) typename ::= ids UNSIGNED */ - { 249, -1 }, /* (137) signed ::= INTEGER */ - { 249, -2 }, /* (138) signed ::= PLUS INTEGER */ - { 249, -2 }, /* (139) signed ::= MINUS INTEGER */ - { 208, -3 }, /* (140) cmd ::= CREATE TABLE create_table_args */ - { 208, -3 }, /* (141) cmd ::= CREATE TABLE create_stable_args */ - { 208, -3 }, /* (142) cmd ::= CREATE STABLE create_stable_args */ - { 208, -3 }, /* (143) cmd ::= CREATE TABLE create_table_list */ - { 252, -1 }, /* (144) create_table_list ::= create_from_stable */ - { 252, -2 }, /* (145) create_table_list ::= create_table_list create_from_stable */ - { 250, -6 }, /* (146) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 251, -10 }, /* (147) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 253, -10 }, /* (148) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - { 253, -13 }, /* (149) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - { 256, -3 }, /* (150) tagNamelist ::= tagNamelist COMMA ids */ - { 256, -1 }, /* (151) tagNamelist ::= ids */ - { 250, -7 }, /* (152) create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select */ - { 257, 0 }, /* (153) to_opt ::= */ - { 257, -3 }, /* (154) to_opt ::= TO ids cpxName */ - { 258, 0 }, /* (155) split_opt ::= */ - { 258, -2 }, /* (156) split_opt ::= SPLIT ids */ - { 254, -3 }, /* (157) columnlist ::= columnlist COMMA column */ - { 254, -1 }, /* (158) columnlist ::= column */ - { 261, -2 }, /* (159) column ::= ids typename */ - { 255, -3 }, /* (160) tagitemlist ::= tagitemlist COMMA tagitem */ - { 255, -1 }, /* (161) tagitemlist ::= tagitem */ - { 262, -1 }, /* (162) tagitem ::= INTEGER */ - { 262, -1 }, /* (163) tagitem ::= FLOAT */ - { 262, -1 }, /* (164) tagitem ::= STRING */ - { 262, -1 }, /* (165) tagitem ::= BOOL */ - { 262, -1 }, /* (166) tagitem ::= NULL */ - { 262, -1 }, /* (167) tagitem ::= NOW */ - { 262, -3 }, /* (168) tagitem ::= NOW PLUS VARIABLE */ - { 262, -3 }, /* (169) tagitem ::= NOW MINUS VARIABLE */ - { 262, -2 }, /* (170) tagitem ::= MINUS INTEGER */ - { 262, -2 }, /* (171) tagitem ::= MINUS FLOAT */ - { 262, -2 }, /* (172) tagitem ::= PLUS INTEGER */ - { 262, -2 }, /* (173) tagitem ::= PLUS FLOAT */ - { 259, -15 }, /* (174) select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - { 259, -3 }, /* (175) select ::= LP select RP */ - { 277, -1 }, /* (176) union ::= select */ - { 277, -4 }, /* (177) union ::= union UNION ALL select */ - { 208, -1 }, /* (178) cmd ::= union */ - { 259, -2 }, /* (179) select ::= SELECT selcollist */ - { 278, -2 }, /* (180) sclp ::= selcollist COMMA */ - { 278, 0 }, /* (181) sclp ::= */ - { 263, -4 }, /* (182) selcollist ::= sclp distinct expr as */ - { 263, -2 }, /* (183) selcollist ::= sclp STAR */ - { 281, -2 }, /* (184) as ::= AS ids */ - { 281, -1 }, /* (185) as ::= ids */ - { 281, 0 }, /* (186) as ::= */ - { 279, -1 }, /* (187) distinct ::= DISTINCT */ - { 279, 0 }, /* (188) distinct ::= */ - { 264, -2 }, /* (189) from ::= FROM tablelist */ - { 264, -2 }, /* (190) from ::= FROM sub */ - { 283, -3 }, /* (191) sub ::= LP union RP */ - { 283, -4 }, /* (192) sub ::= LP union RP ids */ - { 283, -6 }, /* (193) sub ::= sub COMMA LP union RP ids */ - { 282, -2 }, /* (194) tablelist ::= ids cpxName */ - { 282, -3 }, /* (195) tablelist ::= ids cpxName ids */ - { 282, -4 }, /* (196) tablelist ::= tablelist COMMA ids cpxName */ - { 282, -5 }, /* (197) tablelist ::= tablelist COMMA ids cpxName ids */ - { 284, -1 }, /* (198) tmvar ::= VARIABLE */ - { 285, -1 }, /* (199) timestamp ::= INTEGER */ - { 285, -2 }, /* (200) timestamp ::= MINUS INTEGER */ - { 285, -2 }, /* (201) timestamp ::= PLUS INTEGER */ - { 285, -1 }, /* (202) timestamp ::= STRING */ - { 285, -1 }, /* (203) timestamp ::= NOW */ - { 285, -3 }, /* (204) timestamp ::= NOW PLUS VARIABLE */ - { 285, -3 }, /* (205) timestamp ::= NOW MINUS VARIABLE */ - { 266, 0 }, /* (206) range_option ::= */ - { 266, -6 }, /* (207) range_option ::= RANGE LP timestamp COMMA timestamp RP */ - { 267, -4 }, /* (208) interval_option ::= intervalKey LP tmvar RP */ - { 267, -6 }, /* (209) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ - { 267, 0 }, /* (210) interval_option ::= */ - { 286, -1 }, /* (211) intervalKey ::= INTERVAL */ - { 286, -1 }, /* (212) intervalKey ::= EVERY */ - { 269, 0 }, /* (213) session_option ::= */ - { 269, -7 }, /* (214) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - { 270, 0 }, /* (215) windowstate_option ::= */ - { 270, -4 }, /* (216) windowstate_option ::= STATE_WINDOW LP ids RP */ - { 271, 0 }, /* (217) fill_opt ::= */ - { 271, -6 }, /* (218) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 271, -4 }, /* (219) fill_opt ::= FILL LP ID RP */ - { 268, -4 }, /* (220) sliding_opt ::= SLIDING LP tmvar RP */ - { 268, 0 }, /* (221) sliding_opt ::= */ - { 274, 0 }, /* (222) orderby_opt ::= */ - { 274, -3 }, /* (223) orderby_opt ::= ORDER BY sortlist */ - { 287, -4 }, /* (224) sortlist ::= sortlist COMMA item sortorder */ - { 287, -4 }, /* (225) sortlist ::= sortlist COMMA arrow sortorder */ - { 287, -2 }, /* (226) sortlist ::= item sortorder */ - { 287, -2 }, /* (227) sortlist ::= arrow sortorder */ - { 288, -1 }, /* (228) item ::= ID */ - { 288, -3 }, /* (229) item ::= ID DOT ID */ - { 289, -1 }, /* (230) sortorder ::= ASC */ - { 289, -1 }, /* (231) sortorder ::= DESC */ - { 289, 0 }, /* (232) sortorder ::= */ - { 272, 0 }, /* (233) groupby_opt ::= */ - { 272, -3 }, /* (234) groupby_opt ::= GROUP BY grouplist */ - { 291, -3 }, /* (235) grouplist ::= grouplist COMMA item */ - { 291, -3 }, /* (236) grouplist ::= grouplist COMMA arrow */ - { 291, -1 }, /* (237) grouplist ::= item */ - { 291, -1 }, /* (238) grouplist ::= arrow */ - { 273, 0 }, /* (239) having_opt ::= */ - { 273, -2 }, /* (240) having_opt ::= HAVING expr */ - { 276, 0 }, /* (241) limit_opt ::= */ - { 276, -2 }, /* (242) limit_opt ::= LIMIT signed */ - { 276, -4 }, /* (243) limit_opt ::= LIMIT signed OFFSET signed */ - { 276, -4 }, /* (244) limit_opt ::= LIMIT signed COMMA signed */ - { 275, 0 }, /* (245) slimit_opt ::= */ - { 275, -2 }, /* (246) slimit_opt ::= SLIMIT signed */ - { 275, -4 }, /* (247) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 275, -4 }, /* (248) slimit_opt ::= SLIMIT signed COMMA signed */ - { 265, 0 }, /* (249) where_opt ::= */ - { 265, -2 }, /* (250) where_opt ::= WHERE expr */ - { 280, -3 }, /* (251) expr ::= LP expr RP */ - { 280, -1 }, /* (252) expr ::= ID */ - { 280, -3 }, /* (253) expr ::= ID DOT ID */ - { 280, -3 }, /* (254) expr ::= ID DOT STAR */ - { 280, -1 }, /* (255) expr ::= INTEGER */ - { 280, -2 }, /* (256) expr ::= MINUS INTEGER */ - { 280, -2 }, /* (257) expr ::= PLUS INTEGER */ - { 280, -1 }, /* (258) expr ::= FLOAT */ - { 280, -2 }, /* (259) expr ::= MINUS FLOAT */ - { 280, -2 }, /* (260) expr ::= PLUS FLOAT */ - { 280, -1 }, /* (261) expr ::= STRING */ - { 280, -1 }, /* (262) expr ::= NOW */ - { 280, -1 }, /* (263) expr ::= TODAY */ - { 280, -1 }, /* (264) expr ::= VARIABLE */ - { 280, -2 }, /* (265) expr ::= PLUS VARIABLE */ - { 280, -2 }, /* (266) expr ::= MINUS VARIABLE */ - { 280, -1 }, /* (267) expr ::= BOOL */ - { 280, -1 }, /* (268) expr ::= NULL */ - { 280, -4 }, /* (269) expr ::= ID LP exprlist RP */ - { 280, -4 }, /* (270) expr ::= ID LP STAR RP */ - { 280, -6 }, /* (271) expr ::= ID LP expr AS typename RP */ - { 280, -3 }, /* (272) expr ::= expr IS NULL */ - { 280, -4 }, /* (273) expr ::= expr IS NOT NULL */ - { 280, -3 }, /* (274) expr ::= expr LT expr */ - { 280, -3 }, /* (275) expr ::= expr GT expr */ - { 280, -3 }, /* (276) expr ::= expr LE expr */ - { 280, -3 }, /* (277) expr ::= expr GE expr */ - { 280, -3 }, /* (278) expr ::= expr NE expr */ - { 280, -3 }, /* (279) expr ::= expr EQ expr */ - { 280, -5 }, /* (280) expr ::= expr BETWEEN expr AND expr */ - { 280, -3 }, /* (281) expr ::= expr AND expr */ - { 280, -3 }, /* (282) expr ::= expr OR expr */ - { 280, -3 }, /* (283) expr ::= expr PLUS expr */ - { 280, -3 }, /* (284) expr ::= expr MINUS expr */ - { 280, -3 }, /* (285) expr ::= expr STAR expr */ - { 280, -3 }, /* (286) expr ::= expr SLASH expr */ - { 280, -3 }, /* (287) expr ::= expr REM expr */ - { 280, -3 }, /* (288) expr ::= expr BITAND expr */ - { 280, -3 }, /* (289) expr ::= expr BITOR expr */ - { 280, -3 }, /* (290) expr ::= expr BITXOR expr */ - { 280, -2 }, /* (291) expr ::= BITNOT expr */ - { 280, -3 }, /* (292) expr ::= expr LSHIFT expr */ - { 280, -3 }, /* (293) expr ::= expr RSHIFT expr */ - { 280, -3 }, /* (294) expr ::= expr LIKE expr */ - { 280, -3 }, /* (295) expr ::= expr MATCH expr */ - { 280, -3 }, /* (296) expr ::= expr NMATCH expr */ - { 280, -3 }, /* (297) expr ::= ID CONTAINS STRING */ - { 280, -5 }, /* (298) expr ::= ID DOT ID CONTAINS STRING */ - { 290, -3 }, /* (299) arrow ::= ID ARROW STRING */ - { 290, -5 }, /* (300) arrow ::= ID DOT ID ARROW STRING */ - { 280, -1 }, /* (301) expr ::= arrow */ - { 280, -5 }, /* (302) expr ::= expr IN LP exprlist RP */ - { 216, -3 }, /* (303) exprlist ::= exprlist COMMA expritem */ - { 216, -1 }, /* (304) exprlist ::= expritem */ - { 292, -1 }, /* (305) expritem ::= expr */ - { 292, 0 }, /* (306) expritem ::= */ - { 208, -3 }, /* (307) cmd ::= RESET QUERY CACHE */ - { 208, -3 }, /* (308) cmd ::= SYNCDB ids REPLICA */ - { 208, -7 }, /* (309) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 208, -7 }, /* (310) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 208, -7 }, /* (311) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - { 208, -7 }, /* (312) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 208, -7 }, /* (313) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 208, -8 }, /* (314) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 208, -9 }, /* (315) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 208, -7 }, /* (316) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - { 208, -7 }, /* (317) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - { 208, -7 }, /* (318) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - { 208, -7 }, /* (319) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - { 208, -7 }, /* (320) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - { 208, -7 }, /* (321) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - { 208, -8 }, /* (322) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - { 208, -9 }, /* (323) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - { 208, -7 }, /* (324) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - { 208, -3 }, /* (325) cmd ::= KILL CONNECTION INTEGER */ - { 208, -5 }, /* (326) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 208, -5 }, /* (327) cmd ::= KILL QUERY INTEGER COLON INTEGER */ - { 208, -6 }, /* (328) cmd ::= DELETE FROM ifexists ids cpxName where_opt */ +/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side +** of that rule */ +static const YYCODETYPE yyRuleInfoLhs[] = { + 206, /* (0) program ::= cmd */ + 207, /* (1) cmd ::= SHOW DATABASES */ + 207, /* (2) cmd ::= SHOW TOPICS */ + 207, /* (3) cmd ::= SHOW FUNCTIONS */ + 207, /* (4) cmd ::= SHOW MNODES */ + 207, /* (5) cmd ::= SHOW DNODES */ + 207, /* (6) cmd ::= SHOW ACCOUNTS */ + 207, /* (7) cmd ::= SHOW USERS */ + 207, /* (8) cmd ::= SHOW MODULES */ + 207, /* (9) cmd ::= SHOW QUERIES */ + 207, /* (10) cmd ::= SHOW CONNECTIONS */ + 207, /* (11) cmd ::= SHOW STREAMS */ + 207, /* (12) cmd ::= SHOW VARIABLES */ + 207, /* (13) cmd ::= SHOW SCORES */ + 207, /* (14) cmd ::= SHOW GRANTS */ + 207, /* (15) cmd ::= SHOW VNODES */ + 207, /* (16) cmd ::= SHOW VNODES ids */ + 209, /* (17) dbPrefix ::= */ + 209, /* (18) dbPrefix ::= ids DOT */ + 210, /* (19) cpxName ::= */ + 210, /* (20) cpxName ::= DOT ids */ + 207, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ + 207, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ + 207, /* (23) cmd ::= SHOW CREATE DATABASE ids */ + 207, /* (24) cmd ::= SHOW dbPrefix TABLES */ + 207, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE STRING */ + 207, /* (26) cmd ::= SHOW dbPrefix STABLES */ + 207, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE STRING */ + 207, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ + 207, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ + 207, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ + 207, /* (31) cmd ::= DROP DATABASE ifexists ids */ + 207, /* (32) cmd ::= DROP TOPIC ifexists ids */ + 207, /* (33) cmd ::= DROP FUNCTION ids */ + 207, /* (34) cmd ::= DROP DNODE ids */ + 207, /* (35) cmd ::= DROP USER ids */ + 207, /* (36) cmd ::= DROP ACCOUNT ids */ + 207, /* (37) cmd ::= USE ids */ + 207, /* (38) cmd ::= DESCRIBE ids cpxName */ + 207, /* (39) cmd ::= DESC ids cpxName */ + 207, /* (40) cmd ::= ALTER USER ids PASS ids */ + 207, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ + 207, /* (42) cmd ::= ALTER USER ids TAGS ids */ + 207, /* (43) cmd ::= ALTER DNODE ids ids */ + 207, /* (44) cmd ::= ALTER DNODE ids ids ids */ + 207, /* (45) cmd ::= ALTER LOCAL ids */ + 207, /* (46) cmd ::= ALTER LOCAL ids ids */ + 207, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */ + 207, /* (48) cmd ::= ALTER TOPIC ids alter_topic_optr */ + 207, /* (49) cmd ::= ALTER ACCOUNT ids acct_optr */ + 207, /* (50) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + 207, /* (51) cmd ::= COMPACT VNODES IN LP exprlist RP */ + 208, /* (52) ids ::= ID */ + 208, /* (53) ids ::= STRING */ + 211, /* (54) ifexists ::= IF EXISTS */ + 211, /* (55) ifexists ::= */ + 216, /* (56) ifnotexists ::= IF NOT EXISTS */ + 216, /* (57) ifnotexists ::= */ + 207, /* (58) cmd ::= CREATE DNODE ids */ + 207, /* (59) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + 207, /* (60) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + 207, /* (61) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ + 207, /* (62) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + 207, /* (63) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + 207, /* (64) cmd ::= CREATE USER ids PASS ids */ + 207, /* (65) cmd ::= CREATE USER ids PASS ids TAGS ids */ + 220, /* (66) bufsize ::= */ + 220, /* (67) bufsize ::= BUFSIZE INTEGER */ + 221, /* (68) pps ::= */ + 221, /* (69) pps ::= PPS INTEGER */ + 222, /* (70) tseries ::= */ + 222, /* (71) tseries ::= TSERIES INTEGER */ + 223, /* (72) dbs ::= */ + 223, /* (73) dbs ::= DBS INTEGER */ + 224, /* (74) streams ::= */ + 224, /* (75) streams ::= STREAMS INTEGER */ + 225, /* (76) storage ::= */ + 225, /* (77) storage ::= STORAGE INTEGER */ + 226, /* (78) qtime ::= */ + 226, /* (79) qtime ::= QTIME INTEGER */ + 227, /* (80) users ::= */ + 227, /* (81) users ::= USERS INTEGER */ + 228, /* (82) conns ::= */ + 228, /* (83) conns ::= CONNS INTEGER */ + 229, /* (84) state ::= */ + 229, /* (85) state ::= STATE ids */ + 214, /* (86) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + 230, /* (87) intitemlist ::= intitemlist COMMA intitem */ + 230, /* (88) intitemlist ::= intitem */ + 231, /* (89) intitem ::= INTEGER */ + 232, /* (90) keep ::= KEEP intitemlist */ + 233, /* (91) cache ::= CACHE INTEGER */ + 234, /* (92) replica ::= REPLICA INTEGER */ + 235, /* (93) quorum ::= QUORUM INTEGER */ + 236, /* (94) days ::= DAYS INTEGER */ + 237, /* (95) minrows ::= MINROWS INTEGER */ + 238, /* (96) maxrows ::= MAXROWS INTEGER */ + 239, /* (97) blocks ::= BLOCKS INTEGER */ + 240, /* (98) ctime ::= CTIME INTEGER */ + 241, /* (99) wal ::= WAL INTEGER */ + 242, /* (100) fsync ::= FSYNC INTEGER */ + 243, /* (101) comp ::= COMP INTEGER */ + 244, /* (102) prec ::= PRECISION STRING */ + 245, /* (103) update ::= UPDATE INTEGER */ + 246, /* (104) cachelast ::= CACHELAST INTEGER */ + 247, /* (105) partitions ::= PARTITIONS INTEGER */ + 217, /* (106) db_optr ::= */ + 217, /* (107) db_optr ::= db_optr cache */ + 217, /* (108) db_optr ::= db_optr replica */ + 217, /* (109) db_optr ::= db_optr quorum */ + 217, /* (110) db_optr ::= db_optr days */ + 217, /* (111) db_optr ::= db_optr minrows */ + 217, /* (112) db_optr ::= db_optr maxrows */ + 217, /* (113) db_optr ::= db_optr blocks */ + 217, /* (114) db_optr ::= db_optr ctime */ + 217, /* (115) db_optr ::= db_optr wal */ + 217, /* (116) db_optr ::= db_optr fsync */ + 217, /* (117) db_optr ::= db_optr comp */ + 217, /* (118) db_optr ::= db_optr prec */ + 217, /* (119) db_optr ::= db_optr keep */ + 217, /* (120) db_optr ::= db_optr update */ + 217, /* (121) db_optr ::= db_optr cachelast */ + 218, /* (122) topic_optr ::= db_optr */ + 218, /* (123) topic_optr ::= topic_optr partitions */ + 212, /* (124) alter_db_optr ::= */ + 212, /* (125) alter_db_optr ::= alter_db_optr replica */ + 212, /* (126) alter_db_optr ::= alter_db_optr quorum */ + 212, /* (127) alter_db_optr ::= alter_db_optr keep */ + 212, /* (128) alter_db_optr ::= alter_db_optr blocks */ + 212, /* (129) alter_db_optr ::= alter_db_optr comp */ + 212, /* (130) alter_db_optr ::= alter_db_optr update */ + 212, /* (131) alter_db_optr ::= alter_db_optr cachelast */ + 212, /* (132) alter_db_optr ::= alter_db_optr minrows */ + 213, /* (133) alter_topic_optr ::= alter_db_optr */ + 213, /* (134) alter_topic_optr ::= alter_topic_optr partitions */ + 219, /* (135) typename ::= ids */ + 219, /* (136) typename ::= ids LP signed RP */ + 219, /* (137) typename ::= ids UNSIGNED */ + 248, /* (138) signed ::= INTEGER */ + 248, /* (139) signed ::= PLUS INTEGER */ + 248, /* (140) signed ::= MINUS INTEGER */ + 207, /* (141) cmd ::= CREATE TABLE create_table_args */ + 207, /* (142) cmd ::= CREATE TABLE create_stable_args */ + 207, /* (143) cmd ::= CREATE STABLE create_stable_args */ + 207, /* (144) cmd ::= CREATE TABLE create_table_list */ + 251, /* (145) create_table_list ::= create_from_stable */ + 251, /* (146) create_table_list ::= create_table_list create_from_stable */ + 249, /* (147) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + 250, /* (148) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + 252, /* (149) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + 252, /* (150) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + 255, /* (151) tagNamelist ::= tagNamelist COMMA ids */ + 255, /* (152) tagNamelist ::= ids */ + 249, /* (153) create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select */ + 256, /* (154) to_opt ::= */ + 256, /* (155) to_opt ::= TO ids cpxName */ + 257, /* (156) split_opt ::= */ + 257, /* (157) split_opt ::= SPLIT ids */ + 253, /* (158) columnlist ::= columnlist COMMA column */ + 253, /* (159) columnlist ::= column */ + 260, /* (160) column ::= ids typename */ + 254, /* (161) tagitemlist ::= tagitemlist COMMA tagitem */ + 254, /* (162) tagitemlist ::= tagitem */ + 261, /* (163) tagitem ::= INTEGER */ + 261, /* (164) tagitem ::= FLOAT */ + 261, /* (165) tagitem ::= STRING */ + 261, /* (166) tagitem ::= BOOL */ + 261, /* (167) tagitem ::= NULL */ + 261, /* (168) tagitem ::= NOW */ + 261, /* (169) tagitem ::= NOW PLUS VARIABLE */ + 261, /* (170) tagitem ::= NOW MINUS VARIABLE */ + 261, /* (171) tagitem ::= MINUS INTEGER */ + 261, /* (172) tagitem ::= MINUS FLOAT */ + 261, /* (173) tagitem ::= PLUS INTEGER */ + 261, /* (174) tagitem ::= PLUS FLOAT */ + 258, /* (175) select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + 258, /* (176) select ::= LP select RP */ + 276, /* (177) union ::= select */ + 276, /* (178) union ::= union UNION ALL select */ + 207, /* (179) cmd ::= union */ + 258, /* (180) select ::= SELECT selcollist */ + 277, /* (181) sclp ::= selcollist COMMA */ + 277, /* (182) sclp ::= */ + 262, /* (183) selcollist ::= sclp distinct expr as */ + 262, /* (184) selcollist ::= sclp STAR */ + 280, /* (185) as ::= AS ids */ + 280, /* (186) as ::= ids */ + 280, /* (187) as ::= */ + 278, /* (188) distinct ::= DISTINCT */ + 278, /* (189) distinct ::= */ + 263, /* (190) from ::= FROM tablelist */ + 263, /* (191) from ::= FROM sub */ + 282, /* (192) sub ::= LP union RP */ + 282, /* (193) sub ::= LP union RP ids */ + 282, /* (194) sub ::= sub COMMA LP union RP ids */ + 281, /* (195) tablelist ::= ids cpxName */ + 281, /* (196) tablelist ::= ids cpxName ids */ + 281, /* (197) tablelist ::= tablelist COMMA ids cpxName */ + 281, /* (198) tablelist ::= tablelist COMMA ids cpxName ids */ + 283, /* (199) tmvar ::= VARIABLE */ + 284, /* (200) timestamp ::= INTEGER */ + 284, /* (201) timestamp ::= MINUS INTEGER */ + 284, /* (202) timestamp ::= PLUS INTEGER */ + 284, /* (203) timestamp ::= STRING */ + 284, /* (204) timestamp ::= NOW */ + 284, /* (205) timestamp ::= NOW PLUS VARIABLE */ + 284, /* (206) timestamp ::= NOW MINUS VARIABLE */ + 265, /* (207) range_option ::= */ + 265, /* (208) range_option ::= RANGE LP timestamp COMMA timestamp RP */ + 266, /* (209) interval_option ::= intervalKey LP tmvar RP */ + 266, /* (210) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + 266, /* (211) interval_option ::= */ + 285, /* (212) intervalKey ::= INTERVAL */ + 285, /* (213) intervalKey ::= EVERY */ + 268, /* (214) session_option ::= */ + 268, /* (215) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + 269, /* (216) windowstate_option ::= */ + 269, /* (217) windowstate_option ::= STATE_WINDOW LP ids RP */ + 270, /* (218) fill_opt ::= */ + 270, /* (219) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + 270, /* (220) fill_opt ::= FILL LP ID RP */ + 267, /* (221) sliding_opt ::= SLIDING LP tmvar RP */ + 267, /* (222) sliding_opt ::= */ + 273, /* (223) orderby_opt ::= */ + 273, /* (224) orderby_opt ::= ORDER BY sortlist */ + 286, /* (225) sortlist ::= sortlist COMMA item sortorder */ + 286, /* (226) sortlist ::= sortlist COMMA arrow sortorder */ + 286, /* (227) sortlist ::= item sortorder */ + 286, /* (228) sortlist ::= arrow sortorder */ + 287, /* (229) item ::= ID */ + 287, /* (230) item ::= ID DOT ID */ + 288, /* (231) sortorder ::= ASC */ + 288, /* (232) sortorder ::= DESC */ + 288, /* (233) sortorder ::= */ + 271, /* (234) groupby_opt ::= */ + 271, /* (235) groupby_opt ::= GROUP BY grouplist */ + 290, /* (236) grouplist ::= grouplist COMMA item */ + 290, /* (237) grouplist ::= grouplist COMMA arrow */ + 290, /* (238) grouplist ::= item */ + 290, /* (239) grouplist ::= arrow */ + 272, /* (240) having_opt ::= */ + 272, /* (241) having_opt ::= HAVING expr */ + 275, /* (242) limit_opt ::= */ + 275, /* (243) limit_opt ::= LIMIT signed */ + 275, /* (244) limit_opt ::= LIMIT signed OFFSET signed */ + 275, /* (245) limit_opt ::= LIMIT signed COMMA signed */ + 274, /* (246) slimit_opt ::= */ + 274, /* (247) slimit_opt ::= SLIMIT signed */ + 274, /* (248) slimit_opt ::= SLIMIT signed SOFFSET signed */ + 274, /* (249) slimit_opt ::= SLIMIT signed COMMA signed */ + 264, /* (250) where_opt ::= */ + 264, /* (251) where_opt ::= WHERE expr */ + 279, /* (252) expr ::= LP expr RP */ + 279, /* (253) expr ::= ID */ + 279, /* (254) expr ::= ID DOT ID */ + 279, /* (255) expr ::= ID DOT STAR */ + 279, /* (256) expr ::= INTEGER */ + 279, /* (257) expr ::= MINUS INTEGER */ + 279, /* (258) expr ::= PLUS INTEGER */ + 279, /* (259) expr ::= FLOAT */ + 279, /* (260) expr ::= MINUS FLOAT */ + 279, /* (261) expr ::= PLUS FLOAT */ + 279, /* (262) expr ::= STRING */ + 279, /* (263) expr ::= NOW */ + 279, /* (264) expr ::= TODAY */ + 279, /* (265) expr ::= VARIABLE */ + 279, /* (266) expr ::= PLUS VARIABLE */ + 279, /* (267) expr ::= MINUS VARIABLE */ + 279, /* (268) expr ::= BOOL */ + 279, /* (269) expr ::= NULL */ + 279, /* (270) expr ::= ID LP exprlist RP */ + 279, /* (271) expr ::= ID LP STAR RP */ + 279, /* (272) expr ::= ID LP expr AS typename RP */ + 279, /* (273) expr ::= expr IS NULL */ + 279, /* (274) expr ::= expr IS NOT NULL */ + 279, /* (275) expr ::= expr LT expr */ + 279, /* (276) expr ::= expr GT expr */ + 279, /* (277) expr ::= expr LE expr */ + 279, /* (278) expr ::= expr GE expr */ + 279, /* (279) expr ::= expr NE expr */ + 279, /* (280) expr ::= expr EQ expr */ + 279, /* (281) expr ::= expr BETWEEN expr AND expr */ + 279, /* (282) expr ::= expr AND expr */ + 279, /* (283) expr ::= expr OR expr */ + 279, /* (284) expr ::= expr PLUS expr */ + 279, /* (285) expr ::= expr MINUS expr */ + 279, /* (286) expr ::= expr STAR expr */ + 279, /* (287) expr ::= expr SLASH expr */ + 279, /* (288) expr ::= expr REM expr */ + 279, /* (289) expr ::= expr BITAND expr */ + 279, /* (290) expr ::= expr BITOR expr */ + 279, /* (291) expr ::= expr BITXOR expr */ + 279, /* (292) expr ::= BITNOT expr */ + 279, /* (293) expr ::= expr LSHIFT expr */ + 279, /* (294) expr ::= expr RSHIFT expr */ + 279, /* (295) expr ::= expr LIKE expr */ + 279, /* (296) expr ::= expr MATCH expr */ + 279, /* (297) expr ::= expr NMATCH expr */ + 279, /* (298) expr ::= ID CONTAINS STRING */ + 279, /* (299) expr ::= ID DOT ID CONTAINS STRING */ + 289, /* (300) arrow ::= ID ARROW STRING */ + 289, /* (301) arrow ::= ID DOT ID ARROW STRING */ + 279, /* (302) expr ::= arrow */ + 279, /* (303) expr ::= expr IN LP exprlist RP */ + 215, /* (304) exprlist ::= exprlist COMMA expritem */ + 215, /* (305) exprlist ::= expritem */ + 291, /* (306) expritem ::= expr */ + 291, /* (307) expritem ::= */ + 207, /* (308) cmd ::= RESET QUERY CACHE */ + 207, /* (309) cmd ::= SYNCDB ids REPLICA */ + 207, /* (310) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + 207, /* (311) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + 207, /* (312) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + 207, /* (313) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + 207, /* (314) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + 207, /* (315) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + 207, /* (316) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + 207, /* (317) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + 207, /* (318) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + 207, /* (319) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + 207, /* (320) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + 207, /* (321) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + 207, /* (322) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + 207, /* (323) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + 207, /* (324) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + 207, /* (325) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + 207, /* (326) cmd ::= KILL CONNECTION INTEGER */ + 207, /* (327) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + 207, /* (328) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + 207, /* (329) cmd ::= DELETE FROM ifexists ids cpxName where_opt */ +}; + +/* 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 STRING */ + -3, /* (26) cmd ::= SHOW dbPrefix STABLES */ + -5, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE STRING */ + -3, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ + -5, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ + -5, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ + -4, /* (31) cmd ::= DROP DATABASE ifexists ids */ + -4, /* (32) cmd ::= DROP TOPIC ifexists ids */ + -3, /* (33) cmd ::= DROP FUNCTION ids */ + -3, /* (34) cmd ::= DROP DNODE ids */ + -3, /* (35) cmd ::= DROP USER ids */ + -3, /* (36) cmd ::= DROP ACCOUNT ids */ + -2, /* (37) cmd ::= USE ids */ + -3, /* (38) cmd ::= DESCRIBE ids cpxName */ + -3, /* (39) cmd ::= DESC ids cpxName */ + -5, /* (40) cmd ::= ALTER USER ids PASS ids */ + -5, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ + -5, /* (42) cmd ::= ALTER USER ids TAGS ids */ + -4, /* (43) cmd ::= ALTER DNODE ids ids */ + -5, /* (44) cmd ::= ALTER DNODE ids ids ids */ + -3, /* (45) cmd ::= ALTER LOCAL ids */ + -4, /* (46) cmd ::= ALTER LOCAL ids ids */ + -4, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */ + -4, /* (48) cmd ::= ALTER TOPIC ids alter_topic_optr */ + -4, /* (49) cmd ::= ALTER ACCOUNT ids acct_optr */ + -6, /* (50) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + -6, /* (51) cmd ::= COMPACT VNODES IN LP exprlist RP */ + -1, /* (52) ids ::= ID */ + -1, /* (53) ids ::= STRING */ + -2, /* (54) ifexists ::= IF EXISTS */ + 0, /* (55) ifexists ::= */ + -3, /* (56) ifnotexists ::= IF NOT EXISTS */ + 0, /* (57) ifnotexists ::= */ + -3, /* (58) cmd ::= CREATE DNODE ids */ + -6, /* (59) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + -5, /* (60) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + -5, /* (61) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ + -8, /* (62) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + -9, /* (63) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + -5, /* (64) cmd ::= CREATE USER ids PASS ids */ + -7, /* (65) cmd ::= CREATE USER ids PASS ids TAGS ids */ + 0, /* (66) bufsize ::= */ + -2, /* (67) bufsize ::= BUFSIZE INTEGER */ + 0, /* (68) pps ::= */ + -2, /* (69) pps ::= PPS INTEGER */ + 0, /* (70) tseries ::= */ + -2, /* (71) tseries ::= TSERIES INTEGER */ + 0, /* (72) dbs ::= */ + -2, /* (73) dbs ::= DBS INTEGER */ + 0, /* (74) streams ::= */ + -2, /* (75) streams ::= STREAMS INTEGER */ + 0, /* (76) storage ::= */ + -2, /* (77) storage ::= STORAGE INTEGER */ + 0, /* (78) qtime ::= */ + -2, /* (79) qtime ::= QTIME INTEGER */ + 0, /* (80) users ::= */ + -2, /* (81) users ::= USERS INTEGER */ + 0, /* (82) conns ::= */ + -2, /* (83) conns ::= CONNS INTEGER */ + 0, /* (84) state ::= */ + -2, /* (85) state ::= STATE ids */ + -9, /* (86) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + -3, /* (87) intitemlist ::= intitemlist COMMA intitem */ + -1, /* (88) intitemlist ::= intitem */ + -1, /* (89) intitem ::= INTEGER */ + -2, /* (90) keep ::= KEEP intitemlist */ + -2, /* (91) cache ::= CACHE INTEGER */ + -2, /* (92) replica ::= REPLICA INTEGER */ + -2, /* (93) quorum ::= QUORUM INTEGER */ + -2, /* (94) days ::= DAYS INTEGER */ + -2, /* (95) minrows ::= MINROWS INTEGER */ + -2, /* (96) maxrows ::= MAXROWS INTEGER */ + -2, /* (97) blocks ::= BLOCKS INTEGER */ + -2, /* (98) ctime ::= CTIME INTEGER */ + -2, /* (99) wal ::= WAL INTEGER */ + -2, /* (100) fsync ::= FSYNC INTEGER */ + -2, /* (101) comp ::= COMP INTEGER */ + -2, /* (102) prec ::= PRECISION STRING */ + -2, /* (103) update ::= UPDATE INTEGER */ + -2, /* (104) cachelast ::= CACHELAST INTEGER */ + -2, /* (105) partitions ::= PARTITIONS INTEGER */ + 0, /* (106) db_optr ::= */ + -2, /* (107) db_optr ::= db_optr cache */ + -2, /* (108) db_optr ::= db_optr replica */ + -2, /* (109) db_optr ::= db_optr quorum */ + -2, /* (110) db_optr ::= db_optr days */ + -2, /* (111) db_optr ::= db_optr minrows */ + -2, /* (112) db_optr ::= db_optr maxrows */ + -2, /* (113) db_optr ::= db_optr blocks */ + -2, /* (114) db_optr ::= db_optr ctime */ + -2, /* (115) db_optr ::= db_optr wal */ + -2, /* (116) db_optr ::= db_optr fsync */ + -2, /* (117) db_optr ::= db_optr comp */ + -2, /* (118) db_optr ::= db_optr prec */ + -2, /* (119) db_optr ::= db_optr keep */ + -2, /* (120) db_optr ::= db_optr update */ + -2, /* (121) db_optr ::= db_optr cachelast */ + -1, /* (122) topic_optr ::= db_optr */ + -2, /* (123) topic_optr ::= topic_optr partitions */ + 0, /* (124) alter_db_optr ::= */ + -2, /* (125) alter_db_optr ::= alter_db_optr replica */ + -2, /* (126) alter_db_optr ::= alter_db_optr quorum */ + -2, /* (127) alter_db_optr ::= alter_db_optr keep */ + -2, /* (128) alter_db_optr ::= alter_db_optr blocks */ + -2, /* (129) alter_db_optr ::= alter_db_optr comp */ + -2, /* (130) alter_db_optr ::= alter_db_optr update */ + -2, /* (131) alter_db_optr ::= alter_db_optr cachelast */ + -2, /* (132) alter_db_optr ::= alter_db_optr minrows */ + -1, /* (133) alter_topic_optr ::= alter_db_optr */ + -2, /* (134) alter_topic_optr ::= alter_topic_optr partitions */ + -1, /* (135) typename ::= ids */ + -4, /* (136) typename ::= ids LP signed RP */ + -2, /* (137) typename ::= ids UNSIGNED */ + -1, /* (138) signed ::= INTEGER */ + -2, /* (139) signed ::= PLUS INTEGER */ + -2, /* (140) signed ::= MINUS INTEGER */ + -3, /* (141) cmd ::= CREATE TABLE create_table_args */ + -3, /* (142) cmd ::= CREATE TABLE create_stable_args */ + -3, /* (143) cmd ::= CREATE STABLE create_stable_args */ + -3, /* (144) cmd ::= CREATE TABLE create_table_list */ + -1, /* (145) create_table_list ::= create_from_stable */ + -2, /* (146) create_table_list ::= create_table_list create_from_stable */ + -6, /* (147) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + -10, /* (148) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + -10, /* (149) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + -13, /* (150) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + -3, /* (151) tagNamelist ::= tagNamelist COMMA ids */ + -1, /* (152) tagNamelist ::= ids */ + -7, /* (153) create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select */ + 0, /* (154) to_opt ::= */ + -3, /* (155) to_opt ::= TO ids cpxName */ + 0, /* (156) split_opt ::= */ + -2, /* (157) split_opt ::= SPLIT ids */ + -3, /* (158) columnlist ::= columnlist COMMA column */ + -1, /* (159) columnlist ::= column */ + -2, /* (160) column ::= ids typename */ + -3, /* (161) tagitemlist ::= tagitemlist COMMA tagitem */ + -1, /* (162) tagitemlist ::= tagitem */ + -1, /* (163) tagitem ::= INTEGER */ + -1, /* (164) tagitem ::= FLOAT */ + -1, /* (165) tagitem ::= STRING */ + -1, /* (166) tagitem ::= BOOL */ + -1, /* (167) tagitem ::= NULL */ + -1, /* (168) tagitem ::= NOW */ + -3, /* (169) tagitem ::= NOW PLUS VARIABLE */ + -3, /* (170) tagitem ::= NOW MINUS VARIABLE */ + -2, /* (171) tagitem ::= MINUS INTEGER */ + -2, /* (172) tagitem ::= MINUS FLOAT */ + -2, /* (173) tagitem ::= PLUS INTEGER */ + -2, /* (174) tagitem ::= PLUS FLOAT */ + -15, /* (175) select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + -3, /* (176) select ::= LP select RP */ + -1, /* (177) union ::= select */ + -4, /* (178) union ::= union UNION ALL select */ + -1, /* (179) cmd ::= union */ + -2, /* (180) select ::= SELECT selcollist */ + -2, /* (181) sclp ::= selcollist COMMA */ + 0, /* (182) sclp ::= */ + -4, /* (183) selcollist ::= sclp distinct expr as */ + -2, /* (184) selcollist ::= sclp STAR */ + -2, /* (185) as ::= AS ids */ + -1, /* (186) as ::= ids */ + 0, /* (187) as ::= */ + -1, /* (188) distinct ::= DISTINCT */ + 0, /* (189) distinct ::= */ + -2, /* (190) from ::= FROM tablelist */ + -2, /* (191) from ::= FROM sub */ + -3, /* (192) sub ::= LP union RP */ + -4, /* (193) sub ::= LP union RP ids */ + -6, /* (194) sub ::= sub COMMA LP union RP ids */ + -2, /* (195) tablelist ::= ids cpxName */ + -3, /* (196) tablelist ::= ids cpxName ids */ + -4, /* (197) tablelist ::= tablelist COMMA ids cpxName */ + -5, /* (198) tablelist ::= tablelist COMMA ids cpxName ids */ + -1, /* (199) tmvar ::= VARIABLE */ + -1, /* (200) timestamp ::= INTEGER */ + -2, /* (201) timestamp ::= MINUS INTEGER */ + -2, /* (202) timestamp ::= PLUS INTEGER */ + -1, /* (203) timestamp ::= STRING */ + -1, /* (204) timestamp ::= NOW */ + -3, /* (205) timestamp ::= NOW PLUS VARIABLE */ + -3, /* (206) timestamp ::= NOW MINUS VARIABLE */ + 0, /* (207) range_option ::= */ + -6, /* (208) range_option ::= RANGE LP timestamp COMMA timestamp RP */ + -4, /* (209) interval_option ::= intervalKey LP tmvar RP */ + -6, /* (210) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + 0, /* (211) interval_option ::= */ + -1, /* (212) intervalKey ::= INTERVAL */ + -1, /* (213) intervalKey ::= EVERY */ + 0, /* (214) session_option ::= */ + -7, /* (215) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + 0, /* (216) windowstate_option ::= */ + -4, /* (217) windowstate_option ::= STATE_WINDOW LP ids RP */ + 0, /* (218) fill_opt ::= */ + -6, /* (219) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + -4, /* (220) fill_opt ::= FILL LP ID RP */ + -4, /* (221) sliding_opt ::= SLIDING LP tmvar RP */ + 0, /* (222) sliding_opt ::= */ + 0, /* (223) orderby_opt ::= */ + -3, /* (224) orderby_opt ::= ORDER BY sortlist */ + -4, /* (225) sortlist ::= sortlist COMMA item sortorder */ + -4, /* (226) sortlist ::= sortlist COMMA arrow sortorder */ + -2, /* (227) sortlist ::= item sortorder */ + -2, /* (228) sortlist ::= arrow sortorder */ + -1, /* (229) item ::= ID */ + -3, /* (230) item ::= ID DOT ID */ + -1, /* (231) sortorder ::= ASC */ + -1, /* (232) sortorder ::= DESC */ + 0, /* (233) sortorder ::= */ + 0, /* (234) groupby_opt ::= */ + -3, /* (235) groupby_opt ::= GROUP BY grouplist */ + -3, /* (236) grouplist ::= grouplist COMMA item */ + -3, /* (237) grouplist ::= grouplist COMMA arrow */ + -1, /* (238) grouplist ::= item */ + -1, /* (239) grouplist ::= arrow */ + 0, /* (240) having_opt ::= */ + -2, /* (241) having_opt ::= HAVING expr */ + 0, /* (242) limit_opt ::= */ + -2, /* (243) limit_opt ::= LIMIT signed */ + -4, /* (244) limit_opt ::= LIMIT signed OFFSET signed */ + -4, /* (245) limit_opt ::= LIMIT signed COMMA signed */ + 0, /* (246) slimit_opt ::= */ + -2, /* (247) slimit_opt ::= SLIMIT signed */ + -4, /* (248) slimit_opt ::= SLIMIT signed SOFFSET signed */ + -4, /* (249) slimit_opt ::= SLIMIT signed COMMA signed */ + 0, /* (250) where_opt ::= */ + -2, /* (251) where_opt ::= WHERE expr */ + -3, /* (252) expr ::= LP expr RP */ + -1, /* (253) expr ::= ID */ + -3, /* (254) expr ::= ID DOT ID */ + -3, /* (255) expr ::= ID DOT STAR */ + -1, /* (256) expr ::= INTEGER */ + -2, /* (257) expr ::= MINUS INTEGER */ + -2, /* (258) expr ::= PLUS INTEGER */ + -1, /* (259) expr ::= FLOAT */ + -2, /* (260) expr ::= MINUS FLOAT */ + -2, /* (261) expr ::= PLUS FLOAT */ + -1, /* (262) expr ::= STRING */ + -1, /* (263) expr ::= NOW */ + -1, /* (264) expr ::= TODAY */ + -1, /* (265) expr ::= VARIABLE */ + -2, /* (266) expr ::= PLUS VARIABLE */ + -2, /* (267) expr ::= MINUS VARIABLE */ + -1, /* (268) expr ::= BOOL */ + -1, /* (269) expr ::= NULL */ + -4, /* (270) expr ::= ID LP exprlist RP */ + -4, /* (271) expr ::= ID LP STAR RP */ + -6, /* (272) expr ::= ID LP expr AS typename RP */ + -3, /* (273) expr ::= expr IS NULL */ + -4, /* (274) expr ::= expr IS NOT NULL */ + -3, /* (275) expr ::= expr LT expr */ + -3, /* (276) expr ::= expr GT expr */ + -3, /* (277) expr ::= expr LE expr */ + -3, /* (278) expr ::= expr GE expr */ + -3, /* (279) expr ::= expr NE expr */ + -3, /* (280) expr ::= expr EQ expr */ + -5, /* (281) expr ::= expr BETWEEN expr AND expr */ + -3, /* (282) expr ::= expr AND expr */ + -3, /* (283) expr ::= expr OR expr */ + -3, /* (284) expr ::= expr PLUS expr */ + -3, /* (285) expr ::= expr MINUS expr */ + -3, /* (286) expr ::= expr STAR expr */ + -3, /* (287) expr ::= expr SLASH expr */ + -3, /* (288) expr ::= expr REM expr */ + -3, /* (289) expr ::= expr BITAND expr */ + -3, /* (290) expr ::= expr BITOR expr */ + -3, /* (291) expr ::= expr BITXOR expr */ + -2, /* (292) expr ::= BITNOT expr */ + -3, /* (293) expr ::= expr LSHIFT expr */ + -3, /* (294) expr ::= expr RSHIFT expr */ + -3, /* (295) expr ::= expr LIKE expr */ + -3, /* (296) expr ::= expr MATCH expr */ + -3, /* (297) expr ::= expr NMATCH expr */ + -3, /* (298) expr ::= ID CONTAINS STRING */ + -5, /* (299) expr ::= ID DOT ID CONTAINS STRING */ + -3, /* (300) arrow ::= ID ARROW STRING */ + -5, /* (301) arrow ::= ID DOT ID ARROW STRING */ + -1, /* (302) expr ::= arrow */ + -5, /* (303) expr ::= expr IN LP exprlist RP */ + -3, /* (304) exprlist ::= exprlist COMMA expritem */ + -1, /* (305) exprlist ::= expritem */ + -1, /* (306) expritem ::= expr */ + 0, /* (307) expritem ::= */ + -3, /* (308) cmd ::= RESET QUERY CACHE */ + -3, /* (309) cmd ::= SYNCDB ids REPLICA */ + -7, /* (310) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (311) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + -7, /* (312) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + -7, /* (313) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + -7, /* (314) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + -8, /* (315) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + -9, /* (316) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + -7, /* (317) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + -7, /* (318) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + -7, /* (319) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + -7, /* (320) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + -7, /* (321) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + -7, /* (322) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + -8, /* (323) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + -9, /* (324) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + -7, /* (325) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + -3, /* (326) cmd ::= KILL CONNECTION INTEGER */ + -5, /* (327) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + -5, /* (328) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + -6, /* (329) cmd ::= DELETE FROM ifexists ids cpxName where_opt */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2283,30 +2633,34 @@ 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 void yy_reduce( +static YYACTIONTYPE 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 */ - int yyact; /* The next action */ + YYACTIONTYPE 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 = yyRuleInfo[yyruleno].nrhs; + yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno); + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -2324,13 +2678,19 @@ static void yy_reduce( #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); - return; + /* 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; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); - return; + /* 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; } yymsp = yypParser->yytos; } @@ -2349,9 +2709,9 @@ static void yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 140: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==140); - case 141: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==141); - case 142: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==142); + case 141: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==141); + case 142: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==142); + case 143: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==143); {} break; case 1: /* cmd ::= SHOW DATABASES */ @@ -2524,16 +2884,16 @@ static void yy_reduce( 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.yy564, &t);} +{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy342, &t);} break; case 49: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy563);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy299);} 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.yy563);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy299);} break; case 51: /* cmd ::= COMPACT VNODES IN LP exprlist RP */ -{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy367);} +{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy333);} break; case 52: /* ids ::= ID */ case 53: /* ids ::= STRING */ yytestcase(yyruleno==53); @@ -2545,7 +2905,7 @@ static void yy_reduce( break; case 55: /* ifexists ::= */ case 57: /* ifnotexists ::= */ yytestcase(yyruleno==57); - case 188: /* distinct ::= */ yytestcase(yyruleno==188); + case 189: /* distinct ::= */ yytestcase(yyruleno==189); { yymsp[1].minor.yy0.n = 0;} break; case 56: /* ifnotexists ::= IF NOT EXISTS */ @@ -2555,17 +2915,17 @@ static void yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} 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.yy563);} +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy299);} 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.yy564, &yymsp[-2].minor.yy0);} +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy342, &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.yy307, &yymsp[0].minor.yy0, 1);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy263, &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.yy307, &yymsp[0].minor.yy0, 2);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy263, &yymsp[0].minor.yy0, 2);} break; case 64: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, NULL);} @@ -2599,38 +2959,38 @@ static void yy_reduce( break; case 86: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy563.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy563.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy563.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy563.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy563.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy563.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy563.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy563.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy563.stat = yymsp[0].minor.yy0; + yylhsminor.yy299.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy299.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy299.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy299.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy299.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy299.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy299.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy299.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy299.stat = yymsp[0].minor.yy0; } - yymsp[-8].minor.yy563 = yylhsminor.yy563; + yymsp[-8].minor.yy299 = yylhsminor.yy299; break; case 87: /* intitemlist ::= intitemlist COMMA intitem */ - case 160: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==160); -{ yylhsminor.yy367 = tVariantListAppend(yymsp[-2].minor.yy367, &yymsp[0].minor.yy410, -1); } - yymsp[-2].minor.yy367 = yylhsminor.yy367; + case 161: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==161); +{ yylhsminor.yy333 = tVariantListAppend(yymsp[-2].minor.yy333, &yymsp[0].minor.yy42, -1); } + yymsp[-2].minor.yy333 = yylhsminor.yy333; break; case 88: /* intitemlist ::= intitem */ - case 161: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==161); -{ yylhsminor.yy367 = tVariantListAppend(NULL, &yymsp[0].minor.yy410, -1); } - yymsp[0].minor.yy367 = yylhsminor.yy367; + case 162: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==162); +{ yylhsminor.yy333 = tVariantListAppend(NULL, &yymsp[0].minor.yy42, -1); } + yymsp[0].minor.yy333 = yylhsminor.yy333; break; case 89: /* intitem ::= INTEGER */ - case 162: /* tagitem ::= INTEGER */ yytestcase(yyruleno==162); - case 163: /* tagitem ::= FLOAT */ yytestcase(yyruleno==163); - case 164: /* tagitem ::= STRING */ yytestcase(yyruleno==164); - case 165: /* tagitem ::= BOOL */ yytestcase(yyruleno==165); -{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy410, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy410 = yylhsminor.yy410; + case 163: /* tagitem ::= INTEGER */ yytestcase(yyruleno==163); + case 164: /* tagitem ::= FLOAT */ yytestcase(yyruleno==164); + case 165: /* tagitem ::= STRING */ yytestcase(yyruleno==165); + case 166: /* tagitem ::= BOOL */ yytestcase(yyruleno==166); +{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy42, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy42 = yylhsminor.yy42; break; case 90: /* keep ::= KEEP intitemlist */ -{ yymsp[-1].minor.yy367 = yymsp[0].minor.yy367; } +{ yymsp[-1].minor.yy333 = yymsp[0].minor.yy333; } break; case 91: /* cache ::= CACHE INTEGER */ case 92: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==92); @@ -2650,785 +3010,789 @@ static void yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; case 106: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy564); yymsp[1].minor.yy564.dbType = TSDB_DB_TYPE_DEFAULT;} +{setDefaultCreateDbOption(&yymsp[1].minor.yy342); yymsp[1].minor.yy342.dbType = TSDB_DB_TYPE_DEFAULT;} break; case 107: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 108: /* db_optr ::= db_optr replica */ case 125: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==125); -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 109: /* db_optr ::= db_optr quorum */ case 126: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==126); -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 110: /* db_optr ::= db_optr days */ -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 111: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 112: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 113: /* db_optr ::= db_optr blocks */ case 128: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==128); -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 114: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 115: /* db_optr ::= db_optr wal */ -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 116: /* db_optr ::= db_optr fsync */ -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 117: /* db_optr ::= db_optr comp */ case 129: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==129); -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 118: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 119: /* db_optr ::= db_optr keep */ case 127: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==127); -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.keep = yymsp[0].minor.yy367; } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.keep = yymsp[0].minor.yy333; } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 120: /* db_optr ::= db_optr update */ case 130: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==130); -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 121: /* db_optr ::= db_optr cachelast */ case 131: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==131); -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 122: /* topic_optr ::= db_optr */ - case 132: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==132); -{ yylhsminor.yy564 = yymsp[0].minor.yy564; yylhsminor.yy564.dbType = TSDB_DB_TYPE_TOPIC; } - yymsp[0].minor.yy564 = yylhsminor.yy564; + case 133: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==133); +{ yylhsminor.yy342 = yymsp[0].minor.yy342; yylhsminor.yy342.dbType = TSDB_DB_TYPE_TOPIC; } + yymsp[0].minor.yy342 = yylhsminor.yy342; break; case 123: /* topic_optr ::= topic_optr partitions */ - case 133: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==133); -{ yylhsminor.yy564 = yymsp[-1].minor.yy564; yylhsminor.yy564.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + case 134: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==134); +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; break; case 124: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy564); yymsp[1].minor.yy564.dbType = TSDB_DB_TYPE_DEFAULT;} +{ setDefaultCreateDbOption(&yymsp[1].minor.yy342); yymsp[1].minor.yy342.dbType = TSDB_DB_TYPE_DEFAULT;} break; - case 134: /* typename ::= ids */ + case 132: /* alter_db_optr ::= alter_db_optr minrows */ +{ yylhsminor.yy342 = yymsp[-1].minor.yy342; yylhsminor.yy342.minRowsPerBlock = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy342 = yylhsminor.yy342; + break; + case 135: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy307, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy263, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy307 = yylhsminor.yy307; + yymsp[0].minor.yy263 = yylhsminor.yy263; break; - case 135: /* typename ::= ids LP signed RP */ + case 136: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy443 <= 0) { + if (yymsp[-1].minor.yy277 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy307, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy263, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy443; // negative value of name length - tSetColumnType(&yylhsminor.yy307, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy277; // negative value of name length + tSetColumnType(&yylhsminor.yy263, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy307 = yylhsminor.yy307; + yymsp[-3].minor.yy263 = yylhsminor.yy263; break; - case 136: /* typename ::= ids UNSIGNED */ + case 137: /* 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.yy307, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy263, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy307 = yylhsminor.yy307; + yymsp[-1].minor.yy263 = yylhsminor.yy263; break; - case 137: /* signed ::= INTEGER */ -{ yylhsminor.yy443 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy443 = yylhsminor.yy443; + case 138: /* signed ::= INTEGER */ +{ yylhsminor.yy277 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy277 = yylhsminor.yy277; break; - case 138: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy443 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + case 139: /* signed ::= PLUS INTEGER */ +{ yymsp[-1].minor.yy277 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 139: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy443 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} + case 140: /* signed ::= MINUS INTEGER */ +{ yymsp[-1].minor.yy277 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 143: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy74;} + case 144: /* cmd ::= CREATE TABLE create_table_list */ +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy78;} break; - case 144: /* create_table_list ::= create_from_stable */ + case 145: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy110); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy400); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy74 = pCreateTable; + yylhsminor.yy78 = pCreateTable; } - yymsp[0].minor.yy74 = yylhsminor.yy74; + yymsp[0].minor.yy78 = yylhsminor.yy78; break; - case 145: /* create_table_list ::= create_table_list create_from_stable */ + case 146: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy74->childTableInfo, &yymsp[0].minor.yy110); - yylhsminor.yy74 = yymsp[-1].minor.yy74; + taosArrayPush(yymsp[-1].minor.yy78->childTableInfo, &yymsp[0].minor.yy400); + yylhsminor.yy78 = yymsp[-1].minor.yy78; } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + yymsp[-1].minor.yy78 = yylhsminor.yy78; break; - case 146: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 147: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy74 = tSetCreateTableInfo(yymsp[-1].minor.yy367, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy74, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy78 = tSetCreateTableInfo(yymsp[-1].minor.yy333, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy78, 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); } - yymsp[-5].minor.yy74 = yylhsminor.yy74; + yymsp[-5].minor.yy78 = yylhsminor.yy78; break; - case 147: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + case 148: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy74 = tSetCreateTableInfo(yymsp[-5].minor.yy367, yymsp[-1].minor.yy367, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy74, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy78 = tSetCreateTableInfo(yymsp[-5].minor.yy333, yymsp[-1].minor.yy333, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy78, 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); } - yymsp[-9].minor.yy74 = yylhsminor.yy74; + yymsp[-9].minor.yy78 = yylhsminor.yy78; break; - case 148: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + case 149: /* 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.yy110 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy367, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy400 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy333, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy110 = yylhsminor.yy110; + yymsp[-9].minor.yy400 = yylhsminor.yy400; break; - case 149: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + case 150: /* 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.yy110 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy367, yymsp[-1].minor.yy367, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy400 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy333, yymsp[-1].minor.yy333, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } - yymsp[-12].minor.yy110 = yylhsminor.yy110; + yymsp[-12].minor.yy400 = yylhsminor.yy400; break; - case 150: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy367, &yymsp[0].minor.yy0); yylhsminor.yy367 = yymsp[-2].minor.yy367; } - yymsp[-2].minor.yy367 = yylhsminor.yy367; + case 151: /* tagNamelist ::= tagNamelist COMMA ids */ +{taosArrayPush(yymsp[-2].minor.yy333, &yymsp[0].minor.yy0); yylhsminor.yy333 = yymsp[-2].minor.yy333; } + yymsp[-2].minor.yy333 = yylhsminor.yy333; break; - case 151: /* tagNamelist ::= ids */ -{yylhsminor.yy367 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy367, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy367 = yylhsminor.yy367; + case 152: /* tagNamelist ::= ids */ +{yylhsminor.yy333 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy333, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy333 = yylhsminor.yy333; break; - case 152: /* create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select */ + case 153: /* create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select */ { - yylhsminor.yy74 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy426, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy74, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy78 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy144, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy78, NULL, TSDB_SQL_CREATE_TABLE); setCreatedStreamOpt(pInfo, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0); yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-5].minor.yy0, &yymsp[-6].minor.yy0); } - yymsp[-6].minor.yy74 = yylhsminor.yy74; + yymsp[-6].minor.yy78 = yylhsminor.yy78; break; - case 153: /* to_opt ::= */ - case 155: /* split_opt ::= */ yytestcase(yyruleno==155); + case 154: /* to_opt ::= */ + case 156: /* split_opt ::= */ yytestcase(yyruleno==156); {yymsp[1].minor.yy0.n = 0;} break; - case 154: /* to_opt ::= TO ids cpxName */ + case 155: /* to_opt ::= TO ids cpxName */ { yymsp[-2].minor.yy0 = yymsp[-1].minor.yy0; yymsp[-2].minor.yy0.n += yymsp[0].minor.yy0.n; } break; - case 156: /* split_opt ::= SPLIT ids */ + case 157: /* split_opt ::= SPLIT ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} break; - case 157: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy367, &yymsp[0].minor.yy307); yylhsminor.yy367 = yymsp[-2].minor.yy367; } - yymsp[-2].minor.yy367 = yylhsminor.yy367; + case 158: /* columnlist ::= columnlist COMMA column */ +{taosArrayPush(yymsp[-2].minor.yy333, &yymsp[0].minor.yy263); yylhsminor.yy333 = yymsp[-2].minor.yy333; } + yymsp[-2].minor.yy333 = yylhsminor.yy333; break; - case 158: /* columnlist ::= column */ -{yylhsminor.yy367 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy367, &yymsp[0].minor.yy307);} - yymsp[0].minor.yy367 = yylhsminor.yy367; + case 159: /* columnlist ::= column */ +{yylhsminor.yy333 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy333, &yymsp[0].minor.yy263);} + yymsp[0].minor.yy333 = yylhsminor.yy333; break; - case 159: /* column ::= ids typename */ + case 160: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy307, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy307); + tSetColumnInfo(&yylhsminor.yy263, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy263); } - yymsp[-1].minor.yy307 = yylhsminor.yy307; + yymsp[-1].minor.yy263 = yylhsminor.yy263; break; - case 166: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy410, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy410 = yylhsminor.yy410; + case 167: /* tagitem ::= NULL */ +{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy42, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy42 = yylhsminor.yy42; break; - case 167: /* tagitem ::= NOW */ -{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreateExt(&yylhsminor.yy410, &yymsp[0].minor.yy0, TK_NOW, true);} - yymsp[0].minor.yy410 = yylhsminor.yy410; + case 168: /* tagitem ::= NOW */ +{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreateExt(&yylhsminor.yy42, &yymsp[0].minor.yy0, TK_NOW, true);} + yymsp[0].minor.yy42 = yylhsminor.yy42; break; - case 168: /* tagitem ::= NOW PLUS VARIABLE */ + case 169: /* tagitem ::= NOW PLUS VARIABLE */ { yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; - tVariantCreateExt(&yymsp[-2].minor.yy410, &yymsp[0].minor.yy0, TK_PLUS, true); + tVariantCreateExt(&yymsp[-2].minor.yy42, &yymsp[0].minor.yy0, TK_PLUS, true); } break; - case 169: /* tagitem ::= NOW MINUS VARIABLE */ + case 170: /* tagitem ::= NOW MINUS VARIABLE */ { yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; - tVariantCreateExt(&yymsp[-2].minor.yy410, &yymsp[0].minor.yy0, TK_MINUS, true); + tVariantCreateExt(&yymsp[-2].minor.yy42, &yymsp[0].minor.yy0, TK_MINUS, true); } break; - case 170: /* tagitem ::= MINUS INTEGER */ - case 171: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==171); - case 172: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==172); - case 173: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==173); + case 171: /* tagitem ::= MINUS INTEGER */ + case 172: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==172); + case 173: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==173); + case 174: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==174); { 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.yy410, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy42, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy410 = yylhsminor.yy410; + yymsp[-1].minor.yy42 = yylhsminor.yy42; break; - case 174: /* select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + case 175: /* select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { - yylhsminor.yy426 = tSetQuerySqlNode(&yymsp[-14].minor.yy0, yymsp[-13].minor.yy367, yymsp[-12].minor.yy480, yymsp[-11].minor.yy378, yymsp[-4].minor.yy367, yymsp[-2].minor.yy367, &yymsp[-9].minor.yy478, &yymsp[-7].minor.yy373, &yymsp[-6].minor.yy204, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy367, &yymsp[0].minor.yy24, &yymsp[-1].minor.yy24, yymsp[-3].minor.yy378, &yymsp[-10].minor.yy214); + yylhsminor.yy144 = tSetQuerySqlNode(&yymsp[-14].minor.yy0, yymsp[-13].minor.yy333, yymsp[-12].minor.yy516, yymsp[-11].minor.yy194, yymsp[-4].minor.yy333, yymsp[-2].minor.yy333, &yymsp[-9].minor.yy200, &yymsp[-7].minor.yy235, &yymsp[-6].minor.yy248, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy333, &yymsp[0].minor.yy190, &yymsp[-1].minor.yy190, yymsp[-3].minor.yy194, &yymsp[-10].minor.yy132); } - yymsp[-14].minor.yy426 = yylhsminor.yy426; + yymsp[-14].minor.yy144 = yylhsminor.yy144; break; - case 175: /* select ::= LP select RP */ -{yymsp[-2].minor.yy426 = yymsp[-1].minor.yy426;} + case 176: /* select ::= LP select RP */ +{yymsp[-2].minor.yy144 = yymsp[-1].minor.yy144;} break; - case 176: /* union ::= select */ -{ yylhsminor.yy367 = setSubclause(NULL, yymsp[0].minor.yy426); } - yymsp[0].minor.yy367 = yylhsminor.yy367; + case 177: /* union ::= select */ +{ yylhsminor.yy333 = setSubclause(NULL, yymsp[0].minor.yy144); } + yymsp[0].minor.yy333 = yylhsminor.yy333; break; - case 177: /* union ::= union UNION ALL select */ -{ yylhsminor.yy367 = appendSelectClause(yymsp[-3].minor.yy367, yymsp[0].minor.yy426); } - yymsp[-3].minor.yy367 = yylhsminor.yy367; + case 178: /* union ::= union UNION ALL select */ +{ yylhsminor.yy333 = appendSelectClause(yymsp[-3].minor.yy333, yymsp[0].minor.yy144); } + yymsp[-3].minor.yy333 = yylhsminor.yy333; break; - case 178: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy367, NULL, TSDB_SQL_SELECT); } + case 179: /* cmd ::= union */ +{ setSqlInfo(pInfo, yymsp[0].minor.yy333, NULL, TSDB_SQL_SELECT); } break; - case 179: /* select ::= SELECT selcollist */ + case 180: /* select ::= SELECT selcollist */ { - yylhsminor.yy426 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy367, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy144 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy333, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy426 = yylhsminor.yy426; + yymsp[-1].minor.yy144 = yylhsminor.yy144; break; - case 180: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy367 = yymsp[-1].minor.yy367;} - yymsp[-1].minor.yy367 = yylhsminor.yy367; + case 181: /* sclp ::= selcollist COMMA */ +{yylhsminor.yy333 = yymsp[-1].minor.yy333;} + yymsp[-1].minor.yy333 = yylhsminor.yy333; break; - case 181: /* sclp ::= */ - case 222: /* orderby_opt ::= */ yytestcase(yyruleno==222); -{yymsp[1].minor.yy367 = 0;} + case 182: /* sclp ::= */ + case 223: /* orderby_opt ::= */ yytestcase(yyruleno==223); +{yymsp[1].minor.yy333 = 0;} break; - case 182: /* selcollist ::= sclp distinct expr as */ + case 183: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy367 = tSqlExprListAppend(yymsp[-3].minor.yy367, yymsp[-1].minor.yy378, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy333 = tSqlExprListAppend(yymsp[-3].minor.yy333, yymsp[-1].minor.yy194, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-3].minor.yy367 = yylhsminor.yy367; + yymsp[-3].minor.yy333 = yylhsminor.yy333; break; - case 183: /* selcollist ::= sclp STAR */ + case 184: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(pInfo, NULL, TK_ALL); - yylhsminor.yy367 = tSqlExprListAppend(yymsp[-1].minor.yy367, pNode, 0, 0); + yylhsminor.yy333 = tSqlExprListAppend(yymsp[-1].minor.yy333, pNode, 0, 0); } - yymsp[-1].minor.yy367 = yylhsminor.yy367; + yymsp[-1].minor.yy333 = yylhsminor.yy333; break; - case 184: /* as ::= AS ids */ + case 185: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 185: /* as ::= ids */ + case 186: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 186: /* as ::= */ + case 187: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 187: /* distinct ::= DISTINCT */ + case 188: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 189: /* from ::= FROM tablelist */ - case 190: /* from ::= FROM sub */ yytestcase(yyruleno==190); -{yymsp[-1].minor.yy480 = yymsp[0].minor.yy480;} + case 190: /* from ::= FROM tablelist */ + case 191: /* from ::= FROM sub */ yytestcase(yyruleno==191); +{yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} break; - case 191: /* sub ::= LP union RP */ -{yymsp[-2].minor.yy480 = addSubqueryElem(NULL, yymsp[-1].minor.yy367, NULL);} + case 192: /* sub ::= LP union RP */ +{yymsp[-2].minor.yy516 = addSubqueryElem(NULL, yymsp[-1].minor.yy333, NULL);} break; - case 192: /* sub ::= LP union RP ids */ -{yymsp[-3].minor.yy480 = addSubqueryElem(NULL, yymsp[-2].minor.yy367, &yymsp[0].minor.yy0);} + case 193: /* sub ::= LP union RP ids */ +{yymsp[-3].minor.yy516 = addSubqueryElem(NULL, yymsp[-2].minor.yy333, &yymsp[0].minor.yy0);} break; - case 193: /* sub ::= sub COMMA LP union RP ids */ -{yylhsminor.yy480 = addSubqueryElem(yymsp[-5].minor.yy480, yymsp[-2].minor.yy367, &yymsp[0].minor.yy0);} - yymsp[-5].minor.yy480 = yylhsminor.yy480; + case 194: /* sub ::= sub COMMA LP union RP ids */ +{yylhsminor.yy516 = addSubqueryElem(yymsp[-5].minor.yy516, yymsp[-2].minor.yy333, &yymsp[0].minor.yy0);} + yymsp[-5].minor.yy516 = yylhsminor.yy516; break; - case 194: /* tablelist ::= ids cpxName */ + case 195: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy480 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy516 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } - yymsp[-1].minor.yy480 = yylhsminor.yy480; + yymsp[-1].minor.yy516 = yylhsminor.yy516; break; - case 195: /* tablelist ::= ids cpxName ids */ + case 196: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy480 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy516 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy480 = yylhsminor.yy480; + yymsp[-2].minor.yy516 = yylhsminor.yy516; break; - case 196: /* tablelist ::= tablelist COMMA ids cpxName */ + case 197: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy480 = setTableNameList(yymsp[-3].minor.yy480, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy516 = setTableNameList(yymsp[-3].minor.yy516, &yymsp[-1].minor.yy0, NULL); } - yymsp[-3].minor.yy480 = yylhsminor.yy480; + yymsp[-3].minor.yy516 = yylhsminor.yy516; break; - case 197: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 198: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy480 = setTableNameList(yymsp[-4].minor.yy480, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy516 = setTableNameList(yymsp[-4].minor.yy516, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-4].minor.yy480 = yylhsminor.yy480; + yymsp[-4].minor.yy516 = yylhsminor.yy516; break; - case 198: /* tmvar ::= VARIABLE */ + case 199: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 199: /* timestamp ::= INTEGER */ -{ yylhsminor.yy378 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 200: /* timestamp ::= INTEGER */ +{ yylhsminor.yy194 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 200: /* timestamp ::= MINUS INTEGER */ - case 201: /* timestamp ::= PLUS INTEGER */ yytestcase(yyruleno==201); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy378 = tSqlExprCreateTimestamp(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy378 = yylhsminor.yy378; + case 201: /* timestamp ::= MINUS INTEGER */ + case 202: /* timestamp ::= PLUS INTEGER */ yytestcase(yyruleno==202); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy194 = tSqlExprCreateTimestamp(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy194 = yylhsminor.yy194; break; - case 202: /* timestamp ::= STRING */ -{ yylhsminor.yy378 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 203: /* timestamp ::= STRING */ +{ yylhsminor.yy194 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 203: /* timestamp ::= NOW */ -{ yylhsminor.yy378 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 204: /* timestamp ::= NOW */ +{ yylhsminor.yy194 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 204: /* timestamp ::= NOW PLUS VARIABLE */ -{yymsp[-2].minor.yy378 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_PLUS); } + case 205: /* timestamp ::= NOW PLUS VARIABLE */ +{yymsp[-2].minor.yy194 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_PLUS); } break; - case 205: /* timestamp ::= NOW MINUS VARIABLE */ -{yymsp[-2].minor.yy378 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_MINUS); } + case 206: /* timestamp ::= NOW MINUS VARIABLE */ +{yymsp[-2].minor.yy194 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_MINUS); } break; - case 206: /* range_option ::= */ -{yymsp[1].minor.yy214.start = 0; yymsp[1].minor.yy214.end = 0;} + case 207: /* range_option ::= */ +{yymsp[1].minor.yy132.start = 0; yymsp[1].minor.yy132.end = 0;} break; - case 207: /* range_option ::= RANGE LP timestamp COMMA timestamp RP */ -{yymsp[-5].minor.yy214.start = yymsp[-3].minor.yy378; yymsp[-5].minor.yy214.end = yymsp[-1].minor.yy378;} + case 208: /* range_option ::= RANGE LP timestamp COMMA timestamp RP */ +{yymsp[-5].minor.yy132.start = yymsp[-3].minor.yy194; yymsp[-5].minor.yy132.end = yymsp[-1].minor.yy194;} break; - case 208: /* interval_option ::= intervalKey LP tmvar RP */ -{yylhsminor.yy478.interval = yymsp[-1].minor.yy0; yylhsminor.yy478.offset.n = 0; yylhsminor.yy478.token = yymsp[-3].minor.yy586;} - yymsp[-3].minor.yy478 = yylhsminor.yy478; + case 209: /* interval_option ::= intervalKey LP tmvar RP */ +{yylhsminor.yy200.interval = yymsp[-1].minor.yy0; yylhsminor.yy200.offset.n = 0; yylhsminor.yy200.token = yymsp[-3].minor.yy44;} + yymsp[-3].minor.yy200 = yylhsminor.yy200; break; - case 209: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ -{yylhsminor.yy478.interval = yymsp[-3].minor.yy0; yylhsminor.yy478.offset = yymsp[-1].minor.yy0; yylhsminor.yy478.token = yymsp[-5].minor.yy586;} - yymsp[-5].minor.yy478 = yylhsminor.yy478; + case 210: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ +{yylhsminor.yy200.interval = yymsp[-3].minor.yy0; yylhsminor.yy200.offset = yymsp[-1].minor.yy0; yylhsminor.yy200.token = yymsp[-5].minor.yy44;} + yymsp[-5].minor.yy200 = yylhsminor.yy200; break; - case 210: /* interval_option ::= */ -{memset(&yymsp[1].minor.yy478, 0, sizeof(yymsp[1].minor.yy478));} + case 211: /* interval_option ::= */ +{memset(&yymsp[1].minor.yy200, 0, sizeof(yymsp[1].minor.yy200));} break; - case 211: /* intervalKey ::= INTERVAL */ -{yymsp[0].minor.yy586 = TK_INTERVAL;} + case 212: /* intervalKey ::= INTERVAL */ +{yymsp[0].minor.yy44 = TK_INTERVAL;} break; - case 212: /* intervalKey ::= EVERY */ -{yymsp[0].minor.yy586 = TK_EVERY; } + case 213: /* intervalKey ::= EVERY */ +{yymsp[0].minor.yy44 = TK_EVERY; } break; - case 213: /* session_option ::= */ -{yymsp[1].minor.yy373.col.n = 0; yymsp[1].minor.yy373.gap.n = 0;} + case 214: /* session_option ::= */ +{yymsp[1].minor.yy235.col.n = 0; yymsp[1].minor.yy235.gap.n = 0;} break; - case 214: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + case 215: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy373.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy373.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy235.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy235.gap = yymsp[-1].minor.yy0; } break; - case 215: /* windowstate_option ::= */ -{ yymsp[1].minor.yy204.col.n = 0; yymsp[1].minor.yy204.col.z = NULL;} + case 216: /* windowstate_option ::= */ +{ yymsp[1].minor.yy248.col.n = 0; yymsp[1].minor.yy248.col.z = NULL;} break; - case 216: /* windowstate_option ::= STATE_WINDOW LP ids RP */ -{ yymsp[-3].minor.yy204.col = yymsp[-1].minor.yy0; } + case 217: /* windowstate_option ::= STATE_WINDOW LP ids RP */ +{ yymsp[-3].minor.yy248.col = yymsp[-1].minor.yy0; } break; - case 217: /* fill_opt ::= */ -{ yymsp[1].minor.yy367 = 0; } + case 218: /* fill_opt ::= */ +{ yymsp[1].minor.yy333 = 0; } break; - case 218: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 219: /* 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.yy367, &A, -1, 0); - yymsp[-5].minor.yy367 = yymsp[-1].minor.yy367; + tVariantListInsert(yymsp[-1].minor.yy333, &A, -1, 0); + yymsp[-5].minor.yy333 = yymsp[-1].minor.yy333; } break; - case 219: /* fill_opt ::= FILL LP ID RP */ + case 220: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy367 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1, true); + yymsp[-3].minor.yy333 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1, true); } break; - case 220: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 221: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 221: /* sliding_opt ::= */ + case 222: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 223: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy367 = yymsp[0].minor.yy367;} + case 224: /* orderby_opt ::= ORDER BY sortlist */ +{yymsp[-2].minor.yy333 = yymsp[0].minor.yy333;} break; - case 224: /* sortlist ::= sortlist COMMA item sortorder */ + case 225: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy367 = commonItemAppend(yymsp[-3].minor.yy367, &yymsp[-1].minor.yy410, NULL, false, yymsp[0].minor.yy274); + yylhsminor.yy333 = commonItemAppend(yymsp[-3].minor.yy333, &yymsp[-1].minor.yy42, NULL, false, yymsp[0].minor.yy133); } - yymsp[-3].minor.yy367 = yylhsminor.yy367; + yymsp[-3].minor.yy333 = yylhsminor.yy333; break; - case 225: /* sortlist ::= sortlist COMMA arrow sortorder */ + case 226: /* sortlist ::= sortlist COMMA arrow sortorder */ { - yylhsminor.yy367 = commonItemAppend(yymsp[-3].minor.yy367, NULL, yymsp[-1].minor.yy378, true, yymsp[0].minor.yy274); + yylhsminor.yy333 = commonItemAppend(yymsp[-3].minor.yy333, NULL, yymsp[-1].minor.yy194, true, yymsp[0].minor.yy133); } - yymsp[-3].minor.yy367 = yylhsminor.yy367; + yymsp[-3].minor.yy333 = yylhsminor.yy333; break; - case 226: /* sortlist ::= item sortorder */ + case 227: /* sortlist ::= item sortorder */ { - yylhsminor.yy367 = commonItemAppend(NULL, &yymsp[-1].minor.yy410, NULL, false, yymsp[0].minor.yy274); + yylhsminor.yy333 = commonItemAppend(NULL, &yymsp[-1].minor.yy42, NULL, false, yymsp[0].minor.yy133); } - yymsp[-1].minor.yy367 = yylhsminor.yy367; + yymsp[-1].minor.yy333 = yylhsminor.yy333; break; - case 227: /* sortlist ::= arrow sortorder */ + case 228: /* sortlist ::= arrow sortorder */ { - yylhsminor.yy367 = commonItemAppend(NULL, NULL, yymsp[-1].minor.yy378, true, yymsp[0].minor.yy274); + yylhsminor.yy333 = commonItemAppend(NULL, NULL, yymsp[-1].minor.yy194, true, yymsp[0].minor.yy133); } - yymsp[-1].minor.yy367 = yylhsminor.yy367; + yymsp[-1].minor.yy333 = yylhsminor.yy333; break; - case 228: /* item ::= ID */ + case 229: /* item ::= ID */ { toTSDBType(yymsp[0].minor.yy0.type); - tVariantCreate(&yylhsminor.yy410, &yymsp[0].minor.yy0); + tVariantCreate(&yylhsminor.yy42, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy410 = yylhsminor.yy410; + yymsp[0].minor.yy42 = yylhsminor.yy42; break; - case 229: /* item ::= ID DOT ID */ + case 230: /* item ::= ID DOT ID */ { toTSDBType(yymsp[-2].minor.yy0.type); yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); - tVariantCreate(&yylhsminor.yy410, &yymsp[-2].minor.yy0); + tVariantCreate(&yylhsminor.yy42, &yymsp[-2].minor.yy0); } - yymsp[-2].minor.yy410 = yylhsminor.yy410; + yymsp[-2].minor.yy42 = yylhsminor.yy42; break; - case 230: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy274 = TSDB_ORDER_ASC; } + case 231: /* sortorder ::= ASC */ +{ yymsp[0].minor.yy133 = TSDB_ORDER_ASC; } break; - case 231: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy274 = TSDB_ORDER_DESC;} + case 232: /* sortorder ::= DESC */ +{ yymsp[0].minor.yy133 = TSDB_ORDER_DESC;} break; - case 232: /* sortorder ::= */ -{ yymsp[1].minor.yy274 = TSDB_ORDER_ASC; } + case 233: /* sortorder ::= */ +{ yymsp[1].minor.yy133 = TSDB_ORDER_ASC; } break; - case 233: /* groupby_opt ::= */ -{ yymsp[1].minor.yy367 = 0;} + case 234: /* groupby_opt ::= */ +{ yymsp[1].minor.yy333 = 0;} break; - case 234: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy367 = yymsp[0].minor.yy367;} + case 235: /* groupby_opt ::= GROUP BY grouplist */ +{ yymsp[-2].minor.yy333 = yymsp[0].minor.yy333;} break; - case 235: /* grouplist ::= grouplist COMMA item */ + case 236: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy367 = commonItemAppend(yymsp[-2].minor.yy367, &yymsp[0].minor.yy410, NULL, false, -1); + yylhsminor.yy333 = commonItemAppend(yymsp[-2].minor.yy333, &yymsp[0].minor.yy42, NULL, false, -1); } - yymsp[-2].minor.yy367 = yylhsminor.yy367; + yymsp[-2].minor.yy333 = yylhsminor.yy333; break; - case 236: /* grouplist ::= grouplist COMMA arrow */ + case 237: /* grouplist ::= grouplist COMMA arrow */ { - yylhsminor.yy367 = commonItemAppend(yymsp[-2].minor.yy367, NULL, yymsp[0].minor.yy378, true, -1); + yylhsminor.yy333 = commonItemAppend(yymsp[-2].minor.yy333, NULL, yymsp[0].minor.yy194, true, -1); } - yymsp[-2].minor.yy367 = yylhsminor.yy367; + yymsp[-2].minor.yy333 = yylhsminor.yy333; break; - case 237: /* grouplist ::= item */ + case 238: /* grouplist ::= item */ { - yylhsminor.yy367 = commonItemAppend(NULL, &yymsp[0].minor.yy410, NULL, false, -1); + yylhsminor.yy333 = commonItemAppend(NULL, &yymsp[0].minor.yy42, NULL, false, -1); } - yymsp[0].minor.yy367 = yylhsminor.yy367; + yymsp[0].minor.yy333 = yylhsminor.yy333; break; - case 238: /* grouplist ::= arrow */ + case 239: /* grouplist ::= arrow */ { - yylhsminor.yy367 = commonItemAppend(NULL, NULL, yymsp[0].minor.yy378, true, -1); + yylhsminor.yy333 = commonItemAppend(NULL, NULL, yymsp[0].minor.yy194, true, -1); } - yymsp[0].minor.yy367 = yylhsminor.yy367; + yymsp[0].minor.yy333 = yylhsminor.yy333; break; - case 239: /* having_opt ::= */ - case 249: /* where_opt ::= */ yytestcase(yyruleno==249); - case 306: /* expritem ::= */ yytestcase(yyruleno==306); -{yymsp[1].minor.yy378 = 0;} + case 240: /* having_opt ::= */ + case 250: /* where_opt ::= */ yytestcase(yyruleno==250); + case 307: /* expritem ::= */ yytestcase(yyruleno==307); +{yymsp[1].minor.yy194 = 0;} break; - case 240: /* having_opt ::= HAVING expr */ - case 250: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==250); -{yymsp[-1].minor.yy378 = yymsp[0].minor.yy378;} + case 241: /* having_opt ::= HAVING expr */ + case 251: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==251); +{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;} break; - case 241: /* limit_opt ::= */ - case 245: /* slimit_opt ::= */ yytestcase(yyruleno==245); -{yymsp[1].minor.yy24.limit = -1; yymsp[1].minor.yy24.offset = 0;} + case 242: /* limit_opt ::= */ + case 246: /* slimit_opt ::= */ yytestcase(yyruleno==246); +{yymsp[1].minor.yy190.limit = -1; yymsp[1].minor.yy190.offset = 0;} break; - case 242: /* limit_opt ::= LIMIT signed */ - case 246: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==246); -{yymsp[-1].minor.yy24.limit = yymsp[0].minor.yy443; yymsp[-1].minor.yy24.offset = 0;} + case 243: /* limit_opt ::= LIMIT signed */ + case 247: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==247); +{yymsp[-1].minor.yy190.limit = yymsp[0].minor.yy277; yymsp[-1].minor.yy190.offset = 0;} break; - case 243: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy24.limit = yymsp[-2].minor.yy443; yymsp[-3].minor.yy24.offset = yymsp[0].minor.yy443;} + case 244: /* limit_opt ::= LIMIT signed OFFSET signed */ +{ yymsp[-3].minor.yy190.limit = yymsp[-2].minor.yy277; yymsp[-3].minor.yy190.offset = yymsp[0].minor.yy277;} break; - case 244: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy24.limit = yymsp[0].minor.yy443; yymsp[-3].minor.yy24.offset = yymsp[-2].minor.yy443;} + case 245: /* limit_opt ::= LIMIT signed COMMA signed */ +{ yymsp[-3].minor.yy190.limit = yymsp[0].minor.yy277; yymsp[-3].minor.yy190.offset = yymsp[-2].minor.yy277;} break; - case 247: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy24.limit = yymsp[-2].minor.yy443; yymsp[-3].minor.yy24.offset = yymsp[0].minor.yy443;} + case 248: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ +{yymsp[-3].minor.yy190.limit = yymsp[-2].minor.yy277; yymsp[-3].minor.yy190.offset = yymsp[0].minor.yy277;} break; - case 248: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy24.limit = yymsp[0].minor.yy443; yymsp[-3].minor.yy24.offset = yymsp[-2].minor.yy443;} + case 249: /* slimit_opt ::= SLIMIT signed COMMA signed */ +{yymsp[-3].minor.yy190.limit = yymsp[0].minor.yy277; yymsp[-3].minor.yy190.offset = yymsp[-2].minor.yy277;} break; - case 251: /* expr ::= LP expr RP */ -{yylhsminor.yy378 = yymsp[-1].minor.yy378; yylhsminor.yy378->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy378->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 252: /* expr ::= LP expr RP */ +{yylhsminor.yy194 = yymsp[-1].minor.yy194; yylhsminor.yy194->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy194->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 252: /* expr ::= ID */ -{ yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 253: /* expr ::= ID */ +{ yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 253: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 254: /* expr ::= ID DOT ID */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 254: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 255: /* expr ::= ID DOT STAR */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 255: /* expr ::= INTEGER */ -{ yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 256: /* expr ::= INTEGER */ +{ yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 256: /* expr ::= MINUS INTEGER */ - case 257: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==257); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy378 = yylhsminor.yy378; + case 257: /* expr ::= MINUS INTEGER */ + case 258: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==258); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy194 = yylhsminor.yy194; break; - case 258: /* expr ::= FLOAT */ -{ yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 259: /* expr ::= FLOAT */ +{ yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 259: /* expr ::= MINUS FLOAT */ - case 260: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==260); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy378 = yylhsminor.yy378; + case 260: /* expr ::= MINUS FLOAT */ + case 261: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==261); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy194 = yylhsminor.yy194; break; - case 261: /* expr ::= STRING */ -{ yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 262: /* expr ::= STRING */ +{ yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 262: /* expr ::= NOW */ -{ yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 263: /* expr ::= NOW */ +{ yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 263: /* expr ::= TODAY */ -{ yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_TODAY); } - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 264: /* expr ::= TODAY */ +{ yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_TODAY); } + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 264: /* expr ::= VARIABLE */ -{ yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 265: /* expr ::= VARIABLE */ +{ yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 265: /* expr ::= PLUS VARIABLE */ - case 266: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==266); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_VARIABLE);} - yymsp[-1].minor.yy378 = yylhsminor.yy378; + case 266: /* expr ::= PLUS VARIABLE */ + case 267: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==267); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy194 = yylhsminor.yy194; break; - case 267: /* expr ::= BOOL */ -{ yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 268: /* expr ::= BOOL */ +{ yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 268: /* expr ::= NULL */ -{ yylhsminor.yy378 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NULL);} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 269: /* expr ::= NULL */ +{ yylhsminor.yy194 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 269: /* expr ::= ID LP exprlist RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy378 = tSqlExprCreateFunction(yymsp[-1].minor.yy367, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy378 = yylhsminor.yy378; + case 270: /* expr ::= ID LP exprlist RP */ +{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy194 = tSqlExprCreateFunction(yymsp[-1].minor.yy333, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy194 = yylhsminor.yy194; break; - case 270: /* expr ::= ID LP STAR RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy378 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy378 = yylhsminor.yy378; + case 271: /* expr ::= ID LP STAR RP */ +{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy194 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy194 = yylhsminor.yy194; break; - case 271: /* expr ::= ID LP expr AS typename RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-5].minor.yy0); yylhsminor.yy378 = tSqlExprCreateFuncWithParams(pInfo, yymsp[-3].minor.yy378, &yymsp[-1].minor.yy307, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, yymsp[-5].minor.yy0.type); } - yymsp[-5].minor.yy378 = yylhsminor.yy378; + case 272: /* expr ::= ID LP expr AS typename RP */ +{ tStrTokenAppend(pInfo->funcs, &yymsp[-5].minor.yy0); yylhsminor.yy194 = tSqlExprCreateFuncWithParams(pInfo, yymsp[-3].minor.yy194, &yymsp[-1].minor.yy263, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, yymsp[-5].minor.yy0.type); } + yymsp[-5].minor.yy194 = yylhsminor.yy194; break; - case 272: /* expr ::= expr IS NULL */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, NULL, TK_ISNULL);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 273: /* expr ::= expr IS NULL */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, NULL, TK_ISNULL);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 273: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-3].minor.yy378, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy378 = yylhsminor.yy378; + case 274: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-3].minor.yy194, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy194 = yylhsminor.yy194; break; - case 274: /* expr ::= expr LT expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_LT);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 275: /* expr ::= expr LT expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_LT);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 275: /* expr ::= expr GT expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_GT);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 276: /* expr ::= expr GT expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_GT);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 276: /* expr ::= expr LE expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_LE);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 277: /* expr ::= expr LE expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_LE);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 277: /* expr ::= expr GE expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_GE);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 278: /* expr ::= expr GE expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_GE);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 278: /* expr ::= expr NE expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_NE);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 279: /* expr ::= expr NE expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_NE);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 279: /* expr ::= expr EQ expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_EQ);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 280: /* expr ::= expr EQ expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_EQ);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 280: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy378); yylhsminor.yy378 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy378, yymsp[-2].minor.yy378, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy378, TK_LE), TK_AND);} - yymsp[-4].minor.yy378 = yylhsminor.yy378; + case 281: /* expr ::= expr BETWEEN expr AND expr */ +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy194); yylhsminor.yy194 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy194, yymsp[-2].minor.yy194, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy194, TK_LE), TK_AND);} + yymsp[-4].minor.yy194 = yylhsminor.yy194; break; - case 281: /* expr ::= expr AND expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_AND);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 282: /* expr ::= expr AND expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_AND);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 282: /* expr ::= expr OR expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_OR); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 283: /* expr ::= expr OR expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_OR); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 283: /* expr ::= expr PLUS expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_PLUS); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 284: /* expr ::= expr PLUS expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_PLUS); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 284: /* expr ::= expr MINUS expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_MINUS); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 285: /* expr ::= expr MINUS expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_MINUS); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 285: /* expr ::= expr STAR expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_STAR); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 286: /* expr ::= expr STAR expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_STAR); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 286: /* expr ::= expr SLASH expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_DIVIDE);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 287: /* expr ::= expr SLASH expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_DIVIDE);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 287: /* expr ::= expr REM expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_REM); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 288: /* expr ::= expr REM expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_REM); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 288: /* expr ::= expr BITAND expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_BITAND);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 289: /* expr ::= expr BITAND expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_BITAND);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 289: /* expr ::= expr BITOR expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_BITOR); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 290: /* expr ::= expr BITOR expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_BITOR); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 290: /* expr ::= expr BITXOR expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_BITXOR);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 291: /* expr ::= expr BITXOR expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_BITXOR);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 291: /* expr ::= BITNOT expr */ -{yymsp[-1].minor.yy378 = tSqlExprCreate(yymsp[0].minor.yy378, NULL, TK_BITNOT);} + case 292: /* expr ::= BITNOT expr */ +{yymsp[-1].minor.yy194 = tSqlExprCreate(yymsp[0].minor.yy194, NULL, TK_BITNOT);} break; - case 292: /* expr ::= expr LSHIFT expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_LSHIFT);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 293: /* expr ::= expr LSHIFT expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_LSHIFT);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 293: /* expr ::= expr RSHIFT expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_RSHIFT);} - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 294: /* expr ::= expr RSHIFT expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_RSHIFT);} + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 294: /* expr ::= expr LIKE expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_LIKE); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 295: /* expr ::= expr LIKE expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_LIKE); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 295: /* expr ::= expr MATCH expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_MATCH); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 296: /* expr ::= expr MATCH expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_MATCH); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 296: /* expr ::= expr NMATCH expr */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-2].minor.yy378, yymsp[0].minor.yy378, TK_NMATCH); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 297: /* expr ::= expr NMATCH expr */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-2].minor.yy194, yymsp[0].minor.yy194, TK_NMATCH); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 297: /* expr ::= ID CONTAINS STRING */ -{ tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy378 = tSqlExprCreate(S, M, TK_CONTAINS); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 298: /* expr ::= ID CONTAINS STRING */ +{ tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy194 = tSqlExprCreate(S, M, TK_CONTAINS); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 298: /* expr ::= ID DOT ID CONTAINS STRING */ -{ yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy378 = tSqlExprCreate(S, M, TK_CONTAINS); } - yymsp[-4].minor.yy378 = yylhsminor.yy378; + case 299: /* expr ::= ID DOT ID CONTAINS STRING */ +{ yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy194 = tSqlExprCreate(S, M, TK_CONTAINS); } + yymsp[-4].minor.yy194 = yylhsminor.yy194; break; - case 299: /* arrow ::= ID ARROW STRING */ -{tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy378 = tSqlExprCreate(S, M, TK_ARROW); } - yymsp[-2].minor.yy378 = yylhsminor.yy378; + case 300: /* arrow ::= ID ARROW STRING */ +{tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy194 = tSqlExprCreate(S, M, TK_ARROW); } + yymsp[-2].minor.yy194 = yylhsminor.yy194; break; - case 300: /* arrow ::= ID DOT ID ARROW STRING */ -{yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy378 = tSqlExprCreate(S, M, TK_ARROW); } - yymsp[-4].minor.yy378 = yylhsminor.yy378; + case 301: /* arrow ::= ID DOT ID ARROW STRING */ +{yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy194 = tSqlExprCreate(S, M, TK_ARROW); } + yymsp[-4].minor.yy194 = yylhsminor.yy194; break; - case 301: /* expr ::= arrow */ - case 305: /* expritem ::= expr */ yytestcase(yyruleno==305); -{yylhsminor.yy378 = yymsp[0].minor.yy378;} - yymsp[0].minor.yy378 = yylhsminor.yy378; + case 302: /* expr ::= arrow */ + case 306: /* expritem ::= expr */ yytestcase(yyruleno==306); +{yylhsminor.yy194 = yymsp[0].minor.yy194;} + yymsp[0].minor.yy194 = yylhsminor.yy194; break; - case 302: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy378 = tSqlExprCreate(yymsp[-4].minor.yy378, (tSqlExpr*)yymsp[-1].minor.yy367, TK_IN); } - yymsp[-4].minor.yy378 = yylhsminor.yy378; + case 303: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy194 = tSqlExprCreate(yymsp[-4].minor.yy194, (tSqlExpr*)yymsp[-1].minor.yy333, TK_IN); } + yymsp[-4].minor.yy194 = yylhsminor.yy194; break; - case 303: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy367 = tSqlExprListAppend(yymsp[-2].minor.yy367,yymsp[0].minor.yy378,0, 0);} - yymsp[-2].minor.yy367 = yylhsminor.yy367; + case 304: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy333 = tSqlExprListAppend(yymsp[-2].minor.yy333,yymsp[0].minor.yy194,0, 0);} + yymsp[-2].minor.yy333 = yylhsminor.yy333; break; - case 304: /* exprlist ::= expritem */ -{yylhsminor.yy367 = tSqlExprListAppend(0,yymsp[0].minor.yy378,0, 0);} - yymsp[0].minor.yy367 = yylhsminor.yy367; + case 305: /* exprlist ::= expritem */ +{yylhsminor.yy333 = tSqlExprListAppend(0,yymsp[0].minor.yy194,0, 0);} + yymsp[0].minor.yy333 = yylhsminor.yy333; break; - case 307: /* cmd ::= RESET QUERY CACHE */ + case 308: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 308: /* cmd ::= SYNCDB ids REPLICA */ + case 309: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 309: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 310: /* 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.yy367, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy333, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 310: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 311: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3439,21 +3803,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 311: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 312: /* 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.yy367, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy333, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 312: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 313: /* 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.yy367, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy333, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 313: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 314: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3464,7 +3828,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 314: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 315: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3478,33 +3842,33 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 315: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 316: /* 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, false); - A = tVariantListAppend(A, &yymsp[0].minor.yy410, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy42, -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); } break; - case 316: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 317: /* 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.yy367, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy333, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 317: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 318: /* 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.yy367, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy333, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 318: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 319: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3515,21 +3879,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 319: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 320: /* 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.yy367, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy333, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 320: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 321: /* 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.yy367, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy333, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 321: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 322: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3540,7 +3904,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 322: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 323: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3554,38 +3918,38 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 323: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 324: /* 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, false); - A = tVariantListAppend(A, &yymsp[0].minor.yy410, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy42, -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); } break; - case 324: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 325: /* 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.yy367, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy333, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 325: /* cmd ::= KILL CONNECTION INTEGER */ + case 326: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 326: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 327: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 327: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 328: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; - case 328: /* cmd ::= DELETE FROM ifexists ids cpxName where_opt */ + case 329: /* cmd ::= DELETE FROM ifexists ids cpxName where_opt */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - SDelData * pDelData = tGetDelData(&yymsp[-2].minor.yy0, &yymsp[-3].minor.yy0, yymsp[0].minor.yy378); + SDelData * pDelData = tGetDelData(&yymsp[-2].minor.yy0, &yymsp[-3].minor.yy0, yymsp[0].minor.yy194); setSqlInfo(pInfo, pDelData, NULL, TSDB_SQL_DELETE_DATA); } break; @@ -3593,9 +3957,9 @@ static void yy_reduce( break; /********** End reduce actions ************************************************/ }; - assert( yyrulenostateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact, "... then shift"); + return yyact; } /* @@ -3619,7 +3984,8 @@ static void yy_reduce( static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH; + ParseARG_FETCH + ParseCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); @@ -3630,7 +3996,8 @@ static void yy_parse_failed( ** parser fails */ /************ Begin %parse_failure code ***************************************/ /************ End %parse_failure code *****************************************/ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ + ParseCTX_STORE } #endif /* YYNOERRORRECOVERY */ @@ -3642,7 +4009,8 @@ 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; + ParseARG_FETCH + ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ @@ -3668,7 +4036,8 @@ static void yy_syntax_error( assert(len <= outputBufLen); /************ End %syntax_error code ******************************************/ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ + ParseCTX_STORE } /* @@ -3677,7 +4046,8 @@ static void yy_syntax_error( static void yy_accept( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH; + ParseARG_FETCH + ParseCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); @@ -3692,7 +4062,8 @@ static void yy_accept( /*********** Begin %parse_accept code *****************************************/ /*********** End %parse_accept code *******************************************/ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ + ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ + ParseCTX_STORE } /* The main parser program. @@ -3721,45 +4092,47 @@ void Parse( ParseARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; - unsigned int yyact; /* The parser action. */ + YYACTIONTYPE 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; /* The parser */ + yyParser *yypParser = (yyParser*)yyp; /* The parser */ + ParseCTX_FETCH + ParseARG_STORE - 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 ){ - int stateno = yypParser->yytos->stateno; - if( stateno < YY_MIN_REDUCE ){ + if( yyact < YY_MIN_REDUCE ){ fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", - yyTracePrompt,yyTokenName[yymajor],stateno); + yyTracePrompt,yyTokenName[yymajor],yyact); }else{ fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", - yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE); + yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); } } #endif do{ - yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); + assert( yyact==yypParser->yytos->stateno ); + yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ - yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor); + yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, + yyminor ParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ - yy_shift(yypParser,yyact,yymajor,yyminor); + yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; #endif - yymajor = YYNOCODE; + break; }else if( yyact==YY_ACCEPT_ACTION ){ yypParser->yytos--; yy_accept(yypParser); @@ -3810,10 +4183,9 @@ void Parse( yymajor = YYNOCODE; }else{ while( yypParser->yytos >= yypParser->yystack - && yymx != YYERRORSYMBOL && (yyact = yy_find_reduce_action( yypParser->yytos->stateno, - YYERRORSYMBOL)) >= YY_MIN_REDUCE + YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE ){ yy_pop_parser_stack(yypParser); } @@ -3830,6 +4202,8 @@ 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 @@ -3840,8 +4214,7 @@ void Parse( */ yy_syntax_error(yypParser,yymajor, yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - yymajor = YYNOCODE; - + break; #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** @@ -3863,10 +4236,10 @@ void Parse( yypParser->yyerrcnt = -1; #endif } - yymajor = YYNOCODE; + break; #endif } - }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack ); + }while( yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; @@ -3880,4 +4253,18 @@ void Parse( } #endif return; -} \ No newline at end of file +} + +/* +** 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/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 6566bf9e79f3f58557a80c037e99027cd19753ba..5c385410080f62b94dc481c597f7a6e847cc4d46 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1080,7 +1080,9 @@ static void rpcProcessBrokenLink(SRpcConn *pConn) { pContext->code = TSDB_CODE_RPC_NETWORK_UNAVAIL; pContext->pConn = NULL; pConn->pReqMsg = NULL; - taosTmrStart(rpcProcessConnError, 0, pContext, pRpc->tmrCtrl); + int64_t *rid = malloc(sizeof(int64_t)); + *rid = pContext->rid; + taosTmrStart(rpcProcessConnError, 0, rid, pRpc->tmrCtrl); } if (pConn->inType) rpcReportBrokenLinkToServer(pConn); @@ -1293,7 +1295,9 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead, SRpcReqConte rpcFreeCont(rpcMsg.pCont); } else if (pHead->code == TSDB_CODE_RPC_NOT_READY || pHead->code == TSDB_CODE_APP_NOT_READY || pHead->code == TSDB_CODE_DND_EXITING) { pContext->code = pHead->code; - rpcProcessConnError(pContext, NULL); + int64_t *rid = malloc(sizeof(int64_t)); + *rid = pContext->rid; + rpcProcessConnError(rid, NULL); rpcFreeCont(rpcMsg.pCont); } else { rpcNotifyClient(pContext, &rpcMsg); @@ -1395,7 +1399,9 @@ static TBOOL rpcSendReqToServer(SRpcInfo *pRpc, SRpcReqContext *pContext) { if (pConn == NULL) { pContext->code = terrno; // in rpcProcessConnError if numOfTry over limit, could call rpcNotifyClient to stop query - taosTmrStart(rpcProcessConnError, 1, pContext, pRpc->tmrCtrl); + int64_t *rid = malloc(sizeof(int64_t)); + *rid = pContext->rid; + taosTmrStart(rpcProcessConnError, 1, rid, pRpc->tmrCtrl); return BOOL_ASYNC; } @@ -1442,7 +1448,9 @@ static TBOOL rpcSendReqToServer(SRpcInfo *pRpc, SRpcReqContext *pContext) { // try next ip again pContext->code = terrno; // in rpcProcessConnError if numOfTry over limit, could call rpcNotifyClient to stop query - taosTmrStart(rpcProcessConnError, 1, pContext, pRpc->tmrCtrl); + int64_t *rid = malloc(sizeof(int64_t)); + *rid = pContext->rid; + taosTmrStart(rpcProcessConnError, 1, rid, pRpc->tmrCtrl); return BOOL_ASYNC; } @@ -1480,11 +1488,23 @@ static bool rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) { } static void rpcProcessConnError(void *param, void *id) { - SRpcReqContext *pContext = (SRpcReqContext *)param; + if (NULL == param) { + return; + } + + int64_t *rid = (int64_t*)param; + SRpcReqContext *pContext = (SRpcReqContext *)taosAcquireRef(tsRpcRefId, *rid); + if (NULL == pContext) { + free(param); + return; + } + SRpcInfo *pRpc = pContext->pRpc; SRpcMsg rpcMsg; if (pRpc == NULL) { + taosReleaseRef(tsRpcRefId, *rid); + free(param); return; } @@ -1504,6 +1524,9 @@ static void rpcProcessConnError(void *param, void *id) { pContext->epSet.inUse = pContext->epSet.inUse % pContext->epSet.numOfEps; rpcSendReqToServer(pRpc, pContext); } + + taosReleaseRef(tsRpcRefId, *rid); + free(param); } static void rpcProcessRetryTimer(void *param, void *tmrId) { @@ -1528,7 +1551,9 @@ static void rpcProcessRetryTimer(void *param, void *tmrId) { pConn->pContext->code = TSDB_CODE_RPC_NETWORK_UNAVAIL; pConn->pContext->pConn = NULL; pConn->pReqMsg = NULL; - taosTmrStart(rpcProcessConnError, 1, pConn->pContext, pRpc->tmrCtrl); + int64_t *rid = malloc(sizeof(int64_t)); + *rid = pConn->pContext->rid; + taosTmrStart(rpcProcessConnError, 1, rid, pRpc->tmrCtrl); rpcReleaseConn(pConn); } } @@ -1892,4 +1917,4 @@ bool rpcSaveSendInfo(int64_t rpcRid, void** ppContext) { taosReleaseRef(tsRpcRefId, rpcRid); return true; -} \ No newline at end of file +} diff --git a/src/sync/src/syncRetrieve.c b/src/sync/src/syncRetrieve.c index f0fcf6d6dd34e50a9810878aa7fbed2905a7f615..98dbf9bff5360c66037c4baf8dc2b34db23dd3b0 100644 --- a/src/sync/src/syncRetrieve.c +++ b/src/sync/src/syncRetrieve.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "os.h" #include "taoserror.h" +#include "tchecksum.h" #include "tlog.h" #include "tutil.h" #include "tglobal.h" @@ -23,6 +24,7 @@ #include "tsocket.h" #include "twal.h" #include "tsync.h" +#include "tfile.h" #include "syncInt.h" static int32_t syncGetWalVersion(SSyncNode *pNode, SSyncPeer *pPeer) { @@ -134,8 +136,69 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) { return 0; } +static int syncValidateChecksum(SWalHead *pHead) { + if (pHead->sver == 0) { // for compatible with wal before sver 1 + return taosCheckChecksumWhole((uint8_t *)pHead, sizeof(*pHead)); + } else { + // new wal format + uint32_t cksum = pHead->cksum; + pHead->cksum = 0; + int ret = taosCheckChecksum((uint8_t *)pHead, sizeof(*pHead) + pHead->len, cksum); + pHead->cksum = cksum; // must restore cksum for next call walValiteCheckSum + return ret; + } +} + +static int32_t syncSkipCorruptedRecord(SWalHead *pHead, int32_t fd) { + int64_t pos = taosLSeek(fd, 0, SEEK_CUR); + if (pos < 0) { + sError("fd:%d, skip corrupte taosLSeek return error. pos=%" PRId64, fd, pos); + return TSDB_CODE_WAL_FILE_CORRUPTED; + } + // save start bad bytes positioin + int64_t start = pos; + while (1) { + pos++; + if (taosLSeek(fd, pos, SEEK_SET) < 0) { + sError("fd:%d, failed to seek from corrupted wal file pos=%" PRId64 ".since %s", fd, pos, strerror(errno)); + return TSDB_CODE_WAL_FILE_CORRUPTED; + } + + if (fdRead(fd, pHead, sizeof(SWalHead)) <= 0) { + sError("fd:%d, failed to read wal head from corrupted wal. pos=%" PRId64 ".since %s", fd, pos, strerror(errno)); + return TSDB_CODE_WAL_FILE_CORRUPTED; + } + + if (pHead->signature != WAL_SIGNATURE) { + continue; + } + + if (pHead->sver == 0) { + // old format wal, only check head crc + if (syncValidateChecksum(pHead)) { + sInfo("fd:%d, old wal read head ok, pHead->len=%d, skip bad bytes=%" PRId64 " right pos:%" PRId64, fd, pHead->len, pos - start, pos); + return TSDB_CODE_SUCCESS; + } + } else { + // new format wal, check head + body crc + if (fdRead(fd, pHead->cont, pHead->len) < pHead->len) { + sError("fd:%d, read to end of corrupted wal file, offset:%" PRId64, fd, pos); + return TSDB_CODE_WAL_FILE_CORRUPTED; + } + + if (syncValidateChecksum(pHead)) { + sInfo("fd:%d, wal read head ok, pHead->len=%d, skip bad bytes=%" PRId64 " right pos:%" PRId64, fd, pHead->len, pos - start, pos); + return TSDB_CODE_SUCCESS; + } + } + } + + return TSDB_CODE_WAL_FILE_CORRUPTED; +} + // if only a partial record is read out, upper layer will reload the file to get a complete record static int32_t syncReadOneWalRecord(int32_t sfd, SWalHead *pHead) { + int32_t code = TSDB_CODE_SUCCESS; int32_t ret = read(sfd, pHead, sizeof(SWalHead)); if (ret < 0) { sError("sfd:%d, failed to read wal head since %s, ret:%d", sfd, strerror(errno), ret); @@ -153,18 +216,48 @@ static int32_t syncReadOneWalRecord(int32_t sfd, SWalHead *pHead) { return 0; } - assert(pHead->len <= TSDB_MAX_WAL_SIZE); + // check wal head valid + if (pHead->sver == 0 && !syncValidateChecksum(pHead)) { + sError("sfd:%d, old wal head cksum is messed up, sver=%d version:%" PRIu64 " len:%d", sfd, pHead->sver, pHead->version, pHead->len); + code = syncSkipCorruptedRecord(pHead, sfd); + if (code != TSDB_CODE_SUCCESS) { + sError("sfd:%d, wal corrupted and skip failed crc check, code:%d", sfd, code); + return -1; + } + // found next valid item + if (pHead->sver != 0) return sizeof(SWalHead) + pHead->len; + } + + if (pHead->len < 0 || pHead->len > WAL_MAX_SIZE - sizeof(SWalHead)) { + sError("sfd:%d, wal head len out of range, hver:%" PRIu64 " len:%d", sfd, pHead->version, pHead->len); + code = syncSkipCorruptedRecord(pHead, sfd); + if (code != TSDB_CODE_SUCCESS) { + sError("sfd:%d, wal corrupted and skip failed length check, code:%d", sfd, code); + return -1; + } + // found next valid item + if (pHead->sver != 0) return sizeof(SWalHead) + pHead->len; + } - ret = read(sfd, pHead->cont, pHead->len); + // read body + ret = (int32_t)read(sfd, pHead->cont, pHead->len); if (ret < 0) { - sError("sfd:%d, failed to read wal content since %s, ret:%d", sfd, strerror(errno), ret); + sError("sfd:%d, wal read wal cont failed. read len=%d, ret:%d", sfd, pHead->len, ret); return -1; } - if (ret != pHead->len) { - // file is not at end yet, it shall be reloaded - sInfo("sfd:%d, a partial wal conetnt is read out, ret:%d", sfd, ret); - return 0; + if (ret < pHead->len) { + sError("sfd:%d, wal read wal cont length small. need read len=%d, ret len:%d", sfd, pHead->len, ret); + return -1; + } + + if (pHead->sver != 0 && !syncValidateChecksum(pHead)) { + sError("sfd:%d, wal check sum failed, sver=%d version:%" PRIu64 " len:%d", sfd, pHead->sver, pHead->version, pHead->len); + code = syncSkipCorruptedRecord(pHead, sfd); + if (code != TSDB_CODE_SUCCESS) { + sError("sfd:%d, wal read body check sum not right and skip corrupted failed, code:%d", sfd, code); + return -1; + } } return sizeof(SWalHead) + pHead->len; diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index 3abc3e9acc6c8f6e909d4d6ef5f043dc2ee3e156..9358530581a3a755b1765e6e1571bf06a428b074 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -1080,7 +1080,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile int rowsToWrite = pDataCols->numOfRows; ASSERT(rowsToWrite > 0 && rowsToWrite <= pCfg->maxRowsPerFileBlock); - ASSERT((!isLast) || rowsToWrite < pCfg->minRowsPerFileBlock); + // ASSERT((!isLast) || rowsToWrite < pCfg->minRowsPerFileBlock); // Make buffer space if (tsdbMakeRoom(ppBuf, tsdbBlockStatisSize(pDataCols->numOfCols, SBlockVerLatest)) < 0) { diff --git a/src/tsdb/src/tsdbCommitQueue.c b/src/tsdb/src/tsdbCommitQueue.c index 6ca097fbe968beef731229da14677006d0841439..9aff21cac39d7a1b407a0df263f9d903ce540161 100644 --- a/src/tsdb/src/tsdbCommitQueue.c +++ b/src/tsdb/src/tsdbCommitQueue.c @@ -132,13 +132,16 @@ static void tsdbApplyRepoConfig(STsdbRepo *pRepo) { pRepo->config.keep2 = pRepo->save_config.keep2; pRepo->config.cacheLastRow = pRepo->save_config.cacheLastRow; pRepo->config.totalBlocks = pRepo->save_config.totalBlocks; + pRepo->config.minRowsPerFileBlock = pRepo->save_config.minRowsPerFileBlock; pthread_mutex_unlock(&pRepo->save_mutex); - tsdbInfo("vgId:%d apply new config: compression(%d), keep(%d,%d,%d), totalBlocks(%d), cacheLastRow(%d->%d),totalBlocks(%d->%d)", - REPO_ID(pRepo), - pSaveCfg->compression, pSaveCfg->keep,pSaveCfg->keep1, pSaveCfg->keep2, - pSaveCfg->totalBlocks, oldCfg.cacheLastRow, pSaveCfg->cacheLastRow, oldTotalBlocks, pSaveCfg->totalBlocks); + tsdbInfo( + "vgId:%d apply new config: " + "compression(%d),keep(%d,%d,%d),totalBlocks(%d),cacheLastRow(%d->%d),totalBlocks(%d->%d),minRows(%d->%d)", + REPO_ID(pRepo), pSaveCfg->compression, pSaveCfg->keep, pSaveCfg->keep1, pSaveCfg->keep2, pSaveCfg->totalBlocks, + oldCfg.cacheLastRow, pSaveCfg->cacheLastRow, oldTotalBlocks, pSaveCfg->totalBlocks, oldCfg.minRowsPerFileBlock, + pSaveCfg->minRowsPerFileBlock); int err = tsdbExpandPool(pRepo, oldTotalBlocks); if (!TAOS_SUCCEEDED(err)) { diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 63ea4ab6df0e84e81a9308de509ccd24c933c54e..ec4b9a5d49ab1183017453b2bab15be4884ab268 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -233,7 +233,7 @@ int32_t tsdbConfigRepo(STsdbRepo *repo, STsdbCfg *pCfg) { ASSERT(pRCfg->tsdbId == pCfg->tsdbId); ASSERT(pRCfg->cacheBlockSize == pCfg->cacheBlockSize); ASSERT(pRCfg->daysPerFile == pCfg->daysPerFile); - ASSERT(pRCfg->minRowsPerFileBlock == pCfg->minRowsPerFileBlock); + // ASSERT(pRCfg->minRowsPerFileBlock == pCfg->minRowsPerFileBlock); ASSERT(pRCfg->maxRowsPerFileBlock == pCfg->maxRowsPerFileBlock); ASSERT(pRCfg->precision == pCfg->precision); @@ -256,6 +256,9 @@ int32_t tsdbConfigRepo(STsdbRepo *repo, STsdbCfg *pCfg) { if (pRCfg->totalBlocks != pCfg->totalBlocks) { configChanged = true; } + if (pRCfg->minRowsPerFileBlock != pCfg->minRowsPerFileBlock) { + configChanged = true; + } if (!configChanged) { tsdbError("vgId:%d no config changed", REPO_ID(repo)); @@ -277,15 +280,16 @@ int32_t tsdbConfigRepo(STsdbRepo *repo, STsdbCfg *pCfg) { pSaveCfg->keep2 = pCfg->keep2; pSaveCfg->cacheLastRow = pCfg->cacheLastRow; pSaveCfg->totalBlocks = pCfg->totalBlocks; + pSaveCfg->minRowsPerFileBlock = pCfg->minRowsPerFileBlock; - tsdbInfo("vgId:%d old config: compression(%d), keep(%d,%d,%d), cacheLastRow(%d),totalBlocks(%d)", + tsdbInfo("vgId:%d old config: compression(%d),keep(%d,%d,%d),cacheLastRow(%d),totalBlocks(%d),minRows(%d)", REPO_ID(repo), pRCfg->compression, pRCfg->keep, pRCfg->keep1,pRCfg->keep2, - pRCfg->cacheLastRow, pRCfg->totalBlocks); - tsdbInfo("vgId:%d new config: compression(%d), keep(%d,%d,%d), cacheLastRow(%d),totalBlocks(%d)", + pRCfg->cacheLastRow, pRCfg->totalBlocks, pRCfg->minRowsPerFileBlock); + tsdbInfo("vgId:%d new config: compression(%d),keep(%d,%d,%d),cacheLastRow(%d),totalBlocks(%d),minRows(%d)", REPO_ID(repo), pSaveCfg->compression, pSaveCfg->keep,pSaveCfg->keep1, pSaveCfg->keep2, - pSaveCfg->cacheLastRow,pSaveCfg->totalBlocks); + pSaveCfg->cacheLastRow,pSaveCfg->totalBlocks,pSaveCfg->minRowsPerFileBlock); repo->config_changed = true; @@ -641,6 +645,7 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) { // tsdbFreeMemTable(pRepo->imem); tsem_destroy(&(pRepo->readyToCommit)); pthread_mutex_destroy(&pRepo->mutex); + pthread_mutex_destroy(&pRepo->save_mutex); free(pRepo); } } diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index a2c293772213fe804bc49fb2b74b9cc557dca269..d6f4c79ddd8c0d22149eeead5ef23887aae69b04 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define TSDB_CFG_MAX_NUM 136 +#define TSDB_CFG_MAX_NUM 141 #define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_VALUE_LEN 41 diff --git a/src/util/inc/tfile.h b/src/util/inc/tfile.h index 11a04cdf9480927131a92753a56bb67b462500ab..62ca627163b5d4b75dcf5933d77cda41399d590e 100644 --- a/src/util/inc/tfile.h +++ b/src/util/inc/tfile.h @@ -33,6 +33,7 @@ int64_t tfOpenM(const char *pathname, int32_t flags, mode_t mode); int64_t tfClose(int64_t tfd); int64_t tfWrite(int64_t tfd, void *buf, int64_t count); int64_t tfRead(int64_t tfd, void *buf, int64_t count); +int64_t fdRead(int32_t fd, void *buf, int64_t count); int32_t tfFsync(int64_t tfd); bool tfValid(int64_t tfd); int64_t tfLseek(int64_t tfd, int64_t offset, int32_t whence); diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index 11fa0691a41efafdded6d76ee31631f4b631171f..4acaa1111ad81e52ca1da9b4f86bf08b0a00ee34 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -32,20 +32,20 @@ int32_t tsGlobalConfigNum = 0; } static char *tsGlobalUnit[] = { - " ", - "(%)", - "(GB)", - "(Mb)", - "(byte)", - "(s)", + " ", + "(%)", + "(GB)", + "(Mb)", + "(byte)", + "(s)", "(ms)" }; char *tsCfgStatusStr[] = { - "none", - "system default", - "config file", - "taos_options", + "none", + "system default", + "config file", + "taos_options", "program argument list" }; @@ -335,7 +335,7 @@ bool taosReadConfigOption(const char *option, char *value, char *value2, char *v taosReadDataDirCfg(value, value2, value3); ret = true; } else { - ret = false; + ret = false; } break; default: @@ -365,8 +365,8 @@ void taosReadGlobalLogCfg() { wordfree(&full_path); return; } - - if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { + + if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { if (strlen(full_path.we_wordv[0]) >= TSDB_FILENAME_LEN) { printf("\nconfig file: %s path overflow max len %d, all variables are set to default\n", full_path.we_wordv[0], TSDB_FILENAME_LEN - 1); wordfree(&full_path); @@ -380,7 +380,7 @@ void taosReadGlobalLogCfg() { wordfree(&full_path); taosReadLogOption("logDir", tsLogDir); - + sprintf(fileName, "%s/taos.cfg", configDir); fp = fopen(fileName, "r"); if (fp == NULL) { @@ -391,10 +391,10 @@ void taosReadGlobalLogCfg() { ssize_t _bytes = 0; size_t len = 1024; line = calloc(1, len); - + while (!feof(fp)) { memset(line, 0, len); - + option = value = NULL; olen = vlen = 0; @@ -443,7 +443,7 @@ bool taosReadGlobalCfg() { ssize_t _bytes = 0; size_t len = 1024; line = calloc(1, len); - + while (!feof(fp)) { memset(line, 0, len); @@ -457,7 +457,7 @@ bool taosReadGlobalCfg() { } line[len - 1] = 0; - + paGetToken(line, &option, &olen); if (olen == 0) continue; option[olen] = 0; @@ -495,7 +495,7 @@ void taosPrintGlobalCfg() { SGlobalCfg *cfg = tsGlobalConfig + i; if (tscEmbedded == 0 && !(cfg->cfgType & TSDB_CFG_CTYPE_B_CLIENT)) continue; if (cfg->cfgType & TSDB_CFG_CTYPE_B_NOT_PRINT) continue; - + int optionLen = (int)strlen(cfg->option); int blankLen = TSDB_CFG_PRINT_LEN - optionLen; blankLen = blankLen < 0 ? 0 : blankLen; diff --git a/src/util/src/tfile.c b/src/util/src/tfile.c index d975995b2149297d2ae53584bcf36b6c74b7b529..4e41e259af2e76c1a3f2fc93cd628bca81cfee05 100644 --- a/src/util/src/tfile.c +++ b/src/util/src/tfile.c @@ -93,6 +93,13 @@ int64_t tfRead(int64_t tfd, void *buf, int64_t count) { return ret; } +int64_t fdRead(int32_t fd, void *buf, int64_t count) { + int64_t ret = taosRead(fd, buf, count); + if (ret < 0) terrno = TAOS_SYSTEM_ERROR(errno); + return ret; +} + + int32_t tfFsync(int64_t tfd) { void *p = taosAcquireRef(tsFileRsetId, tfd); if (p == NULL) return -1; diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index 19c72d2e0b2b4e059883a506e3c4ad1f1b4cf809..a3d6450e647e1bc7d9c5e76679865d99a7db929d 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -352,43 +352,70 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie serverAddr.sin_addr.s_addr = destIp; serverAddr.sin_port = (uint16_t)htons((uint16_t)destPort); -#ifdef _TD_LINUX - taosSetNonblocking(sockFd, 1); - ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr)); +#if defined(_TD_LINUX) + taosSetNonblocking(sockFd, 1); + ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr)); if (ret == -1) { if (errno == EHOSTUNREACH) { uError("failed to connect socket, ip:0x%x, port:%hu(%s)", destIp, destPort, strerror(errno)); taosCloseSocket(sockFd); - return -1; + return -1; } else if (errno == EINPROGRESS || errno == EAGAIN || errno == EWOULDBLOCK) { - struct pollfd wfd[1]; + struct pollfd wfd[1]; wfd[0].fd = sockFd; wfd[0].events = POLLOUT; - + int res = poll(wfd, 1, tsTcpConnTimeout); if (res == -1 || res == 0) { uError("failed to connect socket, ip:0x%x, port:%hu(poll error/conn timeout)", destIp, destPort); - taosCloseSocket(sockFd); // + taosCloseSocket(sockFd); // return -1; } - int optVal = -1, optLen = sizeof(int); + int optVal = -1, optLen = sizeof(int); if ((0 != taosGetSockOpt(sockFd, SOL_SOCKET, SO_ERROR, &optVal, &optLen)) || (optVal != 0)) { uError("failed to connect socket, ip:0x%x, port:%hu(connect host error)", destIp, destPort); - taosCloseSocket(sockFd); // + taosCloseSocket(sockFd); // return -1; } ret = 0; } else { // Other error uError("failed to connect socket, ip:0x%x, port:%hu(target host cannot be reached)", destIp, destPort); - taosCloseSocket(sockFd); // - return -1; - } + taosCloseSocket(sockFd); // + return -1; + } } - taosSetNonblocking(sockFd, 0); + taosSetNonblocking(sockFd, 0); +#elif defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) + taosSetNonblocking(sockFd, 1); + + ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr)); + if (ret == -1) { + struct timeval timeout; + fd_set set; + + timeout.tv_sec = 0; + timeout.tv_usec = tsTcpConnTimeout * 1000; + FD_ZERO(&set); + FD_SET(sockFd, &set); + if (select(sockFd + 1, NULL, &set, NULL, &timeout) <= 0) { + uError("failed to connect socket, ip:0x%x, port:%hu(select error/conn timeout)", destIp, destPort); + taosCloseSocket(sockFd); // + return -1; + } + + int optVal = -1, optLen = sizeof(int); + if ((0 != taosGetSockOpt(sockFd, SOL_SOCKET, SO_ERROR, &optVal, &optLen)) || (optVal != 0)) { + uError("failed to connect socket, ip:0x%x, port:%hu(connect host error)", destIp, destPort); + taosCloseSocket(sockFd); // + return -1; + } + ret = 0; + } + taosSetNonblocking(sockFd, 0); #else - ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr)); + ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr)); #endif if (ret != 0) { diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index e3371c79db76f4a3875b505aa7f56c67969c49ce..be5b43caf3172d7f6e9e45ae728eb55d08396724 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -161,6 +161,8 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR vTrace("vgId:%d, submit msg is processed", pVnode->vgId); + int64_t submitStartUs = taosGetTimestampUs(); + if (pVnode->dbType == TSDB_DB_TYPE_TOPIC && pVnode->role == TAOS_SYNC_ROLE_MASTER) { tpUpdateTs(pVnode->vgId, &pVnode->sequence, pCont); } @@ -186,6 +188,11 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR atomic_fetch_add_64(&tsSubmitRowSucNum, ntohl(pRsp->affectedRows)); } + int64_t submitEndUs = taosGetTimestampUs(); + if (submitEndUs - submitStartUs > 10 * 1000000) { + vWarn("vgId: %d, submit msg process takes more than 10s", pVnode->vgId); + } + return code; } diff --git a/src/wal/inc/walInt.h b/src/wal/inc/walInt.h index 890b404ce9489f0f7798aa7ff21b4f1e80da2b04..3062b44dfd366f05fbc475fea2d407d841e59b78 100644 --- a/src/wal/inc/walInt.h +++ b/src/wal/inc/walInt.h @@ -34,8 +34,6 @@ extern int32_t wDebugFlag; #define WAL_PREFIX "wal" #define WAL_PREFIX_LEN 3 #define WAL_REFRESH_MS 1000 -#define WAL_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead) + 16) -#define WAL_SIGNATURE ((uint32_t)(0xFAFBFDFE)) #define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12) #define WAL_FILE_LEN (WAL_PATH_LEN + 32) #define WAL_FILE_NUM 1 // 3 diff --git a/src/wal/src/walWrite.c b/src/wal/src/walWrite.c index 3f2df3f6243c3291602ceb0c7fcd93d475927485..036931f0fe73b8c13d5d7b3f24c0ef0bf4166680 100644 --- a/src/wal/src/walWrite.c +++ b/src/wal/src/walWrite.c @@ -112,8 +112,6 @@ void walRemoveAllOldFiles(void *handle) { pthread_mutex_unlock(&pWal->mutex); } -#if defined(WAL_CHECKSUM_WHOLE) - static void walUpdateChecksum(SWalHead *pHead) { pHead->sver = 2; pHead->cksum = 0; @@ -123,17 +121,16 @@ static void walUpdateChecksum(SWalHead *pHead) { static int walValidateChecksum(SWalHead *pHead) { if (pHead->sver == 0) { // for compatible with wal before sver 1 return taosCheckChecksumWhole((uint8_t *)pHead, sizeof(*pHead)); - } else if (pHead->sver >= 1) { + } else { + // new wal format uint32_t cksum = pHead->cksum; pHead->cksum = 0; - return taosCheckChecksum((uint8_t *)pHead, sizeof(*pHead) + pHead->len, cksum); + int ret = taosCheckChecksum((uint8_t *)pHead, sizeof(*pHead) + pHead->len, cksum); + pHead->cksum = cksum; // must restore cksum for next call walValiteCheckSum + return ret; } - - return 0; } -#endif - int32_t walWrite(void *handle, SWalHead *pHead) { if (handle == NULL) return -1; @@ -146,13 +143,8 @@ int32_t walWrite(void *handle, SWalHead *pHead) { if (pHead->version <= pWal->version) return 0; pHead->signature = WAL_SIGNATURE; -#if defined(WAL_CHECKSUM_WHOLE) - walUpdateChecksum(pHead); -#else - pHead->sver = 0; - taosCalcChecksumAppend(0, (uint8_t *)pHead, sizeof(SWalHead)); -#endif + walUpdateChecksum(pHead); int32_t contLen = pHead->len + sizeof(SWalHead); pthread_mutex_lock(&pWal->mutex); @@ -275,38 +267,32 @@ static int32_t walSkipCorruptedRecord(SWal *pWal, SWalHead *pHead, int64_t tfd, continue; } -#if defined(WAL_CHECKSUM_WHOLE) - if (pHead->sver == 0 && walValidateChecksum(pHead)) { - wInfo("vgId:%d, wal head cksum check passed, offset:%" PRId64, pWal->vgId, pos); - *offset = pos; - return TSDB_CODE_SUCCESS; - } - - if (pHead->sver >= 1) { + if (pHead->sver == 0) { + // old wal file format, only check head data crc + if (walValidateChecksum(pHead)) { + wInfo("vgId:%d, wal head cksum check passed, offset:%" PRId64, pWal->vgId, pos); + *offset = pos; + return TSDB_CODE_SUCCESS; + } + } else { + // maybe new wal file format, read body data and check head + body crc if (tfRead(tfd, pHead->cont, pHead->len) < pHead->len) { - wError("vgId:%d, read to end of corrupted wal file, offset:%" PRId64, pWal->vgId, pos); - return TSDB_CODE_WAL_FILE_CORRUPTED; + wError("vgId:%d, read to end of corrupted wal file, offset:%" PRId64, pWal->vgId, pos); + return TSDB_CODE_WAL_FILE_CORRUPTED; } + // check head + body crc if (walValidateChecksum(pHead)) { - wInfo("vgId:%d, wal whole cksum check passed, offset:%" PRId64, pWal->vgId, pos); - *offset = pos; - return TSDB_CODE_SUCCESS; + wInfo("vgId:%d, wal whole cksum check passed, offset:%" PRId64, pWal->vgId, pos); + *offset = pos; + return TSDB_CODE_SUCCESS; } } - -#else - if (taosCheckChecksumWhole((uint8_t *)pHead, sizeof(SWalHead))) { - wInfo("vgId:%d, wal head cksum check passed, offset:%" PRId64, pWal->vgId, pos); - *offset = pos; - return TSDB_CODE_SUCCESS; - } - -#endif } return TSDB_CODE_WAL_FILE_CORRUPTED; } + // Add SMemRowType ahead of SDataRow static void expandSubmitBlk(SSubmitBlk *pDest, SSubmitBlk *pSrc, int32_t *lenExpand) { // copy the header firstly @@ -454,18 +440,21 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch break; } -#if defined(WAL_CHECKSUM_WHOLE) - if ((pHead->sver == 0 && !walValidateChecksum(pHead)) || pHead->sver < 0 || pHead->sver > 2) { - wError("vgId:%d, file:%s, wal head cksum is messed up, hver:%" PRIu64 " len:%d offset:%" PRId64, pWal->vgId, name, + bool contAlreadyRead = false; + + // sver == 0 is old wal format, other is new wal + if (pHead->sver == 0 && !walValidateChecksum(pHead)) { + wError("vgId:%d, file:%s, old wal head cksum is messed up, hver:%" PRIu64 " len:%d offset:%" PRId64, pWal->vgId, name, pHead->version, pHead->len, offset); code = walSkipCorruptedRecord(pWal, pHead, tfd, &offset); if (code != TSDB_CODE_SUCCESS) { walFtruncate(pWal, tfd, offset); break; } + if (pHead->sver != 0) contAlreadyRead = true; } - if (pHead->len < 0 || pHead->len > size - sizeof(SWalHead)) { + if ( pHead->sver == 0 && (pHead->len < 0 || pHead->len > size - sizeof(SWalHead))) { wError("vgId:%d, file:%s, wal head len out of range, hver:%" PRIu64 " len:%d offset:%" PRId64, pWal->vgId, name, pHead->version, pHead->len, offset); code = walSkipCorruptedRecord(pWal, pHead, tfd, &offset); @@ -473,66 +462,36 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch walFtruncate(pWal, tfd, offset); break; } + if (pHead->sver != 0) contAlreadyRead = true; } - ret = (int32_t)tfRead(tfd, pHead->cont, pHead->len); - if (ret < 0) { - wError("vgId:%d, file:%s, failed to read wal body since %s", pWal->vgId, name, strerror(errno)); - code = TAOS_SYSTEM_ERROR(errno); - break; - } - - if (ret < pHead->len) { - wError("vgId:%d, file:%s, failed to read wal body, ret:%d len:%d", pWal->vgId, name, ret, pHead->len); - offset += sizeof(SWalHead); - continue; - } - - if ((pHead->sver >= 1) && !walValidateChecksum(pHead)) { - wError("vgId:%d, file:%s, wal whole cksum is messed up, hver:%" PRIu64 " len:%d offset:%" PRId64, pWal->vgId, name, - pHead->version, pHead->len, offset); - code = walSkipCorruptedRecord(pWal, pHead, tfd, &offset); - if (code != TSDB_CODE_SUCCESS) { - walFtruncate(pWal, tfd, offset); + if (!contAlreadyRead) { + ret = (int32_t)tfRead(tfd, pHead->cont, pHead->len); + if (ret < 0) { + wError("vgId:%d, file:%s, failed to read wal body since %s", pWal->vgId, name, strerror(errno)); + code = TAOS_SYSTEM_ERROR(errno); break; } - } -#else - if (!taosCheckChecksumWhole((uint8_t *)pHead, sizeof(SWalHead))) { - wError("vgId:%d, file:%s, wal head cksum is messed up, hver:%" PRIu64 " len:%d offset:%" PRId64, pWal->vgId, name, - pHead->version, pHead->len, offset); - code = walSkipCorruptedRecord(pWal, pHead, tfd, &offset); - if (code != TSDB_CODE_SUCCESS) { - walFtruncate(pWal, tfd, offset); - break; + if (ret < pHead->len) { + wError("vgId:%d, file:%s, failed to read wal body, ret:%d len:%d", pWal->vgId, name, ret, pHead->len); + offset += sizeof(SWalHead); + continue; } - } - if (pHead->len < 0 || pHead->len > size - sizeof(SWalHead)) { - wError("vgId:%d, file:%s, wal head len out of range, hver:%" PRIu64 " len:%d offset:%" PRId64, pWal->vgId, name, - pHead->version, pHead->len, offset); - code = walSkipCorruptedRecord(pWal, pHead, tfd, &offset); - if (code != TSDB_CODE_SUCCESS) { - walFtruncate(pWal, tfd, offset); - break; + // check new wal sum head + body crc + if ((pHead->sver != 0) && !walValidateChecksum(pHead)) { + // new format wal corrupted + wError("vgId:%d, file:%s, wal whole cksum is messed up, hver:%" PRIu64 " len:%d offset:%" PRId64, pWal->vgId, + name, pHead->version, pHead->len, offset); + code = walSkipCorruptedRecord(pWal, pHead, tfd, &offset); + if (code != TSDB_CODE_SUCCESS) { + walFtruncate(pWal, tfd, offset); + break; + } } } - ret = (int32_t)tfRead(tfd, pHead->cont, pHead->len); - if (ret < 0) { - wError("vgId:%d, file:%s, failed to read wal body since %s", pWal->vgId, name, strerror(errno)); - code = TAOS_SYSTEM_ERROR(errno); - break; - } - - if (ret < pHead->len) { - wError("vgId:%d, file:%s, failed to read wal body, ret:%d len:%d", pWal->vgId, name, ret, pHead->len); - offset += sizeof(SWalHead); - continue; - } - -#endif offset = offset + sizeof(SWalHead) + pHead->len; wTrace("vgId:%d, restore wal, fileId:%" PRId64 " hver:%" PRIu64 " wver:%" PRIu64 " len:%d offset:%" PRId64, diff --git a/tests/develop-test/2-query/function_mode.py b/tests/develop-test/2-query/function_mode.py index 910ebbb2c574573722b1f840b2400f6e124d6f7c..e757434632fc1f8fdef654856d7bc99faa66317c 100644 --- a/tests/develop-test/2-query/function_mode.py +++ b/tests/develop-test/2-query/function_mode.py @@ -57,10 +57,10 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdSql.query('select mode(num) from d001') tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, -32767) tdSql.query('select mode(dbool) from d001') tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, False) tdSql.query('select mode(dtiny) from d001') tdSql.checkRows(1) tdSql.checkData(0, 0, None) @@ -87,7 +87,7 @@ class TDTestCase: tdSql.checkData(0, 0, 1) tdSql.query('select mode(num),mode(voltage) from smode') tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, 3276) tdSql.checkData(0, 1, 1) tdSql.query('select mode(dbool) from smode') tdSql.checkRows(1) @@ -97,7 +97,7 @@ class TDTestCase: tdSql.checkData(0, 0, None) tdSql.query('select mode(dfloat) from smode') tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, 3.3232219219207764) tdSql.query('select mode(ddouble) from smode') tdSql.checkRows(1) tdSql.checkData(0, 0, 4.982392323) @@ -112,16 +112,16 @@ class TDTestCase: #group by column tdSql.query('select mode(num) from d002 group by dbinary') tdSql.checkRows(2) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, 3276) tdSql.checkData(1, 0, None) tdSql.execute('insert into D002 values("2021-11-17 20:31:31", 1, 3276, true, NULL, 3.32322, 4.982392323, "你好吗", "sdf", 333)') tdSql.query('select mode(num) from d002 group by dbinary') tdSql.checkRows(2) tdSql.checkData(1, 0, 3276) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, 3276) tdSql.query('select mode(dfloat) from d002 group by dbinary') tdSql.checkRows(2) - tdSql.checkData(1, 0, None) + tdSql.checkData(1, 0, 3.3232200145721436) tdSql.query('select mode(dchar) from d002 group by dbinary') tdSql.checkRows(2) tdSql.checkData(1, 0, "你好吗") @@ -138,7 +138,7 @@ class TDTestCase: #group by tbname tdSql.query('select mode(dchar) from smode group by tbname') tdSql.checkRows(2) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, "你好吗") tdSql.checkData(0, 1, "d001") tdSql.checkData(1, 0, "你好吗") tdSql.checkData(1, 1, "d002") @@ -148,7 +148,7 @@ class TDTestCase: tdSql.checkRows(2) tdSql.checkData(0, 0, 4.982392323) tdSql.checkData(0, 1, "Beijing.haidian") - tdSql.checkData(1, 0, None) + tdSql.checkData(1, 0, 4.982392323) tdSql.checkData(1, 1, "Beijing.Chaoyang") #group by tag,column @@ -169,7 +169,7 @@ class TDTestCase: tdSql.checkRows(2) tdSql.checkData(0, 0, "你好吗") tdSql.checkData(0, 1, "d002") - tdSql.checkData(1, 0, None) + tdSql.checkData(1, 0, "你好吗") tdSql.checkData(1, 1, "d001") #where @@ -178,7 +178,7 @@ class TDTestCase: tdSql.checkData(0, 0, 19) tdSql.query('select mode(voltage) from smode where num > 9') tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, 19) #interval tdSql.query('select mode(voltage) from smode interval(1s)') @@ -188,7 +188,7 @@ class TDTestCase: tdSql.checkData(0, 0, "2021-01-01 00:00:00") tdSql.checkData(0, 1, 1) tdSql.checkData(1, 0, "2022-01-01 00:00:00") - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, 19) tdSql.query('select mode(voltage) from smode interval(1n)') tdSql.checkRows(4) tdSql.checkData(0, 0, "2021-10-01 00:00:00") @@ -198,7 +198,7 @@ class TDTestCase: tdSql.checkData(2, 0, "2021-12-01 00:00:00") tdSql.checkData(2, 1, 2) tdSql.checkData(3, 0, "2022-01-01 00:00:00") - tdSql.checkData(3, 1, None) + tdSql.checkData(3, 1, 19) tdSql.query('select mode(voltage) from smode where ts > "2021-09-01 00:00:00" and ts <"2022-02-02 00:00:00" interval(1n) fill(prev)') tdSql.checkRows(6) @@ -207,7 +207,7 @@ class TDTestCase: tdSql.checkData(3, 0, "2021-12-01 00:00:00") tdSql.checkData(3, 1, 2) tdSql.checkData(5, 0, "2022-02-01 00:00:00") - tdSql.checkData(5, 1, 2) + tdSql.checkData(5, 1, 19) #session tdSql.query('select mode(voltage) from d002 session(ts,1w)') @@ -222,7 +222,7 @@ class TDTestCase: #state_window tdSql.query('select mode(dfloat) from d002 state_window(voltage)') tdSql.checkRows(3) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, 3.3232200145721436) tdSql.checkData(1, 0, None) #slimit/soffset @@ -237,9 +237,9 @@ class TDTestCase: #having tdSql.query('select mode(ddouble) from smode group by location having mode(ddouble)>3') - tdSql.checkRows(1) + tdSql.checkRows(2) tdSql.checkData(0, 0, 4.982392323) - tdSql.checkData(0, 1, "Beijing.haidian") + tdSql.checkData(0, 1, "Beijing.Chaoyang") #subquery tdSql.query('select mode(ddouble) from (select * from smode where voltage = 1)') diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py index 91c56c6a60ae5fa1d3ebf02fad7ec4483a13f59c..c68375894c6f34bdccc33789384f6113aeb6e105 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py +++ b/tests/develop-test/5-taos-tools/taosbenchmark/default_json.py @@ -32,6 +32,10 @@ class TDTestCase: if "community" in selfPath: projPath = selfPath[: selfPath.find("community")] + elif "src" in selfPath: + projPath = selfPath[: selfPath.find("src")] + elif "/tools/" in selfPath: + projPath = selfPath[: selfPath.find("/tools/")] else: projPath = selfPath[: selfPath.find("tests")] @@ -55,11 +59,10 @@ class TDTestCase: tdLog.info("%s" % cmd) os.system("%s" % cmd) tdSql.execute("reset query cache") - tdSql.query("select count(tbname) from db.stb") - tdSql.checkData(0, 0, 10) + tdSql.query("show db.tables") + tdSql.checkRows(10) tdSql.query("select count(*) from db.stb") - if len(tdSql.queryResult): - tdLog.exit("query result is %d" % len(tdSql.queryResult)) + tdSql.checkData(0, 0, 100) def stop(self): tdSql.close() diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json index d4b2aae2fb7bf1a3612e60f395a1c5ed26ceca8f..da22ef75e2a648e897341338bb762e4fedc6662b 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/default.json @@ -20,8 +20,10 @@ "super_tables": [{ "name": "stb", "childtable_prefix": "stb_", + "childtable_count": 10, + "insert_rows": 10, "columns": [{"type": "INT"}], "tags": [{"type": "INT"}] }] }] -} \ No newline at end of file +} diff --git a/tests/perftest-scripts/coverage_test.sh b/tests/perftest-scripts/coverage_test.sh index 1be2053f24f28dd825c040912783675b1eab94f9..b58fac21c9050b71781c4a06d26ce7c3437f6cc5 100755 --- a/tests/perftest-scripts/coverage_test.sh +++ b/tests/perftest-scripts/coverage_test.sh @@ -64,6 +64,21 @@ function runGeneralCaseOneByOne { done < $1 } +function runTestNGCaseOneByOne { + while read -r line; do + if [[ $line =~ ^./taostest* ]]; then + case=`echo $line | cut -d' ' -f 3 | cut -d'=' -f 2` + yaml=`echo $line | cut -d' ' -f 2` + + if [ -n "$case" ]; then + date +%F\ %T | tee -a $TDENGINE_COVERAGE_REPORT && ./taostest $yaml --case=$case --keep > /dev/null 2>&1 && \ + echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT \ + || echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT + fi + fi + done < $1 +} + function runTest { echo "run Test" @@ -87,6 +102,13 @@ function runTest { else sed -i '3i\\n' $TDENGINE_COVERAGE_REPORT fi + + # run TestNG cases + stopTaosd + $TDENGINE_DIR/debug/build/bin/taosd -c $TDENGINE_DIR/debug/test/cfg > /dev/null & + sleep 10 + cd $TDENGINE_DIR/../TestNG/cases + runTestNGCaseOneByOne ../scripts/cases.txt cd $TDENGINE_DIR/tests rm -rf ../sim diff --git a/tests/pytest/alter/alter_keep.py b/tests/pytest/alter/alter_keep.py index b23f364fc6f16973f8e7b5e6159f95718df9b91b..2b38f4b2aa4c8cbc6ac2fd0bacbd062004768f0a 100644 --- a/tests/pytest/alter/alter_keep.py +++ b/tests/pytest/alter/alter_keep.py @@ -22,7 +22,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - + def alterKeepCommunity(self): tdLog.notice('running Keep Test, Community Version') tdLog.notice('running parameter test for keep during create') @@ -174,7 +174,7 @@ class TDTestCase: tdSql.error('insert into tb values (now-15d, 10)') tdSql.query('select * from tb') tdSql.checkRows(2) - + rowNum = 2 tdLog.notice('testing keep will be altered if sudden change from small to big') for i in range(30): diff --git a/tests/pytest/client/client.py b/tests/pytest/client/client.py index 308ffab848dc5afd94027c910ae4db565393defe..60365831b7b52df0ebb2cb89244ec5092c1ffb4c 100644 --- a/tests/pytest/client/client.py +++ b/tests/pytest/client/client.py @@ -28,8 +28,8 @@ class TDTestCase: tdSql.prepare() ret = tdSql.query('select database()') - tdSql.checkData(0, 0, "db") - + tdSql.checkData(0, 0, "db") + ret = tdSql.query('select server_status()') tdSql.checkData(0, 0, 1) @@ -59,10 +59,10 @@ class TDTestCase: if create_time-time_delta < role_time < create_time+time_delta: tdLog.info("role_time {} and create_time {} expected within range".format(role_time, create_time)) else: - tdLog.exit("role_time {} and create_time {} not expected within range".format(role_time, create_time)) + tdLog.exit("role_time {} and create_time {} not expected within range".format(role_time, create_time)) ret = tdSql.query('show vgroups') - tdSql.checkRows(0) + tdSql.checkRows(0) tdSql.execute('create stable st (ts timestamp, f int) tags(t int)') tdSql.execute('create table ct1 using st tags(1)'); @@ -74,8 +74,8 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 2) tdSql.checkData(0, 1, "leader") - - cmd = "taos -h 127.0.0.1 -s 'show databases'" + + cmd = "taos -h 127.0.0.1 -s 'show databases'" r = os.popen(cmd) text = r.read() r.close diff --git a/tests/pytest/query/query1970YearsAf.py b/tests/pytest/query/query1970YearsAf.py index 62b435fbef9cb132e349e0f8da91eb5c795f3b0b..82b26682427b2d5439c9932f3c2b1d2804459ce0 100644 --- a/tests/pytest/query/query1970YearsAf.py +++ b/tests/pytest/query/query1970YearsAf.py @@ -25,8 +25,8 @@ from util.cases import * from util.dnodes import * from util.dnodes import TDDnode -class TDTestCase: +class TDTestCase: def __init__(self): self.path = "" @@ -68,7 +68,7 @@ class TDTestCase: "cachelast": 0, "quorum": 1, "fsync": 3000, - "update": 0 + "update": 0, } # set stable schema @@ -99,8 +99,7 @@ class TDTestCase: {"type": "TINYINT", "count": 2}, {"type": "BOOL", "count": 2}, {"type": "NCHAR", "len": 3, "count": 1}, - {"type": "BINARY", "len": 8, "count": 1} - + {"type": "BINARY", "len": 8, "count": 1}, ], "tags": [ {"type": "INT", "count": 2}, @@ -111,17 +110,14 @@ class TDTestCase: {"type": "TINYINT", "count": 2}, {"type": "BOOL", "count": 2}, {"type": "NCHAR", "len": 3, "count": 1}, - {"type": "BINARY", "len": 8, "count": 1} - ] + {"type": "BINARY", "len": 8, "count": 1}, + ], } # create different stables like stable1 and add to list super_tables super_tables = [] super_tables.append(stable1) - database = { - "dbinfo": dbinfo, - "super_tables": super_tables - } + database = {"dbinfo": dbinfo, "super_tables": super_tables} cfgdir = self.getCfgDir() create_table = { @@ -137,33 +133,60 @@ class TDTestCase: "confirm_parameter_prompt": "no", "insert_interval": 0, "num_of_records_per_req": 100, - "databases": [database] + "databases": [database], } return create_table + def getPath(self, tool="taosBenchmark"): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if "community" in selfPath: + projPath = selfPath[: selfPath.find("community")] + elif "src" in selfPath: + projPath = selfPath[: selfPath.find("src")] + elif "/tools/" in selfPath: + projPath = selfPath[: selfPath.find("/tools/")] + elif "/tests/" in selfPath: + projPath = selfPath[: selfPath.find("/tests/")] + else: + tdLog.exit("path: %s is not supported" % selfPath) + + paths = [] + for root, dirs, files in os.walk(projPath): + if (tool) in files: + rootRealPath = os.path.dirname(os.path.realpath(root)) + if "packaging" not in rootRealPath: + paths.append(os.path.join(root, tool)) + break + if len(paths) == 0: + return "" + return paths[0] + def createinsertfile(self): create_table = self.creatcfg() date = datetime.datetime.now().strftime("%Y%m%d%H%M") file_create_table = f"/tmp/insert_{date}.json" - with open(file_create_table, 'w') as f: + with open(file_create_table, "w") as f: json.dump(create_table, f) return file_create_table def inserttable(self, filepath): - create_table_cmd = f"taosdemo -f {filepath} > /dev/null 2>&1" + binPath = self.getPath("taosBenchmark") + if binPath == "": + tdLog.exit("taosBenchmark not found!") + else: + tdLog.info("taosBenchmark found in %s" % binPath) + + create_table_cmd = "%s -f %s > /dev/null 2>&1" % (binPath, filepath) _ = subprocess.check_output(create_table_cmd, shell=True).decode("utf-8") def sqlsquery(self): # stable query - tdSql.query( - "select * from stb2 where stb2.ts < '1970-01-01 00:00:00.000' " - ) + tdSql.query("select * from stb2 where stb2.ts < '1970-01-01 00:00:00.000' ") tdSql.checkRows(43200) - tdSql.query( - "select * from stb2 where stb2.ts >= '1970-01-01 00:00:00.000' " - ) + tdSql.query("select * from stb2 where stb2.ts >= '1970-01-01 00:00:00.000' ") tdSql.checkRows(6800) tdSql.query( @@ -172,14 +195,10 @@ class TDTestCase: tdSql.checkRows(3590) # child-tables query - tdSql.query( - "select * from t0 where t0.ts < '1970-01-01 00:00:00.000' " - ) + tdSql.query("select * from t0 where t0.ts < '1970-01-01 00:00:00.000' ") tdSql.checkRows(4320) - tdSql.query( - "select * from t1 where t1.ts >= '1970-01-01 00:00:00.000' " - ) + tdSql.query("select * from t1 where t1.ts >= '1970-01-01 00:00:00.000' ") tdSql.checkRows(680) tdSql.query( @@ -192,9 +211,7 @@ class TDTestCase: ) tdSql.checkRows(680) - tdSql.query( - "select diff(c1) from t0 where t0.ts >= '1970-01-01 00:00:00.000' " - ) + tdSql.query("select diff(c1) from t0 where t0.ts >= '1970-01-01 00:00:00.000' ") tdSql.checkRows(679) tdSql.query( @@ -203,9 +220,7 @@ class TDTestCase: tdSql.checkRows(43200) # query with timestamp in 'where ...' - tdSql.query( - "select * from stb2 where stb2.ts > -28800000 " - ) + tdSql.query("select * from stb2 where stb2.ts > -28800000 ") tdSql.checkRows(6790) tdSql.query( @@ -219,14 +234,16 @@ class TDTestCase: tdSql.checkRows(3590) def run(self): - s = 'reset query cache' + s = "reset query cache" tdSql.execute(s) - s = 'create database if not exists db' + s = "create database if not exists db" tdSql.execute(s) - s = 'use db' + s = "use db" tdSql.execute(s) - tdLog.info("==========step1:create table stable and child table,then insert data automatically") + tdLog.info( + "==========step1:create table stable and child table,then insert data automatically" + ) insertfile = self.createinsertfile() self.inserttable(insertfile) diff --git a/tests/pytest/query/queryError.py b/tests/pytest/query/queryError.py index 7d752a9863312e42e303e5db34e18ad740bc5a19..97d7a0199f782dfe19232c471094e278799d0fb0 100644 --- a/tests/pytest/query/queryError.py +++ b/tests/pytest/query/queryError.py @@ -68,14 +68,14 @@ class TDTestCase: # TD-6006 tdSql.error("select * from dev_001 where 'name' is not null") tdSql.error("select * from dev_001 where \"name\" = 'first'") - + # TS-1577 tdSql.query("show databases") rows = tdSql.queryRows for i in range(1000): tdSql.execute("create database test%d" % i) - + tdSql.query("show databases") tdSql.checkRows(rows + 1000) diff --git a/tests/pytest/query/queryInterval.py b/tests/pytest/query/queryInterval.py index 2c0ae56de4d996846694da03de6ea0056804441d..0579489ee7709c00d7cc4cf6ce5ff79485557d29 100644 --- a/tests/pytest/query/queryInterval.py +++ b/tests/pytest/query/queryInterval.py @@ -197,6 +197,25 @@ class TDTestCase: else: tdLog.exit("sql:%s, column : ts is not sorted in accending order as expected" % (tdSql.sql)) + # TS-1582 + tdSql.execute("create table stb1(ts timestamp, c1 int) tags(t1 int)") + tdSql.execute("insert into tb1 using stb1 tags(1) values(%d, 1)(%d, 5)(%d, 10)" % (self.ts, self.ts + 1000, self.ts + 2000)) + tdSql.execute("insert into tb2 using stb1 tags(2) values(%d, 1)(%d, 5)(%d, 10)" % (self.ts, self.ts + 1000, self.ts + 2000)) + + tdSql.query("select t1, last(c1) from stb1 where ts between 1593548685000 and 1593548688000 interval(2s) fill(NULL) group by tbname") + tdSql.checkRows(6) + tdSql.checkData(2, 2, None) + tdSql.checkData(2, 3, "tb1") + tdSql.checkData(5, 2, None) + tdSql.checkData(5, 3, "tb2") + + tdSql.query("select t1, last(c1) - 1 from stb1 where ts between 1593548685000 and 1593548688000 interval(2s) fill(NULL) group by tbname") + tdSql.checkRows(6) + tdSql.checkData(2, 2, None) + tdSql.checkData(2, 3, "tb1") + tdSql.checkData(5, 2, None) + tdSql.checkData(5, 3, "tb2") + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/tag_lite/TestModifyTag.py b/tests/pytest/tag_lite/TestModifyTag.py index acf63695f6dcc52d2ae9df8cdead96802cd1f4b3..2e14d293ed6466be40cc40980ff8893a3eadeefe 100644 --- a/tests/pytest/tag_lite/TestModifyTag.py +++ b/tests/pytest/tag_lite/TestModifyTag.py @@ -50,8 +50,8 @@ class TDTestCase: buildPath = root[:len(root) - len("/build/bin")] break return buildPath - - + + def run(self): @@ -122,4 +122,4 @@ class TDTestCase: tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tag_lite/alter_tag.py b/tests/pytest/tag_lite/alter_tag.py index 95acf792932a8bf7d3dacdcb0b90d7a32564ad03..977b03e85a0bf5c6eb39f0b40a1af00def34af5b 100644 --- a/tests/pytest/tag_lite/alter_tag.py +++ b/tests/pytest/tag_lite/alter_tag.py @@ -43,9 +43,9 @@ class TDTestCase: tdSql.checkData(0, 6, None) tdSql.checkData(1, 6, 'test') - # Test case for: https://jira.taosdata.com:18080/browse/TD-2423 + # Test case for: https://jira.taosdata.com:18080/browse/TD-2423 tdSql.execute("create table stb(ts timestamp, col1 int, col2 nchar(20)) tags(tg1 int, tg2 binary(20), tg3 nchar(25))") - tdSql.execute("insert into tb1 using stb(tg1, tg3) tags(1, 'test1') values(now, 1, 'test1')") + tdSql.execute("insert into tb1 using stb(tg1, tg3) tags(1, 'test1') values(now, 1, 'test1')") tdSql.query("select *, tg1, tg2, tg3 from tb1") tdSql.checkRows(1) tdSql.checkData(0, 3, 1) @@ -61,7 +61,7 @@ class TDTestCase: #Test case for TS-1285 tdSql.execute("create table stb2(ts timestamp, c1 int) tags(t1 timestamp)") - tdSql.execute("insert into tb3 using stb2 tags('2022-01-01 18:26:50.224') values(now, 1)") + tdSql.execute("insert into tb3 using stb2 tags('2022-01-01 18:26:50.224') values(now, 1)") tdSql.execute("alter table tb3 set tag t1='2022-03-03 18:26:50.224'") tdSql.query("select * from stb2") tdSql.checkData(0, 2, "2022-03-03 18:26:50.224") diff --git a/tests/pytest/tag_lite/bigint.py b/tests/pytest/tag_lite/bigint.py index 733d30983d07ab9e2c30076b76084edb354e289f..d7efd8a903039464edc392eefdf034e51869f7e4 100644 --- a/tests/pytest/tag_lite/bigint.py +++ b/tests/pytest/tag_lite/bigint.py @@ -577,15 +577,15 @@ class TDTestCase: tdSql.execute("use db") tdSql.execute( "create table if not exists st (ts timestamp, tagtype int) tags(dev bigint)") - + tdSql.execute( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 63) - 1)) tdSql.execute( 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (-1 * pow(2, 63) + 1)) - print("==============step2") + print("==============step2") tdSql.query("show tables") - tdSql.checkRows(2) + tdSql.checkRows(2) def stop(self): tdSql.close() diff --git a/tests/pytest/tag_lite/binary.py b/tests/pytest/tag_lite/binary.py index 3825c6637f9357e00bc8491be1d8c2960dde2109..d62d515d99da133c3afc974437d10522f0d73908 100644 --- a/tests/pytest/tag_lite/binary.py +++ b/tests/pytest/tag_lite/binary.py @@ -583,13 +583,13 @@ class TDTestCase: "create table if not exists st (ts timestamp, tagtype int) tags(dev binary(5))") tdSql.error( 'CREATE TABLE if not exists dev_001 using st tags("dev_001")') - + tdSql.execute( 'CREATE TABLE if not exists dev_002 using st tags("dev")') - print("==============step2") + print("==============step2") tdSql.query("show tables") - tdSql.checkRows(1) + tdSql.checkRows(1) def stop(self): tdSql.close() diff --git a/tests/pytest/tag_lite/int.py b/tests/pytest/tag_lite/int.py index 1297d083a0d9aa30a21c3235c89a31236175a119..5410d49a67beb553b489dd6a5d3545f0a03aa448 100644 --- a/tests/pytest/tag_lite/int.py +++ b/tests/pytest/tag_lite/int.py @@ -580,15 +580,15 @@ class TDTestCase: 'CREATE TABLE if not exists dev_001 using st tags(%d)' % pow(2, 31)) tdSql.error( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1 * pow(2, 31))) - + tdSql.execute( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 31) - 1)) tdSql.execute( 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (-1 * pow(2, 31) + 1)) - print("==============step2") + print("==============step2") tdSql.query("show tables") - tdSql.checkRows(2) + tdSql.checkRows(2) def stop(self): tdSql.close() diff --git a/tests/pytest/tag_lite/json_tag_extra.py b/tests/pytest/tag_lite/json_tag_extra.py index 1f2f6b0426df7f1a7a0d75d817bf2b181595971b..1687a561e5c05fe4b48265762e1e15662730178f 100644 --- a/tests/pytest/tag_lite/json_tag_extra.py +++ b/tests/pytest/tag_lite/json_tag_extra.py @@ -47,16 +47,16 @@ class TDTestCase: print("==============step1 tag format =======") tdLog.info("create database ") tdSql.execute("create database db_json") - tdSql.execute("use db_json") - # test tag format + tdSql.execute("use db_json") + # test tag format tdSql.execute("create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json)") tdSql.error("create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json(10000000))") tdSql.error("create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json,jtag1 json)") tdSql.error("create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json,dataBool bool)") - + tdSql.execute("CREATE TABLE if not exists jsons1_1 using jsons1 tags('{\"loc\":\"fff\",\"id\":5}')") - # two stables: jsons1 jsons2 ,test tag's value and key + # two stables: jsons1 jsons2 ,test tag's value and key tdSql.execute("insert into jsons1_1(ts,dataInt) using jsons1 tags('{\"loc+\":\"fff\",\"id\":5}') values (now,12)") tdSql.error("CREATE TABLE if not exists jsons1_1 using jsons1 tags('{oc:\"fff\",\"id\":5}')") diff --git a/tests/pytest/tag_lite/nchar.py b/tests/pytest/tag_lite/nchar.py index 851cc32b56c9104e2f87d5c8ea58ffa0d56ac1a6..072f3e2ba58739241d09252d15e616f61512bdb7 100644 --- a/tests/pytest/tag_lite/nchar.py +++ b/tests/pytest/tag_lite/nchar.py @@ -35,7 +35,7 @@ class TDTestCase: 'CREATE TABLE if not exists dev_002 using st tags("dev")') - print("==============step2") + print("==============step2") tdSql.query("show tables") tdSql.checkRows(1) diff --git a/tests/pytest/tag_lite/smallint.py b/tests/pytest/tag_lite/smallint.py index 93fde22ca92219852426ac18c550231130d23384..883e830976cb5a4eb2e4d060f8bbedb494e60487 100644 --- a/tests/pytest/tag_lite/smallint.py +++ b/tests/pytest/tag_lite/smallint.py @@ -580,15 +580,15 @@ class TDTestCase: 'CREATE TABLE if not exists dev_001 using st tags(%d)' % pow(2, 15)) tdSql.error( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1 * pow(2, 15))) - + tdSql.execute( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 15) - 1)) tdSql.execute( 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (-1 * pow(2, 15) + 1)) - print("==============step2") + print("==============step2") tdSql.query("show tables") - tdSql.checkRows(2) + tdSql.checkRows(2) def stop(self): tdSql.close() diff --git a/tests/pytest/tag_lite/timestamp.py b/tests/pytest/tag_lite/timestamp.py index fa71c2e15422e80076f2b6a6eb26e8198a69a569..00dc0eec3cce1543f2e2c6a808e053389f24cea0 100644 --- a/tests/pytest/tag_lite/timestamp.py +++ b/tests/pytest/tag_lite/timestamp.py @@ -46,7 +46,7 @@ class TDTestCase: tdLog.info('=============== step2') tdSql.query('select * from %s' % (mt)) tdSql.checkRows(5 * rowNum) - + tdSql.query('select * from %s where tgTs = %ld and tgcol2 = 0' % (mt, ts)) tdSql.checkRows(rowNum) @@ -54,7 +54,7 @@ class TDTestCase: tdSql.checkRows(rowNum) tdLog.info('=============== step3') - i = 0 + i = 0 while (i < 5): tb = "%s%d" % (tbPrefix, i + 100) tdLog.info('create table %s using %s tags(%d, \"%s\", %d)' % (tb, mt, i + 100, tsStr, i + 100)) @@ -80,7 +80,7 @@ class TDTestCase: tdLog.info('=============== step4') i = 0 - tb = "%s%d"%(tbPrefix, i + 1000) + tb = "%s%d"%(tbPrefix, i + 1000) tdSql.execute('insert into %s using %s tags(%d, \"%s\", %d) values(now, 10)' % (tb, mt, i + 100, tsStr, i + 1000)) tdSql.execute('insert into %s using %s tags(%d, \"%s\", %d) values(now+2s, 10)' % (tb, mt, i + 100, tsStr, i + 1000)) tdSql.execute('insert into %s using %s tags(%d, \"%s\", %d) values(now+3s, 10)' % (tb, mt, i + 100, tsStr, i + 1000)) @@ -88,11 +88,11 @@ class TDTestCase: tdSql.checkRows(3) i = 0 - tb = "%s%d"%(tbPrefix, i + 10000) + tb = "%s%d"%(tbPrefix, i + 10000) tdSql.execute('create table %s using %s tags(%d, now, %d)' % (tb, mt, i + 10000,i + 10000)) tdSql.checkRows(3) - - + + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/tag_lite/tinyint.py b/tests/pytest/tag_lite/tinyint.py index fc4af4ee9648ef6aca5badeada5420063f76050b..529ad7b9f13d35a540d9561fc684df9d7b5562ff 100644 --- a/tests/pytest/tag_lite/tinyint.py +++ b/tests/pytest/tag_lite/tinyint.py @@ -581,15 +581,15 @@ class TDTestCase: 'CREATE TABLE if not exists dev_001 using st tags(%d)' % pow(2, 7)) tdSql.error( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1 * pow(2, 7))) - + tdSql.execute( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 7) - 1)) tdSql.execute( 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (-1 * pow(2, 7) + 1)) - print("==============step2") + print("==============step2") tdSql.query("show tables") - tdSql.checkRows(2) + tdSql.checkRows(2) def stop(self): tdSql.close() diff --git a/tests/pytest/tag_lite/too_many_tag_condtions.py b/tests/pytest/tag_lite/too_many_tag_condtions.py index a40de405fffeff50ab5794a7838b869345430bf4..63bfd1bbb000946a4961de1a629b48172c513171 100644 --- a/tests/pytest/tag_lite/too_many_tag_condtions.py +++ b/tests/pytest/tag_lite/too_many_tag_condtions.py @@ -13,12 +13,12 @@ class TDTestCase: def run(self): tdSql.prepare() - + tdLog.info('======================== dnode1 start') tbPrefix = "ta_cr_tb" mtPrefix = "ta_cr_mt" - tbNum = 2 - rowNum = 10 + tbNum = 2 + rowNum = 10 totalNum = 200 tagCondsLimit = 1024 tdLog.info('=============== step1: create tbl and prepare data') @@ -26,40 +26,40 @@ class TDTestCase: i = 2 mt = "%s%d" % (mtPrefix, i) tb = "%s%d" % (tbPrefix, i) - + sql ='create table %s (ts timestamp, tbcol int) TAGS(tgcol int)'% (mt) tdLog.info(sql) tdSql.execute(sql) - for i in range(0, tbNum): + for i in range(0, tbNum): tblName = "%s%d"%(tbPrefix, i) - sql = 'create table %s using %s TAGS(%d)'%(tblName, mt, i) + sql = 'create table %s using %s TAGS(%d)'%(tblName, mt, i) tdSql.execute(sql) for j in range(0, rowNum): - sql = "insert into %s values(now, %d)"%(tblName, j) + sql = "insert into %s values(now, %d)"%(tblName, j) tdSql.execute(sql) - sqlPrefix = "select * from %s where "%(mt) + sqlPrefix = "select * from %s where "%(mt) for i in range(2, 2048, 1): conds = "tgcol=1 and "* (i - 1) conds = "%stgcol=1"%(conds) sql = "%s%s"%(sqlPrefix, conds) - if i >= tagCondsLimit: + if i >= tagCondsLimit: tdSql.error(sql) - else: + else: tdSql.query(sql) #tdSql.checkRows(1) for i in range(2, 2048, 1): - conds = "" - for j in range(0, i - 1): + conds = "" + for j in range(0, i - 1): conds = conds + "tgcol=%d or "%(j%tbNum) conds += "tgcol=%d"%(i%tbNum) - sql = sqlPrefix + conds + sql = sqlPrefix + conds if i >= tagCondsLimit: tdSql.error(sql) - else: + else: tdSql.query(sql) - + def stop(self): tdSql.close() diff --git a/tests/pytest/tag_lite/unsignedBigint.py b/tests/pytest/tag_lite/unsignedBigint.py index 6a33812f8839bf8c329c35b9c700bf5479d14a64..2fb0d74eaa84e4554643c07c9a0eb7cf7e813c48 100644 --- a/tests/pytest/tag_lite/unsignedBigint.py +++ b/tests/pytest/tag_lite/unsignedBigint.py @@ -580,16 +580,16 @@ class TDTestCase: 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 64) - 1)) tdSql.error( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1)) - + tdSql.execute( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 64) - 2)) tdSql.execute( 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (0)) tdSql.execute( 'CREATE TABLE if not exists dev_003 using st tags(%s)' % ('NULL')) - print("==============step2") + print("==============step2") tdSql.query("show tables") - tdSql.checkRows(3) + tdSql.checkRows(3) def stop(self): tdSql.close() diff --git a/tests/pytest/tag_lite/unsignedInt.py b/tests/pytest/tag_lite/unsignedInt.py index 6e741d351abe5c5608f45e414bcabc6d40dd0980..fe414da3d6327b9463ef161dc24d89a947285a7f 100644 --- a/tests/pytest/tag_lite/unsignedInt.py +++ b/tests/pytest/tag_lite/unsignedInt.py @@ -581,16 +581,16 @@ class TDTestCase: 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 32) - 1)) tdSql.error( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1)) - + tdSql.execute( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 32) - 2)) tdSql.execute( 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (0)) tdSql.execute( 'CREATE TABLE if not exists dev_003 using st tags(%s)' % ('NULL')) - print("==============step2") + print("==============step2") tdSql.query("show tables") - tdSql.checkRows(3) + tdSql.checkRows(3) def stop(self): tdSql.close() diff --git a/tests/pytest/tag_lite/unsignedSmallint.py b/tests/pytest/tag_lite/unsignedSmallint.py index 21c390d9dca81fc6eb6ef87435acb1bf6d12c406..bf70aca883f15c97be5c557760fa361546c2781a 100644 --- a/tests/pytest/tag_lite/unsignedSmallint.py +++ b/tests/pytest/tag_lite/unsignedSmallint.py @@ -580,7 +580,7 @@ class TDTestCase: 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 16)-1)) tdSql.error( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1)) - + tdSql.execute( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 16) - 2)) tdSql.execute( @@ -588,9 +588,9 @@ class TDTestCase: tdSql.execute( 'CREATE TABLE if not exists dev_003 using st tags(%s)' % ('NULL')) - print("==============step2") + print("==============step2") tdSql.query("show tables") - tdSql.checkRows(3) + tdSql.checkRows(3) def stop(self): tdSql.close() diff --git a/tests/pytest/tag_lite/unsignedTinyint.py b/tests/pytest/tag_lite/unsignedTinyint.py index 7ce3a8398444efae63ccdc93062c00c81c644da0..4896c5fc544b64659f6fbadda5841a17747b7239 100644 --- a/tests/pytest/tag_lite/unsignedTinyint.py +++ b/tests/pytest/tag_lite/unsignedTinyint.py @@ -580,16 +580,16 @@ class TDTestCase: 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 8) - 1)) tdSql.error( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1)) - + tdSql.execute( 'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 8) - 2)) tdSql.execute( 'CREATE TABLE if not exists dev_002 using st tags(%d)' % (0)) tdSql.execute( 'CREATE TABLE if not exists dev_003 using st tags(%s)' % ('NULL')) - print("==============step2") + print("==============step2") tdSql.query("show tables") - tdSql.checkRows(3) + tdSql.checkRows(3) def stop(self): tdSql.close() diff --git a/tests/pytest/tools/taosdemoAllTest/queryQps.json b/tests/pytest/tools/taosdemoAllTest/queryQps.json index 6e8b28d7d450c00ec858b9b54c390ea55a357958..9e75d52a6cd360674e633be886f348556e470342 100644 --- a/tests/pytest/tools/taosdemoAllTest/queryQps.json +++ b/tests/pytest/tools/taosdemoAllTest/queryQps.json @@ -9,29 +9,27 @@ "databases": "db", "query_times": 1, "specified_table_query": { - "query_interval": 10000, + "query_interval": 10, "threads": 4, "sqls": [ - { - "sql": "select last_row(*) from stb00_0", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from stb00_9 ", - "result": "./query_res1.txt" - - }] - }, - "super_table_query": { - "stblname": "stb1", - "query_interval":20000, - "threads": 4, - "sqls": [ { - "sql": "select last_row(ts) from xxxx", - "result": "./query_res2.txt" + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_9 ", + "result": "./query_res1.txt" + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":20, + "threads": 4, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" } - ] - } - } - \ No newline at end of file + ] + } +} diff --git a/tests/pytest/tools/taosdemoAllTest/querySuperMutisql100.json b/tests/pytest/tools/taosdemoAllTest/querySuperMutisql100.json index 6a59d4d75d9f7f29e3697c26d72793b9ad8bd554..0f21df47e668d4e8cb5c137bf497192dc915f2f5 100644 --- a/tests/pytest/tools/taosdemoAllTest/querySuperMutisql100.json +++ b/tests/pytest/tools/taosdemoAllTest/querySuperMutisql100.json @@ -10,410 +10,410 @@ "query_times": 3, "super_table_query": { "stblname": "stb0", - "query_interval": 10000, + "query_interval": 10, "threads": 9, "sqls": [ - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select * from xxxx ", - "result": "./query_res0.txt" + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select * from xxxx ", + "result": "./query_res0.txt" + + }] + } +} - }] - } - } - \ No newline at end of file diff --git a/tests/pytest/tools/taosdumpTestBenchmark.py b/tests/pytest/tools/taosdumpTestBenchmark.py deleted file mode 100644 index d3ac7347b3ad237e29ca5c30a918d4b0f7d649c3..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdumpTestBenchmark.py +++ /dev/null @@ -1,442 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - self.ts = 1538548685000 - self.numberOfTables = 10000 - self.numberOfRecords = 100 - - def checkCommunity(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - if ("community" in selfPath): - return False - else: - return True - - def getPath(self, tool="taosdump"): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - paths = [] - for root, dirs, files in os.walk(projPath): - if ((tool) in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - paths.append(os.path.join(root, tool)) - break - if (len(paths) == 0): - return "" - return paths[0] - - def insert_data(self, tbname, ts_start, count): - pre_insert = "insert into %s values" % tbname - sql = pre_insert - tdLog.debug("doing insert table %s rows=%d ..." % (tbname, count)) - for i in range(count): - sql += " (%d,%d)" % (ts_start + i * 1000, i) - if i > 0 and i % 30000 == 0: - tdSql.execute(sql) - sql = pre_insert - # end sql - if sql != pre_insert: - tdSql.execute(sql) - - tdLog.debug("INSERT TABLE DATA ............ [OK]") - return - - def run(self): - if not os.path.exists("./taosdumptest"): - os.makedirs("./taosdumptest") - else: - os.system("rm -rf ./taosdumptest") - os.makedirs("./taosdumptest") - - for i in range(2): - if not os.path.exists("./taosdumptest/tmp%d" % i): - os.makedirs("./taosdumptest/tmp%d" % i) - else: - os.system("rm -rf ./taosdumptest/tmp%d" % i) - os.makedirs("./taosdumptest/tmp%d" % i) - - binPath = self.getPath("taosdump") - if (binPath == ""): - tdLog.exit("taosdump not found!") - else: - tdLog.info("taosdump found: %s" % binPath) - - # create db1 , one stables and one table ; create general tables - tdSql.execute("drop database if exists dp1") - tdSql.execute("drop database if exists dp2") - tdSql.execute("create database if not exists dp1") - tdSql.execute("use dp1") - tdSql.execute( - '''create table st0(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, - c7 bool, c8 binary(20), c9 nchar(20), c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned, c15 timestamp ) - tags(t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 bool, t8 binary(20), t9 nchar(20), t11 tinyint unsigned, - t12 smallint unsigned, t13 int unsigned, t14 bigint unsigned, t15 timestamp)''') - tdSql.execute( - '''create table st1(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, - c7 bool, c8 binary(20), c9 nchar(20), c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned, c15 timestamp ) tags(jtag json)''') - - intData = [] - floatData = [] - rowNum = 10 - tabNum = 10 - ts = 1537146000000 - for j in range(tabNum): - tdSql.execute( - "create table st0_%d using st0 tags( %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d);" % - (j, - j + - 1, - j + - 1, - j + - 1, - j + - 1, - j + - 0.1, - j + - 0.1, - j % - 2, - j + - 1, - j + - 1, - j + - 1, - j + - 1, - j + - 1, - j + - 1, - ts)) - for i in range(rowNum): - tdSql.execute( - "insert into st0_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" % - (j, ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % - 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, ts)) - intData.append(i + 1) - floatData.append(i + 0.1) - rowNum = 20 - tabNum = 20 - for j in range(tabNum): - tdSql.execute( - "create table st1_%d using st1 tags('{\"nv\":null,\"tea\":true,\"\":false,\" \":123%d,\"tea\":false}');" % - (j, j + 1)) - for i in range(rowNum): - tdSql.execute( - "insert into st1_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" % - (j, self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % - 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, self.ts)) - intData.append(i + 1) - floatData.append(i + 0.1) - # os.system("%staosBenchmark -f tools/taosdump-insert-dp1.json -y " % benchBinPath) - - # create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1 - # \stb3,include ctables stb3_0 and stb3_1 - # create general three tables gt0 gt1 gt2 - tdSql.execute("create database if not exists dp2") - tdSql.execute("use dp2") - tdSql.execute( - "create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)") - tdSql.execute( - "create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ") - tdSql.execute( - "insert into st0_0 values(1614218412000,8600,'R')(1614218422000,8600,'E')") - tdSql.execute( - "insert into st0_1 values(1614218413000,8601,'A')(1614218423000,8601,'D')") - tdSql.execute( - "create stable st1(ts timestamp, c11 float, c12 nchar(10)) tags(t1 int)") - tdSql.execute( - "create table st1_0 using st1 tags(0) st1_1 using st1 tags(1) ") - tdSql.execute( - "insert into st1_0 values(1614218412000,8610.1,'R')(1614218422000,8610.1,'E')") - tdSql.execute( - "insert into st1_1 values(1614218413000,8611.2,'A')(1614218423000,8611.1,'D')") - tdSql.execute( - "create stable st2(ts timestamp, c21 float, c22 nchar(10)) tags(t1 int)") - tdSql.execute( - "create table st20 using st2 tags(0) st21 using st2 tags(1) ") - tdSql.execute( - "insert into st20 values(1614218412000,8620.3,'R')(1614218422000,8620.3,'E')") - tdSql.execute( - "insert into st21 values(1614218413000,8621.4,'A')(1614218423000,8621.4,'D')") - tdSql.execute( - "create table if not exists gt0 (ts timestamp, c00 int, c01 float) ") - tdSql.execute( - "create table if not exists gt1 (ts timestamp, c10 int, c11 double) ") - tdSql.execute( - "create table if not exists gt2 (ts timestamp, c20 int, c21 float) ") - tdSql.execute("insert into gt0 values(1614218412700,8637,78.86155)") - tdSql.execute( - "insert into gt1 values(1614218413800,8638,78.862020199)") - tdSql.execute("insert into gt2 values(1614218413900,8639,78.863)") - # self.insert_data("t", self.ts, 300*10000); - # os.system("%staosBenchmark -f tools/taosdump-insert-dp2.json -y " % benchBinPath) - - # # taosdump data - # os.system("%s -o ./taosdumptest/tmp1 taosdump -h -ptaosdata -P 6030 -u root -o taosdumptest \ - # -D dp1,dp3 -N -c /home/chr/TDinternal/community/sim/dnode1/cfg/taos.cfg -s -d deflate" % binPath) - os.system( - "%s -o ./taosdumptest/tmp0 -D dp2,dp1 -T 8" % - binPath) - os.system( - "%s -o ./taosdumptest/tmp1 dp2 st0 st1_0 gt0 -T 8" % - binPath) - - # check taosdumptest/tmp0 - tdSql.execute("drop database dp1") - tdSql.execute("drop database dp2") - os.system("%s -i ./taosdumptest/tmp0 -T 8 " % binPath) - tdSql.execute("reset query cache") - - tdSql.execute("use dp1") - tdSql.query("show stables") - tdSql.checkRows(3) - for i in range(3): - for j in range(3): - if j < 2: - if tdSql.queryResult[i][0] == 'st%d' % j: - tdSql.checkData(i, 4, (j + 1) * 10) - else: - if tdSql.queryResult[i][0] == 'st%d' % j: - tdSql.checkData(i, 4, 100002) - - tdSql.query("select count(*) from st0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count(*) from st1") - tdSql.checkData(0, 0, 400) - tdSql.query("select count(*) from st2") - tdSql.checkData(0, 0, 1000020) - - tdSql.execute("use dp2") - tdSql.query("show stables") - tdSql.checkRows(3) - for i in range(3): - for j in range(3): - if j < 2: - if tdSql.queryResult[i][0] == 'st%d' % j: - # print(i,"stb%d"%j) - tdSql.checkData(i, 4, 2) - else: - if tdSql.queryResult[i][0] == 'st%d' % j: - tdSql.checkData(i, 4, 100002) - tdSql.query("select count(*) from st0") - tdSql.checkData(0, 0, 4) - tdSql.query("select count(*) from st1") - tdSql.checkData(0, 0, 4) - tdSql.query("select count(*) from st2") - tdSql.checkData(0, 0, 1000024) - tdSql.query("select ts from gt0") - tdSql.checkData(0, 0, '2021-02-25 10:00:12.700') - tdSql.query("select c10 from gt1") - tdSql.checkData(0, 0, 8638) - tdSql.query("select c20 from gt2") - tdSql.checkData(0, 0, 8639) - - # check taosdumptest/tmp1 - tdSql.execute("drop database dp1") - tdSql.execute("drop database dp2") - os.system("%s -i ./taosdumptest/tmp1 -T 8 " % binPath) - tdSql.execute("reset query cache") - tdSql.execute("use dp2") - tdSql.query("show stables") - tdSql.checkRows(2) - tdSql.query("show tables") - tdSql.checkRows(4) - tdSql.query("select count(*) from st1_0") - tdSql.checkData(0, 0, 2) - tdSql.query("select ts from gt0") - tdSql.checkData(0, 0, '2021-02-25 10:00:12.700') - tdSql.error("use dp1") - tdSql.error("select count(*) from st2_0") - tdSql.error("select count(*) from gt2") - - # #check taosdumptest/tmp2 - # tdSql.execute("drop database dp1") - # tdSql.execute("drop database dp2") - # os.system("%s -i ./taosdumptest/tmp2 -T 8 " % binPath) - # tdSql.execute("use dp1") - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(3) - # tdSql.query("select c1 from st0_0 order by ts") - # tdSql.checkData(0,0,8537) - # tdSql.query("select c2 from st0_1 order by ts") - # tdSql.checkData(1,0,"D") - # tdSql.query("select * from gt0") - # tdSql.checkData(0,0,'2021-02-25 10:00:12.000') - # tdSql.checkData(0,1,637) - # tdSql.error("select count(*) from gt1") - # tdSql.error("use dp2") - - # #check taosdumptest/tmp3 - # tdSql.execute("drop database dp1") - # os.system("%s -i ./taosdumptest/tmp3 -T 8 " % binPath) - # tdSql.execute("use dp2") - # tdSql.query("show stables") - # tdSql.checkRows(2) - # tdSql.query("show tables") - # tdSql.checkRows(4) - # tdSql.query("select count(*) from st1_0") - # tdSql.checkData(0,0,2) - # tdSql.query("select ts from gt0") - # tdSql.checkData(0,0,'2021-02-25 10:00:12.700') - # tdSql.error("use dp1") - # tdSql.error("select count(*) from st2_0") - # tdSql.error("select count(*) from gt2") - - # #check taosdumptest/tmp4 - # tdSql.execute("drop database dp2") - # os.system("%s -i ./taosdumptest/tmp4 -T 8 " % binPath) - # tdSql.execute("use dp2") - # tdSql.query("show stables") - # tdSql.checkRows(2) - # tdSql.query("show tables") - # tdSql.checkRows(6) - # tdSql.query("select c20 from gt2") - # tdSql.checkData(0, 0, 8639) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st0_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st2_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st2_0") - # tdSql.checkData(0, 0, 2) - # tdSql.error("use dp1") - # tdSql.error("select count(*) from st1_0") - # tdSql.error("select count(*) from st1_1") - # tdSql.error("select count(*) from gt3") - - # #check taosdumptest/tmp5 - # tdSql.execute("drop database dp2") - # os.system("%s -i ./taosdumptest/tmp5 -T 8 " % binPath) - # tdSql.execute("use dp2") - # tdSql.query("show stables") - # tdSql.checkRows(3) - # tdSql.query("show tables") - # tdSql.checkRows(9) - # tdSql.query("select c20 from gt2") - # tdSql.checkData(0, 0, 8639) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st0_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st2_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st2_0") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st1_1") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select count(*) from st1_0") - # tdSql.checkData(0, 0, 2) - # tdSql.execute("use dp1") - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(4) - # tdSql.query("select c1 from st0_0 order by ts") - # tdSql.checkData(0,0,8537) - # tdSql.query("select c2 from st0_1 order by ts") - # tdSql.checkData(1,0,"D") - # tdSql.query("select * from gt0") - # tdSql.checkData(0,0,'2021-02-25 10:00:12.000') - # tdSql.checkData(0,1,637) - - # # check taosdumptest/tmp6 - # tdSql.execute("drop database dp1") - # tdSql.execute("drop database dp2") - # tdSql.execute("drop database dp3") - # os.system("%s -i ./taosdumptest/tmp6 -T 8 " % binPath) - # tdSql.execute("use dp3") - # tdSql.query("show databases") - # tdSql.checkRows(1) - # tdSql.checkData(0,16,'ns') - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(1) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkData(0, 0, 2) - # tdSql.query("select * from st0 order by ts") - # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') - # tdSql.checkData(0,1,8600) - - # # check taosdumptest/tmp7 - # tdSql.execute("drop database dp3") - # os.system("%s -i ./taosdumptest/tmp7 -T 8 " % binPath) - # tdSql.execute("use dp3") - # tdSql.query("show databases") - # tdSql.checkRows(1) - # tdSql.checkData(0,16,'ms') - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(1) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkRows(0) - # # tdSql.query("select * from st0 order by ts") - # # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') - # # tdSql.checkData(0,1,8600) - - # # check taosdumptest/tmp8 - # tdSql.execute("drop database dp3") - # os.system("%s -i ./taosdumptest/tmp8 -T 8 " % binPath) - # tdSql.execute("use dp3") - # tdSql.query("show stables") - # tdSql.checkRows(1) - # tdSql.query("show tables") - # tdSql.checkRows(1) - # tdSql.query("select count(*) from st0_0") - # tdSql.checkRows(0) - # # tdSql.query("select * from st0 order by ts") - # # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') - # # tdSql.checkData(0,1,8600) - - # os.system("rm -rf ./taosdumptest/tmp1") - # os.system("rm -rf ./taosdumptest/tmp2") - # os.system("rm -rf ./taosdumptest/tmp3") - # os.system("rm -rf ./taosdumptest/tmp4") - # os.system("rm -rf ./taosdumptest/tmp5") - # os.system("rm -rf ./dump_result.txt") - # os.system("rm -rf ./db.csv") - - 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/dnodes.py b/tests/pytest/util/dnodes.py index a2c837ebfcce5b355b92080e66d109e1543b407f..d3565a371b4b52e77e8aa5123094ceb6c6d2051b 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -142,6 +142,7 @@ class TDDnode: "numOfMnodes": "3", "numOfThreadsPerCore": "2.0", "monitor": "0", + "audit": "0", "maxVnodeConnections": "30000", "maxMgmtConnections": "30000", "maxMeterConnections": "30000", diff --git a/tests/script/general/alter/column_width_commit.sim b/tests/script/general/alter/column_width_commit.sim new file mode 100644 index 0000000000000000000000000000000000000000..790f92134bc728916e4ca54d70b8ed2091bde688 --- /dev/null +++ b/tests/script/general/alter/column_width_commit.sim @@ -0,0 +1,50 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ======== step1 create db +sql drop database if exists db1; +sql CREATE DATABASE db1; +sql use db1; + +print ======== step2 create normal table +sql CREATE TABLE normal_t1('ts' TIMESTAMP, 'c1' BINARY(1)); + +print ======== step3 alter column width +sql alter table db1.normal_t1 modify column c1 binary(2400); + +print ======== step4 insert into 20 rows +$ms = 0 +$cnt = 0 +while $cnt < 20 + $ms = $cnt . m + sql insert into normal_t1(ts,c1) values(now + $ms , '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'); + $cnt = $cnt + 1 + endw + +######################################################## +print ===> step 4 stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT + +######################################################## +print ===> step 5 start dnode1 +system sh/exec.sh -n dnode1 -s start + +sleep 1000 + +sql select count(*) from db1.normal_t1; +print $data00 +if $rows != 1 then + return -1 +endi +if $data00 != 20 then + return -1 +endi + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim index 36f4c0e7dcfca27f77b0e701adff47e06f9d1bb0..52777dc08c75b44a1f3a5b713940c386f854aa81 100644 --- a/tests/script/general/db/alter_option.sim +++ b/tests/script/general/db/alter_option.sim @@ -9,7 +9,7 @@ sleep 2000 sql connect print ============= create database -sql create database db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 +sql create database db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 1200 ctime 120 precision 'ms' comp 2 wal 1 replica 1 sql show databases if $data00 != db then return -1 @@ -182,9 +182,13 @@ sql_error alter database db blocks -1 sql_error alter database db blocks 10001 print ============== step minrows +sql_error alter database db minrows 0 sql_error alter database db minrows 1 -sql_error alter database db minrows 100 -sql_error alter database db minrows 1000 +sql_error alter database db minrows -1 +sql_error alter database db minrows 9 +sql_error alter database db minrows 1001 +sql alter database db minrows 100 +sql alter database db minrows 1000 print ============== step maxrows sql_error alter database db maxrows 1 diff --git a/tests/script/general/db/topic1.sim b/tests/script/general/db/topic1.sim index 16399731208915602fea6dcd123fb85edf2e085b..ecf3c13f70b0e5957ef031a5e40c10b3dcf5145f 100644 --- a/tests/script/general/db/topic1.sim +++ b/tests/script/general/db/topic1.sim @@ -471,8 +471,9 @@ sql_error alter topic db blocks 10001 print ============== step minrows sql_error alter database db minrows 1 -sql_error alter database db minrows 100 -sql_error alter database db minrows 1000 +sql alter database db minrows 100 +sql alter database db minrows 399 +sql_error alter database db minrows 1001 sql_error alter topic db minrows 1 sql_error alter topic db minrows 100 diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 67eadbf851a7185c131220c94d046247ff89d166..56c24e6444e57f18654458cdcd27902f45ac59e3 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -193,6 +193,7 @@ cd ../../../debug; make ./test.sh -f general/alter/insert2.sim ./test.sh -f general/alter/metrics.sim ./test.sh -f general/alter/table.sim +./test.sh -f general/alter/column_width_commit.sim ./test.sh -f general/cache/new_metrics.sim ./test.sh -f general/cache/restart_metrics.sim ./test.sh -f general/cache/restart_table.sim diff --git a/tests/script/sh/deploy.bat b/tests/script/sh/deploy.bat index 921f1611fb5ea80bbeb746b693d7c529c421ef27..1ebb57fcfe3525f03494d5cc94cc250be58f5cef 100644 --- a/tests/script/sh/deploy.bat +++ b/tests/script/sh/deploy.bat @@ -85,6 +85,7 @@ echo wdebugFlag 135 >> %TAOS_CFG% echo cqdebugFlag 135 >> %TAOS_CFG% echo monitor 0 >> %TAOS_CFG% echo monitorInterval 1 >> %TAOS_CFG% +echo audit 0 >> %TAOS_CFG% echo http 0 >> %TAOS_CFG% echo slaveQuery 0 >> %TAOS_CFG% echo numOfThreadsPerCore 2.0 >> %TAOS_CFG% diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index cde27d7dc3fa00258d9d9d50ee3dfc82f858b138..764a64e888d9b3a9f776224deac2acc904fef8a4 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -139,6 +139,7 @@ echo "wdebugFlag 143" >> $TAOS_CFG echo "cqdebugFlag 143" >> $TAOS_CFG echo "monitor 0" >> $TAOS_CFG echo "monitorInterval 1" >> $TAOS_CFG +echo "audit 0" >> $TAOS_CFG echo "http 0" >> $TAOS_CFG echo "slaveQuery 0" >> $TAOS_CFG echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG diff --git a/tests/system-test/0-others/audit.py b/tests/system-test/0-others/audit.py new file mode 100644 index 0000000000000000000000000000000000000000..e4e0cad31015adf0a8204f899e9db177d1230ab8 --- /dev/null +++ b/tests/system-test/0-others/audit.py @@ -0,0 +1,225 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +import time +import os +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + + updatecfgDict = {'audit': 1} + + def caseDescription(self): + ''' + TS-1887 Create Audit db for DDL storage + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + now = time.time() + self.ts = int(round(now * 1000)) + + def run(self): + + #tdSql.prepare() + time.sleep(3) + + print("==============step1 test CREATE DDL") + + # CREATE DATABASE + tdSql.execute("create database db") + tdSql.execute("use db") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'CREATE DATABASE') + tdSql.checkData(0, 4, '0.db') + tdSql.checkData(0, 5, 'success') + + # CREATE NORMAL TABLE + tdSql.execute("create table tb (ts timestamp, c0 int)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'CREATE TABLE') + tdSql.checkData(0, 4, '0.db.tb') + tdSql.checkData(0, 5, 'success') + + # CREATE SUPER TABLE + tdSql.execute("create table stb (ts timestamp, c0 int) tags (t0 int)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'CREATE SUPER TABLE') + tdSql.checkData(0, 4, '0.db.stb') + tdSql.checkData(0, 5, 'success') + + # CREATE CHILD TABLE + tdSql.execute("create table ctb using stb tags (1)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'CREATE CHILD TABLE') + tdSql.checkData(0, 4, '0.db.ctb') + tdSql.checkData(0, 5, 'success') + + # CREATE CHILD TABLE(AUTO) + tdSql.execute("insert into ctb_auto using stb tags (2) values (now, 2)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'CREATE CHILD TABLE') + tdSql.checkData(0, 4, '0.db.ctb_auto') + tdSql.checkData(0, 5, 'success') + + print("==============step2 test ALTER DDL") + + # ALTER ATABASE + tdSql.execute("alter database db keep 354") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'ALTER DATABASE') + tdSql.checkData(0, 4, '0.db') + tdSql.checkData(0, 5, 'success') + + tdSql.execute("alter database db cachelast 1") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'ALTER DATABASE') + tdSql.checkData(0, 4, '0.db') + tdSql.checkData(0, 5, 'success') + + # ADD COLUMN NORMAL TABLE + tdSql.execute("alter table tb add column c1 binary(4)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'ADD COLUMN') + tdSql.checkData(0, 4, '0.db.tb') + tdSql.checkData(0, 5, 'success') + + # MODIFY COLUMN NORMAL TABLE + tdSql.execute("alter table tb modify column c1 binary(10)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'MODIFY COLUMN/TAG LENGTH') + tdSql.checkData(0, 4, '0.db.tb') + tdSql.checkData(0, 5, 'success') + + # ADD COLUMN SUPER TABLE + tdSql.execute("alter table stb add column c1 binary(4)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'ADD COLUMN') + tdSql.checkData(0, 4, '0.db.stb') + tdSql.checkData(0, 5, 'success') + + # ADD TAG SUPER TABLE + tdSql.execute("alter table stb add tag t1 binary(4)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'ADD TAG') + tdSql.checkData(0, 4, '0.db.stb') + tdSql.checkData(0, 5, 'success') + + # MODIFY COLUMN SUPER TABLE + tdSql.execute("alter table stb modify column c1 binary(10)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'MODIFY COLUMN/TAG LENGTH') + tdSql.checkData(0, 4, '0.db.stb') + tdSql.checkData(0, 5, 'success') + + # MODIFY TAG SUPER TABLE + tdSql.execute("alter table stb modify tag t1 binary(10)") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'MODIFY COLUMN/TAG LENGTH') + tdSql.checkData(0, 4, '0.db.stb') + tdSql.checkData(0, 5, 'success') + + # CHANGE TAG NAME SUPER TABLE + tdSql.execute("alter table stb change tag t1 t2") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'CHANGE TAG NAME') + tdSql.checkData(0, 4, '0.db.stb') + tdSql.checkData(0, 5, 'success') + + + print("==============step3 test DROP DDL") + # DROP COLUMN NORMAL TABLE + tdSql.execute("alter table tb drop column c1") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'DROP COLUMN') + tdSql.checkData(0, 4, '0.db.tb') + tdSql.checkData(0, 5, 'success') + + # DROP COLUMN SUPER TABLE + tdSql.execute("alter table stb drop column c1") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'DROP COLUMN') + tdSql.checkData(0, 4, '0.db.stb') + tdSql.checkData(0, 5, 'success') + + # DROP TAG SUPER TABLE + tdSql.execute("alter table stb drop tag t2") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'DROP TAG') + tdSql.checkData(0, 4, '0.db.stb') + tdSql.checkData(0, 5, 'success') + + # DROP NORMAL TABLE + tdSql.execute("drop table tb") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'DROP TABLE') + tdSql.checkData(0, 4, '0.db.tb') + tdSql.checkData(0, 5, 'success') + + # DROP CHILD TABLE + tdSql.execute("drop table ctb") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'DROP CHILD TABLE') + tdSql.checkData(0, 4, '0.db.ctb') + tdSql.checkData(0, 5, 'success') + + # DROP SUPER TABLE + tdSql.execute("drop table stb") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'DROP SUPER TABLE') + tdSql.checkData(0, 4, '0.db.stb') + tdSql.checkData(0, 5, 'success') + + # DROP DATABASE + tdSql.execute("drop database db") + + tdSql.query("select last(*) from audit.ddl"); + tdSql.checkData(0, 3, 'DROP DATABASE') + tdSql.checkData(0, 4, '0.db') + tdSql.checkData(0, 5, 'success') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/5-taos-tools/TD-12478.py b/tests/system-test/5-taos-tools/TD-12478.py index 69849d3c7a7962955619a2674367402b5352376e..4328d65ba0883865bc7ed63b7acfddd659f5ea06 100644 --- a/tests/system-test/5-taos-tools/TD-12478.py +++ b/tests/system-test/5-taos-tools/TD-12478.py @@ -28,13 +28,13 @@ from itertools import combinations from faker import Faker import subprocess + class TDTestCase: def caseDescription(self): - ''' - case1[TD-12434]:taosdump null nchar/binary length can cause core:taos-tools/src/taosdump.c - case2[TD-12478]:taos_stmt_execute() failed! reason: WAL size exceeds limit - ''' - return + """ + case1[TD-12434]:taosdump null nchar/binary length can cause core:taos-tools/src/taosdump.c + case2[TD-12478]:taos_stmt_execute() failed! reason: WAL size exceeds limit + """ def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) @@ -43,104 +43,184 @@ class TDTestCase: os.system("rm -rf 5-taos-tools/TD-12478.py.sql") os.system("rm db*") os.system("rm dump_result.txt*") - + os.system("rm -rf taosdump.*") + def restartDnodes(self): tdDnodes.stop(1) tdDnodes.start(1) - def dropandcreateDB_random(self,n): + def dropandcreateDB_random(self, n): self.ts = 1630000000000 - - fake = Faker('zh_CN') + + fake = Faker("zh_CN") self.num_random = fake.random_int(min=1000, max=5000, step=1) print(self.num_random) for i in range(n): - tdSql.execute('''drop database if exists db ;''') - tdSql.execute('''create database db keep 36500;''') - tdSql.execute('''use db;''') + tdSql.execute("""drop database if exists db ;""") + tdSql.execute("""create database db keep 36500;""") + tdSql.execute("""use db;""") - tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + tdSql.execute( + """create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ - tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') - tdSql.execute('''create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);""" + ) + tdSql.execute( + """create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ - tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') - - tdSql.execute('''create table table_1 using stable_1 tags('table_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') - tdSql.execute('''create table table_2 using stable_1 tags('table_2', '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , 'binary2' , 'nchar2' , '2' , '22' , \'1999-09-09 09:09:09.090\')''') - tdSql.execute('''create table table_3 using stable_1 tags('table_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , \'2099-09-09 09:09:09.090\')''') - tdSql.execute('''create table table_21 using stable_2 tags('table_21' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') - - #regular table - tdSql.execute('''create table regular_table_1 \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);""" + ) + + tdSql.execute( + """create table table_1 using stable_1 tags('table_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')""" + ) + tdSql.execute( + """create table table_2 using stable_1 tags('table_2', '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , 'binary2' , 'nchar2' , '2' , '22' , \'1999-09-09 09:09:09.090\')""" + ) + tdSql.execute( + """create table table_3 using stable_1 tags('table_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , \'2099-09-09 09:09:09.090\')""" + ) + tdSql.execute( + """create table table_21 using stable_2 tags('table_21' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')""" + ) + + # regular table + tdSql.execute( + """create table regular_table_1 \ (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') - tdSql.execute('''create table regular_table_2 \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;""" + ) + tdSql.execute( + """create table regular_table_2 \ (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') - tdSql.execute('''create table regular_table_3 \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;""" + ) + tdSql.execute( + """create table regular_table_3 \ (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') - - - for i in range(self.num_random): - tdSql.execute('''insert into table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' - % (self.ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1), - fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) - tdSql.execute('''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' - % (self.ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1) , - fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1) , - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) - - tdSql.execute('''insert into table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' - % (self.ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), - fake.random_int(min=0, max=9223372036854775807, step=1), - fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) - tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' - % (self.ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), - fake.random_int(min=0, max=9223372036854775807, step=1), - fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) - - tdSql.execute('''insert into table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)''' - % (self.ts + i*1000, fake.random_int(min=-2147483647, max=0, step=1), - fake.random_int(min=-9223372036854775807, max=0, step=1), - fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) - tdSql.execute('''insert into regular_table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' - % (self.ts + i*1000, fake.random_int(min=-2147483647, max=0, step=1), - fake.random_int(min=-9223372036854775807, max=0, step=1), - fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , self.ts + i)) + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;""" + ) + + for i in range(self.num_random): + tdSql.execute( + """insert into table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)""" + % ( + self.ts + i * 1000, + fake.random_int(min=-2147483647, max=2147483647, step=1), + fake.random_int( + min=-9223372036854775807, max=9223372036854775807, step=1 + ), + fake.random_int(min=-32767, max=32767, step=1), + fake.random_int(min=-127, max=127, step=1), + fake.pyfloat(), + fake.pyfloat(), + fake.pystr(), + fake.address(), + self.ts + i, + ) + ) + tdSql.execute( + """insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)""" + % ( + self.ts + i * 1000, + fake.random_int(min=-2147483647, max=2147483647, step=1), + fake.random_int( + min=-9223372036854775807, max=9223372036854775807, step=1 + ), + fake.random_int(min=-32767, max=32767, step=1), + fake.random_int(min=-127, max=127, step=1), + fake.pyfloat(), + fake.pyfloat(), + fake.pystr(), + fake.address(), + self.ts + i, + ) + ) + + tdSql.execute( + """insert into table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)""" + % ( + self.ts + i * 1000, + fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1), + fake.random_int(min=0, max=127, step=1), + fake.pyfloat(), + fake.pyfloat(), + fake.pystr(), + fake.address(), + self.ts + i, + ) + ) + tdSql.execute( + """insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)""" + % ( + self.ts + i * 1000, + fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1), + fake.random_int(min=0, max=127, step=1), + fake.pyfloat(), + fake.pyfloat(), + fake.pystr(), + fake.address(), + self.ts + i, + ) + ) + + tdSql.execute( + """insert into table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d)""" + % ( + self.ts + i * 1000, + fake.random_int(min=-2147483647, max=0, step=1), + fake.random_int(min=-9223372036854775807, max=0, step=1), + fake.random_int(min=-32767, max=0, step=1), + fake.random_int(min=-127, max=0, step=1), + fake.pyfloat(), + fake.pyfloat(), + fake.pystr(), + fake.address(), + self.ts + i, + ) + ) + tdSql.execute( + """insert into regular_table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)""" + % ( + self.ts + i * 1000, + fake.random_int(min=-2147483647, max=0, step=1), + fake.random_int(min=-9223372036854775807, max=0, step=1), + fake.random_int(min=-32767, max=0, step=1), + fake.random_int(min=-127, max=0, step=1), + fake.pyfloat(), + fake.pyfloat(), + fake.pystr(), + fake.address(), + self.ts + i, + ) + ) tdSql.query("select count(*) from stable_1;") - tdSql.checkData(0,0,3*self.num_random) + tdSql.checkData(0, 0, 3 * self.num_random) tdSql.query("select count(*) from regular_table_1;") - tdSql.checkData(0,0,self.num_random) + tdSql.checkData(0, 0, self.num_random) def run(self): tdSql.prepare() dcDB = self.dropandcreateDB_random(1) - + assert os.system("taosdump -D db") == 0 assert os.system("taosdump -i . -g") == 0 tdSql.query("select count(*) from stable_1;") - tdSql.checkData(0,0,3*self.num_random) + tdSql.checkData(0, 0, 3 * self.num_random) tdSql.query("select count(*) from regular_table_1;") - tdSql.checkData(0,0,self.num_random) + tdSql.checkData(0, 0, self.num_random) tdSql.query("select count(*) from regular_table_2;") - tdSql.checkData(0,0,self.num_random) + tdSql.checkData(0, 0, self.num_random) tdSql.query("select count(*) from regular_table_3;") - tdSql.checkData(0,0,self.num_random) - - + tdSql.checkData(0, 0, self.num_random) def stop(self): tdSql.close() @@ -148,4 +228,4 @@ class TDTestCase: tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/5-taos-tools/taosbenchmark/queryQps.json b/tests/system-test/5-taos-tools/taosbenchmark/queryQps.json index 6e8b28d7d450c00ec858b9b54c390ea55a357958..9e75d52a6cd360674e633be886f348556e470342 100644 --- a/tests/system-test/5-taos-tools/taosbenchmark/queryQps.json +++ b/tests/system-test/5-taos-tools/taosbenchmark/queryQps.json @@ -9,29 +9,27 @@ "databases": "db", "query_times": 1, "specified_table_query": { - "query_interval": 10000, + "query_interval": 10, "threads": 4, "sqls": [ - { - "sql": "select last_row(*) from stb00_0", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from stb00_9 ", - "result": "./query_res1.txt" - - }] - }, - "super_table_query": { - "stblname": "stb1", - "query_interval":20000, - "threads": 4, - "sqls": [ { - "sql": "select last_row(ts) from xxxx", - "result": "./query_res2.txt" + "sql": "select last_row(*) from stb00_0", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from stb00_9 ", + "result": "./query_res1.txt" + }] + }, + "super_table_query": { + "stblname": "stb1", + "query_interval":20, + "threads": 4, + "sqls": [ + { + "sql": "select last_row(ts) from xxxx", + "result": "./query_res2.txt" } - ] - } - } - \ No newline at end of file + ] + } +} diff --git a/tests/system-test/5-taos-tools/taosbenchmark/querySuperMutisql100.json b/tests/system-test/5-taos-tools/taosbenchmark/querySuperMutisql100.json index 6a59d4d75d9f7f29e3697c26d72793b9ad8bd554..0f21df47e668d4e8cb5c137bf497192dc915f2f5 100644 --- a/tests/system-test/5-taos-tools/taosbenchmark/querySuperMutisql100.json +++ b/tests/system-test/5-taos-tools/taosbenchmark/querySuperMutisql100.json @@ -10,410 +10,410 @@ "query_times": 3, "super_table_query": { "stblname": "stb0", - "query_interval": 10000, + "query_interval": 10, "threads": 9, "sqls": [ - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select last_row(*) from xxxx ", - "result": "./query_res0.txt" - }, - { - "sql": "select * from xxxx ", - "result": "./query_res0.txt" + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select last_row(*) from xxxx ", + "result": "./query_res0.txt" + }, + { + "sql": "select * from xxxx ", + "result": "./query_res0.txt" + + }] + } +} - }] - } - } - \ No newline at end of file diff --git a/tests/system-test/5-taos-tools/taosbenchmark/taosdemoTestInsertWithJson.py b/tests/system-test/5-taos-tools/taosbenchmark/taosdemoTestInsertWithJson.py index 6fbb6464a4b88041bed0191fdb637cf27f6d2947..0c903c7d2a3405433942073c4695c58de3487ceb 100644 --- a/tests/system-test/5-taos-tools/taosbenchmark/taosdemoTestInsertWithJson.py +++ b/tests/system-test/5-taos-tools/taosbenchmark/taosdemoTestInsertWithJson.py @@ -24,36 +24,44 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] + if "community" in selfPath: + projPath = selfPath[: selfPath.find("community")] + elif "src" in selfPath: + projPath = selfPath[: selfPath.find("src")] + elif "/tools/" in selfPath: + projPath = selfPath[: selfPath.find("/tools/")] + elif "/tests/" in selfPath: + projPath = selfPath[: selfPath.find("/tests/")] else: - projPath = selfPath[:selfPath.find("tests")] + tdLog.exit("path: %s is not supported" % selfPath) + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if (tool) in files: rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + if "packaging" not in rootRealPath: + paths.append(os.path.join(root, tool)) break - return buildPath + if len(paths) == 0: + return "" + return paths[0] def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath() + if binPath == "": + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) testcaseFilename = os.path.split(__file__)[-1] os.system("rm -rf ./insert*_res.txt*") - os.system("rm -rf 5-taos-tools/taosbenchmark/%s.sql" % testcaseFilename ) + os.system("rm -rf 5-taos-tools/taosbenchmark/%s.sql" % testcaseFilename) # insert: create one or mutiple tables per sql and insert multiple rows per sql - os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insert-1s1tnt1r.json -y " % binPath) + os.system("%s -f 5-taos-tools/taosbenchmark/insert-1s1tnt1r.json -y " % binPath) tdSql.execute("use db") tdSql.query("select count (tbname) from stb0") tdSql.checkData(0, 0, 11) @@ -69,7 +77,7 @@ class TDTestCase: tdSql.checkData(0, 0, 2000) # restful connector insert data - os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insertRestful.json -y " % binPath) + os.system("%s -f 5-taos-tools/taosbenchmark/insertRestful.json -y " % binPath) tdSql.execute("use db") tdSql.query("select count (tbname) from stb0") tdSql.checkData(0, 0, 10) @@ -84,19 +92,19 @@ class TDTestCase: tdSql.query("select count(*) from stb1") tdSql.checkData(0, 0, 200) - # default values json files - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insert-default.json -y " % binPath) + # default values json files + tdSql.execute("drop database if exists db") + os.system("%s -f 5-taos-tools/taosbenchmark/insert-default.json -y " % binPath) tdSql.query("show databases;") for i in range(tdSql.queryRows): - if tdSql.queryResult[i][0] == 'db': - tdSql.checkData(i, 2, 100) - tdSql.checkData(i, 4, 1) - tdSql.checkData(i, 6, 10) - tdSql.checkData(i, 16, 'ms') - + if tdSql.queryResult[i][0] == "db": + tdSql.checkData(i, 2, 100) + tdSql.checkData(i, 4, 1) + tdSql.checkData(i, 6, 10) + tdSql.checkData(i, 16, "ms") + # insert: create mutiple tables per sql and insert one rows per sql . - os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insert-1s1tntmr.json -y " % binPath) + os.system("%s -f 5-taos-tools/taosbenchmark/insert-1s1tntmr.json -y " % binPath) tdSql.execute("use db") tdSql.query("select count (tbname) from stb0") tdSql.checkData(0, 0, 10) @@ -113,7 +121,9 @@ class TDTestCase: # insert: using parament "insert_interval to controls spped of insert. # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 - os.system("%staosBenchmark -f 5-taos-tools/taosbenchmark/insert-interval-speed.json -y" % binPath) + os.system( + "%s -f 5-taos-tools/taosbenchmark/insert-interval-speed.json -y" % binPath + ) tdSql.execute("use db") tdSql.query("show stables") tdSql.checkData(0, 4, 10) @@ -131,11 +141,6 @@ class TDTestCase: # rm useless files os.system("rm -rf ./insert*_res.txt*") - - - - - def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/fulltest-others.sh b/tests/system-test/fulltest-others.sh index 26e6aee2b90a619329e23bb8418b95cc0466a78f..862586c230c78c535a2ffb66306ca492ecd47ed1 100755 --- a/tests/system-test/fulltest-others.sh +++ b/tests/system-test/fulltest-others.sh @@ -1 +1,2 @@ -python3 ./test.py -f 0-others/create_col_tag.py \ No newline at end of file +python3 ./test.py -f 0-others/create_col_tag.py +python3 ./test.py -f 0-others/audit.py