diff --git a/.travis.yml b/.travis.yml index 8c57085296..9aac6c597c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ matrix: - psmisc - unixodbc - unixodbc-dev + - mono-complete before_script: - export TZ=Asia/Harbin @@ -59,6 +60,18 @@ matrix: pip3 install guppy3 pip3 install --user ${TRAVIS_BUILD_DIR}/src/connector/python/linux/python3/ + cd ${TRAVIS_BUILD_DIR}/tests/examples/C#/taosdemo + mcs -out:taosdemo *.cs || travis_terminate $? + pkill -TERM -x taosd + fuser -k -n tcp 6030 + sleep 1 + ${TRAVIS_BUILD_DIR}/debug/build/bin/taosd -c ${TRAVIS_BUILD_DIR}/debug/test/cfg > /dev/null & + sleep 5 + mono taosdemo -Q DEFAULT -y || travis_terminate $? + pkill -KILL -x taosd + fuser -k -n tcp 6030 + sleep 1 + cd ${TRAVIS_BUILD_DIR}/tests ./test-all.sh smoke || travis_terminate $? sleep 1 @@ -74,6 +87,7 @@ matrix: ./valgrind-test.sh 2>&1 > mem-error-out.log sleep 1 + # Color setting RED='\033[0;31m' GREEN='\033[1;32m' diff --git a/CMakeLists.txt b/CMakeLists.txt index eb2b1cceb4..0c474a355d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) IF (CMAKE_VERSION VERSION_LESS 3.0) PROJECT(TDengine CXX) SET(PROJECT_VERSION_MAJOR "${LIB_MAJOR_VERSION}") diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 8c6c73c440..1d725add21 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) ADD_SUBDIRECTORY(zlib-1.2.11) diff --git a/deps/MQTT-C/CMakeLists.txt b/deps/MQTT-C/CMakeLists.txt index 15b3552521..36ede467ac 100644 --- a/deps/MQTT-C/CMakeLists.txt +++ b/deps/MQTT-C/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) # MQTT-C build options option(MQTT_C_OpenSSL_SUPPORT "Build MQTT-C with OpenSSL support?" OFF) diff --git a/deps/MsvcLibX/CMakeLists.txt b/deps/MsvcLibX/CMakeLists.txt index 4428579e1c..c02e4c7a4d 100644 --- a/deps/MsvcLibX/CMakeLists.txt +++ b/deps/MsvcLibX/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_WINDOWS) diff --git a/deps/iconv/CMakeLists.txt b/deps/iconv/CMakeLists.txt index 286070fa90..f26f109735 100644 --- a/deps/iconv/CMakeLists.txt +++ b/deps/iconv/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_WINDOWS) diff --git a/deps/pthread/CMakeLists.txt b/deps/pthread/CMakeLists.txt index 04e5be7472..dcd9ed0358 100644 --- a/deps/pthread/CMakeLists.txt +++ b/deps/pthread/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_WINDOWS) diff --git a/deps/regex/CMakeLists.txt b/deps/regex/CMakeLists.txt index 054b093d07..c7e983b992 100644 --- a/deps/regex/CMakeLists.txt +++ b/deps/regex/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_WINDOWS) diff --git a/deps/wepoll/CMakeLists.txt b/deps/wepoll/CMakeLists.txt index a81fd782bb..a8b3411221 100644 --- a/deps/wepoll/CMakeLists.txt +++ b/deps/wepoll/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_WINDOWS) diff --git a/deps/zlib-1.2.11/CMakeLists.txt b/deps/zlib-1.2.11/CMakeLists.txt index f83aa70085..a8750471d6 100644 --- a/deps/zlib-1.2.11/CMakeLists.txt +++ b/deps/zlib-1.2.11/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_WINDOWS) diff --git a/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md b/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md index 4f0e1d3853..bee3d99b26 100644 --- a/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md +++ b/documentation20/webdocs/markdowndocs/TAOS SQL-ch.md @@ -68,7 +68,9 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic 2) UPDATE 标志数据库支持更新相同时间戳数据; 3) 数据库名最大长度为33; + 4) 一条SQL 语句的最大长度为65480个字符; + 5) 数据库还有更多与存储相关的配置参数,请参见系统管理。 - **显示系统当前参数** @@ -130,12 +132,37 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]); ``` 说明: + 1) 表的第一个字段必须是TIMESTAMP,并且系统自动将其设为主键; - 2) 表名最大长度为193; + + 2) 表名最大长度为192; + 3) 表的每行长度不能超过16k个字符; + 4) 子表名只能由字母、数字和下划线组成,且不能以数字开头 + 5) 使用数据类型binary或nchar,需指定其最长的字节数,如binary(20),表示20字节; +- **以超级表为模板创建数据表** + + ```mysql + CREATE TABLE [IF NOT EXISTS] tb_name USING stb_name TAGS (tag_value1, ...); + ``` + 以指定的超级表为模板,指定 tags 的值来创建数据表。 + +- **批量创建数据表** + + ```mysql + CREATE TABLE [IF NOT EXISTS] tb_name1 USING stb_name TAGS (tag_value1, ...) tb_name2 USING stb_name TAGS (tag_value2, ...) ...; + ``` + 以更快的速度批量创建大量数据表。(服务器端 2.0.14 及以上版本) + + 说明: + + 1)批量建表方式要求数据表必须以超级表为模板。 + + 2)在不超出 SQL 语句长度限制的前提下,单条语句中的建表数量建议控制在 1000~3000 之间,将会获得比较理想的建表速度。 + - **删除数据表** ```mysql @@ -148,7 +175,11 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic SHOW TABLES [LIKE tb_name_wildcar]; ``` - 显示当前数据库下的所有数据表信息。说明:可在 like 中使用通配符进行名称的匹配。 通配符匹配:1)“%”(百分号)匹配 0 到任意个字符;2)“\_”(下划线)匹配一个字符。 + 显示当前数据库下的所有数据表信息。 + + 说明:可在like中使用通配符进行名称的匹配,这一通配符字符串最长不能超过24字节。 + + 通配符匹配:1)’%’ (百分号)匹配0到任意个字符;2)’\_’下划线匹配一个字符。 - **在线修改显示字符宽度** @@ -168,8 +199,10 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic ALTER TABLE tb_name ADD COLUMN field_name data_type; ``` 说明: + 1) 列的最大个数为1024,最小个数为2; - 2) 列名最大长度为65; + + 2) 列名最大长度为64; - **表删除列** @@ -187,10 +220,14 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic 创建STable, 与创建表的SQL语法相似,但需指定TAGS字段的名称和类型 说明: + 1) TAGS 列的数据类型不能是timestamp类型; + 2) TAGS 列名不能与其他列名相同; + 3) TAGS 列名不能为预留关键字; - 4) TAGS 最多允许128个,可以0个,总长度不超过16k个字符 + + 4) TAGS 最多允许128个,至少1个,总长度不超过16k个字符。 - **删除超级表** @@ -316,7 +353,9 @@ SELECT select_expr [, select_expr ...] [LIMIT limit_val [, OFFSET offset_val]] [>> export_file] ``` + 说明:针对 insert 类型的 SQL 语句,我们采用的流式解析策略,在发现后面的错误之前,前面正确的部分SQL仍会执行。下面的sql中,insert语句是无效的,但是d1001仍会被创建。 + ```mysql taos> CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT); Query OK, 0 row(s) affected (0.008245s) @@ -551,8 +590,8 @@ Query OK, 1 row(s) in set (0.001091s) | % | match with any char sequences | **`binary`** **`nchar`** | | _ | match with a single char | **`binary`** **`nchar`** | -1. 同时进行多个字段的范围过滤需要使用关键词AND进行连接不同的查询条件,暂不支持OR连接的不同列之间的查询过滤条件。 -2. 针对某一字段的过滤只支持单一时间区间过滤条件。但是针对其他的(普通)列或标签列,可以使用``` OR``` 条件进行组合条件的查询过滤。例如:((value > 20 and value < 30) OR (value < 12)) 。 +1. 同时进行多个字段的范围过滤,需要使用关键词 AND 来连接不同的查询条件,暂不支持 OR 连接的不同列之间的查询过滤条件。 +2. 针对单一字段的过滤,如果是时间过滤条件,则一条语句中只支持设定一个;但针对其他的(普通)列或标签列,则可以使用``` OR``` 关键字进行组合条件的查询过滤。例如:((value > 20 and value < 30) OR (value < 12)) 。 ### SQL 示例 @@ -597,10 +636,20 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ``` 功能说明:统计表/超级表中记录行数或某列的非空值个数。 + 返回结果数据类型:长整型INT64。 + 应用字段:应用全部字段。 + 适用于:表、超级表。 - 说明:1)可以使用星号*来替代具体的字段,使用星号(*)返回全部记录数量。2)针对同一表的(不包含NULL值)字段查询结果均相同。3)如果统计对象是具体的列,则返回该列中非NULL值的记录数量。 + + 说明: + + 1)可以使用星号*来替代具体的字段,使用星号(*)返回全部记录数量。 + + 2)针对同一表的(不包含NULL值)字段查询结果均相同。 + + 3)如果统计对象是具体的列,则返回该列中非NULL值的记录数量。 示例: ```mysql @@ -622,8 +671,11 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT AVG(field_name) FROM tb_name [WHERE clause]; ``` 功能说明:统计表/超级表中某列的平均值。 + 返回结果数据类型:双精度浮点数Double。 + 应用字段:不能应用在timestamp、binary、nchar、bool字段。 + 适用于:表、超级表。 示例: @@ -646,9 +698,11 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT TWA(field_name) FROM tb_name WHERE clause; ``` 功能说明:时间加权平均函数。统计表/超级表中某列在一段时间内的时间加权平均。 + 返回结果数据类型:双精度浮点数Double。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 - 说明:时间加权平均(time weighted average, TWA)查询需要指定查询时间段的 _开始时间_ 和 _结束时间_ 。 + 适用于:表、超级表。 - **SUM** @@ -656,8 +710,11 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT SUM(field_name) FROM tb_name [WHERE clause]; ``` 功能说明:统计表/超级表中某列的和。 + 返回结果数据类型:双精度浮点数Double和长整型INT64。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 + 适用于:表、超级表。 示例: @@ -680,8 +737,11 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ``` 功能说明:统计表中某列的均方差。 + 返回结果数据类型:双精度浮点数Double。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 + 适用于:表。 示例: @@ -698,9 +758,13 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause]; ``` 功能说明:统计表中某列的值是主键(时间戳)的拟合直线方程。start_val是自变量初始值,step_val是自变量的步长值。 + 返回结果数据类型:字符串表达式(斜率, 截距)。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 + 说明:自变量是时间戳,因变量是该列的值。 + 适用于:表。 示例: @@ -719,7 +783,9 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` 功能说明:统计表/超级表中某列的值最小值。 + 返回结果数据类型:同应用的字段。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 示例: @@ -742,7 +808,9 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` 功能说明:统计表/超级表中某列的值最大值。 + 返回结果数据类型:同应用的字段。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 示例: @@ -765,9 +833,18 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` 功能说明:统计表/超级表中某列的值最先写入的非NULL值。 + 返回结果数据类型:同应用的字段。 + 应用字段:所有字段。 - 说明:1)如果要返回各个列的首个(时间戳最小)非NULL值,可以使用FIRST(\*);2) 如果结果集中的某列全部为NULL值,则该列的返回结果也是NULL;3) 如果结果集中所有列全部为NULL值,则不返回结果。 + + 说明: + + 1)如果要返回各个列的首个(时间戳最小)非NULL值,可以使用FIRST(\*); + + 2) 如果结果集中的某列全部为NULL值,则该列的返回结果也是NULL; + + 3) 如果结果集中所有列全部为NULL值,则不返回结果。 示例: ```mysql @@ -789,9 +866,16 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` 功能说明:统计表/超级表中某列的值最后写入的非NULL值。 + 返回结果数据类型:同应用的字段。 + 应用字段:所有字段。 - 说明:1)如果要返回各个列的最后(时间戳最大)一个非NULL值,可以使用LAST(\*);2)如果结果集中的某列全部为NULL值,则该列的返回结果也是NULL;如果结果集中所有列全部为NULL值,则不返回结果。 + + 说明: + + 1)如果要返回各个列的最后(时间戳最大)一个非NULL值,可以使用LAST(\*); + + 2)如果结果集中的某列全部为NULL值,则该列的返回结果也是NULL;如果结果集中所有列全部为NULL值,则不返回结果。 示例: ```mysql @@ -813,9 +897,16 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ``` 功能说明: 统计表/超级表中某列的值最大*k*个非NULL值。若多于k个列值并列最大,则返回时间戳小的。 + 返回结果数据类型:同应用的字段。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 - 说明:1)*k*值取值范围1≤*k*≤100;2)系统同时返回该记录关联的时间戳列。 + + 说明: + + 1)*k*值取值范围1≤*k*≤100; + + 2)系统同时返回该记录关联的时间戳列。 示例: ```mysql @@ -840,9 +931,16 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ``` 功能说明:统计表/超级表中某列的值最小*k*个非NULL值。若多于k个列值并列最小,则返回时间戳小的。 + 返回结果数据类型:同应用的字段。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 - 说明:1)*k*值取值范围1≤*k*≤100;2)系统同时返回该记录关联的时间戳列。 + + 说明: + + 1)*k*值取值范围1≤*k*≤100; + + 2)系统同时返回该记录关联的时间戳列。 示例: ```mysql @@ -866,8 +964,11 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; ``` 功能说明:统计表中某列的值百分比分位数。 + 返回结果数据类型: 双精度浮点数Double。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 + 说明:*P*值取值范围0≤*P*≤100,为0的时候等同于MIN,为100的时候等同于MAX。 示例: @@ -884,9 +985,13 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT APERCENTILE(field_name, P) FROM { tb_name | stb_name } [WHERE clause]; ``` 功能说明:统计表中某列的值百分比分位数,与PERCENTILE函数相似,但是返回近似结果。 + 返回结果数据类型: 双精度浮点数Double。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 + 说明:*P*值取值范围0≤*P*≤100,为0的时候等同于MIN,为100的时候等同于MAX。推荐使用```APERCENTILE```函数,该函数性能远胜于```PERCENTILE```函数 + ```mysql taos> SELECT APERCENTILE(current, 20) FROM d1001; apercentile(current, 20) | @@ -900,8 +1005,11 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; ``` 功能说明:返回表(超级表)的最后一条记录。 + 返回结果数据类型:同应用的字段。 + 应用字段:所有字段。 + 说明:与last函数不同,last_row不支持时间范围限制,强制返回最后一条记录。 示例: @@ -925,8 +1033,11 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT DIFF(field_name) FROM tb_name [WHERE clause]; ``` 功能说明:统计表中某列的值与前一行对应值的差。 + 返回结果数据类型: 同应用字段。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 + 说明:输出结果行数是范围内总行数减一,第一行没有结果输出。 示例: @@ -944,8 +1055,11 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` 功能说明:统计表/超级表中某列的最大值和最小值之差。 + 返回结果数据类型: 双精度浮点数。 + 应用字段:不能应用在binary、nchar、bool类型字段。 + 说明:可用于TIMESTAMP字段,此时表示记录的时间覆盖范围。 示例: @@ -969,9 +1083,16 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 SELECT field_name [+|-|*|/|%][Value|field_name] FROM { tb_name | stb_name } [WHERE clause]; ``` 功能说明:统计表/超级表中某列或多列间的值加、减、乘、除、取余计算结果。 + 返回结果数据类型:双精度浮点数。 + 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 - 说明:1)支持两列或多列之间进行计算,可使用括号控制计算优先级;2)NULL字段不参与计算,如果参与计算的某行中包含NULL,该行的计算结果为NULL。 + + 说明: + + 1)支持两列或多列之间进行计算,可使用括号控制计算优先级; + + 2)NULL字段不参与计算,如果参与计算的某行中包含NULL,该行的计算结果为NULL。 ```mysql taos> SELECT current + voltage * phase FROM d1001; diff --git a/documentation20/webdocs/markdowndocs/administrator-ch.md b/documentation20/webdocs/markdowndocs/administrator-ch.md index 81704c7dbd..9eee5b2b69 100644 --- a/documentation20/webdocs/markdowndocs/administrator-ch.md +++ b/documentation20/webdocs/markdowndocs/administrator-ch.md @@ -105,7 +105,7 @@ taosd -C - queryBufferSize: 为所有并发查询占用保留的内存大小。计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。单位为字节。 - ratioOfQueryCores: 设置查询线程的最大数量。最小值0 表示只有1个查询线程;最大值2表示最大建立2倍CPU核数的查询线程。默认为1,表示最大和CPU核数相等的查询线程。该值可以为小数,即0.5表示最大建立CPU核数一半的查询线程。 -**注意:**对于端口,TDengine会使用从serverPort起13个连续的TCP和UDP端口号,请务必在防火墙打开。因此如果是缺省配置,需要打开从6030都6042共13个端口,而且必须TCP和UDP都打开。 +**注意:**对于端口,TDengine会使用从serverPort起13个连续的TCP和UDP端口号,请务必在防火墙打开。因此如果是缺省配置,需要打开从6030到6042共13个端口,而且必须TCP和UDP都打开。 不同应用场景的数据往往具有不同的数据特征,比如保留天数、副本数、采集频次、记录大小、采集点的数量、压缩等都可完全不同。为获得在存储上的最高效率,TDengine提供如下存储相关的系统配置参数: @@ -255,7 +255,7 @@ taos -C 或 taos --dump-config CREATE USER PASS <'password'>; ``` -创建用户,并指定用户名和密码,密码需要用单引号引起来,单引号为英文半角 +创建用户,并指定用户名和密码,密码需要用单引号引起来,单引号为英文半角 ```sql DROP USER ; @@ -267,13 +267,15 @@ DROP USER ; ALTER USER PASS <'password'>; ``` -修改用户密码, 为避免被转换为小写,密码需要用单引号引用,单引号为英文半角 +修改用户密码,为避免被转换为小写,密码需要用单引号引用,单引号为英文半角 ```sql -ALTER USER PRIVILEGE ; +ALTER USER PRIVILEGE ; ``` -修改用户权限为:super/write/read,不需要添加单引号 +修改用户权限为:write 或 read,不需要添加单引号 + +说明:系统内共有 super/write/read 三种权限级别,但目前不允许通过 alter 指令把 super 权限赋予用户。 ```mysql SHOW USERS; @@ -432,11 +434,12 @@ TDengine的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下 - 数据库名:不能包含“.”以及特殊字符,不能超过32个字符 - 表名:不能包含“.”以及特殊字符,与所属数据库名一起,不能超过192个字符 - 表的列名:不能包含特殊字符,不能超过64个字符 +- 数据库名、表名、列名,都不能以数字开头 - 表的列数:不能超过1024列 - 记录的最大长度:包括时间戳8 byte,不能超过16KB - 单条SQL语句默认最大字符串长度:65480 byte - 数据库副本数:不能超过3 -- 用户名:不能超过20个byte +- 用户名:不能超过23个byte - 用户密码:不能超过15个byte - 标签(Tags)数量:不能超过128个 - 标签的总长度:不能超过16Kbyte diff --git a/documentation20/webdocs/markdowndocs/cluster.md b/documentation20/webdocs/markdowndocs/cluster.md index f5fa6af48c..08206a85a8 100644 --- a/documentation20/webdocs/markdowndocs/cluster.md +++ b/documentation20/webdocs/markdowndocs/cluster.md @@ -89,6 +89,8 @@ SHOW DNODES; ``` 它将列出集群中所有的dnode,每个dnode的fqdn:port, 状态(ready, offline等),vnode数目,还未使用的vnode数目等信息。在添加或删除一个节点后,可以使用该命令查看。 +如果集群配置了Arbitrator,那么它也会在这个节点列表中显示出来,其role列的值会是“arb”。 + ###查看虚拟节点组 为充分利用多核技术,并提供scalability,数据需要分片处理。因此TDengine会将一个DB的数据切分成多份,存放在多个vnode里。这些vnode可能分布在多个dnode里,这样就实现了水平扩展。一个vnode仅仅属于一个DB,但一个DB可以有多个vnode。vnode的是mnode根据当前系统资源的情况,自动进行分配的,无需任何人工干预。 @@ -139,4 +141,6 @@ SHOW MNODES; 如果副本数为偶数,当一个vnode group里一半vnode不工作时,是无法从中选出master的。同理,一半mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。 -TDengine安装包里带有一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数`-p`可以指定其对外服务的端口号,缺省是6030。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的arbitrator。 +TDengine安装包里带有一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数`-p`可以指定其对外服务的端口号,缺省是6030。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为Arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的Arbitrator。 + +在配置了Arbitrator的情况下,它也会显示在“show dnodes;”指令给出的节点列表中。 diff --git a/documentation20/webdocs/markdowndocs/connector-ch.md b/documentation20/webdocs/markdowndocs/connector-ch.md index cc6287953a..da9c2e5a11 100644 --- a/documentation20/webdocs/markdowndocs/connector-ch.md +++ b/documentation20/webdocs/markdowndocs/connector-ch.md @@ -178,11 +178,11 @@ C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine 获取客户端版本信息。 -- `TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, int port)` +- `TAOS *taos_connect(const char *host, const char *user, const char *pass, const char *db, int port)` 创建数据库连接,初始化连接上下文。其中需要用户提供的参数包含: - - ip:TDengine管理主节点的IP地址 + - host:TDengine管理主节点的FQDN - user:用户名 - pass:密码 - db:数据库名字,如果用户没有提供,也可以正常连接,用户可以通过该连接创建新的数据库,如果用户提供了数据库名字,则说明该数据库用户已经创建好,缺省使用该数据库 @@ -252,7 +252,7 @@ C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine - `void taos_free_result(TAOS_RES *res)` - 释放查询结果集以及相关的资源。查询完成后,务必调用该API释放资源,否则可能导致应用内存泄露。 + 释放查询结果集以及相关的资源。查询完成后,务必调用该API释放资源,否则可能导致应用内存泄露。但也需注意,释放资源后,如果再调用`taos_consume`等获取查询结果的函数,将导致应用Crash。 - `char *taos_errstr(TAOS_RES *res)` @@ -262,11 +262,11 @@ C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine 获取最近一次API调用失败的原因,返回值为错误代码。 -**注意**:对于每个数据库应用,2.0及以上版本 TDengine 推荐只建立一个连接。同时在应用中将该连接 (TAOS*) 结构体传递到不同的线程共享使用。基于 TAOS 结构体发出的查询、写入等操作具有多线程安全性。C 语言的连接器可以按照需求动态建立面向数据库的新连接(该过程对用户不可见),同时建议只有在程序最后退出的时候才调用 taos_close 关闭连接。 +**注意**:2.0及以上版本 TDengine 推荐数据库应用的每个线程都建立一个独立的连接,或基于线程建立连接池。而不推荐在应用中将该连接 (TAOS\*) 结构体传递到不同的线程共享使用。基于 TAOS 结构体发出的查询、写入等操作具有多线程安全性,但 “USE statement” 等状态量有可能在线程之间相互干扰。此外,C 语言的连接器可以按照需求动态建立面向数据库的新连接(该过程对用户不可见),同时建议只有在程序最后退出的时候才调用 taos_close 关闭连接。 ### 异步查询API -同步API之外,TDengine还提供性能更高的异步调用API处理数据插入、查询操作。在软硬件环境相同的情况下,异步API处理数据插入的速度比同步API快2~4倍。异步API采用非阻塞式的调用方式,在系统真正完成某个具体数据库操作前,立即返回。调用的线程可以去处理其他工作,从而可以提升整个应用的性能。异步API在网络延迟严重的情况下,优点尤为突出。 +同步API之外,TDengine还提供性能更高的异步调用API处理数据插入、查询操作。在软硬件环境相同的情况下,异步API处理数据插入的速度比同步API快2\~4倍。异步API采用非阻塞式的调用方式,在系统真正完成某个具体数据库操作前,立即返回。调用的线程可以去处理其他工作,从而可以提升整个应用的性能。异步API在网络延迟严重的情况下,优点尤为突出。 异步API都需要应用提供相应的回调函数,回调函数参数设置如下:前两个参数都是一致的,第三个参数依不同的API而定。第一个参数param是应用调用异步API时提供给系统的,用于回调时,应用能够找回具体操作的上下文,依具体实现而定。第二个参数是SQL操作的结果集,如果为空,比如insert操作,表示没有记录返回,如果不为空,比如select操作,表示有记录返回。 @@ -425,7 +425,7 @@ cd C:\TDengine\connector\python\windows python -m pip install python3\ ``` -*如果机器上没有pip命令,用户可将src/connector/python/python3或src/connector/python/python2下的taos文件夹拷贝到应用程序的目录使用。 +* 如果机器上没有pip命令,用户可将src/connector/python/python3或src/connector/python/python2下的taos文件夹拷贝到应用程序的目录使用。 对于windows 客户端,安装TDengine windows 客户端后,将C:\TDengine\driver\taos.dll拷贝到C:\windows\system32目录下即可。 ### 使用 @@ -442,7 +442,7 @@ import taos conn = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos") c1 = conn.cursor() ``` -*host 是TDengine 服务端所有IP, config 为客户端配置文件所在目录 +* host 是TDengine 服务端所有IP, config 为客户端配置文件所在目录 * 写入数据 ```python @@ -510,17 +510,17 @@ conn.close() 用户可通过python的帮助信息直接查看模块的使用信息,或者参考tests/examples/python中的示例程序。以下为部分常用类和方法: -- _TDengineConnection_类 +- _TDengineConnection_ 类 参考python中help(taos.TDengineConnection)。 - 这个类对应客户端和TDengine建立的一个连接。在客户端多线程的场景下,这个连接实例可以是每个线程申请一个,也可以多线程共享一个连接。 + 这个类对应客户端和TDengine建立的一个连接。在客户端多线程的场景下,推荐每个线程申请一个独立的连接实例,而不建议多线程共享一个连接。 -- _TDengineCursor_类 +- _TDengineCursor_ 类 参考python中help(taos.TDengineCursor)。 这个类对应客户端进行的写入、查询操作。在客户端多线程的场景下,这个游标实例必须保持线程独享,不能夸线程共享使用,否则会导致返回结果出现错误。 -- _connect_方法 +- _connect_ 方法 用于生成taos.TDengineConnection的实例。 @@ -800,7 +800,7 @@ go env -w GOPROXY=https://goproxy.io,direct - `sql.Open(DRIVER_NAME string, dataSourceName string) *DB` - 该API用来打开DB,返回一个类型为*DB的对象,一般情况下,DRIVER_NAME设置为字符串`taosSql`, dataSourceName设置为字符串`user:password@/tcp(host:port)/dbname`,如果客户想要用多个goroutine并发访问TDengine, 那么需要在各个goroutine中分别创建一个sql.Open对象并用之访问TDengine + 该API用来打开DB,返回一个类型为\*DB的对象,一般情况下,DRIVER_NAME设置为字符串`taosSql`, dataSourceName设置为字符串`user:password@/tcp(host:port)/dbname`,如果客户想要用多个goroutine并发访问TDengine, 那么需要在各个goroutine中分别创建一个sql.Open对象并用之访问TDengine **注意**: 该API成功创建的时候,并没有做权限等检查,只有在真正执行Query或者Exec的时候才能真正的去创建连接,并同时检查user/password/host/port是不是合法。 另外,由于整个驱动程序大部分实现都下沉到taosSql所依赖的libtaos中。所以,sql.Open本身特别轻量。 @@ -822,7 +822,7 @@ go env -w GOPROXY=https://goproxy.io,direct - `func (s *Stmt) Query(args ...interface{}) (*Rows, error)` - sql.Open内置的方法,Query executes a prepared query statement with the given arguments and returns the query results as a *Rows. + sql.Open内置的方法,Query executes a prepared query statement with the given arguments and returns the query results as a \*Rows. - `func (s *Stmt) Close() error` @@ -894,7 +894,7 @@ Node-example-raw.js 验证方法: -1. 新建安装验证目录,例如:~/tdengine-test,拷贝github上nodejsChecker.js源程序。下载地址:(https://github.com/taosdata/TDengine/tree/develop/tests/examples/nodejs/nodejsChecker.js)。 +1. 新建安装验证目录,例如:\~/tdengine-test,拷贝github上nodejsChecker.js源程序。下载地址:(https://github.com/taosdata/TDengine/tree/develop/tests/examples/nodejs/nodejsChecker.js)。 2. 在命令中执行以下命令: diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 73fa915abd..4aefc2f449 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -72,9 +72,6 @@ # time interval of heart beat from shell to dnode, seconds # shellActivityTimer 3 -# time of keeping table meta data in cache, seconds -# tableMetaKeepTimer 7200 - # minimum sliding window time, milli-second # minSlidingTime 10 @@ -162,10 +159,10 @@ # stop writing logs when the disk size of the log folder is less than this value # minimalLogDirGB 0.1 -# stop writing temporary files when the disk size of the log folder is less than this value +# stop writing temporary files when the disk size of the tmp folder is less than this value # minimalTmpDirGB 0.1 -# stop writing data when the disk size of the log folder is less than this value +# if disk free space is less than this value, taosd service exit directly within startup process # minimalDataDirGB 0.1 # One mnode is equal to the number of vnode consumed diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 338abcc6a0..d98ed2185f 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -348,7 +348,7 @@ function set_ipAsFqdn() { } function local_fqdn_check() { - #serverFqdn=$(hostname -f) + #serverFqdn=$(hostname) echo echo -e -n "System hostname is: ${GREEN}$serverFqdn${NC}" echo @@ -911,7 +911,7 @@ function install_TDengine() { ## ==============================Main program starts from here============================ -serverFqdn=$(hostname -f) +serverFqdn=$(hostname) if [ "$verType" == "server" ]; then # Install server and client if [ -x ${bin_dir}/taosd ]; then diff --git a/packaging/tools/install_power.sh b/packaging/tools/install_power.sh index 28788ceb74..b14d5d400b 100755 --- a/packaging/tools/install_power.sh +++ b/packaging/tools/install_power.sh @@ -345,7 +345,7 @@ function set_ipAsFqdn() { } function local_fqdn_check() { - #serverFqdn=$(hostname -f) + #serverFqdn=$(hostname) echo echo -e -n "System hostname is: ${GREEN}$serverFqdn${NC}" echo @@ -881,7 +881,7 @@ function install_PowerDB() { ## ==============================Main program starts from here============================ -serverFqdn=$(hostname -f) +serverFqdn=$(hostname) if [ "$verType" == "server" ]; then # Install server and client if [ -x ${bin_dir}/powerd ]; then diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index 9d15b9736e..6bfbf33fd1 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -228,7 +228,7 @@ function set_ipAsFqdn() { } function local_fqdn_check() { - #serverFqdn=$(hostname -f) + #serverFqdn=$(hostname) echo echo -e -n "System hostname is: ${GREEN}$serverFqdn${NC}" echo @@ -492,5 +492,5 @@ function install_TDengine() { ## ==============================Main program starts from here============================ -serverFqdn=$(hostname -f) +serverFqdn=$(hostname) install_TDengine diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 931a0a132e..04bc61ed9e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) # Base compile diff --git a/src/balance/CMakeLists.txt b/src/balance/CMakeLists.txt index 6c26e50b87..fdc43ea32f 100644 --- a/src/balance/CMakeLists.txt +++ b/src/balance/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/mnode/inc) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index daf7c5e534..4049c0d729 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) diff --git a/src/client/inc/tscSubquery.h b/src/client/inc/tscSubquery.h index d3996ccf7f..43c9b009bf 100644 --- a/src/client/inc/tscSubquery.h +++ b/src/client/inc/tscSubquery.h @@ -43,6 +43,11 @@ TAOS_ROW doSetResultRowData(SSqlObj *pSql); char *getArithmeticInputSrc(void *param, const char *name, int32_t colId); +void tscLockByThread(int64_t *lockedBy); + +void tscUnlockByThread(int64_t *lockedBy); + + #ifdef __cplusplus } #endif diff --git a/src/client/inc/tschemautil.h b/src/client/inc/tschemautil.h index 7c41164a04..c881a7a763 100644 --- a/src/client/inc/tschemautil.h +++ b/src/client/inc/tschemautil.h @@ -26,7 +26,7 @@ extern "C" { #define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS) -//struct SSchema; +#define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS) /** * get the number of tags of this table @@ -91,7 +91,7 @@ SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId); * @param numOfCols * @return */ -bool isValidSchema(struct SSchema *pSchema, int32_t numOfCols); +bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags); /** * get the schema for the "tbname" column. it is a built column diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 25a299d098..900fab53a2 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -300,8 +300,8 @@ typedef struct STscObj { void * pTimer; char user[TSDB_USER_LEN]; char pass[TSDB_KEY_LEN]; - char acctId[TSDB_ACCT_LEN]; - char db[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN]; + char acctId[TSDB_ACCT_ID_LEN]; + char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; char sversion[TSDB_VERSION_LEN]; char writeAuth : 1; char superAuth : 1; @@ -347,6 +347,11 @@ typedef struct SSqlObj { SSubqueryState subState; struct SSqlObj **pSubs; + int64_t metaRid; + int64_t svgroupRid; + + int64_t squeryLock; + struct SSqlObj *prev, *next; int64_t self; } SSqlObj; @@ -460,7 +465,7 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField } else { assert(bytes == tDataTypeDesc[type].nSize); - pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : (unsigned char*)&pInfo->pSqlExpr->param[1].i64Key; + pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : (unsigned char*)&pInfo->pSqlExpr->param[1].i64; pRes->length[columnIndex] = bytes; } } else { diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index b7b3441bd1..37207858a8 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -95,7 +95,7 @@ void taos_query_a(TAOS *taos, const char *sqlstr, __async_cb_func_t fp, void *pa return; } - nPrintTsc(sqlstr); + nPrintTsc("%s", sqlstr); SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); if (pSql == NULL) { @@ -365,7 +365,7 @@ static void tscProcessAsyncError(SSchedMsg *pMsg) { void (*fp)() = pMsg->ahandle; terrno = *(int32_t*) pMsg->msg; tfree(pMsg->msg); - (*fp)(pMsg->thandle, NULL, *(int32_t*)pMsg->msg); + (*fp)(pMsg->thandle, NULL, terrno); } void tscQueueAsyncError(void(*fp), void *param, int32_t code) { @@ -388,7 +388,7 @@ void tscAsyncResultOnError(SSqlObj *pSql) { } assert(pSql->res.code != TSDB_CODE_SUCCESS); - tscError("%p add into queued async res, code:%s", pSql, tstrerror(pSql->res.code)); + tscError("%p invoke user specified function due to error occured, code:%s", pSql, tstrerror(pSql->res.code)); SSqlRes *pRes = &pSql->res; if (pSql->fp == NULL || pSql->fetchFp == NULL){ @@ -402,8 +402,10 @@ void tscAsyncResultOnError(SSqlObj *pSql) { int tscSendMsgToServer(SSqlObj *pSql); void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { - SSqlObj *pSql = (SSqlObj *)param; - if (pSql == NULL || pSql->signature != pSql) return; + SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)param); + if (pSql == NULL) return; + + assert(pSql->signature == pSql && (int64_t)param == pSql->self); SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; @@ -428,7 +430,8 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { code = tscGetTableMeta(pSql, pTableMetaInfo); assert(code == TSDB_CODE_TSC_ACTION_IN_PROGRESS || code == TSDB_CODE_SUCCESS); - if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + taosReleaseRef(tscObjRef, pSql->self); return; } @@ -436,6 +439,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { // tscProcessSql can add error into async res tscProcessSql(pSql); + taosReleaseRef(tscObjRef, pSql->self); return; } else { // continue to process normal async query if (pCmd->parseFinished) { @@ -446,6 +450,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { assert(code == TSDB_CODE_TSC_ACTION_IN_PROGRESS || code == TSDB_CODE_SUCCESS); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + taosReleaseRef(tscObjRef, pSql->self); return; } @@ -458,6 +463,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + taosReleaseRef(tscObjRef, pSql->self); return; } else if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -468,12 +474,14 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { tscProcessSql(pSql); } + taosReleaseRef(tscObjRef, pSql->self); return; } else { tscDebug("%p continue parse sql after get table meta", pSql); code = tsParseSql(pSql, false); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + taosReleaseRef(tscObjRef, pSql->self); return; } else if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -483,12 +491,14 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); code = tscGetTableMeta(pSql, pTableMetaInfo); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + taosReleaseRef(tscObjRef, pSql->self); return; } else { assert(code == TSDB_CODE_SUCCESS); } (*pSql->fp)(pSql->param, pSql, code); + taosReleaseRef(tscObjRef, pSql->self); return; } @@ -501,6 +511,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { code = tscGetTableMeta(pSql, pTableMetaInfo); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + taosReleaseRef(tscObjRef, pSql->self); return; } else if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -509,6 +520,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { code = tscGetSTableVgroupInfo(pSql, pCmd->clauseIndex); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + taosReleaseRef(tscObjRef, pSql->self); return; } else if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -521,11 +533,16 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { } (*pSql->fp)(pSql->param, pSql, code); + + taosReleaseRef(tscObjRef, pSql->self); return; } tscDoQuery(pSql); + + taosReleaseRef(tscObjRef, pSql->self); + return; _error: @@ -533,4 +550,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { pSql->res.code = code; tscAsyncResultOnError(pSql); } + + taosReleaseRef(tscObjRef, pSql->self); } diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 16bbd420c0..48380f8641 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -204,7 +204,7 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) { assert(tscGetMetaInfo(pQueryInfo, 0)->pTableMeta != NULL); const int32_t NUM_OF_DESC_TABLE_COLUMNS = 4; - const int32_t TYPE_COLUMN_LENGTH = 16; + const int32_t TYPE_COLUMN_LENGTH = 20; const int32_t NOTE_COLUMN_MIN_LENGTH = 8; int32_t noteFieldLen = NOTE_COLUMN_MIN_LENGTH; diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c index 921aa9bade..4aa751574c 100644 --- a/src/client/src/tscLocalMerge.c +++ b/src/client/src/tscLocalMerge.c @@ -95,11 +95,11 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc int32_t functionId = pExpr->functionId; if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { pCtx->ptsOutputBuf = pReducer->pCtx[0].aOutputBuf; - pCtx->param[2].i64Key = pQueryInfo->order.order; + pCtx->param[2].i64 = pQueryInfo->order.order; pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT; - pCtx->param[1].i64Key = pQueryInfo->order.orderColId; + pCtx->param[1].i64 = pQueryInfo->order.orderColId; } else if (functionId == TSDB_FUNC_APERCT) { - pCtx->param[0].i64Key = pExpr->param[0].i64Key; + pCtx->param[0].i64 = pExpr->param[0].i64; pCtx->param[0].nType = pExpr->param[0].nType; } @@ -1064,7 +1064,7 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, } } else if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM) { SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, j); - pCtx->param[0].i64Key = pExpr->param[0].i64Key; + pCtx->param[0].i64 = pExpr->param[0].i64; } pCtx->currentStage = MERGE_STAGE; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index ec90d21394..7151c33393 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -20,6 +20,7 @@ #include "os.h" +#include "ttype.h" #include "hash.h" #include "tscUtil.h" #include "tschemautil.h" @@ -40,46 +41,9 @@ enum { static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows); -static int32_t tscToInteger(SStrToken *pToken, int64_t *value, char **endPtr) { - if (pToken->n == 0) { - return TK_ILLEGAL; - } - - - int32_t radix = 10; - if (pToken->type == TK_HEX) { - radix = 16; - } else if (pToken->type == TK_BIN) { - radix = 2; - } - - errno = 0; - *value = strtoll(pToken->z, endPtr, radix); - if (**endPtr == 'e' || **endPtr == 'E' || **endPtr == '.') { - errno = 0; - double v = round(strtod(pToken->z, endPtr)); - if (v > INT64_MAX || v <= INT64_MIN) { - errno = ERANGE; - } else { - *value = (int64_t)v; - } - } - - // not a valid integer number, return error - if (*endPtr - pToken->z != pToken->n) { - return TK_ILLEGAL; - } - - return pToken->type; -} - static int32_t tscToDouble(SStrToken *pToken, double *value, char **endPtr) { - if (pToken->n == 0) { - return TK_ILLEGAL; - } - errno = 0; - *value = strtod(pToken->z, endPtr); + *value = strtold(pToken->z, endPtr); // not a valid integer number, return error if ((*endPtr - pToken->z) != pToken->n) { @@ -163,86 +127,119 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1 return TSDB_CODE_SUCCESS; } +// todo extract the null value check +static bool isNullStr(SStrToken* pToken) { + return (pToken->type == TK_NULL) || ((pToken->type == TK_STRING) && (pToken->n != 0) && + (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)); +} int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload, char *msg, char **str, bool primaryKey, int16_t timePrec) { int64_t iv; - int32_t numType; - char * endptr = NULL; - errno = 0; // clear the previous existed error information + int32_t ret; + char *endptr = NULL; + + if (IS_NUMERIC_TYPE(pSchema->type) && pToken->n == 0) { + return tscInvalidSQLErrMsg(msg, "invalid numeric data", pToken->z); + } switch (pSchema->type) { case TSDB_DATA_TYPE_BOOL: { // bool - if ((pToken->type == TK_BOOL || pToken->type == TK_STRING) && (pToken->n != 0)) { - if (strncmp(pToken->z, "true", pToken->n) == 0) { - *(uint8_t *)payload = TSDB_TRUE; - } else if (strncmp(pToken->z, "false", pToken->n) == 0) { - *(uint8_t *)payload = TSDB_FALSE; - } else if (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0) { - *(uint8_t *)payload = TSDB_DATA_BOOL_NULL; - } else { - return tscSQLSyntaxErrMsg(msg, "invalid bool data", pToken->z); - } - } else if (pToken->type == TK_INTEGER) { - iv = strtoll(pToken->z, NULL, 10); - *(uint8_t *)payload = (int8_t)((iv == 0) ? TSDB_FALSE : TSDB_TRUE); - } else if (pToken->type == TK_FLOAT) { - double dv = strtod(pToken->z, NULL); - *(uint8_t *)payload = (int8_t)((dv == 0) ? TSDB_FALSE : TSDB_TRUE); - } else if (pToken->type == TK_NULL) { - *(uint8_t *)payload = TSDB_DATA_BOOL_NULL; + if (isNullStr(pToken)) { + *((uint8_t *)payload) = TSDB_DATA_BOOL_NULL; } else { - return tscInvalidSQLErrMsg(msg, "invalid bool data", pToken->z); + if ((pToken->type == TK_BOOL || pToken->type == TK_STRING) && (pToken->n != 0)) { + if (strncmp(pToken->z, "true", pToken->n) == 0) { + *(uint8_t *)payload = TSDB_TRUE; + } else if (strncmp(pToken->z, "false", pToken->n) == 0) { + *(uint8_t *)payload = TSDB_FALSE; + } else { + return tscSQLSyntaxErrMsg(msg, "invalid bool data", pToken->z); + } + } else if (pToken->type == TK_INTEGER) { + iv = strtoll(pToken->z, NULL, 10); + *(uint8_t *)payload = (int8_t)((iv == 0) ? TSDB_FALSE : TSDB_TRUE); + } else if (pToken->type == TK_FLOAT) { + double dv = strtod(pToken->z, NULL); + *(uint8_t *)payload = (int8_t)((dv == 0) ? TSDB_FALSE : TSDB_TRUE); + } else { + return tscInvalidSQLErrMsg(msg, "invalid bool data", pToken->z); + } } break; } + case TSDB_DATA_TYPE_TINYINT: - if (pToken->type == TK_NULL) { - *((int8_t *)payload) = TSDB_DATA_TINYINT_NULL; - } else if ((pToken->type == TK_STRING) && (pToken->n != 0) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)) { - *((int8_t *)payload) = TSDB_DATA_TINYINT_NULL; + if (isNullStr(pToken)) { + *((uint8_t *)payload) = TSDB_DATA_TINYINT_NULL; } else { - numType = tscToInteger(pToken, &iv, &endptr); - if (TK_ILLEGAL == numType) { + ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true); + if (ret != TSDB_CODE_SUCCESS) { return tscInvalidSQLErrMsg(msg, "invalid tinyint data", pToken->z); - } else if (errno == ERANGE || iv > INT8_MAX || iv <= INT8_MIN) { - return tscInvalidSQLErrMsg(msg, "tinyint data overflow", pToken->z); + } else if (!IS_VALID_TINYINT(iv)) { + return tscInvalidSQLErrMsg(msg, "data overflow", pToken->z); } - *((int8_t *)payload) = (int8_t)iv; + *((uint8_t *)payload) = (uint8_t)iv; + } + + break; + + case TSDB_DATA_TYPE_UTINYINT: + if (isNullStr(pToken)) { + *((uint8_t *)payload) = TSDB_DATA_UTINYINT_NULL; + } else { + ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false); + if (ret != TSDB_CODE_SUCCESS) { + return tscInvalidSQLErrMsg(msg, "invalid unsigned tinyint data", pToken->z); + } else if (!IS_VALID_UTINYINT(iv)) { + return tscInvalidSQLErrMsg(msg, "unsigned tinyint data overflow", pToken->z); + } + + *((uint8_t *)payload) = (uint8_t)iv; } break; case TSDB_DATA_TYPE_SMALLINT: - if (pToken->type == TK_NULL) { - *((int16_t *)payload) = TSDB_DATA_SMALLINT_NULL; - } else if ((pToken->type == TK_STRING) && (pToken->n != 0) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)) { + if (isNullStr(pToken)) { *((int16_t *)payload) = TSDB_DATA_SMALLINT_NULL; } else { - numType = tscToInteger(pToken, &iv, &endptr); - if (TK_ILLEGAL == numType) { + ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true); + if (ret != TSDB_CODE_SUCCESS) { return tscInvalidSQLErrMsg(msg, "invalid smallint data", pToken->z); - } else if (errno == ERANGE || iv > INT16_MAX || iv <= INT16_MIN) { + } else if (!IS_VALID_SMALLINT(iv)) { return tscInvalidSQLErrMsg(msg, "smallint data overflow", pToken->z); } *((int16_t *)payload) = (int16_t)iv; } + + break; + + case TSDB_DATA_TYPE_USMALLINT: + if (isNullStr(pToken)) { + *((uint16_t *)payload) = TSDB_DATA_USMALLINT_NULL; + } else { + ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false); + if (ret != TSDB_CODE_SUCCESS) { + return tscInvalidSQLErrMsg(msg, "invalid unsigned smallint data", pToken->z); + } else if (!IS_VALID_USMALLINT(iv)) { + return tscInvalidSQLErrMsg(msg, "unsigned smallint data overflow", pToken->z); + } + + *((uint16_t *)payload) = (uint16_t)iv; + } + break; case TSDB_DATA_TYPE_INT: - if (pToken->type == TK_NULL) { - *((int32_t *)payload) = TSDB_DATA_INT_NULL; - } else if ((pToken->type == TK_STRING) && (pToken->n != 0) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)) { + if (isNullStr(pToken)) { *((int32_t *)payload) = TSDB_DATA_INT_NULL; } else { - numType = tscToInteger(pToken, &iv, &endptr); - if (TK_ILLEGAL == numType) { + ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true); + if (ret != TSDB_CODE_SUCCESS) { return tscInvalidSQLErrMsg(msg, "invalid int data", pToken->z); - } else if (errno == ERANGE || iv > INT32_MAX || iv <= INT32_MIN) { + } else if (!IS_VALID_INT(iv)) { return tscInvalidSQLErrMsg(msg, "int data overflow", pToken->z); } @@ -251,17 +248,30 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload, break; + case TSDB_DATA_TYPE_UINT: + if (isNullStr(pToken)) { + *((uint32_t *)payload) = TSDB_DATA_UINT_NULL; + } else { + ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false); + if (ret != TSDB_CODE_SUCCESS) { + return tscInvalidSQLErrMsg(msg, "invalid unsigned int data", pToken->z); + } else if (!IS_VALID_UINT(iv)) { + return tscInvalidSQLErrMsg(msg, "unsigned int data overflow", pToken->z); + } + + *((uint32_t *)payload) = (uint32_t)iv; + } + + break; + case TSDB_DATA_TYPE_BIGINT: - if (pToken->type == TK_NULL) { - *((int64_t *)payload) = TSDB_DATA_BIGINT_NULL; - } else if ((pToken->type == TK_STRING) && (pToken->n != 0) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)) { + if (isNullStr(pToken)) { *((int64_t *)payload) = TSDB_DATA_BIGINT_NULL; } else { - numType = tscToInteger(pToken, &iv, &endptr); - if (TK_ILLEGAL == numType) { + ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true); + if (ret != TSDB_CODE_SUCCESS) { return tscInvalidSQLErrMsg(msg, "invalid bigint data", pToken->z); - } else if (errno == ERANGE || iv == INT64_MIN) { + } else if (!IS_VALID_BIGINT(iv)) { return tscInvalidSQLErrMsg(msg, "bigint data overflow", pToken->z); } @@ -269,11 +279,23 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload, } break; + case TSDB_DATA_TYPE_UBIGINT: + if (isNullStr(pToken)) { + *((uint64_t *)payload) = TSDB_DATA_UBIGINT_NULL; + } else { + ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false); + if (ret != TSDB_CODE_SUCCESS) { + return tscInvalidSQLErrMsg(msg, "invalid unsigned bigint data", pToken->z); + } else if (!IS_VALID_UBIGINT((uint64_t)iv)) { + return tscInvalidSQLErrMsg(msg, "unsigned bigint data overflow", pToken->z); + } + + *((uint64_t *)payload) = iv; + } + break; + case TSDB_DATA_TYPE_FLOAT: - if (pToken->type == TK_NULL) { - *((int32_t *)payload) = TSDB_DATA_FLOAT_NULL; - } else if ((pToken->type == TK_STRING) && (pToken->n != 0) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)) { + if (isNullStr(pToken)) { *((int32_t *)payload) = TSDB_DATA_FLOAT_NULL; } else { double dv; @@ -281,24 +303,16 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload, return tscInvalidSQLErrMsg(msg, "illegal float data", pToken->z); } - float fv = (float)dv; - if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || (fv > FLT_MAX || fv < -FLT_MAX)) { + if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || dv > FLT_MAX || dv < -FLT_MAX || isinf(dv) || isnan(dv)) { return tscInvalidSQLErrMsg(msg, "illegal float data", pToken->z); } - if (isinf(fv) || isnan(fv)) { - *((int32_t *)payload) = TSDB_DATA_FLOAT_NULL; - } - - *((float *)payload) = fv; + *((float *)payload) = (float)dv; } break; case TSDB_DATA_TYPE_DOUBLE: - if (pToken->type == TK_NULL) { - *((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL; - } else if ((pToken->type == TK_STRING) && (pToken->n != 0) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)) { + if (isNullStr(pToken)) { *((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL; } else { double dv; @@ -306,15 +320,11 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload, return tscInvalidSQLErrMsg(msg, "illegal double data", pToken->z); } - if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || (dv > DBL_MAX || dv < -DBL_MAX)) { + if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || isinf(dv) || isnan(dv)) { return tscInvalidSQLErrMsg(msg, "illegal double data", pToken->z); } - if (isinf(dv) || isnan(dv)) { - *((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL; - } else { - *((double *)payload) = dv; - } + *((double *)payload) = dv; } break; @@ -337,7 +347,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload, setVardataNull(payload, TSDB_DATA_TYPE_NCHAR); } else { // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' - size_t output = 0; + int32_t output = 0; if (!taosMbsToUcs4(pToken->z, pToken->n, varDataVal(payload), pSchema->bytes - VARSTR_HEADER_SIZE, &output)) { char buf[512] = {0}; snprintf(buf, tListLen(buf), "%s", strerror(errno)); @@ -752,6 +762,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { char *sql = *sqlstr; + pSql->cmd.autoCreated = false; + // get the token of specified table index = 0; tableToken = tStrGetToken(sql, &index, false, 0, NULL); @@ -935,11 +947,15 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { SKVRow row = tdGetKVRowFromBuilder(&kvRowBuilder); tdDestroyKVRowBuilder(&kvRowBuilder); if (row == NULL) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return tscInvalidSQLErrMsg(pCmd->payload, "tag value expected", NULL); } tdSortKVRowByColIdx(row); pCmd->tagData.dataLen = kvRowLen(row); + if (pCmd->tagData.dataLen <= 0){ + return tscInvalidSQLErrMsg(pCmd->payload, "tag value expected", NULL); + } + char* pTag = realloc(pCmd->tagData.data, pCmd->tagData.dataLen); if (pTag == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 8134a35811..981b354c8a 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -84,35 +84,35 @@ static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) { var->nLen = 0; if (tb->is_null != NULL && *(tb->is_null)) { var->nType = TSDB_DATA_TYPE_NULL; - var->i64Key = 0; + var->i64 = 0; continue; } var->nType = tb->buffer_type; switch (tb->buffer_type) { case TSDB_DATA_TYPE_NULL: - var->i64Key = 0; + var->i64 = 0; break; case TSDB_DATA_TYPE_BOOL: - var->i64Key = (*(int8_t*)tb->buffer) ? 1 : 0; + var->i64 = (*(int8_t*)tb->buffer) ? 1 : 0; break; case TSDB_DATA_TYPE_TINYINT: - var->i64Key = *(int8_t*)tb->buffer; + var->i64 = *(int8_t*)tb->buffer; break; case TSDB_DATA_TYPE_SMALLINT: - var->i64Key = *(int16_t*)tb->buffer; + var->i64 = *(int16_t*)tb->buffer; break; case TSDB_DATA_TYPE_INT: - var->i64Key = *(int32_t*)tb->buffer; + var->i64 = *(int32_t*)tb->buffer; break; case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_TIMESTAMP: - var->i64Key = *(int64_t*)tb->buffer; + var->i64 = *(int64_t*)tb->buffer; break; case TSDB_DATA_TYPE_FLOAT: @@ -219,7 +219,7 @@ static char* normalStmtBuildSql(STscStmt* stmt) { case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_BIGINT: - taosStringBuilderAppendInteger(&sb, var->i64Key); + taosStringBuilderAppendInteger(&sb, var->i64); break; case TSDB_DATA_TYPE_FLOAT: @@ -616,7 +616,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) { case TSDB_DATA_TYPE_NCHAR: { switch (bind->buffer_type) { case TSDB_DATA_TYPE_NCHAR: { - size_t output = 0; + int32_t output = 0; if (!taosMbsToUcs4(bind->buffer, *bind->length, varDataVal(data + param->offset), param->bytes - VARSTR_HEADER_SIZE, &output)) { return TSDB_CODE_TSC_INVALID_VALUE; } @@ -678,7 +678,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) { return TSDB_CODE_SUCCESS; case TSDB_DATA_TYPE_NCHAR: { - size_t output = 0; + int32_t output = 0; if (!taosMbsToUcs4(bind->buffer, *bind->length, varDataVal(data + param->offset), param->bytes - VARSTR_HEADER_SIZE, &output)) { return TSDB_CODE_TSC_INVALID_VALUE; } diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 8ac47d1ec3..ffb2927cbd 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -19,6 +19,7 @@ #define _GNU_SOURCE #include "os.h" +#include "ttype.h" #include "qAst.h" #include "taos.h" #include "taosmsg.h" @@ -220,7 +221,7 @@ static int32_t handlePassword(SSqlCmd* pCmd, SStrToken* pPwd) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - if (pPwd->n >= TSDB_PASSWORD_LEN) { + if (pPwd->n >= TSDB_KEY_LEN) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -484,10 +485,10 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { case TSDB_SQL_CREATE_USER: case TSDB_SQL_ALTER_USER: { - const char* msg5 = "invalid user rights"; - const char* msg7 = "not support options"; const char* msg2 = "invalid user/account name"; const char* msg3 = "name too long"; + const char* msg5 = "invalid user rights"; + const char* msg7 = "not support options"; pCmd->command = pInfo->type; @@ -950,7 +951,7 @@ static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd) { return false; } - if (pField->type < TSDB_DATA_TYPE_BOOL || pField->type > TSDB_DATA_TYPE_NCHAR) { + if (!isValidDataType(pField->type)) { invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4); return false; } @@ -1011,7 +1012,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC return false; } - if (p->type < TSDB_DATA_TYPE_BOOL || p->type > TSDB_DATA_TYPE_NCHAR) { + if (!isValidDataType(p->type)) { invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5); return false; } @@ -1241,7 +1242,7 @@ int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStr /* db name is not specified, the tableName dose not include db name */ if (pDB != NULL) { - if (pDB->n >= TSDB_ACCT_LEN + TSDB_DB_NAME_LEN || pDB->n == 0) { + if (pDB->n >= TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN || pDB->n == 0) { return TSDB_CODE_TSC_INVALID_SQL; } @@ -1754,7 +1755,7 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS // set reverse order scan data blocks for last query if (functionID == TSDB_FUNC_LAST) { pExpr->numOfParams = 1; - pExpr->param[0].i64Key = TSDB_ORDER_DESC; + pExpr->param[0].i64 = TSDB_ORDER_DESC; pExpr->param[0].nType = TSDB_DATA_TYPE_INT; } @@ -1945,7 +1946,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, index.columnIndex); int16_t colType = pSchema->type; - if (colType <= TSDB_DATA_TYPE_BOOL || colType >= TSDB_DATA_TYPE_BINARY) { + if (!IS_NUMERIC_TYPE(colType)) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -2105,7 +2106,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col if (!TSDB_COL_IS_TAG(pIndex->flag) && pIndex->colIndex < tscGetNumOfColumns(pTableMetaInfo->pTableMeta)) { // group by normal columns SSqlExpr* pExpr = taosArrayGetP(pQueryInfo->exprList, colIndex + i); pExpr->numOfParams = 1; - pExpr->param->i64Key = TSDB_ORDER_ASC; + pExpr->param->i64 = TSDB_ORDER_ASC; break; } @@ -2182,7 +2183,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col // 2. valid the column type int16_t colType = pSchema[index.columnIndex].type; - if (colType == TSDB_DATA_TYPE_BOOL || colType >= TSDB_DATA_TYPE_BINARY) { + if (!IS_NUMERIC_TYPE(colType)) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -2727,7 +2728,7 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) { if ((functionId >= TSDB_FUNC_SUM && functionId <= TSDB_FUNC_TWA) || (functionId >= TSDB_FUNC_FIRST_DST && functionId <= TSDB_FUNC_LAST_DST) || (functionId >= TSDB_FUNC_RATE && functionId <= TSDB_FUNC_AVG_IRATE)) { - if (getResultDataInfo(pSrcSchema->type, pSrcSchema->bytes, functionId, (int32_t)pExpr->param[0].i64Key, &type, &bytes, + if (getResultDataInfo(pSrcSchema->type, pSrcSchema->bytes, functionId, (int32_t)pExpr->param[0].i64, &type, &bytes, &interBytes, 0, true) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_SQL; } @@ -2827,7 +2828,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool int32_t factor = functionCompatList[tscSqlExprGet(pQueryInfo, startIdx)->functionId]; if (tscSqlExprGet(pQueryInfo, 0)->functionId == TSDB_FUNC_LAST_ROW && (joinQuery || intervalQuery)) { - return false; + return false; } // diff function cannot be executed with other function @@ -4396,8 +4397,8 @@ int32_t getTimeRange(STimeWindow* win, tSQLExpr* pRight, int32_t optr, int16_t t * * Additional check to avoid data overflow */ - if (pRight->val.i64Key <= INT64_MAX / 1000) { - pRight->val.i64Key *= 1000; + if (pRight->val.i64 <= INT64_MAX / 1000) { + pRight->val.i64 *= 1000; } } else if (pRight->nSQLOptr == TK_FLOAT && timePrecision == TSDB_TIME_PRECISION_MILLI) { pRight->val.dKey *= 1000; @@ -5380,22 +5381,22 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* p tVariantListItem* p0 = taosArrayGet(pKeep, 0); switch (s) { case 1: { - pMsg->daysToKeep = htonl((int32_t)p0->pVar.i64Key); + pMsg->daysToKeep = htonl((int32_t)p0->pVar.i64); } break; case 2: { tVariantListItem* p1 = taosArrayGet(pKeep, 1); - pMsg->daysToKeep = htonl((int32_t)p0->pVar.i64Key); - pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64Key); + pMsg->daysToKeep = htonl((int32_t)p0->pVar.i64); + pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64); break; } case 3: { tVariantListItem* p1 = taosArrayGet(pKeep, 1); tVariantListItem* p2 = taosArrayGet(pKeep, 2); - pMsg->daysToKeep = htonl((int32_t)p0->pVar.i64Key); - pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64Key); - pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64Key); + pMsg->daysToKeep = htonl((int32_t)p0->pVar.i64); + pMsg->daysToKeep1 = htonl((int32_t)p1->pVar.i64); + pMsg->daysToKeep2 = htonl((int32_t)p2->pVar.i64); break; } default: { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } @@ -5561,7 +5562,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) { if ((pExpr->functionId != TSDB_FUNC_TAG_DUMMY && pExpr->functionId != TSDB_FUNC_TS_DUMMY) && !(pExpr->functionId == TSDB_FUNC_PRJ && TSDB_COL_IS_UD_COL(pExpr->colInfo.flag))) { SSchema* pColSchema = &pSchema[pExpr->colInfo.colIndex]; - getResultDataInfo(pColSchema->type, pColSchema->bytes, pExpr->functionId, (int32_t)pExpr->param[0].i64Key, &pExpr->resType, + getResultDataInfo(pColSchema->type, pColSchema->bytes, pExpr->functionId, (int32_t)pExpr->param[0].i64, &pExpr->resType, &pExpr->resBytes, &pExpr->interBytes, tagLength, isSTable); } } @@ -6021,9 +6022,9 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCreateDbMsg* pCreate) { } if (pCreate->quorum != -1 && - (pCreate->quorum < TSDB_MIN_DB_REPLICA_OPTION || pCreate->quorum > TSDB_MAX_DB_REPLICA_OPTION)) { + (pCreate->quorum < TSDB_MIN_DB_QUORUM_OPTION || pCreate->quorum > TSDB_MAX_DB_QUORUM_OPTION)) { snprintf(msg, tListLen(msg), "invalid db option quorum: %d valid range: [%d, %d]", pCreate->quorum, - TSDB_MIN_DB_REPLICA_OPTION, TSDB_MAX_DB_REPLICA_OPTION); + TSDB_MIN_DB_QUORUM_OPTION, TSDB_MAX_DB_QUORUM_OPTION); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } @@ -6100,7 +6101,9 @@ void tscPrintSelectClause(SSqlObj* pSql, int32_t subClauseIndex) { int32_t tmpLen = 0; tmpLen = sprintf(tmpBuf, "%s(uid:%" PRId64 ", %d)", aAggs[pExpr->functionId].aName, pExpr->uid, pExpr->colInfo.colId); - if (tmpLen + offset > totalBufSize) break; + + if (tmpLen + offset >= totalBufSize - 1) break; + offset += sprintf(str + offset, "%s", tmpBuf); @@ -6109,7 +6112,9 @@ void tscPrintSelectClause(SSqlObj* pSql, int32_t subClauseIndex) { } } + assert(offset < totalBufSize); str[offset] = ']'; + assert(offset < totalBufSize); tscDebug("%p select clause:%s", pSql, str); } @@ -6760,7 +6765,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS // check for dividing by 0 if ((*pExpr)->_node.optr == TSDB_BINARY_OP_DIVIDE) { if (pRight->nodeType == TSQL_NODE_VALUE) { - if (pRight->pVal->nType == TSDB_DATA_TYPE_INT && pRight->pVal->i64Key == 0) { + if (pRight->pVal->nType == TSDB_DATA_TYPE_INT && pRight->pVal->i64 == 0) { return TSDB_CODE_TSC_INVALID_SQL; } else if (pRight->pVal->nType == TSDB_DATA_TYPE_FLOAT && pRight->pVal->dKey == 0) { return TSDB_CODE_TSC_INVALID_SQL; diff --git a/src/client/src/tscSchemaUtil.c b/src/client/src/tscSchemaUtil.c index b9d38e3ea7..123f0fd222 100644 --- a/src/client/src/tscSchemaUtil.c +++ b/src/client/src/tscSchemaUtil.c @@ -66,30 +66,24 @@ STableComInfo tscGetTableInfo(const STableMeta* pTableMeta) { return pTableMeta->tableInfo; } -bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) { - if (!VALIDNUMOFCOLS(numOfCols)) { - return false; - } - - /* first column must be the timestamp, which is a primary key */ - if (pSchema[0].type != TSDB_DATA_TYPE_TIMESTAMP) { - return false; - } - - /* type is valid, length is valid */ +static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen) { int32_t rowLen = 0; for (int32_t i = 0; i < numOfCols; ++i) { // 1. valid types - if (pSchema[i].type > TSDB_DATA_TYPE_TIMESTAMP || pSchema[i].type < TSDB_DATA_TYPE_BOOL) { + if (!isValidDataType(pSchema[i].type)) { return false; } // 2. valid length for each type - if (pSchema[i].type == TSDB_DATA_TYPE_TIMESTAMP) { + if (pSchema[i].type == TSDB_DATA_TYPE_BINARY) { if (pSchema[i].bytes > TSDB_MAX_BINARY_LEN) { return false; } + } else if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) { + if (pSchema[i].bytes > TSDB_MAX_NCHAR_LEN) { + return false; + } } else { if (pSchema[i].bytes != tDataTypeDesc[pSchema[i].type].nSize) { return false; @@ -106,8 +100,32 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) { rowLen += pSchema[i].bytes; } - // valid total length - return (rowLen <= TSDB_MAX_BYTES_PER_ROW); + return rowLen <= maxLen; +} + +bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags) { + if (!VALIDNUMOFCOLS(numOfCols)) { + return false; + } + + if (!VALIDNUMOFTAGS(numOfTags)) { + return false; + } + + /* first column must be the timestamp, which is a primary key */ + if (pSchema[0].type != TSDB_DATA_TYPE_TIMESTAMP) { + return false; + } + + if (!doValidateSchema(pSchema, numOfCols, TSDB_MAX_BYTES_PER_ROW)) { + return false; + } + + if (!doValidateSchema(&pSchema[numOfCols], numOfTags, TSDB_MAX_TAGS_LEN)) { + return false; + } + + return true; } SSchema* tscGetTableColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) { diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 4949aa9b9d..15dd77faeb 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -423,7 +423,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { if (shouldFree) { // in case of table-meta/vgrouplist query, automatically free it taosRemoveRef(tscObjRef, pSql->self); - tscDebug("%p sqlObj is automatically freed", pSql); + tscDebug("%p sqlObj is automatically freed", pSql); } rpcFreeCont(rpcMsg->pCont); @@ -755,12 +755,10 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SColumn *pCol = taosArrayGetP(pQueryInfo->colList, i); SSchema *pColSchema = &pSchema[pCol->colIndex.columnIndex]; - if (pCol->colIndex.columnIndex >= tscGetNumOfColumns(pTableMeta) || pColSchema->type < TSDB_DATA_TYPE_BOOL || - pColSchema->type > TSDB_DATA_TYPE_NCHAR) { + if (pCol->colIndex.columnIndex >= tscGetNumOfColumns(pTableMeta) || !isValidDataType(pColSchema->type)) { tscError("%p tid:%d uid:%" PRIu64" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s", pSql, pTableMeta->id.tid, pTableMeta->id.uid, pTableMetaInfo->name, tscGetNumOfColumns(pTableMeta), pCol->colIndex.columnIndex, pColSchema->name); - return TSDB_CODE_TSC_INVALID_SQL; } @@ -826,7 +824,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { memcpy(pMsg, pExpr->param[j].pz, pExpr->param[j].nLen); pMsg += pExpr->param[j].nLen; } else { - pSqlFuncExpr->arg[j].argValue.i64 = htobe64(pExpr->param[j].i64Key); + pSqlFuncExpr->arg[j].argValue.i64 = htobe64(pExpr->param[j].i64); } } @@ -866,7 +864,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { memcpy(pMsg, pExpr->param[j].pz, pExpr->param[j].nLen); pMsg += pExpr->param[j].nLen; } else { - pSqlFuncExpr1->arg[j].argValue.i64 = htobe64(pExpr->param[j].i64Key); + pSqlFuncExpr1->arg[j].argValue.i64 = htobe64(pExpr->param[j].i64); } } @@ -944,7 +942,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSchema *pColSchema = &pSchema[pCol->colIndex.columnIndex]; if ((pCol->colIndex.columnIndex >= numOfTagColumns || pCol->colIndex.columnIndex < -1) || - (pColSchema->type < TSDB_DATA_TYPE_BOOL || pColSchema->type > TSDB_DATA_TYPE_NCHAR)) { + (!isValidDataType(pColSchema->type))) { tscError("%p tid:%d uid:%" PRIu64 " id:%s, tag index out of range, totalCols:%d, numOfTags:%d, index:%d, column name:%s", pSql, pTableMeta->id.tid, pTableMeta->id.uid, pTableMetaInfo->name, total, numOfTagColumns, pCol->colIndex.columnIndex, pColSchema->name); @@ -1830,7 +1828,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { assert(i == 0); } - assert(pSchema->type >= TSDB_DATA_TYPE_BOOL && pSchema->type <= TSDB_DATA_TYPE_NCHAR); + assert(isValidDataType(pSchema->type)); pSchema++; } @@ -1977,9 +1975,6 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) { // // rsp += tagLen; // int32_t size = (int32_t)(rsp - ((char *)pMeta)); // Consistent with STableMeta in cache - // - // pMeta->index = 0; - // (void)taosCachePut(tscMetaCache, pMeta->tableId, (char *)pMeta, size, tsTableMetaKeepTimer); // } } @@ -1992,16 +1987,20 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) { } int tscProcessSTableVgroupRsp(SSqlObj *pSql) { + // master sqlObj locates in param + SSqlObj* parent = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)pSql->param); + if(parent == NULL) { + return pSql->res.code; + } + + assert(parent->signature == parent && (int64_t)pSql->param == parent->self); + SSqlRes* pRes = &pSql->res; // NOTE: the order of several table must be preserved. SSTableVgroupRspMsg *pStableVgroup = (SSTableVgroupRspMsg *)pRes->pRsp; pStableVgroup->numOfTables = htonl(pStableVgroup->numOfTables); char *pMsg = pRes->pRsp + sizeof(SSTableVgroupRspMsg); - - // master sqlObj locates in param - SSqlObj* parent = pSql->param; - assert(parent != NULL); SSqlCmd* pCmd = &parent->cmd; for(int32_t i = 0; i < pStableVgroup->numOfTables; ++i) { @@ -2035,6 +2034,8 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) { pMsg += size; } + + taosReleaseRef(tscObjRef, parent->self); return pSql->res.code; } @@ -2328,11 +2329,15 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn tscDebug("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated); - pNew->fp = tscTableMetaCallBack; - pNew->param = pSql; - registerSqlObj(pNew); + pNew->fp = tscTableMetaCallBack; + pNew->param = (void *)pSql->self; + + tscDebug("%p metaRid from %" PRId64 " to %" PRId64 , pSql, pSql->metaRid, pNew->self); + + pSql->metaRid = pNew->self; + int32_t code = tscProcessSql(pNew); if (code == TSDB_CODE_SUCCESS) { code = TSDB_CODE_TSC_ACTION_IN_PROGRESS; // notify application that current process needs to be terminated @@ -2348,6 +2353,7 @@ int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) { uint32_t size = tscGetTableMetaMaxSize(); pTableMetaInfo->pTableMeta = calloc(1, size); + pTableMetaInfo->pTableMeta->tableType = -1; pTableMetaInfo->pTableMeta->tableInfo.numOfColumns = -1; int32_t len = (int32_t) strlen(pTableMetaInfo->name); @@ -2447,10 +2453,15 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) { pNewQueryInfo->numOfTables = pQueryInfo->numOfTables; registerSqlObj(pNew); + tscDebug("%p svgroupRid from %" PRId64 " to %" PRId64 , pSql, pSql->svgroupRid, pNew->self); + + pSql->svgroupRid = pNew->self; + + tscDebug("%p new sqlObj:%p to get vgroupInfo, numOfTables:%d", pSql, pNew, pNewQueryInfo->numOfTables); pNew->fp = tscTableMetaCallBack; - pNew->param = pSql; + pNew->param = (void *)pSql->self; code = tscProcessSql(pNew); if (code == TSDB_CODE_SUCCESS) { code = TSDB_CODE_TSC_ACTION_IN_PROGRESS; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 377cb24b1d..3f25d7a14d 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -47,7 +47,7 @@ static bool validUserName(const char* user) { } static bool validPassword(const char* passwd) { - return validImpl(passwd, TSDB_PASSWORD_LEN - 1); + return validImpl(passwd, TSDB_KEY_LEN - 1); } static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, const char *auth, const char *db, @@ -238,11 +238,11 @@ TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t us uint8_t passLen, const char *db, uint8_t dbLen, uint16_t port) { char ipBuf[TSDB_EP_LEN] = {0}; char userBuf[TSDB_USER_LEN] = {0}; - char passBuf[TSDB_PASSWORD_LEN] = {0}; + char passBuf[TSDB_KEY_LEN] = {0}; char dbBuf[TSDB_DB_NAME_LEN] = {0}; strncpy(ipBuf, ip, MIN(TSDB_EP_LEN - 1, ipLen)); strncpy(userBuf, user, MIN(TSDB_USER_LEN - 1, userLen)); - strncpy(passBuf, pass, MIN(TSDB_PASSWORD_LEN - 1, passLen)); + strncpy(passBuf, pass, MIN(TSDB_KEY_LEN - 1, passLen)); strncpy(dbBuf, db, MIN(TSDB_DB_NAME_LEN - 1, dbLen)); return taos_connect(ipBuf, userBuf, passBuf, dbBuf, port); } @@ -327,7 +327,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, int64_t* return NULL; } - nPrintTsc(sqlstr); + nPrintTsc("%s", sqlstr); SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); if (pSql == NULL) { @@ -694,6 +694,8 @@ static void tscKillSTableQuery(SSqlObj *pSql) { // set the master sqlObj flag to cancel query pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED; + tscLockByThread(&pSql->squeryLock); + for (int i = 0; i < pSql->subState.numOfSub; ++i) { // NOTE: pSub may have been released already here SSqlObj *pSub = pSql->pSubs[i]; @@ -713,6 +715,12 @@ static void tscKillSTableQuery(SSqlObj *pSql) { taosReleaseRef(tscObjRef, pSubObj->self); } + if (pSql->subState.numOfSub <= 0) { + tscAsyncResultOnError(pSql); + } + + tscUnlockByThread(&pSql->squeryLock); + tscDebug("%p super table query cancelled", pSql); } @@ -788,18 +796,34 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) len += sprintf(str + len, "%d", *((int8_t *)row[i])); break; + case TSDB_DATA_TYPE_UTINYINT: + len += sprintf(str + len, "%u", *((uint8_t *)row[i])); + break; + case TSDB_DATA_TYPE_SMALLINT: len += sprintf(str + len, "%d", *((int16_t *)row[i])); break; + case TSDB_DATA_TYPE_USMALLINT: + len += sprintf(str + len, "%u", *((uint16_t *)row[i])); + break; + case TSDB_DATA_TYPE_INT: len += sprintf(str + len, "%d", *((int32_t *)row[i])); break; + case TSDB_DATA_TYPE_UINT: + len += sprintf(str + len, "%u", *((uint32_t *)row[i])); + break; + case TSDB_DATA_TYPE_BIGINT: len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i])); break; + case TSDB_DATA_TYPE_UBIGINT: + len += sprintf(str + len, "%" PRIu64, *((uint64_t *)row[i])); + break; + case TSDB_DATA_TYPE_FLOAT: { float fv = 0; fv = GET_FLOAT_VAL(row[i]); @@ -962,7 +986,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t return code; } - if (++pCmd->count > TSDB_MULTI_METERMETA_MAX_NUM) { + if (++pCmd->count > TSDB_MULTI_TABLEMETA_MAX_NUM) { code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; sprintf(pCmd->payload, "tables over the max number"); return code; diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index d1004fff62..a39fbc9420 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -65,15 +65,30 @@ static int64_t tscGetRetryDelayTime(SSqlStream* pStream, int64_t slidingTime, in return retryDelta; } +static void setRetryInfo(SSqlStream* pStream, int32_t code) { + SSqlObj* pSql = pStream->pSql; + + pSql->res.code = code; + int64_t retryDelayTime = tscGetRetryDelayTime(pStream, pStream->interval.sliding, pStream->precision); + tscDebug("%p stream:%p, get table Meta failed, retry in %" PRId64 "ms", pSql, pStream, retryDelayTime); + tscSetRetryTimer(pStream, pSql, retryDelayTime); +} + static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) { SSqlStream *pStream = (SSqlStream *)param; - assert(pStream->pSql == tres && code == TSDB_CODE_SUCCESS); + assert(pStream->pSql == tres); SSqlObj* pSql = (SSqlObj*) tres; - pSql->fp = doLaunchQuery; + + pSql->fp = doLaunchQuery; pSql->fetchFp = doLaunchQuery; pSql->res.completed = false; + if (code != TSDB_CODE_SUCCESS) { + setRetryInfo(pStream, code); + return; + } + SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); @@ -82,6 +97,10 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) { code = tscGetSTableVgroupInfo(pSql, 0); } + if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { + return; + } + // failed to get table Meta or vgroup list, retry in 10sec. if (code == TSDB_CODE_SUCCESS) { tscTansformSQLFuncForSTableQuery(pQueryInfo); @@ -91,11 +110,8 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) { pSql->fetchFp = tscProcessStreamQueryCallback; tscDoQuery(pSql); tscIncStreamExecutionCount(pStream); - } else if (code != TSDB_CODE_TSC_ACTION_IN_PROGRESS) { - pSql->res.code = code; - int64_t retryDelayTime = tscGetRetryDelayTime(pStream, pStream->interval.sliding, pStream->precision); - tscDebug("%p stream:%p, get table Meta failed, retry in %" PRId64 "ms", pSql, pStream, retryDelayTime); - tscSetRetryTimer(pStream, pSql, retryDelayTime); + } else { + setRetryInfo(pStream, code); } } @@ -535,7 +551,6 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) { int64_t starttime = tscGetLaunchTimestamp(pStream); pCmd->command = TSDB_SQL_SELECT; - registerSqlObj(pSql); tscAddIntoStreamList(pStream); taosTmrReset(tscProcessStreamTimer, (int32_t)starttime, pStream, tscTmr, &pStream->pTimer); @@ -594,12 +609,15 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p pSql->fp = tscCreateStream; pSql->fetchFp = tscCreateStream; + + registerSqlObj(pSql); + int32_t code = tsParseSql(pSql, true); if (code == TSDB_CODE_SUCCESS) { tscCreateStream(pStream, pSql, code); } else if (code != TSDB_CODE_TSC_ACTION_IN_PROGRESS) { tscError("%p open stream failed, sql:%s, code:%s", pSql, sqlstr, tstrerror(pRes->code)); - tscFreeSqlObj(pSql); + taosReleaseRef(tscObjRef, pSql->self); free(pStream); return NULL; } diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 96fdde4fd6..2622246111 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -465,7 +465,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { int16_t colId = tscGetJoinTagColIdByUid(&pQueryInfo->tagCond, pTableMetaInfo->pTableMeta->id.uid); // set the tag column id for executor to extract correct tag value - pExpr->param[0] = (tVariant) {.i64Key = colId, .nType = TSDB_DATA_TYPE_BIGINT, .nLen = sizeof(int64_t)}; + pExpr->param[0] = (tVariant) {.i64 = colId, .nType = TSDB_DATA_TYPE_BIGINT, .nLen = sizeof(int64_t)}; pExpr->numOfParams = 1; } @@ -533,7 +533,7 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) { freeJoinSubqueryObj(pSqlObj); } - tscDestroyJoinSupporter(pSupporter); + //tscDestroyJoinSupporter(pSupporter); } // update the query time range according to the join results on timestamp @@ -650,7 +650,7 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, 0); int16_t tagColId = tscGetJoinTagColIdByUid(&pSupporter->tagCond, pTableMetaInfo->pTableMeta->id.uid); - pExpr->param->i64Key = tagColId; + pExpr->param->i64 = tagColId; pExpr->numOfParams = 1; } @@ -1362,9 +1362,11 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) { SJoinSupporter* pSupporter = (SJoinSupporter*)param; SSqlObj* pParentSql = pSupporter->pObj; - + // There is only one subquery and table for each subquery. SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); + assert(pQueryInfo->numOfTables == 1 && pSql->cmd.numOfClause == 1); // retrieve actual query results from vnode during the second stage join subquery @@ -1382,7 +1384,6 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) { tscError("%p abort query, code:%s, global code:%s", pSql, tstrerror(code), tstrerror(pParentSql->res.code)); pParentSql->res.code = code; - quitAllSubquery(pParentSql, pSupporter); tscAsyncResultOnError(pParentSql); @@ -1405,9 +1406,6 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) { return; } - - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - // In case of consequence query from other vnode, do not wait for other query response here. if (!(pTableMetaInfo->vgroupIndex > 0 && tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0))) { if (atomic_sub_fetch_32(&pParentSql->subState.numOfRemain, 1) > 0) { @@ -1547,7 +1545,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { int16_t tagColId = tscGetJoinTagColIdByUid(&pSupporter->tagCond, pTableMetaInfo->pTableMeta->id.uid); - pExpr->param->i64Key = tagColId; + pExpr->param->i64 = tagColId; pExpr->numOfParams = 1; } @@ -1658,6 +1656,25 @@ static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs) { } } +void tscLockByThread(int64_t *lockedBy) { + int64_t tid = taosGetSelfPthreadId(); + int i = 0; + while (atomic_val_compare_exchange_64(lockedBy, 0, tid) != 0) { + if (++i % 100 == 0) { + sched_yield(); + } + } +} + +void tscUnlockByThread(int64_t *lockedBy) { + int64_t tid = taosGetSelfPthreadId(); + if (atomic_val_compare_exchange_64(lockedBy, tid, 0) != tid) { + assert(false); + } +} + + + int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { SSqlRes *pRes = &pSql->res; SSqlCmd *pCmd = &pSql->cmd; @@ -2120,6 +2137,7 @@ static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsuppo return pNew; } +// todo there is are race condition in this function, while cancel is called by user. void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) { // the param may be null, since it may be done by other query threads. and the asyncOnError may enter in this // function while kill query by a user. diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 5d818692ed..9a8aa917e7 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -71,6 +71,7 @@ void tsSetSTableQueryCond(STagCond* pTagCond, uint64_t uid, SBufferWriter* bw) { bool tscQueryTags(SQueryInfo* pQueryInfo) { int32_t numOfCols = (int32_t) tscSqlExprNumOfExprs(pQueryInfo); + for (int32_t i = 0; i < numOfCols; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); int32_t functId = pExpr->functionId; @@ -314,7 +315,7 @@ void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo) { } else { for (int32_t k = 0; k < pRes->numOfRows; ++k) { char* p = ((char**)pRes->urow)[i] + k * pInfo->field.bytes; - memcpy(p, &pInfo->pSqlExpr->param[1].i64Key, pInfo->field.bytes); + memcpy(p, &pInfo->pSqlExpr->param[1].i64, pInfo->field.bytes); } } } @@ -467,6 +468,18 @@ void tscFreeRegisteredSqlObj(void *pSql) { } +void tscFreeMetaSqlObj(int64_t *rid){ + if (RID_VALID(*rid)) { + SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, *rid); + if (pSql) { + taosRemoveRef(tscObjRef, *rid); + taosReleaseRef(tscObjRef, *rid); + } + + *rid = 0; + } +} + void tscFreeSqlObj(SSqlObj* pSql) { if (pSql == NULL || pSql->signature != pSql) { return; @@ -476,6 +489,9 @@ void tscFreeSqlObj(SSqlObj* pSql) { pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED; + tscFreeMetaSqlObj(&pSql->metaRid); + tscFreeMetaSqlObj(&pSql->svgroupRid); + tscFreeSubobj(pSql); SSqlCmd* pCmd = &pSql->cmd; @@ -504,6 +520,7 @@ void tscFreeSqlObj(SSqlObj* pSql) { pCmd->allocSize = 0; tsem_destroy(&pSql->rspSem); + memset(pSql, 0, sizeof(*pSql)); free(pSql); } @@ -2192,7 +2209,9 @@ void tscDoQuery(SSqlObj* pSql) { tscProcessSql(pSql); } else { // secondary stage join query. if (tscIsTwoStageSTableQuery(pQueryInfo, 0)) { // super table query + tscLockByThread(&pSql->squeryLock); tscHandleMasterSTableQuery(pSql); + tscUnlockByThread(&pSql->squeryLock); } else { tscProcessSql(pSql); } @@ -2201,7 +2220,9 @@ void tscDoQuery(SSqlObj* pSql) { return; } else if (tscIsTwoStageSTableQuery(pQueryInfo, 0)) { // super table query + tscLockByThread(&pSql->squeryLock); tscHandleMasterSTableQuery(pSql); + tscUnlockByThread(&pSql->squeryLock); return; } diff --git a/src/client/tests/CMakeLists.txt b/src/client/tests/CMakeLists.txt index f07af85e25..4ea0b80bf7 100644 --- a/src/client/tests/CMakeLists.txt +++ b/src/client/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include/gtest) diff --git a/src/client/tests/timeParseTest.cpp b/src/client/tests/timeParseTest.cpp index bee01b5cec..d7325430cd 100644 --- a/src/client/tests/timeParseTest.cpp +++ b/src/client/tests/timeParseTest.cpp @@ -162,6 +162,10 @@ TEST(testCase, parse_time) { taosParseTime(t13, &time, strlen(t13), TSDB_TIME_PRECISION_MILLI, 0); EXPECT_EQ(time, -28800 * MILLISECOND_PER_SECOND); + + char* t = "2021-01-08T02:11:40.000+00:00"; + taosParseTime(t, &time, strlen(t), TSDB_TIME_PRECISION_MILLI, 0); + printf("%ld\n", time); } diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 0da7bda994..df0ac79865 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index f1fc5ca808..c54d519637 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -36,6 +36,7 @@ extern int8_t tsEnableVnodeBak; extern int8_t tsEnableTelemetryReporting; extern char tsEmail[]; extern char tsArbitrator[]; +extern int8_t tsArbOnline; // common extern int tsRpcTimer; @@ -62,7 +63,6 @@ extern int32_t tsRetrieveBlockingModel;// retrieve threads will be blocked extern int8_t tsKeepOriginalColumnName; // client -extern int32_t tsTableMetaKeepTimer; extern int32_t tsMaxSQLStringLen; extern int8_t tsTscEnableRecordSql; extern int32_t tsMaxNumOfOrderedResults; @@ -190,7 +190,7 @@ extern int32_t monDebugFlag; extern int32_t uDebugFlag; extern int32_t rpcDebugFlag; extern int32_t odbcDebugFlag; -extern int32_t qDebugFlag; +extern uint32_t qDebugFlag; extern int32_t wDebugFlag; extern int32_t cqDebugFlag; extern int32_t debugFlag; diff --git a/src/common/inc/tvariant.h b/src/common/inc/tvariant.h index e9973bcb95..f8f715c6ca 100644 --- a/src/common/inc/tvariant.h +++ b/src/common/inc/tvariant.h @@ -28,7 +28,8 @@ typedef struct tVariant { uint32_t nType; int32_t nLen; // only used for string, for number, it is useless union { - int64_t i64Key; + int64_t i64; + uint64_t u64; double dKey; char * pz; wchar_t *wpz; @@ -36,9 +37,9 @@ typedef struct tVariant { }; } tVariant; -void tVariantCreate(tVariant *pVar, SStrToken *token); +bool tVariantIsValid(tVariant *pVar); -void tVariantCreateFromString(tVariant *pVar, char *pz, uint32_t len, uint32_t type); +void tVariantCreate(tVariant *pVar, SStrToken *token); void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32_t type); diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 8fa17f8751..125e805642 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -41,6 +41,7 @@ int32_t tsStatusInterval = 1; // second int32_t tsNumOfMnodes = 3; int8_t tsEnableVnodeBak = 1; int8_t tsEnableTelemetryReporting = 1; +int8_t tsArbOnline = 0; char tsEmail[TSDB_FQDN_LEN] = {0}; // common @@ -71,7 +72,6 @@ char tsTempDir[TSDB_FILENAME_LEN] = "/tmp/"; int32_t tsCompressMsgSize = -1; // client -int32_t tsTableMetaKeepTimer = 7200; // second int32_t tsMaxSQLStringLen = TSDB_MAX_SQL_LEN; int8_t tsTscEnableRecordSql = 0; @@ -218,7 +218,7 @@ int32_t odbcDebugFlag = 131; int32_t httpDebugFlag = 131; int32_t mqttDebugFlag = 131; int32_t monDebugFlag = 131; -int32_t qDebugFlag = 131; +uint32_t qDebugFlag = 131; int32_t rpcDebugFlag = 131; int32_t uDebugFlag = 131; int32_t debugFlag = 0; @@ -595,16 +595,6 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_SECOND; taosInitConfigOption(cfg); - cfg.option = "tableMetaKeepTimer"; - cfg.ptr = &tsTableMetaKeepTimer; - cfg.valType = TAOS_CFG_VTYPE_INT32; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; - cfg.minValue = 1; - cfg.maxValue = 8640000; - cfg.ptrLength = 0; - cfg.unitType = TAOS_CFG_UTYPE_SECOND; - taosInitConfigOption(cfg); - cfg.option = "minSlidingTime"; cfg.ptr = &tsMinSlidingTime; cfg.valType = TAOS_CFG_VTYPE_INT32; @@ -810,8 +800,8 @@ static void doInitGlobalConfig(void) { cfg.ptr = &tsQuorum; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = TSDB_MIN_DB_REPLICA_OPTION; - cfg.maxValue = TSDB_MAX_DB_REPLICA_OPTION; + cfg.minValue = TSDB_MIN_DB_QUORUM_OPTION; + cfg.maxValue = TSDB_MAX_DB_QUORUM_OPTION; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index f28481977f..8197fb1042 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -18,7 +18,7 @@ #include "ttokendef.h" #include "tscompression.h" -const int32_t TYPE_BYTES[11] = { +const int32_t TYPE_BYTES[15] = { -1, // TSDB_DATA_TYPE_NULL sizeof(int8_t), // TSDB_DATA_TYPE_BOOL sizeof(int8_t), // TSDB_DATA_TYPE_TINYINT @@ -29,10 +29,28 @@ const int32_t TYPE_BYTES[11] = { sizeof(double), // TSDB_DATA_TYPE_DOUBLE sizeof(VarDataOffsetT), // TSDB_DATA_TYPE_BINARY sizeof(TSKEY), // TSDB_DATA_TYPE_TIMESTAMP - sizeof(VarDataOffsetT) // TSDB_DATA_TYPE_NCHAR + sizeof(VarDataOffsetT), // TSDB_DATA_TYPE_NCHAR + sizeof(uint8_t), // TSDB_DATA_TYPE_UTINYINT + sizeof(uint16_t), // TSDB_DATA_TYPE_USMALLINT + sizeof(uint32_t), // TSDB_DATA_TYPE_UINT + sizeof(uint64_t), // TSDB_DATA_TYPE_UBIGINT }; -static void getStatics_bool(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, +#define DO_STATICS(__sum, __min, __max, __minIndex, __maxIndex, _list, _index) \ + do { \ + (__sum) += (_list)[(_index)]; \ + if ((__min) > (_list)[(_index)]) { \ + (__min) = (_list)[(_index)]; \ + (__minIndex) = (_index); \ + } \ + \ + if ((__max) < (_list)[(_index)]) { \ + (__max) = (_list)[(_index)]; \ + (__maxIndex) = (_index); \ + } \ + } while (0) + +static void getStatics_bool(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int8_t *data = (int8_t *)pData; *min = INT64_MAX; @@ -43,26 +61,17 @@ static void getStatics_bool(const TSKEY *primaryKey, const void *pData, int32_t ASSERT(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull((char *)&data[i], TSDB_DATA_TYPE_BOOL)) { + if (data[i] == TSDB_DATA_BOOL_NULL) { (*numOfNull) += 1; continue; } - - *sum += data[i]; - if (*min > data[i]) { - *min = data[i]; - *minIndex = i; - } - - if (*max < data[i]) { - *max = data[i]; - *maxIndex = i; - } + + DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i); } } -static void getStatics_i8(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, - int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_i8(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, + int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int8_t *data = (int8_t *)pData; *min = INT64_MAX; *max = INT64_MIN; @@ -72,26 +81,43 @@ static void getStatics_i8(const TSKEY *primaryKey, const void *pData, int32_t nu ASSERT(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull((char *)&data[i], TSDB_DATA_TYPE_TINYINT)) { + if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) { (*numOfNull) += 1; continue; } - - *sum += data[i]; - if (*min > data[i]) { - *min = data[i]; - *minIndex = i; - } - - if (*max < data[i]) { - *max = data[i]; - *maxIndex = i; - } + + DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i); } } -static void getStatics_i16(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, - int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_u8(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, + int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { + uint8_t *data = (uint8_t *)pData; + uint64_t _min = UINT64_MAX; + uint64_t _max = 0; + uint64_t _sum = 0; + + *minIndex = 0; + *maxIndex = 0; + + ASSERT(numOfRow <= INT16_MAX); + + for (int32_t i = 0; i < numOfRow; ++i) { + if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) { + (*numOfNull) += 1; + continue; + } + + DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i); + } + + *min = _min; + *max = _max; + *sum = _sum; +} + +static void getStatics_i16(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, + int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int16_t *data = (int16_t *)pData; *min = INT64_MAX; *max = INT64_MIN; @@ -100,39 +126,45 @@ static void getStatics_i16(const TSKEY *primaryKey, const void *pData, int32_t n ASSERT(numOfRow <= INT16_MAX); - // int64_t lastKey = 0; - // int16_t lastVal = TSDB_DATA_SMALLINT_NULL; - for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull((const char*) &data[i], TSDB_DATA_TYPE_SMALLINT)) { + if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) { (*numOfNull) += 1; continue; } - - *sum += data[i]; - if (*min > data[i]) { - *min = data[i]; - *minIndex = i; - } - - if (*max < data[i]) { - *max = data[i]; - *maxIndex = i; - } - - // if (isNull(&lastVal, TSDB_DATA_TYPE_SMALLINT)) { - // lastKey = primaryKey[i]; - // lastVal = data[i]; - // } else { - // *wsum = lastVal * (primaryKey[i] - lastKey); - // lastKey = primaryKey[i]; - // lastVal = data[i]; - // } + + DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i); } + } -static void getStatics_i32(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, - int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { +static void getStatics_u16(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, + int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { + uint16_t *data = (uint16_t *)pData; + uint64_t _min = UINT64_MAX; + uint64_t _max = 0; + uint64_t _sum = 0; + + *minIndex = 0; + *maxIndex = 0; + + ASSERT(numOfRow <= INT16_MAX); + + for (int32_t i = 0; i < numOfRow; ++i) { + if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) { + (*numOfNull) += 1; + continue; + } + + DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i); + } + + *min = _min; + *max = _max; + *sum = _sum; +} + +static void getStatics_i32(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, + int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int32_t *data = (int32_t *)pData; *min = INT64_MAX; *max = INT64_MIN; @@ -141,29 +173,43 @@ static void getStatics_i32(const TSKEY *primaryKey, const void *pData, int32_t n ASSERT(numOfRow <= INT16_MAX); - // int64_t lastKey = 0; - // int32_t lastVal = TSDB_DATA_INT_NULL; - for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull((const char*) &data[i], TSDB_DATA_TYPE_INT)) { + if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) { (*numOfNull) += 1; continue; } - - *sum += data[i]; - if (*min > data[i]) { - *min = data[i]; - *minIndex = i; - } - - if (*max < data[i]) { - *max = data[i]; - *maxIndex = i; - } + + DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i); } } -static void getStatics_i64(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, +static void getStatics_u32(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, + int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { + uint32_t *data = (uint32_t *)pData; + uint64_t _min = UINT64_MAX; + uint64_t _max = 0; + uint64_t _sum = 0; + + *minIndex = 0; + *maxIndex = 0; + + ASSERT(numOfRow <= INT16_MAX); + + for (int32_t i = 0; i < numOfRow; ++i) { + if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) { + (*numOfNull) += 1; + continue; + } + + DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i); + } + + *min = _min; + *max = _max; + *sum = _sum; +} + +static void getStatics_i64(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int64_t *data = (int64_t *)pData; *min = INT64_MAX; @@ -174,52 +220,60 @@ static void getStatics_i64(const TSKEY *primaryKey, const void *pData, int32_t n ASSERT(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull((const char*) &data[i], TSDB_DATA_TYPE_BIGINT)) { + if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) { (*numOfNull) += 1; continue; } - - *sum += data[i]; - if (*min > data[i]) { - *min = data[i]; - *minIndex = i; - } - - if (*max < data[i]) { - *max = data[i]; - *maxIndex = i; - } - - // if (isNull(&lastVal, TSDB_DATA_TYPE_BIGINT)) { - // lastKey = primaryKey[i]; - // lastVal = data[i]; - // } else { - // *wsum = lastVal * (primaryKey[i] - lastKey); - // lastKey = primaryKey[i]; - // lastVal = data[i]; - // } + + DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i); } } -static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, +static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, + int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { + uint64_t *data = (uint64_t *)pData; + uint64_t _min = UINT64_MAX; + uint64_t _max = 0; + uint64_t _sum = 0; + + *minIndex = 0; + *maxIndex = 0; + + ASSERT(numOfRow <= INT16_MAX); + + for (int32_t i = 0; i < numOfRow; ++i) { + if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) { + (*numOfNull) += 1; + continue; + } + + DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i); + } + + *min = _min; + *max = _max; + *sum = _sum; +} + +static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { - float *data = (float *)pData; - float fmin = FLT_MAX; - float fmax = -FLT_MAX; - double dsum = 0; - *minIndex = 0; - *maxIndex = 0; + float *data = (float *)pData; + float fmin = FLT_MAX; + float fmax = -FLT_MAX; + double dsum = 0; + *minIndex = 0; + *maxIndex = 0; ASSERT(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull((const char*) &data[i], TSDB_DATA_TYPE_FLOAT)) { + if ((*(uint32_t*)&(data[i])) == TSDB_DATA_FLOAT_NULL) { (*numOfNull) += 1; continue; } - - float fv = 0; - fv = GET_FLOAT_VAL((const char*)&(data[i])); + + float fv = GET_FLOAT_VAL((const char*)&(data[i])); + dsum += fv; if (fmin > fv) { fmin = fv; @@ -232,28 +286,24 @@ static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t num } } - double csum = 0; - csum = GET_DOUBLE_VAL((const char *)sum); - csum += dsum; - - SET_DOUBLE_VAL(sum, csum); + SET_DOUBLE_VAL(sum, dsum); SET_DOUBLE_VAL(max, fmax); SET_DOUBLE_VAL(min, fmin); } -static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, +static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { double *data = (double *)pData; - double dmin = DBL_MAX; - double dmax = -DBL_MAX; - double dsum = 0; - *minIndex = 0; - *maxIndex = 0; + double dmin = DBL_MAX; + double dmax = -DBL_MAX; + double dsum = 0; + *minIndex = 0; + *maxIndex = 0; ASSERT(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull((const char*) &data[i], TSDB_DATA_TYPE_DOUBLE)) { + if ((*(uint64_t*)&(data[i])) == TSDB_DATA_DOUBLE_NULL) { (*numOfNull) += 1; continue; } @@ -272,16 +322,12 @@ static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t num } } - double csum = 0; - csum = GET_DOUBLE_VAL((const char *)sum); - csum += dsum; - - SET_DOUBLE_PTR(sum, &csum); + SET_DOUBLE_PTR(sum, &dsum); SET_DOUBLE_PTR(max, &dmax); SET_DOUBLE_PTR(min, &dmin); } -static void getStatics_bin(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, +static void getStatics_bin(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { const char* data = pData; ASSERT(numOfRow <= INT16_MAX); @@ -301,7 +347,7 @@ static void getStatics_bin(const TSKEY *primaryKey, const void *pData, int32_t n *maxIndex = 0; } -static void getStatics_nchr(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, +static void getStatics_nchr(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { const char* data = pData; ASSERT(numOfRow <= INT16_MAX); @@ -321,18 +367,22 @@ static void getStatics_nchr(const TSKEY *primaryKey, const void *pData, int32_t *maxIndex = 0; } -tDataTypeDescriptor tDataTypeDesc[11] = { - {TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", NULL, NULL, NULL}, - {TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", tsCompressBool, tsDecompressBool, getStatics_bool}, - {TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", tsCompressTinyint, tsDecompressTinyint, getStatics_i8}, - {TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", tsCompressSmallint, tsDecompressSmallint, getStatics_i16}, - {TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", tsCompressInt, tsDecompressInt, getStatics_i32}, - {TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", tsCompressBigint, tsDecompressBigint, getStatics_i64}, - {TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", tsCompressFloat, tsDecompressFloat, getStatics_f}, - {TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", tsCompressDouble, tsDecompressDouble, getStatics_d}, - {TSDB_DATA_TYPE_BINARY, 6, 0, "BINARY", tsCompressString, tsDecompressString, getStatics_bin}, - {TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", tsCompressTimestamp, tsDecompressTimestamp, getStatics_i64}, - {TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR", tsCompressString, tsDecompressString, getStatics_nchr}, +tDataTypeDescriptor tDataTypeDesc[15] = { + {TSDB_DATA_TYPE_NULL, 6,1, "NOTYPE", NULL, NULL, NULL}, + {TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", tsCompressBool, tsDecompressBool, getStatics_bool}, + {TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", tsCompressTinyint, tsDecompressTinyint, getStatics_i8}, + {TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", tsCompressSmallint, tsDecompressSmallint, getStatics_i16}, + {TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", tsCompressInt, tsDecompressInt, getStatics_i32}, + {TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", tsCompressBigint, tsDecompressBigint, getStatics_i64}, + {TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", tsCompressFloat, tsDecompressFloat, getStatics_f}, + {TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", tsCompressDouble, tsDecompressDouble, getStatics_d}, + {TSDB_DATA_TYPE_BINARY, 6, 0, "BINARY", tsCompressString, tsDecompressString, getStatics_bin}, + {TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", tsCompressTimestamp, tsDecompressTimestamp, getStatics_i64}, + {TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR", tsCompressString, tsDecompressString, getStatics_nchr}, + {TSDB_DATA_TYPE_UTINYINT, 16, CHAR_BYTES, "TINYINT UNSIGNED", tsCompressTinyint, tsDecompressTinyint, getStatics_u8}, + {TSDB_DATA_TYPE_USMALLINT, 17, SHORT_BYTES, "SMALLINT UNSIGNED", tsCompressSmallint, tsDecompressSmallint, getStatics_u16}, + {TSDB_DATA_TYPE_UINT, 12, INT_BYTES, "INT UNSIGNED", tsCompressInt, tsDecompressInt, getStatics_u32}, + {TSDB_DATA_TYPE_UBIGINT, 15, LONG_BYTES, "BIGINT UNSIGNED", tsCompressBigint, tsDecompressBigint, getStatics_u64}, }; char tTokenTypeSwitcher[13] = { @@ -352,7 +402,7 @@ char tTokenTypeSwitcher[13] = { }; bool isValidDataType(int32_t type) { - return type >= TSDB_DATA_TYPE_NULL && type <= TSDB_DATA_TYPE_NCHAR; + return type >= TSDB_DATA_TYPE_NULL && type <= TSDB_DATA_TYPE_UBIGINT; } void setVardataNull(char* val, int32_t type) { @@ -397,6 +447,26 @@ void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems) { *(uint64_t *)(val + i * tDataTypeDesc[type].nSize) = TSDB_DATA_BIGINT_NULL; } break; + case TSDB_DATA_TYPE_UTINYINT: + for (int32_t i = 0; i < numOfElems; ++i) { + *(uint8_t *)(val + i * tDataTypeDesc[type].nSize) = TSDB_DATA_UTINYINT_NULL; + } + break; + case TSDB_DATA_TYPE_USMALLINT: + for (int32_t i = 0; i < numOfElems; ++i) { + *(uint16_t *)(val + i * tDataTypeDesc[type].nSize) = TSDB_DATA_USMALLINT_NULL; + } + break; + case TSDB_DATA_TYPE_UINT: + for (int32_t i = 0; i < numOfElems; ++i) { + *(uint32_t *)(val + i * tDataTypeDesc[type].nSize) = TSDB_DATA_UINT_NULL; + } + break; + case TSDB_DATA_TYPE_UBIGINT: + for (int32_t i = 0; i < numOfElems; ++i) { + *(uint64_t *)(val + i * tDataTypeDesc[type].nSize) = TSDB_DATA_UBIGINT_NULL; + } + break; case TSDB_DATA_TYPE_FLOAT: for (int32_t i = 0; i < numOfElems; ++i) { *(uint32_t *)(val + i * tDataTypeDesc[type].nSize) = TSDB_DATA_FLOAT_NULL; @@ -422,13 +492,17 @@ void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems) { } } -static uint8_t nullBool = TSDB_DATA_BOOL_NULL; -static uint8_t nullTinyInt = TSDB_DATA_TINYINT_NULL; -static uint16_t nullSmallInt = TSDB_DATA_SMALLINT_NULL; -static uint32_t nullInt = TSDB_DATA_INT_NULL; -static uint64_t nullBigInt = TSDB_DATA_BIGINT_NULL; -static uint32_t nullFloat = TSDB_DATA_FLOAT_NULL; -static uint64_t nullDouble = TSDB_DATA_DOUBLE_NULL; +static uint8_t nullBool = TSDB_DATA_BOOL_NULL; +static uint8_t nullTinyInt = TSDB_DATA_TINYINT_NULL; +static uint16_t nullSmallInt = TSDB_DATA_SMALLINT_NULL; +static uint32_t nullInt = TSDB_DATA_INT_NULL; +static uint64_t nullBigInt = TSDB_DATA_BIGINT_NULL; +static uint32_t nullFloat = TSDB_DATA_FLOAT_NULL; +static uint64_t nullDouble = TSDB_DATA_DOUBLE_NULL; +static uint8_t nullTinyIntu = TSDB_DATA_UTINYINT_NULL; +static uint16_t nullSmallIntu = TSDB_DATA_USMALLINT_NULL; +static uint32_t nullIntu = TSDB_DATA_UINT_NULL; +static uint64_t nullBigIntu = TSDB_DATA_UBIGINT_NULL; static union { tstr str; @@ -436,17 +510,25 @@ static union { } nullBinary = {.str = {.len = 1}}, nullNchar = {.str = {.len = 4}}; static void *nullValues[] = { - &nullBool, &nullTinyInt, &nullSmallInt, &nullInt, &nullBigInt, - &nullFloat, &nullDouble, &nullBinary, &nullBigInt, &nullNchar, + &nullBool, &nullTinyInt, &nullSmallInt, &nullInt, &nullBigInt, + &nullFloat, &nullDouble, &nullBinary, &nullBigInt, &nullNchar, + &nullTinyIntu, &nullSmallIntu, &nullIntu, &nullBigIntu, }; void *getNullValue(int32_t type) { - assert(type >= TSDB_DATA_TYPE_BOOL && type <= TSDB_DATA_TYPE_NCHAR); + assert(type >= TSDB_DATA_TYPE_BOOL && type <= TSDB_DATA_TYPE_UBIGINT); return nullValues[type - 1]; } void assignVal(char *val, const char *src, int32_t len, int32_t type) { switch (type) { + case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_TINYINT: + *((int8_t *)val) = GET_INT8_VAL(src); + break; + case TSDB_DATA_TYPE_SMALLINT: + *((int16_t *)val) = GET_INT16_VAL(src); + break; case TSDB_DATA_TYPE_INT: { *((int32_t *)val) = GET_INT32_VAL(src); break; @@ -457,17 +539,10 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) { case TSDB_DATA_TYPE_DOUBLE: SET_DOUBLE_VAL(val, GET_DOUBLE_VAL(src)); break; - case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_TIMESTAMP: *((int64_t *)val) = GET_INT64_VAL(src); break; - case TSDB_DATA_TYPE_SMALLINT: - *((int16_t *)val) = GET_INT16_VAL(src); - break; - case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: - *((int8_t *)val) = GET_INT8_VAL(src); - break; case TSDB_DATA_TYPE_BINARY: varDataCopy(val, src); break; @@ -483,12 +558,14 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) { void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf) { switch (type) { - case TSDB_DATA_TYPE_INT: { + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: { SWAP(*(int32_t *)(pLeft), *(int32_t *)(pRight), int32_t); break; } case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_TIMESTAMP: { SWAP(*(int64_t *)(pLeft), *(int64_t *)(pRight), int64_t); break; @@ -497,7 +574,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf SWAP(*(double *)(pLeft), *(double *)(pRight), double); break; } - case TSDB_DATA_TYPE_SMALLINT: { + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT: { SWAP(*(int16_t *)(pLeft), *(int16_t *)(pRight), int16_t); break; } @@ -508,7 +586,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf } case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: { + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: { SWAP(*(int8_t *)(pLeft), *(int8_t *)(pRight), int8_t); break; } @@ -521,3 +600,41 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf } } } + +int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bool issigned) { + errno = 0; + int32_t ret = 0; + + char* endPtr = NULL; + if (type == TK_FLOAT) { + double v = strtod(z, &endPtr); + if ((errno == ERANGE && v == HUGE_VALF) || isinf(v) || isnan(v)) { + ret = -1; + } else if ((issigned && (v < INT64_MIN || v > INT64_MAX)) || ((!issigned) && (v < 0 || v > UINT64_MAX))) { + ret = -1; + } else { + *value = (int64_t) round(v); + } + + errno = 0; + return ret; + } + + int32_t radix = 10; + if (type == TK_HEX) { + radix = 16; + } else if (type == TK_BIN) { + radix = 2; + } + + // the string may be overflow according to errno + *value = issigned? strtoll(z, &endPtr, radix):strtoul(z, &endPtr, radix); + + // not a valid integer number, return error + if (endPtr - z != n || errno == ERANGE) { + ret = -1; + } + + errno = 0; + return ret; +} diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index 571ec2e0dd..09c5c76163 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -21,36 +21,48 @@ #include "tstoken.h" #include "ttokendef.h" #include "tutil.h" +#include "ttype.h" -// todo support scientific expression number and oct number -void tVariantCreate(tVariant *pVar, SStrToken *token) { tVariantCreateFromString(pVar, token->z, token->n, token->type); } +void tVariantCreate(tVariant *pVar, SStrToken *token) { + int32_t ret = 0; + int32_t type = token->type; -void tVariantCreateFromString(tVariant *pVar, char *pz, uint32_t len, uint32_t type) { memset(pVar, 0, sizeof(tVariant)); - - switch (type) { + + switch (token->type) { case TSDB_DATA_TYPE_BOOL: { - int32_t k = strncasecmp(pz, "true", 4); + int32_t k = strncasecmp(token->z, "true", 4); if (k == 0) { - pVar->i64Key = TSDB_TRUE; + pVar->i64 = TSDB_TRUE; } else { - assert(strncasecmp(pz, "false", 5) == 0); - pVar->i64Key = TSDB_FALSE; + assert(strncasecmp(token->z, "false", 5) == 0); + pVar->i64 = TSDB_FALSE; } + break; } + case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_BIGINT: - case TSDB_DATA_TYPE_INT: - pVar->i64Key = strtoll(pz, NULL, 10); + case TSDB_DATA_TYPE_INT:{ + ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, true); + if (ret != 0) { + pVar->nType = -1; // -1 means error type + return; + } + break; + } + case TSDB_DATA_TYPE_DOUBLE: - case TSDB_DATA_TYPE_FLOAT: - pVar->dKey = strtod(pz, NULL); + case TSDB_DATA_TYPE_FLOAT: { + pVar->dKey = strtod(token->z, NULL); break; + } + case TSDB_DATA_TYPE_BINARY: { - pVar->pz = strndup(pz, len); + pVar->pz = strndup(token->z, token->n); pVar->nLen = strdequote(pVar->pz); break; } @@ -74,20 +86,36 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 switch (type) { case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: { - pVar->i64Key = GET_INT8_VAL(pz); + pVar->i64 = GET_INT8_VAL(pz); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + pVar->u64 = GET_UINT8_VAL(pz); break; } case TSDB_DATA_TYPE_SMALLINT: { - pVar->i64Key = GET_INT16_VAL(pz); + pVar->i64 = GET_INT16_VAL(pz); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + pVar->u64 = GET_UINT16_VAL(pz); break; } case TSDB_DATA_TYPE_INT: { - pVar->i64Key = GET_INT32_VAL(pz); + pVar->i64 = GET_INT32_VAL(pz); + break; + } + case TSDB_DATA_TYPE_UINT: { + pVar->u64 = GET_UINT32_VAL(pz); break; } case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_TIMESTAMP: { - pVar->i64Key = GET_INT64_VAL(pz); + pVar->i64 = GET_INT64_VAL(pz); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + pVar->u64 = GET_UINT64_VAL(pz); break; } case TSDB_DATA_TYPE_DOUBLE: { @@ -115,7 +143,7 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32 } default: - pVar->i64Key = GET_INT32_VAL(pVar); + pVar->i64 = GET_INT32_VAL(pz); } pVar->nType = type; @@ -141,6 +169,11 @@ void tVariantDestroy(tVariant *pVar) { } } +bool tVariantIsValid(tVariant *pVar) { + assert(pVar != NULL); + return isValidDataType(pVar->nType); +} + void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { if (pSrc == NULL || pDst == NULL) return; @@ -159,8 +192,8 @@ void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { } - if (pSrc->nType >= TSDB_DATA_TYPE_BOOL && pSrc->nType <= TSDB_DATA_TYPE_DOUBLE) { - pDst->i64Key = pSrc->i64Key; + if (IS_NUMERIC_TYPE(pSrc->nType) || (pSrc->nType == TSDB_DATA_TYPE_BOOL)) { + pDst->i64 = pSrc->i64; } else if (pSrc->nType == TSDB_DATA_TYPE_ARRAY) { // this is only for string array size_t num = taosArrayGetSize(pSrc->arr); pDst->arr = taosArrayInit(num, sizeof(char*)); @@ -189,30 +222,30 @@ int32_t tVariantCompare(const tVariant* p1, const tVariant* p2) { return 1; } - switch (p1->nType) { - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: { - if (p1->nLen == p2->nLen) { - return memcmp(p1->pz, p2->pz, p1->nLen); - } else { - return p1->nLen > p2->nLen? 1:-1; - } - }; - - case TSDB_DATA_TYPE_FLOAT: - case TSDB_DATA_TYPE_DOUBLE: - if (p1->dKey == p2->dKey) { - return 0; - } else { - return p1->dKey > p2->dKey? 1:-1; - } - - default: - if (p1->i64Key == p2->i64Key) { - return 0; - } else { - return p1->i64Key > p2->i64Key? 1:-1; - } + if (p1->nType == TSDB_DATA_TYPE_BINARY || p1->nType == TSDB_DATA_TYPE_NCHAR) { + if (p1->nLen == p2->nLen) { + return memcmp(p1->pz, p2->pz, p1->nLen); + } else { + return p1->nLen > p2->nLen? 1:-1; + } + } else if (p1->nType == TSDB_DATA_TYPE_FLOAT || p1->nType == TSDB_DATA_TYPE_DOUBLE) { + if (p1->dKey == p2->dKey) { + return 0; + } else { + return p1->dKey > p2->dKey? 1:-1; + } + } else if (IS_UNSIGNED_NUMERIC_TYPE(p1->nType)) { + if (p1->u64 == p2->u64) { + return 0; + } else { + return p1->u64 > p2->u64? 1:-1; + } + } else { + if (p1->i64 == p2->i64) { + return 0; + } else { + return p1->i64 > p2->i64? 1:-1; + } } } @@ -239,11 +272,15 @@ int32_t tVariantToString(tVariant *pVar, char *dst) { case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_INT: - return sprintf(dst, "%d", (int32_t)pVar->i64Key); + case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_USMALLINT: + case TSDB_DATA_TYPE_UINT: + return sprintf(dst, "%d", (int32_t)pVar->i64); case TSDB_DATA_TYPE_BIGINT: - return sprintf(dst, "%" PRId64, pVar->i64Key); - + return sprintf(dst, "%" PRId64, pVar->i64); + case TSDB_DATA_TYPE_UBIGINT: + return sprintf(dst, "%" PRIu64, pVar->u64); case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_DOUBLE: return sprintf(dst, "%.9lf", pVar->dKey); @@ -253,121 +290,6 @@ int32_t tVariantToString(tVariant *pVar, char *dst) { } } -#if 0 -static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type, bool releaseVariantPtr) { - if (pVariant->nType == TSDB_DATA_TYPE_NULL) { - setNull(pDest, type, tDataTypeDesc[type].nSize); - return 0; - } - - if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - *((int64_t *)pDest) = pVariant->i64Key; - } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { - if ((pVariant->dKey < INT64_MIN) || (pVariant->dKey > INT64_MAX)) { - return -1; - } - - *((int64_t *)pDest) = (int64_t)pVariant->dKey; - } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { - errno = 0; - char *endPtr = NULL; - - SStrToken token = {0}; - token.n = tSQLGetToken(pVariant->pz, &token.type); - - if (token.type == TK_MINUS || token.type == TK_PLUS) { - token.n = tSQLGetToken(pVariant->pz + token.n, &token.type); - } - - if (token.type == TK_FLOAT) { - double v = strtod(pVariant->pz, &endPtr); - if (releaseVariantPtr) { - free(pVariant->pz); - pVariant->nLen = 0; - } - - if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) { - return -1; - } - - if ((v < INT64_MIN) || (v > INT64_MAX)) { - return -1; - } - - *((int64_t *)pDest) = (int64_t)v; - } else if (token.type == TK_INTEGER) { - int64_t val = strtoll(pVariant->pz, &endPtr, 10); - if (releaseVariantPtr) { - free(pVariant->pz); - pVariant->nLen = 0; - } - - if (errno == ERANGE) { - return -1; // data overflow - } - - *((int64_t *)pDest) = val; - } else if (token.type == TK_NULL) { - if (releaseVariantPtr) { - free(pVariant->pz); - pVariant->nLen = 0; - } - setNull(pDest, type, tDataTypeDesc[type].nSize); - } else { - return -1; - } - - } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) { - errno = 0; - wchar_t *endPtr = NULL; - - SStrToken token = {0}; - token.n = tSQLGetToken(pVariant->pz, &token.type); - - if (token.type == TK_MINUS || token.type == TK_PLUS) { - token.n = tSQLGetToken(pVariant->pz + token.n, &token.type); - } - - if (token.type == TK_FLOAT) { - double v = wcstod(pVariant->wpz, &endPtr); - if (releaseVariantPtr) { - free(pVariant->pz); - pVariant->nLen = 0; - } - - if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) { - return -1; - } - - if ((v < INT64_MIN) || (v > INT64_MAX)) { - return -1; - } - - *((int64_t *)pDest) = (int64_t)v; - } else if (token.type == TK_NULL) { - if (releaseVariantPtr) { - free(pVariant->pz); - pVariant->nLen = 0; - } - setNull(pDest, type, tDataTypeDesc[type].nSize); - } else { - int64_t val = wcstoll(pVariant->wpz, &endPtr, 10); - if (releaseVariantPtr) { - free(pVariant->pz); - pVariant->nLen = 0; - } - - if (errno == ERANGE) { - return -1; // data overflow - } - - *((int64_t *)pDest) = val; - } - } - - return 0; -} -#endif static FORCE_INLINE int32_t convertToBoolImpl(char *pStr, int32_t len) { if ((strncasecmp(pStr, "true", len) == 0) && (len == 4)) { return TSDB_TRUE; @@ -385,15 +307,18 @@ static FORCE_INLINE int32_t wcsconvertToBoolImpl(wchar_t *pstr, int32_t len) { return TSDB_TRUE; } else if (wcsncasecmp(pstr, L"false", len) == 0 && (len == 5)) { return TSDB_FALSE; + } else if (memcmp(pstr, L"null", wcslen(L"null")) == 0) { + return TSDB_DATA_BOOL_NULL; } else { return -1; } } static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { - const int32_t INITIAL_ALLOC_SIZE = 20; + const int32_t INITIAL_ALLOC_SIZE = 40; char * pBuf = NULL; - + + // it is a in-place convert type for tVariant, local buffer is needed if (*pDest == pVariant->pz) { pBuf = calloc(1, INITIAL_ALLOC_SIZE); } @@ -413,12 +338,12 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { } } else { - if (pVariant->nType >= TSDB_DATA_TYPE_TINYINT && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - sprintf(pBuf == NULL ? *pDest : pBuf, "%" PRId64, pVariant->i64Key); + if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType)) { + sprintf(pBuf == NULL ? *pDest : pBuf, "%" PRId64, pVariant->i64); } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { sprintf(pBuf == NULL ? *pDest : pBuf, "%lf", pVariant->dKey); } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL) { - sprintf(pBuf == NULL ? *pDest : pBuf, "%s", (pVariant->i64Key == TSDB_TRUE) ? "TRUE" : "FALSE"); + sprintf(pBuf == NULL ? *pDest : pBuf, "%s", (pVariant->i64 == TSDB_TRUE) ? "TRUE" : "FALSE"); } else if (pVariant->nType == 0) { // null data setNull(pBuf == NULL ? *pDest : pBuf, TSDB_DATA_TYPE_BINARY, 0); } @@ -432,28 +357,33 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { return 0; } -// todo handle the error static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { char tmpBuf[40] = {0}; char * pDst = tmpBuf; int32_t nLen = 0; - - if (pVariant->nType >= TSDB_DATA_TYPE_TINYINT && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - nLen = sprintf(pDst, "%" PRId64, pVariant->i64Key); + + // convert the number to string, than convert it to wchar string. + if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType)) { + nLen = sprintf(pDst, "%" PRId64, pVariant->i64); + } else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) { + nLen = sprintf(pDst, "%"PRIu64, pVariant->u64); } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { nLen = sprintf(pDst, "%lf", pVariant->dKey); } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { pDst = pVariant->pz; nLen = pVariant->nLen; } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL) { - nLen = sprintf(pDst, "%s", (pVariant->i64Key == TSDB_TRUE) ? "TRUE" : "FALSE"); + nLen = sprintf(pDst, "%s", (pVariant->i64 == TSDB_TRUE) ? "TRUE" : "FALSE"); } if (*pDest == pVariant->pz) { wchar_t *pWStr = calloc(1, (nLen + 1) * TSDB_NCHAR_SIZE); - taosMbsToUcs4(pDst, nLen, (char *)pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL); - + bool ret = taosMbsToUcs4(pDst, nLen, (char *)pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL); + if (!ret) { + return -1; + } + // free the binary buffer in the first place if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { free(pVariant->wpz); @@ -468,11 +398,15 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { pVariant->wpz = (wchar_t *)tmp; } else { - size_t output = -1; - taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output); - + int32_t output = 0; + + bool ret = taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output); + if (!ret) { + return -1; + } + if (pDestSize != NULL) { - *pDestSize = (int32_t)output; + *pDestSize = output; } } @@ -481,38 +415,31 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { static FORCE_INLINE int32_t convertToDouble(char *pStr, int32_t len, double *value) { SStrToken stoken = {.z = pStr, .n = len}; - - if (TK_ILLEGAL == isValidNumber(&stoken)) { + if (TK_ILLEGAL == tGetNumericStringType(&stoken)) { return -1; } *value = strtod(pStr, NULL); - return 0; } -static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result, int32_t type, int64_t lowBnd, - int64_t upperBnd, bool releaseVariantPtr) { +static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result, int32_t type, bool issigned, bool releaseVariantPtr) { if (pVariant->nType == TSDB_DATA_TYPE_NULL) { setNull((char *)result, type, tDataTypeDesc[type].nSize); return 0; } - - if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - *result = pVariant->i64Key; - } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { - *result = (int64_t)pVariant->dKey; + + errno = 0; + if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType)) { + *result = pVariant->i64; + } else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) { + *result = pVariant->u64; + } else if (IS_FLOAT_TYPE(pVariant->nType)) { + *result = (int64_t) pVariant->dKey; } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { - errno = 0; - char *endPtr = NULL; - - SStrToken token = {0}; - token.n = tSQLGetToken(pVariant->pz, &token.type); - - if (token.type == TK_MINUS || token.type == TK_PLUS) { - token.n = tSQLGetToken(pVariant->pz + token.n, &token.type); - } - + SStrToken token = {.z = pVariant->pz, .n = pVariant->nLen}; + /*int32_t n = */tSQLGetToken(pVariant->pz, &token.type); + if (token.type == TK_NULL) { if (releaseVariantPtr) { free(pVariant->pz); @@ -522,39 +449,25 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result setNull((char *)result, type, tDataTypeDesc[type].nSize); return 0; } - - SStrToken sToken = {.z = pVariant->pz, .n = pVariant->nLen}; - if (TK_ILLEGAL == isValidNumber(&sToken)) { + + // decide if it is a valid number + token.type = tGetNumericStringType(&token); + if (token.type == TK_ILLEGAL) { return -1; } - - if (token.type == TK_FLOAT) { - double v = strtod(pVariant->pz, &endPtr); - if (releaseVariantPtr) { - free(pVariant->pz); - pVariant->nLen = 0; - } - - if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) { - return -1; - } - - *result = (int64_t)v; - } else if (token.type == TK_INTEGER) { - int64_t val = strtoll(pVariant->pz, &endPtr, 10); - if (releaseVariantPtr) { - free(pVariant->pz); - pVariant->nLen = 0; - } - - if (errno == ERANGE) { - return -1; // data overflow - } - - *result = val; - } else { + + int64_t res = 0; + int32_t t = tStrToInteger(token.z, token.type, token.n, &res, issigned); + if (t != 0) { return -1; } + + if (releaseVariantPtr) { + free(pVariant->pz); + pVariant->nLen = 0; + } + + *result = res; } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) { errno = 0; wchar_t *endPtr = NULL; @@ -599,19 +512,35 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result *result = val; } } - - if ((*result <= lowBnd) || (*result > upperBnd)) { - return -1; + + bool code = false; + switch(type) { + case TSDB_DATA_TYPE_TINYINT: + code = IS_VALID_TINYINT(*result); break; + case TSDB_DATA_TYPE_SMALLINT: + code = IS_VALID_SMALLINT(*result); break; + case TSDB_DATA_TYPE_INT: + code = IS_VALID_INT(*result); break; + case TSDB_DATA_TYPE_BIGINT: + code = IS_VALID_BIGINT(*result); break; + case TSDB_DATA_TYPE_UTINYINT: + code = IS_VALID_UTINYINT(*result); break; + case TSDB_DATA_TYPE_USMALLINT: + code = IS_VALID_USMALLINT(*result); break; + case TSDB_DATA_TYPE_UINT: + code = IS_VALID_UINT(*result); break; + case TSDB_DATA_TYPE_UBIGINT: + code = IS_VALID_UBIGINT(*result); break; } - - return 0; + + return code? 0:-1; } static int32_t convertToBool(tVariant *pVariant, int64_t *pDest) { if (pVariant->nType == TSDB_DATA_TYPE_BOOL) { - *pDest = pVariant->i64Key; // in order to be compatible to null of bool - } else if (pVariant->nType >= TSDB_DATA_TYPE_TINYINT && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - *pDest = ((pVariant->i64Key != 0) ? TSDB_TRUE : TSDB_FALSE); + *pDest = pVariant->i64; // in order to be compatible to null of bool + } else if (IS_NUMERIC_TYPE(pVariant->nType)) { + *pDest = ((pVariant->i64 != 0) ? TSDB_TRUE : TSDB_FALSE); } else if (pVariant->nType == TSDB_DATA_TYPE_FLOAT || pVariant->nType == TSDB_DATA_TYPE_DOUBLE) { *pDest = ((pVariant->dKey != 0) ? TSDB_TRUE : TSDB_FALSE); } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { @@ -638,8 +567,6 @@ static int32_t convertToBool(tVariant *pVariant, int64_t *pDest) { /* * transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType * to column type defined in schema - * - * todo handle the return value */ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix) { if (pVariant == NULL || (pVariant->nType != 0 && !isValidDataType(pVariant->nType))) { @@ -647,57 +574,82 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu } errno = 0; // reset global error code - + int64_t result; + switch (type) { case TSDB_DATA_TYPE_BOOL: { - int64_t dst = 0; - if (convertToBool(pVariant, &dst) < 0) { + if (convertToBool(pVariant, &result) < 0) { return -1; } - *(int8_t *)payload = (int8_t)dst; + + *(int8_t *)payload = (int8_t)result; break; } case TSDB_DATA_TYPE_TINYINT: { - int64_t result = 0; - if (convertToInteger(pVariant, &result, type, INT8_MIN, INT8_MAX, false) < 0) { + if (convertToInteger(pVariant, &result, type, true, false) < 0) { return -1; } - - *((int8_t *)payload) = (int8_t)result; + *((int8_t *)payload) = (int8_t) result; + break; + } + + case TSDB_DATA_TYPE_UTINYINT: { + if (convertToInteger(pVariant, &result, type, false, false) < 0) { + return -1; + } + *((uint8_t *)payload) = (uint8_t) result; break; } case TSDB_DATA_TYPE_SMALLINT: { - int64_t result = 0; - if (convertToInteger(pVariant, &result, type, INT16_MIN, INT16_MAX, false) < 0) { + if (convertToInteger(pVariant, &result, type, true, false) < 0) { return -1; } - *((int16_t *)payload) = (int16_t)result; break; } + + case TSDB_DATA_TYPE_USMALLINT: { + if (convertToInteger(pVariant, &result, type, false, false) < 0) { + return -1; + } + *((uint16_t *)payload) = (uint16_t)result; + break; + } case TSDB_DATA_TYPE_INT: { - int64_t result = 0; - if (convertToInteger(pVariant, &result, type, INT32_MIN, INT32_MAX, false) < 0) { + if (convertToInteger(pVariant, &result, type, true, false) < 0) { return -1; } - *((int32_t *)payload) = (int32_t)result; break; } + + case TSDB_DATA_TYPE_UINT: { + if (convertToInteger(pVariant, &result, type, false, false) < 0) { + return -1; + } + *((uint32_t *)payload) = (uint32_t)result; + break; + } case TSDB_DATA_TYPE_BIGINT: { - int64_t result = 0; - if (convertToInteger(pVariant, &result, type, INT64_MIN, INT64_MAX, false) < 0) { + if (convertToInteger(pVariant, &result, type, true, false) < 0) { return -1; } - *((int64_t *)payload) = (int64_t)result; break; } - + + case TSDB_DATA_TYPE_UBIGINT: { + if (convertToInteger(pVariant, &result, type, false, false) < 0) { + return -1; + } + *((uint64_t *)payload) = (uint64_t)result; + break; + } + case TSDB_DATA_TYPE_FLOAT: { if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { if (strncasecmp(TSDB_DATA_NULL_STR_L, pVariant->pz, pVariant->nLen) == 0 && @@ -706,20 +658,19 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu return 0; } else { double value = -1; - int32_t ret; - ret = convertToDouble(pVariant->pz, pVariant->nLen, &value); + int32_t ret = convertToDouble(pVariant->pz, pVariant->nLen, &value); if ((errno == ERANGE && (float)value == -1) || (ret != 0)) { return -1; } SET_FLOAT_VAL(payload, value); } - } else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - SET_FLOAT_VAL(payload, pVariant->i64Key); - } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { + } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(pVariant->nType) || IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) { + SET_FLOAT_VAL(payload, pVariant->i64); + } else if (IS_FLOAT_TYPE(pVariant->nType)) { SET_FLOAT_VAL(payload, pVariant->dKey); } else if (pVariant->nType == TSDB_DATA_TYPE_NULL) { - *((int32_t *)payload) = TSDB_DATA_FLOAT_NULL; + *((uint32_t *)payload) = TSDB_DATA_FLOAT_NULL; return 0; } @@ -745,9 +696,9 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu SET_DOUBLE_VAL(payload, value); } - } else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - SET_DOUBLE_VAL(payload, pVariant->i64Key); - } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { + } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(pVariant->nType) || IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) { + SET_DOUBLE_VAL(payload, pVariant->i64); + } else if (IS_FLOAT_TYPE(pVariant->nType)) { SET_DOUBLE_VAL(payload, pVariant->dKey); } else if (pVariant->nType == TSDB_DATA_TYPE_NULL) { *((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL; @@ -755,9 +706,10 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu } double dv = GET_DOUBLE_VAL(payload); - if (isinf(dv) || isnan(dv) || dv > DBL_MAX || dv < -DBL_MAX) { + if (errno == ERANGE || isinf(dv) || isnan(dv)) { return -1; } + break; } @@ -794,7 +746,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu if (pVariant->nType == TSDB_DATA_TYPE_NULL) { *((int64_t *)payload) = TSDB_DATA_BIGINT_NULL; } else { - *((int64_t *)payload) = pVariant->i64Key; + *((int64_t *)payload) = pVariant->i64; } break; } @@ -805,7 +757,9 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu *(uint32_t *)payload = TSDB_DATA_NCHAR_NULL; } else { if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) { - toNchar(pVariant, &payload, &newlen); + if (toNchar(pVariant, &payload, &newlen) != 0) { + return -1; + } } else { wcsncpy((wchar_t *)payload, pVariant->wpz, pVariant->nLen); } @@ -817,7 +771,9 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu char *p = varDataVal(payload); if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) { - toNchar(pVariant, &p, &newlen); + if (toNchar(pVariant, &p, &newlen) != 0) { + return -1; + } } else { wcsncpy((wchar_t *)p, pVariant->wpz, pVariant->nLen); newlen = pVariant->nLen; @@ -848,7 +804,7 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) { switch (type) { case TSDB_DATA_TYPE_BOOL: { // bool - if (convertToBool(pVariant, &pVariant->i64Key) < 0) { + if (convertToBool(pVariant, &pVariant->i64) < 0) { return -1; } @@ -859,7 +815,7 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) { case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_SMALLINT: { - convertToInteger(pVariant, &(pVariant->i64Key), type, INT64_MIN, INT64_MAX, true); + convertToInteger(pVariant, &(pVariant->i64), type, true, true); pVariant->nType = TSDB_DATA_TYPE_BIGINT; break; } @@ -886,7 +842,7 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) { free(pVariant->pz); pVariant->dKey = v; } else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - pVariant->dKey = (double)(pVariant->i64Key); + pVariant->dKey = (double)(pVariant->i64); } pVariant->nType = TSDB_DATA_TYPE_DOUBLE; @@ -901,7 +857,9 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) { } case TSDB_DATA_TYPE_NCHAR: { if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) { - toNchar(pVariant, &pVariant->pz, &pVariant->nLen); + if (toNchar(pVariant, &pVariant->pz, &pVariant->nLen) != 0) { + return -1; + } } pVariant->nType = type; break; @@ -909,6 +867,4 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) { } return 0; -} - - +} \ No newline at end of file diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt index e289f1ae1b..22d3d31547 100644 --- a/src/connector/jdbc/CMakeLists.txt +++ b/src/connector/jdbc/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) diff --git a/src/connector/odbc/CMakeLists.txt b/src/connector/odbc/CMakeLists.txt index 0d8c07041a..2e1e39ef12 100644 --- a/src/connector/odbc/CMakeLists.txt +++ b/src/connector/odbc/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_LINUX_64) diff --git a/src/connector/odbc/src/CMakeLists.txt b/src/connector/odbc/src/CMakeLists.txt index 2699e1bc90..67357cb469 100644 --- a/src/connector/odbc/src/CMakeLists.txt +++ b/src/connector/odbc/src/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_LINUX_64) diff --git a/src/cq/CMakeLists.txt b/src/cq/CMakeLists.txt index e631397348..9da831c9c1 100644 --- a/src/cq/CMakeLists.txt +++ b/src/cq/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index de76c30e8e..0fe5ea78d4 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -43,7 +43,7 @@ typedef struct { int32_t master; int32_t num; // number of continuous streams char user[TSDB_USER_LEN]; - char pass[TSDB_PASSWORD_LEN]; + char pass[TSDB_KEY_LEN]; char db[TSDB_DB_NAME_LEN]; FCqWrite cqWrite; struct SCqObj *pHead; @@ -295,6 +295,8 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { if (pObj->pStream == NULL) { pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, 0, pObj, NULL); + + // TODO the pObj->pStream may be released if error happens if (pObj->pStream) { tscSetStreamDestTable(pObj->pStream, pObj->dstTable); pContext->num++; @@ -306,11 +308,14 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) { } static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) { - SCqObj *pObj = (SCqObj *)param; + SCqObj *pObj = (SCqObj *)param; if (tres == NULL && row == NULL) { + taos_close_stream(pObj->pStream); + pObj->pStream = NULL; return; } + SCqContext *pContext = pObj->pContext; STSchema *pSchema = pObj->pSchema; if (pObj->pStream == NULL) return; @@ -336,7 +341,7 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) { val = ((char*)val) - sizeof(VarDataLenT); } else if (c->type == TSDB_DATA_TYPE_NCHAR) { char buf[TSDB_MAX_NCHAR_LEN]; - size_t len = taos_fetch_lengths(tres)[i]; + int32_t len = taos_fetch_lengths(tres)[i]; taosMbsToUcs4(val, len, buf, sizeof(buf), &len); memcpy(val + sizeof(VarDataLenT), buf, len); varDataLen(val) = len; diff --git a/src/cq/test/CMakeLists.txt b/src/cq/test/CMakeLists.txt index 59c0ac79cf..87a8705fcd 100644 --- a/src/cq/test/CMakeLists.txt +++ b/src/cq/test/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) LIST(APPEND CQTEST_SRC ./cqtest.c) diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index ebb25bf858..699ca00a25 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index 36232893b5..a4d7e791e6 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -160,7 +160,7 @@ static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) { syslog(LOG_INFO, "Shut down signal is %d", signum); syslog(LOG_INFO, "Shutting down TDengine service..."); // clean the system. - dInfo("shut down signal is %d, sender PID:%d", signum, sigInfo->si_pid); + dInfo("shut down signal is %d, sender PID:%d cmdline:%s", signum, sigInfo->si_pid, taosGetCmdlineByPID(sigInfo->si_pid)); // protect the application from receive another signal struct sigaction act = {{0}}; diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index 775ced0990..ab5a4ccaad 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -202,13 +202,14 @@ static void *dnodeProcessVWriteQueue(void *wparam) { for (int32_t i = 0; i < numOfMsgs; ++i) { taosGetQitem(pWorker->qall, &qtype, (void **)&pWrite); dTrace("msg:%p, app:%p type:%s will be processed in vwrite queue, qtype:%s hver:%" PRIu64, pWrite, - pWrite->rpcMsg.ahandle, taosMsg[pWrite->pHead->msgType], qtypeStr[qtype], pWrite->pHead->version); + pWrite->rpcMsg.ahandle, taosMsg[pWrite->pHead.msgType], qtypeStr[qtype], pWrite->pHead.version); - pWrite->code = vnodeProcessWrite(pVnode, pWrite->pHead, qtype, &pWrite->rspRet); + pWrite->code = vnodeProcessWrite(pVnode, &pWrite->pHead, qtype, pWrite); if (pWrite->code <= 0) pWrite->processedCount = 1; - if (pWrite->code == 0 && pWrite->pHead->msgType != TSDB_MSG_TYPE_SUBMIT) forceFsync = true; + if (pWrite->code > 0) pWrite->code = 0; + if (pWrite->code == 0 && pWrite->pHead.msgType != TSDB_MSG_TYPE_SUBMIT) forceFsync = true; - dTrace("msg:%p is processed in vwrite queue, result:%s", pWrite, tstrerror(pWrite->code)); + dTrace("msg:%p is processed in vwrite queue, code:0x%x", pWrite, pWrite->code); } walFsync(vnodeGetWal(pVnode), forceFsync); @@ -221,7 +222,7 @@ static void *dnodeProcessVWriteQueue(void *wparam) { dnodeSendRpcVWriteRsp(pVnode, pWrite, pWrite->code); } else { if (qtype == TAOS_QTYPE_FWD) { - vnodeConfirmForward(pVnode, pWrite->pHead->version, 0); + vnodeConfirmForward(pVnode, pWrite->pHead.version, 0); } if (pWrite->rspRet.rsp) { rpcFreeCont(pWrite->rspRet.rsp); diff --git a/src/inc/taos.h b/src/inc/taos.h index cd863587a6..5e4f50e31d 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -42,6 +42,10 @@ typedef void **TAOS_ROW; #define TSDB_DATA_TYPE_BINARY 8 // string #define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes #define TSDB_DATA_TYPE_NCHAR 10 // unicode string +#define TSDB_DATA_TYPE_UTINYINT 11 // 1 byte +#define TSDB_DATA_TYPE_USMALLINT 12 // 2 bytes +#define TSDB_DATA_TYPE_UINT 13 // 4 bytes +#define TSDB_DATA_TYPE_UBIGINT 14 // 8 bytes typedef enum { TSDB_OPTION_LOCALE, diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 7f1ed40815..7ccb7db935 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -60,7 +60,7 @@ typedef struct tstr { // Bytes for each type. -extern const int32_t TYPE_BYTES[11]; +extern const int32_t TYPE_BYTES[15]; // TODO: replace and remove code below #define CHAR_BYTES sizeof(char) @@ -92,6 +92,11 @@ extern const int32_t TYPE_BYTES[11]; #define TSDB_DATA_NCHAR_NULL 0xFFFFFFFF #define TSDB_DATA_BINARY_NULL 0xFF +#define TSDB_DATA_UTINYINT_NULL 0xFF +#define TSDB_DATA_USMALLINT_NULL 0xFFFF +#define TSDB_DATA_UINT_NULL 0xFFFFFFFF +#define TSDB_DATA_UBIGINT_NULL 0xFFFFFFFFFFFFFFFFL + #define TSDB_DATA_NULL_STR "NULL" #define TSDB_DATA_NULL_STR_L "null" @@ -131,19 +136,16 @@ do { \ (src) = (void *)((char *)src + sizeof(type));\ } while(0) -#define GET_INT8_VAL(x) (*(int8_t *)(x)) -#define GET_INT16_VAL(x) (*(int16_t *)(x)) -#define GET_INT32_VAL(x) (*(int32_t *)(x)) -#define GET_INT64_VAL(x) (*(int64_t *)(x)) +#define GET_INT8_VAL(x) (*(int8_t *)(x)) +#define GET_INT16_VAL(x) (*(int16_t *)(x)) +#define GET_INT32_VAL(x) (*(int32_t *)(x)) +#define GET_INT64_VAL(x) (*(int64_t *)(x)) +#define GET_UINT8_VAL(x) (*(uint8_t*) (x)) +#define GET_UINT16_VAL(x) (*(uint16_t *)(x)) +#define GET_UINT32_VAL(x) (*(uint32_t *)(x)) +#define GET_UINT64_VAL(x) (*(uint64_t *)(x)) + #ifdef _TD_ARM_32 - - //#define __float_align_declear() float __underlyFloat = 0.0; - //#define __float_align_declear() - //#define GET_FLOAT_VAL_ALIGN(x) (*(int32_t*)&(__underlyFloat) = *(int32_t*)(x); __underlyFloat); - // notes: src must be float or double type variable !!! - //#define SET_FLOAT_VAL_ALIGN(dst, src) (*(int32_t*) dst = *(int32_t*)src); - //#define SET_DOUBLE_VAL_ALIGN(dst, src) (*(int64_t*) dst = *(int64_t*)src); - float taos_align_get_float(const char* pBuf); double taos_align_get_double(const char* pBuf); @@ -171,14 +173,14 @@ typedef struct tDataTypeDescriptor { char algorithm, char *const buffer, int bufferSize); int (*decompFunc)(const char *const input, int compressedSize, const int nelements, char *const output, int outputSize, char algorithm, char *const buffer, int bufferSize); - void (*getStatisFunc)(const TSKEY *primaryKey, const void *pData, int32_t numofrow, int64_t *min, int64_t *max, - int64_t *sum, int16_t *minindex, int16_t *maxindex, int16_t *numofnull); + void (*getStatisFunc)(const void *pData, int32_t numofrow, int64_t *min, int64_t *max, int64_t *sum, + int16_t *minindex, int16_t *maxindex, int16_t *numofnull); } tDataTypeDescriptor; -extern tDataTypeDescriptor tDataTypeDesc[11]; +extern tDataTypeDescriptor tDataTypeDesc[15]; bool isValidDataType(int32_t type); -//bool isNull(const char *val, int32_t type); + static FORCE_INLINE bool isNull(const char *val, int32_t type) { switch (type) { case TSDB_DATA_TYPE_BOOL: @@ -200,6 +202,15 @@ static FORCE_INLINE bool isNull(const char *val, int32_t type) { return varDataLen(val) == sizeof(int32_t) && *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL; case TSDB_DATA_TYPE_BINARY: return varDataLen(val) == sizeof(int8_t) && *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL; + case TSDB_DATA_TYPE_UTINYINT: + return *(uint8_t*) val == TSDB_DATA_UTINYINT_NULL; + case TSDB_DATA_TYPE_USMALLINT: + return *(uint16_t*) val == TSDB_DATA_USMALLINT_NULL; + case TSDB_DATA_TYPE_UINT: + return *(uint32_t*) val == TSDB_DATA_UINT_NULL; + case TSDB_DATA_TYPE_UBIGINT: + return *(uint64_t*) val == TSDB_DATA_UBIGINT_NULL; + default: return false; }; @@ -213,6 +224,10 @@ void* getNullValue(int32_t type); void assignVal(char *val, const char *src, int32_t len, int32_t type); void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf); +int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bool issigned); + +#define SET_DOUBLE_NULL(v) (*(uint64_t *)(v) = TSDB_DATA_DOUBLE_NULL) + // TODO: check if below is necessary #define TSDB_RELATION_INVALID 0 #define TSDB_RELATION_LESS 1 @@ -241,10 +256,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_USER_LEN TSDB_UNI_LEN // ACCOUNT is a 32 bit positive integer -// this is the length of its string representation -// including the terminator zero -#define TSDB_ACCT_LEN 11 -#define TSDB_PASSWORD_LEN TSDB_UNI_LEN +// this is the length of its string representation, including the terminator zero +#define TSDB_ACCT_ID_LEN 11 #define TSDB_MAX_COLUMNS 1024 #define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns @@ -252,7 +265,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_NODE_NAME_LEN 64 #define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string #define TSDB_DB_NAME_LEN 33 -#define TSDB_TABLE_FNAME_LEN (TSDB_ACCT_LEN + TSDB_DB_NAME_LEN + TSDB_TABLE_NAME_LEN) +#define TSDB_TABLE_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_TABLE_NAME_LEN) #define TSDB_COL_NAME_LEN 65 #define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64 #define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE @@ -278,11 +291,6 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_EP_LEN (TSDB_FQDN_LEN+6) #define TSDB_IPv4ADDR_LEN 16 #define TSDB_FILENAME_LEN 128 -#define TSDB_METER_VNODE_BITS 20 -#define TSDB_METER_SID_MASK 0xFFFFF -#define TSDB_SHELL_VNODE_BITS 24 -#define TSDB_SHELL_SID_MASK 0xFF -#define TSDB_HTTP_TOKEN_LEN 20 #define TSDB_SHOW_SQL_LEN 512 #define TSDB_SLOW_QUERY_SQL_LEN 512 @@ -296,9 +304,6 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_MQTT_TOPIC_LEN 64 #define TSDB_MQTT_CLIENT_ID_LEN 32 -#define TSDB_METER_STATE_OFFLINE 0 -#define TSDB_METER_STATE_ONLLINE 1 - #define TSDB_DEFAULT_PKT_SIZE 65480 //same as RPC_MAX_UDP_SIZE #define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE @@ -318,7 +323,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_TBNAME_COLUMN_INDEX (-1) #define TSDB_UD_COLUMN_INDEX (-100) -#define TSDB_MULTI_METERMETA_MAX_NUM 100000 // maximum batch size allowed to load metermeta +#define TSDB_MULTI_TABLEMETA_MAX_NUM 100000 // maximum batch size allowed to load table meta #define TSDB_MIN_CACHE_BLOCK_SIZE 1 #define TSDB_MAX_CACHE_BLOCK_SIZE 128 // 128MB for each vnode @@ -380,6 +385,9 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_MIN_DB_REPLICA_OPTION 1 #define TSDB_MAX_DB_REPLICA_OPTION 3 #define TSDB_DEFAULT_DB_REPLICA_OPTION 1 + +#define TSDB_MIN_DB_QUORUM_OPTION 1 +#define TSDB_MAX_DB_QUORUM_OPTION 2 #define TSDB_DEFAULT_DB_QUORUM_OPTION 1 #define TSDB_MAX_JOIN_TABLE_NUM 5 @@ -436,7 +444,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_PORT_HTTP 11 #define TSDB_PORT_ARBITRATOR 12 -#define TSDB_MAX_WAL_SIZE (1024*1024*2) +#define TSDB_MAX_WAL_SIZE (1024*1024*3) typedef enum { TAOS_QTYPE_RPC = 0, diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index ed88bc15ee..b6cf1b5f1f 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -180,6 +180,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, 0, 0x036A, "Tag does n TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_ALREAY_EXIST, 0, 0x036B, "Field already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_NOT_EXIST, 0, 0x036C, "Field does not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STABLE_NAME, 0, 0x036D, "Super table does not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG, 0, 0x036E, "Invalid create table message") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_NOT_SELECTED, 0, 0x0380, "Database not specified or available") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_ALREADY_EXIST, 0, 0x0381, "Database already exists") diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 2dee6dc3bb..905867fbc7 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -268,7 +268,7 @@ typedef struct { typedef struct { int32_t len; // one create table message char tableId[TSDB_TABLE_FNAME_LEN]; - char db[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN]; + char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; int8_t igExists; int8_t getMeta; int16_t numOfTags; @@ -290,7 +290,7 @@ typedef struct { typedef struct { char tableId[TSDB_TABLE_FNAME_LEN]; - char db[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN]; + char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; int16_t type; /* operation type */ int16_t numOfCols; /* number of schema */ int32_t tagValLen; @@ -322,7 +322,7 @@ typedef struct { } SConnectMsg; typedef struct { - char acctId[TSDB_ACCT_LEN]; + char acctId[TSDB_ACCT_ID_LEN]; char serverVersion[TSDB_VERSION_LEN]; char clusterId[TSDB_CLUSTER_ID_LEN]; int8_t writeAuth; @@ -534,7 +534,7 @@ typedef struct { } SVnodeLoad; typedef struct { - char db[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN]; + char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; int32_t cacheBlockSize; //MB int32_t totalBlocks; int32_t maxTables; @@ -682,7 +682,7 @@ typedef struct { } SVnodeDesc; typedef struct { - char db[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN]; + char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; SVnodeCfg cfg; SVnodeDesc nodes[TSDB_MAX_REPLICA]; } SCreateVnodeMsg, SAlterVnodeMsg; @@ -761,7 +761,7 @@ typedef struct { */ typedef struct { int8_t type; - char db[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN]; + char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; uint16_t payloadLen; char payload[]; } SShowMsg; diff --git a/src/inc/tcq.h b/src/inc/tcq.h index ad123d4080..1941649d0a 100644 --- a/src/inc/tcq.h +++ b/src/inc/tcq.h @@ -26,7 +26,7 @@ typedef int32_t (*FCqWrite)(int32_t vgId, void *pHead, int32_t qtype, void *pMsg typedef struct { int32_t vgId; char user[TSDB_USER_LEN]; - char pass[TSDB_PASSWORD_LEN]; + char pass[TSDB_KEY_LEN]; char db[TSDB_DB_NAME_LEN]; FCqWrite cqWrite; } SCqCfg; diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index 7bd7b228cb..09500fc8c5 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -117,112 +117,114 @@ #define TK_CACHELAST 99 #define TK_LP 100 #define TK_RP 101 -#define TK_TAGS 102 -#define TK_USING 103 -#define TK_AS 104 -#define TK_COMMA 105 -#define TK_NULL 106 -#define TK_SELECT 107 -#define TK_UNION 108 -#define TK_ALL 109 -#define TK_FROM 110 -#define TK_VARIABLE 111 -#define TK_INTERVAL 112 -#define TK_FILL 113 -#define TK_SLIDING 114 -#define TK_ORDER 115 -#define TK_BY 116 -#define TK_ASC 117 -#define TK_DESC 118 -#define TK_GROUP 119 -#define TK_HAVING 120 -#define TK_LIMIT 121 -#define TK_OFFSET 122 -#define TK_SLIMIT 123 -#define TK_SOFFSET 124 -#define TK_WHERE 125 -#define TK_NOW 126 -#define TK_RESET 127 -#define TK_QUERY 128 -#define TK_ADD 129 -#define TK_COLUMN 130 -#define TK_TAG 131 -#define TK_CHANGE 132 -#define TK_SET 133 -#define TK_KILL 134 -#define TK_CONNECTION 135 -#define TK_STREAM 136 -#define TK_COLON 137 -#define TK_ABORT 138 -#define TK_AFTER 139 -#define TK_ATTACH 140 -#define TK_BEFORE 141 -#define TK_BEGIN 142 -#define TK_CASCADE 143 -#define TK_CLUSTER 144 -#define TK_CONFLICT 145 -#define TK_COPY 146 -#define TK_DEFERRED 147 -#define TK_DELIMITERS 148 -#define TK_DETACH 149 -#define TK_EACH 150 -#define TK_END 151 -#define TK_EXPLAIN 152 -#define TK_FAIL 153 -#define TK_FOR 154 -#define TK_IGNORE 155 -#define TK_IMMEDIATE 156 -#define TK_INITIALLY 157 -#define TK_INSTEAD 158 -#define TK_MATCH 159 -#define TK_KEY 160 -#define TK_OF 161 -#define TK_RAISE 162 -#define TK_REPLACE 163 -#define TK_RESTRICT 164 -#define TK_ROW 165 -#define TK_STATEMENT 166 -#define TK_TRIGGER 167 -#define TK_VIEW 168 -#define TK_COUNT 169 -#define TK_SUM 170 -#define TK_AVG 171 -#define TK_MIN 172 -#define TK_MAX 173 -#define TK_FIRST 174 -#define TK_LAST 175 -#define TK_TOP 176 -#define TK_BOTTOM 177 -#define TK_STDDEV 178 -#define TK_PERCENTILE 179 -#define TK_APERCENTILE 180 -#define TK_LEASTSQUARES 181 -#define TK_HISTOGRAM 182 -#define TK_DIFF 183 -#define TK_SPREAD 184 -#define TK_TWA 185 -#define TK_INTERP 186 -#define TK_LAST_ROW 187 -#define TK_RATE 188 -#define TK_IRATE 189 -#define TK_SUM_RATE 190 -#define TK_SUM_IRATE 191 -#define TK_AVG_RATE 192 -#define TK_AVG_IRATE 193 -#define TK_TBID 194 -#define TK_SEMI 195 -#define TK_NONE 196 -#define TK_PREV 197 -#define TK_LINEAR 198 -#define TK_IMPORT 199 -#define TK_METRIC 200 -#define TK_TBNAME 201 -#define TK_JOIN 202 -#define TK_METRICS 203 -#define TK_STABLE 204 -#define TK_INSERT 205 -#define TK_INTO 206 -#define TK_VALUES 207 +#define TK_UNSIGNED 102 +#define TK_TAGS 103 +#define TK_USING 104 +#define TK_AS 105 +#define TK_COMMA 106 +#define TK_NULL 107 +#define TK_SELECT 108 +#define TK_UNION 109 +#define TK_ALL 110 +#define TK_FROM 111 +#define TK_VARIABLE 112 +#define TK_INTERVAL 113 +#define TK_FILL 114 +#define TK_SLIDING 115 +#define TK_ORDER 116 +#define TK_BY 117 +#define TK_ASC 118 +#define TK_DESC 119 +#define TK_GROUP 120 +#define TK_HAVING 121 +#define TK_LIMIT 122 +#define TK_OFFSET 123 +#define TK_SLIMIT 124 +#define TK_SOFFSET 125 +#define TK_WHERE 126 +#define TK_NOW 127 +#define TK_RESET 128 +#define TK_QUERY 129 +#define TK_ADD 130 +#define TK_COLUMN 131 +#define TK_TAG 132 +#define TK_CHANGE 133 +#define TK_SET 134 +#define TK_KILL 135 +#define TK_CONNECTION 136 +#define TK_STREAM 137 +#define TK_COLON 138 +#define TK_ABORT 139 +#define TK_AFTER 140 +#define TK_ATTACH 141 +#define TK_BEFORE 142 +#define TK_BEGIN 143 +#define TK_CASCADE 144 +#define TK_CLUSTER 145 +#define TK_CONFLICT 146 +#define TK_COPY 147 +#define TK_DEFERRED 148 +#define TK_DELIMITERS 149 +#define TK_DETACH 150 +#define TK_EACH 151 +#define TK_END 152 +#define TK_EXPLAIN 153 +#define TK_FAIL 154 +#define TK_FOR 155 +#define TK_IGNORE 156 +#define TK_IMMEDIATE 157 +#define TK_INITIALLY 158 +#define TK_INSTEAD 159 +#define TK_MATCH 160 +#define TK_KEY 161 +#define TK_OF 162 +#define TK_RAISE 163 +#define TK_REPLACE 164 +#define TK_RESTRICT 165 +#define TK_ROW 166 +#define TK_STATEMENT 167 +#define TK_TRIGGER 168 +#define TK_VIEW 169 +#define TK_COUNT 170 +#define TK_SUM 171 +#define TK_AVG 172 +#define TK_MIN 173 +#define TK_MAX 174 +#define TK_FIRST 175 +#define TK_LAST 176 +#define TK_TOP 177 +#define TK_BOTTOM 178 +#define TK_STDDEV 179 +#define TK_PERCENTILE 180 +#define TK_APERCENTILE 181 +#define TK_LEASTSQUARES 182 +#define TK_HISTOGRAM 183 +#define TK_DIFF 184 +#define TK_SPREAD 185 +#define TK_TWA 186 +#define TK_INTERP 187 +#define TK_LAST_ROW 188 +#define TK_RATE 189 +#define TK_IRATE 190 +#define TK_SUM_RATE 191 +#define TK_SUM_IRATE 192 +#define TK_AVG_RATE 193 +#define TK_AVG_IRATE 194 +#define TK_TBID 195 +#define TK_SEMI 196 +#define TK_NONE 197 +#define TK_PREV 198 +#define TK_LINEAR 199 +#define TK_IMPORT 200 +#define TK_METRIC 201 +#define TK_TBNAME 202 +#define TK_JOIN 203 +#define TK_METRICS 204 +#define TK_STABLE 205 +#define TK_INSERT 206 +#define TK_INTO 207 +#define TK_VALUES 208 + #define TK_SPACE 300 diff --git a/src/inc/ttype.h b/src/inc/ttype.h index 7f6a8d65e7..1849139df1 100644 --- a/src/inc/ttype.h +++ b/src/inc/ttype.h @@ -8,27 +8,56 @@ extern "C" { #include "taosdef.h" #define GET_TYPED_DATA(_v, _finalType, _type, _data) \ - switch (_type) { \ - case TSDB_DATA_TYPE_BOOL: \ - case TSDB_DATA_TYPE_TINYINT: \ - (_v) = (_finalType)GET_INT8_VAL(_data); \ - break; \ - case TSDB_DATA_TYPE_SMALLINT: \ - (_v) = (_finalType)GET_INT16_VAL(_data); \ - break; \ - case TSDB_DATA_TYPE_BIGINT: \ - (_v) = (_finalType)(GET_INT64_VAL(_data)); \ - break; \ - case TSDB_DATA_TYPE_FLOAT: \ - (_v) = (_finalType)GET_FLOAT_VAL(_data); \ - break; \ - case TSDB_DATA_TYPE_DOUBLE: \ - (_v) = (_finalType)GET_DOUBLE_VAL(_data); \ - break; \ - default: \ - (_v) = (_finalType)GET_INT32_VAL(_data); \ - break; \ - } + do { \ + switch (_type) { \ + case TSDB_DATA_TYPE_BOOL: \ + case TSDB_DATA_TYPE_TINYINT: \ + (_v) = (_finalType)GET_INT8_VAL(_data); \ + break; \ + case TSDB_DATA_TYPE_UTINYINT: \ + (_v) = (_finalType)GET_UINT8_VAL(_data); \ + break; \ + case TSDB_DATA_TYPE_SMALLINT: \ + (_v) = (_finalType)GET_INT16_VAL(_data); \ + break; \ + case TSDB_DATA_TYPE_USMALLINT: \ + (_v) = (_finalType)GET_UINT16_VAL(_data); \ + break; \ + case TSDB_DATA_TYPE_BIGINT: \ + (_v) = (_finalType)(GET_INT64_VAL(_data)); \ + break; \ + case TSDB_DATA_TYPE_UBIGINT: \ + (_v) = (_finalType)(GET_UINT64_VAL(_data)); \ + break; \ + case TSDB_DATA_TYPE_FLOAT: \ + (_v) = (_finalType)GET_FLOAT_VAL(_data); \ + break; \ + case TSDB_DATA_TYPE_DOUBLE: \ + (_v) = (_finalType)GET_DOUBLE_VAL(_data); \ + break; \ + case TSDB_DATA_TYPE_UINT: \ + (_v) = (_finalType)GET_UINT32_VAL(_data); \ + break; \ + default: \ + (_v) = (_finalType)GET_INT32_VAL(_data); \ + break; \ + } \ + } while (0) + +#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT) +#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT) +#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE) + +#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t))) + +#define IS_VALID_TINYINT(_t) ((_t) > INT8_MIN && (_t) <= INT8_MAX) +#define IS_VALID_SMALLINT(_t) ((_t) > INT16_MIN && (_t) <= INT16_MAX) +#define IS_VALID_INT(_t) ((_t) > INT32_MIN && (_t) <= INT32_MAX) +#define IS_VALID_BIGINT(_t) ((_t) > INT64_MIN && (_t) <= INT64_MAX) +#define IS_VALID_UTINYINT(_t) ((_t) >= 0 && (_t) < UINT8_MAX) +#define IS_VALID_USMALLINT(_t) ((_t) >= 0 && (_t) < UINT16_MAX) +#define IS_VALID_UINT(_t) ((_t) >= 0 && (_t) < UINT32_MAX) +#define IS_VALID_UBIGINT(_t) ((_t) >= 0 && (_t) < UINT64_MAX) #ifdef __cplusplus } diff --git a/src/inc/vnode.h b/src/inc/vnode.h index cbe64484b1..7c9ebd8a0b 100644 --- a/src/inc/vnode.h +++ b/src/inc/vnode.h @@ -49,7 +49,7 @@ typedef struct { SRpcMsg rpcMsg; SRspRet rspRet; char reserveForSync[24]; - SWalHead pHead[]; + SWalHead pHead; } SVWriteMsg; // vnodeStatus diff --git a/src/kit/CMakeLists.txt b/src/kit/CMakeLists.txt index bf52784300..bf77d856f9 100644 --- a/src/kit/CMakeLists.txt +++ b/src/kit/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) ADD_SUBDIRECTORY(shell) diff --git a/src/kit/shell/CMakeLists.txt b/src/kit/shell/CMakeLists.txt index c86cac281c..45da99e572 100644 --- a/src/kit/shell/CMakeLists.txt +++ b/src/kit/shell/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index fca0e93472..a986f2d3cb 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -603,15 +603,27 @@ static void printField(const char* val, TAOS_FIELD* field, int width, int32_t le case TSDB_DATA_TYPE_TINYINT: printf("%*d", width, *((int8_t *)val)); break; + case TSDB_DATA_TYPE_UTINYINT: + printf("%*u", width, *((uint8_t *)val)); + break; case TSDB_DATA_TYPE_SMALLINT: printf("%*d", width, *((int16_t *)val)); break; + case TSDB_DATA_TYPE_USMALLINT: + printf("%*u", width, *((uint16_t *)val)); + break; case TSDB_DATA_TYPE_INT: printf("%*d", width, *((int32_t *)val)); break; + case TSDB_DATA_TYPE_UINT: + printf("%*u", width, *((uint32_t *)val)); + break; case TSDB_DATA_TYPE_BIGINT: printf("%*" PRId64, width, *((int64_t *)val)); break; + case TSDB_DATA_TYPE_UBIGINT: + printf("%*" PRIu64, width, *((uint64_t *)val)); + break; case TSDB_DATA_TYPE_FLOAT: printf("%*.5f", width, GET_FLOAT_VAL(val)); break; @@ -679,15 +691,19 @@ static int calcColWidth(TAOS_FIELD* field, int precision) { return MAX(5, width); // 'false' case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT: return MAX(4, width); // '-127' case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT: return MAX(6, width); // '-32767' case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: return MAX(11, width); // '-2147483648' case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: return MAX(21, width); // '-9223372036854775807' case TSDB_DATA_TYPE_FLOAT: diff --git a/src/kit/taosdemo/CMakeLists.txt b/src/kit/taosdemo/CMakeLists.txt index ab02bdb64d..91c743939c 100644 --- a/src/kit/taosdemo/CMakeLists.txt +++ b/src/kit/taosdemo/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) diff --git a/src/kit/taosdemox/CMakeLists.txt b/src/kit/taosdemox/CMakeLists.txt index 3f5e725aea..7db6c04b28 100644 --- a/src/kit/taosdemox/CMakeLists.txt +++ b/src/kit/taosdemox/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) diff --git a/src/kit/taosdemox/insert.json b/src/kit/taosdemox/insert.json index 88416c13a4..aa071c115d 100644 --- a/src/kit/taosdemox/insert.json +++ b/src/kit/taosdemox/insert.json @@ -5,7 +5,8 @@ "port": 6030, "user": "root", "password": "taosdata", - "thread_count": 2, + "thread_count": 4, + "thread_count_create_tbl": 1, "result_file": "./insert_res.txt", "databases": [{ "dbinfo": { diff --git a/src/kit/taosdemox/subscribe.json b/src/kit/taosdemox/subscribe.json index 6dfacdd6ed..f70b1213a8 100644 --- a/src/kit/taosdemox/subscribe.json +++ b/src/kit/taosdemox/subscribe.json @@ -5,13 +5,13 @@ "port": 6030, "user": "root", "password": "taosdata", - "databases": "db01", - "super_table_query": + "databases": "db", + "specified_table_query": {"concurrent":1, "mode":"sync", "interval":5000, "restart":"yes", "keepProgress":"yes", - "sqls": [{"sql": "select avg(c1) from stb01 where col1 > 1;", "result": "./subscribe_res0.txt"}] + "sqls": [{"sql": "select avg(col1) from stb01 where col1 > 1;", "result": "./subscribe_res0.txt"}] }, - "sub_table_query": - {"stblname": "stb01", "threads":1, "mode":"sync", "interval":10000, "restart":"yes", "keepProgress":"yes", - "sqls": [{"sql": "select col1 from xxxx where col1 > 10;", "result": "./subscribe_res1.txt"}] - } + "super_table_query": + {"stblname": "stb", "threads":1, "mode":"sync", "interval":10000, "restart":"yes", "keepProgress":"yes", + "sqls": [{"sql": "select col1 from xxxx where col1 > 10;", "result": "./subscribe_res1.txt"}] + } } diff --git a/src/kit/taosdemox/taosdemox.c b/src/kit/taosdemox/taosdemox.c index 97e7b42667..5c187030c5 100644 --- a/src/kit/taosdemox/taosdemox.c +++ b/src/kit/taosdemox/taosdemox.c @@ -93,9 +93,6 @@ extern char configDir[]; #define MAX_QUERY_SQL_COUNT 10 #define MAX_QUERY_SQL_LENGTH 256 - -#define MAX_LINE_COUNT_IN_MEM 10000 - typedef enum CREATE_SUB_TALBE_MOD_EN { PRE_CREATE_SUBTBL, AUTO_CREATE_SUBTBL, @@ -259,6 +256,7 @@ typedef struct SDbs_S { bool queryMode; int threadCount; + int threadCountByCreateTbl; int dbCount; SDataBase db[MAX_DB_COUNT]; @@ -1418,7 +1416,6 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName, char* sTblName char command[BUFFER_SIZE] = "\0"; TAOS_RES * res; TAOS_ROW row = NULL; - int count = 0; char* childTblName = *childTblNameOfSuperTbl; @@ -1433,12 +1430,13 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName, char* sTblName exit(-1); } - int childTblCount = 10000; - count = 0; + int childTblCount = 10000; + int count = 0; childTblName = (char*)calloc(1, childTblCount * TSDB_TABLE_NAME_LEN); char* pTblName = childTblName; while ((row = taos_fetch_row(res)) != NULL) { - strncpy(pTblName, (char *)row[0], TSDB_TABLE_NAME_LEN); + int32_t* len = taos_fetch_lengths(res); + strncpy(pTblName, (char *)row[0], len[0]); //printf("==== sub table name: %s\n", pTblName); count++; if (count >= childTblCount - 1) { @@ -1829,38 +1827,64 @@ static void createChildTables() { if ((AUTO_CREATE_SUBTBL == g_Dbs.db[i].superTbls[j].autoCreateTable) || (TBL_ALREADY_EXISTS == g_Dbs.db[i].superTbls[j].childTblExists)) { continue; } - startMultiThreadCreateChildTable(g_Dbs.db[i].superTbls[j].colsOfCreatChildTable, g_Dbs.threadCount, g_Dbs.db[i].superTbls[j].childTblCount, g_Dbs.db[i].dbName, &(g_Dbs.db[i].superTbls[j])); + startMultiThreadCreateChildTable(g_Dbs.db[i].superTbls[j].colsOfCreatChildTable, g_Dbs.threadCountByCreateTbl, g_Dbs.db[i].superTbls[j].childTblCount, g_Dbs.db[i].dbName, &(g_Dbs.db[i].superTbls[j])); g_totalChildTables += g_Dbs.db[i].superTbls[j].childTblCount; } } } +/* +static int taosGetLineNum(const char *fileName) +{ + int lineNum = 0; + char cmd[1024] = { 0 }; + char buf[1024] = { 0 }; + sprintf(cmd, "wc -l %s", fileName); + + FILE *fp = popen(cmd, "r"); + if (fp == NULL) { + fprintf(stderr, "ERROR: failed to execute:%s, error:%s\n", cmd, strerror(errno)); + return lineNum; + } + + if (fgets(buf, sizeof(buf), fp)) { + int index = strchr((const char*)buf, ' ') - buf; + buf[index] = '\0'; + lineNum = atoi(buf); + } + pclose(fp); + return lineNum; +} +*/ + /* Read 10000 lines at most. If more than 10000 lines, continue to read after using */ -int readTagFromCsvFileToMem(SSuperTable * supterTblInfo) { +int readTagFromCsvFileToMem(SSuperTable * superTblInfo) { size_t n = 0; ssize_t readLen = 0; char * line = NULL; - FILE *fp = fopen(supterTblInfo->tagsFile, "r"); + FILE *fp = fopen(superTblInfo->tagsFile, "r"); if (fp == NULL) { - printf("Failed to open tags file: %s, reason:%s\n", supterTblInfo->tagsFile, strerror(errno)); + printf("Failed to open tags file: %s, reason:%s\n", superTblInfo->tagsFile, strerror(errno)); return -1; } - if (supterTblInfo->tagDataBuf) { - free(supterTblInfo->tagDataBuf); - supterTblInfo->tagDataBuf = NULL; + if (superTblInfo->tagDataBuf) { + free(superTblInfo->tagDataBuf); + superTblInfo->tagDataBuf = NULL; } - - supterTblInfo->tagDataBuf = calloc(supterTblInfo->lenOfTagOfOneRow * MAX_LINE_COUNT_IN_MEM, 1); - if (supterTblInfo->tagDataBuf == NULL) { + + int tagCount = 10000; + int count = 0; + char* tagDataBuf = calloc(1, superTblInfo->lenOfTagOfOneRow * tagCount); + if (tagDataBuf == NULL) { printf("Failed to calloc, reason:%s\n", strerror(errno)); fclose(fp); return -1; } - + while ((readLen = getline(&line, &n, fp)) != -1) { if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) { line[--readLen] = 0; @@ -1870,20 +1894,35 @@ int readTagFromCsvFileToMem(SSuperTable * supterTblInfo) { continue; } - memcpy(supterTblInfo->tagDataBuf + supterTblInfo->tagSampleCount * supterTblInfo->lenOfTagOfOneRow, line, readLen); - supterTblInfo->tagSampleCount++; + memcpy(tagDataBuf + count * superTblInfo->lenOfTagOfOneRow, line, readLen); + count++; - if (supterTblInfo->tagSampleCount >= MAX_LINE_COUNT_IN_MEM) { - break; + if (count >= tagCount - 1) { + char *tmp = realloc(tagDataBuf, (size_t)tagCount*1.5*superTblInfo->lenOfTagOfOneRow); + if (tmp != NULL) { + tagDataBuf = tmp; + tagCount = (int)(tagCount*1.5); + memset(tagDataBuf + count*superTblInfo->lenOfTagOfOneRow, 0, (size_t)((tagCount-count)*superTblInfo->lenOfTagOfOneRow)); + } else { + // exit, if allocate more memory failed + printf("realloc fail for save tag val from %s\n", superTblInfo->tagsFile); + tmfree(tagDataBuf); + free(line); + fclose(fp); + return -1; + } } } + superTblInfo->tagDataBuf = tagDataBuf; + superTblInfo->tagSampleCount = count; + free(line); fclose(fp); return 0; } -int readSampleFromJsonFileToMem(SSuperTable * supterTblInfo) { +int readSampleFromJsonFileToMem(SSuperTable * superTblInfo) { // TODO return 0; } @@ -2138,6 +2177,16 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { printf("failed to read json, threads not found"); goto PARSE_OVER; } + + cJSON* threads2 = cJSON_GetObjectItem(root, "thread_count_create_tbl"); + if (threads2 && threads2->type == cJSON_Number) { + g_Dbs.threadCountByCreateTbl = threads2->valueint; + } else if (!threads2) { + g_Dbs.threadCountByCreateTbl = 1; + } else { + printf("failed to read json, threads2 not found"); + goto PARSE_OVER; + } cJSON* dbs = cJSON_GetObjectItem(root, "databases"); if (!dbs || dbs->type != cJSON_Array) { @@ -3008,6 +3057,10 @@ void postFreeResource() { free(g_Dbs.db[i].superTbls[j].sampleDataBuf); g_Dbs.db[i].superTbls[j].sampleDataBuf = NULL; } + if (0 != g_Dbs.db[i].superTbls[j].tagDataBuf) { + free(g_Dbs.db[i].superTbls[j].tagDataBuf); + g_Dbs.db[i].superTbls[j].tagDataBuf = NULL; + } if (0 != g_Dbs.db[i].superTbls[j].childTblName) { free(g_Dbs.db[i].superTbls[j].childTblName); g_Dbs.db[i].superTbls[j].childTblName = NULL; @@ -4216,23 +4269,24 @@ void *subSubscribeProcess(void *sarg) { } while (0); // start loop to consume result + TAOS_RES* res = NULL; while (1) { for (int i = 0; i < g_queryInfo.subQueryInfo.sqlCount; i++) { if (1 == g_queryInfo.subQueryInfo.subscribeMode) { continue; } - TAOS_RES* res = taos_consume(g_queryInfo.subQueryInfo.tsub[i]); + res = taos_consume(g_queryInfo.subQueryInfo.tsub[i]); if (res) { char tmpFile[MAX_FILE_NAME_LEN*2] = {0}; if (g_queryInfo.subQueryInfo.result[i][0] != 0) { sprintf(tmpFile, "%s-%d", g_queryInfo.subQueryInfo.result[i], winfo->threadID); } getResult(res, tmpFile); - taos_free_result(res); } } } + taos_free_result(res); for (int i = 0; i < g_queryInfo.subQueryInfo.sqlCount; i++) { taos_unsubscribe(g_queryInfo.subQueryInfo.tsub[i], g_queryInfo.subQueryInfo.subscribeKeepProgress); @@ -4275,23 +4329,24 @@ void *superSubscribeProcess(void *sarg) { } while (0); // start loop to consume result + TAOS_RES* res = NULL; while (1) { for (int i = 0; i < g_queryInfo.superQueryInfo.sqlCount; i++) { if (1 == g_queryInfo.superQueryInfo.subscribeMode) { continue; } - TAOS_RES* res = taos_consume(g_queryInfo.superQueryInfo.tsub[i]); + res = taos_consume(g_queryInfo.superQueryInfo.tsub[i]); if (res) { char tmpFile[MAX_FILE_NAME_LEN*2] = {0}; if (g_queryInfo.superQueryInfo.result[i][0] != 0) { sprintf(tmpFile, "%s-%d", g_queryInfo.superQueryInfo.result[i], winfo->threadID); } getResult(res, tmpFile); - taos_free_result(res); } } } + taos_free_result(res); for (int i = 0; i < g_queryInfo.superQueryInfo.sqlCount; i++) { taos_unsubscribe(g_queryInfo.superQueryInfo.tsub[i], g_queryInfo.superQueryInfo.subscribeKeepProgress); diff --git a/src/kit/taosdump/CMakeLists.txt b/src/kit/taosdump/CMakeLists.txt index dcdbd48615..dc9ac6d4a7 100644 --- a/src/kit/taosdump/CMakeLists.txt +++ b/src/kit/taosdump/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) diff --git a/src/mnode/CMakeLists.txt b/src/mnode/CMakeLists.txt index ff5c9335b6..4123098694 100644 --- a/src/mnode/CMakeLists.txt +++ b/src/mnode/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_LINUX) diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index a07607e615..5eeac97209 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -138,7 +138,7 @@ typedef struct SVgObj { int64_t createdTime; int32_t lbDnodeId; int32_t lbTime; - char dbName[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN]; + char dbName[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; int8_t inUse; int8_t accessState; int8_t status; @@ -179,7 +179,7 @@ typedef struct { } SDbCfg; typedef struct SDbObj { - char name[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN]; + char name[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; int8_t reserved0[4]; char acct[TSDB_USER_LEN]; int64_t createdTime; @@ -259,7 +259,7 @@ typedef struct { int16_t bytes[TSDB_MAX_COLUMNS]; int32_t numOfReads; int8_t maxReplica; - int8_t reserved0[0]; + int8_t reserved0[1]; uint16_t payloadLen; char payload[]; } SShowObj; diff --git a/src/mnode/inc/mnodeSdb.h b/src/mnode/inc/mnodeSdb.h index e4df562d81..e4e4a7a054 100644 --- a/src/mnode/inc/mnodeSdb.h +++ b/src/mnode/inc/mnodeSdb.h @@ -60,7 +60,7 @@ typedef struct SSdbRow { int32_t (*fpReq)(SMnodeMsg *pMsg); int32_t (*fpRsp)(SMnodeMsg *pMsg, int32_t code); char reserveForSync[24]; - SWalHead pHead[]; + SWalHead pHead; } SSdbRow; typedef struct { diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 8a03b1cd0e..fbcad151bc 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -316,9 +316,14 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) { return TSDB_CODE_MND_INVALID_DB_OPTION; } - if (pCfg->quorum < TSDB_MIN_DB_REPLICA_OPTION || pCfg->quorum > TSDB_MAX_DB_REPLICA_OPTION) { - mError("invalid db option quorum:%d valid range: [%d, %d]", pCfg->quorum, TSDB_MIN_DB_REPLICA_OPTION, - TSDB_MAX_DB_REPLICA_OPTION); + if (pCfg->quorum > pCfg->replications) { + mError("invalid db option quorum:%d larger than replica:%d", pCfg->quorum, pCfg->replications); + return TSDB_CODE_MND_INVALID_DB_OPTION; + } + + if (pCfg->quorum < TSDB_MIN_DB_QUORUM_OPTION || pCfg->quorum > TSDB_MAX_DB_QUORUM_OPTION) { + mError("invalid db option quorum:%d valid range: [%d, %d]", pCfg->quorum, TSDB_MIN_DB_QUORUM_OPTION, + TSDB_MAX_DB_QUORUM_OPTION); return TSDB_CODE_MND_INVALID_DB_OPTION; } diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index 14d1fa5816..792e41dd5b 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -810,6 +810,10 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC } pShow->numOfRows = mnodeGetDnodesNum(); + if (tsArbitrator[0] != 0) { + pShow->numOfRows++; + } + pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; pShow->pIter = NULL; @@ -821,7 +825,7 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn) { int32_t numOfRows = 0; int32_t cols = 0; - SDnodeObj *pDnode = NULL; + SDnodeObj *pDnode = NULL; char *pWrite; while (numOfRows < rows) { @@ -864,10 +868,49 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo STR_TO_VARSTR(pWrite, offlineReason[pDnode->offlineReason]); cols++; - numOfRows++; + numOfRows++; mnodeDecDnodeRef(pDnode); } + if (tsArbitrator[0] != 0) { + cols = 0; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int16_t *)pWrite = 0; + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_WITH_MAXSIZE_TO_VARSTR(pWrite, tsArbitrator, pShow->bytes[cols]); + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int16_t *)pWrite = 0; + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int16_t *)pWrite = 0; + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + char *status = dnodeStatus[tsArbOnline > 0 ? TAOS_DN_STATUS_READY : TAOS_DN_STATUS_OFFLINE]; + STR_TO_VARSTR(pWrite, status); + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, "arb"); + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int64_t *)pWrite = 0; + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + STR_TO_VARSTR(pWrite, "-"); + cols++; + + numOfRows++; + } + mnodeVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; return numOfRows; diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 9d2bfe0ce1..ae495108b3 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -274,7 +274,7 @@ static int32_t sdbGetSyncVersion(int32_t vgId, uint64_t *fver, uint64_t *vver) { // failed to forward, need revert insert static void sdbHandleFailedConfirm(SSdbRow *pRow) { - SWalHead *pHead = pRow->pHead; + SWalHead *pHead = &pRow->pHead; int32_t action = pHead->msgType % 10; sdbError("vgId:1, row:%p:%s hver:%" PRIu64 " action:%s, failed to foward since %s", pRow->pObj, @@ -1012,7 +1012,7 @@ static void sdbFreeQueue() { } static int32_t sdbWriteToQueue(SSdbRow *pRow, int32_t qtype) { - SWalHead *pHead = pRow->pHead; + SWalHead *pHead = &pRow->pHead; if (pHead->len > TSDB_MAX_WAL_SIZE) { sdbError("vgId:1, wal len:%d exceeds limit, hver:%" PRIu64, pHead->len, pHead->version); @@ -1051,8 +1051,8 @@ static int32_t sdbWriteFwdToQueue(int32_t vgId, void *wparam, int32_t qtype, voi return TSDB_CODE_VND_OUT_OF_MEMORY; } - memcpy(pRow->pHead, pHead, sizeof(SWalHead) + pHead->len); - pRow->rowData = pRow->pHead->cont; + memcpy(&pRow->pHead, pHead, sizeof(SWalHead) + pHead->len); + pRow->rowData = pRow->pHead.cont; int32_t code = sdbWriteToQueue(pRow, qtype); if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) code = 0; @@ -1073,7 +1073,7 @@ static int32_t sdbWriteRowToQueue(SSdbRow *pInputRow, int32_t action) { memcpy(pRow, pInputRow, sizeof(SSdbRow)); pRow->processedCount = 1; - SWalHead *pHead = pRow->pHead; + SWalHead *pHead = &pRow->pHead; pRow->rowData = pHead->cont; (*pTable->fpEncode)(pRow); @@ -1103,9 +1103,9 @@ static void *sdbWorkerFp(void *pWorker) { for (int32_t i = 0; i < numOfMsgs; ++i) { taosGetQitem(tsSdbWQall, &qtype, (void **)&pRow); sdbTrace("vgId:1, msg:%p, row:%p hver:%" PRIu64 ", will be processed in sdb queue", pRow->pMsg, pRow->pObj, - pRow->pHead->version); + pRow->pHead.version); - pRow->code = sdbProcessWrite((qtype == TAOS_QTYPE_RPC) ? pRow : NULL, pRow->pHead, qtype, NULL); + pRow->code = sdbProcessWrite((qtype == TAOS_QTYPE_RPC) ? pRow : NULL, &pRow->pHead, qtype, NULL); if (pRow->code > 0) pRow->code = 0; sdbTrace("vgId:1, msg:%p is processed in sdb queue, code:%x", pRow->pMsg, pRow->code); @@ -1122,7 +1122,7 @@ static void *sdbWorkerFp(void *pWorker) { sdbConfirmForward(1, pRow, pRow->code); } else { if (qtype == TAOS_QTYPE_FWD) { - syncConfirmForward(tsSdbMgmt.sync, pRow->pHead->version, pRow->code); + syncConfirmForward(tsSdbMgmt.sync, pRow->pHead.version, pRow->code); } sdbFreeFromQueue(pRow); } diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index f53a4209b0..de37b09345 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -35,12 +35,9 @@ #include "mnodeAcct.h" #include "mnodeDb.h" #include "mnodeDnode.h" -#include "mnodeMnode.h" -#include "mnodeProfile.h" #include "mnodeSdb.h" #include "mnodeShow.h" #include "mnodeTable.h" -#include "mnodeUser.h" #include "mnodeVgroup.h" #include "mnodeWrite.h" #include "mnodeRead.h" @@ -1003,7 +1000,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { SCMCreateTableMsg *pCreate1 = pMsg->rpcMsg.pCont; if (pCreate1->numOfTables == 0) { - // todo return to error message + return TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG; } SCreateTableMsg* pCreate = (SCreateTableMsg*)((char*)pCreate1 + sizeof(SCMCreateTableMsg)); @@ -1032,16 +1029,39 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { mError("msg:%p, app:%p table:%s, failed to create, no schema input", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableId); return TSDB_CODE_MND_INVALID_TABLE_NAME; } + memcpy(pStable->schema, pCreate->schema, numOfCols * sizeof(SSchema)); + if (pStable->numOfColumns > TSDB_MAX_COLUMNS || pStable->numOfTags > TSDB_MAX_TAGS) { + mError("msg:%p, app:%p table:%s, failed to create, too many columns", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableId); + return TSDB_CODE_MND_INVALID_TABLE_NAME; + } + pStable->nextColId = 0; + + // TODO extract method to valid the schema + int32_t schemaLen = 0; + int32_t tagLen = 0; for (int32_t col = 0; col < numOfCols; col++) { SSchema *tschema = pStable->schema; tschema[col].colId = pStable->nextColId++; tschema[col].bytes = htons(tschema[col].bytes); - - // todo 1. check the length of each column; 2. check the total length of all columns - assert(tschema[col].type >= TSDB_DATA_TYPE_BOOL && tschema[col].type <= TSDB_DATA_TYPE_NCHAR); + + if (col < pStable->numOfTables) { + schemaLen += tschema[col].bytes; + } else { + tagLen += tschema[col].bytes; + } + + if (!isValidDataType(tschema[col].type)) { + mError("msg:%p, app:%p table:%s, failed to create, invalid data type in schema", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableId); + return TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG; + } + } + + if (schemaLen > (TSDB_MAX_BYTES_PER_ROW || tagLen > TSDB_MAX_TAGS_LEN)) { + mError("msg:%p, app:%p table:%s, failed to create, schema is too long", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableId); + return TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG; } pMsg->pTable = (STableObj *)pStable; @@ -2361,6 +2381,12 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) { static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) { STableInfoMsg *pInfo = pMsg->rpcMsg.pCont; + if (pMsg->rpcMsg.contLen <= sizeof(*pInfo)) { + mError("msg:%p, app:%p table:%s, failed to auto create child table, tags not exist", pMsg, pMsg->rpcMsg.ahandle, + pInfo->tableId); + return TSDB_CODE_MND_TAG_NOT_EXIST; + } + char* p = pInfo->tags; int32_t nameLen = htonl(*(int32_t*) p); p += sizeof(int32_t); diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 827be0687d..881ef95fca 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -565,7 +565,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) { SDbObj *pDb = pMsg->pDb; SVgObj *pVgroup = (SVgObj *)calloc(1, sizeof(SVgObj)); - tstrncpy(pVgroup->dbName, pDb->name, TSDB_ACCT_LEN + TSDB_DB_NAME_LEN); + tstrncpy(pVgroup->dbName, pDb->name, TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN); pVgroup->numOfVnodes = pDb->cfg.replications; pVgroup->createdTime = taosGetTimestampMs(); pVgroup->accessState = TSDB_VN_ALL_ACCCESS; diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index 4e44d29a02..f41719f240 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_LINUX) @@ -10,3 +10,5 @@ ELSEIF (TD_WINDOWS) ENDIF () ADD_SUBDIRECTORY(src/detail) +ADD_SUBDIRECTORY(tests) + diff --git a/src/os/inc/osString.h b/src/os/inc/osString.h index e07bea4f40..97966ed412 100644 --- a/src/os/inc/osString.h +++ b/src/os/inc/osString.h @@ -47,7 +47,7 @@ extern "C" { // USE_LIBICONV int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs); -bool taosMbsToUcs4(char *mbs, size_t mbs_len, char *ucs4, int32_t ucs4_max_len, size_t *len); +bool taosMbsToUcs4(char *mbs, size_t mbs_len, char *ucs4, int32_t ucs4_max_len, int *len); int tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int bytes); bool taosValidateEncodec(const char *encodec); char * taosCharsetReplace(char *charsetstr); diff --git a/src/os/inc/osSysinfo.h b/src/os/inc/osSysinfo.h index 2b98f8b4bf..b592a6c679 100644 --- a/src/os/inc/osSysinfo.h +++ b/src/os/inc/osSysinfo.h @@ -32,6 +32,7 @@ void taosPrintOsInfo(); int taosSystem(const char * cmd) ; void taosKillSystem(); bool taosGetSystemUid(char *uid); +char *taosGetCmdlineByPID(int pid); // TAOS_OS_FUNC_SYSINFO_CORE void taosSetCoreDump(); diff --git a/src/os/src/alpine/CMakeLists.txt b/src/os/src/alpine/CMakeLists.txt index b5e739c24c..daa0b3cf43 100644 --- a/src/os/src/alpine/CMakeLists.txt +++ b/src/os/src/alpine/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) AUX_SOURCE_DIRECTORY(. SRC) diff --git a/src/os/src/darwin/CMakeLists.txt b/src/os/src/darwin/CMakeLists.txt index c4cb28aa05..7f05ddd64b 100644 --- a/src/os/src/darwin/CMakeLists.txt +++ b/src/os/src/darwin/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) AUX_SOURCE_DIRECTORY(. SRC) diff --git a/src/os/src/detail/CMakeLists.txt b/src/os/src/detail/CMakeLists.txt index 0d5c130d6e..e4052a4fb3 100644 --- a/src/os/src/detail/CMakeLists.txt +++ b/src/os/src/detail/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(.) diff --git a/src/os/src/detail/osString.c b/src/os/src/detail/osString.c index 31ffd6b87c..59f47b4815 100644 --- a/src/os/src/detail/osString.c +++ b/src/os/src/detail/osString.c @@ -46,7 +46,7 @@ int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) { return (int32_t)(ucs4_max_len - outLen); } -bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, size_t *len) { +bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, int32_t *len) { memset(ucs4, 0, ucs4_max_len); iconv_t cd = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); size_t ucs4_input_len = mbsLength; @@ -58,7 +58,7 @@ bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len iconv_close(cd); if (len != NULL) { - *len = ucs4_max_len - outLeft; + *len = (int32_t)(ucs4_max_len - outLeft); } return true; @@ -92,7 +92,7 @@ int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) { return len; } -bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, size_t *len) { +bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, int32_t *len) { memset(ucs4, 0, ucs4_max_len); mbstate_t state = {0}; int32_t retlen = mbsnrtowcs((wchar_t *)ucs4, (const char **)&mbs, mbsLength, ucs4_max_len / 4, &state); diff --git a/src/os/src/detail/osTime.c b/src/os/src/detail/osTime.c index b78627f46f..1710c469fb 100644 --- a/src/os/src/detail/osTime.c +++ b/src/os/src/detail/osTime.c @@ -486,7 +486,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio start = (delta / pInterval->sliding + factor) * pInterval->sliding; if (pInterval->intervalUnit == 'd' || pInterval->intervalUnit == 'w') { - /* + /* * here we revised the start time of day according to the local time zone, * but in case of DST, the start time of one day need to be dynamically decided. */ @@ -501,9 +501,24 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio start += (int64_t)(timezone * TSDB_TICK_PER_SECOND(precision)); } - int64_t end = start + pInterval->interval - 1; - if (end < t) { - start += pInterval->sliding; + int64_t end = 0; + + // not enough time range + if (INT64_MAX - start > pInterval->interval - 1) { + end = start + pInterval->interval - 1; + + while(end < t && ((start + pInterval->sliding) <= INT64_MAX)) { // move forward to the correct time window + start += pInterval->sliding; + + if (INT64_MAX - start > pInterval->interval - 1) { + end = start + pInterval->interval - 1; + } else { + end = INT64_MAX; + break; + } + } + } else { + end = INT64_MAX; } } diff --git a/src/os/src/linux/CMakeLists.txt b/src/os/src/linux/CMakeLists.txt index b1a7ebf54e..8ab8f55467 100644 --- a/src/os/src/linux/CMakeLists.txt +++ b/src/os/src/linux/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) AUX_SOURCE_DIRECTORY(. SRC) diff --git a/src/os/src/linux/linuxEnv.c b/src/os/src/linux/linuxEnv.c index 14b40a1f18..5772885cb4 100644 --- a/src/os/src/linux/linuxEnv.c +++ b/src/os/src/linux/linuxEnv.c @@ -39,4 +39,22 @@ void osInit() { strcpy(tsDnodeDir, ""); strcpy(tsMnodeDir, ""); strcpy(tsOsName, "Linux"); -} \ No newline at end of file +} + +char cmdline[1024]; + +char *taosGetCmdlineByPID(int pid) +{ + sprintf(cmdline, "/proc/%d/cmdline",pid); + FILE* f = fopen(cmdline,"r"); + if(f){ + size_t size; + size = fread(cmdline, sizeof(char), 1024, f); + if(size>0){ + if('\n'==cmdline[size-1]) + cmdline[size-1]='\0'; + } + fclose(f); + } + return cmdline; +} diff --git a/src/os/src/windows/CMakeLists.txt b/src/os/src/windows/CMakeLists.txt index 9dcc9e7e6d..a430dd3b3f 100644 --- a/src/os/src/windows/CMakeLists.txt +++ b/src/os/src/windows/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) AUX_SOURCE_DIRECTORY(. SRC) diff --git a/src/os/tests/CMakeLists.txt b/src/os/tests/CMakeLists.txt new file mode 100644 index 0000000000..1a18a72b40 --- /dev/null +++ b/src/os/tests/CMakeLists.txt @@ -0,0 +1,15 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(TDengine) + +FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include/gtest) +FIND_LIBRARY(LIB_GTEST_STATIC_DIR libgtest.a /usr/lib/ /usr/local/lib) + +IF (HEADER_GTEST_INCLUDE_DIR AND LIB_GTEST_STATIC_DIR) + MESSAGE(STATUS "gTest library found, build unit test") + + INCLUDE_DIRECTORIES(${HEADER_GTEST_INCLUDE_DIR}) + AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) + + ADD_EXECUTABLE(osTest ${SOURCE_LIST}) + TARGET_LINK_LIBRARIES(osTest taos osdetail tutil common gtest pthread) +ENDIF() \ No newline at end of file diff --git a/src/os/tests/test.cpp b/src/os/tests/test.cpp new file mode 100644 index 0000000000..600e5d71a7 --- /dev/null +++ b/src/os/tests/test.cpp @@ -0,0 +1,34 @@ +#include "os.h" +#include +#include +#include + +#include "taos.h" +#include "tstoken.h" +#include "tutil.h" + +int main(int argc, char** argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + +// test function in os module +TEST(testCase, parse_time) { + taos_options(TSDB_OPTION_TIMEZONE, "GMT-8"); + deltaToUtcInitOnce(); + + // window: 1500000001000, 1500002000000 + // pQuery->interval: interval: 86400000, sliding:3600000 + int64_t key = 1500000001000; + SInterval interval = {0}; + interval.interval = 86400000; + interval.intervalUnit = 'd'; + interval.sliding = 3600000; + interval.slidingUnit = 'h'; + + int64_t s = taosTimeTruncate(key, &interval, TSDB_TIME_PRECISION_MILLI); + ASSERT_TRUE(s + interval.interval >= key); +} + + + diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 742235894a..d03717b6e1 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) ADD_SUBDIRECTORY(monitor) diff --git a/src/plugins/http/CMakeLists.txt b/src/plugins/http/CMakeLists.txt index 5d8b52986a..56c3c25d7c 100644 --- a/src/plugins/http/CMakeLists.txt +++ b/src/plugins/http/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/zlib-1.2.11/inc) diff --git a/src/plugins/http/inc/httpInt.h b/src/plugins/http/inc/httpInt.h index ebdfabf310..ac182b707b 100644 --- a/src/plugins/http/inc/httpInt.h +++ b/src/plugins/http/inc/httpInt.h @@ -39,7 +39,7 @@ #define HTTP_GC_TARGET_SIZE 512 #define HTTP_WRITE_RETRY_TIMES 500 #define HTTP_WRITE_WAIT_TIME_MS 5 -#define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + TSDB_PASSWORD_LEN) +#define HTTP_SESSION_ID_LEN (TSDB_USER_LEN + TSDB_KEY_LEN) typedef enum HttpReqType { HTTP_REQTYPE_OTHERS = 0, @@ -147,7 +147,7 @@ typedef struct HttpContext { uint8_t parsed; char ipstr[22]; char user[TSDB_USER_LEN]; // parsed from auth token or login message - char pass[TSDB_PASSWORD_LEN]; + char pass[TSDB_KEY_LEN]; TAOS * taos; void * ppContext; HttpSession *session; diff --git a/src/plugins/http/src/httpAuth.c b/src/plugins/http/src/httpAuth.c index 8beef7c042..56da8a7089 100644 --- a/src/plugins/http/src/httpAuth.c +++ b/src/plugins/http/src/httpAuth.c @@ -51,7 +51,7 @@ int32_t httpParseBasicAuthToken(HttpContext *pContext, char *token, int32_t len) char *password = user + 1; int32_t pass_len = (int32_t)((base64 + outlen) - password); - if (pass_len < 1 || pass_len >= TSDB_PASSWORD_LEN) { + if (pass_len < 1 || pass_len >= TSDB_KEY_LEN) { httpError("context:%p, fd:%d, basic token:%s parse password error", pContext, pContext->fd, token); free(base64); return -1; @@ -73,7 +73,7 @@ int32_t httpParseTaosdAuthToken(HttpContext *pContext, char *token, int32_t len) if (base64) free(base64); return 01; } - if (outlen != (TSDB_USER_LEN + TSDB_PASSWORD_LEN)) { + if (outlen != (TSDB_USER_LEN + TSDB_KEY_LEN)) { httpError("context:%p, fd:%d, taosd token:%s length error", pContext, pContext->fd, token); free(base64); return -1; @@ -103,8 +103,8 @@ int32_t httpGenTaosdAuthToken(HttpContext *pContext, char *token, int32_t maxLen size = sizeof(pContext->pass); tstrncpy(buffer + sizeof(pContext->user), pContext->pass, size); - char *encrypt = taosDesEncode(KEY_DES_4, buffer, TSDB_USER_LEN + TSDB_PASSWORD_LEN); - char *base64 = base64_encode((const unsigned char *)encrypt, TSDB_USER_LEN + TSDB_PASSWORD_LEN); + char *encrypt = taosDesEncode(KEY_DES_4, buffer, TSDB_USER_LEN + TSDB_KEY_LEN); + char *base64 = base64_encode((const unsigned char *)encrypt, TSDB_USER_LEN + TSDB_KEY_LEN); size_t len = strlen(base64); tstrncpy(token, base64, len + 1); diff --git a/src/plugins/http/src/httpGcHandle.c b/src/plugins/http/src/httpGcHandle.c index 5d4cb0c680..c21799e736 100644 --- a/src/plugins/http/src/httpGcHandle.c +++ b/src/plugins/http/src/httpGcHandle.c @@ -59,11 +59,11 @@ bool gcGetUserFromUrl(HttpContext* pContext) { bool gcGetPassFromUrl(HttpContext* pContext) { HttpParser* pParser = pContext->parser; - if (pParser->path[GC_PASS_URL_POS].pos >= TSDB_PASSWORD_LEN || pParser->path[GC_PASS_URL_POS].pos <= 0) { + if (pParser->path[GC_PASS_URL_POS].pos >= TSDB_KEY_LEN || pParser->path[GC_PASS_URL_POS].pos <= 0) { return false; } - tstrncpy(pContext->pass, pParser->path[GC_PASS_URL_POS].str, TSDB_PASSWORD_LEN); + tstrncpy(pContext->pass, pParser->path[GC_PASS_URL_POS].str, TSDB_KEY_LEN); return true; } diff --git a/src/plugins/http/src/httpRestHandle.c b/src/plugins/http/src/httpRestHandle.c index 0a28c431ef..66f1db1a54 100644 --- a/src/plugins/http/src/httpRestHandle.c +++ b/src/plugins/http/src/httpRestHandle.c @@ -72,11 +72,11 @@ bool restGetUserFromUrl(HttpContext* pContext) { bool restGetPassFromUrl(HttpContext* pContext) { HttpParser* pParser = pContext->parser; - if (pParser->path[REST_PASS_URL_POS].pos >= TSDB_PASSWORD_LEN || pParser->path[REST_PASS_URL_POS].pos <= 0) { + if (pParser->path[REST_PASS_URL_POS].pos >= TSDB_KEY_LEN || pParser->path[REST_PASS_URL_POS].pos <= 0) { return false; } - tstrncpy(pContext->pass, pParser->path[REST_PASS_URL_POS].str, TSDB_PASSWORD_LEN); + tstrncpy(pContext->pass, pParser->path[REST_PASS_URL_POS].str, TSDB_KEY_LEN); return true; } diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c index 3e517c6fa6..cc8e9e86e3 100644 --- a/src/plugins/http/src/httpSql.c +++ b/src/plugins/http/src/httpSql.c @@ -181,7 +181,7 @@ void httpProcessMultiSql(HttpContext *pContext) { char *sql = httpGetCmdsString(pContext, cmd->sql); httpTraceL("context:%p, fd:%d, user:%s, process pos:%d, start query, sql:%s", pContext, pContext->fd, pContext->user, multiCmds->pos, sql); - nPrintHttp(sql); + nPrintHttp("%s", sql); taos_query_a(pContext->session->taos, sql, httpProcessMultiSqlCallBack, (void *)pContext); } @@ -329,7 +329,7 @@ void httpProcessSingleSqlCmd(HttpContext *pContext) { } httpTraceL("context:%p, fd:%d, user:%s, start query, sql:%s", pContext, pContext->fd, pContext->user, sql); - nPrintHttp(sql); + nPrintHttp("%s", sql); taos_query_a(pSession->taos, sql, httpProcessSingleSqlCallBack, (void *)pContext); } diff --git a/src/plugins/http/src/httpTgHandle.c b/src/plugins/http/src/httpTgHandle.c index e2b57b87bb..0a3ef539e3 100644 --- a/src/plugins/http/src/httpTgHandle.c +++ b/src/plugins/http/src/httpTgHandle.c @@ -324,7 +324,7 @@ bool tgGetUserFromUrl(HttpContext *pContext) { bool tgGetPassFromUrl(HttpContext *pContext) { HttpParser *pParser = pContext->parser; - if (pParser->path[TG_PASS_URL_POS].pos >= TSDB_PASSWORD_LEN || pParser->path[TG_PASS_URL_POS].pos <= 0) { + if (pParser->path[TG_PASS_URL_POS].pos >= TSDB_KEY_LEN || pParser->path[TG_PASS_URL_POS].pos <= 0) { return false; } diff --git a/src/plugins/monitor/CMakeLists.txt b/src/plugins/monitor/CMakeLists.txt index edea2187ea..90189c9d75 100644 --- a/src/plugins/monitor/CMakeLists.txt +++ b/src/plugins/monitor/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) diff --git a/src/plugins/mqtt/CMakeLists.txt b/src/plugins/mqtt/CMakeLists.txt index cf5729d608..3761f70134 100644 --- a/src/plugins/mqtt/CMakeLists.txt +++ b/src/plugins/mqtt/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) diff --git a/src/query/CMakeLists.txt b/src/query/CMakeLists.txt index c1024f0080..e403251858 100644 --- a/src/query/CMakeLists.txt +++ b/src/query/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/tsdb/inc) diff --git a/src/query/inc/qArithmeticOperator.h b/src/query/inc/qArithmeticOperator.h index f13c63acc3..27e8871e2f 100644 --- a/src/query/inc/qArithmeticOperator.h +++ b/src/query/inc/qArithmeticOperator.h @@ -13,17 +13,17 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_TSYNTAXTREEFUNCTION_H -#define TDENGINE_TSYNTAXTREEFUNCTION_H +#ifndef TDENGINE_QARITHMETICOPERATOR_H +#define TDENGINE_QARITHMETICOPERATOR_H #ifdef __cplusplus extern "C" { #endif -typedef void (*_bi_consumer_fn_t)(void *left, void *right, int32_t numOfLeft, int32_t numOfRight, void *output, - int32_t order); +typedef void (*_arithmetic_operator_fn_t)(void *left, int32_t numLeft, int32_t leftType, void *right, int32_t numRight, + int32_t rightType, void *output, int32_t order); -_bi_consumer_fn_t getArithmeticOperatorFn(int32_t leftType, int32_t rightType, int32_t optr); +_arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr); #ifdef __cplusplus } diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index c3d60e21dc..79d98432c8 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -30,7 +30,7 @@ #include "tsqlfunction.h" struct SColumnFilterElem; -typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, char* val1, char* val2); +typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, const char* val1, const char* val2, int16_t type); typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order); typedef struct SResultRowPool { diff --git a/src/query/inc/qPercentile.h b/src/query/inc/qPercentile.h index c34c24c5b2..f5b770593c 100644 --- a/src/query/inc/qPercentile.h +++ b/src/query/inc/qPercentile.h @@ -16,32 +16,36 @@ #ifndef TDENGINE_QPERCENTILE_H #define TDENGINE_QPERCENTILE_H +#ifdef __cplusplus +extern "C" { +#endif + #include "qExtbuffer.h" #include "qResultbuf.h" #include "qTsbuf.h" typedef struct MinMaxEntry { union { - double dMinVal; - int32_t iMinVal; - int64_t i64MinVal; + double dMinVal; + int64_t i64MinVal; + uint64_t u64MinVal; }; union { double dMaxVal; - int32_t iMaxVal; int64_t i64MaxVal; + int64_t u64MaxVal; }; } MinMaxEntry; typedef struct { - int32_t size; - int32_t pageId; + int32_t size; + int32_t pageId; tFilePage *data; } SSlotInfo; typedef struct tMemBucketSlot { - SSlotInfo info; - MinMaxEntry range; + SSlotInfo info; + MinMaxEntry range; } tMemBucketSlot; struct tMemBucket; @@ -52,16 +56,16 @@ typedef struct tMemBucket { int16_t type; int16_t bytes; int32_t total; - int32_t elemPerPage; // number of elements for each object - int32_t maxCapacity; // maximum allowed number of elements that can be sort directly to get the result - int32_t bufPageSize; // disk page size - MinMaxEntry range; // value range - int32_t times; // count that has been checked for deciding the correct data value buckets. + int32_t elemPerPage; // number of elements for each object + int32_t maxCapacity; // maximum allowed number of elements that can be sort directly to get the result + int32_t bufPageSize; // disk page size + MinMaxEntry range; // value range + int32_t times; // count that has been checked for deciding the correct data value buckets. __compar_fn_t comparFn; - tMemBucketSlot *pSlots; + tMemBucketSlot * pSlots; SDiskbasedResultBuf *pBuffer; - __perc_hash_func_t hashFunc; + __perc_hash_func_t hashFunc; } tMemBucket; tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval, double maxval); @@ -73,3 +77,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size); double getPercentile(tMemBucket *pMemBucket, double percent); #endif // TDENGINE_QPERCENTILE_H + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/query/inc/qUtil.h b/src/query/inc/qUtil.h index 4620e3d61e..27bf7f2d96 100644 --- a/src/query/inc/qUtil.h +++ b/src/query/inc/qUtil.h @@ -60,11 +60,10 @@ static FORCE_INLINE char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int3 pQuery->pExpr1[columnIndex].bytes * realRowId; } -bool isNull_filter(SColumnFilterElem *pFilter, char* minval, char* maxval); -bool notNull_filter(SColumnFilterElem *pFilter, char* minval, char* maxval); +bool isNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type); +bool notNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type); -__filter_func_t *getRangeFilterFuncArray(int32_t type); -__filter_func_t *getValueFilterFuncArray(int32_t type); +__filter_func_t getFilterOperator(int32_t lowerOptr, int32_t upperOptr); SResultRowPool* initResultRowPool(size_t size); SResultRow* getNewResultRow(SResultRowPool* p); diff --git a/src/query/inc/queryLog.h b/src/query/inc/queryLog.h index d4e909d33a..26544ab0f9 100644 --- a/src/query/inc/queryLog.h +++ b/src/query/inc/queryLog.h @@ -22,8 +22,7 @@ extern "C" { #include "tlog.h" -extern int32_t qDebugFlag; -extern int8_t tscEmbedded; +extern uint32_t qDebugFlag; #define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", 255, __VA_ARGS__); }} while(0) #define qError(...) do { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", 255, __VA_ARGS__); }} while(0) diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index dda15fb508..1fa1369bb5 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -291,6 +291,13 @@ typename(A) ::= ids(X) LP signed(Y) RP. { } } +// define the unsigned number type +typename(A) ::= ids(X) UNSIGNED(Z). { + X.type = 0; + X.n = ((Z.z + Z.n) - X.z); + tSqlSetColumnType (&A, &X); +} + %type signed {int64_t} signed(A) ::= INTEGER(X). { A = strtol(X.z, NULL, 10); } signed(A) ::= PLUS INTEGER(X). { A = strtol(X.z, NULL, 10); } diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 0754483449..3c7fd794bf 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -21,7 +21,7 @@ #include "qTsbuf.h" #include "taosdef.h" #include "taosmsg.h" -#include "tscLog.h" +#include "queryLog.h" #include "tscSubquery.h" #include "tsqlfunction.h" #include "ttype.h" @@ -51,16 +51,16 @@ #define INC_INIT_VAL(ctx, res) (GET_RES_INFO(ctx)->numOfRes += (res)); -#define DO_UPDATE_TAG_COLUMNS(ctx, ts) \ - do { \ - for (int32_t _i = 0; _i < (ctx)->tagInfo.numOfTagCols; ++_i) { \ - SQLFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[_i]; \ - if (__ctx->functionId == TSDB_FUNC_TS_DUMMY) { \ - __ctx->tag.i64Key = (ts); \ - __ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; \ - } \ - aAggs[TSDB_FUNC_TAG].xFunction(__ctx); \ - } \ +#define DO_UPDATE_TAG_COLUMNS(ctx, ts) \ + do { \ + for (int32_t _i = 0; _i < (ctx)->tagInfo.numOfTagCols; ++_i) { \ + SQLFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[_i]; \ + if (__ctx->functionId == TSDB_FUNC_TS_DUMMY) { \ + __ctx->tag.i64 = (ts); \ + __ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; \ + } \ + aAggs[TSDB_FUNC_TAG].xFunction(__ctx); \ + } \ } while (0) #define DO_UPDATE_TAG_COLUMNS_WITHOUT_TS(ctx) \ @@ -158,7 +158,7 @@ typedef struct SRateInfo { int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, int16_t *type, int16_t *bytes, int32_t *interBytes, int16_t extLength, bool isSuperTable) { if (!isValidDataType(dataType)) { - tscError("Illegal data type %d or data type length %d", dataType, dataBytes); + qError("Illegal data type %d or data type length %d", dataType, dataBytes); return TSDB_CODE_TSC_INVALID_SQL; } @@ -263,8 +263,10 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI } if (functionId == TSDB_FUNC_SUM) { - if (dataType >= TSDB_DATA_TYPE_TINYINT && dataType <= TSDB_DATA_TYPE_BIGINT) { + if (IS_SIGNED_NUMERIC_TYPE(dataType)) { *type = TSDB_DATA_TYPE_BIGINT; + } else if (IS_UNSIGNED_NUMERIC_TYPE(dataType)) { + *type = TSDB_DATA_TYPE_UBIGINT; } else { *type = TSDB_DATA_TYPE_DOUBLE; } @@ -463,7 +465,7 @@ int32_t no_data_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId } #define LIST_ADD_N(x, ctx, p, t, numOfElem, tsdbType) \ - { \ + do { \ t *d = (t *)(p); \ for (int32_t i = 0; i < (ctx)->size; ++i) { \ if (((ctx)->hasNull) && isNull((char *)&(d)[i], tsdbType)) { \ @@ -472,7 +474,7 @@ int32_t no_data_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId (x) += (d)[i]; \ (numOfElem)++; \ } \ - }; + } while(0) #define UPDATE_DATA(ctx, left, right, num, sign, k) \ do { \ @@ -516,9 +518,12 @@ static void do_sum(SQLFunctionCtx *pCtx) { notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; assert(pCtx->size >= pCtx->preAggVals.statis.numOfNull); - if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) { - int64_t *retVal = (int64_t*) pCtx->aOutputBuf; + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { + int64_t *retVal = (int64_t *)pCtx->aOutputBuf; *retVal += pCtx->preAggVals.statis.sum; + } else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->inputType)) { + uint64_t *retVal = (uint64_t *)pCtx->aOutputBuf; + *retVal += (uint64_t)pCtx->preAggVals.statis.sum; } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE || pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { double *retVal = (double*) pCtx->aOutputBuf; *retVal += GET_DOUBLE_VAL((const char*)&(pCtx->preAggVals.statis.sum)); @@ -526,10 +531,10 @@ static void do_sum(SQLFunctionCtx *pCtx) { } else { // computing based on the true data block void *pData = GET_INPUT_DATA_LIST(pCtx); notNullElems = 0; - - if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) { - int64_t *retVal = (int64_t*) pCtx->aOutputBuf; - + + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { + int64_t *retVal = (int64_t *)pCtx->aOutputBuf; + if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) { LIST_ADD_N(*retVal, pCtx, pData, int8_t, notNullElems, pCtx->inputType); } else if (pCtx->inputType == TSDB_DATA_TYPE_SMALLINT) { @@ -539,11 +544,23 @@ static void do_sum(SQLFunctionCtx *pCtx) { } else if (pCtx->inputType == TSDB_DATA_TYPE_BIGINT) { LIST_ADD_N(*retVal, pCtx, pData, int64_t, notNullElems, pCtx->inputType); } + } else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->inputType)) { + uint64_t *retVal = (uint64_t *)pCtx->aOutputBuf; + + if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) { + LIST_ADD_N(*retVal, pCtx, pData, uint8_t, notNullElems, pCtx->inputType); + } else if (pCtx->inputType == TSDB_DATA_TYPE_SMALLINT) { + LIST_ADD_N(*retVal, pCtx, pData, uint16_t, notNullElems, pCtx->inputType); + } else if (pCtx->inputType == TSDB_DATA_TYPE_INT) { + LIST_ADD_N(*retVal, pCtx, pData, uint32_t, notNullElems, pCtx->inputType); + } else if (pCtx->inputType == TSDB_DATA_TYPE_BIGINT) { + LIST_ADD_N(*retVal, pCtx, pData, uint64_t, notNullElems, pCtx->inputType); + } } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE) { - double *retVal = (double*) pCtx->aOutputBuf; + double *retVal = (double *)pCtx->aOutputBuf; LIST_ADD_N(*retVal, pCtx, pData, double, notNullElems, pCtx->inputType); } else if (pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { - double *retVal = (double*) pCtx->aOutputBuf; + double *retVal = (double *)pCtx->aOutputBuf; LIST_ADD_N(*retVal, pCtx, pData, float, notNullElems, pCtx->inputType); } } @@ -668,7 +685,7 @@ static int32_t firstFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, i } static int32_t lastFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { - if (pCtx->order != pCtx->param[0].i64Key) { + if (pCtx->order != pCtx->param[0].i64) { return BLK_DATA_NO_NEEDED; } @@ -700,7 +717,7 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY en } static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { - if (pCtx->order != pCtx->param[0].i64Key) { + if (pCtx->order != pCtx->param[0].i64) { return BLK_DATA_NO_NEEDED; } @@ -732,15 +749,16 @@ static void avg_function(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); SAvgInfo *pAvgInfo = (SAvgInfo *)GET_ROWCELL_INTERBUF(pResInfo); - double * pVal = &pAvgInfo->sum; + double *pVal = &pAvgInfo->sum; - if (pCtx->preAggVals.isSet) { - // Pre-aggregation + if (pCtx->preAggVals.isSet) { // Pre-aggregation notNullElems = pCtx->size - pCtx->preAggVals.statis.numOfNull; assert(notNullElems >= 0); - if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) { + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { *pVal += pCtx->preAggVals.statis.sum; + } else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->inputType)) { + *pVal += (uint64_t) pCtx->preAggVals.statis.sum; } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE || pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { *pVal += GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.sum)); } @@ -759,6 +777,14 @@ static void avg_function(SQLFunctionCtx *pCtx) { LIST_ADD_N(*pVal, pCtx, pData, double, notNullElems, pCtx->inputType); } else if (pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { LIST_ADD_N(*pVal, pCtx, pData, float, notNullElems, pCtx->inputType); + } else if (pCtx->inputType == TSDB_DATA_TYPE_UTINYINT) { + LIST_ADD_N(*pVal, pCtx, pData, uint8_t, notNullElems, pCtx->inputType); + } else if (pCtx->inputType == TSDB_DATA_TYPE_USMALLINT) { + LIST_ADD_N(*pVal, pCtx, pData, uint16_t, notNullElems, pCtx->inputType); + } else if (pCtx->inputType == TSDB_DATA_TYPE_UINT) { + LIST_ADD_N(*pVal, pCtx, pData, uint32_t, notNullElems, pCtx->inputType); + } else if (pCtx->inputType == TSDB_DATA_TYPE_UBIGINT) { + LIST_ADD_N(*pVal, pCtx, pData, uint64_t, notNullElems, pCtx->inputType); } } @@ -804,8 +830,16 @@ static void avg_function_f(SQLFunctionCtx *pCtx, int32_t index) { pAvgInfo->sum += GET_DOUBLE_VAL(pData); } else if (pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { pAvgInfo->sum += GET_FLOAT_VAL(pData); + } else if (pCtx->inputType == TSDB_DATA_TYPE_UTINYINT) { + pAvgInfo->sum += GET_UINT8_VAL(pData); + } else if (pCtx->inputType == TSDB_DATA_TYPE_USMALLINT) { + pAvgInfo->sum += GET_UINT16_VAL(pData); + } else if (pCtx->inputType == TSDB_DATA_TYPE_UINT) { + pAvgInfo->sum += GET_UINT32_VAL(pData); + } else if (pCtx->inputType == TSDB_DATA_TYPE_UBIGINT) { + pAvgInfo->sum += GET_UINT64_VAL(pData); } - + // restore sum and count of elements pAvgInfo->num += 1; @@ -822,7 +856,7 @@ static void avg_func_merge(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); double *sum = (double*) pCtx->aOutputBuf; - char * input = GET_INPUT_DATA_LIST(pCtx); + char *input = GET_INPUT_DATA_LIST(pCtx); for (int32_t i = 0; i < pCtx->size; ++i, input += pCtx->inputBytes) { SAvgInfo *pInput = (SAvgInfo *)input; @@ -848,13 +882,12 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) { if (GET_INT64_VAL(GET_ROWCELL_INTERBUF(pResInfo)) <= 0) { setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); - return; // empty table + return; } *(double *)pCtx->aOutputBuf = (*(double *)pCtx->aOutputBuf) / *(int64_t *)GET_ROWCELL_INTERBUF(pResInfo); } else { // this is the secondary merge, only in the secondary merge, the input type is TSDB_DATA_TYPE_BINARY - assert(pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_DOUBLE); - + assert(IS_NUMERIC_TYPE(pCtx->inputType)); SAvgInfo *pAvgInfo = (SAvgInfo *)GET_ROWCELL_INTERBUF(pResInfo); if (pAvgInfo->num == 0) { // all data are NULL or empty table @@ -881,12 +914,8 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, if (*notNullElems == 0) { return; } - - if (*notNullElems == 0){ - return; - } - void * tval = NULL; + void* tval = NULL; int16_t index = 0; if (isMin) { @@ -913,7 +942,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, key = pCtx->ptsList[index]; } - if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) { + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { int64_t val = GET_INT64_VAL(tval); if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) { int8_t *data = (int8_t *)pOutput; @@ -926,7 +955,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, } else if (pCtx->inputType == TSDB_DATA_TYPE_INT) { int32_t *data = (int32_t *)pOutput; #if defined(_DEBUG_VIEW) - tscDebug("max value updated according to pre-cal:%d", *data); + qDebug("max value updated according to pre-cal:%d", *data); #endif if ((*data < val) ^ isMin) { @@ -934,7 +963,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, for (int32_t i = 0; i < (pCtx)->tagInfo.numOfTagCols; ++i) { SQLFunctionCtx *__ctx = pCtx->tagInfo.pTagCtxList[i]; if (__ctx->functionId == TSDB_FUNC_TS_DUMMY) { - __ctx->tag.i64Key = key; + __ctx->tag.i64 = key; __ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; } @@ -945,11 +974,27 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, int64_t *data = (int64_t *)pOutput; UPDATE_DATA(pCtx, *data, val, notNullElems, isMin, key); } + } else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->inputType)) { + uint64_t val = GET_UINT64_VAL(tval); + if (pCtx->inputType == TSDB_DATA_TYPE_UTINYINT) { + uint8_t *data = (uint8_t *)pOutput; + + UPDATE_DATA(pCtx, *data, (uint8_t)val, notNullElems, isMin, key); + } else if (pCtx->inputType == TSDB_DATA_TYPE_USMALLINT) { + uint16_t *data = (uint16_t *)pOutput; + UPDATE_DATA(pCtx, *data, (uint16_t)val, notNullElems, isMin, key); + } else if (pCtx->inputType == TSDB_DATA_TYPE_UINT) { + uint32_t *data = (uint32_t *)pOutput; + UPDATE_DATA(pCtx, *data, (uint32_t)val, notNullElems, isMin, key); + } else if (pCtx->inputType == TSDB_DATA_TYPE_UBIGINT) { + uint64_t *data = (uint64_t *)pOutput; + UPDATE_DATA(pCtx, *data, val, notNullElems, isMin, key); + } } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE) { - double *data = (double *)pOutput; - double val = GET_DOUBLE_VAL(tval); - - UPDATE_DATA(pCtx, *data, val, notNullElems, isMin, key); + double *data = (double *)pOutput; + double val = GET_DOUBLE_VAL(tval); + + UPDATE_DATA(pCtx, *data, val, notNullElems, isMin, key); } else if (pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { float *data = (float *)pOutput; double val = GET_DOUBLE_VAL(tval); @@ -965,7 +1010,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, *notNullElems = 0; - if (pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) { + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType)) { if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) { TYPED_LOOPCHECK_N(int8_t, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems); } else if (pCtx->inputType == TSDB_DATA_TYPE_SMALLINT) { @@ -989,11 +1034,21 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, *notNullElems += 1; } #if defined(_DEBUG_VIEW) - tscDebug("max value updated:%d", *retVal); + qDebug("max value updated:%d", *retVal); #endif } else if (pCtx->inputType == TSDB_DATA_TYPE_BIGINT) { TYPED_LOOPCHECK_N(int64_t, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems); } + } else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->inputType)) { + if (pCtx->inputType == TSDB_DATA_TYPE_UTINYINT) { + TYPED_LOOPCHECK_N(uint8_t, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems); + } else if (pCtx->inputType == TSDB_DATA_TYPE_USMALLINT) { + TYPED_LOOPCHECK_N(uint16_t, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems); + } else if (pCtx->inputType == TSDB_DATA_TYPE_UINT) { + TYPED_LOOPCHECK_N(uint32_t, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems); + } else if (pCtx->inputType == TSDB_DATA_TYPE_BIGINT) { + TYPED_LOOPCHECK_N(uint64_t, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems); + } } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE) { TYPED_LOOPCHECK_N(double, pOutput, p, pCtx, pCtx->inputType, isMin, *notNullElems); } else if (pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { @@ -1009,28 +1064,40 @@ static bool min_func_setup(SQLFunctionCtx *pCtx) { GET_TRUE_DATA_TYPE(); switch (type) { + case TSDB_DATA_TYPE_TINYINT: + *((int8_t *)pCtx->aOutputBuf) = INT8_MAX; + break; + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) pCtx->aOutputBuf = UINT8_MAX; + break; + case TSDB_DATA_TYPE_SMALLINT: + *((int16_t *)pCtx->aOutputBuf) = INT16_MAX; + break; + case TSDB_DATA_TYPE_USMALLINT: + *((uint16_t *)pCtx->aOutputBuf) = UINT16_MAX; + break; case TSDB_DATA_TYPE_INT: *((int32_t *)pCtx->aOutputBuf) = INT32_MAX; break; + case TSDB_DATA_TYPE_UINT: + *((uint32_t *)pCtx->aOutputBuf) = UINT32_MAX; + break; + case TSDB_DATA_TYPE_BIGINT: + *((int64_t *)pCtx->aOutputBuf) = INT64_MAX; + break; + case TSDB_DATA_TYPE_UBIGINT: + *((uint64_t *)pCtx->aOutputBuf) = UINT64_MAX; + break; case TSDB_DATA_TYPE_FLOAT: *((float *)pCtx->aOutputBuf) = FLT_MAX; break; case TSDB_DATA_TYPE_DOUBLE: *((double *)pCtx->aOutputBuf) = DBL_MAX; break; - case TSDB_DATA_TYPE_BIGINT: - *((int64_t *)pCtx->aOutputBuf) = INT64_MAX; - break; - case TSDB_DATA_TYPE_SMALLINT: - *((int16_t *)pCtx->aOutputBuf) = INT16_MAX; - break; - case TSDB_DATA_TYPE_TINYINT: - *((int8_t *)pCtx->aOutputBuf) = INT8_MAX; - break; default: - tscError("illegal data type:%d in min/max query", pCtx->inputType); + qError("illegal data type:%d in min/max query", pCtx->inputType); } - + return true; } @@ -1045,6 +1112,9 @@ static bool max_func_setup(SQLFunctionCtx *pCtx) { case TSDB_DATA_TYPE_INT: *((int32_t *)pCtx->aOutputBuf) = INT32_MIN; break; + case TSDB_DATA_TYPE_UINT: + *((uint32_t *)pCtx->aOutputBuf) = 0; + break; case TSDB_DATA_TYPE_FLOAT: *((float *)pCtx->aOutputBuf) = -FLT_MAX; break; @@ -1054,14 +1124,23 @@ static bool max_func_setup(SQLFunctionCtx *pCtx) { case TSDB_DATA_TYPE_BIGINT: *((int64_t *)pCtx->aOutputBuf) = INT64_MIN; break; + case TSDB_DATA_TYPE_UBIGINT: + *((uint64_t *)pCtx->aOutputBuf) = 0; + break; case TSDB_DATA_TYPE_SMALLINT: *((int16_t *)pCtx->aOutputBuf) = INT16_MIN; break; + case TSDB_DATA_TYPE_USMALLINT: + *((uint16_t *)pCtx->aOutputBuf) = 0; + break; case TSDB_DATA_TYPE_TINYINT: *((int8_t *)pCtx->aOutputBuf) = INT8_MIN; break; + case TSDB_DATA_TYPE_UTINYINT: + *((uint8_t *)pCtx->aOutputBuf) = 0; + break; default: - tscError("illegal data type:%d in min/max query", pCtx->inputType); + qError("illegal data type:%d in min/max query", pCtx->inputType); } return true; @@ -1108,7 +1187,6 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp int32_t notNullElems = 0; GET_TRUE_DATA_TYPE(); - assert(pCtx->stableQuery); for (int32_t i = 0; i < pCtx->size; ++i) { @@ -1122,7 +1200,7 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp int8_t v = GET_INT8_VAL(input); DUPATE_DATA_WITHOUT_TS(pCtx, *(int8_t *)output, v, notNullElems, isMin); break; - }; + } case TSDB_DATA_TYPE_SMALLINT: { int16_t v = GET_INT16_VAL(input); DUPATE_DATA_WITHOUT_TS(pCtx, *(int16_t *)output, v, notNullElems, isMin); @@ -1156,7 +1234,7 @@ static int32_t minmax_merge_impl(SQLFunctionCtx *pCtx, int32_t bytes, char *outp int64_t v = GET_INT64_VAL(input); DUPATE_DATA_WITHOUT_TS(pCtx, *(int64_t *)output, v, notNullElems, isMin); break; - }; + } default: break; } @@ -1312,10 +1390,9 @@ static void stddev_function(SQLFunctionCtx *pCtx) { break; } default: - tscError("stddev function not support data type:%d", pCtx->inputType); + qError("stddev function not support data type:%d", pCtx->inputType); } - // TODO get the correct data SET_VAL(pCtx, 1, 1); } } @@ -1362,7 +1439,7 @@ static void stddev_function_f(SQLFunctionCtx *pCtx, int32_t index) { break; } default: - tscError("stddev function not support data type:%d", pCtx->inputType); + qError("stddev function not support data type:%d", pCtx->inputType); } SET_VAL(pCtx, 1, 1); @@ -1421,7 +1498,7 @@ static bool first_last_function_setup(SQLFunctionCtx *pCtx) { // used to keep the timestamp for comparison pCtx->param[1].nType = 0; - pCtx->param[1].i64Key = 0; + pCtx->param[1].i64 = 0; return true; } @@ -1552,9 +1629,9 @@ static void first_dist_func_merge(SQLFunctionCtx *pCtx) { } // The param[1] is used to keep the initial value of max ts value - if (pCtx->param[1].nType != pCtx->outputType || pCtx->param[1].i64Key > pInput->ts) { + if (pCtx->param[1].nType != pCtx->outputType || pCtx->param[1].i64 > pInput->ts) { memcpy(pCtx->aOutputBuf, pData, pCtx->outputBytes); - pCtx->param[1].i64Key = pInput->ts; + pCtx->param[1].i64 = pInput->ts; pCtx->param[1].nType = pCtx->outputType; DO_UPDATE_TAG_COLUMNS(pCtx, pInput->ts); @@ -1573,7 +1650,7 @@ static void first_dist_func_merge(SQLFunctionCtx *pCtx) { * least one data in this block that is not null.(TODO opt for this case) */ static void last_function(SQLFunctionCtx *pCtx) { - if (pCtx->order != pCtx->param[0].i64Key || pCtx->preAggVals.dataBlockLoaded == false) { + if (pCtx->order != pCtx->param[0].i64 || pCtx->preAggVals.dataBlockLoaded == false) { return; } @@ -1609,7 +1686,7 @@ static void last_function_f(SQLFunctionCtx *pCtx, int32_t index) { } // the scan order is not the required order, ignore it - if (pCtx->order != pCtx->param[0].i64Key) { + if (pCtx->order != pCtx->param[0].i64) { return; } @@ -1645,7 +1722,7 @@ static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t ind if (pInfo->hasResult != DATA_SET_FLAG || pInfo->ts < timestamp[index]) { #if defined(_DEBUG_VIEW) - tscDebug("assign index:%d, ts:%" PRId64 ", val:%d, ", index, timestamp[index], *(int32_t *)pData); + qDebug("assign index:%d, ts:%" PRId64 ", val:%d, ", index, timestamp[index], *(int32_t *)pData); #endif memcpy(pCtx->aOutputBuf, pData, pCtx->inputBytes); @@ -1661,7 +1738,7 @@ static void last_dist_function(SQLFunctionCtx *pCtx) { * 1. for scan data is not the required order * 2. for data blocks that are not loaded, no need to check data */ - if (pCtx->order != pCtx->param[0].i64Key) { + if (pCtx->order != pCtx->param[0].i64) { return; } @@ -1706,7 +1783,7 @@ static void last_dist_function_f(SQLFunctionCtx *pCtx, int32_t index) { * 1. for scan data in asc order, no need to check data * 2. for data blocks that are not loaded, no need to check data */ - if (pCtx->order != pCtx->param[0].i64Key) { + if (pCtx->order != pCtx->param[0].i64) { return; } @@ -1732,9 +1809,9 @@ static void last_dist_func_merge(SQLFunctionCtx *pCtx) { * param[1] used to keep the corresponding timestamp to decide if current result is * the true last result */ - if (pCtx->param[1].nType != pCtx->outputType || pCtx->param[1].i64Key < pInput->ts) { + if (pCtx->param[1].nType != pCtx->outputType || pCtx->param[1].i64 < pInput->ts) { memcpy(pCtx->aOutputBuf, pData, pCtx->outputBytes); - pCtx->param[1].i64Key = pInput->ts; + pCtx->param[1].i64 = pInput->ts; pCtx->param[1].nType = pCtx->outputType; DO_UPDATE_TAG_COLUMNS(pCtx, pInput->ts); @@ -1794,7 +1871,7 @@ static void last_row_finalizer(SQLFunctionCtx *pCtx) { static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int64_t tsKey, char *pTags, SExtTagsInfo *pTagInfo, int16_t stage) { dst->v.nType = type; - dst->v.i64Key = *(int64_t *)val; + dst->v.i64 = *(int64_t *)val; dst->timestamp = tsKey; int32_t size = 0; @@ -1805,7 +1882,7 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6 SQLFunctionCtx* ctx = pTagInfo->pTagCtxList[i]; if (ctx->functionId == TSDB_FUNC_TS_DUMMY) { ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; - ctx->tag.i64Key = tsKey; + ctx->tag.i64 = tsKey; } tVariantDump(&ctx->tag, dst->pTags + size, ctx->tag.nType, true); @@ -1832,15 +1909,15 @@ static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, if (pInfo->num < maxLen) { if (pInfo->num == 0 || ((type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) && - val.i64Key >= pList[pInfo->num - 1]->v.i64Key) || + val.i64 >= pList[pInfo->num - 1]->v.i64) || ((type >= TSDB_DATA_TYPE_FLOAT && type <= TSDB_DATA_TYPE_DOUBLE) && val.dKey >= pList[pInfo->num - 1]->v.dKey)) { - valuePairAssign(pList[pInfo->num], type, (const char*)&val.i64Key, ts, pTags, pTagInfo, stage); + valuePairAssign(pList[pInfo->num], type, (const char*)&val.i64, ts, pTags, pTagInfo, stage); } else { int32_t i = pInfo->num - 1; if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) { - while (i >= 0 && pList[i]->v.i64Key > val.i64Key) { + while (i >= 0 && pList[i]->v.i64 > val.i64) { VALUEPAIRASSIGN(pList[i + 1], pList[i], pTagInfo->tagsLen); i -= 1; } @@ -1851,18 +1928,18 @@ static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, } } - valuePairAssign(pList[i + 1], type, (const char*) &val.i64Key, ts, pTags, pTagInfo, stage); + valuePairAssign(pList[i + 1], type, (const char*) &val.i64, ts, pTags, pTagInfo, stage); } pInfo->num++; } else { int32_t i = 0; - if (((type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) && val.i64Key > pList[0]->v.i64Key) || + if (((type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) && val.i64 > pList[0]->v.i64) || ((type >= TSDB_DATA_TYPE_FLOAT && type <= TSDB_DATA_TYPE_DOUBLE) && val.dKey > pList[0]->v.dKey)) { // find the appropriate the slot position if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) { - while (i + 1 < maxLen && pList[i + 1]->v.i64Key < val.i64Key) { + while (i + 1 < maxLen && pList[i + 1]->v.i64 < val.i64) { VALUEPAIRASSIGN(pList[i], pList[i + 1], pTagInfo->tagsLen); i += 1; } @@ -1873,7 +1950,7 @@ static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, } } - valuePairAssign(pList[i], type, (const char*) &val.i64Key, ts, pTags, pTagInfo, stage); + valuePairAssign(pList[i], type, (const char*) &val.i64, ts, pTags, pTagInfo, stage); } } } @@ -1888,12 +1965,12 @@ static void do_bottom_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pDa if (pInfo->num < maxLen) { if (pInfo->num == 0) { - valuePairAssign(pList[pInfo->num], type, (const char*) &val.i64Key, ts, pTags, pTagInfo, stage); + valuePairAssign(pList[pInfo->num], type, (const char*) &val.i64, ts, pTags, pTagInfo, stage); } else { int32_t i = pInfo->num - 1; if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) { - while (i >= 0 && pList[i]->v.i64Key < val.i64Key) { + while (i >= 0 && pList[i]->v.i64 < val.i64) { VALUEPAIRASSIGN(pList[i + 1], pList[i], pTagInfo->tagsLen); i -= 1; } @@ -1904,18 +1981,18 @@ static void do_bottom_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pDa } } - valuePairAssign(pList[i + 1], type, (const char*)&val.i64Key, ts, pTags, pTagInfo, stage); + valuePairAssign(pList[i + 1], type, (const char*)&val.i64, ts, pTags, pTagInfo, stage); } pInfo->num++; } else { int32_t i = 0; - if (((type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) && val.i64Key < pList[0]->v.i64Key) || + if (((type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) && val.i64 < pList[0]->v.i64) || ((type >= TSDB_DATA_TYPE_FLOAT && type <= TSDB_DATA_TYPE_DOUBLE) && val.dKey < pList[0]->v.dKey)) { // find the appropriate the slot position if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) { - while (i + 1 < maxLen && pList[i + 1]->v.i64Key > val.i64Key) { + while (i + 1 < maxLen && pList[i + 1]->v.i64 > val.i64) { VALUEPAIRASSIGN(pList[i], pList[i + 1], pTagInfo->tagsLen); i += 1; } @@ -1926,7 +2003,7 @@ static void do_bottom_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pDa } } - valuePairAssign(pList[i], type, (const char*)&val.i64Key, ts, pTags, pTagInfo, stage); + valuePairAssign(pList[i], type, (const char*)&val.i64, ts, pTags, pTagInfo, stage); } } } @@ -1956,10 +2033,10 @@ static int32_t resDataAscComparFn(const void *pLeft, const void *pRight) { return pLeftElem->v.dKey > pRightElem->v.dKey ? 1 : -1; } } else { - if (pLeftElem->v.i64Key == pRightElem->v.i64Key) { + if (pLeftElem->v.i64 == pRightElem->v.i64) { return 0; } else { - return pLeftElem->v.i64Key > pRightElem->v.i64Key ? 1 : -1; + return pLeftElem->v.i64 > pRightElem->v.i64 ? 1 : -1; } } } @@ -1976,17 +2053,19 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) { int32_t len = (int32_t)(GET_RES_INFO(pCtx)->numOfRes); switch (type) { + case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_INT: { int32_t *output = (int32_t *)pCtx->aOutputBuf; for (int32_t i = 0; i < len; ++i, output += step) { - *output = (int32_t)tvp[i]->v.i64Key; + *output = (int32_t)tvp[i]->v.i64; } break; } + case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_BIGINT: { int64_t *output = (int64_t *)pCtx->aOutputBuf; for (int32_t i = 0; i < len; ++i, output += step) { - *output = tvp[i]->v.i64Key; + *output = tvp[i]->v.i64; } break; } @@ -2004,22 +2083,24 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) { } break; } + case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_SMALLINT: { int16_t *output = (int16_t *)pCtx->aOutputBuf; for (int32_t i = 0; i < len; ++i, output += step) { - *output = (int16_t)tvp[i]->v.i64Key; + *output = (int16_t)tvp[i]->v.i64; } break; } + case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_TINYINT: { int8_t *output = (int8_t *)pCtx->aOutputBuf; for (int32_t i = 0; i < len; ++i, output += step) { - *output = (int8_t)tvp[i]->v.i64Key; + *output = (int8_t)tvp[i]->v.i64; } break; } default: { - tscError("top/bottom function not support data type:%d", pCtx->inputType); + qError("top/bottom function not support data type:%d", pCtx->inputType); return; } } @@ -2077,7 +2158,7 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const cha STopBotInfo *pTopBotInfo = getTopBotOutputInfo(pCtx); // required number of results are not reached, continue load data block - if (pTopBotInfo->num < pCtx->param[0].i64Key) { + if (pTopBotInfo->num < pCtx->param[0].i64) { return true; } @@ -2086,13 +2167,13 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const cha if (functionId == TSDB_FUNC_TOP) { switch (pCtx->inputType) { case TSDB_DATA_TYPE_TINYINT: - return GET_INT8_VAL(maxval) > pRes[0]->v.i64Key; + return GET_INT8_VAL(maxval) > pRes[0]->v.i64; case TSDB_DATA_TYPE_SMALLINT: - return GET_INT16_VAL(maxval) > pRes[0]->v.i64Key; + return GET_INT16_VAL(maxval) > pRes[0]->v.i64; case TSDB_DATA_TYPE_INT: - return GET_INT32_VAL(maxval) > pRes[0]->v.i64Key; + return GET_INT32_VAL(maxval) > pRes[0]->v.i64; case TSDB_DATA_TYPE_BIGINT: - return GET_INT64_VAL(maxval) > pRes[0]->v.i64Key; + return GET_INT64_VAL(maxval) > pRes[0]->v.i64; case TSDB_DATA_TYPE_FLOAT: return GET_FLOAT_VAL(maxval) > pRes[0]->v.dKey; case TSDB_DATA_TYPE_DOUBLE: @@ -2103,13 +2184,13 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const cha } else { switch (pCtx->inputType) { case TSDB_DATA_TYPE_TINYINT: - return GET_INT8_VAL(minval) < pRes[0]->v.i64Key; + return GET_INT8_VAL(minval) < pRes[0]->v.i64; case TSDB_DATA_TYPE_SMALLINT: - return GET_INT16_VAL(minval) < pRes[0]->v.i64Key; + return GET_INT16_VAL(minval) < pRes[0]->v.i64; case TSDB_DATA_TYPE_INT: - return GET_INT32_VAL(minval) < pRes[0]->v.i64Key; + return GET_INT32_VAL(minval) < pRes[0]->v.i64; case TSDB_DATA_TYPE_BIGINT: - return GET_INT64_VAL(minval) < pRes[0]->v.i64Key; + return GET_INT64_VAL(minval) < pRes[0]->v.i64; case TSDB_DATA_TYPE_FLOAT: return GET_FLOAT_VAL(minval) < pRes[0]->v.dKey; case TSDB_DATA_TYPE_DOUBLE: @@ -2129,12 +2210,12 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const cha static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) { char *tmp = (char *)pTopBotInfo + sizeof(STopBotInfo); pTopBotInfo->res = (tValuePair**) tmp; - tmp += POINTER_BYTES * pCtx->param[0].i64Key; + tmp += POINTER_BYTES * pCtx->param[0].i64; size_t size = sizeof(tValuePair) + pCtx->tagInfo.tagsLen; -// assert(pCtx->param[0].i64Key > 0); +// assert(pCtx->param[0].i64 > 0); - for (int32_t i = 0; i < pCtx->param[0].i64Key; ++i) { + for (int32_t i = 0; i < pCtx->param[0].i64; ++i) { pTopBotInfo->res[i] = (tValuePair*) tmp; pTopBotInfo->res[i]->pTags = tmp + sizeof(tValuePair); tmp += size; @@ -2167,7 +2248,7 @@ static void top_function(SQLFunctionCtx *pCtx) { } notNullElems++; - do_top_function_add(pRes, (int32_t)pCtx->param[0].i64Key, data, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); + do_top_function_add(pRes, (int32_t)pCtx->param[0].i64, data, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); } if (!pCtx->hasNull) { @@ -2195,7 +2276,7 @@ static void top_function_f(SQLFunctionCtx *pCtx, int32_t index) { SET_VAL(pCtx, 1, 1); TSKEY ts = GET_TS_DATA(pCtx, index); - do_top_function_add(pRes, (int32_t)pCtx->param[0].i64Key, pData, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); + do_top_function_add(pRes, (int32_t)pCtx->param[0].i64, pData, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; @@ -2212,7 +2293,7 @@ static void top_func_merge(SQLFunctionCtx *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].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, + 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); } @@ -2238,7 +2319,7 @@ static void bottom_function(SQLFunctionCtx *pCtx) { } notNullElems++; - do_bottom_function_add(pRes, (int32_t)pCtx->param[0].i64Key, data, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); + do_bottom_function_add(pRes, (int32_t)pCtx->param[0].i64, data, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); } if (!pCtx->hasNull) { @@ -2264,7 +2345,7 @@ static void bottom_function_f(SQLFunctionCtx *pCtx, int32_t index) { STopBotInfo *pRes = getTopBotOutputInfo(pCtx); SET_VAL(pCtx, 1, 1); - do_bottom_function_add(pRes, (int32_t)pCtx->param[0].i64Key, pData, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); + do_bottom_function_add(pRes, (int32_t)pCtx->param[0].i64, pData, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); pResInfo->hasResult = DATA_SET_FLAG; @@ -2281,7 +2362,7 @@ static void bottom_func_merge(SQLFunctionCtx *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_bottom_function_add(pOutput, (int32_t)pCtx->param[0].i64Key, &pInput->res[i]->v.i64Key, pInput->res[i]->timestamp, type, + do_bottom_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); } @@ -2307,11 +2388,11 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) { tValuePair **tvp = pRes->res; // user specify the order of output by sort the result according to timestamp - if (pCtx->param[1].i64Key == PRIMARYKEY_TIMESTAMP_COL_INDEX) { - __compar_fn_t comparator = (pCtx->param[2].i64Key == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn; + if (pCtx->param[1].i64 == PRIMARYKEY_TIMESTAMP_COL_INDEX) { + __compar_fn_t comparator = (pCtx->param[2].i64 == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn; qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator); - } else if (pCtx->param[1].i64Key > PRIMARYKEY_TIMESTAMP_COL_INDEX) { - __compar_fn_t comparator = (pCtx->param[2].i64Key == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn; + } else if (pCtx->param[1].i64 > PRIMARYKEY_TIMESTAMP_COL_INDEX) { + __compar_fn_t comparator = (pCtx->param[2].i64 == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn; qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator); } @@ -2438,7 +2519,7 @@ static void percentile_function_f(SQLFunctionCtx *pCtx, int32_t index) { } static void percentile_finalizer(SQLFunctionCtx *pCtx) { - double v = pCtx->param[0].nType == TSDB_DATA_TYPE_INT ? pCtx->param[0].i64Key : pCtx->param[0].dKey; + 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); @@ -2464,7 +2545,7 @@ static void percentile_next_step(SQLFunctionCtx *pCtx) { if (pInfo->numOfElems == 0) { pResInfo->complete = true; } else { - pInfo->pMemBucket = tMemBucketCreate(pCtx->inputBytes, pCtx->inputType, GET_DOUBLE_VAL(&pInfo->minval), GET_DOUBLE_VAL(&pInfo->maxval)); + pInfo->pMemBucket = tMemBucketCreate(pCtx->inputBytes, pCtx->inputType, pInfo->minval, pInfo->maxval); } pInfo->stage += 1; @@ -2586,7 +2667,7 @@ static void apercentile_func_merge(SQLFunctionCtx *pCtx) { } static void apercentile_finalizer(SQLFunctionCtx *pCtx) { - double v = (pCtx->param[0].nType == TSDB_DATA_TYPE_INT) ? pCtx->param[0].i64Key : pCtx->param[0].dKey; + 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); @@ -2761,7 +2842,7 @@ static void leastsquares_function_f(SQLFunctionCtx *pCtx, int32_t index) { break; } default: - tscError("error data type in leastsquare function:%d", pCtx->inputType); + qError("error data type in leastsquare function:%d", pCtx->inputType); }; SET_VAL(pCtx, 1, 1); @@ -2841,7 +2922,7 @@ static void col_project_function_f(SQLFunctionCtx *pCtx, int32_t index) { } // only one output - if (pCtx->param[0].i64Key == 1 && pResInfo->numOfRes >= 1) { + if (pCtx->param[0].i64 == 1 && pResInfo->numOfRes >= 1) { return; } @@ -2942,23 +3023,23 @@ static void diff_function(SQLFunctionCtx *pCtx) { } if (pCtx->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { // initial value is not set yet - pCtx->param[1].i64Key = pData[i]; + pCtx->param[1].i64 = pData[i]; pCtx->param[1].nType = pCtx->inputType; } else if ((i == 0 && pCtx->order == TSDB_ORDER_ASC) || (i == pCtx->size - 1 && pCtx->order == TSDB_ORDER_DESC)) { - *pOutput = (int32_t)(pData[i] - pCtx->param[1].i64Key); + *pOutput = (int32_t)(pData[i] - pCtx->param[1].i64); *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; } else { - *pOutput = (int32_t)(pData[i] - pCtx->param[1].i64Key); // direct previous may be null + *pOutput = (int32_t)(pData[i] - pCtx->param[1].i64); // direct previous may be null *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; } - pCtx->param[1].i64Key = pData[i]; + pCtx->param[1].i64 = pData[i]; pCtx->param[1].nType = pCtx->inputType; notNullElems++; } @@ -2974,28 +3055,28 @@ static void diff_function(SQLFunctionCtx *pCtx) { } if (pCtx->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { // initial value is not set yet - pCtx->param[1].i64Key = pData[i]; + pCtx->param[1].i64 = pData[i]; pCtx->param[1].nType = pCtx->inputType; } else if ((i == 0 && pCtx->order == TSDB_ORDER_ASC) || (i == pCtx->size - 1 && pCtx->order == TSDB_ORDER_DESC)) { - *pOutput = pData[i] - pCtx->param[1].i64Key; + *pOutput = pData[i] - pCtx->param[1].i64; *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; } else { - *pOutput = pData[i] - pCtx->param[1].i64Key; + *pOutput = pData[i] - pCtx->param[1].i64; *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; } - pCtx->param[1].i64Key = pData[i]; + pCtx->param[1].i64 = pData[i]; pCtx->param[1].nType = pCtx->inputType; notNullElems++; } break; - }; + } case TSDB_DATA_TYPE_DOUBLE: { double *pData = (double *)data; double *pOutput = (double *)pCtx->aOutputBuf; @@ -3025,7 +3106,7 @@ static void diff_function(SQLFunctionCtx *pCtx) { notNullElems++; } break; - }; + } case TSDB_DATA_TYPE_FLOAT: { float *pData = (float *)data; float *pOutput = (float *)pCtx->aOutputBuf; @@ -3058,7 +3139,7 @@ static void diff_function(SQLFunctionCtx *pCtx) { notNullElems++; } break; - }; + } case TSDB_DATA_TYPE_SMALLINT: { int16_t *pData = (int16_t *)data; int16_t *pOutput = (int16_t *)pCtx->aOutputBuf; @@ -3069,27 +3150,27 @@ static void diff_function(SQLFunctionCtx *pCtx) { } if (pCtx->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { // initial value is not set yet - pCtx->param[1].i64Key = pData[i]; + pCtx->param[1].i64 = pData[i]; pCtx->param[1].nType = pCtx->inputType; } else if ((i == 0 && pCtx->order == TSDB_ORDER_ASC) || (i == pCtx->size - 1 && pCtx->order == TSDB_ORDER_DESC)) { - *pOutput = (int16_t)(pData[i] - pCtx->param[1].i64Key); + *pOutput = (int16_t)(pData[i] - pCtx->param[1].i64); *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; } else { - *pOutput = (int16_t)(pData[i] - pCtx->param[1].i64Key); + *pOutput = (int16_t)(pData[i] - pCtx->param[1].i64); *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; } - pCtx->param[1].i64Key = pData[i]; + pCtx->param[1].i64 = pData[i]; pCtx->param[1].nType = pCtx->inputType; notNullElems++; } break; - }; + } case TSDB_DATA_TYPE_TINYINT: { int8_t *pData = (int8_t *)data; int8_t *pOutput = (int8_t *)pCtx->aOutputBuf; @@ -3100,30 +3181,30 @@ static void diff_function(SQLFunctionCtx *pCtx) { } if (pCtx->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { // initial value is not set yet - pCtx->param[1].i64Key = pData[i]; + pCtx->param[1].i64 = pData[i]; pCtx->param[1].nType = pCtx->inputType; } else if ((i == 0 && pCtx->order == TSDB_ORDER_ASC) || (i == pCtx->size - 1 && pCtx->order == TSDB_ORDER_DESC)) { - *pOutput = (int8_t)(pData[i] - pCtx->param[1].i64Key); + *pOutput = (int8_t)(pData[i] - pCtx->param[1].i64); *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; } else { - *pOutput = (int8_t)(pData[i] - pCtx->param[1].i64Key); + *pOutput = (int8_t)(pData[i] - pCtx->param[1].i64); *pTimestamp = tsList[i]; pOutput += 1; pTimestamp += 1; } - pCtx->param[1].i64Key = pData[i]; + pCtx->param[1].i64 = pData[i]; pCtx->param[1].nType = pCtx->inputType; notNullElems++; } break; - }; + } default: - tscError("error input type"); + qError("error input type"); } // initial value is not set yet @@ -3147,10 +3228,10 @@ static void diff_function(SQLFunctionCtx *pCtx) { do { \ if ((ctx)->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { \ (ctx)->param[1].nType = (ctx)->inputType; \ - *(type *)&(ctx)->param[1].i64Key = *(type *)(d); \ + *(type *)&(ctx)->param[1].i64 = *(type *)(d); \ } else { \ - *(type *)(ctx)->aOutputBuf = *(type *)(d) - (*(type *)(&(ctx)->param[1].i64Key)); \ - *(type *)(&(ctx)->param[1].i64Key) = *(type *)(d); \ + *(type *)(ctx)->aOutputBuf = *(type *)(d) - (*(type *)(&(ctx)->param[1].i64)); \ + *(type *)(&(ctx)->param[1].i64) = *(type *)(d); \ *(int64_t *)(ctx)->ptsOutputBuf = GET_TS_DATA(ctx, index); \ } \ } while (0); @@ -3172,10 +3253,10 @@ static void diff_function_f(SQLFunctionCtx *pCtx, int32_t index) { case TSDB_DATA_TYPE_INT: { if (pCtx->param[1].nType == INITIAL_VALUE_NOT_ASSIGNED) { // initial value is not set yet pCtx->param[1].nType = pCtx->inputType; - pCtx->param[1].i64Key = *(int32_t *)pData; + pCtx->param[1].i64 = *(int32_t *)pData; } else { - *(int32_t *)pCtx->aOutputBuf = *(int32_t *)pData - (int32_t)pCtx->param[1].i64Key; - pCtx->param[1].i64Key = *(int32_t *)pData; + *(int32_t *)pCtx->aOutputBuf = *(int32_t *)pData - (int32_t)pCtx->param[1].i64; + pCtx->param[1].i64 = *(int32_t *)pData; *(int64_t *)pCtx->ptsOutputBuf = GET_TS_DATA(pCtx, index); } break; @@ -3201,7 +3282,7 @@ static void diff_function_f(SQLFunctionCtx *pCtx, int32_t index) { break; }; default: - tscError("error input type"); + qError("error input type"); } if (GET_RES_INFO(pCtx)->numOfRes > 0) { @@ -3297,17 +3378,17 @@ static void spread_function(SQLFunctionCtx *pCtx) { if (numOfElems == 0) { goto _spread_over; } - - if ((pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_BIGINT) || + + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inputType) || IS_UNSIGNED_NUMERIC_TYPE(pCtx->inputType) || (pCtx->inputType == TSDB_DATA_TYPE_TIMESTAMP)) { if (pInfo->min > pCtx->preAggVals.statis.min) { pInfo->min = (double)pCtx->preAggVals.statis.min; } - + if (pInfo->max < pCtx->preAggVals.statis.max) { pInfo->max = (double)pCtx->preAggVals.statis.max; } - } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE || pCtx->inputType == TSDB_DATA_TYPE_FLOAT) { + } else if (IS_FLOAT_TYPE(pCtx->inputType)) { if (pInfo->min > GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.min))) { pInfo->min = GET_DOUBLE_VAL((const char *)&(pCtx->preAggVals.statis.min)); } @@ -3402,7 +3483,7 @@ static void spread_function_f(SQLFunctionCtx *pCtx, int32_t index) { * here we set the result value back to the intermediate buffer, to apply the finalize the function * the final result is generated in spread_function_finalizer */ -void spread_func_sec_merge(SQLFunctionCtx *pCtx) { +void spread_func_merge(SQLFunctionCtx *pCtx) { SSpreadInfo *pData = (SSpreadInfo *)GET_INPUT_DATA_LIST(pCtx); if (pData->hasResult != DATA_SET_FLAG) { return; @@ -3436,8 +3517,7 @@ void spread_function_finalizer(SQLFunctionCtx *pCtx) { *(double *)pCtx->aOutputBuf = pCtx->param[3].dKey - pCtx->param[0].dKey; } else { - assert((pCtx->inputType >= TSDB_DATA_TYPE_TINYINT && pCtx->inputType <= TSDB_DATA_TYPE_DOUBLE) || - (pCtx->inputType == TSDB_DATA_TYPE_TIMESTAMP)); + 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) { @@ -3802,11 +3882,11 @@ static void ts_comp_function(SQLFunctionCtx *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].i64Key, &pCtx->tag, input, pCtx->size * TSDB_KEYSIZE); + tsBufAppend(pTSbuf, (int32_t)pCtx->param[0].i64, &pCtx->tag, input, pCtx->size * TSDB_KEYSIZE); } else { for (int32_t i = pCtx->size - 1; i >= 0; --i) { char *d = GET_INPUT_DATA(pCtx, i); - tsBufAppend(pTSbuf, (int32_t)pCtx->param[0].i64Key, &pCtx->tag, d, (int32_t)TSDB_KEYSIZE); + tsBufAppend(pTSbuf, (int32_t)pCtx->param[0].i64, &pCtx->tag, d, (int32_t)TSDB_KEYSIZE); } } @@ -3825,7 +3905,7 @@ static void ts_comp_function_f(SQLFunctionCtx *pCtx, int32_t index) { STSBuf *pTSbuf = pInfo->pTSBuf; - tsBufAppend(pTSbuf, (int32_t)pCtx->param[0].i64Key, &pCtx->tag, pData, TSDB_KEYSIZE); + tsBufAppend(pTSbuf, (int32_t)pCtx->param[0].i64, &pCtx->tag, pData, TSDB_KEYSIZE); SET_VAL(pCtx, pCtx->size, 1); pResInfo->hasResult = DATA_SET_FLAG; @@ -3873,7 +3953,7 @@ static double do_calc_rate(const SRateInfo* pRateInfo) { double resultVal = ((double)diff) / duration; - tscDebug("do_calc_rate() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " resultVal:%f", + qDebug("do_calc_rate() isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " resultVal:%f", pRateInfo->isIRate, pRateInfo->firstKey, pRateInfo->lastKey, pRateInfo->firstValue, pRateInfo->lastValue, pRateInfo->CorrectionValue, resultVal); return resultVal; @@ -3907,12 +3987,12 @@ static void rate_function(SQLFunctionCtx *pCtx) { SRateInfo *pRateInfo = (SRateInfo *)GET_ROWCELL_INTERBUF(pResInfo); TSKEY *primaryKey = GET_TS_LIST(pCtx); - tscDebug("%p rate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull); + 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)) { - tscDebug("%p rate_function() index of null data:%d", pCtx, i); + qDebug("%p rate_function() index of null data:%d", pCtx, i); continue; } @@ -3925,19 +4005,19 @@ static void rate_function(SQLFunctionCtx *pCtx) { pRateInfo->firstValue = v; pRateInfo->firstKey = primaryKey[i]; - tscDebug("firstValue:%" PRId64 " firstKey:%" PRId64, pRateInfo->firstValue, pRateInfo->firstKey); + qDebug("firstValue:%" PRId64 " firstKey:%" PRId64, pRateInfo->firstValue, pRateInfo->firstKey); } if (INT64_MIN == pRateInfo->lastValue) { pRateInfo->lastValue = v; } else if (v < pRateInfo->lastValue) { pRateInfo->CorrectionValue += pRateInfo->lastValue; - tscDebug("CorrectionValue:%" PRId64, pRateInfo->CorrectionValue); + qDebug("CorrectionValue:%" PRId64, pRateInfo->CorrectionValue); } pRateInfo->lastValue = v; pRateInfo->lastKey = primaryKey[i]; - tscDebug("lastValue:%" PRId64 " lastKey:%" PRId64, pRateInfo->lastValue, pRateInfo->lastKey); + qDebug("lastValue:%" PRId64 " lastKey:%" PRId64, pRateInfo->lastValue, pRateInfo->lastKey); } if (!pCtx->hasNull) { @@ -3985,7 +4065,7 @@ static void rate_function_f(SQLFunctionCtx *pCtx, int32_t index) { pRateInfo->lastValue = v; pRateInfo->lastKey = primaryKey[index]; - tscDebug("====%p rate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " CorrectionValue:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->CorrectionValue); + qDebug("====%p rate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " CorrectionValue:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->CorrectionValue); SET_VAL(pCtx, 1, 1); @@ -4007,7 +4087,7 @@ static void rate_func_copy(SQLFunctionCtx *pCtx) { pResInfo->hasResult = ((SRateInfo*)pCtx->aInputElemBuf)->hasResult; SRateInfo* pRateInfo = (SRateInfo*)pCtx->aInputElemBuf; - tscDebug("%p rate_func_merge() firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d", + qDebug("%p rate_func_merge() firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d", pCtx, pRateInfo->firstKey, pRateInfo->lastKey, pRateInfo->firstValue, pRateInfo->lastValue, pRateInfo->CorrectionValue, pRateInfo->hasResult); } @@ -4015,7 +4095,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); SRateInfo *pRateInfo = (SRateInfo *)GET_ROWCELL_INTERBUF(pResInfo); - tscDebug("%p isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d", + qDebug("%p isIRate:%d firstKey:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " lastValue:%" PRId64 " CorrectionValue:%" PRId64 " hasResult:%d", pCtx, pRateInfo->isIRate, pRateInfo->firstKey, pRateInfo->lastKey, pRateInfo->firstValue, pRateInfo->lastValue, pRateInfo->CorrectionValue, pRateInfo->hasResult); if (pRateInfo->hasResult != DATA_SET_FLAG) { @@ -4025,7 +4105,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) { *(double*)pCtx->aOutputBuf = do_calc_rate(pRateInfo); - tscDebug("rate_finalizer() output result:%f", *(double *)pCtx->aOutputBuf); + qDebug("rate_finalizer() output result:%f", *(double *)pCtx->aOutputBuf); // cannot set the numOfIteratedElems again since it is set during previous iteration pResInfo->numOfRes = 1; @@ -4041,7 +4121,7 @@ static void irate_function(SQLFunctionCtx *pCtx) { SRateInfo *pRateInfo = (SRateInfo *)GET_ROWCELL_INTERBUF(pResInfo); TSKEY *primaryKey = GET_TS_LIST(pCtx); - tscDebug("%p irate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull); + qDebug("%p irate_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull); if (pCtx->size < 1) { return; @@ -4050,7 +4130,7 @@ static void irate_function(SQLFunctionCtx *pCtx) { for (int32_t i = pCtx->size - 1; i >= 0; --i) { char *pData = GET_INPUT_DATA(pCtx, i); if (pCtx->hasNull && isNull(pData, pCtx->inputType)) { - tscDebug("%p irate_function() index of null data:%d", pCtx, i); + qDebug("%p irate_function() index of null data:%d", pCtx, i); continue; } @@ -4064,7 +4144,7 @@ static void irate_function(SQLFunctionCtx *pCtx) { pRateInfo->lastValue = v; pRateInfo->lastKey = primaryKey[i]; - tscDebug("%p irate_function() lastValue:%" PRId64 " lastKey:%" PRId64, pCtx, pRateInfo->lastValue, pRateInfo->lastKey); + qDebug("%p irate_function() lastValue:%" PRId64 " lastKey:%" PRId64, pCtx, pRateInfo->lastValue, pRateInfo->lastKey); continue; } @@ -4072,7 +4152,7 @@ static void irate_function(SQLFunctionCtx *pCtx) { pRateInfo->firstValue = v; pRateInfo->firstKey = primaryKey[i]; - tscDebug("%p irate_function() firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, pRateInfo->firstValue, pRateInfo->firstKey); + qDebug("%p irate_function() firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, pRateInfo->firstValue, pRateInfo->firstKey); break; } } @@ -4110,7 +4190,7 @@ static void irate_function_f(SQLFunctionCtx *pCtx, int32_t index) { pRateInfo->lastValue = v; pRateInfo->lastKey = primaryKey[index]; - tscDebug("====%p irate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->firstValue , pRateInfo->firstKey); + qDebug("====%p irate_function_f() index:%d lastValue:%" PRId64 " lastKey:%" PRId64 " firstValue:%" PRId64 " firstKey:%" PRId64, pCtx, index, pRateInfo->lastValue, pRateInfo->lastKey, pRateInfo->firstValue , pRateInfo->firstKey); SET_VAL(pCtx, 1, 1); @@ -4134,7 +4214,7 @@ static void do_sumrate_merge(SQLFunctionCtx *pCtx) { for (int32_t i = 0; i < pCtx->size; ++i, input += pCtx->inputBytes) { SRateInfo *pInput = (SRateInfo *)input; - tscDebug("%p do_sumrate_merge() hasResult:%d input num:%" PRId64 " input sum:%f total num:%" PRId64 " total sum:%f", pCtx, pInput->hasResult, pInput->num, pInput->sum, pRateInfo->num, pRateInfo->sum); + qDebug("%p do_sumrate_merge() hasResult:%d input num:%" PRId64 " input sum:%f total num:%" PRId64 " total sum:%f", pCtx, pInput->hasResult, pInput->num, pInput->sum, pRateInfo->num, pRateInfo->sum); if (pInput->hasResult != DATA_SET_FLAG) { continue; @@ -4157,7 +4237,7 @@ static void do_sumrate_merge(SQLFunctionCtx *pCtx) { } static void sumrate_func_merge(SQLFunctionCtx *pCtx) { - tscDebug("%p sumrate_func_merge() process ...", pCtx); + qDebug("%p sumrate_func_merge() process ...", pCtx); do_sumrate_merge(pCtx); } @@ -4165,7 +4245,7 @@ static void sumrate_finalizer(SQLFunctionCtx *pCtx) { SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx); SRateInfo *pRateInfo = (SRateInfo *)GET_ROWCELL_INTERBUF(pResInfo); - tscDebug("%p sumrate_finalizer() superTableQ:%d num:%" PRId64 " sum:%f hasResult:%d", pCtx, pCtx->stableQuery, pRateInfo->num, pRateInfo->sum, pRateInfo->hasResult); + qDebug("%p sumrate_finalizer() superTableQ:%d num:%" PRId64 " sum:%f hasResult:%d", pCtx, pCtx->stableQuery, pRateInfo->num, pRateInfo->sum, pRateInfo->hasResult); if (pRateInfo->hasResult != DATA_SET_FLAG) { setNull(pCtx->aOutputBuf, TSDB_DATA_TYPE_DOUBLE, sizeof(double)); @@ -4408,7 +4488,7 @@ SQLAggFuncElem aAggs[] = {{ spread_function_f, no_next_step, spread_function_finalizer, - spread_func_sec_merge, + spread_func_merge, count_load_data_info, }, { diff --git a/src/query/src/qArithmeticOperator.c b/src/query/src/qArithmeticOperator.c index 0955d48df0..27bdd4372b 100644 --- a/src/query/src/qArithmeticOperator.c +++ b/src/query/src/qArithmeticOperator.c @@ -21,29 +21,29 @@ #define ARRAY_LIST_OP(left, right, _left_type, _right_type, len1, len2, out, op, _res_type, _ord) \ { \ - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; \ - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; \ + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; \ + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; \ \ if ((len1) == (len2)) { \ - for (; i < (len2) && i >= 0; i += step, (out) += 1) { \ + for (; i < (len2) && i >= 0; i += step, (out) += 1) { \ if (isNull((char *)&((left)[i]), _left_type) || isNull((char *)&((right)[i]), _right_type)) { \ - setNull((char *)(out), _res_type, tDataTypeDesc[_res_type].nSize); \ + SET_DOUBLE_NULL(out); \ continue; \ } \ *(out) = (double)(left)[i] op(right)[i]; \ } \ } else if ((len1) == 1) { \ - for (; i >= 0 && i < (len2); i += step, (out) += 1) { \ + for (; i >= 0 && i < (len2); i += step, (out) += 1) { \ if (isNull((char *)(left), _left_type) || isNull((char *)&(right)[i], _right_type)) { \ - setNull((char *)(out), _res_type, tDataTypeDesc[_res_type].nSize); \ + SET_DOUBLE_NULL(out); \ continue; \ } \ *(out) = (double)(left)[0] op(right)[i]; \ } \ } else if ((len2) == 1) { \ - for (; i >= 0 && i < (len1); i += step, (out) += 1) { \ + for (; i >= 0 && i < (len1); i += step, (out) += 1) { \ if (isNull((char *)&(left)[i], _left_type) || isNull((char *)(right), _right_type)) { \ - setNull((char *)(out), _res_type, tDataTypeDesc[_res_type].nSize); \ + SET_DOUBLE_NULL(out); \ continue; \ } \ *(out) = (double)(left)[i] op(right)[0]; \ @@ -53,29 +53,29 @@ #define ARRAY_LIST_OP_REM(left, right, _left_type, _right_type, len1, len2, out, op, _res_type, _ord) \ { \ - int32_t i = (_ord == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; \ - int32_t step = (_ord == TSDB_ORDER_ASC) ? 1 : -1; \ + int32_t i = (_ord == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; \ + int32_t step = (_ord == TSDB_ORDER_ASC) ? 1 : -1; \ \ if (len1 == (len2)) { \ - for (; i >= 0 && i < (len2); i += step, (out) += 1) { \ + for (; i >= 0 && i < (len2); i += step, (out) += 1) { \ if (isNull((char *)&(left[i]), _left_type) || isNull((char *)&(right[i]), _right_type)) { \ - setNull((char *)(out), _res_type, tDataTypeDesc[_res_type].nSize); \ + SET_DOUBLE_NULL(out); \ continue; \ } \ *(out) = (double)(left)[i] - ((int64_t)(((double)(left)[i]) / (right)[i])) * (right)[i]; \ } \ } else if (len1 == 1) { \ - for (; i >= 0 && i < (len2); i += step, (out) += 1) { \ + for (; i >= 0 && i < (len2); i += step, (out) += 1) { \ if (isNull((char *)(left), _left_type) || isNull((char *)&((right)[i]), _right_type)) { \ - setNull((char *)(out), _res_type, tDataTypeDesc[_res_type].nSize); \ + SET_DOUBLE_NULL(out); \ continue; \ } \ *(out) = (double)(left)[0] - ((int64_t)(((double)(left)[0]) / (right)[i])) * (right)[i]; \ } \ } else if ((len2) == 1) { \ - for (; i >= 0 && i < len1; i += step, (out) += 1) { \ + for (; i >= 0 && i < len1; i += step, (out) += 1) { \ if (isNull((char *)&((left)[i]), _left_type) || isNull((char *)(right), _right_type)) { \ - setNull((char *)(out), _res_type, tDataTypeDesc[_res_type].nSize); \ + SET_DOUBLE_NULL(out); \ continue; \ } \ *(out) = (double)(left)[i] - ((int64_t)(((double)(left)[i]) / (right)[0])) * (right)[0]; \ @@ -99,10 +99,42 @@ _type_right *pRight = (_type_right *)(right); \ _type_res * pOutput = (_type_res *)(out); -#define TYPE_CONVERT(left, right, out, _type_left, _type_right) \ - TYPE_CONVERT_DOUBLE_RES(left, right, out, _type_left, _type_right, double) +#define DO_VECTOR_ADD(left, numLeft, leftType, leftOriginType, right, numRight, rightType, rightOriginType, _output, \ + _order) \ + do { \ + TYPE_CONVERT_DOUBLE_RES(left, right, _output, leftOriginType, rightOriginType, double); \ + ARRAY_LIST_ADD(pLeft, pRight, leftType, rightType, numLeft, numRight, pOutput, _order); \ + } while (0) -void calc_fn_i32_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +#define DO_VECTOR_SUB(left, numLeft, leftType, leftOriginType, right, numRight, rightType, rightOriginType, _output, \ + _order) \ + do { \ + TYPE_CONVERT_DOUBLE_RES(left, right, _output, leftOriginType, rightOriginType, double); \ + ARRAY_LIST_SUB(pLeft, pRight, leftType, rightType, numLeft, numRight, pOutput, _order); \ + } while (0) + +#define DO_VECTOR_MULTIPLY(left, numLeft, leftType, leftOriginType, right, numRight, rightType, rightOriginType, \ + _output, _order) \ + do { \ + TYPE_CONVERT_DOUBLE_RES(left, right, _output, leftOriginType, rightOriginType, double); \ + ARRAY_LIST_MULTI(pLeft, pRight, leftType, rightType, numLeft, numRight, pOutput, _order); \ + } while (0) + +#define DO_VECTOR_DIVIDE(left, numLeft, leftType, leftOriginType, right, numRight, rightType, rightOriginType, \ + _output, _order) \ + do { \ + TYPE_CONVERT_DOUBLE_RES(left, right, _output, leftOriginType, rightOriginType, double); \ + ARRAY_LIST_DIV(pLeft, pRight, leftType, rightType, numLeft, numRight, pOutput, _order); \ + } while (0) + +#define DO_VECTOR_REMAINDER(left, numLeft, leftType, leftOriginType, right, numRight, rightType, rightOriginType, \ + _output, _order) \ + do { \ + TYPE_CONVERT_DOUBLE_RES(left, right, _output, leftOriginType, rightOriginType, double); \ + ARRAY_LIST_REM(pLeft, pRight, leftType, rightType, numLeft, numRight, pOutput, _order); \ + } while (0) + +void calc_i32_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { int32_t *pLeft = (int32_t *)left; int32_t *pRight = (int32_t *)right; double * pOutput = (double *)output; @@ -139,168 +171,2568 @@ void calc_fn_i32_i32_add(void *left, void *right, int32_t numLeft, int32_t numRi } } -void calc_fn_i32_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void vectorAdd(void *left, int32_t numLeft, int32_t leftType, void *right, int32_t numRight, int32_t rightType, + void *output, int32_t order) { + switch(leftType) { + case TSDB_DATA_TYPE_TINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, int8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, uint8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, int16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, uint16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_INT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, int32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, uint32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_BIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, int64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, uint64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_FLOAT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, float, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_ADD(left, numLeft, leftType, double, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + default:; + } +} + +void vectorSub(void *left, int32_t numLeft, int32_t leftType, void *right, int32_t numRight, int32_t rightType, + void *output, int32_t order) { + switch(leftType) { + case TSDB_DATA_TYPE_TINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, int8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, uint8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, int16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, uint16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_INT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, int32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, uint32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_BIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, int64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, uint64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_FLOAT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, float, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_SUB(left, numLeft, leftType, double, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + default:; + } +} + +void vectorMultiply(void *left, int32_t numLeft, int32_t leftType, void *right, int32_t numRight, int32_t rightType, + void *output, int32_t order) { + switch(leftType) { + case TSDB_DATA_TYPE_TINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_INT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_BIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, int64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, uint64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_FLOAT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, float, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_MULTIPLY(left, numLeft, leftType, double, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + default:; + } +} + +void vectorDivide(void *left, int32_t numLeft, int32_t leftType, void *right, int32_t numRight, int32_t rightType, + void *output, int32_t order) { + switch(leftType) { + case TSDB_DATA_TYPE_TINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_INT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_BIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, int64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, uint64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_FLOAT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, float, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_DIVIDE(left, numLeft, leftType, double, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + default:; + } +} + +void vectorRemainder(void *left, int32_t numLeft, int32_t leftType, void *right, int32_t numRight, int32_t rightType, + void *output, int32_t order) { + switch(leftType) { + case TSDB_DATA_TYPE_TINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint8_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint16_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_INT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint32_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_BIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, int64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, uint64_t, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_FLOAT: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, float, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + switch (rightType) { + case TSDB_DATA_TYPE_TINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, int8_t, output, order); + break; + } + case TSDB_DATA_TYPE_UTINYINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, uint8_t, output, order); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, int16_t, output, order); + break; + } + case TSDB_DATA_TYPE_USMALLINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, uint16_t, output, order); + break; + } + case TSDB_DATA_TYPE_INT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, int32_t, output, order); + break; + } + case TSDB_DATA_TYPE_UINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, uint32_t, output, order); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, int64_t, output, order); + break; + } + case TSDB_DATA_TYPE_UBIGINT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, uint64_t, output, order); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, float, output, order); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + DO_VECTOR_REMAINDER(left, numLeft, leftType, double, right, numRight, rightType, double, output, order); + break; + } + default: + assert(0); + } + break; + } + default:; + } +} + +/* +void calc_i32_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int8_t) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int16_t) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int64_t); ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, float) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, double) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int8_t) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_u8_u8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + TYPE_CONVERT(left, right, output, uint8_t, uint8_t) + ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_UTINYINT, TSDB_DATA_TYPE_UTINYINT, numLeft, numRight, pOutput, order); +} + +void calc_i8_u8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + TYPE_CONVERT(left, right, output, int8_t, uint8_t) + ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_UTINYINT, numLeft, numRight, pOutput, order); +} + +void calc_u8_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i8_u8_add(right, left, numRight, numLeft, output, order); +} + +void calc_i8_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int16_t) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_i8_add(right, left, numRight, numLeft, output, order); +void calc_i8_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_i8_add(right, left, numRight, numLeft, output, order); } -void calc_fn_i8_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int64_t) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, float) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, double) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i8_i16_add(right, left, numRight, numLeft, output, order); +void calc_i16_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i8_i16_add(right, left, numRight, numLeft, output, order); } -void calc_fn_i16_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int16_t) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_i16_add(right, left, numRight, numLeft, output, order); +void calc_i16_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_i16_add(right, left, numRight, numLeft, output, order); } -void calc_fn_i16_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int64_t) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, float) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, double) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i8_i64_add(right, left, numRight, numLeft, output, order); +void calc_i64_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i8_i64_add(right, left, numRight, numLeft, output, order); } -void calc_fn_i64_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i16_i64_add(right, left, numRight, numLeft, output, order); +void calc_i64_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i16_i64_add(right, left, numRight, numLeft, output, order); } -void calc_fn_i64_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_i64_add(right, left, numRight, numLeft, output, order); +void calc_i64_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_i64_add(right, left, numRight, numLeft, output, order); } -void calc_fn_i64_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int64_t) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, float) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, double) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_f_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i8_f_add(right, left, numRight, numLeft, output, order); +void calc_f_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i8_f_add(right, left, numRight, numLeft, output, order); } -void calc_fn_f_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i16_f_add(right, left, numRight, numLeft, output, order); +void calc_f_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i16_f_add(right, left, numRight, numLeft, output, order); } -void calc_fn_f_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_f_add(right, left, numRight, numLeft, output, order); +void calc_f_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_f_add(right, left, numRight, numLeft, output, order); } -void calc_fn_f_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i64_f_add(right, left, numRight, numLeft, output, order); +void calc_f_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i64_f_add(right, left, numRight, numLeft, output, order); } -void calc_fn_f_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, float) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_f_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, double) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_d_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i8_d_add(right, left, numRight, numLeft, output, order); +void calc_d_i8_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i8_d_add(right, left, numRight, numLeft, output, order); } -void calc_fn_d_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i16_d_add(right, left, numRight, numLeft, output, order); +void calc_d_i16_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i16_d_add(right, left, numRight, numLeft, output, order); } -void calc_fn_d_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_d_add(right, left, numRight, numLeft, output, order); +void calc_d_i32_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_d_add(right, left, numRight, numLeft, output, order); } -void calc_fn_d_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i64_d_add(right, left, numRight, numLeft, output, order); +void calc_d_i64_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i64_d_add(right, left, numRight, numLeft, output, order); } -void calc_fn_d_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_f_d_add(right, left, numRight, numLeft, output, order); +void calc_d_f_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_f_d_add(right, left, numRight, numLeft, output, order); } -void calc_fn_d_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_d_add(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, double) ARRAY_LIST_ADD(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void calc_fn_i32_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { int32_t *pLeft = (int32_t *)left; int32_t *pRight = (int32_t *)right; double * pOutput = (double *)output; @@ -335,183 +2767,183 @@ void calc_fn_i32_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRi } } -void calc_fn_i32_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int8_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int16_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int64_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, float) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, double) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int8_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int16_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int32_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int64_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, float) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, double) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int8_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int16_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int32_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int64_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, float) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, double) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int8_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int16_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int32_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int64_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, float) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, double) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_f_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int8_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_f_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int16_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_f_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int32_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_f_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int64_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_f_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, float) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_f_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, double) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_d_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i8_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int8_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_d_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i16_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int16_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_d_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i32_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int32_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_d_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i64_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int64_t) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_d_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_f_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, float) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_d_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_d_sub(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, double) ARRAY_LIST_SUB(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// -void calc_fn_i32_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { int32_t *pLeft = (int32_t *)left; int32_t *pRight = (int32_t *)right; double * pOutput = (double *)output; @@ -548,168 +2980,168 @@ void calc_fn_i32_i32_multi(void *left, void *right, int32_t numLeft, int32_t num } } -void calc_fn_i32_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int8_t) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int16_t) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int64_t) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, float) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, double) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int8_t) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int16_t) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_i8_multi(right, left, numRight, numLeft, output, order); +void calc_i8_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_i8_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_i8_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int64_t) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, float) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, double) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i8_i16_multi(right, left, numRight, numLeft, output, order); +void calc_i16_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i8_i16_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_i16_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int16_t) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_i16_multi(right, left, numRight, numLeft, output, order); +void calc_i16_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_i16_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_i16_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int64_t) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, float) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, double) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i8_i64_multi(right, left, numRight, numLeft, output, order); +void calc_i64_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i8_i64_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_i64_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i16_i64_multi(right, left, numRight, numLeft, output, order); +void calc_i64_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i16_i64_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_i64_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_i64_multi(right, left, numRight, numLeft, output, order); +void calc_i64_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_i64_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_i64_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int64_t) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, float) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, double) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_f_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i8_f_multi(right, left, numRight, numLeft, output, order); +void calc_f_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i8_f_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_f_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i16_f_multi(right, left, numRight, numLeft, output, order); +void calc_f_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i16_f_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_f_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_f_multi(right, left, numRight, numLeft, output, order); +void calc_f_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_f_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_f_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i64_f_multi(right, left, numRight, numLeft, output, order); +void calc_f_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i64_f_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_f_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, float) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_f_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, double) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_d_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i8_d_multi(right, left, numRight, numLeft, output, order); +void calc_d_i8_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i8_d_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_d_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i16_d_multi(right, left, numRight, numLeft, output, order); +void calc_d_i16_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i16_d_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_d_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i32_d_multi(right, left, numRight, numLeft, output, order); +void calc_d_i32_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i32_d_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_d_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_i64_d_multi(right, left, numRight, numLeft, output, order); +void calc_d_i64_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_i64_d_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_d_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { - calc_fn_f_d_multi(right, left, numRight, numLeft, output, order); +void calc_d_f_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { + calc_f_d_multi(right, left, numRight, numLeft, output, order); } -void calc_fn_d_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_d_multi(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, double) ARRAY_LIST_MULTI(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } //////////////////////////////////////////////////////////////////////////////////////////////////////////// -void calc_fn_i32_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { int32_t *pLeft = (int32_t *)left; int32_t *pRight = (int32_t *)right; double * pOutput = (double *)output; @@ -746,184 +3178,184 @@ void calc_fn_i32_i32_div(void *left, void *right, int32_t numLeft, int32_t numRi } } -void calc_fn_i32_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int8_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int16_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int64_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, float) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, double) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int8_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int16_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int32_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int64_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, float) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, double) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int8_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int16_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int32_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int64_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, float) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, double) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int8_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int16_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int32_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int64_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, float) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, double) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_f_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int8_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_f_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int16_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_f_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int32_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_f_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int64_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_f_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, float) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_f_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, double) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_d_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i8_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int8_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_d_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i16_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int16_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_d_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i32_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int32_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_d_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i64_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int64_t) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_d_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_f_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, float) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_d_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_d_div(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, double) ARRAY_LIST_DIV(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } //////////////////////////////////////////////////////////////////////////////////////////////////////////// -void calc_fn_i32_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { int32_t *pLeft = (int32_t *)left; int32_t *pRight = (int32_t *)right; double * pOutput = (double *)output; @@ -961,27 +3393,27 @@ void calc_fn_i32_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRi } } -void calc_fn_i32_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int8_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int16_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, int64_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int32_t, float) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i32_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i32_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { int32_t *pLeft = (int32_t *)left; double * pRight = (double *)right; double * pOutput = (double *)output; @@ -1019,238 +3451,241 @@ void calc_fn_i32_d_rem(void *left, void *right, int32_t numLeft, int32_t numRigh } } -void calc_fn_i8_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int8_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int16_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int32_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, int64_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, float) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i8_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i8_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int8_t, double) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int8_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int16_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int32_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, int64_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, float) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i16_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i16_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int16_t, double) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int8_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int16_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int32_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, int64_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, float) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_i64_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_i64_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, int64_t, double) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_f_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int8_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_f_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int16_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_f_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int32_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_f_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, int64_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_f_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, float) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_f_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_f_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, float, double) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -void calc_fn_d_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i8_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int8_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_TINYINT, numLeft, numRight, pOutput, order); } -void calc_fn_d_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i16_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int16_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_SMALLINT, numLeft, numRight, pOutput, order); } -void calc_fn_d_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i32_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int32_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_INT, numLeft, numRight, pOutput, order); } -void calc_fn_d_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_i64_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, int64_t) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_BIGINT, numLeft, numRight, pOutput, order); } -void calc_fn_d_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_f_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, float) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_FLOAT, numLeft, numRight, pOutput, order); } -void calc_fn_d_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { +void calc_d_d_rem(void *left, void *right, int32_t numLeft, int32_t numRight, void *output, int32_t order) { TYPE_CONVERT(left, right, output, double, double) ARRAY_LIST_REM(pLeft, pRight, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_DOUBLE, numLeft, numRight, pOutput, order); } -/* +* * the following are two-dimensional array list of callback function . */ -_bi_consumer_fn_t add_function_arraylist[8][10] = { - /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary*/ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // EMPTY, - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_BOOL, - {NULL, NULL, calc_fn_i8_i8_add, calc_fn_i8_i16_add, calc_fn_i8_i32_add, calc_fn_i8_i64_add, calc_fn_i8_f_add, calc_fn_i8_d_add, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT - {NULL, NULL, calc_fn_i16_i8_add, calc_fn_i16_i16_add, calc_fn_i16_i32_add, calc_fn_i16_i64_add, calc_fn_i16_f_add, calc_fn_i16_d_add, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT - {NULL, NULL, calc_fn_i32_i8_add, calc_fn_i32_i16_add, calc_fn_i32_i32_add, calc_fn_i32_i64_add, calc_fn_i32_f_add, calc_fn_i32_d_add, NULL, NULL}, // TSDB_DATA_TYPE_INT - {NULL, NULL, calc_fn_i64_i8_add, calc_fn_i64_i16_add, calc_fn_i64_i32_add, calc_fn_i64_i64_add, calc_fn_i64_f_add, calc_fn_i64_d_add, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT - {NULL, NULL, calc_fn_f_i8_add, calc_fn_f_i16_add, calc_fn_f_i32_add, calc_fn_f_i64_add, calc_fn_f_f_add, calc_fn_f_d_add, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT - {NULL, NULL, calc_fn_d_i8_add, calc_fn_d_i16_add, calc_fn_d_i32_add, calc_fn_d_i64_add, calc_fn_d_f_add, calc_fn_d_d_add, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE -}; - -_bi_consumer_fn_t sub_function_arraylist[8][10] = { - /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary*/ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // EMPTY, - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_BOOL, - {NULL, NULL, calc_fn_i8_i8_sub, calc_fn_i8_i16_sub, calc_fn_i8_i32_sub, calc_fn_i8_i64_sub, calc_fn_i8_f_sub, calc_fn_i8_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT - {NULL, NULL, calc_fn_i16_i8_sub, calc_fn_i16_i16_sub, calc_fn_i16_i32_sub, calc_fn_i16_i64_sub, calc_fn_i16_f_sub, calc_fn_i16_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT - {NULL, NULL, calc_fn_i32_i8_sub, calc_fn_i32_i16_sub, calc_fn_i32_i32_sub, calc_fn_i32_i64_sub, calc_fn_i32_f_sub, calc_fn_i32_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_INT - {NULL, NULL, calc_fn_i64_i8_sub, calc_fn_i64_i16_sub, calc_fn_i64_i32_sub, calc_fn_i64_i64_sub, calc_fn_i64_f_sub, calc_fn_i64_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT - {NULL, NULL, calc_fn_f_i8_sub, calc_fn_f_i16_sub, calc_fn_f_i32_sub, calc_fn_f_i64_sub, calc_fn_f_f_sub, calc_fn_f_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT - {NULL, NULL, calc_fn_d_i8_sub, calc_fn_d_i16_sub, calc_fn_d_i32_sub, calc_fn_d_i64_sub, calc_fn_d_f_sub, calc_fn_d_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE -}; - -_bi_consumer_fn_t multi_function_arraylist[][10] = { - /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary*/ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // EMPTY, - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_BOOL, - {NULL, NULL, calc_fn_i8_i8_multi, calc_fn_i8_i16_multi, calc_fn_i8_i32_multi, calc_fn_i8_i64_multi, calc_fn_i8_f_multi, calc_fn_i8_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT - {NULL, NULL, calc_fn_i16_i8_multi, calc_fn_i16_i16_multi, calc_fn_i16_i32_multi, calc_fn_i16_i64_multi, calc_fn_i16_f_multi, calc_fn_i16_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT - {NULL, NULL, calc_fn_i32_i8_multi, calc_fn_i32_i16_multi, calc_fn_i32_i32_multi, calc_fn_i32_i64_multi, calc_fn_i32_f_multi, calc_fn_i32_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_INT - {NULL, NULL, calc_fn_i64_i8_multi, calc_fn_i64_i16_multi, calc_fn_i64_i32_multi, calc_fn_i64_i64_multi, calc_fn_i64_f_multi, calc_fn_i64_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT - {NULL, NULL, calc_fn_f_i8_multi, calc_fn_f_i16_multi, calc_fn_f_i32_multi, calc_fn_f_i64_multi, calc_fn_f_f_multi, calc_fn_f_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT - {NULL, NULL, calc_fn_d_i8_multi, calc_fn_d_i16_multi, calc_fn_d_i32_multi, calc_fn_d_i64_multi, calc_fn_d_f_multi, calc_fn_d_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE -}; - -_bi_consumer_fn_t div_function_arraylist[8][10] = { - /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary*/ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // EMPTY, - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_BOOL, - {NULL, NULL, calc_fn_i8_i8_div, calc_fn_i8_i16_div, calc_fn_i8_i32_div, calc_fn_i8_i64_div, calc_fn_i8_f_div, calc_fn_i8_d_div, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT - {NULL, NULL, calc_fn_i16_i8_div, calc_fn_i16_i16_div, calc_fn_i16_i32_div, calc_fn_i16_i64_div, calc_fn_i16_f_div, calc_fn_i16_d_div, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT - {NULL, NULL, calc_fn_i32_i8_div, calc_fn_i32_i16_div, calc_fn_i32_i32_div, calc_fn_i32_i64_div, calc_fn_i32_f_div, calc_fn_i32_d_div, NULL, NULL}, // TSDB_DATA_TYPE_INT - {NULL, NULL, calc_fn_i64_i8_div, calc_fn_i64_i16_div, calc_fn_i64_i32_div, calc_fn_i64_i64_div, calc_fn_i64_f_div, calc_fn_i64_d_div, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT - {NULL, NULL, calc_fn_f_i8_div, calc_fn_f_i16_div, calc_fn_f_i32_div, calc_fn_f_i64_div, calc_fn_f_f_div, calc_fn_f_d_div, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT - {NULL, NULL, calc_fn_d_i8_div, calc_fn_d_i16_div, calc_fn_d_i32_div, calc_fn_d_i64_div, calc_fn_d_f_div, calc_fn_d_d_div, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE -}; - -_bi_consumer_fn_t rem_function_arraylist[8][10] = { - /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary*/ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // EMPTY, - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_BOOL, - {NULL, NULL, calc_fn_i8_i8_rem, calc_fn_i8_i16_rem, calc_fn_i8_i32_rem, calc_fn_i8_i64_rem, calc_fn_i8_f_rem, calc_fn_i8_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT - {NULL, NULL, calc_fn_i16_i8_rem, calc_fn_i16_i16_rem, calc_fn_i16_i32_rem, calc_fn_i16_i64_rem, calc_fn_i16_f_rem, calc_fn_i16_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT - {NULL, NULL, calc_fn_i32_i8_rem, calc_fn_i32_i16_rem, calc_fn_i32_i32_rem, calc_fn_i32_i64_rem, calc_fn_i32_f_rem, calc_fn_i32_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_INT - {NULL, NULL, calc_fn_i64_i8_rem, calc_fn_i64_i16_rem, calc_fn_i64_i32_rem, calc_fn_i64_i64_rem, calc_fn_i64_f_rem, calc_fn_i64_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT - {NULL, NULL, calc_fn_f_i8_rem, calc_fn_f_i16_rem, calc_fn_f_i32_rem, calc_fn_f_i64_rem, calc_fn_f_f_rem, calc_fn_f_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT - {NULL, NULL, calc_fn_d_i8_rem, calc_fn_d_i16_rem, calc_fn_d_i32_rem, calc_fn_d_i64_rem, calc_fn_d_f_rem, calc_fn_d_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE -}; +//_arithmetic_operator_fn_t add_function_arraylist[15][15] = { +// /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary*/ +// {0}, // EMPTY, +// {0}, // TSDB_DATA_TYPE_BOOL, +// {NULL, NULL, calc_i8_i8_add, calc_i8_i16_add, calc_i8_i32_add, calc_i8_i64_add, calc_i8_f_add, calc_i8_d_add, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT +// {NULL, NULL, calc_i16_i8_add, calc_i16_i16_add, calc_i16_i32_add, calc_i16_i64_add, calc_i16_f_add, calc_i16_d_add, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT +// {NULL, NULL, calc_i32_i8_add, calc_i32_i16_add, calc_i32_i32_add, calc_i32_i64_add, calc_i32_f_add, calc_i32_d_add, NULL, NULL}, // TSDB_DATA_TYPE_INT +// {NULL, NULL, calc_i64_i8_add, calc_i64_i16_add, calc_i64_i32_add, calc_i64_i64_add, calc_i64_f_add, calc_i64_d_add, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT +// {NULL, NULL, calc_f_i8_add, calc_f_i16_add, calc_f_i32_add, calc_f_i64_add, calc_f_f_add, calc_f_d_add, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT +// {NULL, NULL, calc_d_i8_add, calc_d_i16_add, calc_d_i32_add, calc_d_i64_add, calc_d_f_add, calc_d_d_add, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE +// {0}, // TSDB_DATA_TYPE_BINARY, +// {0}, // TSDB_DATA_TYPE_NCHAR, +// {NULL, NULL, calc_u8_i8_add, calc_u8_i16_add, calc_u8_i32_add, calc_u8_i64_add, calc_u8_f_add, calc_u8_d_add, NULL, NULL, calc_u8_u8_add, calc_u8_u16_add, calc_u8_u32_add, calc_u8_u64_add, NULL}, // TSDB_DATA_TYPE_UTINYINT, +// {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_USMALLINT, +// {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_UINT, +// {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_UBIGINT, +// +//}; +// +//_arithmetic_operator_fn_t sub_function_arraylist[8][15] = { +// /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary*/ +// {0}, // EMPTY, +// {0}, // TSDB_DATA_TYPE_BOOL, +// {NULL, NULL, calc_i8_i8_sub, calc_i8_i16_sub, calc_i8_i32_sub, calc_i8_i64_sub, calc_i8_f_sub, calc_i8_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT +// {NULL, NULL, calc_i16_i8_sub, calc_i16_i16_sub, calc_i16_i32_sub, calc_i16_i64_sub, calc_i16_f_sub, calc_i16_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT +// {NULL, NULL, calc_i32_i8_sub, calc_i32_i16_sub, calc_i32_i32_sub, calc_i32_i64_sub, calc_i32_f_sub, calc_i32_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_INT +// {NULL, NULL, calc_i64_i8_sub, calc_i64_i16_sub, calc_i64_i32_sub, calc_i64_i64_sub, calc_i64_f_sub, calc_i64_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT +// {NULL, NULL, calc_f_i8_sub, calc_f_i16_sub, calc_f_i32_sub, calc_f_i64_sub, calc_f_f_sub, calc_f_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT +// {NULL, NULL, calc_d_i8_sub, calc_d_i16_sub, calc_d_i32_sub, calc_d_i64_sub, calc_d_f_sub, calc_d_d_sub, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE +//}; +// +//_arithmetic_operator_fn_t multi_function_arraylist[][15] = { +// /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary*/ +// {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // EMPTY, +// {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_BOOL, +// {NULL, NULL, calc_i8_i8_multi, calc_i8_i16_multi, calc_i8_i32_multi, calc_i8_i64_multi, calc_i8_f_multi, calc_i8_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT +// {NULL, NULL, calc_i16_i8_multi, calc_i16_i16_multi, calc_i16_i32_multi, calc_i16_i64_multi, calc_i16_f_multi, calc_i16_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT +// {NULL, NULL, calc_i32_i8_multi, calc_i32_i16_multi, calc_i32_i32_multi, calc_i32_i64_multi, calc_i32_f_multi, calc_i32_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_INT +// {NULL, NULL, calc_i64_i8_multi, calc_i64_i16_multi, calc_i64_i32_multi, calc_i64_i64_multi, calc_i64_f_multi, calc_i64_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT +// {NULL, NULL, calc_f_i8_multi, calc_f_i16_multi, calc_f_i32_multi, calc_f_i64_multi, calc_f_f_multi, calc_f_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT +// {NULL, NULL, calc_d_i8_multi, calc_d_i16_multi, calc_d_i32_multi, calc_d_i64_multi, calc_d_f_multi, calc_d_d_multi, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE +//}; +// +//_arithmetic_operator_fn_t div_function_arraylist[8][15] = { +// /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary*/ +// {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // EMPTY, +// {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_BOOL, +// {NULL, NULL, calc_i8_i8_div, calc_i8_i16_div, calc_i8_i32_div, calc_i8_i64_div, calc_i8_f_div, calc_i8_d_div, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT +// {NULL, NULL, calc_i16_i8_div, calc_i16_i16_div, calc_i16_i32_div, calc_i16_i64_div, calc_i16_f_div, calc_i16_d_div, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT +// {NULL, NULL, calc_i32_i8_div, calc_i32_i16_div, calc_i32_i32_div, calc_i32_i64_div, calc_i32_f_div, calc_i32_d_div, NULL, NULL}, // TSDB_DATA_TYPE_INT +// {NULL, NULL, calc_i64_i8_div, calc_i64_i16_div, calc_i64_i32_div, calc_i64_i64_div, calc_i64_f_div, calc_i64_d_div, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT +// {NULL, NULL, calc_f_i8_div, calc_f_i16_div, calc_f_i32_div, calc_f_i64_div, calc_f_f_div, calc_f_d_div, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT +// {NULL, NULL, calc_d_i8_div, calc_d_i16_div, calc_d_i32_div, calc_d_i64_div, calc_d_f_div, calc_d_d_div, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE +//}; +// +//_arithmetic_operator_fn_t rem_function_arraylist[8][15] = { +// /*NULL, bool, tinyint, smallint, int, bigint, float, double, timestamp, binary, nchar, unsigned tinyint, unsigned smallint, unsigned int, unsigned bigint*/ +// {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // EMPTY, +// {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, // TSDB_DATA_TYPE_BOOL, +// {NULL, NULL, calc_i8_i8_rem, calc_i8_i16_rem, calc_i8_i32_rem, calc_i8_i64_rem, calc_i8_f_rem, calc_i8_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_TINYINT +// {NULL, NULL, calc_i16_i8_rem, calc_i16_i16_rem, calc_i16_i32_rem, calc_i16_i64_rem, calc_i16_f_rem, calc_i16_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_SMALLINT +// {NULL, NULL, calc_i32_i8_rem, calc_i32_i16_rem, calc_i32_i32_rem, calc_i32_i64_rem, calc_i32_f_rem, calc_i32_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_INT +// {NULL, NULL, calc_i64_i8_rem, calc_i64_i16_rem, calc_i64_i32_rem, calc_i64_i64_rem, calc_i64_f_rem, calc_i64_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_BIGINT +// {NULL, NULL, calc_f_i8_rem, calc_f_i16_rem, calc_f_i32_rem, calc_f_i64_rem, calc_f_f_rem, calc_f_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_FLOAT +// {NULL, NULL, calc_d_i8_rem, calc_d_i16_rem, calc_d_i32_rem, calc_d_i64_rem, calc_d_f_rem, calc_d_d_rem, NULL, NULL}, // TSDB_DATA_TYPE_DOUBLE +//}; //////////////////////////////////////////////////////////////////////////////////////////////////////////// -_bi_consumer_fn_t getArithmeticOperatorFn(int32_t leftType, int32_t rightType, int32_t optr) { - switch (optr) { +_arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr) { + switch (arithmeticOptr) { case TSDB_BINARY_OP_ADD: - return add_function_arraylist[leftType][rightType]; + return vectorAdd; case TSDB_BINARY_OP_SUBTRACT: - return sub_function_arraylist[leftType][rightType]; + return vectorSub; case TSDB_BINARY_OP_MULTIPLY: - return multi_function_arraylist[leftType][rightType]; + return vectorMultiply; case TSDB_BINARY_OP_DIVIDE: - return div_function_arraylist[leftType][rightType]; + return vectorDivide; case TSDB_BINARY_OP_REMAINDER: - return rem_function_arraylist[leftType][rightType]; + return vectorRemainder; default: - assert(0); return NULL; } - - assert(0); - return NULL; } diff --git a/src/query/src/qAst.c b/src/query/src/qAst.c index c23a794196..1e6dbe8e3d 100644 --- a/src/query/src/qAst.c +++ b/src/query/src/qAst.c @@ -197,76 +197,76 @@ void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, * exprLeft + exprRight * the type of returned value of one expression is always double float precious */ - _bi_consumer_fn_t fp = getArithmeticOperatorFn(TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_DOUBLE, pExprs->_node.optr); - fp(pLeftOutput, pRightOutput, numOfRows, numOfRows, pOutput, TSDB_ORDER_ASC); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); + OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC); } else if (pRight->nodeType == TSQL_NODE_COL) { // exprLeft + columnRight - _bi_consumer_fn_t fp = getArithmeticOperatorFn(TSDB_DATA_TYPE_DOUBLE, pRight->pSchema->type, pExprs->_node.optr); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); // set input buffer char *pInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); if (order == TSDB_ORDER_DESC) { reverseCopy(pdata, pInputData, pRight->pSchema->type, numOfRows); - fp(pLeftOutput, pdata, numOfRows, numOfRows, pOutput, TSDB_ORDER_ASC); + OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pdata, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC); } else { - fp(pLeftOutput, pInputData, numOfRows, numOfRows, pOutput, TSDB_ORDER_ASC); + OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pInputData, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC); } } else if (pRight->nodeType == TSQL_NODE_VALUE) { // exprLeft + 12 - _bi_consumer_fn_t fp = getArithmeticOperatorFn(TSDB_DATA_TYPE_DOUBLE, pRight->pVal->nType, pExprs->_node.optr); - fp(pLeftOutput, &pRight->pVal->i64Key, numOfRows, 1, pOutput, TSDB_ORDER_ASC); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); + OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, &pRight->pVal->i64, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC); } } else if (pLeft->nodeType == TSQL_NODE_COL) { // column data specified on left-hand-side char *pLeftInputData = getSourceDataBlock(param, pLeft->pSchema->name, pLeft->pSchema->colId); if (pRight->nodeType == TSQL_NODE_EXPR) { // columnLeft + expr2 - _bi_consumer_fn_t fp = getArithmeticOperatorFn(pLeft->pSchema->type, TSDB_DATA_TYPE_DOUBLE, pExprs->_node.optr); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); if (order == TSDB_ORDER_DESC) { reverseCopy(pdata, pLeftInputData, pLeft->pSchema->type, numOfRows); - fp(pdata, pRightOutput, numOfRows, numOfRows, pOutput, TSDB_ORDER_ASC); + OperatorFn(pdata, numOfRows, pLeft->pSchema->type, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC); } else { - fp(pLeftInputData, pRightOutput, numOfRows, numOfRows, pOutput, TSDB_ORDER_ASC); + OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC); } } else if (pRight->nodeType == TSQL_NODE_COL) { // columnLeft + columnRight // column data specified on right-hand-side char *pRightInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); - _bi_consumer_fn_t fp = getArithmeticOperatorFn(pLeft->pSchema->type, pRight->pSchema->type, pExprs->_node.optr); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); // both columns are descending order, do not reverse the source data - fp(pLeftInputData, pRightInputData, numOfRows, numOfRows, pOutput, order); + OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, pRightInputData, numOfRows, pRight->pSchema->type, pOutput, order); } else if (pRight->nodeType == TSQL_NODE_VALUE) { // columnLeft + 12 - _bi_consumer_fn_t fp = getArithmeticOperatorFn(pLeft->pSchema->type, pRight->pVal->nType, pExprs->_node.optr); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); if (order == TSDB_ORDER_DESC) { reverseCopy(pdata, pLeftInputData, pLeft->pSchema->type, numOfRows); - fp(pdata, &pRight->pVal->i64Key, numOfRows, 1, pOutput, TSDB_ORDER_ASC); + OperatorFn(pdata, numOfRows, pLeft->pSchema->type, &pRight->pVal->i64, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC); } else { - fp(pLeftInputData, &pRight->pVal->i64Key, numOfRows, 1, pOutput, TSDB_ORDER_ASC); + OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, &pRight->pVal->i64, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC); } } } else { // column data specified on left-hand-side if (pRight->nodeType == TSQL_NODE_EXPR) { // 12 + expr2 - _bi_consumer_fn_t fp = getArithmeticOperatorFn(pLeft->pVal->nType, TSDB_DATA_TYPE_DOUBLE, pExprs->_node.optr); - fp(&pLeft->pVal->i64Key, pRightOutput, 1, numOfRows, pOutput, TSDB_ORDER_ASC); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); + OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC); } else if (pRight->nodeType == TSQL_NODE_COL) { // 12 + columnRight // column data specified on right-hand-side char *pRightInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); - _bi_consumer_fn_t fp = getArithmeticOperatorFn(pLeft->pVal->nType, pRight->pSchema->type, pExprs->_node.optr); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); if (order == TSDB_ORDER_DESC) { reverseCopy(pdata, pRightInputData, pRight->pSchema->type, numOfRows); - fp(&pLeft->pVal->i64Key, pdata, numOfRows, 1, pOutput, TSDB_ORDER_ASC); + OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, pdata, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC); } else { - fp(&pLeft->pVal->i64Key, pRightInputData, 1, numOfRows, pOutput, TSDB_ORDER_ASC); + OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, pRightInputData, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC); } } else if (pRight->nodeType == TSQL_NODE_VALUE) { // 12 + 12 - _bi_consumer_fn_t fp = getArithmeticOperatorFn(pLeft->pVal->nType, pRight->pVal->nType, pExprs->_node.optr); - fp(&pLeft->pVal->i64Key, &pRight->pVal->i64Key, 1, 1, pOutput, TSDB_ORDER_ASC); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr); + OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, &pRight->pVal->i64, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC); } } @@ -285,7 +285,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { tbufWriteInt32(bw, pVal->nLen); tbufWrite(bw, pVal->pz, pVal->nLen); } else { - tbufWriteInt64(bw, pVal->i64Key); + tbufWriteInt64(bw, pVal->i64); } } else if (expr->nodeType == TSQL_NODE_COL) { @@ -355,7 +355,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { pVal->pz = calloc(1, pVal->nLen + 1); tbufReadToBuffer(br, pVal->pz, pVal->nLen); } else { - pVal->i64Key = tbufReadInt64(br); + pVal->i64 = tbufReadInt64(br); } } else if (pExpr->nodeType == TSQL_NODE_COL) { diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 7b544040bf..90cd74de72 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -212,22 +212,22 @@ bool doFilterData(SQuery *pQuery, int32_t elemPos) { bool isnull = isNull(pElem, pFilterInfo->info.type); if (isnull) { - if (pFilterElem->fp == isNull_filter) { + if (pFilterElem->fp == isNullOperator) { qualified = true; break; } else { continue; } } else { - if (pFilterElem->fp == notNull_filter) { + if (pFilterElem->fp == notNullOperator) { qualified = true; break; - } else if (pFilterElem->fp == isNull_filter) { + } else if (pFilterElem->fp == isNullOperator) { continue; } } - if (pFilterElem->fp(pFilterElem, pElem, pElem)) { + if (pFilterElem->fp(pFilterElem, pElem, pElem, pFilterInfo->info.type)) { qualified = true; break; } @@ -759,7 +759,7 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey, } if (i == pResultRowInfo->size - 1) { - pResultRowInfo->curIndex = i; + pResultRowInfo->curIndex = i; } else { pResultRowInfo->curIndex = i + 1; // current not closed result object } @@ -1372,7 +1372,7 @@ static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, int32_t offset) { #if defined(_DEBUG_VIEW) printf("elem in comp ts file:%" PRId64 ", key:%" PRId64 ", tag:%"PRIu64", query order:%d, ts order:%d, traverse:%d, index:%d\n", - elem.ts, key, elem.tag.i64Key, pQuery->order.order, pRuntimeEnv->pTsBuf->tsOrder, + elem.ts, key, elem.tag.i64, pQuery->order.order, pRuntimeEnv->pTsBuf->tsOrder, pRuntimeEnv->pTsBuf->cur.order, pRuntimeEnv->pTsBuf->cur.tsIndex); #endif @@ -1412,7 +1412,7 @@ static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx // denote the order type if ((functionId == TSDB_FUNC_LAST_DST || functionId == TSDB_FUNC_LAST)) { - return pCtx->param[0].i64Key == pQuery->order.order; + return pCtx->param[0].i64 == pQuery->order.order; } // in the supplementary scan, only the following functions need to be executed @@ -1781,9 +1781,9 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY * top/bottom values emerge, so does diff function */ if (functionId == TSDB_FUNC_TWA) { - pCtx->param[1].i64Key = pQuery->window.skey; + pCtx->param[1].i64 = pQuery->window.skey; pCtx->param[1].nType = TSDB_DATA_TYPE_BIGINT; - pCtx->param[2].i64Key = pQuery->window.ekey; + pCtx->param[2].i64 = pQuery->window.ekey; pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT; } @@ -1813,7 +1813,7 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY } } } else if (functionId == TSDB_FUNC_TS_COMP) { - pCtx->param[0].i64Key = vgId; + pCtx->param[0].i64 = vgId; pCtx->param[0].nType = TSDB_DATA_TYPE_BIGINT; } @@ -1952,12 +1952,12 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order int32_t f = pQuery->pExpr1[0].base.functionId; assert(f == TSDB_FUNC_TS || f == TSDB_FUNC_TS_DUMMY); - pCtx->param[2].i64Key = order; + pCtx->param[2].i64 = order; pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT; - pCtx->param[3].i64Key = functionId; + pCtx->param[3].i64 = functionId; pCtx->param[3].nType = TSDB_DATA_TYPE_BIGINT; - pCtx->param[1].i64Key = pQuery->order.orderColId; + pCtx->param[1].i64 = pQuery->order.orderColId; } if (functionId == TSDB_FUNC_ARITHM) { @@ -2478,7 +2478,7 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat // if isNULL query exists, load the null data column for (int32_t j = 0; j < pFilterInfo->numOfFilters; ++j) { SColumnFilterElem *pFilterElem = &pFilterInfo->pFilters[j]; - if (pFilterElem->fp == isNull_filter) { + if (pFilterElem->fp == isNullOperator) { return true; } } @@ -2493,13 +2493,13 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat float maxval = (float)(*(double *)(&pDataBlockst->max)); for (int32_t i = 0; i < pFilterInfo->numOfFilters; ++i) { - if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&minval, (char *)&maxval)) { + if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&minval, (char *)&maxval, TSDB_DATA_TYPE_FLOAT)) { return true; } } } else { for (int32_t i = 0; i < pFilterInfo->numOfFilters; ++i) { - if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&pDataBlockst->min, (char *)&pDataBlockst->max)) { + if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&pDataBlockst->min, (char *)&pDataBlockst->max, pFilterInfo->info.type)) { return true; } } @@ -2966,7 +2966,7 @@ void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) { pExprInfo->base.arg->argValue.i64, pRuntimeEnv->pCtx[0].tag.pz); } else { qDebug("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%" PRId64, pQInfo, - pExprInfo->base.arg->argValue.i64, pRuntimeEnv->pCtx[0].tag.i64Key); + pExprInfo->base.arg->argValue.i64, pRuntimeEnv->pCtx[0].tag.i64); } } } @@ -3168,6 +3168,10 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) { // all results in current group have been returned to client, try next group if (pGroupResInfo->index >= taosArrayGetSize(pGroupResInfo->pRows)) { // current results of group has been sent to client, try next group + pGroupResInfo->index = 0; + pGroupResInfo->rowId = 0; + taosArrayClear(pGroupResInfo->pRows); + if (mergeGroupResult(pQInfo) != TSDB_CODE_SUCCESS) { return; // failed to save data in the disk } @@ -3946,7 +3950,7 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { qError("QInfo:%p failed to find tag:%s in ts_comp", pQInfo, pTag->pz); } else { - qError("QInfo:%p failed to find tag:%" PRId64 " in ts_comp", pQInfo, pTag->i64Key); + qError("QInfo:%p failed to find tag:%" PRId64 " in ts_comp", pQInfo, pTag->i64); } return false; @@ -3957,7 +3961,7 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); } else { - qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); + qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); } } else { @@ -3966,7 +3970,7 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); } else { - qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); + qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex); } } } @@ -4930,7 +4934,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { qError("QInfo:%p failed to find tag:%s in ts_comp", pQInfo, pTag->pz); } else { - qError("QInfo:%p failed to find tag:%"PRId64" in ts_comp", pQInfo, pTag->i64Key); + qError("QInfo:%p failed to find tag:%"PRId64" in ts_comp", pQInfo, pTag->i64); } return false; @@ -4941,7 +4945,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, cur.blockIndex, cur.tsIndex); } else { - qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, + qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64, cur.blockIndex, cur.tsIndex); } } @@ -4955,7 +4959,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { qError("QInfo:%p failed to find tag:%s in ts_comp", pQInfo, pTag->pz); } else { - qError("QInfo:%p failed to find tag:%"PRId64" in ts_comp", pQInfo, pTag->i64Key); + qError("QInfo:%p failed to find tag:%"PRId64" in ts_comp", pQInfo, pTag->i64); } return false; @@ -4964,7 +4968,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { qDebug("QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, cur.blockIndex, cur.tsIndex); } else { - qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, cur.blockIndex, cur.tsIndex); + qDebug("QInfo:%p find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64, cur.blockIndex, cur.tsIndex); } } @@ -4974,7 +4978,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) { qDebug("QInfo:%p continue scan ts_comp file, tag:%s blockIndex:%d, tsIndex:%d", pQInfo, pTag->pz, cur.blockIndex, cur.tsIndex); } else { - qDebug("QInfo:%p continue scan ts_comp file, tag:%"PRId64" blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64Key, cur.blockIndex, cur.tsIndex); + qDebug("QInfo:%p continue scan ts_comp file, tag:%"PRId64" blockIndex:%d, tsIndex:%d", pQInfo, pTag->i64, cur.blockIndex, cur.tsIndex); } } } @@ -6025,7 +6029,11 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, pColInfo->bytes = htons(pColInfo->bytes); pColInfo->numOfFilters = htons(pColInfo->numOfFilters); - assert(pColInfo->type >= TSDB_DATA_TYPE_BOOL && pColInfo->type <= TSDB_DATA_TYPE_NCHAR); + if (!isValidDataType(pColInfo->type)) { + qDebug("qmsg:%p, invalid data type in source column, index:%d, type:%d", pQueryMsg, col, pColInfo->type); + code = TSDB_CODE_QRY_INVALID_MSG; + goto _cleanup; + } int32_t numOfFilters = pColInfo->numOfFilters; if (numOfFilters > 0) { @@ -6111,7 +6119,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, if (pQueryMsg->secondStageOutput) { pExprMsg = (SSqlFuncMsg *)pMsg; *pSecStageExpr = calloc(pQueryMsg->secondStageOutput, POINTER_BYTES); - + for (int32_t i = 0; i < pQueryMsg->secondStageOutput; ++i) { (*pSecStageExpr)[i] = pExprMsg; @@ -6445,55 +6453,18 @@ static int32_t createFilterInfo(void *pQInfo, SQuery *pQuery) { int32_t lower = pSingleColFilter->filterInfo.lowerRelOptr; int32_t upper = pSingleColFilter->filterInfo.upperRelOptr; - if (lower == TSDB_RELATION_INVALID && upper == TSDB_RELATION_INVALID) { qError("QInfo:%p invalid filter info", pQInfo); return TSDB_CODE_QRY_INVALID_MSG; } - int16_t type = pQuery->colList[i].type; - int16_t bytes = pQuery->colList[i].bytes; - - // todo refactor - __filter_func_t *rangeFilterArray = getRangeFilterFuncArray(type); - __filter_func_t *filterArray = getValueFilterFuncArray(type); - - if (rangeFilterArray == NULL && filterArray == NULL) { - qError("QInfo:%p failed to get filter function, invalid data type:%d", pQInfo, type); + pSingleColFilter->fp = getFilterOperator(lower, upper); + if (pSingleColFilter->fp == NULL) { + qError("QInfo:%p invalid filter info", pQInfo); return TSDB_CODE_QRY_INVALID_MSG; } - if ((lower == TSDB_RELATION_GREATER_EQUAL || lower == TSDB_RELATION_GREATER) && - (upper == TSDB_RELATION_LESS_EQUAL || upper == TSDB_RELATION_LESS)) { - assert(rangeFilterArray != NULL); - if (lower == TSDB_RELATION_GREATER_EQUAL) { - if (upper == TSDB_RELATION_LESS_EQUAL) { - pSingleColFilter->fp = rangeFilterArray[4]; - } else { - pSingleColFilter->fp = rangeFilterArray[2]; - } - } else { - if (upper == TSDB_RELATION_LESS_EQUAL) { - pSingleColFilter->fp = rangeFilterArray[3]; - } else { - pSingleColFilter->fp = rangeFilterArray[1]; - } - } - } else { // set callback filter function - assert(filterArray != NULL); - if (lower != TSDB_RELATION_INVALID) { - pSingleColFilter->fp = filterArray[lower]; - - if (upper != TSDB_RELATION_INVALID) { - qError("pQInfo:%p failed to get filter function, invalid filter condition: %d", pQInfo, type); - return TSDB_CODE_QRY_INVALID_MSG; - } - } else { - pSingleColFilter->fp = filterArray[upper]; - } - } - assert(pSingleColFilter->fp != NULL); - pSingleColFilter->bytes = bytes; + pSingleColFilter->bytes = pQuery->colList[i].bytes; } j++; @@ -6796,7 +6767,7 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ UNUSED(ret); } - + pQuery->precision = tsdbGetCfg(tsdb)->precision; if ((QUERY_IS_ASC_QUERY(pQuery) && (pQuery->window.skey > pQuery->window.ekey)) || @@ -6961,11 +6932,12 @@ static size_t getResultSize(SQInfo *pQInfo, int64_t *numOfRows) { */ if (isTSCompQuery(pQuery) && (*numOfRows) > 0) { struct stat fStat; - if (fstat(fileno(*(FILE **)pQuery->sdata[0]->data), &fStat) == 0) { + FILE *f = *(FILE **)pQuery->sdata[0]->data; + if ((f != NULL) && (fstat(fileno(f), &fStat) == 0)) { *numOfRows = fStat.st_size; return fStat.st_size; } else { - qError("QInfo:%p failed to get file info, path:%s, reason:%s", pQInfo, pQuery->sdata[0]->data, strerror(errno)); + qError("QInfo:%p failed to get file info, file:%p, reason:%s", pQInfo, f, strerror(errno)); return 0; } } else { @@ -6980,7 +6952,7 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) { // load data from file to msg buffer if (isTSCompQuery(pQuery)) { - FILE *f = *(FILE **)pQuery->sdata[0]->data; + FILE *f = *(FILE **)pQuery->sdata[0]->data; // TODO refactor // make sure file exist if (f) { diff --git a/src/query/src/qFilterfunc.c b/src/query/src/qFilterfunc.c index 2a40533e90..884f7e653f 100644 --- a/src/query/src/qFilterfunc.c +++ b/src/query/src/qFilterfunc.c @@ -19,212 +19,174 @@ #include "qExecutor.h" #include "taosmsg.h" #include "tcompare.h" -#include "tsqlfunction.h" +#include "ttype.h" -#define FLT_EQUAL(_x, _y) (fabs((_x) - (_y)) <= (4 * FLT_EPSILON)) +#define FLT_COMPAR_TOL_FACTOR 4 +#define FLT_EQUAL(_x, _y) (fabs((_x) - (_y)) <= (FLT_COMPAR_TOL_FACTOR * FLT_EPSILON)) #define FLT_GREATER(_x, _y) (!FLT_EQUAL((_x), (_y)) && ((_x) > (_y))) #define FLT_LESS(_x, _y) (!FLT_EQUAL((_x), (_y)) && ((_x) < (_y))) #define FLT_GREATEREQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) > (_y))) #define FLT_LESSEQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) < (_y))) -bool less_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int8_t *)minval < pFilter->filterInfo.upperBndi); -} +bool lessOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type) { + SColumnFilterInfo* pFilterInfo = &pFilter->filterInfo; -bool less_i16(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int16_t *)minval < pFilter->filterInfo.upperBndi); -} - -bool less_i32(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int32_t *)minval < pFilter->filterInfo.upperBndi); -} - -bool less_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int64_t *)minval < pFilter->filterInfo.upperBndi); -} - -bool less_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return FLT_LESS(*(float*)minval, pFilter->filterInfo.upperBndd); -} - -bool less_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return *(double *)minval < pFilter->filterInfo.upperBndd; -} - -////////////////////////////////////////////////////////////////// -bool larger_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int8_t *)maxval > pFilter->filterInfo.lowerBndi); -} - -bool larger_i16(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int16_t *)maxval > pFilter->filterInfo.lowerBndi); -} - -bool larger_i32(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int32_t *)maxval > pFilter->filterInfo.lowerBndi); -} - -bool larger_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int64_t *)maxval > pFilter->filterInfo.lowerBndi); -} - -bool larger_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return FLT_GREATER(*(float*)maxval, pFilter->filterInfo.lowerBndd); -} - -bool larger_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(double *)maxval > pFilter->filterInfo.lowerBndd); -} -///////////////////////////////////////////////////////////////////// - -bool lessEqual_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int8_t *)minval <= pFilter->filterInfo.upperBndi); -} - -bool lessEqual_i16(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int16_t *)minval <= pFilter->filterInfo.upperBndi); -} - -bool lessEqual_i32(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int32_t *)minval <= pFilter->filterInfo.upperBndi); -} - -bool lessEqual_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int64_t *)minval <= pFilter->filterInfo.upperBndi); -} - -bool lessEqual_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return FLT_LESSEQUAL(*(float*)minval, pFilter->filterInfo.upperBndd); -} - -bool lessEqual_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if ((fabs(*(double*)minval) - pFilter->filterInfo.upperBndd) <= 2 * DBL_EPSILON) { - return true; + switch(type) { + case TSDB_DATA_TYPE_TINYINT: return (*(int8_t *)minval < pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_UTINYINT: return (*(uint8_t *)minval < pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_SMALLINT: return (*(int16_t *)minval < pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_USMALLINT: return (*(uint16_t *)minval < pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_INT: return (*(int32_t *)minval < pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_UINT: return (*(uint32_t *)minval < pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: return (*(int64_t *)minval < pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_UBIGINT: return (*(uint64_t *)minval < pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_FLOAT: return FLT_LESS(*(float*)minval, pFilter->filterInfo.upperBndd); + case TSDB_DATA_TYPE_DOUBLE: return (*(double *)minval < pFilterInfo->upperBndd); + default: + return false; } - - return (*(double *)minval <= pFilter->filterInfo.upperBndd); } -////////////////////////////////////////////////////////////////////////// -bool largeEqual_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int8_t *)maxval >= pFilter->filterInfo.lowerBndi); -} +bool greaterOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type) { + SColumnFilterInfo *pFilterInfo = &pFilter->filterInfo; -bool largeEqual_i16(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int16_t *)maxval >= pFilter->filterInfo.lowerBndi); -} - -bool largeEqual_i32(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int32_t *)maxval >= pFilter->filterInfo.lowerBndi); -} - -bool largeEqual_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int64_t *)maxval >= pFilter->filterInfo.lowerBndi); -} - -bool largeEqual_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return FLT_GREATEREQUAL(*(float*)maxval, pFilter->filterInfo.lowerBndd); -} - -bool largeEqual_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (fabs(*(double *)maxval - pFilter->filterInfo.lowerBndd) <= 2 * DBL_EPSILON) { - return true; + switch (type) { + case TSDB_DATA_TYPE_TINYINT: return (*(int8_t *)maxval > pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_UTINYINT: return (*(uint8_t *)maxval > pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_SMALLINT: return (*(int16_t *)maxval > pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_USMALLINT: return (*(uint16_t *)maxval > pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_INT: return (*(int32_t *)maxval > pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_UINT: return (*(uint32_t *)maxval > pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: return (*(int64_t *)maxval > pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_UBIGINT: return (*(uint64_t *)maxval > pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_FLOAT: return FLT_GREATER(*(float *)maxval, pFilterInfo->lowerBndd); + case TSDB_DATA_TYPE_DOUBLE: return (*(double *)maxval > pFilterInfo->lowerBndd); + default: + return false; } +} - return (*(double *)maxval - pFilter->filterInfo.lowerBndd > (2 * DBL_EPSILON)); +bool lessEqualOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type) { + SColumnFilterInfo* pFilterInfo = &pFilter->filterInfo; + + switch(type) { + case TSDB_DATA_TYPE_TINYINT: return (*(int8_t *)minval <= pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_UTINYINT: return (*(uint8_t *)minval <= pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_SMALLINT: return (*(int16_t *)minval <= pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_USMALLINT: return (*(uint16_t *)minval <= pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_INT: return (*(int32_t *)minval <= pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_UINT: return (*(uint32_t *)minval <= pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: return (*(int64_t *)minval <= pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_UBIGINT: return (*(uint64_t *)minval <= pFilterInfo->upperBndi); + case TSDB_DATA_TYPE_FLOAT: return FLT_LESSEQUAL(*(float*)minval, pFilterInfo->upperBndd); + case TSDB_DATA_TYPE_DOUBLE: { + if ((fabs(*(double*)minval) - pFilterInfo->upperBndd) <= 2 * DBL_EPSILON) { + return true; + } + + return (*(double *)minval <= pFilterInfo->upperBndd); + } + default: + return false; + } +} + +bool greaterEqualOperator(SColumnFilterElem *pFilter, const char *minval, const char *maxval, int16_t type) { + SColumnFilterInfo *pFilterInfo = &pFilter->filterInfo; + + switch (type) { + case TSDB_DATA_TYPE_TINYINT: return (*(int8_t *)maxval >= pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_UTINYINT: return (*(uint8_t *)maxval >= pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_SMALLINT: return (*(int16_t *)maxval >= pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_USMALLINT: return (*(uint16_t *)maxval >= pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_INT: return (*(int32_t *)maxval >= pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_UINT: return (*(uint32_t *)maxval >= pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: return (*(int64_t *)maxval >= pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_UBIGINT: return (*(uint64_t *)maxval >= pFilterInfo->lowerBndi); + case TSDB_DATA_TYPE_FLOAT: return FLT_GREATEREQUAL(*(float*)maxval, pFilterInfo->lowerBndd); + case TSDB_DATA_TYPE_DOUBLE: { + if (fabs(*(double *)maxval - pFilterInfo->lowerBndd) <= 2 * DBL_EPSILON) { + return true; + } + + return (*(double *)maxval - pFilterInfo->lowerBndd > (2 * DBL_EPSILON)); + } + default: + return false; + } } //////////////////////////////////////////////////////////////////////// +bool equalOperator(SColumnFilterElem *pFilter, const char *minval, const char *maxval, int16_t type) { + SColumnFilterInfo *pFilterInfo = &pFilter->filterInfo; -bool equal_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(int8_t *)minval == *(int8_t *)maxval) { - return (*(int8_t *)minval == pFilter->filterInfo.lowerBndi); - } else { /* range filter */ - assert(*(int8_t *)minval < *(int8_t *)maxval); + if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) { + int64_t minv = -1, maxv = -1; + GET_TYPED_DATA(minv, int64_t, type, minval); + GET_TYPED_DATA(maxv, int64_t, type, maxval); - return *(int8_t *)minval <= pFilter->filterInfo.lowerBndi && *(int8_t *)maxval >= pFilter->filterInfo.lowerBndi; - } -} + if (minv == maxv) { + return minv == pFilterInfo->lowerBndi; + } else { + assert(minv < maxv); + return minv <= pFilterInfo->lowerBndi && pFilterInfo->lowerBndi <= maxv; + } + } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { + uint64_t minv = 0, maxv = 0; + GET_TYPED_DATA(minv, uint64_t, type, minval); + GET_TYPED_DATA(maxv, uint64_t, type, maxval); -bool equal_i16(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(int16_t *)minval == *(int16_t *)maxval) { - return (*(int16_t *)minval == pFilter->filterInfo.lowerBndi); - } else { /* range filter */ - assert(*(int16_t *)minval < *(int16_t *)maxval); + if (minv == maxv) { + return minv == pFilterInfo->lowerBndi; + } else { + assert(minv < maxv); + return minv <= pFilterInfo->lowerBndi && pFilterInfo->lowerBndi <= maxv; + } + } else if (IS_FLOAT_TYPE(type)) { + double minv = -1, maxv = -1; + GET_TYPED_DATA(minv, double, type, minval); + GET_TYPED_DATA(maxv, double, type, maxval); - return *(int16_t *)minval <= pFilter->filterInfo.lowerBndi && *(int16_t *)maxval >= pFilter->filterInfo.lowerBndi; - } -} + if (minv == maxv) { + return FLT_EQUAL(minv, pFilterInfo->lowerBndd); + } else { // range filter + assert(minv < maxv); + return minv <= pFilterInfo->lowerBndd && pFilterInfo->lowerBndd <= maxv; + } + } else if (type == TSDB_DATA_TYPE_BINARY) { + // query condition string is greater than the max length of string, not qualified data + if (pFilterInfo->len != varDataLen(minval)) { + return false; + } -bool equal_i32(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(int32_t *)minval == *(int32_t *)maxval) { - return (*(int32_t *)minval == pFilter->filterInfo.lowerBndi); - } else { /* range filter */ - assert(*(int32_t *)minval < *(int32_t *)maxval); + return strncmp((char *)pFilterInfo->pz, varDataVal(minval), varDataLen(minval)) == 0; + } else if (type == TSDB_DATA_TYPE_NCHAR) { + // query condition string is greater than the max length of string, not qualified data + if (pFilterInfo->len != varDataLen(minval)) { + return false; + } - return *(int32_t *)minval <= pFilter->filterInfo.lowerBndi && *(int32_t *)maxval >= pFilter->filterInfo.lowerBndi; - } -} - -bool equal_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(int64_t *)minval == *(int64_t *)maxval) { - return (*(int64_t *)minval == pFilter->filterInfo.lowerBndi); - } else { /* range filter */ - assert(*(int64_t *)minval < *(int64_t *)maxval); - - return *(int64_t *)minval <= pFilter->filterInfo.lowerBndi && *(int64_t *)maxval >= pFilter->filterInfo.lowerBndi; - } -} - -// user specified input filter value and the original saved float value may needs to -// increase the tolerance to obtain the correct result. -bool equal_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(float *)minval == *(float *)maxval) { - return FLT_EQUAL(*(float*)minval, pFilter->filterInfo.lowerBndd); - } else { // range filter - assert(*(float *)minval < *(float *)maxval); - return *(float *)minval <= pFilter->filterInfo.lowerBndd && *(float *)maxval >= pFilter->filterInfo.lowerBndd; - } -} - -bool equal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(double *)minval == *(double *)maxval) { - return (fabs(*(double *)minval - pFilter->filterInfo.lowerBndd) <= 2 * DBL_EPSILON); - } else { // range filter - assert(*(double *)minval < *(double *)maxval); - return *(double *)minval <= pFilter->filterInfo.lowerBndi && *(double *)maxval >= pFilter->filterInfo.lowerBndi; - } -} - -bool equal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { - // query condition string is greater than the max length of string, not qualified data - if (pFilter->filterInfo.len != varDataLen(minval)) { + return wcsncmp((wchar_t *)pFilterInfo->pz, varDataVal(minval), varDataLen(minval) / TSDB_NCHAR_SIZE) == 0; + } else { return false; } - - return strncmp((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)) == 0; -} - -bool equal_nchar(SColumnFilterElem *pFilter, char *minval, char *maxval) { - // query condition string is greater than the max length of string, not qualified data - if (pFilter->filterInfo.len != varDataLen(minval)) { - return false; - } - - return wcsncmp((wchar_t *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE) == 0; } //////////////////////////////////////////////////////////////// -bool like_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { - SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; - - return patternMatch((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval), &info) == TSDB_PATTERN_MATCH; -} - -bool like_nchar(SColumnFilterElem* pFilter, char* minval, char *maxval) { - SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; - - return WCSPatternMatch((wchar_t*)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH; +bool likeOperator(SColumnFilterElem *pFilter, const char *minval, const char *maxval, int16_t type) { + if (type == TSDB_DATA_TYPE_BINARY) { + SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; + return patternMatch((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval), &info) == TSDB_PATTERN_MATCH; + } else if (type == TSDB_DATA_TYPE_NCHAR) { + SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; + return WCSPatternMatch((wchar_t*)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH; + } else { + return false; + } } //////////////////////////////////////////////////////////////// @@ -236,362 +198,237 @@ bool like_nchar(SColumnFilterElem* pFilter, char* minval, char *maxval) { * During pre-filter stage, if there is one element that locates in [minval, maxval], * the filter function will return true. */ -bool nequal_i8(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(int8_t *)minval == *(int8_t *)maxval) { - return (*(int8_t *)minval != pFilter->filterInfo.lowerBndi); - } +// TODO not equal need to refactor +bool notEqualOperator(SColumnFilterElem *pFilter, const char *minval, const char *maxval, int16_t type) { + SColumnFilterInfo *pFilterInfo = &pFilter->filterInfo; - return true; -} + if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) { + int64_t minv = -1, maxv = -1; + GET_TYPED_DATA(minv, int64_t, type, minval); + GET_TYPED_DATA(maxv, int64_t, type, maxval); -bool nequal_i16(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(int16_t *)minval == *(int16_t *)maxval) { - return (*(int16_t *)minval != pFilter->filterInfo.lowerBndi); - } - - return true; -} - -bool nequal_i32(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(int32_t *)minval == *(int32_t *)maxval) { - return (*(int32_t *)minval != pFilter->filterInfo.lowerBndi); - } - - return true; -} - -bool nequal_i64(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(int64_t *)minval == *(int64_t *)maxval) { - return (*(int64_t *)minval != pFilter->filterInfo.lowerBndi); - } - - return true; -} - -bool nequal_ds(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(float *)minval == *(float *)maxval) { - return !FLT_EQUAL(*(float *)minval, pFilter->filterInfo.lowerBndd); - } - - return true; -} - -bool nequal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (*(double *)minval == *(double *)maxval) { - return (*(double *)minval != pFilter->filterInfo.lowerBndd); - } - - return true; -} - -bool nequal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { - if (pFilter->filterInfo.len != varDataLen(minval)) { + if (minv == maxv) { + return minv != pFilterInfo->lowerBndi; + } return true; - } + } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { + uint64_t minv = 0, maxv = 0; + GET_TYPED_DATA(minv, uint64_t, type, minval); + GET_TYPED_DATA(maxv, uint64_t, type, maxval); - return strncmp((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)) != 0; -} - -bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) { - if (pFilter->filterInfo.len > pFilter->bytes) { + if (minv == maxv) { + return minv != pFilterInfo->lowerBndi; + } return true; + } else if (IS_FLOAT_TYPE(type)) { + double minv = -1, maxv = -1; + GET_TYPED_DATA(minv, double, type, minval); + GET_TYPED_DATA(maxv, double, type, maxval); + + if (minv == maxv) { + return !FLT_EQUAL(minv, pFilterInfo->lowerBndd); + } + return true; + } else if (type == TSDB_DATA_TYPE_BINARY) { + if (pFilterInfo->len != varDataLen(minval)) { + return true; + } + return strncmp((char *)pFilterInfo->pz, varDataVal(minval), varDataLen(minval)) != 0; + } else if (type == TSDB_DATA_TYPE_NCHAR) { + if (pFilterInfo->len != varDataLen(minval)) { + return true; + } + return wcsncmp((wchar_t *)pFilterInfo->pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE) != 0; + } else { + return false; } - - return wcsncmp((wchar_t *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE) != 0; -} -//////////////////////////////////////////////////////////////// -bool isNull_filter(SColumnFilterElem *pFilter, char* minval, char* maxval) { - return true; -} - -bool notNull_filter(SColumnFilterElem *pFilter, char* minval, char* maxval) { - return true; } //////////////////////////////////////////////////////////////// - -bool rangeFilter_i32_ii(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int32_t *)minval <= pFilter->filterInfo.upperBndi && *(int32_t *)maxval >= pFilter->filterInfo.lowerBndi); +// dummy filter, not used +bool isNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type) { + return true; } -bool rangeFilter_i32_ee(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int32_t *)minvalfilterInfo.upperBndi &&*(int32_t *)maxval> pFilter->filterInfo.lowerBndi); -} - -bool rangeFilter_i32_ie(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int32_t *)minval < pFilter->filterInfo.upperBndi && *(int32_t *)maxval >= pFilter->filterInfo.lowerBndi); -} - -bool rangeFilter_i32_ei(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int32_t *)minval <= pFilter->filterInfo.upperBndi && *(int32_t *)maxval > pFilter->filterInfo.lowerBndi); +bool notNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type) { + return true; } /////////////////////////////////////////////////////////////////////////////// -bool rangeFilter_i8_ii(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int8_t *)minval <= pFilter->filterInfo.upperBndi && *(int8_t *)maxval >= pFilter->filterInfo.lowerBndi); +bool rangeFilter_ii(SColumnFilterElem *pFilter, const char *minval, const char *maxval, int16_t type) { + SColumnFilterInfo *pFilterInfo = &pFilter->filterInfo; + + switch (type) { + case TSDB_DATA_TYPE_TINYINT: + return ((*(int8_t *)minval <= pFilterInfo->upperBndi) && (*(int8_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UTINYINT: + return ((*(uint8_t *)minval <= pFilterInfo->upperBndi) && (*(uint8_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_SMALLINT: + return ((*(int16_t *)minval <= pFilterInfo->upperBndi) && (*(int16_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_USMALLINT: + return ((*(uint16_t *)minval <= pFilterInfo->upperBndi) && (*(uint16_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_INT: + return ((*(int32_t *)minval <= pFilterInfo->upperBndi) && (*(int32_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UINT: + return ((*(uint32_t *)minval <= pFilterInfo->upperBndi) && (*(uint32_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: + return ((*(int64_t *)minval <= pFilterInfo->upperBndi) && (*(int64_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UBIGINT: + return ((*(uint64_t *)minval <= pFilterInfo->upperBndi) && (*(uint64_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_FLOAT: + return FLT_LESSEQUAL(*(float *)minval, pFilterInfo->upperBndd) && + FLT_GREATEREQUAL(*(float *)maxval, pFilterInfo->lowerBndd); + case TSDB_DATA_TYPE_DOUBLE: + return (*(double *)minval <= pFilterInfo->upperBndd && *(double *)maxval >= pFilterInfo->lowerBndd); + default: + return false; + } } -bool rangeFilter_i8_ee(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int8_t *)minvalfilterInfo.upperBndi &&*(int8_t *)maxval> pFilter->filterInfo.lowerBndi); +bool rangeFilter_ee(SColumnFilterElem *pFilter, const char *minval, const char *maxval, int16_t type) { + SColumnFilterInfo *pFilterInfo = &pFilter->filterInfo; + + switch (type) { + case TSDB_DATA_TYPE_TINYINT: + return ((*(int8_t *)minval < pFilterInfo->upperBndi) && (*(int8_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UTINYINT: + return ((*(uint8_t *)minval < pFilterInfo->upperBndi) && (*(uint8_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_SMALLINT: + return ((*(int16_t *)minval < pFilterInfo->upperBndi) && (*(int16_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_USMALLINT: + return ((*(uint16_t *)minval < pFilterInfo->upperBndi) && (*(uint16_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_INT: + return ((*(int32_t *)minval < pFilterInfo->upperBndi) && (*(int32_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UINT: + return ((*(uint32_t *)minval < pFilterInfo->upperBndi) && (*(uint32_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: + return ((*(int64_t *)minval < pFilterInfo->upperBndi) && (*(int64_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UBIGINT: + return ((*(uint64_t *)minval < pFilterInfo->upperBndi) && (*(uint64_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_FLOAT: + return ((*(float *)minval < pFilterInfo->upperBndd) && (*(float *)maxval > pFilterInfo->lowerBndd)); + case TSDB_DATA_TYPE_DOUBLE: + return ((*(double *)minval < pFilterInfo->upperBndd) && (*(double *)maxval > pFilterInfo->lowerBndd)); + default: + return false; + } } -bool rangeFilter_i8_ie(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int8_t *)minval < pFilter->filterInfo.upperBndi && *(int8_t *)maxval >= pFilter->filterInfo.lowerBndi); +bool rangeFilter_ie(SColumnFilterElem *pFilter, const char *minval, const char *maxval, int16_t type) { + SColumnFilterInfo *pFilterInfo = &pFilter->filterInfo; + + switch (type) { + case TSDB_DATA_TYPE_TINYINT: + return ((*(int8_t *)minval < pFilterInfo->upperBndi) && (*(int8_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UTINYINT: + return ((*(uint8_t *)minval < pFilterInfo->upperBndi) && (*(uint8_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_SMALLINT: + return ((*(int16_t *)minval < pFilterInfo->upperBndi) && (*(int16_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_USMALLINT: + return ((*(uint16_t *)minval < pFilterInfo->upperBndi) && (*(uint16_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_INT: + return ((*(int32_t *)minval < pFilterInfo->upperBndi) && (*(int32_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UINT: + return ((*(uint32_t *)minval < pFilterInfo->upperBndi) && (*(uint32_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: + return ((*(int64_t *)minval < pFilterInfo->upperBndi) && (*(int64_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UBIGINT: + return ((*(uint64_t *)minval < pFilterInfo->upperBndi) && (*(uint64_t *)maxval >= pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_FLOAT: + return ((*(float *)minval < pFilterInfo->upperBndd) && (*(float *)maxval >= pFilterInfo->lowerBndd)); + case TSDB_DATA_TYPE_DOUBLE: + return ((*(double *)minval < pFilterInfo->upperBndd) && (*(double *)maxval >= pFilterInfo->lowerBndd)); + default: + return false; + } } -bool rangeFilter_i8_ei(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int8_t *)minval <= pFilter->filterInfo.upperBndi && *(int8_t *)maxval > pFilter->filterInfo.lowerBndi); -} +bool rangeFilter_ei(SColumnFilterElem *pFilter, const char *minval, const char *maxval, int16_t type) { + SColumnFilterInfo *pFilterInfo = &pFilter->filterInfo; -///////////////////////////////////////////////////////////////////////////////////// -bool rangeFilter_i16_ii(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int16_t *)minval <= pFilter->filterInfo.upperBndi && *(int16_t *)maxval >= pFilter->filterInfo.lowerBndi); -} - -bool rangeFilter_i16_ee(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int16_t *)minvalfilterInfo.upperBndi &&*(int16_t *)maxval> pFilter->filterInfo.lowerBndi); -} - -bool rangeFilter_i16_ie(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int16_t *)minval < pFilter->filterInfo.upperBndi && *(int16_t *)maxval >= pFilter->filterInfo.lowerBndi); -} - -bool rangeFilter_i16_ei(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int16_t *)minval <= pFilter->filterInfo.upperBndi && *(int16_t *)maxval > pFilter->filterInfo.lowerBndi); -} - -//////////////////////////////////////////////////////////////////////// -bool rangeFilter_i64_ii(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int64_t *)minval <= pFilter->filterInfo.upperBndi && *(int64_t *)maxval >= pFilter->filterInfo.lowerBndi); -} - -bool rangeFilter_i64_ee(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int64_t *)minvalfilterInfo.upperBndi &&*(int64_t *)maxval> pFilter->filterInfo.lowerBndi); -} - -bool rangeFilter_i64_ie(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int64_t *)minval < pFilter->filterInfo.upperBndi && *(int64_t *)maxval >= pFilter->filterInfo.lowerBndi); -} - -bool rangeFilter_i64_ei(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(int64_t *)minval <= pFilter->filterInfo.upperBndi && *(int64_t *)maxval > pFilter->filterInfo.lowerBndi); -} - -//////////////////////////////////////////////////////////////////////// -bool rangeFilter_ds_ii(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return FLT_LESSEQUAL(*(float *)minval, pFilter->filterInfo.upperBndd) && - FLT_GREATEREQUAL(*(float *)maxval, pFilter->filterInfo.lowerBndd); -} - -bool rangeFilter_ds_ee(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(float *)minvalfilterInfo.upperBndd &&*(float *)maxval> pFilter->filterInfo.lowerBndd); -} - -bool rangeFilter_ds_ie(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(float *)minval < pFilter->filterInfo.upperBndd && *(float *)maxval >= pFilter->filterInfo.lowerBndd); -} - -bool rangeFilter_ds_ei(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return FLT_GREATER(*(float *)maxval, pFilter->filterInfo.lowerBndd) && - FLT_LESSEQUAL(*(float *)minval, pFilter->filterInfo.upperBndd); -} - -////////////////////////////////////////////////////////////////////////// -bool rangeFilter_dd_ii(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(double *)minval <= pFilter->filterInfo.upperBndd && *(double *)maxval >= pFilter->filterInfo.lowerBndd); -} - -bool rangeFilter_dd_ee(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(double *)minvalfilterInfo.upperBndd &&*(double *)maxval> pFilter->filterInfo.lowerBndd); -} - -bool rangeFilter_dd_ie(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(double *)minval < pFilter->filterInfo.upperBndd && *(double *)maxval >= pFilter->filterInfo.lowerBndd); -} - -bool rangeFilter_dd_ei(SColumnFilterElem *pFilter, char *minval, char *maxval) { - return (*(double *)minval <= pFilter->filterInfo.upperBndd && *(double *)maxval > pFilter->filterInfo.lowerBndd); + switch (type) { + case TSDB_DATA_TYPE_TINYINT: + return ((*(int8_t *)minval <= pFilterInfo->upperBndi) && (*(int8_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UTINYINT: + return ((*(uint8_t *)minval <= pFilterInfo->upperBndi) && (*(uint8_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_SMALLINT: + return ((*(int16_t *)minval <= pFilterInfo->upperBndi) && (*(int16_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_USMALLINT: + return ((*(uint16_t *)minval <= pFilterInfo->upperBndi) && (*(uint16_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_INT: + return ((*(int32_t *)minval <= pFilterInfo->upperBndi) && (*(int32_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UINT: + return ((*(uint32_t *)minval <= pFilterInfo->upperBndi) && (*(uint32_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_TIMESTAMP: + case TSDB_DATA_TYPE_BIGINT: + return ((*(int64_t *)minval <= pFilterInfo->upperBndi) && (*(int64_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_UBIGINT: + return ((*(uint64_t *)minval <= pFilterInfo->upperBndi) && (*(uint64_t *)maxval > pFilterInfo->lowerBndi)); + case TSDB_DATA_TYPE_FLOAT: + return FLT_GREATER(*(float *)maxval, pFilterInfo->lowerBndd) && + FLT_LESSEQUAL(*(float *)minval, pFilterInfo->upperBndd); + case TSDB_DATA_TYPE_DOUBLE: + return ((*(double *)minval <= pFilterInfo->upperBndd) && (*(double *)maxval > pFilterInfo->lowerBndd)); + default: + return false; + } } //////////////////////////////////////////////////////////////////////////// -bool (*filterFunc_i8[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - less_i8, - larger_i8, - equal_i8, - lessEqual_i8, - largeEqual_i8, - nequal_i8, - NULL, - isNull_filter, - notNull_filter, +bool (*filterOperators[])(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type) = { + NULL, + lessOperator, + greaterOperator, + equalOperator, + lessEqualOperator, + greaterEqualOperator, + notEqualOperator, + likeOperator, + isNullOperator, + notNullOperator, }; -bool (*filterFunc_i16[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - less_i16, - larger_i16, - equal_i16, - lessEqual_i16, - largeEqual_i16, - nequal_i16, - NULL, - isNull_filter, - notNull_filter, +bool (*rangeFilterOperators[])(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type) = { + NULL, + rangeFilter_ee, + rangeFilter_ie, + rangeFilter_ei, + rangeFilter_ii, }; -bool (*filterFunc_i32[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - less_i32, - larger_i32, - equal_i32, - lessEqual_i32, - largeEqual_i32, - nequal_i32, - NULL, - isNull_filter, - notNull_filter, -}; +__filter_func_t getFilterOperator(int32_t lowerOptr, int32_t upperOptr) { + __filter_func_t funcFp = NULL; -bool (*filterFunc_i64[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - less_i64, - larger_i64, - equal_i64, - lessEqual_i64, - largeEqual_i64, - nequal_i64, - NULL, - isNull_filter, - notNull_filter, -}; + if ((lowerOptr == TSDB_RELATION_GREATER_EQUAL || lowerOptr == TSDB_RELATION_GREATER) && + (upperOptr == TSDB_RELATION_LESS_EQUAL || upperOptr == TSDB_RELATION_LESS)) { + if (lowerOptr == TSDB_RELATION_GREATER_EQUAL) { + if (upperOptr == TSDB_RELATION_LESS_EQUAL) { + funcFp = rangeFilterOperators[4]; + } else { + funcFp = rangeFilterOperators[2]; + } + } else { + if (upperOptr == TSDB_RELATION_LESS_EQUAL) { + funcFp = rangeFilterOperators[3]; + } else { + funcFp = rangeFilterOperators[1]; + } + } + } else { // set callback filter function + if (lowerOptr != TSDB_RELATION_INVALID) { + funcFp = filterOperators[lowerOptr]; -bool (*filterFunc_ds[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - less_ds, - larger_ds, - equal_ds, - lessEqual_ds, - largeEqual_ds, - nequal_ds, - NULL, - isNull_filter, - notNull_filter, -}; - -bool (*filterFunc_dd[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - less_dd, - larger_dd, - equal_dd, - lessEqual_dd, - largeEqual_dd, - nequal_dd, - NULL, - isNull_filter, - notNull_filter, -}; - -bool (*filterFunc_str[])(SColumnFilterElem* pFilter, char* minval, char *maxval) = { - NULL, - NULL, - NULL, - equal_str, - NULL, - NULL, - nequal_str, - like_str, - isNull_filter, - notNull_filter, -}; - -bool (*filterFunc_nchar[])(SColumnFilterElem* pFitler, char* minval, char* maxval) = { - NULL, - NULL, - NULL, - equal_nchar, - NULL, - NULL, - nequal_nchar, - like_nchar, - isNull_filter, - notNull_filter, -}; - -bool (*rangeFilterFunc_i8[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - rangeFilter_i8_ee, - rangeFilter_i8_ie, - rangeFilter_i8_ei, - rangeFilter_i8_ii, -}; - -bool (*rangeFilterFunc_i16[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - rangeFilter_i16_ee, - rangeFilter_i16_ie, - rangeFilter_i16_ei, - rangeFilter_i16_ii, -}; - -bool (*rangeFilterFunc_i32[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - rangeFilter_i32_ee, - rangeFilter_i32_ie, - rangeFilter_i32_ei, - rangeFilter_i32_ii, -}; - -bool (*rangeFilterFunc_i64[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - rangeFilter_i64_ee, - rangeFilter_i64_ie, - rangeFilter_i64_ei, - rangeFilter_i64_ii, -}; - -bool (*rangeFilterFunc_ds[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - rangeFilter_ds_ee, - rangeFilter_ds_ie, - rangeFilter_ds_ei, - rangeFilter_ds_ii, -}; - -bool (*rangeFilterFunc_dd[])(SColumnFilterElem *pFilter, char *minval, char *maxval) = { - NULL, - rangeFilter_dd_ee, - rangeFilter_dd_ie, - rangeFilter_dd_ei, - rangeFilter_dd_ii, -}; - -__filter_func_t* getRangeFilterFuncArray(int32_t type) { - switch(type) { - case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: return rangeFilterFunc_i8; - case TSDB_DATA_TYPE_SMALLINT: return rangeFilterFunc_i16; - case TSDB_DATA_TYPE_INT: return rangeFilterFunc_i32; - case TSDB_DATA_TYPE_TIMESTAMP: //timestamp uses bigint filter - case TSDB_DATA_TYPE_BIGINT: return rangeFilterFunc_i64; - case TSDB_DATA_TYPE_FLOAT: return rangeFilterFunc_ds; - case TSDB_DATA_TYPE_DOUBLE: return rangeFilterFunc_dd; - default:return NULL; + // invalid filter condition: %d", pQInfo, type + if (upperOptr != TSDB_RELATION_INVALID) { + return NULL; + } + } else { + funcFp = filterOperators[upperOptr]; + } } -} -__filter_func_t* getValueFilterFuncArray(int32_t type) { - switch(type) { - case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: return filterFunc_i8; - case TSDB_DATA_TYPE_SMALLINT: return filterFunc_i16; - case TSDB_DATA_TYPE_INT: return filterFunc_i32; - case TSDB_DATA_TYPE_TIMESTAMP: //timestamp uses bigint filter - case TSDB_DATA_TYPE_BIGINT: return filterFunc_i64; - case TSDB_DATA_TYPE_FLOAT: return filterFunc_ds; - case TSDB_DATA_TYPE_DOUBLE: return filterFunc_dd; - case TSDB_DATA_TYPE_BINARY: return filterFunc_str; - case TSDB_DATA_TYPE_NCHAR: return filterFunc_nchar; - default: return NULL; - } + return funcFp; } diff --git a/src/query/src/qHistogram.c b/src/query/src/qHistogram.c index 98b825c11f..bdc071060c 100644 --- a/src/query/src/qHistogram.c +++ b/src/query/src/qHistogram.c @@ -174,11 +174,11 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) { if ((*pHisto)->numOfElems >= 1 && idx < (*pHisto)->numOfEntries) { if (idx > 0) { assert((*pHisto)->elems[idx - 1].val <= val); + } else { + assert((*pHisto)->elems[idx].val > val); } - - assert((*pHisto)->elems[idx].val > val); } else if ((*pHisto)->numOfElems > 0) { - assert((*pHisto)->elems[(*pHisto)->numOfEntries].val < val); + assert((*pHisto)->elems[(*pHisto)->numOfEntries].val <= val); } histogramCreateBin(*pHisto, idx, val); diff --git a/src/query/src/qParserImpl.c b/src/query/src/qParserImpl.c index 4b3a56e4ee..d311cb3557 100644 --- a/src/query/src/qParserImpl.c +++ b/src/query/src/qParserImpl.c @@ -129,11 +129,11 @@ tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) { pSqlExpr->nSQLOptr = optrType; } else if (optrType == TK_NOW) { // use microsecond by default - pSqlExpr->val.i64Key = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO); + pSqlExpr->val.i64 = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO); pSqlExpr->val.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond } else if (optrType == TK_VARIABLE) { - int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->val.i64Key); + int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->val.i64); if (ret != TSDB_CODE_SUCCESS) { terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; } @@ -200,25 +200,25 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { switch (optrType) { case TK_PLUS: { - pExpr->val.i64Key = pLeft->val.i64Key + pRight->val.i64Key; + pExpr->val.i64 = pLeft->val.i64 + pRight->val.i64; break; } case TK_MINUS: { - pExpr->val.i64Key = pLeft->val.i64Key - pRight->val.i64Key; + pExpr->val.i64 = pLeft->val.i64 - pRight->val.i64; break; } case TK_STAR: { - pExpr->val.i64Key = pLeft->val.i64Key * pRight->val.i64Key; + pExpr->val.i64 = pLeft->val.i64 * pRight->val.i64; break; } case TK_DIVIDE: { pExpr->nSQLOptr = TK_FLOAT; pExpr->val.nType = TSDB_DATA_TYPE_DOUBLE; - pExpr->val.dKey = (double)pLeft->val.i64Key / pRight->val.i64Key; + pExpr->val.dKey = (double)pLeft->val.i64 / pRight->val.i64; break; } case TK_REM: { - pExpr->val.i64Key = pLeft->val.i64Key % pRight->val.i64Key; + pExpr->val.i64 = pLeft->val.i64 % pRight->val.i64; break; } } @@ -231,8 +231,8 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { pExpr->val.nType = TSDB_DATA_TYPE_DOUBLE; pExpr->nSQLOptr = TK_FLOAT; - double left = (pLeft->val.nType == TSDB_DATA_TYPE_DOUBLE) ? pLeft->val.dKey : pLeft->val.i64Key; - double right = (pRight->val.nType == TSDB_DATA_TYPE_DOUBLE) ? pRight->val.dKey : pRight->val.i64Key; + double left = (pLeft->val.nType == TSDB_DATA_TYPE_DOUBLE) ? pLeft->val.dKey : pLeft->val.i64; + double right = (pRight->val.nType == TSDB_DATA_TYPE_DOUBLE) ? pRight->val.dKey : pRight->val.i64; switch (optrType) { case TK_PLUS: { @@ -384,7 +384,7 @@ void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) pField->name[pName->n] = 0; pField->type = pType->type; - if(pField->type < TSDB_DATA_TYPE_BOOL || pField->type > TSDB_DATA_TYPE_NCHAR){ + if(!isValidDataType(pField->type)){ pField->bytes = 0; } else { pField->bytes = pType->bytes; @@ -393,50 +393,60 @@ void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) } void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type) { + // set the field type invalid pField->type = -1; + pField->name[0] = 0; - for (int32_t i = 0; i < tListLen(tDataTypeDesc); ++i) { - if ((strncasecmp(type->z, tDataTypeDesc[i].aName, tDataTypeDesc[i].nameLen) == 0) && - (type->n == tDataTypeDesc[i].nameLen)) { - pField->type = i; - pField->bytes = tDataTypeDesc[i].nSize; - - if (i == TSDB_DATA_TYPE_NCHAR) { - /* - * for nchar, the TOKENTYPE is the number of character, so the length is the - * number of bytes in UCS-4 format, which is 4 times larger than the - * number of characters - */ - if (type->type == 0) { - pField->bytes = 0; - } else { - int32_t bytes = -(int32_t)(type->type); - if (bytes > (TSDB_MAX_NCHAR_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - // we have to postpone reporting the error because it cannot be done here - // as pField->bytes is int16_t, use 'TSDB_MAX_NCHAR_LEN + 1' to avoid overflow - bytes = TSDB_MAX_NCHAR_LEN + 1; - } else { - bytes = bytes * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; - } - pField->bytes = (int16_t)bytes; - } - } else if (i == TSDB_DATA_TYPE_BINARY) { - /* for binary, the TOKENTYPE is the length of binary */ - if (type->type == 0) { - pField->bytes = 0; - } else { - int32_t bytes = -(int32_t)(type->type); - if (bytes > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) { - // refer comment for NCHAR above - bytes = TSDB_MAX_BINARY_LEN + 1; - } else { - bytes += VARSTR_HEADER_SIZE; - } - pField->bytes = (int16_t)bytes; - } - } + int32_t i = 0; + while (i < tListLen(tDataTypeDesc)) { + if ((type->n == tDataTypeDesc[i].nameLen) && + (strncasecmp(type->z, tDataTypeDesc[i].aName, tDataTypeDesc[i].nameLen) == 0)) { break; } + + i += 1; + } + + if (i == tListLen(tDataTypeDesc)) { + return; + } + + pField->type = i; + pField->bytes = tDataTypeDesc[i].nSize; + + if (i == TSDB_DATA_TYPE_NCHAR) { + /* + * for nchar, the TOKENTYPE is the number of character, so the length is the + * number of bytes in UCS-4 format, which is 4 times larger than the number of characters + */ + if (type->type == 0) { + pField->bytes = 0; + } else { + int32_t bytes = -(int32_t)(type->type); + if (bytes > (TSDB_MAX_NCHAR_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { + // we have to postpone reporting the error because it cannot be done here + // as pField->bytes is int16_t, use 'TSDB_MAX_NCHAR_LEN + 1' to avoid overflow + bytes = TSDB_MAX_NCHAR_LEN + 1; + } else { + bytes = bytes * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; + } + pField->bytes = (int16_t)bytes; + } + } else if (i == TSDB_DATA_TYPE_BINARY) { + /* for binary, the TOKENTYPE is the length of binary */ + if (type->type == 0) { + pField->bytes = 0; + } else { + int32_t bytes = -(int32_t)(type->type); + if (bytes > TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE) { + // refer comment for NCHAR above + bytes = TSDB_MAX_BINARY_LEN + 1; + } else { + bytes += VARSTR_HEADER_SIZE; + } + + pField->bytes = (int16_t)bytes; + } } } diff --git a/src/query/src/qPercentile.c b/src/query/src/qPercentile.c index 51125d62b9..3e4891092a 100644 --- a/src/query/src/qPercentile.c +++ b/src/query/src/qPercentile.c @@ -12,14 +12,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +#include "os.h" #include "qPercentile.h" #include "qResultbuf.h" -#include "os.h" #include "queryLog.h" #include "taosdef.h" -#include "tulog.h" #include "tcompare.h" +#include "ttype.h" #define DEFAULT_NUM_OF_SLOT 1024 @@ -48,25 +48,15 @@ static tFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx) } static void resetBoundingBox(MinMaxEntry* range, int32_t type) { - switch (type) { - case TSDB_DATA_TYPE_BIGINT: { - range->i64MaxVal = INT64_MIN; - range->i64MinVal = INT64_MAX; - break; - }; - case TSDB_DATA_TYPE_INT: - case TSDB_DATA_TYPE_SMALLINT: - case TSDB_DATA_TYPE_TINYINT: { - range->iMaxVal = INT32_MIN; - range->iMinVal = INT32_MAX; - break; - }; - case TSDB_DATA_TYPE_DOUBLE: - case TSDB_DATA_TYPE_FLOAT: { - range->dMaxVal = -DBL_MAX; - range->dMinVal = DBL_MAX; - break; - } + if (IS_SIGNED_NUMERIC_TYPE(type)) { + range->i64MaxVal = INT64_MIN; + range->i64MinVal = INT64_MAX; + } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { + range->u64MaxVal = 0; + range->u64MinVal = UINT64_MAX; + } else { + range->dMaxVal = -DBL_MAX; + range->dMinVal = DBL_MAX; } } @@ -75,23 +65,15 @@ static int32_t setBoundingBox(MinMaxEntry* range, int16_t type, double minval, d return -1; } - switch(type) { - case TSDB_DATA_TYPE_TINYINT: - case TSDB_DATA_TYPE_SMALLINT: - case TSDB_DATA_TYPE_INT: - range->iMinVal = (int32_t) minval; - range->iMaxVal = (int32_t) maxval; - break; - - case TSDB_DATA_TYPE_BIGINT: - range->i64MinVal = (int64_t) minval; - range->i64MaxVal = (int64_t) maxval; - break; - case TSDB_DATA_TYPE_FLOAT: - case TSDB_DATA_TYPE_DOUBLE: - range->dMinVal = minval; - range->dMaxVal = maxval; - break; + if (IS_SIGNED_NUMERIC_TYPE(type)) { + range->i64MinVal = (int64_t) minval; + range->i64MaxVal = (int64_t) maxval; + } else if (IS_UNSIGNED_NUMERIC_TYPE(type)){ + range->u64MinVal = (uint64_t) minval; + range->u64MaxVal = (uint64_t) maxval; + } else { + range->dMinVal = minval; + range->dMaxVal = maxval; } return 0; @@ -120,117 +102,56 @@ double findOnlyResult(tMemBucket *pMemBucket) { tFilePage* pPage = getResBufPage(pMemBucket->pBuffer, pgInfo->pageId); assert(pPage->num == 1); - switch (pMemBucket->type) { - case TSDB_DATA_TYPE_INT: - return *(int32_t *)pPage->data; - case TSDB_DATA_TYPE_SMALLINT: - return *(int16_t *)pPage->data; - case TSDB_DATA_TYPE_TINYINT: - return *(int8_t *)pPage->data; - case TSDB_DATA_TYPE_BIGINT: - return (double)(*(int64_t *)pPage->data); - case TSDB_DATA_TYPE_DOUBLE: { - double dv = GET_DOUBLE_VAL(pPage->data); - return dv; - } - case TSDB_DATA_TYPE_FLOAT: { - float fv = GET_FLOAT_VAL(pPage->data); - return fv; - } - default: - return 0; - } + double v = 0; + GET_TYPED_DATA(v, double, pMemBucket->type, pPage->data); + return v; } return 0; } -int32_t tBucketBigIntHash(tMemBucket *pBucket, const void *value) { - int64_t v = *(int64_t *)value; +int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) { + int64_t v = 0; + GET_TYPED_DATA(v, int64_t, pBucket->type, value); + int32_t index = -1; - - int32_t halfSlot = pBucket->numOfSlots >> 1; -// int32_t bits = 32;//bitsOfNumber(pBucket->numOfSlots) - 1; - - if (pBucket->range.i64MaxVal == INT64_MIN) { - if (v >= 0) { - index = (v >> (64 - 9)) + halfSlot; - } else { // v<0 - index = ((-v) >> (64 - 9)); - index = -index + (halfSlot - 1); - } - - return index; + // divide the value range into 1024 buckets + uint64_t span = pBucket->range.i64MaxVal - pBucket->range.i64MinVal; + if (span < pBucket->numOfSlots) { + int64_t delta = v - pBucket->range.i64MinVal; + index = (delta % pBucket->numOfSlots); } else { - // out of range - if (v < pBucket->range.i64MinVal || v > pBucket->range.i64MaxVal) { - return -1; + double slotSpan = (double)span / pBucket->numOfSlots; + index = (int32_t)((v - pBucket->range.i64MinVal) / slotSpan); + if (v == pBucket->range.i64MaxVal) { + index -= 1; } - - // todo hash for bigint and float and double - int64_t span = pBucket->range.i64MaxVal - pBucket->range.i64MinVal; - if (span < pBucket->numOfSlots) { - int32_t delta = (int32_t)(v - pBucket->range.i64MinVal); - index = delta % pBucket->numOfSlots; - } else { - double slotSpan = (double)span / pBucket->numOfSlots; - index = (int32_t)((v - pBucket->range.i64MinVal) / slotSpan); - if (v == pBucket->range.i64MaxVal) { - index -= 1; - } - } - - return index; } + + assert(v >= pBucket->range.i64MinVal && v <= pBucket->range.i64MaxVal && index >= 0 && index < pBucket->numOfSlots); + return index; } -// todo refactor to more generic -int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) { - int32_t v = 0; - switch(pBucket->type) { - case TSDB_DATA_TYPE_SMALLINT: v = *(int16_t*) value; break; - case TSDB_DATA_TYPE_TINYINT: v = *(int8_t*) value; break; - default: v = *(int32_t*) value;break; - } +int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) { + int64_t v = 0; + GET_TYPED_DATA(v, uint64_t, pBucket->type, value); int32_t index = -1; - if (pBucket->range.iMaxVal == INT32_MIN) { - /* - * taking negative integer into consideration, - * there is only half of pBucket->segs available for non-negative integer - */ - int32_t halfSlot = pBucket->numOfSlots >> 1; - int32_t bits = 32;//bitsOfNumber(pBucket->numOfSlots) - 1; - - if (v >= 0) { - index = (v >> (bits - 9)) + halfSlot; - } else { // v < 0 - index = ((-v) >> (32 - 9)); - index = -index + (halfSlot - 1); - } - - return index; + // divide the value range into 1024 buckets + uint64_t span = pBucket->range.u64MaxVal - pBucket->range.u64MinVal; + if (span < pBucket->numOfSlots) { + int64_t delta = v - pBucket->range.u64MinVal; + index = (int32_t) (delta % pBucket->numOfSlots); } else { - // out of range - if (v < pBucket->range.iMinVal || v > pBucket->range.iMaxVal) { - return -1; + double slotSpan = (double)span / pBucket->numOfSlots; + index = (int32_t)((v - pBucket->range.u64MinVal) / slotSpan); + if (v == pBucket->range.u64MaxVal) { + index -= 1; } - - // divide a range of [iMinVal, iMaxVal] into 1024 buckets - int32_t span = pBucket->range.iMaxVal - pBucket->range.iMinVal; - if (span < pBucket->numOfSlots) { - int32_t delta = v - pBucket->range.iMinVal; - index = (delta % pBucket->numOfSlots); - } else { - double slotSpan = (double)span / pBucket->numOfSlots; - index = (int32_t)((v - pBucket->range.iMinVal) / slotSpan); - if (v == pBucket->range.iMaxVal) { - index -= 1; - } - } - - return index; } + + assert(v >= pBucket->range.u64MinVal && v <= pBucket->range.i64MaxVal && index >= 0 && index < pBucket->numOfSlots); + return index; } int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) { @@ -243,62 +164,30 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) { int32_t index = -1; - if (pBucket->range.dMinVal == DBL_MAX) { - /* - * taking negative integer into consideration, - * there is only half of pBucket->segs available for non-negative integer - */ - double x = DBL_MAX / (pBucket->numOfSlots >> 1); - double posx = (v + DBL_MAX) / x; - return ((int32_t)posx) % pBucket->numOfSlots; + // divide a range of [dMinVal, dMaxVal] into 1024 buckets + double span = pBucket->range.dMaxVal - pBucket->range.dMinVal; + if (span < pBucket->numOfSlots) { + int32_t delta = (int32_t)(v - pBucket->range.dMinVal); + index = (delta % pBucket->numOfSlots); } else { - - // out of range - if (v < pBucket->range.dMinVal || v > pBucket->range.dMaxVal) { - return -1; + double slotSpan = span / pBucket->numOfSlots; + index = (int32_t)((v - pBucket->range.dMinVal) / slotSpan); + if (v == pBucket->range.dMaxVal) { + index -= 1; } - - // divide a range of [dMinVal, dMaxVal] into 1024 buckets - double span = pBucket->range.dMaxVal - pBucket->range.dMinVal; - if (span < pBucket->numOfSlots) { - int32_t delta = (int32_t)(v - pBucket->range.dMinVal); - index = (delta % pBucket->numOfSlots); - } else { - double slotSpan = span / pBucket->numOfSlots; - index = (int32_t)((v - pBucket->range.dMinVal) / slotSpan); - if (v == pBucket->range.dMaxVal) { - index -= 1; - } - } - - if (index < 0 || index > pBucket->numOfSlots) { - uError("error in hash process. slot id: %d", index); - } - - return index; } + + assert(v >= pBucket->range.dMinVal && v <= pBucket->range.dMaxVal && index >= 0 && index < pBucket->numOfSlots); + return index; } static __perc_hash_func_t getHashFunc(int32_t type) { - switch (type) { - case TSDB_DATA_TYPE_INT: - case TSDB_DATA_TYPE_SMALLINT: - case TSDB_DATA_TYPE_TINYINT: { - return tBucketIntHash; - }; - - case TSDB_DATA_TYPE_DOUBLE: - case TSDB_DATA_TYPE_FLOAT: { - return tBucketDoubleHash; - }; - - case TSDB_DATA_TYPE_BIGINT: { - return tBucketBigIntHash; - }; - - default: { - return NULL; - } + if (IS_SIGNED_NUMERIC_TYPE(type)) { + return tBucketIntHash; + } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { + return tBucketUintHash; + } else { + return tBucketDoubleHash; } } @@ -328,7 +217,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval, pBucket->maxCapacity = 200000; if (setBoundingBox(&pBucket->range, pBucket->type, minval, maxval) != 0) { - uError("MemBucket:%p, invalid value range: %f-%f", pBucket, minval, maxval); + qError("MemBucket:%p, invalid value range: %f-%f", pBucket, minval, maxval); free(pBucket); return NULL; } @@ -338,7 +227,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval, pBucket->hashFunc = getHashFunc(pBucket->type); if (pBucket->hashFunc == NULL) { - uError("MemBucket:%p, not support data type %d, failed", pBucket, pBucket->type); + qError("MemBucket:%p, not support data type %d, failed", pBucket, pBucket->type); free(pBucket); return NULL; } @@ -357,7 +246,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval, return NULL; } - uDebug("MemBucket:%p, elem size:%d", pBucket, pBucket->bytes); + qDebug("MemBucket:%p, elem size:%d", pBucket, pBucket->bytes); return pBucket; } @@ -372,77 +261,41 @@ void tMemBucketDestroy(tMemBucket *pBucket) { } void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataType) { - switch (dataType) { - case TSDB_DATA_TYPE_INT: { - int32_t val = *(int32_t *)data; - if (r->iMinVal > val) { - r->iMinVal = val; - } + if (IS_SIGNED_NUMERIC_TYPE(dataType)) { + int64_t v = 0; + GET_TYPED_DATA(v, int64_t, dataType, data); - if (r->iMaxVal < val) { - r->iMaxVal = val; - } - break; - }; - case TSDB_DATA_TYPE_BIGINT: { - int64_t val = *(int64_t *)data; - if (r->i64MinVal > val) { - r->i64MinVal = val; - } + if (r->i64MinVal > v) { + r->i64MinVal = v; + } - if (r->i64MaxVal < val) { - r->i64MaxVal = val; - } - break; - }; - case TSDB_DATA_TYPE_SMALLINT: { - int32_t val = *(int16_t *)data; - if (r->iMinVal > val) { - r->iMinVal = val; - } + if (r->i64MaxVal < v) { + r->i64MaxVal = v; + } + } else if (IS_UNSIGNED_NUMERIC_TYPE(dataType)) { + uint64_t v = 0; + GET_TYPED_DATA(v, uint64_t, dataType, data); - if (r->iMaxVal < val) { - r->iMaxVal = val; - } - break; - }; - case TSDB_DATA_TYPE_TINYINT: { - int32_t val = *(int8_t *)data; - if (r->iMinVal > val) { - r->iMinVal = val; - } + if (r->i64MinVal > v) { + r->i64MinVal = v; + } - if (r->iMaxVal < val) { - r->iMaxVal = val; - } + if (r->i64MaxVal < v) { + r->i64MaxVal = v; + } + } else if (IS_FLOAT_TYPE(dataType)) { + double v = 0; + GET_TYPED_DATA(v, double, dataType, data); - break; - }; - case TSDB_DATA_TYPE_DOUBLE: { - // double val = *(double *)data; - double val = GET_DOUBLE_VAL(data); - if (r->dMinVal > val) { - r->dMinVal = val; - } + if (r->dMinVal > v) { + r->dMinVal = v; + } - if (r->dMaxVal < val) { - r->dMaxVal = val; - } - break; - }; - case TSDB_DATA_TYPE_FLOAT: { - double val = GET_FLOAT_VAL(data); - - if (r->dMinVal > val) { - r->dMinVal = val; - } - - if (r->dMaxVal < val) { - r->dMaxVal = val; - } - break; - }; - default: { assert(false); } + if (r->dMaxVal < v) { + r->dMaxVal = v; + } + } else { + assert(0); } } @@ -452,16 +305,13 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { assert(pBucket != NULL && data != NULL && size > 0); - pBucket->total += (int32_t)size; - + int32_t count = 0; int32_t bytes = pBucket->bytes; for (int32_t i = 0; i < size; ++i) { char *d = (char *) data + i * bytes; + count += 1; int32_t index = (pBucket->hashFunc)(pBucket, d); - if (index == -1) { // the value is out of range, do not add it into bucket - return -1; - } tMemBucketSlot *pSlot = &pBucket->pSlots[index]; tMemBucketUpdateBoundingBox(&pSlot->range, d, pBucket->type); @@ -489,64 +339,11 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { pSlot->info.size += 1; } + pBucket->total += count; return 0; } //////////////////////////////////////////////////////////////////////////////////////////// -static UNUSED_FUNC void findMaxMinValue(tMemBucket *pMemBucket, double *maxVal, double *minVal) { - *minVal = DBL_MAX; - *maxVal = -DBL_MAX; - - for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) { - tMemBucketSlot *pSlot = &pMemBucket->pSlots[i]; - if (pSlot->info.size == 0) { - continue; - } - - switch (pMemBucket->type) { - case TSDB_DATA_TYPE_INT: - case TSDB_DATA_TYPE_SMALLINT: - case TSDB_DATA_TYPE_TINYINT: { - double minv = pSlot->range.iMinVal; - double maxv = pSlot->range.iMaxVal; - - if (*minVal > minv) { - *minVal = minv; - } - if (*maxVal < maxv) { - *maxVal = maxv; - } - break; - } - case TSDB_DATA_TYPE_DOUBLE: - case TSDB_DATA_TYPE_FLOAT: { - double minv = pSlot->range.dMinVal; - double maxv = pSlot->range.dMaxVal; - - if (*minVal > minv) { - *minVal = minv; - } - if (*maxVal < maxv) { - *maxVal = maxv; - } - break; - } - case TSDB_DATA_TYPE_BIGINT: { - double minv = (double)pSlot->range.i64MinVal; - double maxv = (double)pSlot->range.i64MaxVal; - - if (*minVal > minv) { - *minVal = minv; - } - if (*maxVal < maxv) { - *maxVal = maxv; - } - break; - } - } - } -} - /* * * now, we need to find the minimum value of the next slot for @@ -565,7 +362,6 @@ static MinMaxEntry getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int3 } static bool isIdenticalData(tMemBucket *pMemBucket, int32_t index); -char *getFirstElemOfMemBuffer(tMemBucketSlot *pSeg, int32_t slotIdx, tFilePage *pPage); static double getIdenticalDataVal(tMemBucket* pMemBucket, int32_t slotIndex) { assert(isIdenticalData(pMemBucket, slotIndex)); @@ -573,24 +369,12 @@ static double getIdenticalDataVal(tMemBucket* pMemBucket, int32_t slotIndex) { tMemBucketSlot *pSlot = &pMemBucket->pSlots[slotIndex]; double finalResult = 0.0; - switch (pMemBucket->type) { - case TSDB_DATA_TYPE_SMALLINT: - case TSDB_DATA_TYPE_TINYINT: - case TSDB_DATA_TYPE_INT: { - finalResult = pSlot->range.iMinVal; - break; - } - - case TSDB_DATA_TYPE_FLOAT: - case TSDB_DATA_TYPE_DOUBLE: { - finalResult = pSlot->range.dMinVal; - break; - }; - - case TSDB_DATA_TYPE_BIGINT: { - finalResult = (double)pSlot->range.i64MinVal; - break; - } + if (IS_SIGNED_NUMERIC_TYPE(pMemBucket->type)) { + finalResult = (double) pSlot->range.i64MinVal; + } else if (IS_UNSIGNED_NUMERIC_TYPE(pMemBucket->type)) { + finalResult = (double) pSlot->range.u64MinVal; + } else { + finalResult = (double) pSlot->range.dMinVal; } return finalResult; @@ -616,26 +400,16 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) double maxOfThisSlot = 0; double minOfNextSlot = 0; - switch (pMemBucket->type) { - case TSDB_DATA_TYPE_INT: - case TSDB_DATA_TYPE_SMALLINT: - case TSDB_DATA_TYPE_TINYINT: { - maxOfThisSlot = pSlot->range.iMaxVal; - minOfNextSlot = next.iMinVal; - break; - }; - case TSDB_DATA_TYPE_FLOAT: - case TSDB_DATA_TYPE_DOUBLE: { - maxOfThisSlot = pSlot->range.dMaxVal; - minOfNextSlot = next.dMinVal; - break; - }; - case TSDB_DATA_TYPE_BIGINT: { - maxOfThisSlot = (double)pSlot->range.i64MaxVal; - minOfNextSlot = (double)next.i64MinVal; - break; - } - }; + if (IS_SIGNED_NUMERIC_TYPE(pMemBucket->type)) { + maxOfThisSlot = (double) pSlot->range.i64MaxVal; + minOfNextSlot = (double) next.i64MinVal; + } else if (IS_UNSIGNED_NUMERIC_TYPE(pMemBucket->type)) { + maxOfThisSlot = (double) pSlot->range.u64MaxVal; + minOfNextSlot = (double) next.u64MinVal; + } else { + maxOfThisSlot = (double) pSlot->range.dMaxVal; + minOfNextSlot = (double) next.dMinVal; + } assert(minOfNextSlot > maxOfThisSlot); @@ -652,38 +426,8 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) char *nextVal = thisVal + pMemBucket->bytes; double td = 1.0, nd = 1.0; - switch (pMemBucket->type) { - case TSDB_DATA_TYPE_SMALLINT: { - td = *(int16_t *)thisVal; - nd = *(int16_t *)nextVal; - break; - } - case TSDB_DATA_TYPE_TINYINT: { - td = *(int8_t *)thisVal; - nd = *(int8_t *)nextVal; - break; - } - case TSDB_DATA_TYPE_INT: { - td = *(int32_t *)thisVal; - nd = *(int32_t *)nextVal; - break; - }; - case TSDB_DATA_TYPE_FLOAT: { - td = GET_FLOAT_VAL(thisVal); - nd = GET_FLOAT_VAL(nextVal); - break; - } - case TSDB_DATA_TYPE_DOUBLE: { - td = GET_DOUBLE_VAL(thisVal); - nd = GET_DOUBLE_VAL(nextVal); - break; - } - case TSDB_DATA_TYPE_BIGINT: { - td = (double)*(int64_t *)thisVal; - nd = (double)*(int64_t *)nextVal; - break; - } - } + GET_TYPED_DATA(td, double, pMemBucket->type, thisVal); + GET_TYPED_DATA(nd, double, pMemBucket->type, nextVal); double val = (1 - fraction) * td + fraction * nd; tfree(buffer); @@ -696,7 +440,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) // try next round pMemBucket->times += 1; - uDebug("MemBucket:%p, start next round data bucketing, time:%d", pMemBucket, pMemBucket->times); + qDebug("MemBucket:%p, start next round data bucketing, time:%d", pMemBucket, pMemBucket->times); pMemBucket->range = pSlot->range; pMemBucket->total = 0; @@ -741,20 +485,14 @@ double getPercentile(tMemBucket *pMemBucket, double percent) { if (fabs(percent - 100.0) < DBL_EPSILON || (percent < DBL_EPSILON)) { MinMaxEntry* pRange = &pMemBucket->range; - switch(pMemBucket->type) { - case TSDB_DATA_TYPE_TINYINT: - case TSDB_DATA_TYPE_SMALLINT: - case TSDB_DATA_TYPE_INT: - return fabs(percent - 100) < DBL_EPSILON? pRange->iMaxVal:pRange->iMinVal; - case TSDB_DATA_TYPE_BIGINT: { - double v = (double)(fabs(percent - 100) < DBL_EPSILON ? pRange->i64MaxVal : pRange->i64MinVal); - return v; - } - case TSDB_DATA_TYPE_FLOAT: - case TSDB_DATA_TYPE_DOUBLE: - return fabs(percent - 100) < DBL_EPSILON? pRange->dMaxVal:pRange->dMinVal; - default: - return -1; + if (IS_SIGNED_NUMERIC_TYPE(pMemBucket->type)) { + double v = (double)(fabs(percent - 100) < DBL_EPSILON ? pRange->i64MaxVal : pRange->i64MinVal); + return v; + } else if (IS_UNSIGNED_NUMERIC_TYPE(pMemBucket->type)) { + double v = (double)(fabs(percent - 100) < DBL_EPSILON ? pRange->u64MaxVal : pRange->u64MinVal); + return v; + } else { + return fabs(percent - 100) < DBL_EPSILON? pRange->dMaxVal:pRange->dMinVal; } } @@ -771,40 +509,9 @@ double getPercentile(tMemBucket *pMemBucket, double percent) { bool isIdenticalData(tMemBucket *pMemBucket, int32_t index) { tMemBucketSlot *pSeg = &pMemBucket->pSlots[index]; - if (pMemBucket->type == TSDB_DATA_TYPE_INT || pMemBucket->type == TSDB_DATA_TYPE_BIGINT || - pMemBucket->type == TSDB_DATA_TYPE_SMALLINT || pMemBucket->type == TSDB_DATA_TYPE_TINYINT) { + if (IS_FLOAT_TYPE(pMemBucket->type)) { + return fabs(pSeg->range.dMaxVal - pSeg->range.dMinVal) < DBL_EPSILON; + } else { return pSeg->range.i64MinVal == pSeg->range.i64MaxVal; } - - if (pMemBucket->type == TSDB_DATA_TYPE_FLOAT || pMemBucket->type == TSDB_DATA_TYPE_DOUBLE) { - return fabs(pSeg->range.dMaxVal - pSeg->range.dMinVal) < DBL_EPSILON; - } - - return false; -} - -/* - * get the first element of one slot into memory. - * if no data of current slot in memory, load it from disk - */ -char *getFirstElemOfMemBuffer(tMemBucketSlot *pSeg, int32_t slotIdx, tFilePage *pPage) { -// STSBuf *pMemBuffer = pSeg->pBuffer[slotIdx]; - char *thisVal = NULL; - -// if (pSeg->pBuffer[slotIdx]->numOfTotal != 0) { -//// thisVal = pSeg->pBuffer[slotIdx]->pHead->item.data; -// } else { -// /* -// * no data in memory, load one page into memory -// */ -// tFlushoutInfo *pFlushInfo = &pMemBuffer->fileMeta.flushoutData.pFlushoutInfo[0]; -// assert(pFlushInfo->numOfPages == pMemBuffer->fileMeta.nFileSize); -// int32_t ret; -// ret = fseek(pMemBuffer->file, pFlushInfo->startPageId * pMemBuffer->pageSize, SEEK_SET); -// UNUSED(ret); -// size_t sz = fread(pPage, pMemBuffer->pageSize, 1, pMemBuffer->file); -// UNUSED(sz); -// thisVal = pPage->data; -// } - return thisVal; } diff --git a/src/query/src/qTokenizer.c b/src/query/src/qTokenizer.c index e243637333..48d2f5d505 100644 --- a/src/query/src/qTokenizer.c +++ b/src/query/src/qTokenizer.c @@ -129,6 +129,7 @@ static SKeyword keywordTable[] = { {"PRECISION", TK_PRECISION}, {"LP", TK_LP}, {"RP", TK_RP}, + {"UNSIGNED", TK_UNSIGNED}, {"TAGS", TK_TAGS}, {"USING", TK_USING}, {"AS", TK_AS}, diff --git a/src/query/src/qTsbuf.c b/src/query/src/qTsbuf.c index a5d4690a8e..a53f8935ee 100644 --- a/src/query/src/qTsbuf.c +++ b/src/query/src/qTsbuf.c @@ -268,7 +268,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) { metaLen += (int32_t)fwrite(pBlock->tag.pz, 1, (size_t)pBlock->tag.nLen, pTSBuf->f); } else if (pBlock->tag.nType != TSDB_DATA_TYPE_NULL) { metaLen += (int32_t)fwrite(&pBlock->tag.nLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f); - metaLen += (int32_t)fwrite(&pBlock->tag.i64Key, 1, (size_t) pBlock->tag.nLen, pTSBuf->f); + metaLen += (int32_t)fwrite(&pBlock->tag.i64, 1, (size_t) pBlock->tag.nLen, pTSBuf->f); } else { trueLen = 0; metaLen += (int32_t)fwrite(&trueLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f); @@ -351,7 +351,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) { sz = fread(pBlock->tag.pz, (size_t)pBlock->tag.nLen, 1, pTSBuf->f); UNUSED(sz); } else if (pBlock->tag.nType != TSDB_DATA_TYPE_NULL) { //TODO check the return value - sz = fread(&pBlock->tag.i64Key, (size_t) pBlock->tag.nLen, 1, pTSBuf->f); + sz = fread(&pBlock->tag.i64, (size_t) pBlock->tag.nLen, 1, pTSBuf->f); UNUSED(sz); } @@ -955,7 +955,7 @@ void tsBufDisplay(STSBuf* pTSBuf) { while (tsBufNextPos(pTSBuf)) { STSElem elem = tsBufGetElem(pTSBuf); if (elem.tag->nType == TSDB_DATA_TYPE_BIGINT) { - printf("%d-%" PRId64 "-%" PRId64 "\n", elem.id, elem.tag->i64Key, elem.ts); + printf("%d-%" PRId64 "-%" PRId64 "\n", elem.id, elem.tag->i64, elem.ts); } } diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 7c10a4ce6b..6c59a51074 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -97,27 +97,27 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 278 +#define YYNOCODE 279 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SQuerySQL* yy4; - SSubclauseInfo* yy13; - int yy70; - SCreatedTableInfo yy84; - SIntervalVal yy222; - TAOS_FIELD yy363; - tSQLExprList* yy382; - int64_t yy387; - SArray* yy403; - SLimitVal yy404; - SCreateTableSQL* yy436; - SCreateAcctSQL yy463; - SCreateDBInfo yy478; - tVariant yy488; - tSQLExpr* yy522; + SCreateTableSQL* yy38; + SCreateAcctSQL yy71; + tSQLExpr* yy78; + int yy96; + SQuerySQL* yy148; + SCreatedTableInfo yy152; + SSubclauseInfo* yy153; + tSQLExprList* yy166; + SLimitVal yy167; + TAOS_FIELD yy183; + SCreateDBInfo yy234; + int64_t yy325; + SIntervalVal yy400; + SArray* yy421; + tVariant yy430; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -128,16 +128,16 @@ typedef union { #define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 #define YYNSTATE 258 -#define YYNRULE 239 -#define YYNTOKEN 208 +#define YYNRULE 240 +#define YYNTOKEN 209 #define YY_MAX_SHIFT 257 -#define YY_MIN_SHIFTREDUCE 430 -#define YY_MAX_SHIFTREDUCE 668 -#define YY_ERROR_ACTION 669 -#define YY_ACCEPT_ACTION 670 -#define YY_NO_ACTION 671 -#define YY_MIN_REDUCE 672 -#define YY_MAX_REDUCE 910 +#define YY_MIN_SHIFTREDUCE 431 +#define YY_MAX_SHIFTREDUCE 670 +#define YY_ERROR_ACTION 671 +#define YY_ACCEPT_ACTION 672 +#define YY_NO_ACTION 673 +#define YY_MIN_REDUCE 674 +#define YY_MAX_REDUCE 913 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined @@ -203,228 +203,228 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (585) +#define YY_ACTTAB_COUNT (586) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 143, 473, 143, 23, 670, 257, 165, 545, 824, 474, - /* 10 */ 897, 168, 898, 37, 38, 12, 39, 40, 813, 23, - /* 20 */ 173, 31, 473, 473, 209, 43, 41, 45, 42, 802, - /* 30 */ 474, 474, 163, 36, 35, 231, 230, 34, 33, 32, - /* 40 */ 37, 38, 798, 39, 40, 813, 105, 173, 31, 162, - /* 50 */ 255, 209, 43, 41, 45, 42, 176, 178, 799, 194, - /* 60 */ 36, 35, 233, 821, 34, 33, 32, 431, 432, 433, - /* 70 */ 434, 435, 436, 437, 438, 439, 440, 441, 442, 256, - /* 80 */ 802, 143, 184, 63, 179, 37, 38, 224, 39, 40, - /* 90 */ 167, 898, 173, 31, 800, 29, 209, 43, 41, 45, - /* 100 */ 42, 110, 197, 791, 57, 36, 35, 251, 210, 34, - /* 110 */ 33, 32, 110, 17, 222, 250, 249, 221, 220, 219, - /* 120 */ 248, 218, 247, 246, 245, 217, 244, 243, 622, 772, - /* 130 */ 802, 760, 761, 762, 763, 764, 765, 766, 767, 768, - /* 140 */ 769, 770, 771, 773, 774, 242, 38, 180, 39, 40, - /* 150 */ 228, 227, 173, 31, 110, 18, 209, 43, 41, 45, - /* 160 */ 42, 851, 28, 204, 110, 36, 35, 23, 187, 34, - /* 170 */ 33, 32, 850, 39, 40, 191, 190, 173, 31, 224, - /* 180 */ 624, 209, 43, 41, 45, 42, 34, 33, 32, 9, - /* 190 */ 36, 35, 65, 120, 34, 33, 32, 172, 635, 638, - /* 200 */ 66, 626, 104, 629, 177, 632, 799, 172, 635, 28, - /* 210 */ 13, 626, 206, 629, 61, 632, 625, 172, 635, 142, - /* 220 */ 572, 626, 23, 629, 62, 632, 155, 196, 147, 169, - /* 230 */ 170, 793, 156, 208, 603, 604, 92, 91, 150, 169, - /* 240 */ 170, 894, 713, 580, 17, 133, 250, 249, 893, 169, - /* 250 */ 170, 248, 64, 247, 246, 245, 892, 244, 243, 229, - /* 260 */ 778, 799, 80, 776, 777, 590, 18, 242, 779, 107, - /* 270 */ 781, 782, 780, 28, 783, 784, 43, 41, 45, 42, - /* 280 */ 159, 790, 22, 792, 36, 35, 160, 171, 34, 33, - /* 290 */ 32, 722, 564, 193, 133, 561, 44, 562, 52, 563, - /* 300 */ 158, 254, 253, 98, 36, 35, 44, 634, 34, 33, - /* 310 */ 32, 23, 145, 3, 124, 53, 44, 634, 146, 72, - /* 320 */ 68, 71, 633, 181, 182, 148, 714, 634, 4, 133, - /* 330 */ 78, 82, 633, 137, 135, 149, 87, 90, 81, 95, - /* 340 */ 94, 93, 633, 153, 84, 594, 577, 154, 234, 48, - /* 350 */ 799, 19, 49, 152, 595, 654, 636, 141, 15, 14, - /* 360 */ 14, 628, 627, 631, 630, 553, 212, 151, 554, 24, - /* 370 */ 24, 50, 48, 77, 76, 11, 10, 568, 566, 569, - /* 380 */ 567, 89, 88, 103, 101, 907, 144, 801, 861, 860, - /* 390 */ 174, 857, 856, 175, 823, 232, 565, 828, 830, 106, - /* 400 */ 843, 815, 842, 121, 122, 28, 119, 123, 195, 724, - /* 410 */ 216, 139, 26, 225, 721, 226, 906, 74, 102, 905, - /* 420 */ 903, 125, 742, 27, 25, 140, 711, 83, 589, 709, - /* 430 */ 85, 86, 707, 706, 183, 134, 704, 703, 702, 701, - /* 440 */ 198, 700, 136, 698, 696, 694, 692, 690, 138, 164, - /* 450 */ 58, 54, 59, 202, 51, 844, 46, 812, 207, 205, - /* 460 */ 203, 201, 199, 30, 79, 235, 236, 237, 238, 239, - /* 470 */ 240, 161, 214, 241, 252, 215, 668, 186, 185, 157, - /* 480 */ 69, 667, 188, 189, 666, 659, 192, 196, 166, 574, - /* 490 */ 705, 591, 56, 96, 132, 743, 126, 128, 127, 129, - /* 500 */ 130, 699, 111, 131, 1, 97, 116, 112, 113, 114, - /* 510 */ 691, 797, 60, 117, 115, 118, 2, 20, 108, 200, - /* 520 */ 6, 596, 109, 5, 7, 637, 21, 8, 211, 16, - /* 530 */ 213, 639, 67, 65, 514, 510, 508, 507, 506, 503, - /* 540 */ 477, 223, 70, 47, 73, 75, 24, 547, 546, 544, - /* 550 */ 55, 498, 496, 488, 494, 490, 492, 486, 484, 516, - /* 560 */ 515, 513, 512, 511, 509, 505, 504, 48, 475, 446, - /* 570 */ 444, 672, 671, 671, 671, 671, 671, 671, 671, 671, - /* 580 */ 671, 671, 671, 99, 100, + /* 0 */ 143, 474, 143, 23, 672, 257, 165, 547, 827, 475, + /* 10 */ 900, 168, 901, 37, 38, 12, 39, 40, 816, 23, + /* 20 */ 173, 31, 474, 474, 210, 43, 41, 45, 42, 805, + /* 30 */ 475, 475, 163, 36, 35, 232, 231, 34, 33, 32, + /* 40 */ 37, 38, 801, 39, 40, 816, 110, 173, 31, 162, + /* 50 */ 255, 210, 43, 41, 45, 42, 176, 66, 802, 195, + /* 60 */ 36, 35, 178, 824, 34, 33, 32, 432, 433, 434, + /* 70 */ 435, 436, 437, 438, 439, 440, 441, 442, 443, 256, + /* 80 */ 179, 225, 185, 37, 38, 805, 39, 40, 796, 242, + /* 90 */ 173, 31, 143, 180, 210, 43, 41, 45, 42, 110, + /* 100 */ 110, 167, 901, 36, 35, 57, 853, 34, 33, 32, + /* 110 */ 17, 223, 250, 249, 222, 221, 220, 248, 219, 247, + /* 120 */ 246, 245, 218, 244, 243, 803, 142, 774, 624, 762, + /* 130 */ 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, + /* 140 */ 773, 775, 776, 38, 181, 39, 40, 229, 228, 173, + /* 150 */ 31, 605, 606, 210, 43, 41, 45, 42, 207, 854, + /* 160 */ 61, 205, 36, 35, 23, 110, 34, 33, 32, 188, + /* 170 */ 39, 40, 23, 251, 173, 31, 192, 191, 210, 43, + /* 180 */ 41, 45, 42, 34, 33, 32, 105, 36, 35, 104, + /* 190 */ 147, 34, 33, 32, 172, 637, 805, 28, 628, 897, + /* 200 */ 631, 177, 634, 802, 172, 637, 896, 13, 628, 230, + /* 210 */ 631, 802, 634, 18, 172, 637, 794, 895, 628, 63, + /* 220 */ 631, 28, 634, 155, 574, 62, 169, 170, 23, 156, + /* 230 */ 209, 29, 197, 92, 91, 150, 169, 170, 77, 76, + /* 240 */ 582, 17, 198, 250, 249, 159, 169, 170, 248, 626, + /* 250 */ 247, 246, 245, 715, 244, 243, 133, 211, 780, 80, + /* 260 */ 160, 778, 779, 18, 242, 234, 781, 802, 783, 784, + /* 270 */ 782, 28, 785, 786, 43, 41, 45, 42, 724, 579, + /* 280 */ 64, 133, 36, 35, 19, 627, 34, 33, 32, 3, + /* 290 */ 124, 194, 225, 44, 910, 72, 68, 71, 158, 11, + /* 300 */ 10, 566, 592, 44, 563, 636, 564, 107, 565, 793, + /* 310 */ 22, 795, 630, 44, 633, 636, 716, 36, 35, 133, + /* 320 */ 635, 34, 33, 32, 171, 636, 596, 49, 78, 82, + /* 330 */ 635, 48, 182, 183, 87, 90, 81, 137, 135, 629, + /* 340 */ 635, 632, 84, 95, 94, 93, 50, 9, 145, 640, + /* 350 */ 52, 65, 120, 254, 253, 98, 597, 656, 638, 555, + /* 360 */ 146, 15, 14, 14, 24, 4, 55, 53, 546, 213, + /* 370 */ 556, 570, 148, 571, 24, 48, 568, 149, 569, 89, + /* 380 */ 88, 103, 101, 153, 154, 152, 141, 151, 144, 804, + /* 390 */ 864, 863, 818, 174, 860, 859, 175, 233, 826, 846, + /* 400 */ 831, 833, 106, 121, 845, 122, 567, 119, 123, 726, + /* 410 */ 217, 139, 26, 226, 102, 723, 28, 227, 909, 74, + /* 420 */ 908, 906, 125, 744, 27, 25, 196, 140, 713, 591, + /* 430 */ 83, 711, 85, 86, 199, 709, 708, 184, 54, 134, + /* 440 */ 706, 164, 705, 704, 703, 702, 136, 700, 698, 696, + /* 450 */ 694, 692, 138, 203, 58, 59, 51, 847, 815, 46, + /* 460 */ 208, 206, 204, 202, 200, 30, 79, 235, 236, 237, + /* 470 */ 238, 239, 240, 241, 161, 215, 216, 252, 670, 187, + /* 480 */ 186, 669, 69, 189, 157, 190, 668, 193, 661, 707, + /* 490 */ 197, 576, 60, 56, 593, 96, 128, 97, 127, 745, + /* 500 */ 126, 130, 129, 131, 132, 701, 693, 113, 111, 118, + /* 510 */ 116, 114, 112, 115, 800, 1, 117, 2, 166, 20, + /* 520 */ 108, 201, 6, 598, 109, 7, 639, 5, 8, 21, + /* 530 */ 16, 67, 212, 641, 214, 515, 65, 511, 509, 508, + /* 540 */ 507, 504, 478, 224, 70, 47, 73, 75, 24, 549, + /* 550 */ 548, 545, 499, 497, 489, 495, 491, 493, 487, 485, + /* 560 */ 517, 516, 514, 513, 512, 510, 506, 505, 48, 476, + /* 570 */ 447, 445, 674, 673, 673, 673, 673, 673, 673, 673, + /* 580 */ 673, 673, 673, 673, 99, 100, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 266, 1, 266, 212, 209, 210, 229, 5, 212, 9, - /* 10 */ 276, 275, 276, 13, 14, 266, 16, 17, 250, 212, - /* 20 */ 20, 21, 1, 1, 24, 25, 26, 27, 28, 252, - /* 30 */ 9, 9, 264, 33, 34, 33, 34, 37, 38, 39, - /* 40 */ 13, 14, 251, 16, 17, 250, 212, 20, 21, 211, - /* 50 */ 212, 24, 25, 26, 27, 28, 249, 229, 251, 264, - /* 60 */ 33, 34, 212, 267, 37, 38, 39, 45, 46, 47, + /* 0 */ 267, 1, 267, 213, 210, 211, 230, 5, 213, 9, + /* 10 */ 277, 276, 277, 13, 14, 267, 16, 17, 251, 213, + /* 20 */ 20, 21, 1, 1, 24, 25, 26, 27, 28, 253, + /* 30 */ 9, 9, 265, 33, 34, 33, 34, 37, 38, 39, + /* 40 */ 13, 14, 252, 16, 17, 251, 213, 20, 21, 212, + /* 50 */ 213, 24, 25, 26, 27, 28, 250, 218, 252, 265, + /* 60 */ 33, 34, 230, 268, 37, 38, 39, 45, 46, 47, /* 70 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - /* 80 */ 252, 266, 60, 253, 66, 13, 14, 76, 16, 17, - /* 90 */ 275, 276, 20, 21, 244, 265, 24, 25, 26, 27, - /* 100 */ 28, 212, 268, 0, 104, 33, 34, 229, 15, 37, - /* 110 */ 38, 39, 212, 85, 86, 87, 88, 89, 90, 91, - /* 120 */ 92, 93, 94, 95, 96, 97, 98, 99, 101, 228, - /* 130 */ 252, 230, 231, 232, 233, 234, 235, 236, 237, 238, - /* 140 */ 239, 240, 241, 242, 243, 78, 14, 129, 16, 17, - /* 150 */ 132, 133, 20, 21, 212, 100, 24, 25, 26, 27, - /* 160 */ 28, 272, 107, 274, 212, 33, 34, 212, 128, 37, - /* 170 */ 38, 39, 272, 16, 17, 135, 136, 20, 21, 76, - /* 180 */ 1, 24, 25, 26, 27, 28, 37, 38, 39, 100, - /* 190 */ 33, 34, 103, 104, 37, 38, 39, 1, 2, 106, - /* 200 */ 217, 5, 100, 7, 249, 9, 251, 1, 2, 107, - /* 210 */ 44, 5, 270, 7, 272, 9, 37, 1, 2, 266, - /* 220 */ 101, 5, 212, 7, 272, 9, 60, 108, 266, 33, - /* 230 */ 34, 248, 66, 37, 117, 118, 70, 71, 72, 33, - /* 240 */ 34, 266, 216, 37, 85, 219, 87, 88, 266, 33, - /* 250 */ 34, 92, 217, 94, 95, 96, 266, 98, 99, 249, - /* 260 */ 228, 251, 73, 231, 232, 101, 100, 78, 236, 105, - /* 270 */ 238, 239, 240, 107, 242, 243, 25, 26, 27, 28, - /* 280 */ 266, 246, 247, 248, 33, 34, 266, 59, 37, 38, - /* 290 */ 39, 216, 2, 127, 219, 5, 100, 7, 105, 9, - /* 300 */ 134, 63, 64, 65, 33, 34, 100, 111, 37, 38, - /* 310 */ 39, 212, 266, 61, 62, 122, 100, 111, 266, 67, - /* 320 */ 68, 69, 126, 33, 34, 266, 216, 111, 100, 219, - /* 330 */ 61, 62, 126, 61, 62, 266, 67, 68, 69, 67, - /* 340 */ 68, 69, 126, 266, 75, 101, 105, 266, 249, 105, - /* 350 */ 251, 110, 105, 266, 101, 101, 101, 266, 105, 105, - /* 360 */ 105, 5, 5, 7, 7, 101, 101, 266, 101, 105, - /* 370 */ 105, 124, 105, 130, 131, 130, 131, 5, 5, 7, - /* 380 */ 7, 73, 74, 61, 62, 252, 266, 252, 245, 245, - /* 390 */ 245, 245, 245, 245, 212, 245, 106, 212, 212, 212, - /* 400 */ 273, 250, 273, 212, 212, 107, 254, 212, 250, 212, - /* 410 */ 212, 212, 212, 212, 212, 212, 212, 212, 59, 212, - /* 420 */ 212, 212, 212, 212, 212, 212, 212, 212, 111, 212, - /* 430 */ 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, - /* 440 */ 269, 212, 212, 212, 212, 212, 212, 212, 212, 269, - /* 450 */ 213, 121, 213, 269, 123, 213, 120, 263, 115, 119, - /* 460 */ 114, 113, 112, 125, 84, 83, 49, 80, 82, 53, - /* 470 */ 81, 213, 213, 79, 76, 213, 5, 5, 137, 213, - /* 480 */ 217, 5, 137, 5, 5, 86, 128, 108, 1, 101, - /* 490 */ 213, 101, 109, 214, 220, 227, 226, 221, 225, 224, - /* 500 */ 222, 213, 262, 223, 218, 214, 257, 261, 260, 259, - /* 510 */ 213, 250, 105, 256, 258, 255, 215, 105, 100, 100, - /* 520 */ 116, 101, 100, 100, 116, 101, 105, 100, 102, 100, - /* 530 */ 102, 106, 73, 103, 9, 5, 5, 5, 5, 5, - /* 540 */ 77, 15, 73, 16, 131, 131, 105, 5, 5, 101, - /* 550 */ 100, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 560 */ 5, 5, 5, 5, 5, 5, 5, 105, 77, 59, - /* 570 */ 58, 0, 277, 277, 277, 277, 277, 277, 277, 277, - /* 580 */ 277, 277, 277, 21, 21, 277, 277, 277, 277, 277, - /* 590 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 600 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 610 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 620 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 630 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 640 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 650 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 660 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 670 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 680 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 690 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 700 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 710 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 720 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 730 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 740 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 750 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 760 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 770 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 780 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 790 */ 277, 277, 277, + /* 80 */ 66, 76, 60, 13, 14, 253, 16, 17, 249, 78, + /* 90 */ 20, 21, 267, 213, 24, 25, 26, 27, 28, 213, + /* 100 */ 213, 276, 277, 33, 34, 105, 273, 37, 38, 39, + /* 110 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + /* 120 */ 95, 96, 97, 98, 99, 245, 267, 229, 101, 231, + /* 130 */ 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, + /* 140 */ 242, 243, 244, 14, 130, 16, 17, 133, 134, 20, + /* 150 */ 21, 118, 119, 24, 25, 26, 27, 28, 271, 273, + /* 160 */ 273, 275, 33, 34, 213, 213, 37, 38, 39, 129, + /* 170 */ 16, 17, 213, 230, 20, 21, 136, 137, 24, 25, + /* 180 */ 26, 27, 28, 37, 38, 39, 213, 33, 34, 100, + /* 190 */ 267, 37, 38, 39, 1, 2, 253, 108, 5, 267, + /* 200 */ 7, 250, 9, 252, 1, 2, 267, 44, 5, 250, + /* 210 */ 7, 252, 9, 100, 1, 2, 0, 267, 5, 254, + /* 220 */ 7, 108, 9, 60, 101, 273, 33, 34, 213, 66, + /* 230 */ 37, 266, 109, 70, 71, 72, 33, 34, 131, 132, + /* 240 */ 37, 85, 269, 87, 88, 267, 33, 34, 92, 1, + /* 250 */ 94, 95, 96, 217, 98, 99, 220, 15, 229, 73, + /* 260 */ 267, 232, 233, 100, 78, 250, 237, 252, 239, 240, + /* 270 */ 241, 108, 243, 244, 25, 26, 27, 28, 217, 106, + /* 280 */ 218, 220, 33, 34, 111, 37, 37, 38, 39, 61, + /* 290 */ 62, 128, 76, 100, 253, 67, 68, 69, 135, 131, + /* 300 */ 132, 2, 101, 100, 5, 112, 7, 106, 9, 247, + /* 310 */ 248, 249, 5, 100, 7, 112, 217, 33, 34, 220, + /* 320 */ 127, 37, 38, 39, 59, 112, 101, 106, 61, 62, + /* 330 */ 127, 106, 33, 34, 67, 68, 69, 61, 62, 5, + /* 340 */ 127, 7, 75, 67, 68, 69, 125, 100, 267, 107, + /* 350 */ 106, 104, 105, 63, 64, 65, 101, 101, 101, 101, + /* 360 */ 267, 106, 106, 106, 106, 100, 100, 123, 102, 101, + /* 370 */ 101, 5, 267, 7, 106, 106, 5, 267, 7, 73, + /* 380 */ 74, 61, 62, 267, 267, 267, 267, 267, 267, 253, + /* 390 */ 246, 246, 251, 246, 246, 246, 246, 246, 213, 274, + /* 400 */ 213, 213, 213, 213, 274, 213, 107, 255, 213, 213, + /* 410 */ 213, 213, 213, 213, 59, 213, 108, 213, 213, 213, + /* 420 */ 213, 213, 213, 213, 213, 213, 251, 213, 213, 112, + /* 430 */ 213, 213, 213, 213, 270, 213, 213, 213, 122, 213, + /* 440 */ 213, 270, 213, 213, 213, 213, 213, 213, 213, 213, + /* 450 */ 213, 213, 213, 270, 214, 214, 124, 214, 264, 121, + /* 460 */ 116, 120, 115, 114, 113, 126, 84, 83, 49, 80, + /* 470 */ 82, 53, 81, 79, 214, 214, 214, 76, 5, 5, + /* 480 */ 138, 5, 218, 138, 214, 5, 5, 129, 86, 214, + /* 490 */ 109, 101, 106, 110, 101, 215, 222, 215, 226, 228, + /* 500 */ 227, 223, 225, 224, 221, 214, 214, 261, 263, 256, + /* 510 */ 258, 260, 262, 259, 251, 219, 257, 216, 1, 106, + /* 520 */ 100, 100, 117, 101, 100, 117, 101, 100, 100, 106, + /* 530 */ 100, 73, 103, 107, 103, 9, 104, 5, 5, 5, + /* 540 */ 5, 5, 77, 15, 73, 16, 132, 132, 106, 5, + /* 550 */ 5, 101, 5, 5, 5, 5, 5, 5, 5, 5, + /* 560 */ 5, 5, 5, 5, 5, 5, 5, 5, 106, 77, + /* 570 */ 59, 58, 0, 278, 278, 278, 278, 278, 278, 278, + /* 580 */ 278, 278, 278, 278, 21, 21, 278, 278, 278, 278, + /* 590 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 600 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 610 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 620 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 630 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 640 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 650 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 660 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 670 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 680 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 690 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 700 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 710 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 720 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 730 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 740 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 750 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 760 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 770 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 780 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 790 */ 278, 278, 278, 278, 278, }; #define YY_SHIFT_COUNT (257) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (571) +#define YY_SHIFT_MAX (572) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 166, 28, 159, 11, 196, 216, 21, 21, 21, 21, - /* 10 */ 21, 21, 0, 22, 216, 290, 290, 290, 55, 21, - /* 20 */ 21, 21, 103, 21, 21, 189, 67, 67, 585, 206, - /* 30 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 40 */ 216, 216, 216, 216, 216, 216, 216, 290, 290, 2, - /* 50 */ 2, 2, 2, 2, 2, 2, 102, 21, 21, 21, - /* 60 */ 21, 117, 117, 241, 21, 21, 21, 21, 21, 21, + /* 0 */ 163, 25, 156, 5, 193, 213, 21, 21, 21, 21, + /* 10 */ 21, 21, 0, 22, 213, 299, 299, 299, 113, 21, + /* 20 */ 21, 21, 216, 21, 21, 186, 11, 11, 586, 203, + /* 30 */ 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, + /* 40 */ 213, 213, 213, 213, 213, 213, 213, 299, 299, 2, + /* 50 */ 2, 2, 2, 2, 2, 2, 89, 21, 21, 21, + /* 60 */ 21, 33, 33, 173, 21, 21, 21, 21, 21, 21, /* 70 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, /* 80 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, /* 90 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - /* 100 */ 21, 21, 21, 21, 298, 359, 359, 317, 317, 317, - /* 110 */ 359, 330, 331, 336, 343, 340, 346, 348, 350, 338, - /* 120 */ 298, 359, 359, 359, 11, 359, 380, 382, 417, 387, - /* 130 */ 386, 416, 389, 394, 359, 398, 359, 398, 359, 585, - /* 140 */ 585, 27, 72, 72, 72, 132, 157, 251, 251, 251, - /* 150 */ 269, 271, 271, 271, 271, 252, 272, 18, 40, 149, - /* 160 */ 149, 89, 238, 119, 164, 244, 253, 254, 255, 356, - /* 170 */ 357, 179, 228, 93, 247, 193, 264, 265, 267, 243, - /* 180 */ 245, 372, 373, 308, 322, 471, 341, 472, 476, 345, - /* 190 */ 478, 479, 399, 358, 379, 388, 383, 407, 390, 418, - /* 200 */ 487, 419, 420, 422, 412, 404, 421, 408, 424, 423, - /* 210 */ 425, 427, 426, 429, 428, 430, 459, 525, 530, 531, - /* 220 */ 532, 533, 534, 463, 526, 469, 527, 413, 414, 441, - /* 230 */ 542, 543, 448, 450, 441, 546, 547, 548, 549, 550, - /* 240 */ 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, - /* 250 */ 561, 462, 491, 562, 563, 510, 512, 571, + /* 100 */ 21, 21, 21, 21, 308, 355, 355, 317, 317, 317, + /* 110 */ 355, 316, 332, 338, 344, 341, 347, 349, 351, 339, + /* 120 */ 308, 355, 355, 355, 5, 355, 382, 384, 419, 389, + /* 130 */ 388, 418, 391, 394, 355, 401, 355, 401, 355, 586, + /* 140 */ 586, 27, 70, 70, 70, 129, 154, 249, 249, 249, + /* 150 */ 267, 284, 284, 284, 284, 228, 276, 14, 40, 146, + /* 160 */ 146, 247, 290, 123, 201, 225, 255, 256, 257, 307, + /* 170 */ 334, 248, 265, 242, 221, 244, 258, 268, 269, 107, + /* 180 */ 266, 168, 366, 371, 306, 320, 473, 342, 474, 476, + /* 190 */ 345, 480, 481, 402, 358, 381, 390, 383, 386, 393, + /* 200 */ 420, 517, 421, 422, 424, 413, 405, 423, 408, 425, + /* 210 */ 427, 426, 428, 429, 430, 431, 432, 458, 526, 532, + /* 220 */ 533, 534, 535, 536, 465, 528, 471, 529, 414, 415, + /* 230 */ 442, 544, 545, 450, 442, 547, 548, 549, 550, 551, + /* 240 */ 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, + /* 250 */ 562, 462, 492, 563, 564, 511, 513, 572, }; #define YY_REDUCE_COUNT (140) -#define YY_REDUCE_MIN (-266) +#define YY_REDUCE_MIN (-267) #define YY_REDUCE_MAX (301) static const short yy_reduce_ofst[] = { - /* 0 */ -205, -99, 32, 35, -264, -185, -111, -58, -193, -45, - /* 10 */ 10, 99, -204, -162, -266, -223, -172, -122, -232, -166, - /* 20 */ -100, -48, -17, -150, -209, 26, 75, 110, -170, -251, - /* 30 */ -47, -38, -25, -18, -10, 14, 20, 46, 52, 59, - /* 40 */ 69, 77, 81, 87, 91, 101, 120, 133, 135, 143, - /* 50 */ 144, 145, 146, 147, 148, 150, 151, 182, 185, 186, - /* 60 */ 187, 127, 129, 152, 191, 192, 195, 197, 198, 199, - /* 70 */ 200, 201, 202, 203, 204, 205, 207, 208, 209, 210, - /* 80 */ 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, - /* 90 */ 222, 223, 224, 225, 226, 227, 229, 230, 231, 232, - /* 100 */ 233, 234, 235, 236, 158, 237, 239, 171, 180, 184, - /* 110 */ 242, 194, 240, 246, 248, 250, 256, 249, 257, 260, - /* 120 */ 261, 258, 259, 262, 263, 266, 268, 270, 273, 276, - /* 130 */ 275, 278, 280, 274, 277, 279, 288, 291, 297, 286, + /* 0 */ -206, -102, 29, 62, -265, -175, -114, -113, -194, -49, + /* 10 */ -41, 15, -205, -163, -267, -224, -168, -57, -233, -27, + /* 20 */ -167, -48, -161, -120, -210, 36, 61, 99, -35, -252, + /* 30 */ -141, -77, -68, -61, -50, -22, -7, 81, 93, 105, + /* 40 */ 110, 116, 117, 118, 119, 120, 121, 41, 136, 144, + /* 50 */ 145, 147, 148, 149, 150, 151, 141, 185, 187, 188, + /* 60 */ 189, 125, 130, 152, 190, 192, 195, 196, 197, 198, + /* 70 */ 199, 200, 202, 204, 205, 206, 207, 208, 209, 210, + /* 80 */ 211, 212, 214, 215, 217, 218, 219, 220, 222, 223, + /* 90 */ 224, 226, 227, 229, 230, 231, 232, 233, 234, 235, + /* 100 */ 236, 237, 238, 239, 175, 240, 241, 164, 171, 183, + /* 110 */ 243, 194, 245, 250, 246, 251, 254, 252, 259, 253, + /* 120 */ 263, 260, 261, 262, 264, 270, 271, 273, 272, 274, + /* 130 */ 277, 278, 279, 283, 275, 280, 291, 282, 292, 296, /* 140 */ 301, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 669, 723, 712, 720, 900, 900, 669, 669, 669, 669, - /* 10 */ 669, 669, 825, 687, 900, 669, 669, 669, 669, 669, - /* 20 */ 669, 669, 720, 669, 669, 725, 725, 725, 820, 669, - /* 30 */ 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, - /* 40 */ 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, - /* 50 */ 669, 669, 669, 669, 669, 669, 669, 669, 827, 829, - /* 60 */ 669, 847, 847, 818, 669, 669, 669, 669, 669, 669, - /* 70 */ 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, - /* 80 */ 669, 669, 669, 710, 669, 708, 669, 669, 669, 669, - /* 90 */ 669, 669, 669, 669, 669, 669, 669, 669, 697, 669, - /* 100 */ 669, 669, 669, 669, 669, 689, 689, 669, 669, 669, - /* 110 */ 689, 854, 858, 852, 840, 848, 839, 835, 834, 862, - /* 120 */ 669, 689, 689, 689, 720, 689, 741, 739, 737, 729, - /* 130 */ 735, 731, 733, 727, 689, 718, 689, 718, 689, 759, - /* 140 */ 775, 669, 863, 899, 853, 889, 888, 895, 887, 886, - /* 150 */ 669, 882, 883, 885, 884, 669, 669, 669, 669, 891, - /* 160 */ 890, 669, 669, 669, 669, 669, 669, 669, 669, 669, - /* 170 */ 669, 669, 865, 669, 859, 855, 669, 669, 669, 669, - /* 180 */ 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, - /* 190 */ 669, 669, 669, 669, 817, 669, 669, 826, 669, 669, - /* 200 */ 669, 669, 669, 669, 849, 669, 841, 669, 669, 669, - /* 210 */ 669, 669, 794, 669, 669, 669, 669, 669, 669, 669, - /* 220 */ 669, 669, 669, 669, 669, 669, 669, 669, 669, 904, - /* 230 */ 669, 669, 669, 785, 902, 669, 669, 669, 669, 669, - /* 240 */ 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, - /* 250 */ 669, 744, 669, 695, 693, 669, 685, 669, + /* 0 */ 671, 725, 714, 722, 903, 903, 671, 671, 671, 671, + /* 10 */ 671, 671, 828, 689, 903, 671, 671, 671, 671, 671, + /* 20 */ 671, 671, 722, 671, 671, 727, 727, 727, 823, 671, + /* 30 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, + /* 40 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, + /* 50 */ 671, 671, 671, 671, 671, 671, 671, 671, 830, 832, + /* 60 */ 671, 850, 850, 821, 671, 671, 671, 671, 671, 671, + /* 70 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, + /* 80 */ 671, 671, 671, 712, 671, 710, 671, 671, 671, 671, + /* 90 */ 671, 671, 671, 671, 671, 671, 671, 671, 699, 671, + /* 100 */ 671, 671, 671, 671, 671, 691, 691, 671, 671, 671, + /* 110 */ 691, 857, 861, 855, 843, 851, 842, 838, 837, 865, + /* 120 */ 671, 691, 691, 691, 722, 691, 743, 741, 739, 731, + /* 130 */ 737, 733, 735, 729, 691, 720, 691, 720, 691, 761, + /* 140 */ 777, 671, 866, 902, 856, 892, 891, 898, 890, 889, + /* 150 */ 671, 885, 886, 888, 887, 671, 671, 671, 671, 894, + /* 160 */ 893, 671, 671, 671, 671, 671, 671, 671, 671, 671, + /* 170 */ 671, 671, 868, 671, 862, 858, 671, 671, 671, 671, + /* 180 */ 787, 671, 671, 671, 671, 671, 671, 671, 671, 671, + /* 190 */ 671, 671, 671, 671, 671, 820, 671, 671, 829, 671, + /* 200 */ 671, 671, 671, 671, 671, 852, 671, 844, 671, 671, + /* 210 */ 671, 671, 671, 797, 671, 671, 671, 671, 671, 671, + /* 220 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, + /* 230 */ 907, 671, 671, 671, 905, 671, 671, 671, 671, 671, + /* 240 */ 671, 671, 671, 671, 671, 671, 671, 671, 671, 671, + /* 250 */ 671, 746, 671, 697, 695, 671, 687, 671, }; /********** End of lemon-generated parsing tables *****************************/ @@ -546,6 +546,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* CACHELAST => nothing */ 0, /* LP => nothing */ 0, /* RP => nothing */ + 0, /* UNSIGNED => nothing */ 0, /* TAGS => nothing */ 0, /* USING => nothing */ 0, /* AS => nothing */ @@ -840,181 +841,182 @@ static const char *const yyTokenName[] = { /* 99 */ "CACHELAST", /* 100 */ "LP", /* 101 */ "RP", - /* 102 */ "TAGS", - /* 103 */ "USING", - /* 104 */ "AS", - /* 105 */ "COMMA", - /* 106 */ "NULL", - /* 107 */ "SELECT", - /* 108 */ "UNION", - /* 109 */ "ALL", - /* 110 */ "FROM", - /* 111 */ "VARIABLE", - /* 112 */ "INTERVAL", - /* 113 */ "FILL", - /* 114 */ "SLIDING", - /* 115 */ "ORDER", - /* 116 */ "BY", - /* 117 */ "ASC", - /* 118 */ "DESC", - /* 119 */ "GROUP", - /* 120 */ "HAVING", - /* 121 */ "LIMIT", - /* 122 */ "OFFSET", - /* 123 */ "SLIMIT", - /* 124 */ "SOFFSET", - /* 125 */ "WHERE", - /* 126 */ "NOW", - /* 127 */ "RESET", - /* 128 */ "QUERY", - /* 129 */ "ADD", - /* 130 */ "COLUMN", - /* 131 */ "TAG", - /* 132 */ "CHANGE", - /* 133 */ "SET", - /* 134 */ "KILL", - /* 135 */ "CONNECTION", - /* 136 */ "STREAM", - /* 137 */ "COLON", - /* 138 */ "ABORT", - /* 139 */ "AFTER", - /* 140 */ "ATTACH", - /* 141 */ "BEFORE", - /* 142 */ "BEGIN", - /* 143 */ "CASCADE", - /* 144 */ "CLUSTER", - /* 145 */ "CONFLICT", - /* 146 */ "COPY", - /* 147 */ "DEFERRED", - /* 148 */ "DELIMITERS", - /* 149 */ "DETACH", - /* 150 */ "EACH", - /* 151 */ "END", - /* 152 */ "EXPLAIN", - /* 153 */ "FAIL", - /* 154 */ "FOR", - /* 155 */ "IGNORE", - /* 156 */ "IMMEDIATE", - /* 157 */ "INITIALLY", - /* 158 */ "INSTEAD", - /* 159 */ "MATCH", - /* 160 */ "KEY", - /* 161 */ "OF", - /* 162 */ "RAISE", - /* 163 */ "REPLACE", - /* 164 */ "RESTRICT", - /* 165 */ "ROW", - /* 166 */ "STATEMENT", - /* 167 */ "TRIGGER", - /* 168 */ "VIEW", - /* 169 */ "COUNT", - /* 170 */ "SUM", - /* 171 */ "AVG", - /* 172 */ "MIN", - /* 173 */ "MAX", - /* 174 */ "FIRST", - /* 175 */ "LAST", - /* 176 */ "TOP", - /* 177 */ "BOTTOM", - /* 178 */ "STDDEV", - /* 179 */ "PERCENTILE", - /* 180 */ "APERCENTILE", - /* 181 */ "LEASTSQUARES", - /* 182 */ "HISTOGRAM", - /* 183 */ "DIFF", - /* 184 */ "SPREAD", - /* 185 */ "TWA", - /* 186 */ "INTERP", - /* 187 */ "LAST_ROW", - /* 188 */ "RATE", - /* 189 */ "IRATE", - /* 190 */ "SUM_RATE", - /* 191 */ "SUM_IRATE", - /* 192 */ "AVG_RATE", - /* 193 */ "AVG_IRATE", - /* 194 */ "TBID", - /* 195 */ "SEMI", - /* 196 */ "NONE", - /* 197 */ "PREV", - /* 198 */ "LINEAR", - /* 199 */ "IMPORT", - /* 200 */ "METRIC", - /* 201 */ "TBNAME", - /* 202 */ "JOIN", - /* 203 */ "METRICS", - /* 204 */ "STABLE", - /* 205 */ "INSERT", - /* 206 */ "INTO", - /* 207 */ "VALUES", - /* 208 */ "error", - /* 209 */ "program", - /* 210 */ "cmd", - /* 211 */ "dbPrefix", - /* 212 */ "ids", - /* 213 */ "cpxName", - /* 214 */ "ifexists", - /* 215 */ "alter_db_optr", - /* 216 */ "acct_optr", - /* 217 */ "ifnotexists", - /* 218 */ "db_optr", - /* 219 */ "pps", - /* 220 */ "tseries", - /* 221 */ "dbs", - /* 222 */ "streams", - /* 223 */ "storage", - /* 224 */ "qtime", - /* 225 */ "users", - /* 226 */ "conns", - /* 227 */ "state", - /* 228 */ "keep", - /* 229 */ "tagitemlist", - /* 230 */ "cache", - /* 231 */ "replica", - /* 232 */ "quorum", - /* 233 */ "days", - /* 234 */ "minrows", - /* 235 */ "maxrows", - /* 236 */ "blocks", - /* 237 */ "ctime", - /* 238 */ "wal", - /* 239 */ "fsync", - /* 240 */ "comp", - /* 241 */ "prec", - /* 242 */ "update", - /* 243 */ "cachelast", - /* 244 */ "typename", - /* 245 */ "signed", - /* 246 */ "create_table_args", - /* 247 */ "create_table_list", - /* 248 */ "create_from_stable", - /* 249 */ "columnlist", - /* 250 */ "select", - /* 251 */ "column", - /* 252 */ "tagitem", - /* 253 */ "selcollist", - /* 254 */ "from", - /* 255 */ "where_opt", - /* 256 */ "interval_opt", - /* 257 */ "fill_opt", - /* 258 */ "sliding_opt", - /* 259 */ "groupby_opt", - /* 260 */ "orderby_opt", - /* 261 */ "having_opt", - /* 262 */ "slimit_opt", - /* 263 */ "limit_opt", - /* 264 */ "union", - /* 265 */ "sclp", - /* 266 */ "expr", - /* 267 */ "as", - /* 268 */ "tablelist", - /* 269 */ "tmvar", - /* 270 */ "sortlist", - /* 271 */ "sortitem", - /* 272 */ "item", - /* 273 */ "sortorder", - /* 274 */ "grouplist", - /* 275 */ "exprlist", - /* 276 */ "expritem", + /* 102 */ "UNSIGNED", + /* 103 */ "TAGS", + /* 104 */ "USING", + /* 105 */ "AS", + /* 106 */ "COMMA", + /* 107 */ "NULL", + /* 108 */ "SELECT", + /* 109 */ "UNION", + /* 110 */ "ALL", + /* 111 */ "FROM", + /* 112 */ "VARIABLE", + /* 113 */ "INTERVAL", + /* 114 */ "FILL", + /* 115 */ "SLIDING", + /* 116 */ "ORDER", + /* 117 */ "BY", + /* 118 */ "ASC", + /* 119 */ "DESC", + /* 120 */ "GROUP", + /* 121 */ "HAVING", + /* 122 */ "LIMIT", + /* 123 */ "OFFSET", + /* 124 */ "SLIMIT", + /* 125 */ "SOFFSET", + /* 126 */ "WHERE", + /* 127 */ "NOW", + /* 128 */ "RESET", + /* 129 */ "QUERY", + /* 130 */ "ADD", + /* 131 */ "COLUMN", + /* 132 */ "TAG", + /* 133 */ "CHANGE", + /* 134 */ "SET", + /* 135 */ "KILL", + /* 136 */ "CONNECTION", + /* 137 */ "STREAM", + /* 138 */ "COLON", + /* 139 */ "ABORT", + /* 140 */ "AFTER", + /* 141 */ "ATTACH", + /* 142 */ "BEFORE", + /* 143 */ "BEGIN", + /* 144 */ "CASCADE", + /* 145 */ "CLUSTER", + /* 146 */ "CONFLICT", + /* 147 */ "COPY", + /* 148 */ "DEFERRED", + /* 149 */ "DELIMITERS", + /* 150 */ "DETACH", + /* 151 */ "EACH", + /* 152 */ "END", + /* 153 */ "EXPLAIN", + /* 154 */ "FAIL", + /* 155 */ "FOR", + /* 156 */ "IGNORE", + /* 157 */ "IMMEDIATE", + /* 158 */ "INITIALLY", + /* 159 */ "INSTEAD", + /* 160 */ "MATCH", + /* 161 */ "KEY", + /* 162 */ "OF", + /* 163 */ "RAISE", + /* 164 */ "REPLACE", + /* 165 */ "RESTRICT", + /* 166 */ "ROW", + /* 167 */ "STATEMENT", + /* 168 */ "TRIGGER", + /* 169 */ "VIEW", + /* 170 */ "COUNT", + /* 171 */ "SUM", + /* 172 */ "AVG", + /* 173 */ "MIN", + /* 174 */ "MAX", + /* 175 */ "FIRST", + /* 176 */ "LAST", + /* 177 */ "TOP", + /* 178 */ "BOTTOM", + /* 179 */ "STDDEV", + /* 180 */ "PERCENTILE", + /* 181 */ "APERCENTILE", + /* 182 */ "LEASTSQUARES", + /* 183 */ "HISTOGRAM", + /* 184 */ "DIFF", + /* 185 */ "SPREAD", + /* 186 */ "TWA", + /* 187 */ "INTERP", + /* 188 */ "LAST_ROW", + /* 189 */ "RATE", + /* 190 */ "IRATE", + /* 191 */ "SUM_RATE", + /* 192 */ "SUM_IRATE", + /* 193 */ "AVG_RATE", + /* 194 */ "AVG_IRATE", + /* 195 */ "TBID", + /* 196 */ "SEMI", + /* 197 */ "NONE", + /* 198 */ "PREV", + /* 199 */ "LINEAR", + /* 200 */ "IMPORT", + /* 201 */ "METRIC", + /* 202 */ "TBNAME", + /* 203 */ "JOIN", + /* 204 */ "METRICS", + /* 205 */ "STABLE", + /* 206 */ "INSERT", + /* 207 */ "INTO", + /* 208 */ "VALUES", + /* 209 */ "error", + /* 210 */ "program", + /* 211 */ "cmd", + /* 212 */ "dbPrefix", + /* 213 */ "ids", + /* 214 */ "cpxName", + /* 215 */ "ifexists", + /* 216 */ "alter_db_optr", + /* 217 */ "acct_optr", + /* 218 */ "ifnotexists", + /* 219 */ "db_optr", + /* 220 */ "pps", + /* 221 */ "tseries", + /* 222 */ "dbs", + /* 223 */ "streams", + /* 224 */ "storage", + /* 225 */ "qtime", + /* 226 */ "users", + /* 227 */ "conns", + /* 228 */ "state", + /* 229 */ "keep", + /* 230 */ "tagitemlist", + /* 231 */ "cache", + /* 232 */ "replica", + /* 233 */ "quorum", + /* 234 */ "days", + /* 235 */ "minrows", + /* 236 */ "maxrows", + /* 237 */ "blocks", + /* 238 */ "ctime", + /* 239 */ "wal", + /* 240 */ "fsync", + /* 241 */ "comp", + /* 242 */ "prec", + /* 243 */ "update", + /* 244 */ "cachelast", + /* 245 */ "typename", + /* 246 */ "signed", + /* 247 */ "create_table_args", + /* 248 */ "create_table_list", + /* 249 */ "create_from_stable", + /* 250 */ "columnlist", + /* 251 */ "select", + /* 252 */ "column", + /* 253 */ "tagitem", + /* 254 */ "selcollist", + /* 255 */ "from", + /* 256 */ "where_opt", + /* 257 */ "interval_opt", + /* 258 */ "fill_opt", + /* 259 */ "sliding_opt", + /* 260 */ "groupby_opt", + /* 261 */ "orderby_opt", + /* 262 */ "having_opt", + /* 263 */ "slimit_opt", + /* 264 */ "limit_opt", + /* 265 */ "union", + /* 266 */ "sclp", + /* 267 */ "expr", + /* 268 */ "as", + /* 269 */ "tablelist", + /* 270 */ "tmvar", + /* 271 */ "sortlist", + /* 272 */ "sortitem", + /* 273 */ "item", + /* 274 */ "sortorder", + /* 275 */ "grouplist", + /* 276 */ "exprlist", + /* 277 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1137,130 +1139,131 @@ static const char *const yyRuleName[] = { /* 112 */ "alter_db_optr ::= alter_db_optr cachelast", /* 113 */ "typename ::= ids", /* 114 */ "typename ::= ids LP signed RP", - /* 115 */ "signed ::= INTEGER", - /* 116 */ "signed ::= PLUS INTEGER", - /* 117 */ "signed ::= MINUS INTEGER", - /* 118 */ "cmd ::= CREATE TABLE create_table_args", - /* 119 */ "cmd ::= CREATE TABLE create_table_list", - /* 120 */ "create_table_list ::= create_from_stable", - /* 121 */ "create_table_list ::= create_table_list create_from_stable", - /* 122 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 123 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 124 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", - /* 125 */ "create_table_args ::= ifnotexists ids cpxName AS select", - /* 126 */ "columnlist ::= columnlist COMMA column", - /* 127 */ "columnlist ::= column", - /* 128 */ "column ::= ids typename", - /* 129 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 130 */ "tagitemlist ::= tagitem", - /* 131 */ "tagitem ::= INTEGER", - /* 132 */ "tagitem ::= FLOAT", - /* 133 */ "tagitem ::= STRING", - /* 134 */ "tagitem ::= BOOL", - /* 135 */ "tagitem ::= NULL", - /* 136 */ "tagitem ::= MINUS INTEGER", - /* 137 */ "tagitem ::= MINUS FLOAT", - /* 138 */ "tagitem ::= PLUS INTEGER", - /* 139 */ "tagitem ::= PLUS FLOAT", - /* 140 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", - /* 141 */ "union ::= select", - /* 142 */ "union ::= LP union RP", - /* 143 */ "union ::= union UNION ALL select", - /* 144 */ "union ::= union UNION ALL LP select RP", - /* 145 */ "cmd ::= union", - /* 146 */ "select ::= SELECT selcollist", - /* 147 */ "sclp ::= selcollist COMMA", - /* 148 */ "sclp ::=", - /* 149 */ "selcollist ::= sclp expr as", - /* 150 */ "selcollist ::= sclp STAR", - /* 151 */ "as ::= AS ids", - /* 152 */ "as ::= ids", - /* 153 */ "as ::=", - /* 154 */ "from ::= FROM tablelist", - /* 155 */ "tablelist ::= ids cpxName", - /* 156 */ "tablelist ::= ids cpxName ids", - /* 157 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 158 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 159 */ "tmvar ::= VARIABLE", - /* 160 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 161 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", - /* 162 */ "interval_opt ::=", - /* 163 */ "fill_opt ::=", - /* 164 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 165 */ "fill_opt ::= FILL LP ID RP", - /* 166 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 167 */ "sliding_opt ::=", - /* 168 */ "orderby_opt ::=", - /* 169 */ "orderby_opt ::= ORDER BY sortlist", - /* 170 */ "sortlist ::= sortlist COMMA item sortorder", - /* 171 */ "sortlist ::= item sortorder", - /* 172 */ "item ::= ids cpxName", - /* 173 */ "sortorder ::= ASC", - /* 174 */ "sortorder ::= DESC", - /* 175 */ "sortorder ::=", - /* 176 */ "groupby_opt ::=", - /* 177 */ "groupby_opt ::= GROUP BY grouplist", - /* 178 */ "grouplist ::= grouplist COMMA item", - /* 179 */ "grouplist ::= item", - /* 180 */ "having_opt ::=", - /* 181 */ "having_opt ::= HAVING expr", - /* 182 */ "limit_opt ::=", - /* 183 */ "limit_opt ::= LIMIT signed", - /* 184 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 185 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 186 */ "slimit_opt ::=", - /* 187 */ "slimit_opt ::= SLIMIT signed", - /* 188 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 189 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 190 */ "where_opt ::=", - /* 191 */ "where_opt ::= WHERE expr", - /* 192 */ "expr ::= LP expr RP", - /* 193 */ "expr ::= ID", - /* 194 */ "expr ::= ID DOT ID", - /* 195 */ "expr ::= ID DOT STAR", - /* 196 */ "expr ::= INTEGER", - /* 197 */ "expr ::= MINUS INTEGER", - /* 198 */ "expr ::= PLUS INTEGER", - /* 199 */ "expr ::= FLOAT", - /* 200 */ "expr ::= MINUS FLOAT", - /* 201 */ "expr ::= PLUS FLOAT", - /* 202 */ "expr ::= STRING", - /* 203 */ "expr ::= NOW", - /* 204 */ "expr ::= VARIABLE", - /* 205 */ "expr ::= BOOL", - /* 206 */ "expr ::= ID LP exprlist RP", - /* 207 */ "expr ::= ID LP STAR RP", - /* 208 */ "expr ::= expr IS NULL", - /* 209 */ "expr ::= expr IS NOT NULL", - /* 210 */ "expr ::= expr LT expr", - /* 211 */ "expr ::= expr GT expr", - /* 212 */ "expr ::= expr LE expr", - /* 213 */ "expr ::= expr GE expr", - /* 214 */ "expr ::= expr NE expr", - /* 215 */ "expr ::= expr EQ expr", - /* 216 */ "expr ::= expr AND expr", - /* 217 */ "expr ::= expr OR expr", - /* 218 */ "expr ::= expr PLUS expr", - /* 219 */ "expr ::= expr MINUS expr", - /* 220 */ "expr ::= expr STAR expr", - /* 221 */ "expr ::= expr SLASH expr", - /* 222 */ "expr ::= expr REM expr", - /* 223 */ "expr ::= expr LIKE expr", - /* 224 */ "expr ::= expr IN LP exprlist RP", - /* 225 */ "exprlist ::= exprlist COMMA expritem", - /* 226 */ "exprlist ::= expritem", - /* 227 */ "expritem ::= expr", - /* 228 */ "expritem ::=", - /* 229 */ "cmd ::= RESET QUERY CACHE", - /* 230 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 231 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 232 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 233 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 234 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 235 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 236 */ "cmd ::= KILL CONNECTION INTEGER", - /* 237 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 238 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 115 */ "typename ::= ids UNSIGNED", + /* 116 */ "signed ::= INTEGER", + /* 117 */ "signed ::= PLUS INTEGER", + /* 118 */ "signed ::= MINUS INTEGER", + /* 119 */ "cmd ::= CREATE TABLE create_table_args", + /* 120 */ "cmd ::= CREATE TABLE create_table_list", + /* 121 */ "create_table_list ::= create_from_stable", + /* 122 */ "create_table_list ::= create_table_list create_from_stable", + /* 123 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", + /* 124 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", + /* 125 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", + /* 126 */ "create_table_args ::= ifnotexists ids cpxName AS select", + /* 127 */ "columnlist ::= columnlist COMMA column", + /* 128 */ "columnlist ::= column", + /* 129 */ "column ::= ids typename", + /* 130 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 131 */ "tagitemlist ::= tagitem", + /* 132 */ "tagitem ::= INTEGER", + /* 133 */ "tagitem ::= FLOAT", + /* 134 */ "tagitem ::= STRING", + /* 135 */ "tagitem ::= BOOL", + /* 136 */ "tagitem ::= NULL", + /* 137 */ "tagitem ::= MINUS INTEGER", + /* 138 */ "tagitem ::= MINUS FLOAT", + /* 139 */ "tagitem ::= PLUS INTEGER", + /* 140 */ "tagitem ::= PLUS FLOAT", + /* 141 */ "select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", + /* 142 */ "union ::= select", + /* 143 */ "union ::= LP union RP", + /* 144 */ "union ::= union UNION ALL select", + /* 145 */ "union ::= union UNION ALL LP select RP", + /* 146 */ "cmd ::= union", + /* 147 */ "select ::= SELECT selcollist", + /* 148 */ "sclp ::= selcollist COMMA", + /* 149 */ "sclp ::=", + /* 150 */ "selcollist ::= sclp expr as", + /* 151 */ "selcollist ::= sclp STAR", + /* 152 */ "as ::= AS ids", + /* 153 */ "as ::= ids", + /* 154 */ "as ::=", + /* 155 */ "from ::= FROM tablelist", + /* 156 */ "tablelist ::= ids cpxName", + /* 157 */ "tablelist ::= ids cpxName ids", + /* 158 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 159 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 160 */ "tmvar ::= VARIABLE", + /* 161 */ "interval_opt ::= INTERVAL LP tmvar RP", + /* 162 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", + /* 163 */ "interval_opt ::=", + /* 164 */ "fill_opt ::=", + /* 165 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 166 */ "fill_opt ::= FILL LP ID RP", + /* 167 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 168 */ "sliding_opt ::=", + /* 169 */ "orderby_opt ::=", + /* 170 */ "orderby_opt ::= ORDER BY sortlist", + /* 171 */ "sortlist ::= sortlist COMMA item sortorder", + /* 172 */ "sortlist ::= item sortorder", + /* 173 */ "item ::= ids cpxName", + /* 174 */ "sortorder ::= ASC", + /* 175 */ "sortorder ::= DESC", + /* 176 */ "sortorder ::=", + /* 177 */ "groupby_opt ::=", + /* 178 */ "groupby_opt ::= GROUP BY grouplist", + /* 179 */ "grouplist ::= grouplist COMMA item", + /* 180 */ "grouplist ::= item", + /* 181 */ "having_opt ::=", + /* 182 */ "having_opt ::= HAVING expr", + /* 183 */ "limit_opt ::=", + /* 184 */ "limit_opt ::= LIMIT signed", + /* 185 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 186 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 187 */ "slimit_opt ::=", + /* 188 */ "slimit_opt ::= SLIMIT signed", + /* 189 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 190 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 191 */ "where_opt ::=", + /* 192 */ "where_opt ::= WHERE expr", + /* 193 */ "expr ::= LP expr RP", + /* 194 */ "expr ::= ID", + /* 195 */ "expr ::= ID DOT ID", + /* 196 */ "expr ::= ID DOT STAR", + /* 197 */ "expr ::= INTEGER", + /* 198 */ "expr ::= MINUS INTEGER", + /* 199 */ "expr ::= PLUS INTEGER", + /* 200 */ "expr ::= FLOAT", + /* 201 */ "expr ::= MINUS FLOAT", + /* 202 */ "expr ::= PLUS FLOAT", + /* 203 */ "expr ::= STRING", + /* 204 */ "expr ::= NOW", + /* 205 */ "expr ::= VARIABLE", + /* 206 */ "expr ::= BOOL", + /* 207 */ "expr ::= ID LP exprlist RP", + /* 208 */ "expr ::= ID LP STAR RP", + /* 209 */ "expr ::= expr IS NULL", + /* 210 */ "expr ::= expr IS NOT NULL", + /* 211 */ "expr ::= expr LT expr", + /* 212 */ "expr ::= expr GT expr", + /* 213 */ "expr ::= expr LE expr", + /* 214 */ "expr ::= expr GE expr", + /* 215 */ "expr ::= expr NE expr", + /* 216 */ "expr ::= expr EQ expr", + /* 217 */ "expr ::= expr AND expr", + /* 218 */ "expr ::= expr OR expr", + /* 219 */ "expr ::= expr PLUS expr", + /* 220 */ "expr ::= expr MINUS expr", + /* 221 */ "expr ::= expr STAR expr", + /* 222 */ "expr ::= expr SLASH expr", + /* 223 */ "expr ::= expr REM expr", + /* 224 */ "expr ::= expr LIKE expr", + /* 225 */ "expr ::= expr IN LP exprlist RP", + /* 226 */ "exprlist ::= exprlist COMMA expritem", + /* 227 */ "exprlist ::= expritem", + /* 228 */ "expritem ::= expr", + /* 229 */ "expritem ::=", + /* 230 */ "cmd ::= RESET QUERY CACHE", + /* 231 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 232 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 233 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 234 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 235 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 236 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 237 */ "cmd ::= KILL CONNECTION INTEGER", + /* 238 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 239 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1381,51 +1384,51 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 228: /* keep */ - case 229: /* tagitemlist */ - case 249: /* columnlist */ - case 257: /* fill_opt */ - case 259: /* groupby_opt */ - case 260: /* orderby_opt */ - case 270: /* sortlist */ - case 274: /* grouplist */ + case 229: /* keep */ + case 230: /* tagitemlist */ + case 250: /* columnlist */ + case 258: /* fill_opt */ + case 260: /* groupby_opt */ + case 261: /* orderby_opt */ + case 271: /* sortlist */ + case 275: /* grouplist */ { -taosArrayDestroy((yypminor->yy403)); +taosArrayDestroy((yypminor->yy421)); } break; - case 247: /* create_table_list */ + case 248: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy436)); +destroyCreateTableSql((yypminor->yy38)); } break; - case 250: /* select */ + case 251: /* select */ { -doDestroyQuerySql((yypminor->yy4)); +doDestroyQuerySql((yypminor->yy148)); } break; - case 253: /* selcollist */ - case 265: /* sclp */ - case 275: /* exprlist */ + case 254: /* selcollist */ + case 266: /* sclp */ + case 276: /* exprlist */ { -tSqlExprListDestroy((yypminor->yy382)); +tSqlExprListDestroy((yypminor->yy166)); } break; - case 255: /* where_opt */ - case 261: /* having_opt */ - case 266: /* expr */ - case 276: /* expritem */ + case 256: /* where_opt */ + case 262: /* having_opt */ + case 267: /* expr */ + case 277: /* expritem */ { -tSqlExprDestroy((yypminor->yy522)); +tSqlExprDestroy((yypminor->yy78)); } break; - case 264: /* union */ + case 265: /* union */ { -destroyAllSelectClause((yypminor->yy13)); +destroyAllSelectClause((yypminor->yy153)); } break; - case 271: /* sortitem */ + case 272: /* sortitem */ { -tVariantDestroy(&(yypminor->yy488)); +tVariantDestroy(&(yypminor->yy430)); } break; /********* End destructor definitions *****************************************/ @@ -1719,245 +1722,246 @@ 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[] = { - { 209, -1 }, /* (0) program ::= cmd */ - { 210, -2 }, /* (1) cmd ::= SHOW DATABASES */ - { 210, -2 }, /* (2) cmd ::= SHOW MNODES */ - { 210, -2 }, /* (3) cmd ::= SHOW DNODES */ - { 210, -2 }, /* (4) cmd ::= SHOW ACCOUNTS */ - { 210, -2 }, /* (5) cmd ::= SHOW USERS */ - { 210, -2 }, /* (6) cmd ::= SHOW MODULES */ - { 210, -2 }, /* (7) cmd ::= SHOW QUERIES */ - { 210, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */ - { 210, -2 }, /* (9) cmd ::= SHOW STREAMS */ - { 210, -2 }, /* (10) cmd ::= SHOW VARIABLES */ - { 210, -2 }, /* (11) cmd ::= SHOW SCORES */ - { 210, -2 }, /* (12) cmd ::= SHOW GRANTS */ - { 210, -2 }, /* (13) cmd ::= SHOW VNODES */ - { 210, -3 }, /* (14) cmd ::= SHOW VNODES IPTOKEN */ - { 211, 0 }, /* (15) dbPrefix ::= */ - { 211, -2 }, /* (16) dbPrefix ::= ids DOT */ - { 213, 0 }, /* (17) cpxName ::= */ - { 213, -2 }, /* (18) cpxName ::= DOT ids */ - { 210, -5 }, /* (19) cmd ::= SHOW CREATE TABLE ids cpxName */ - { 210, -4 }, /* (20) cmd ::= SHOW CREATE DATABASE ids */ - { 210, -3 }, /* (21) cmd ::= SHOW dbPrefix TABLES */ - { 210, -5 }, /* (22) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - { 210, -3 }, /* (23) cmd ::= SHOW dbPrefix STABLES */ - { 210, -5 }, /* (24) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - { 210, -3 }, /* (25) cmd ::= SHOW dbPrefix VGROUPS */ - { 210, -4 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS ids */ - { 210, -5 }, /* (27) cmd ::= DROP TABLE ifexists ids cpxName */ - { 210, -4 }, /* (28) cmd ::= DROP DATABASE ifexists ids */ - { 210, -3 }, /* (29) cmd ::= DROP DNODE ids */ - { 210, -3 }, /* (30) cmd ::= DROP USER ids */ - { 210, -3 }, /* (31) cmd ::= DROP ACCOUNT ids */ - { 210, -2 }, /* (32) cmd ::= USE ids */ - { 210, -3 }, /* (33) cmd ::= DESCRIBE ids cpxName */ - { 210, -5 }, /* (34) cmd ::= ALTER USER ids PASS ids */ - { 210, -5 }, /* (35) cmd ::= ALTER USER ids PRIVILEGE ids */ - { 210, -4 }, /* (36) cmd ::= ALTER DNODE ids ids */ - { 210, -5 }, /* (37) cmd ::= ALTER DNODE ids ids ids */ - { 210, -3 }, /* (38) cmd ::= ALTER LOCAL ids */ - { 210, -4 }, /* (39) cmd ::= ALTER LOCAL ids ids */ - { 210, -4 }, /* (40) cmd ::= ALTER DATABASE ids alter_db_optr */ - { 210, -4 }, /* (41) cmd ::= ALTER ACCOUNT ids acct_optr */ - { 210, -6 }, /* (42) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - { 212, -1 }, /* (43) ids ::= ID */ - { 212, -1 }, /* (44) ids ::= STRING */ - { 214, -2 }, /* (45) ifexists ::= IF EXISTS */ - { 214, 0 }, /* (46) ifexists ::= */ - { 217, -3 }, /* (47) ifnotexists ::= IF NOT EXISTS */ - { 217, 0 }, /* (48) ifnotexists ::= */ - { 210, -3 }, /* (49) cmd ::= CREATE DNODE ids */ - { 210, -6 }, /* (50) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - { 210, -5 }, /* (51) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - { 210, -5 }, /* (52) cmd ::= CREATE USER ids PASS ids */ - { 219, 0 }, /* (53) pps ::= */ - { 219, -2 }, /* (54) pps ::= PPS INTEGER */ - { 220, 0 }, /* (55) tseries ::= */ - { 220, -2 }, /* (56) tseries ::= TSERIES INTEGER */ - { 221, 0 }, /* (57) dbs ::= */ - { 221, -2 }, /* (58) dbs ::= DBS INTEGER */ - { 222, 0 }, /* (59) streams ::= */ - { 222, -2 }, /* (60) streams ::= STREAMS INTEGER */ - { 223, 0 }, /* (61) storage ::= */ - { 223, -2 }, /* (62) storage ::= STORAGE INTEGER */ - { 224, 0 }, /* (63) qtime ::= */ - { 224, -2 }, /* (64) qtime ::= QTIME INTEGER */ - { 225, 0 }, /* (65) users ::= */ - { 225, -2 }, /* (66) users ::= USERS INTEGER */ - { 226, 0 }, /* (67) conns ::= */ - { 226, -2 }, /* (68) conns ::= CONNS INTEGER */ - { 227, 0 }, /* (69) state ::= */ - { 227, -2 }, /* (70) state ::= STATE ids */ - { 216, -9 }, /* (71) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - { 228, -2 }, /* (72) keep ::= KEEP tagitemlist */ - { 230, -2 }, /* (73) cache ::= CACHE INTEGER */ - { 231, -2 }, /* (74) replica ::= REPLICA INTEGER */ - { 232, -2 }, /* (75) quorum ::= QUORUM INTEGER */ - { 233, -2 }, /* (76) days ::= DAYS INTEGER */ - { 234, -2 }, /* (77) minrows ::= MINROWS INTEGER */ - { 235, -2 }, /* (78) maxrows ::= MAXROWS INTEGER */ - { 236, -2 }, /* (79) blocks ::= BLOCKS INTEGER */ - { 237, -2 }, /* (80) ctime ::= CTIME INTEGER */ - { 238, -2 }, /* (81) wal ::= WAL INTEGER */ - { 239, -2 }, /* (82) fsync ::= FSYNC INTEGER */ - { 240, -2 }, /* (83) comp ::= COMP INTEGER */ - { 241, -2 }, /* (84) prec ::= PRECISION STRING */ - { 242, -2 }, /* (85) update ::= UPDATE INTEGER */ - { 243, -2 }, /* (86) cachelast ::= CACHELAST INTEGER */ - { 218, 0 }, /* (87) db_optr ::= */ - { 218, -2 }, /* (88) db_optr ::= db_optr cache */ - { 218, -2 }, /* (89) db_optr ::= db_optr replica */ - { 218, -2 }, /* (90) db_optr ::= db_optr quorum */ - { 218, -2 }, /* (91) db_optr ::= db_optr days */ - { 218, -2 }, /* (92) db_optr ::= db_optr minrows */ - { 218, -2 }, /* (93) db_optr ::= db_optr maxrows */ - { 218, -2 }, /* (94) db_optr ::= db_optr blocks */ - { 218, -2 }, /* (95) db_optr ::= db_optr ctime */ - { 218, -2 }, /* (96) db_optr ::= db_optr wal */ - { 218, -2 }, /* (97) db_optr ::= db_optr fsync */ - { 218, -2 }, /* (98) db_optr ::= db_optr comp */ - { 218, -2 }, /* (99) db_optr ::= db_optr prec */ - { 218, -2 }, /* (100) db_optr ::= db_optr keep */ - { 218, -2 }, /* (101) db_optr ::= db_optr update */ - { 218, -2 }, /* (102) db_optr ::= db_optr cachelast */ - { 215, 0 }, /* (103) alter_db_optr ::= */ - { 215, -2 }, /* (104) alter_db_optr ::= alter_db_optr replica */ - { 215, -2 }, /* (105) alter_db_optr ::= alter_db_optr quorum */ - { 215, -2 }, /* (106) alter_db_optr ::= alter_db_optr keep */ - { 215, -2 }, /* (107) alter_db_optr ::= alter_db_optr blocks */ - { 215, -2 }, /* (108) alter_db_optr ::= alter_db_optr comp */ - { 215, -2 }, /* (109) alter_db_optr ::= alter_db_optr wal */ - { 215, -2 }, /* (110) alter_db_optr ::= alter_db_optr fsync */ - { 215, -2 }, /* (111) alter_db_optr ::= alter_db_optr update */ - { 215, -2 }, /* (112) alter_db_optr ::= alter_db_optr cachelast */ - { 244, -1 }, /* (113) typename ::= ids */ - { 244, -4 }, /* (114) typename ::= ids LP signed RP */ - { 245, -1 }, /* (115) signed ::= INTEGER */ - { 245, -2 }, /* (116) signed ::= PLUS INTEGER */ - { 245, -2 }, /* (117) signed ::= MINUS INTEGER */ - { 210, -3 }, /* (118) cmd ::= CREATE TABLE create_table_args */ - { 210, -3 }, /* (119) cmd ::= CREATE TABLE create_table_list */ - { 247, -1 }, /* (120) create_table_list ::= create_from_stable */ - { 247, -2 }, /* (121) create_table_list ::= create_table_list create_from_stable */ - { 246, -6 }, /* (122) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 246, -10 }, /* (123) create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 248, -10 }, /* (124) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - { 246, -5 }, /* (125) create_table_args ::= ifnotexists ids cpxName AS select */ - { 249, -3 }, /* (126) columnlist ::= columnlist COMMA column */ - { 249, -1 }, /* (127) columnlist ::= column */ - { 251, -2 }, /* (128) column ::= ids typename */ - { 229, -3 }, /* (129) tagitemlist ::= tagitemlist COMMA tagitem */ - { 229, -1 }, /* (130) tagitemlist ::= tagitem */ - { 252, -1 }, /* (131) tagitem ::= INTEGER */ - { 252, -1 }, /* (132) tagitem ::= FLOAT */ - { 252, -1 }, /* (133) tagitem ::= STRING */ - { 252, -1 }, /* (134) tagitem ::= BOOL */ - { 252, -1 }, /* (135) tagitem ::= NULL */ - { 252, -2 }, /* (136) tagitem ::= MINUS INTEGER */ - { 252, -2 }, /* (137) tagitem ::= MINUS FLOAT */ - { 252, -2 }, /* (138) tagitem ::= PLUS INTEGER */ - { 252, -2 }, /* (139) tagitem ::= PLUS FLOAT */ - { 250, -12 }, /* (140) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - { 264, -1 }, /* (141) union ::= select */ - { 264, -3 }, /* (142) union ::= LP union RP */ - { 264, -4 }, /* (143) union ::= union UNION ALL select */ - { 264, -6 }, /* (144) union ::= union UNION ALL LP select RP */ - { 210, -1 }, /* (145) cmd ::= union */ - { 250, -2 }, /* (146) select ::= SELECT selcollist */ - { 265, -2 }, /* (147) sclp ::= selcollist COMMA */ - { 265, 0 }, /* (148) sclp ::= */ - { 253, -3 }, /* (149) selcollist ::= sclp expr as */ - { 253, -2 }, /* (150) selcollist ::= sclp STAR */ - { 267, -2 }, /* (151) as ::= AS ids */ - { 267, -1 }, /* (152) as ::= ids */ - { 267, 0 }, /* (153) as ::= */ - { 254, -2 }, /* (154) from ::= FROM tablelist */ - { 268, -2 }, /* (155) tablelist ::= ids cpxName */ - { 268, -3 }, /* (156) tablelist ::= ids cpxName ids */ - { 268, -4 }, /* (157) tablelist ::= tablelist COMMA ids cpxName */ - { 268, -5 }, /* (158) tablelist ::= tablelist COMMA ids cpxName ids */ - { 269, -1 }, /* (159) tmvar ::= VARIABLE */ - { 256, -4 }, /* (160) interval_opt ::= INTERVAL LP tmvar RP */ - { 256, -6 }, /* (161) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - { 256, 0 }, /* (162) interval_opt ::= */ - { 257, 0 }, /* (163) fill_opt ::= */ - { 257, -6 }, /* (164) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 257, -4 }, /* (165) fill_opt ::= FILL LP ID RP */ - { 258, -4 }, /* (166) sliding_opt ::= SLIDING LP tmvar RP */ - { 258, 0 }, /* (167) sliding_opt ::= */ - { 260, 0 }, /* (168) orderby_opt ::= */ - { 260, -3 }, /* (169) orderby_opt ::= ORDER BY sortlist */ - { 270, -4 }, /* (170) sortlist ::= sortlist COMMA item sortorder */ - { 270, -2 }, /* (171) sortlist ::= item sortorder */ - { 272, -2 }, /* (172) item ::= ids cpxName */ - { 273, -1 }, /* (173) sortorder ::= ASC */ - { 273, -1 }, /* (174) sortorder ::= DESC */ - { 273, 0 }, /* (175) sortorder ::= */ - { 259, 0 }, /* (176) groupby_opt ::= */ - { 259, -3 }, /* (177) groupby_opt ::= GROUP BY grouplist */ - { 274, -3 }, /* (178) grouplist ::= grouplist COMMA item */ - { 274, -1 }, /* (179) grouplist ::= item */ - { 261, 0 }, /* (180) having_opt ::= */ - { 261, -2 }, /* (181) having_opt ::= HAVING expr */ - { 263, 0 }, /* (182) limit_opt ::= */ - { 263, -2 }, /* (183) limit_opt ::= LIMIT signed */ - { 263, -4 }, /* (184) limit_opt ::= LIMIT signed OFFSET signed */ - { 263, -4 }, /* (185) limit_opt ::= LIMIT signed COMMA signed */ - { 262, 0 }, /* (186) slimit_opt ::= */ - { 262, -2 }, /* (187) slimit_opt ::= SLIMIT signed */ - { 262, -4 }, /* (188) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 262, -4 }, /* (189) slimit_opt ::= SLIMIT signed COMMA signed */ - { 255, 0 }, /* (190) where_opt ::= */ - { 255, -2 }, /* (191) where_opt ::= WHERE expr */ - { 266, -3 }, /* (192) expr ::= LP expr RP */ - { 266, -1 }, /* (193) expr ::= ID */ - { 266, -3 }, /* (194) expr ::= ID DOT ID */ - { 266, -3 }, /* (195) expr ::= ID DOT STAR */ - { 266, -1 }, /* (196) expr ::= INTEGER */ - { 266, -2 }, /* (197) expr ::= MINUS INTEGER */ - { 266, -2 }, /* (198) expr ::= PLUS INTEGER */ - { 266, -1 }, /* (199) expr ::= FLOAT */ - { 266, -2 }, /* (200) expr ::= MINUS FLOAT */ - { 266, -2 }, /* (201) expr ::= PLUS FLOAT */ - { 266, -1 }, /* (202) expr ::= STRING */ - { 266, -1 }, /* (203) expr ::= NOW */ - { 266, -1 }, /* (204) expr ::= VARIABLE */ - { 266, -1 }, /* (205) expr ::= BOOL */ - { 266, -4 }, /* (206) expr ::= ID LP exprlist RP */ - { 266, -4 }, /* (207) expr ::= ID LP STAR RP */ - { 266, -3 }, /* (208) expr ::= expr IS NULL */ - { 266, -4 }, /* (209) expr ::= expr IS NOT NULL */ - { 266, -3 }, /* (210) expr ::= expr LT expr */ - { 266, -3 }, /* (211) expr ::= expr GT expr */ - { 266, -3 }, /* (212) expr ::= expr LE expr */ - { 266, -3 }, /* (213) expr ::= expr GE expr */ - { 266, -3 }, /* (214) expr ::= expr NE expr */ - { 266, -3 }, /* (215) expr ::= expr EQ expr */ - { 266, -3 }, /* (216) expr ::= expr AND expr */ - { 266, -3 }, /* (217) expr ::= expr OR expr */ - { 266, -3 }, /* (218) expr ::= expr PLUS expr */ - { 266, -3 }, /* (219) expr ::= expr MINUS expr */ - { 266, -3 }, /* (220) expr ::= expr STAR expr */ - { 266, -3 }, /* (221) expr ::= expr SLASH expr */ - { 266, -3 }, /* (222) expr ::= expr REM expr */ - { 266, -3 }, /* (223) expr ::= expr LIKE expr */ - { 266, -5 }, /* (224) expr ::= expr IN LP exprlist RP */ - { 275, -3 }, /* (225) exprlist ::= exprlist COMMA expritem */ - { 275, -1 }, /* (226) exprlist ::= expritem */ - { 276, -1 }, /* (227) expritem ::= expr */ - { 276, 0 }, /* (228) expritem ::= */ - { 210, -3 }, /* (229) cmd ::= RESET QUERY CACHE */ - { 210, -7 }, /* (230) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 210, -7 }, /* (231) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 210, -7 }, /* (232) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 210, -7 }, /* (233) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 210, -8 }, /* (234) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 210, -9 }, /* (235) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 210, -3 }, /* (236) cmd ::= KILL CONNECTION INTEGER */ - { 210, -5 }, /* (237) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 210, -5 }, /* (238) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 210, -1 }, /* (0) program ::= cmd */ + { 211, -2 }, /* (1) cmd ::= SHOW DATABASES */ + { 211, -2 }, /* (2) cmd ::= SHOW MNODES */ + { 211, -2 }, /* (3) cmd ::= SHOW DNODES */ + { 211, -2 }, /* (4) cmd ::= SHOW ACCOUNTS */ + { 211, -2 }, /* (5) cmd ::= SHOW USERS */ + { 211, -2 }, /* (6) cmd ::= SHOW MODULES */ + { 211, -2 }, /* (7) cmd ::= SHOW QUERIES */ + { 211, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */ + { 211, -2 }, /* (9) cmd ::= SHOW STREAMS */ + { 211, -2 }, /* (10) cmd ::= SHOW VARIABLES */ + { 211, -2 }, /* (11) cmd ::= SHOW SCORES */ + { 211, -2 }, /* (12) cmd ::= SHOW GRANTS */ + { 211, -2 }, /* (13) cmd ::= SHOW VNODES */ + { 211, -3 }, /* (14) cmd ::= SHOW VNODES IPTOKEN */ + { 212, 0 }, /* (15) dbPrefix ::= */ + { 212, -2 }, /* (16) dbPrefix ::= ids DOT */ + { 214, 0 }, /* (17) cpxName ::= */ + { 214, -2 }, /* (18) cpxName ::= DOT ids */ + { 211, -5 }, /* (19) cmd ::= SHOW CREATE TABLE ids cpxName */ + { 211, -4 }, /* (20) cmd ::= SHOW CREATE DATABASE ids */ + { 211, -3 }, /* (21) cmd ::= SHOW dbPrefix TABLES */ + { 211, -5 }, /* (22) cmd ::= SHOW dbPrefix TABLES LIKE ids */ + { 211, -3 }, /* (23) cmd ::= SHOW dbPrefix STABLES */ + { 211, -5 }, /* (24) cmd ::= SHOW dbPrefix STABLES LIKE ids */ + { 211, -3 }, /* (25) cmd ::= SHOW dbPrefix VGROUPS */ + { 211, -4 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS ids */ + { 211, -5 }, /* (27) cmd ::= DROP TABLE ifexists ids cpxName */ + { 211, -4 }, /* (28) cmd ::= DROP DATABASE ifexists ids */ + { 211, -3 }, /* (29) cmd ::= DROP DNODE ids */ + { 211, -3 }, /* (30) cmd ::= DROP USER ids */ + { 211, -3 }, /* (31) cmd ::= DROP ACCOUNT ids */ + { 211, -2 }, /* (32) cmd ::= USE ids */ + { 211, -3 }, /* (33) cmd ::= DESCRIBE ids cpxName */ + { 211, -5 }, /* (34) cmd ::= ALTER USER ids PASS ids */ + { 211, -5 }, /* (35) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 211, -4 }, /* (36) cmd ::= ALTER DNODE ids ids */ + { 211, -5 }, /* (37) cmd ::= ALTER DNODE ids ids ids */ + { 211, -3 }, /* (38) cmd ::= ALTER LOCAL ids */ + { 211, -4 }, /* (39) cmd ::= ALTER LOCAL ids ids */ + { 211, -4 }, /* (40) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 211, -4 }, /* (41) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 211, -6 }, /* (42) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 213, -1 }, /* (43) ids ::= ID */ + { 213, -1 }, /* (44) ids ::= STRING */ + { 215, -2 }, /* (45) ifexists ::= IF EXISTS */ + { 215, 0 }, /* (46) ifexists ::= */ + { 218, -3 }, /* (47) ifnotexists ::= IF NOT EXISTS */ + { 218, 0 }, /* (48) ifnotexists ::= */ + { 211, -3 }, /* (49) cmd ::= CREATE DNODE ids */ + { 211, -6 }, /* (50) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 211, -5 }, /* (51) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 211, -5 }, /* (52) cmd ::= CREATE USER ids PASS ids */ + { 220, 0 }, /* (53) pps ::= */ + { 220, -2 }, /* (54) pps ::= PPS INTEGER */ + { 221, 0 }, /* (55) tseries ::= */ + { 221, -2 }, /* (56) tseries ::= TSERIES INTEGER */ + { 222, 0 }, /* (57) dbs ::= */ + { 222, -2 }, /* (58) dbs ::= DBS INTEGER */ + { 223, 0 }, /* (59) streams ::= */ + { 223, -2 }, /* (60) streams ::= STREAMS INTEGER */ + { 224, 0 }, /* (61) storage ::= */ + { 224, -2 }, /* (62) storage ::= STORAGE INTEGER */ + { 225, 0 }, /* (63) qtime ::= */ + { 225, -2 }, /* (64) qtime ::= QTIME INTEGER */ + { 226, 0 }, /* (65) users ::= */ + { 226, -2 }, /* (66) users ::= USERS INTEGER */ + { 227, 0 }, /* (67) conns ::= */ + { 227, -2 }, /* (68) conns ::= CONNS INTEGER */ + { 228, 0 }, /* (69) state ::= */ + { 228, -2 }, /* (70) state ::= STATE ids */ + { 217, -9 }, /* (71) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 229, -2 }, /* (72) keep ::= KEEP tagitemlist */ + { 231, -2 }, /* (73) cache ::= CACHE INTEGER */ + { 232, -2 }, /* (74) replica ::= REPLICA INTEGER */ + { 233, -2 }, /* (75) quorum ::= QUORUM INTEGER */ + { 234, -2 }, /* (76) days ::= DAYS INTEGER */ + { 235, -2 }, /* (77) minrows ::= MINROWS INTEGER */ + { 236, -2 }, /* (78) maxrows ::= MAXROWS INTEGER */ + { 237, -2 }, /* (79) blocks ::= BLOCKS INTEGER */ + { 238, -2 }, /* (80) ctime ::= CTIME INTEGER */ + { 239, -2 }, /* (81) wal ::= WAL INTEGER */ + { 240, -2 }, /* (82) fsync ::= FSYNC INTEGER */ + { 241, -2 }, /* (83) comp ::= COMP INTEGER */ + { 242, -2 }, /* (84) prec ::= PRECISION STRING */ + { 243, -2 }, /* (85) update ::= UPDATE INTEGER */ + { 244, -2 }, /* (86) cachelast ::= CACHELAST INTEGER */ + { 219, 0 }, /* (87) db_optr ::= */ + { 219, -2 }, /* (88) db_optr ::= db_optr cache */ + { 219, -2 }, /* (89) db_optr ::= db_optr replica */ + { 219, -2 }, /* (90) db_optr ::= db_optr quorum */ + { 219, -2 }, /* (91) db_optr ::= db_optr days */ + { 219, -2 }, /* (92) db_optr ::= db_optr minrows */ + { 219, -2 }, /* (93) db_optr ::= db_optr maxrows */ + { 219, -2 }, /* (94) db_optr ::= db_optr blocks */ + { 219, -2 }, /* (95) db_optr ::= db_optr ctime */ + { 219, -2 }, /* (96) db_optr ::= db_optr wal */ + { 219, -2 }, /* (97) db_optr ::= db_optr fsync */ + { 219, -2 }, /* (98) db_optr ::= db_optr comp */ + { 219, -2 }, /* (99) db_optr ::= db_optr prec */ + { 219, -2 }, /* (100) db_optr ::= db_optr keep */ + { 219, -2 }, /* (101) db_optr ::= db_optr update */ + { 219, -2 }, /* (102) db_optr ::= db_optr cachelast */ + { 216, 0 }, /* (103) alter_db_optr ::= */ + { 216, -2 }, /* (104) alter_db_optr ::= alter_db_optr replica */ + { 216, -2 }, /* (105) alter_db_optr ::= alter_db_optr quorum */ + { 216, -2 }, /* (106) alter_db_optr ::= alter_db_optr keep */ + { 216, -2 }, /* (107) alter_db_optr ::= alter_db_optr blocks */ + { 216, -2 }, /* (108) alter_db_optr ::= alter_db_optr comp */ + { 216, -2 }, /* (109) alter_db_optr ::= alter_db_optr wal */ + { 216, -2 }, /* (110) alter_db_optr ::= alter_db_optr fsync */ + { 216, -2 }, /* (111) alter_db_optr ::= alter_db_optr update */ + { 216, -2 }, /* (112) alter_db_optr ::= alter_db_optr cachelast */ + { 245, -1 }, /* (113) typename ::= ids */ + { 245, -4 }, /* (114) typename ::= ids LP signed RP */ + { 245, -2 }, /* (115) typename ::= ids UNSIGNED */ + { 246, -1 }, /* (116) signed ::= INTEGER */ + { 246, -2 }, /* (117) signed ::= PLUS INTEGER */ + { 246, -2 }, /* (118) signed ::= MINUS INTEGER */ + { 211, -3 }, /* (119) cmd ::= CREATE TABLE create_table_args */ + { 211, -3 }, /* (120) cmd ::= CREATE TABLE create_table_list */ + { 248, -1 }, /* (121) create_table_list ::= create_from_stable */ + { 248, -2 }, /* (122) create_table_list ::= create_table_list create_from_stable */ + { 247, -6 }, /* (123) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 247, -10 }, /* (124) create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 249, -10 }, /* (125) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + { 247, -5 }, /* (126) create_table_args ::= ifnotexists ids cpxName AS select */ + { 250, -3 }, /* (127) columnlist ::= columnlist COMMA column */ + { 250, -1 }, /* (128) columnlist ::= column */ + { 252, -2 }, /* (129) column ::= ids typename */ + { 230, -3 }, /* (130) tagitemlist ::= tagitemlist COMMA tagitem */ + { 230, -1 }, /* (131) tagitemlist ::= tagitem */ + { 253, -1 }, /* (132) tagitem ::= INTEGER */ + { 253, -1 }, /* (133) tagitem ::= FLOAT */ + { 253, -1 }, /* (134) tagitem ::= STRING */ + { 253, -1 }, /* (135) tagitem ::= BOOL */ + { 253, -1 }, /* (136) tagitem ::= NULL */ + { 253, -2 }, /* (137) tagitem ::= MINUS INTEGER */ + { 253, -2 }, /* (138) tagitem ::= MINUS FLOAT */ + { 253, -2 }, /* (139) tagitem ::= PLUS INTEGER */ + { 253, -2 }, /* (140) tagitem ::= PLUS FLOAT */ + { 251, -12 }, /* (141) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + { 265, -1 }, /* (142) union ::= select */ + { 265, -3 }, /* (143) union ::= LP union RP */ + { 265, -4 }, /* (144) union ::= union UNION ALL select */ + { 265, -6 }, /* (145) union ::= union UNION ALL LP select RP */ + { 211, -1 }, /* (146) cmd ::= union */ + { 251, -2 }, /* (147) select ::= SELECT selcollist */ + { 266, -2 }, /* (148) sclp ::= selcollist COMMA */ + { 266, 0 }, /* (149) sclp ::= */ + { 254, -3 }, /* (150) selcollist ::= sclp expr as */ + { 254, -2 }, /* (151) selcollist ::= sclp STAR */ + { 268, -2 }, /* (152) as ::= AS ids */ + { 268, -1 }, /* (153) as ::= ids */ + { 268, 0 }, /* (154) as ::= */ + { 255, -2 }, /* (155) from ::= FROM tablelist */ + { 269, -2 }, /* (156) tablelist ::= ids cpxName */ + { 269, -3 }, /* (157) tablelist ::= ids cpxName ids */ + { 269, -4 }, /* (158) tablelist ::= tablelist COMMA ids cpxName */ + { 269, -5 }, /* (159) tablelist ::= tablelist COMMA ids cpxName ids */ + { 270, -1 }, /* (160) tmvar ::= VARIABLE */ + { 257, -4 }, /* (161) interval_opt ::= INTERVAL LP tmvar RP */ + { 257, -6 }, /* (162) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + { 257, 0 }, /* (163) interval_opt ::= */ + { 258, 0 }, /* (164) fill_opt ::= */ + { 258, -6 }, /* (165) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 258, -4 }, /* (166) fill_opt ::= FILL LP ID RP */ + { 259, -4 }, /* (167) sliding_opt ::= SLIDING LP tmvar RP */ + { 259, 0 }, /* (168) sliding_opt ::= */ + { 261, 0 }, /* (169) orderby_opt ::= */ + { 261, -3 }, /* (170) orderby_opt ::= ORDER BY sortlist */ + { 271, -4 }, /* (171) sortlist ::= sortlist COMMA item sortorder */ + { 271, -2 }, /* (172) sortlist ::= item sortorder */ + { 273, -2 }, /* (173) item ::= ids cpxName */ + { 274, -1 }, /* (174) sortorder ::= ASC */ + { 274, -1 }, /* (175) sortorder ::= DESC */ + { 274, 0 }, /* (176) sortorder ::= */ + { 260, 0 }, /* (177) groupby_opt ::= */ + { 260, -3 }, /* (178) groupby_opt ::= GROUP BY grouplist */ + { 275, -3 }, /* (179) grouplist ::= grouplist COMMA item */ + { 275, -1 }, /* (180) grouplist ::= item */ + { 262, 0 }, /* (181) having_opt ::= */ + { 262, -2 }, /* (182) having_opt ::= HAVING expr */ + { 264, 0 }, /* (183) limit_opt ::= */ + { 264, -2 }, /* (184) limit_opt ::= LIMIT signed */ + { 264, -4 }, /* (185) limit_opt ::= LIMIT signed OFFSET signed */ + { 264, -4 }, /* (186) limit_opt ::= LIMIT signed COMMA signed */ + { 263, 0 }, /* (187) slimit_opt ::= */ + { 263, -2 }, /* (188) slimit_opt ::= SLIMIT signed */ + { 263, -4 }, /* (189) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 263, -4 }, /* (190) slimit_opt ::= SLIMIT signed COMMA signed */ + { 256, 0 }, /* (191) where_opt ::= */ + { 256, -2 }, /* (192) where_opt ::= WHERE expr */ + { 267, -3 }, /* (193) expr ::= LP expr RP */ + { 267, -1 }, /* (194) expr ::= ID */ + { 267, -3 }, /* (195) expr ::= ID DOT ID */ + { 267, -3 }, /* (196) expr ::= ID DOT STAR */ + { 267, -1 }, /* (197) expr ::= INTEGER */ + { 267, -2 }, /* (198) expr ::= MINUS INTEGER */ + { 267, -2 }, /* (199) expr ::= PLUS INTEGER */ + { 267, -1 }, /* (200) expr ::= FLOAT */ + { 267, -2 }, /* (201) expr ::= MINUS FLOAT */ + { 267, -2 }, /* (202) expr ::= PLUS FLOAT */ + { 267, -1 }, /* (203) expr ::= STRING */ + { 267, -1 }, /* (204) expr ::= NOW */ + { 267, -1 }, /* (205) expr ::= VARIABLE */ + { 267, -1 }, /* (206) expr ::= BOOL */ + { 267, -4 }, /* (207) expr ::= ID LP exprlist RP */ + { 267, -4 }, /* (208) expr ::= ID LP STAR RP */ + { 267, -3 }, /* (209) expr ::= expr IS NULL */ + { 267, -4 }, /* (210) expr ::= expr IS NOT NULL */ + { 267, -3 }, /* (211) expr ::= expr LT expr */ + { 267, -3 }, /* (212) expr ::= expr GT expr */ + { 267, -3 }, /* (213) expr ::= expr LE expr */ + { 267, -3 }, /* (214) expr ::= expr GE expr */ + { 267, -3 }, /* (215) expr ::= expr NE expr */ + { 267, -3 }, /* (216) expr ::= expr EQ expr */ + { 267, -3 }, /* (217) expr ::= expr AND expr */ + { 267, -3 }, /* (218) expr ::= expr OR expr */ + { 267, -3 }, /* (219) expr ::= expr PLUS expr */ + { 267, -3 }, /* (220) expr ::= expr MINUS expr */ + { 267, -3 }, /* (221) expr ::= expr STAR expr */ + { 267, -3 }, /* (222) expr ::= expr SLASH expr */ + { 267, -3 }, /* (223) expr ::= expr REM expr */ + { 267, -3 }, /* (224) expr ::= expr LIKE expr */ + { 267, -5 }, /* (225) expr ::= expr IN LP exprlist RP */ + { 276, -3 }, /* (226) exprlist ::= exprlist COMMA expritem */ + { 276, -1 }, /* (227) exprlist ::= expritem */ + { 277, -1 }, /* (228) expritem ::= expr */ + { 277, 0 }, /* (229) expritem ::= */ + { 211, -3 }, /* (230) cmd ::= RESET QUERY CACHE */ + { 211, -7 }, /* (231) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 211, -7 }, /* (232) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 211, -7 }, /* (233) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 211, -7 }, /* (234) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 211, -8 }, /* (235) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 211, -9 }, /* (236) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 211, -3 }, /* (237) cmd ::= KILL CONNECTION INTEGER */ + { 211, -5 }, /* (238) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 211, -5 }, /* (239) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2038,7 +2042,7 @@ static void yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 118: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==118); + case 119: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==119); {} break; case 1: /* cmd ::= SHOW DATABASES */ @@ -2189,13 +2193,13 @@ static void yy_reduce( { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; case 40: /* cmd ::= ALTER DATABASE ids alter_db_optr */ -{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy478, &t);} +{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy234, &t);} break; case 41: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy463);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy71);} break; case 42: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy463);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy71);} break; case 43: /* ids ::= ID */ case 44: /* ids ::= STRING */ yytestcase(yyruleno==44); @@ -2216,10 +2220,10 @@ static void yy_reduce( { setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; case 50: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy463);} +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy71);} break; case 51: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ -{ setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy478, &yymsp[-2].minor.yy0);} +{ setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy234, &yymsp[-2].minor.yy0);} break; case 52: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} @@ -2248,20 +2252,20 @@ static void yy_reduce( break; case 71: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy463.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy463.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy463.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy463.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy463.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy463.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy463.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy463.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy463.stat = yymsp[0].minor.yy0; + yylhsminor.yy71.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy71.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy71.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy71.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy71.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy71.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy71.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy71.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy71.stat = yymsp[0].minor.yy0; } - yymsp[-8].minor.yy463 = yylhsminor.yy463; + yymsp[-8].minor.yy71 = yylhsminor.yy71; break; case 72: /* keep ::= KEEP tagitemlist */ -{ yymsp[-1].minor.yy403 = yymsp[0].minor.yy403; } +{ yymsp[-1].minor.yy421 = yymsp[0].minor.yy421; } break; case 73: /* cache ::= CACHE INTEGER */ case 74: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==74); @@ -2280,584 +2284,592 @@ static void yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; case 87: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy478);} +{setDefaultCreateDbOption(&yymsp[1].minor.yy234);} break; case 88: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 89: /* db_optr ::= db_optr replica */ case 104: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==104); -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 90: /* db_optr ::= db_optr quorum */ case 105: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==105); -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 91: /* db_optr ::= db_optr days */ -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 92: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 93: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 94: /* db_optr ::= db_optr blocks */ case 107: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==107); -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 95: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 96: /* db_optr ::= db_optr wal */ case 109: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==109); -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 97: /* db_optr ::= db_optr fsync */ case 110: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==110); -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 98: /* db_optr ::= db_optr comp */ case 108: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==108); -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 99: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 100: /* db_optr ::= db_optr keep */ case 106: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==106); -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.keep = yymsp[0].minor.yy403; } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.keep = yymsp[0].minor.yy421; } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 101: /* db_optr ::= db_optr update */ case 111: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==111); -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 102: /* db_optr ::= db_optr cachelast */ case 112: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==112); -{ yylhsminor.yy478 = yymsp[-1].minor.yy478; yylhsminor.yy478.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy478 = yylhsminor.yy478; +{ yylhsminor.yy234 = yymsp[-1].minor.yy234; yylhsminor.yy234.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy234 = yylhsminor.yy234; break; case 103: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy478);} +{ setDefaultCreateDbOption(&yymsp[1].minor.yy234);} break; case 113: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSqlSetColumnType (&yylhsminor.yy363, &yymsp[0].minor.yy0); + tSqlSetColumnType (&yylhsminor.yy183, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy363 = yylhsminor.yy363; + yymsp[0].minor.yy183 = yylhsminor.yy183; break; case 114: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy387 <= 0) { + if (yymsp[-1].minor.yy325 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSqlSetColumnType(&yylhsminor.yy363, &yymsp[-3].minor.yy0); + tSqlSetColumnType(&yylhsminor.yy183, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy387; // negative value of name length - tSqlSetColumnType(&yylhsminor.yy363, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy325; // negative value of name length + tSqlSetColumnType(&yylhsminor.yy183, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy363 = yylhsminor.yy363; + yymsp[-3].minor.yy183 = yylhsminor.yy183; break; - case 115: /* signed ::= INTEGER */ -{ yylhsminor.yy387 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy387 = yylhsminor.yy387; + case 115: /* typename ::= ids UNSIGNED */ +{ + yymsp[-1].minor.yy0.type = 0; + yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); + tSqlSetColumnType (&yylhsminor.yy183, &yymsp[-1].minor.yy0); +} + yymsp[-1].minor.yy183 = yylhsminor.yy183; break; - case 116: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy387 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + case 116: /* signed ::= INTEGER */ +{ yylhsminor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy325 = yylhsminor.yy325; break; - case 117: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy387 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} + case 117: /* signed ::= PLUS INTEGER */ +{ yymsp[-1].minor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 119: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy436;} + case 118: /* signed ::= MINUS INTEGER */ +{ yymsp[-1].minor.yy325 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 120: /* create_table_list ::= create_from_stable */ + case 120: /* cmd ::= CREATE TABLE create_table_list */ +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy38;} + break; + case 121: /* create_table_list ::= create_from_stable */ { SCreateTableSQL* pCreateTable = calloc(1, sizeof(SCreateTableSQL)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy84); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy152); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy436 = pCreateTable; + yylhsminor.yy38 = pCreateTable; } - yymsp[0].minor.yy436 = yylhsminor.yy436; + yymsp[0].minor.yy38 = yylhsminor.yy38; break; - case 121: /* create_table_list ::= create_table_list create_from_stable */ + case 122: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy436->childTableInfo, &yymsp[0].minor.yy84); - yylhsminor.yy436 = yymsp[-1].minor.yy436; + taosArrayPush(yymsp[-1].minor.yy38->childTableInfo, &yymsp[0].minor.yy152); + yylhsminor.yy38 = yymsp[-1].minor.yy38; } - yymsp[-1].minor.yy436 = yylhsminor.yy436; + yymsp[-1].minor.yy38 = yylhsminor.yy38; break; - case 122: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 123: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy436 = tSetCreateSqlElems(yymsp[-1].minor.yy403, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy436, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy38 = tSetCreateSqlElems(yymsp[-1].minor.yy421, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy38, 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.yy436 = yylhsminor.yy436; + yymsp[-5].minor.yy38 = yylhsminor.yy38; break; - case 123: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + case 124: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy436 = tSetCreateSqlElems(yymsp[-5].minor.yy403, yymsp[-1].minor.yy403, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy436, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy38 = tSetCreateSqlElems(yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy38, 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.yy436 = yylhsminor.yy436; + yymsp[-9].minor.yy38 = yylhsminor.yy38; break; - case 124: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + case 125: /* 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.yy84 = createNewChildTableInfo(&yymsp[-5].minor.yy0, yymsp[-1].minor.yy403, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy152 = createNewChildTableInfo(&yymsp[-5].minor.yy0, yymsp[-1].minor.yy421, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy84 = yylhsminor.yy84; + yymsp[-9].minor.yy152 = yylhsminor.yy152; break; - case 125: /* create_table_args ::= ifnotexists ids cpxName AS select */ + case 126: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy436 = tSetCreateSqlElems(NULL, NULL, yymsp[0].minor.yy4, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy436, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy38 = tSetCreateSqlElems(NULL, NULL, yymsp[0].minor.yy148, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy38, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); } - yymsp[-4].minor.yy436 = yylhsminor.yy436; + yymsp[-4].minor.yy38 = yylhsminor.yy38; break; - case 126: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy403, &yymsp[0].minor.yy363); yylhsminor.yy403 = yymsp[-2].minor.yy403; } - yymsp[-2].minor.yy403 = yylhsminor.yy403; + case 127: /* columnlist ::= columnlist COMMA column */ +{taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy183); yylhsminor.yy421 = yymsp[-2].minor.yy421; } + yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 127: /* columnlist ::= column */ -{yylhsminor.yy403 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy403, &yymsp[0].minor.yy363);} - yymsp[0].minor.yy403 = yylhsminor.yy403; + case 128: /* columnlist ::= column */ +{yylhsminor.yy421 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy183);} + yymsp[0].minor.yy421 = yylhsminor.yy421; break; - case 128: /* column ::= ids typename */ + case 129: /* column ::= ids typename */ { - tSqlSetColumnInfo(&yylhsminor.yy363, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy363); + tSqlSetColumnInfo(&yylhsminor.yy183, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy183); } - yymsp[-1].minor.yy363 = yylhsminor.yy363; + yymsp[-1].minor.yy183 = yylhsminor.yy183; break; - case 129: /* tagitemlist ::= tagitemlist COMMA tagitem */ -{ yylhsminor.yy403 = tVariantListAppend(yymsp[-2].minor.yy403, &yymsp[0].minor.yy488, -1); } - yymsp[-2].minor.yy403 = yylhsminor.yy403; + case 130: /* tagitemlist ::= tagitemlist COMMA tagitem */ +{ yylhsminor.yy421 = tVariantListAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy430, -1); } + yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 130: /* tagitemlist ::= tagitem */ -{ yylhsminor.yy403 = tVariantListAppend(NULL, &yymsp[0].minor.yy488, -1); } - yymsp[0].minor.yy403 = yylhsminor.yy403; + case 131: /* tagitemlist ::= tagitem */ +{ yylhsminor.yy421 = tVariantListAppend(NULL, &yymsp[0].minor.yy430, -1); } + yymsp[0].minor.yy421 = yylhsminor.yy421; break; - case 131: /* tagitem ::= INTEGER */ - case 132: /* tagitem ::= FLOAT */ yytestcase(yyruleno==132); - case 133: /* tagitem ::= STRING */ yytestcase(yyruleno==133); - case 134: /* tagitem ::= BOOL */ yytestcase(yyruleno==134); -{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy488, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy488 = yylhsminor.yy488; + case 132: /* tagitem ::= INTEGER */ + case 133: /* tagitem ::= FLOAT */ yytestcase(yyruleno==133); + case 134: /* tagitem ::= STRING */ yytestcase(yyruleno==134); + case 135: /* tagitem ::= BOOL */ yytestcase(yyruleno==135); +{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy430, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy430 = yylhsminor.yy430; break; - case 135: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy488, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy488 = yylhsminor.yy488; + case 136: /* tagitem ::= NULL */ +{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy430, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy430 = yylhsminor.yy430; break; - case 136: /* tagitem ::= MINUS INTEGER */ - case 137: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==137); - case 138: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==138); - case 139: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==139); + case 137: /* tagitem ::= MINUS INTEGER */ + case 138: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==138); + case 139: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==139); + case 140: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==140); { 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.yy488, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy430, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy488 = yylhsminor.yy488; + yymsp[-1].minor.yy430 = yylhsminor.yy430; break; - case 140: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + case 141: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { - yylhsminor.yy4 = tSetQuerySqlElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy382, yymsp[-9].minor.yy403, yymsp[-8].minor.yy522, yymsp[-4].minor.yy403, yymsp[-3].minor.yy403, &yymsp[-7].minor.yy222, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy403, &yymsp[0].minor.yy404, &yymsp[-1].minor.yy404); + yylhsminor.yy148 = tSetQuerySqlElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy166, yymsp[-9].minor.yy421, yymsp[-8].minor.yy78, yymsp[-4].minor.yy421, yymsp[-3].minor.yy421, &yymsp[-7].minor.yy400, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy421, &yymsp[0].minor.yy167, &yymsp[-1].minor.yy167); } - yymsp[-11].minor.yy4 = yylhsminor.yy4; + yymsp[-11].minor.yy148 = yylhsminor.yy148; break; - case 141: /* union ::= select */ -{ yylhsminor.yy13 = setSubclause(NULL, yymsp[0].minor.yy4); } - yymsp[0].minor.yy13 = yylhsminor.yy13; + case 142: /* union ::= select */ +{ yylhsminor.yy153 = setSubclause(NULL, yymsp[0].minor.yy148); } + yymsp[0].minor.yy153 = yylhsminor.yy153; break; - case 142: /* union ::= LP union RP */ -{ yymsp[-2].minor.yy13 = yymsp[-1].minor.yy13; } + case 143: /* union ::= LP union RP */ +{ yymsp[-2].minor.yy153 = yymsp[-1].minor.yy153; } break; - case 143: /* union ::= union UNION ALL select */ -{ yylhsminor.yy13 = appendSelectClause(yymsp[-3].minor.yy13, yymsp[0].minor.yy4); } - yymsp[-3].minor.yy13 = yylhsminor.yy13; + case 144: /* union ::= union UNION ALL select */ +{ yylhsminor.yy153 = appendSelectClause(yymsp[-3].minor.yy153, yymsp[0].minor.yy148); } + yymsp[-3].minor.yy153 = yylhsminor.yy153; break; - case 144: /* union ::= union UNION ALL LP select RP */ -{ yylhsminor.yy13 = appendSelectClause(yymsp[-5].minor.yy13, yymsp[-1].minor.yy4); } - yymsp[-5].minor.yy13 = yylhsminor.yy13; + case 145: /* union ::= union UNION ALL LP select RP */ +{ yylhsminor.yy153 = appendSelectClause(yymsp[-5].minor.yy153, yymsp[-1].minor.yy148); } + yymsp[-5].minor.yy153 = yylhsminor.yy153; break; - case 145: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy13, NULL, TSDB_SQL_SELECT); } + case 146: /* cmd ::= union */ +{ setSqlInfo(pInfo, yymsp[0].minor.yy153, NULL, TSDB_SQL_SELECT); } break; - case 146: /* select ::= SELECT selcollist */ + case 147: /* select ::= SELECT selcollist */ { - yylhsminor.yy4 = tSetQuerySqlElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy382, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy148 = tSetQuerySqlElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy166, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy4 = yylhsminor.yy4; + yymsp[-1].minor.yy148 = yylhsminor.yy148; break; - case 147: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy382 = yymsp[-1].minor.yy382;} - yymsp[-1].minor.yy382 = yylhsminor.yy382; + case 148: /* sclp ::= selcollist COMMA */ +{yylhsminor.yy166 = yymsp[-1].minor.yy166;} + yymsp[-1].minor.yy166 = yylhsminor.yy166; break; - case 148: /* sclp ::= */ -{yymsp[1].minor.yy382 = 0;} + case 149: /* sclp ::= */ +{yymsp[1].minor.yy166 = 0;} break; - case 149: /* selcollist ::= sclp expr as */ + case 150: /* selcollist ::= sclp expr as */ { - yylhsminor.yy382 = tSqlExprListAppend(yymsp[-2].minor.yy382, yymsp[-1].minor.yy522, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy166 = tSqlExprListAppend(yymsp[-2].minor.yy166, yymsp[-1].minor.yy78, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-2].minor.yy382 = yylhsminor.yy382; + yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 150: /* selcollist ::= sclp STAR */ + case 151: /* selcollist ::= sclp STAR */ { tSQLExpr *pNode = tSqlExprIdValueCreate(NULL, TK_ALL); - yylhsminor.yy382 = tSqlExprListAppend(yymsp[-1].minor.yy382, pNode, 0); + yylhsminor.yy166 = tSqlExprListAppend(yymsp[-1].minor.yy166, pNode, 0); } - yymsp[-1].minor.yy382 = yylhsminor.yy382; + yymsp[-1].minor.yy166 = yylhsminor.yy166; break; - case 151: /* as ::= AS ids */ + case 152: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 152: /* as ::= ids */ + case 153: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 153: /* as ::= */ + case 154: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 154: /* from ::= FROM tablelist */ -{yymsp[-1].minor.yy403 = yymsp[0].minor.yy403;} + case 155: /* from ::= FROM tablelist */ +{yymsp[-1].minor.yy421 = yymsp[0].minor.yy421;} break; - case 155: /* tablelist ::= ids cpxName */ + case 156: /* tablelist ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy403 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); - yylhsminor.yy403 = tVariantListAppendToken(yylhsminor.yy403, &yymsp[-1].minor.yy0, -1); // table alias name + yylhsminor.yy421 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy421 = tVariantListAppendToken(yylhsminor.yy421, &yymsp[-1].minor.yy0, -1); // table alias name } - yymsp[-1].minor.yy403 = yylhsminor.yy403; + yymsp[-1].minor.yy421 = yylhsminor.yy421; break; - case 156: /* tablelist ::= ids cpxName ids */ + case 157: /* tablelist ::= ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy403 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - yylhsminor.yy403 = tVariantListAppendToken(yylhsminor.yy403, &yymsp[0].minor.yy0, -1); + yylhsminor.yy421 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); + yylhsminor.yy421 = tVariantListAppendToken(yylhsminor.yy421, &yymsp[0].minor.yy0, -1); } - yymsp[-2].minor.yy403 = yylhsminor.yy403; + yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 157: /* tablelist ::= tablelist COMMA ids cpxName */ + case 158: /* tablelist ::= tablelist COMMA ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy403 = tVariantListAppendToken(yymsp[-3].minor.yy403, &yymsp[-1].minor.yy0, -1); - yylhsminor.yy403 = tVariantListAppendToken(yylhsminor.yy403, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy421 = tVariantListAppendToken(yymsp[-3].minor.yy421, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy421 = tVariantListAppendToken(yylhsminor.yy421, &yymsp[-1].minor.yy0, -1); } - yymsp[-3].minor.yy403 = yylhsminor.yy403; + yymsp[-3].minor.yy421 = yylhsminor.yy421; break; - case 158: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 159: /* tablelist ::= tablelist COMMA ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy403 = tVariantListAppendToken(yymsp[-4].minor.yy403, &yymsp[-2].minor.yy0, -1); - yylhsminor.yy403 = tVariantListAppendToken(yylhsminor.yy403, &yymsp[0].minor.yy0, -1); + yylhsminor.yy421 = tVariantListAppendToken(yymsp[-4].minor.yy421, &yymsp[-2].minor.yy0, -1); + yylhsminor.yy421 = tVariantListAppendToken(yylhsminor.yy421, &yymsp[0].minor.yy0, -1); } - yymsp[-4].minor.yy403 = yylhsminor.yy403; + yymsp[-4].minor.yy421 = yylhsminor.yy421; break; - case 159: /* tmvar ::= VARIABLE */ + case 160: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 160: /* interval_opt ::= INTERVAL LP tmvar RP */ -{yymsp[-3].minor.yy222.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy222.offset.n = 0; yymsp[-3].minor.yy222.offset.z = NULL; yymsp[-3].minor.yy222.offset.type = 0;} + case 161: /* interval_opt ::= INTERVAL LP tmvar RP */ +{yymsp[-3].minor.yy400.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy400.offset.n = 0; yymsp[-3].minor.yy400.offset.z = NULL; yymsp[-3].minor.yy400.offset.type = 0;} break; - case 161: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ -{yymsp[-5].minor.yy222.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy222.offset = yymsp[-1].minor.yy0;} + case 162: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ +{yymsp[-5].minor.yy400.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy400.offset = yymsp[-1].minor.yy0;} break; - case 162: /* interval_opt ::= */ -{memset(&yymsp[1].minor.yy222, 0, sizeof(yymsp[1].minor.yy222));} + case 163: /* interval_opt ::= */ +{memset(&yymsp[1].minor.yy400, 0, sizeof(yymsp[1].minor.yy400));} break; - case 163: /* fill_opt ::= */ -{yymsp[1].minor.yy403 = 0; } + case 164: /* fill_opt ::= */ +{yymsp[1].minor.yy421 = 0; } break; - case 164: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 165: /* 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.yy403, &A, -1, 0); - yymsp[-5].minor.yy403 = yymsp[-1].minor.yy403; + tVariantListInsert(yymsp[-1].minor.yy421, &A, -1, 0); + yymsp[-5].minor.yy421 = yymsp[-1].minor.yy421; } break; - case 165: /* fill_opt ::= FILL LP ID RP */ + case 166: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy403 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy421 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 166: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 167: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 167: /* sliding_opt ::= */ + case 168: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 168: /* orderby_opt ::= */ -{yymsp[1].minor.yy403 = 0;} + case 169: /* orderby_opt ::= */ +{yymsp[1].minor.yy421 = 0;} break; - case 169: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy403 = yymsp[0].minor.yy403;} + case 170: /* orderby_opt ::= ORDER BY sortlist */ +{yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} break; - case 170: /* sortlist ::= sortlist COMMA item sortorder */ + case 171: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy403 = tVariantListAppend(yymsp[-3].minor.yy403, &yymsp[-1].minor.yy488, yymsp[0].minor.yy70); + yylhsminor.yy421 = tVariantListAppend(yymsp[-3].minor.yy421, &yymsp[-1].minor.yy430, yymsp[0].minor.yy96); } - yymsp[-3].minor.yy403 = yylhsminor.yy403; + yymsp[-3].minor.yy421 = yylhsminor.yy421; break; - case 171: /* sortlist ::= item sortorder */ + case 172: /* sortlist ::= item sortorder */ { - yylhsminor.yy403 = tVariantListAppend(NULL, &yymsp[-1].minor.yy488, yymsp[0].minor.yy70); + yylhsminor.yy421 = tVariantListAppend(NULL, &yymsp[-1].minor.yy430, yymsp[0].minor.yy96); } - yymsp[-1].minor.yy403 = yylhsminor.yy403; + yymsp[-1].minor.yy421 = yylhsminor.yy421; break; - case 172: /* item ::= ids cpxName */ + case 173: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - tVariantCreate(&yylhsminor.yy488, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy430, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy488 = yylhsminor.yy488; + yymsp[-1].minor.yy430 = yylhsminor.yy430; break; - case 173: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy70 = TSDB_ORDER_ASC; } + case 174: /* sortorder ::= ASC */ +{ yymsp[0].minor.yy96 = TSDB_ORDER_ASC; } break; - case 174: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy70 = TSDB_ORDER_DESC;} + case 175: /* sortorder ::= DESC */ +{ yymsp[0].minor.yy96 = TSDB_ORDER_DESC;} break; - case 175: /* sortorder ::= */ -{ yymsp[1].minor.yy70 = TSDB_ORDER_ASC; } + case 176: /* sortorder ::= */ +{ yymsp[1].minor.yy96 = TSDB_ORDER_ASC; } break; - case 176: /* groupby_opt ::= */ -{ yymsp[1].minor.yy403 = 0;} + case 177: /* groupby_opt ::= */ +{ yymsp[1].minor.yy421 = 0;} break; - case 177: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy403 = yymsp[0].minor.yy403;} + case 178: /* groupby_opt ::= GROUP BY grouplist */ +{ yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} break; - case 178: /* grouplist ::= grouplist COMMA item */ + case 179: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy403 = tVariantListAppend(yymsp[-2].minor.yy403, &yymsp[0].minor.yy488, -1); + yylhsminor.yy421 = tVariantListAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy430, -1); } - yymsp[-2].minor.yy403 = yylhsminor.yy403; + yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 179: /* grouplist ::= item */ + case 180: /* grouplist ::= item */ { - yylhsminor.yy403 = tVariantListAppend(NULL, &yymsp[0].minor.yy488, -1); + yylhsminor.yy421 = tVariantListAppend(NULL, &yymsp[0].minor.yy430, -1); } - yymsp[0].minor.yy403 = yylhsminor.yy403; + yymsp[0].minor.yy421 = yylhsminor.yy421; break; - case 180: /* having_opt ::= */ - case 190: /* where_opt ::= */ yytestcase(yyruleno==190); - case 228: /* expritem ::= */ yytestcase(yyruleno==228); -{yymsp[1].minor.yy522 = 0;} + case 181: /* having_opt ::= */ + case 191: /* where_opt ::= */ yytestcase(yyruleno==191); + case 229: /* expritem ::= */ yytestcase(yyruleno==229); +{yymsp[1].minor.yy78 = 0;} break; - case 181: /* having_opt ::= HAVING expr */ - case 191: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==191); -{yymsp[-1].minor.yy522 = yymsp[0].minor.yy522;} + case 182: /* having_opt ::= HAVING expr */ + case 192: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==192); +{yymsp[-1].minor.yy78 = yymsp[0].minor.yy78;} break; - case 182: /* limit_opt ::= */ - case 186: /* slimit_opt ::= */ yytestcase(yyruleno==186); -{yymsp[1].minor.yy404.limit = -1; yymsp[1].minor.yy404.offset = 0;} + case 183: /* limit_opt ::= */ + case 187: /* slimit_opt ::= */ yytestcase(yyruleno==187); +{yymsp[1].minor.yy167.limit = -1; yymsp[1].minor.yy167.offset = 0;} break; - case 183: /* limit_opt ::= LIMIT signed */ - case 187: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==187); -{yymsp[-1].minor.yy404.limit = yymsp[0].minor.yy387; yymsp[-1].minor.yy404.offset = 0;} + case 184: /* limit_opt ::= LIMIT signed */ + case 188: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==188); +{yymsp[-1].minor.yy167.limit = yymsp[0].minor.yy325; yymsp[-1].minor.yy167.offset = 0;} break; - case 184: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy404.limit = yymsp[-2].minor.yy387; yymsp[-3].minor.yy404.offset = yymsp[0].minor.yy387;} + case 185: /* limit_opt ::= LIMIT signed OFFSET signed */ +{ yymsp[-3].minor.yy167.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy167.offset = yymsp[0].minor.yy325;} break; - case 185: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy404.limit = yymsp[0].minor.yy387; yymsp[-3].minor.yy404.offset = yymsp[-2].minor.yy387;} + case 186: /* limit_opt ::= LIMIT signed COMMA signed */ +{ yymsp[-3].minor.yy167.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy167.offset = yymsp[-2].minor.yy325;} break; - case 188: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy404.limit = yymsp[-2].minor.yy387; yymsp[-3].minor.yy404.offset = yymsp[0].minor.yy387;} + case 189: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ +{yymsp[-3].minor.yy167.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy167.offset = yymsp[0].minor.yy325;} break; - case 189: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy404.limit = yymsp[0].minor.yy387; yymsp[-3].minor.yy404.offset = yymsp[-2].minor.yy387;} + case 190: /* slimit_opt ::= SLIMIT signed COMMA signed */ +{yymsp[-3].minor.yy167.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy167.offset = yymsp[-2].minor.yy325;} break; - case 192: /* expr ::= LP expr RP */ -{yylhsminor.yy522 = yymsp[-1].minor.yy522; yylhsminor.yy522->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy522->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 193: /* expr ::= LP expr RP */ +{yylhsminor.yy78 = yymsp[-1].minor.yy78; yylhsminor.yy78->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy78->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 193: /* expr ::= ID */ -{ yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy522 = yylhsminor.yy522; + case 194: /* expr ::= ID */ +{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy78 = yylhsminor.yy78; break; - case 194: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 195: /* expr ::= ID DOT ID */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 195: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 196: /* expr ::= ID DOT STAR */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 196: /* expr ::= INTEGER */ -{ yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy522 = yylhsminor.yy522; + case 197: /* expr ::= INTEGER */ +{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy78 = yylhsminor.yy78; break; - case 197: /* expr ::= MINUS INTEGER */ - case 198: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==198); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy522 = yylhsminor.yy522; + case 198: /* expr ::= MINUS INTEGER */ + case 199: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==199); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy78 = yylhsminor.yy78; break; - case 199: /* expr ::= FLOAT */ -{ yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy522 = yylhsminor.yy522; + case 200: /* expr ::= FLOAT */ +{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy78 = yylhsminor.yy78; break; - case 200: /* expr ::= MINUS FLOAT */ - case 201: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==201); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy522 = yylhsminor.yy522; + case 201: /* expr ::= MINUS FLOAT */ + case 202: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==202); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy78 = yylhsminor.yy78; break; - case 202: /* expr ::= STRING */ -{ yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy522 = yylhsminor.yy522; + case 203: /* expr ::= STRING */ +{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy78 = yylhsminor.yy78; break; - case 203: /* expr ::= NOW */ -{ yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy522 = yylhsminor.yy522; + case 204: /* expr ::= NOW */ +{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy78 = yylhsminor.yy78; break; - case 204: /* expr ::= VARIABLE */ -{ yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy522 = yylhsminor.yy522; + case 205: /* expr ::= VARIABLE */ +{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy78 = yylhsminor.yy78; break; - case 205: /* expr ::= BOOL */ -{ yylhsminor.yy522 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy522 = yylhsminor.yy522; + case 206: /* expr ::= BOOL */ +{ yylhsminor.yy78 = tSqlExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy78 = yylhsminor.yy78; break; - case 206: /* expr ::= ID LP exprlist RP */ -{ yylhsminor.yy522 = tSqlExprCreateFunction(yymsp[-1].minor.yy382, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy522 = yylhsminor.yy522; + case 207: /* expr ::= ID LP exprlist RP */ +{ yylhsminor.yy78 = tSqlExprCreateFunction(yymsp[-1].minor.yy166, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy78 = yylhsminor.yy78; break; - case 207: /* expr ::= ID LP STAR RP */ -{ yylhsminor.yy522 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy522 = yylhsminor.yy522; + case 208: /* expr ::= ID LP STAR RP */ +{ yylhsminor.yy78 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy78 = yylhsminor.yy78; break; - case 208: /* expr ::= expr IS NULL */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, NULL, TK_ISNULL);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 209: /* expr ::= expr IS NULL */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, NULL, TK_ISNULL);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 209: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-3].minor.yy522, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy522 = yylhsminor.yy522; + case 210: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-3].minor.yy78, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy78 = yylhsminor.yy78; break; - case 210: /* expr ::= expr LT expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_LT);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 211: /* expr ::= expr LT expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_LT);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 211: /* expr ::= expr GT expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_GT);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 212: /* expr ::= expr GT expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_GT);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 212: /* expr ::= expr LE expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_LE);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 213: /* expr ::= expr LE expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_LE);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 213: /* expr ::= expr GE expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_GE);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 214: /* expr ::= expr GE expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_GE);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 214: /* expr ::= expr NE expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_NE);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 215: /* expr ::= expr NE expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_NE);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 215: /* expr ::= expr EQ expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_EQ);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 216: /* expr ::= expr EQ expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_EQ);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 216: /* expr ::= expr AND expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_AND);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 217: /* expr ::= expr AND expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_AND);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 217: /* expr ::= expr OR expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_OR); } - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 218: /* expr ::= expr OR expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_OR); } + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 218: /* expr ::= expr PLUS expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_PLUS); } - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 219: /* expr ::= expr PLUS expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_PLUS); } + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 219: /* expr ::= expr MINUS expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_MINUS); } - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 220: /* expr ::= expr MINUS expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_MINUS); } + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 220: /* expr ::= expr STAR expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_STAR); } - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 221: /* expr ::= expr STAR expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_STAR); } + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 221: /* expr ::= expr SLASH expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_DIVIDE);} - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 222: /* expr ::= expr SLASH expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_DIVIDE);} + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 222: /* expr ::= expr REM expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_REM); } - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 223: /* expr ::= expr REM expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_REM); } + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 223: /* expr ::= expr LIKE expr */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-2].minor.yy522, yymsp[0].minor.yy522, TK_LIKE); } - yymsp[-2].minor.yy522 = yylhsminor.yy522; + case 224: /* expr ::= expr LIKE expr */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-2].minor.yy78, yymsp[0].minor.yy78, TK_LIKE); } + yymsp[-2].minor.yy78 = yylhsminor.yy78; break; - case 224: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy522 = tSqlExprCreate(yymsp[-4].minor.yy522, (tSQLExpr*)yymsp[-1].minor.yy382, TK_IN); } - yymsp[-4].minor.yy522 = yylhsminor.yy522; + case 225: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy78 = tSqlExprCreate(yymsp[-4].minor.yy78, (tSQLExpr*)yymsp[-1].minor.yy166, TK_IN); } + yymsp[-4].minor.yy78 = yylhsminor.yy78; break; - case 225: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy382 = tSqlExprListAppend(yymsp[-2].minor.yy382,yymsp[0].minor.yy522,0);} - yymsp[-2].minor.yy382 = yylhsminor.yy382; + case 226: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy166 = tSqlExprListAppend(yymsp[-2].minor.yy166,yymsp[0].minor.yy78,0);} + yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 226: /* exprlist ::= expritem */ -{yylhsminor.yy382 = tSqlExprListAppend(0,yymsp[0].minor.yy522,0);} - yymsp[0].minor.yy382 = yylhsminor.yy382; + case 227: /* exprlist ::= expritem */ +{yylhsminor.yy166 = tSqlExprListAppend(0,yymsp[0].minor.yy78,0);} + yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 227: /* expritem ::= expr */ -{yylhsminor.yy522 = yymsp[0].minor.yy522;} - yymsp[0].minor.yy522 = yylhsminor.yy522; + case 228: /* expritem ::= expr */ +{yylhsminor.yy78 = yymsp[0].minor.yy78;} + yymsp[0].minor.yy78 = yylhsminor.yy78; break; - case 229: /* cmd ::= RESET QUERY CACHE */ + case 230: /* cmd ::= RESET QUERY CACHE */ { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 230: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 231: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy403, NULL, TSDB_ALTER_TABLE_ADD_COLUMN); + SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 231: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 232: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -2868,14 +2880,14 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 232: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 233: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy403, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN); + SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 233: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 234: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -2886,7 +2898,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 234: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 235: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -2900,25 +2912,25 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 235: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 236: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tVariantListAppend(A, &yymsp[0].minor.yy488, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy430, -1); SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 236: /* cmd ::= KILL CONNECTION INTEGER */ + case 237: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 237: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 238: /* 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 238: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 239: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: diff --git a/src/query/tests/CMakeLists.txt b/src/query/tests/CMakeLists.txt index 1856223391..c3798b869e 100644 --- a/src/query/tests/CMakeLists.txt +++ b/src/query/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include/gtest) diff --git a/src/query/tests/astTest.cpp b/src/query/tests/astTest.cpp index 99f03a7ff8..728de4357c 100644 --- a/src/query/tests/astTest.cpp +++ b/src/query/tests/astTest.cpp @@ -471,7 +471,7 @@ tExprNode *createExpr1() { pRight->pVal = (tVariant*) calloc(1, sizeof(tVariant)); pRight->pVal->nType = TSDB_DATA_TYPE_INT; - pRight->pVal->i64Key = 12; + pRight->pVal->i64 = 12; auto *pRoot = (tExprNode*) calloc(1, sizeof(tExprNode)); pRoot->nodeType = TSQL_NODE_EXPR; @@ -574,7 +574,7 @@ void exprSerializeTest1() { tVariant* v2 = p2->_node.pRight->pVal; ASSERT_EQ(v1->nType, v2->nType); - ASSERT_EQ(v1->i64Key, v2->i64Key); + ASSERT_EQ(v1->i64, v2->i64); ASSERT_EQ(p1->_node.hasPK, p2->_node.hasPK); tExprTreeDestroy(&p1, nullptr); diff --git a/src/query/tests/percentileTest.cpp b/src/query/tests/percentileTest.cpp new file mode 100644 index 0000000000..f1fc458501 --- /dev/null +++ b/src/query/tests/percentileTest.cpp @@ -0,0 +1,254 @@ +#include +#include + +#include "qResultbuf.h" +#include "taos.h" +#include "taosdef.h" + +#include "qPercentile.h" + +namespace { +tMemBucket *createBigIntDataBucket(int32_t start, int32_t end) { + tMemBucket *pBucket = tMemBucketCreate(sizeof(int64_t), TSDB_DATA_TYPE_BIGINT, start, end); + for (int32_t i = start; i <= end; ++i) { + int64_t val = i; + tMemBucketPut(pBucket, &val, 1); + } + + return pBucket; +} + +tMemBucket *createIntDataBucket(int32_t start, int32_t end) { + tMemBucket *pBucket = tMemBucketCreate(sizeof(int32_t), TSDB_DATA_TYPE_INT, start, end); + + for (int32_t i = start; i <= end; ++i) { + int32_t val = i; + tMemBucketPut(pBucket, &val, 1); + } + + return pBucket; +} + +tMemBucket *createDoubleDataBucket(int32_t start, int32_t end) { + tMemBucket *pBucket = tMemBucketCreate(sizeof(double), TSDB_DATA_TYPE_DOUBLE, start, end); + for (int32_t i = start; i <= end; ++i) { + double val = i; + int32_t ret = tMemBucketPut(pBucket, &val, 1); + if (ret != 0) { + printf("value out of range:%f", val); + } + } + + return pBucket; +} + +tMemBucket *createUnsignedDataBucket(int32_t start, int32_t end, int32_t type) { + tMemBucket *pBucket = tMemBucketCreate(tDataTypeDesc[type].nSize, type, start, end); + for (int32_t i = start; i <= end; ++i) { + uint64_t k = i; + int32_t ret = tMemBucketPut(pBucket, &k, 1); + if (ret != 0) { + printf("value out of range:%f", k); + } + } + + return pBucket; +} + +void intDataTest() { + printf("running %s\n", __FUNCTION__); + + tMemBucket *pBucket = NULL; + double result = 0.; + + pBucket = createIntDataBucket(0, 0); + result = getPercentile(pBucket, 0); + ASSERT_DOUBLE_EQ(result, 0); + tMemBucketDestroy(pBucket); + + pBucket = createIntDataBucket(0, 1); + result = getPercentile(pBucket, 100); + ASSERT_DOUBLE_EQ(result, 1); + + result = getPercentile(pBucket, 0); + ASSERT_DOUBLE_EQ(result, 0); + tMemBucketDestroy(pBucket); + + pBucket = createIntDataBucket(-1, 1); + + result = getPercentile(pBucket, 50); + ASSERT_DOUBLE_EQ(result, 0); + + result = getPercentile(pBucket, 0); + ASSERT_DOUBLE_EQ(result, -1); + + result = getPercentile(pBucket, 75); + ASSERT_DOUBLE_EQ(result, 0.5); + + result = getPercentile(pBucket, 100); + ASSERT_DOUBLE_EQ(result, 1); + tMemBucketDestroy(pBucket); + + pBucket = createIntDataBucket(0, 99999); + result = getPercentile(pBucket, 50); + ASSERT_DOUBLE_EQ(result, 49999.5); + + tMemBucketDestroy(pBucket); +} + +void bigintDataTest() { + printf("running %s\n", __FUNCTION__); + + tMemBucket *pBucket = NULL; + double result = 0.0; + + pBucket = createBigIntDataBucket(-1000, 1000); + result = getPercentile(pBucket, 50); + ASSERT_DOUBLE_EQ(result, 0.); + tMemBucketDestroy(pBucket); + + pBucket = createBigIntDataBucket(-10000, 10000); + result = getPercentile(pBucket, 100); + ASSERT_DOUBLE_EQ(result, 10000.0); + tMemBucketDestroy(pBucket); + + pBucket = createBigIntDataBucket(-10000, 10000); + result = getPercentile(pBucket, 75); + ASSERT_DOUBLE_EQ(result, 5000.0); + + tMemBucketDestroy(pBucket); +} + +void doubleDataTest() { + printf("running %s\n", __FUNCTION__); + + tMemBucket *pBucket = NULL; + double result = 0; + + pBucket = createDoubleDataBucket(-10, 10); + result = getPercentile(pBucket, 0); + ASSERT_DOUBLE_EQ(result, -10.0); + + printf("result is: %lf\n", result); + tMemBucketDestroy(pBucket); + + pBucket = createDoubleDataBucket(-100000, 100000); + result = getPercentile(pBucket, 25); + ASSERT_DOUBLE_EQ(result, -50000); + + printf("result is: %lf\n", result); + + tMemBucketDestroy(pBucket); + + pBucket = createDoubleDataBucket(-100000, 100000); + result = getPercentile(pBucket, 50); + ASSERT_DOUBLE_EQ(result, 0); + + tMemBucketDestroy(pBucket); + + pBucket = createDoubleDataBucket(-100000, 100000); + result = getPercentile(pBucket, 75); + ASSERT_DOUBLE_EQ(result, 50000); + tMemBucketDestroy(pBucket); + + pBucket = createDoubleDataBucket(-100000, 100000); + + result = getPercentile(pBucket, 100); + ASSERT_DOUBLE_EQ(result, 100000.0); + + printf("result is: %lf\n", result); + tMemBucketDestroy(pBucket); +} + +/* + * large data test, we employ 0.1billion double data to calculated the percentile + * which is 800MB data + */ +void largeDataTest() { + printf("running : %s\n", __FUNCTION__); + + tMemBucket *pBucket = NULL; + double result = 0; + + struct timeval tv; + gettimeofday(&tv, NULL); + + int64_t start = tv.tv_sec; + printf("start time: %" PRId64 "\n", tv.tv_sec); + pBucket = createDoubleDataBucket(0, 100000000); + result = getPercentile(pBucket, 50); + ASSERT_DOUBLE_EQ(result, 50000000); + + gettimeofday(&tv, NULL); + + printf("total elapsed time: %" PRId64 " sec.", -start + tv.tv_sec); + printf("the result of %d is: %lf\n", 50, result); + tMemBucketDestroy(pBucket); +} + +void qsortTest() { + printf("running : %s\n", __FUNCTION__); + + SSchema field[1] = { + {TSDB_DATA_TYPE_INT, "k", sizeof(int32_t)}, + }; + + const int32_t num = 2000; + + int32_t *d = (int32_t *)malloc(sizeof(int32_t) * num); + for (int32_t i = 0; i < num; ++i) { + d[i] = i % 4; + } + + const int32_t numOfOrderCols = 1; + int32_t orderColIdx = 0; + SColumnModel * pModel = createColumnModel(field, 1, 1000); + tOrderDescriptor *pDesc = tOrderDesCreate(&orderColIdx, numOfOrderCols, pModel, 1); + + tColDataQSort(pDesc, num, 0, num - 1, (char *)d, 1); + + for (int32_t i = 0; i < num; ++i) { + printf("%d\t", d[i]); + } + printf("\n"); + + destroyColumnModel(pModel); +} + +void unsignedDataTest() { + printf("running %s\n", __FUNCTION__); + + tMemBucket *pBucket = NULL; + double result = 0.0; + + pBucket = createUnsignedDataBucket(0, 1000, TSDB_DATA_TYPE_UINT); + result = getPercentile(pBucket, 50); + ASSERT_DOUBLE_EQ(result, 500.0); + tMemBucketDestroy(pBucket); + + pBucket = createUnsignedDataBucket(0, 10000, TSDB_DATA_TYPE_UBIGINT); + result = getPercentile(pBucket, 100); + ASSERT_DOUBLE_EQ(result, 10000.0); + + result = getPercentile(pBucket, 0); + ASSERT_DOUBLE_EQ(result, 0.0); + + result = getPercentile(pBucket, 50); + ASSERT_DOUBLE_EQ(result, 5000); + + result = getPercentile(pBucket, 75); + ASSERT_DOUBLE_EQ(result, 7500); + tMemBucketDestroy(pBucket); + +} + +} // namespace + +TEST(testCase, percentileTest) { + // qsortTest(); + intDataTest(); + bigintDataTest(); + doubleDataTest(); + unsignedDataTest(); + largeDataTest(); +} diff --git a/src/query/tests/tsBufTest.cpp b/src/query/tests/tsBufTest.cpp index bada3194bd..8ca636b834 100644 --- a/src/query/tests/tsBufTest.cpp +++ b/src/query/tests/tsBufTest.cpp @@ -34,7 +34,7 @@ void simpleTest() { int32_t num = 10; tVariant t = {0}; t.nType = TSDB_DATA_TYPE_BIGINT; - t.i64Key = 1; + t.i64 = 1; int64_t* list = createTsList(10, 10000000, 30); tsBufAppend(pTSBuf, 0, &t, (const char*)list, num * sizeof(int64_t)); @@ -61,7 +61,7 @@ void largeTSTest() { int32_t num = 1000000; tVariant t = {0}; t.nType = TSDB_DATA_TYPE_BIGINT; - t.i64Key = 1; + t.i64 = 1; int64_t* list = createTsList(num, 10000000, 30); tsBufAppend(pTSBuf, 0, &t, (const char*)list, num * sizeof(int64_t)); @@ -93,7 +93,7 @@ void multiTagsTest() { for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf, 0, &t, (const char*)list, num * sizeof(int64_t)); free(list); @@ -104,7 +104,7 @@ void multiTagsTest() { EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); EXPECT_EQ(pTSBuf->numOfGroups, 1); tsBufFlush(pTSBuf); @@ -131,7 +131,7 @@ void multiVnodeTagsTest() { for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t)); free(list); @@ -144,11 +144,11 @@ void multiVnodeTagsTest() { EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); tsBufFlush(pTSBuf); EXPECT_EQ(pTSBuf->tsData.len, 0); @@ -175,7 +175,7 @@ void loadDataTest() { for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t)); printf("%d - %" PRIu64 "\n", i, list[0]); @@ -190,11 +190,11 @@ void loadDataTest() { EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t)); - EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1); + EXPECT_EQ(pTSBuf->block.tag.i64, numOfTags - 1); tsBufFlush(pTSBuf); EXPECT_EQ(pTSBuf->tsData.len, 0); @@ -253,7 +253,7 @@ void TSTraverse() { for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t)); printf("%d - %d - %" PRIu64 ", %" PRIu64 "\n", j, i, list[0], list[num - 1]); @@ -297,14 +297,14 @@ void TSTraverse() { tVariant t = {0}; t.nType = TSDB_DATA_TYPE_BIGINT; - t.i64Key = startTag; + t.i64 = startTag; tsBufGetElemStartPos(pTSBuf, startVnode, &t); int32_t totalOutput = 10; while (1) { STSElem elem = tsBufGetElem(pTSBuf); - printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64Key, elem.ts); + printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64, elem.ts); if (!tsBufNextPos(pTSBuf)) { break; @@ -314,7 +314,7 @@ void TSTraverse() { totalOutput = 10; startTag -= 1; - t.i64Key = startTag; + t.i64 = startTag; tsBufGetElemStartPos(pTSBuf, startVnode, &t); if (startTag == 0) { @@ -345,14 +345,14 @@ void TSTraverse() { startVnode = 1; startTag = 2; - t.i64Key = startTag; + t.i64 = startTag; tsBufGetElemStartPos(pTSBuf, startVnode, &t); totalOutput = 10; while (1) { STSElem elem = tsBufGetElem(pTSBuf); - printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64Key, elem.ts); + printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64, elem.ts); if (!tsBufNextPos(pTSBuf)) { break; @@ -362,7 +362,7 @@ void TSTraverse() { totalOutput = 10; startTag -= 1; - t.i64Key = startTag; + t.i64 = startTag; tsBufGetElemStartPos(pTSBuf, startVnode, &t); if (startTag < 0) { @@ -414,7 +414,7 @@ void mergeDiffVnodeBufferTest() { int64_t start = 10000000; for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf1, 1, &t, (const char*)list, num * sizeof(int64_t)); tsBufAppend(pTSBuf2, 9, &t, (const char*)list, num * sizeof(int64_t)); @@ -451,7 +451,7 @@ void mergeIdenticalVnodeBufferTest() { int64_t start = 10000000; for (int32_t i = 0; i < numOfTags; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf1, 12, &t, (const char*)list, num * sizeof(int64_t)); free(list); @@ -462,7 +462,7 @@ void mergeIdenticalVnodeBufferTest() { for (int32_t i = numOfTags; i < numOfTags * 2; ++i) { int64_t* list = createTsList(num, start, step); - t.i64Key = i; + t.i64 = i; tsBufAppend(pTSBuf2, 77, &t, (const char*)list, num * sizeof(int64_t)); free(list); @@ -487,7 +487,7 @@ void mergeIdenticalVnodeBufferTest() { EXPECT_EQ(elem.id, 77); } - printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64Key, elem.ts); + printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.id, elem.tag->i64, elem.ts); } tsBufDestroy(pTSBuf1); diff --git a/src/query/tests/unitTest.cpp b/src/query/tests/unitTest.cpp index b6e1170d0e..a8500364dc 100644 --- a/src/query/tests/unitTest.cpp +++ b/src/query/tests/unitTest.cpp @@ -27,22 +27,22 @@ int32_t testValidateName(char* name) { } static void _init_tvariant_bool(tVariant* t) { - t->i64Key = TSDB_FALSE; + t->i64 = TSDB_FALSE; t->nType = TSDB_DATA_TYPE_BOOL; } static void _init_tvariant_tinyint(tVariant* t) { - t->i64Key = -27; + t->i64 = -27; t->nType = TSDB_DATA_TYPE_TINYINT; } static void _init_tvariant_int(tVariant* t) { - t->i64Key = -23997659; + t->i64 = -23997659; t->nType = TSDB_DATA_TYPE_INT; } static void _init_tvariant_bigint(tVariant* t) { - t->i64Key = -3333333333333; + t->i64 = -3333333333333; t->nType = TSDB_DATA_TYPE_BIGINT; } @@ -446,19 +446,19 @@ TEST(testCase, tvariant_convert) { _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_bool(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -481,23 +481,23 @@ TEST(testCase, tvariant_convert) { // 2. tinyint to other data types _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0); - EXPECT_EQ(t.i64Key, -27); + EXPECT_EQ(t.i64, -27); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0); - EXPECT_EQ(t.i64Key, -27); + EXPECT_EQ(t.i64, -27); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_INT), 0); - EXPECT_EQ(t.i64Key, -27); + EXPECT_EQ(t.i64, -27); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -27); + EXPECT_EQ(t.i64, -27); _init_tvariant_tinyint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -521,7 +521,7 @@ TEST(testCase, tvariant_convert) { // types////////////////////////////////////////////////////////////////// _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0); @@ -531,11 +531,11 @@ TEST(testCase, tvariant_convert) { _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_INT), 0); - EXPECT_EQ(t.i64Key, -23997659); + EXPECT_EQ(t.i64, -23997659); _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -23997659); + EXPECT_EQ(t.i64, -23997659); _init_tvariant_int(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -559,7 +559,7 @@ TEST(testCase, tvariant_convert) { // type////////////////////////////////////////////////////////////////////////////// _init_tvariant_bigint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_bigint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0); @@ -572,7 +572,7 @@ TEST(testCase, tvariant_convert) { _init_tvariant_bigint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -3333333333333); + EXPECT_EQ(t.i64, -3333333333333); _init_tvariant_bigint(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -596,11 +596,11 @@ TEST(testCase, tvariant_convert) { // types//////////////////////////////////////////////////////////////////////// _init_tvariant_float(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_float(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -8991212199); + EXPECT_EQ(t.i64, -8991212199); _init_tvariant_float(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -626,14 +626,14 @@ TEST(testCase, tvariant_convert) { t.nLen = strlen(t.pz); t.nType = TSDB_DATA_TYPE_BINARY; EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 1); + EXPECT_EQ(t.i64, 1); _init_tvariant_binary(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), -1); _init_tvariant_binary(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, 200000); + EXPECT_EQ(t.i64, 200000); _init_tvariant_binary(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -659,14 +659,14 @@ TEST(testCase, tvariant_convert) { t.nLen = wcslen(t.wpz); t.nType = TSDB_DATA_TYPE_NCHAR; EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); - EXPECT_EQ(t.i64Key, 0); + EXPECT_EQ(t.i64, 0); _init_tvariant_nchar(&t); EXPECT_LE(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0); _init_tvariant_nchar(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0); - EXPECT_EQ(t.i64Key, -2000000); + EXPECT_EQ(t.i64, -2000000); _init_tvariant_nchar(&t); EXPECT_EQ(tVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0); @@ -732,34 +732,34 @@ static SStrToken createStrToken(char* s) { TEST(testCase, isValidNumber_test) { SStrToken t1 = createStrToken("123abc"); - EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL); + EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL); t1 = createStrToken("0xabc"); - EXPECT_EQ(isValidNumber(&t1), TK_HEX); + EXPECT_EQ(tGetNumericStringType(&t1), TK_HEX); t1 = createStrToken("0b11101"); - EXPECT_EQ(isValidNumber(&t1), TK_BIN); + EXPECT_EQ(tGetNumericStringType(&t1), TK_BIN); t1 = createStrToken(".134abc"); - EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL); + EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL); t1 = createStrToken("1e1 "); - EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL); + EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL); t1 = createStrToken("1+2"); - EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL); + EXPECT_EQ(tGetNumericStringType(&t1), TK_ILLEGAL); t1 = createStrToken("-0x123"); - EXPECT_EQ(isValidNumber(&t1), TK_HEX); + EXPECT_EQ(tGetNumericStringType(&t1), TK_HEX); t1 = createStrToken("-1"); - EXPECT_EQ(isValidNumber(&t1), TK_INTEGER); + EXPECT_EQ(tGetNumericStringType(&t1), TK_INTEGER); t1 = createStrToken("-0b1110"); - EXPECT_EQ(isValidNumber(&t1), TK_BIN); + EXPECT_EQ(tGetNumericStringType(&t1), TK_BIN); t1 = createStrToken("-.234"); - EXPECT_EQ(isValidNumber(&t1), TK_FLOAT); + EXPECT_EQ(tGetNumericStringType(&t1), TK_FLOAT); } TEST(testCase, getTempFilePath_test) { diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt index f94b4aeb6d..02a1e7c2d8 100644 --- a/src/rpc/CMakeLists.txt +++ b/src/rpc/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index af51733c21..17b80a0afb 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1390,7 +1390,7 @@ static void rpcProcessRetryTimer(void *param, void *tmrId) { pConn->pContext->code = TSDB_CODE_RPC_NETWORK_UNAVAIL; pConn->pContext->pConn = NULL; pConn->pReqMsg = NULL; - taosTmrStart(rpcProcessConnError, 0, pConn->pContext, pRpc->tmrCtrl); + taosTmrStart(rpcProcessConnError, 1, pConn->pContext, pRpc->tmrCtrl); rpcReleaseConn(pConn); } } diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 178b96c423..daf3bd86c1 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -241,7 +241,7 @@ static void *taosAcceptTcpConnection(void *arg) { } taosKeepTcpAlive(connFd); - struct timeval to={1, 0}; + struct timeval to={5, 0}; int32_t ret = taosSetSockOpt(connFd, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof(to)); if (ret != 0) { taosCloseSocket(connFd); diff --git a/src/rpc/test/CMakeLists.txt b/src/rpc/test/CMakeLists.txt index 383ce1b0f6..9a4bcc353d 100644 --- a/src/rpc/test/CMakeLists.txt +++ b/src/rpc/test/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/rpc/inc) diff --git a/src/sync/CMakeLists.txt b/src/sync/CMakeLists.txt index aa38a56f38..6a53380841 100644 --- a/src/sync/CMakeLists.txt +++ b/src/sync/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) diff --git a/src/sync/inc/syncInt.h b/src/sync/inc/syncInt.h index 47090cfa0c..eef687d647 100644 --- a/src/sync/inc/syncInt.h +++ b/src/sync/inc/syncInt.h @@ -87,6 +87,7 @@ typedef struct SsyncPeer { int32_t numOfRetrieves; // number of retrieves tried int32_t fileChanged; // a flag to indicate file is changed during retrieving process int32_t refCount; + int8_t isArb; int64_t rid; void * timer; void * pConn; diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index db100250a8..98100fbdd8 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -475,7 +475,13 @@ static void syncAddArbitrator(SSyncNode *pNode) { } } - pNode->peerInfo[TAOS_SYNC_MAX_REPLICA] = syncAddPeer(pNode, &nodeInfo); + pPeer = syncAddPeer(pNode, &nodeInfo); + if (pPeer != NULL) { + pPeer->isArb = 1; + sInfo("%s, is added as arbitrator", pPeer->id); + } + + pNode->peerInfo[TAOS_SYNC_MAX_REPLICA] = pPeer; } static void syncFreeNode(void *param) { @@ -651,9 +657,14 @@ static void syncChooseMaster(SSyncNode *pNode) { // add arbitrator connection SSyncPeer *pArb = pNode->peerInfo[TAOS_SYNC_MAX_REPLICA]; - if (pArb && pArb->role != TAOS_SYNC_ROLE_OFFLINE) { - onlineNum++; - replica = pNode->replica + 1; + if (pArb) { + if (pArb->role != TAOS_SYNC_ROLE_OFFLINE) { + onlineNum++; + replica = pNode->replica + 1; + sDebug("vgId:%d, arb:%s is used while choose master", pNode->vgId, pArb->id); + } else { + sError("vgId:%d, arb:%s is not used while choose master for its offline", pNode->vgId, pArb->id); + } } if (index < 0 && onlineNum > replica / 2.0) { @@ -1118,6 +1129,7 @@ static void syncSetupPeerConnection(SSyncPeer *pPeer) { pPeer->peerFd = connFd; pPeer->role = TAOS_SYNC_ROLE_UNSYNCED; pPeer->pConn = syncAllocateTcpConn(tsTcpPool, pPeer->rid, connFd); + if (pPeer->isArb) tsArbOnline = 1; } else { sDebug("%s, failed to setup peer connection to server since %s, try later", pPeer->id, strerror(errno)); taosClose(connFd); @@ -1196,7 +1208,7 @@ static void syncProcessIncommingConnection(int32_t connFd, uint32_t sourceIp) { return; } - sDebug("vgId:%d, sync connection is incomming, tranId:%u", vgId, msg.tranId); + sDebug("vgId:%d, sync connection is incoming, tranId:%u", vgId, msg.tranId); SSyncNode *pNode = *ppNode; pthread_mutex_lock(&pNode->mutex); @@ -1243,6 +1255,9 @@ static void syncProcessBrokenLink(int64_t rid) { sDebug("%s, TCP link is broken since %s, pfd:%d sfd:%d", pPeer->id, strerror(errno), pPeer->peerFd, pPeer->syncFd); pPeer->peerFd = -1; + if (pPeer->isArb) { + tsArbOnline = 0; + } syncRestartConnection(pPeer); pthread_mutex_unlock(&pNode->mutex); diff --git a/src/sync/src/syncRetrieve.c b/src/sync/src/syncRetrieve.c index 153886102e..cb2379583f 100644 --- a/src/sync/src/syncRetrieve.c +++ b/src/sync/src/syncRetrieve.c @@ -475,7 +475,8 @@ void *syncRetrieveData(void *param) { SSyncNode *pNode = pPeer->pSyncNode; taosBlockSIGPIPE(); - sInfo("%s, start to retrieve data, sstatus:%s", pPeer->id, syncStatus[pPeer->sstatus]); + sInfo("%s, start to retrieve data, sstatus:%s, numOfRetrieves:%d", pPeer->id, syncStatus[pPeer->sstatus], + pPeer->numOfRetrieves); if (pNode->notifyFlowCtrl) (*pNode->notifyFlowCtrl)(pNode->vgId, pPeer->numOfRetrieves); @@ -497,9 +498,11 @@ void *syncRetrieveData(void *param) { pPeer->numOfRetrieves++; } else { pPeer->numOfRetrieves = 0; - if (pNode->notifyFlowCtrl) (*pNode->notifyFlowCtrl)(pNode->vgId, 0); + // if (pNode->notifyFlowCtrl) (*pNode->notifyFlowCtrl)(pNode->vgId, 0); } + if (pNode->notifyFlowCtrl) (*pNode->notifyFlowCtrl)(pNode->vgId, 0); + pPeer->fileChanged = 0; taosClose(pPeer->syncFd); diff --git a/src/sync/test/CMakeLists.txt b/src/sync/test/CMakeLists.txt index 27614454f9..256e87580d 100644 --- a/src/sync/test/CMakeLists.txt +++ b/src/sync/test/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_LINUX) diff --git a/src/tsdb/CMakeLists.txt b/src/tsdb/CMakeLists.txt index d86b104f23..d8bc20ca99 100644 --- a/src/tsdb/CMakeLists.txt +++ b/src/tsdb/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c index 8e57066d27..b53b8ed5b4 100644 --- a/src/tsdb/src/tsdbRWHelper.c +++ b/src/tsdb/src/tsdbRWHelper.c @@ -753,8 +753,8 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa pCompCol->type = pDataCol->type; if (tDataTypeDesc[pDataCol->type].getStatisFunc) { (*tDataTypeDesc[pDataCol->type].getStatisFunc)( - (TSKEY *)(pDataCols->cols[0].pData), pDataCol->pData, rowsToWrite, &(pCompCol->min), &(pCompCol->max), - &(pCompCol->sum), &(pCompCol->minIndex), &(pCompCol->maxIndex), &(pCompCol->numOfNull)); + pDataCol->pData, rowsToWrite, &(pCompCol->min), &(pCompCol->max), &(pCompCol->sum), &(pCompCol->minIndex), + &(pCompCol->maxIndex), &(pCompCol->numOfNull)); } nColsNotAllNull++; } diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 78b9c90979..48b4d76561 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/rpc/inc) diff --git a/src/util/inc/tstoken.h b/src/util/inc/tstoken.h index e2654f21f4..b36d0017e8 100644 --- a/src/util/inc/tstoken.h +++ b/src/util/inc/tstoken.h @@ -76,7 +76,7 @@ bool isKeyWord(const char *z, int32_t len); * @param pToken * @return token type, if it is not a number, TK_ILLEGAL will return */ -static FORCE_INLINE int32_t isValidNumber(const SStrToken* pToken) { +static FORCE_INLINE int32_t tGetNumericStringType(const SStrToken* pToken) { const char* z = pToken->z; int32_t type = TK_ILLEGAL; @@ -111,7 +111,6 @@ static FORCE_INLINE int32_t isValidNumber(const SStrToken* pToken) { type = TK_FLOAT; goto _end; - break; } case '0': { diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index ff67b1f3ec..75ac930723 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -30,28 +30,51 @@ int32_t compareInt8Val(const void *pLeft, const void *pRight) { return 0; } -int32_t compareIntDoubleVal(const void *pLeft, const void *pRight) { - int64_t lhs = GET_INT64_VAL(pLeft); - double rhs = GET_DOUBLE_VAL(pRight); - if (fabs(lhs - rhs) < FLT_EPSILON) { - return 0; - } else { - return (lhs > rhs) ? 1 : -1; - } +int32_t compareUint32Val(const void *pLeft, const void *pRight) { + int32_t left = GET_UINT32_VAL(pLeft), right = GET_UINT32_VAL(pRight); + if (left > right) return 1; + if (left < right) return -1; + return 0; } -int32_t compareDoubleIntVal(const void *pLeft, const void *pRight) { - double lhs = GET_DOUBLE_VAL(pLeft); - int64_t rhs = GET_INT64_VAL(pRight); - if (fabs(lhs - rhs) < FLT_EPSILON) { - return 0; - } else { - return (lhs > rhs) ? 1 : -1; - } +int32_t compareUint64Val(const void *pLeft, const void *pRight) { + int64_t left = GET_UINT64_VAL(pLeft), right = GET_UINT64_VAL(pRight); + if (left > right) return 1; + if (left < right) return -1; + return 0; +} + +int32_t compareUint16Val(const void *pLeft, const void *pRight) { + int16_t left = GET_UINT16_VAL(pLeft), right = GET_UINT16_VAL(pRight); + if (left > right) return 1; + if (left < right) return -1; + return 0; +} + +int32_t compareUint8Val(const void* pLeft, const void* pRight) { + uint8_t left = GET_UINT8_VAL(pLeft), right = GET_UINT8_VAL(pRight); + if (left > right) return 1; + if (left < right) return -1; + return 0; } int32_t compareFloatVal(const void *pLeft, const void *pRight) { - float ret = GET_FLOAT_VAL(pLeft) - GET_FLOAT_VAL(pRight); + float p1 = GET_FLOAT_VAL(pLeft); + float p2 = GET_FLOAT_VAL(pRight); + + if (isnan(p1) && isnan(p2)) { + return 0; + } + + if (isnan(p1)) { + return -1; + } + + if (isnan(p2)) { + return 1; + } + + float ret = p1 - p2; if (fabs(ret) < FLT_EPSILON) { return 0; } else { @@ -60,7 +83,22 @@ int32_t compareFloatVal(const void *pLeft, const void *pRight) { } int32_t compareDoubleVal(const void *pLeft, const void *pRight) { - double ret = GET_DOUBLE_VAL(pLeft) - GET_DOUBLE_VAL(pRight); + double p1 = GET_DOUBLE_VAL(pLeft); + double p2 = GET_DOUBLE_VAL(pRight); + + if (isnan(p1) && isnan(p2)) { + return 0; + } + + if (isnan(p1)) { + return -1; + } + + if (isnan(p2)) { + return 1; + } + + double ret = p1 - p2; if (fabs(ret) < FLT_EPSILON) { return 0; } else { @@ -339,15 +377,24 @@ __compar_fn_t getKeyComparFunc(int32_t keyType) { case TSDB_DATA_TYPE_DOUBLE: comparFn = compareDoubleVal; break; - + case TSDB_DATA_TYPE_UTINYINT: + comparFn = compareUint8Val; + break; + case TSDB_DATA_TYPE_USMALLINT: + comparFn = compareUint16Val; + break; + case TSDB_DATA_TYPE_UINT: + comparFn = compareUint32Val; + break; + case TSDB_DATA_TYPE_UBIGINT: + comparFn = compareUint64Val; + break; case TSDB_DATA_TYPE_BINARY: comparFn = compareLenPrefixedStr; break; - case TSDB_DATA_TYPE_NCHAR: comparFn = compareLenPrefixedWStr; break; - default: comparFn = compareInt32Val; break; diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index 1a5c3bd64d..49b69ea0a1 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -283,6 +283,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie SOCKET sockFd = 0; int32_t ret; struct sockaddr_in serverAddr, clientAddr; + int32_t bufSize = 1024 * 1024; sockFd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -300,6 +301,18 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie return -1; } + if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_SNDBUF, (void *)&bufSize, sizeof(bufSize)) != 0) { + uError("failed to set the send buffer size for TCP socket\n"); + taosCloseSocket(sockFd); + return -1; + } + + if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_RCVBUF, (void *)&bufSize, sizeof(bufSize)) != 0) { + uError("failed to set the receive buffer size for TCP socket\n"); + taosCloseSocket(sockFd); + return -1; + } + if (clientIp != 0) { memset((char *)&clientAddr, 0, sizeof(clientAddr)); clientAddr.sin_family = AF_INET; diff --git a/src/util/tests/CMakeLists.txt b/src/util/tests/CMakeLists.txt index 0c96ed2a2f..6066d58416 100644 --- a/src/util/tests/CMakeLists.txt +++ b/src/util/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include/gtest) diff --git a/src/vnode/CMakeLists.txt b/src/vnode/CMakeLists.txt index de0cdb028b..c953883361 100644 --- a/src/vnode/CMakeLists.txt +++ b/src/vnode/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index 7adeda590a..3ec77bbc12 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -67,7 +67,7 @@ typedef struct { void * qMgmt; char * rootDir; tsem_t sem; - char db[TSDB_ACCT_LEN + TSDB_DB_NAME_LEN]; + char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; pthread_mutex_t statusMutex; } SVnodeObj; diff --git a/src/vnode/inc/vnodeRead.h b/src/vnode/inc/vnodeRead.h index f5375d6ab0..0e9655f837 100644 --- a/src/vnode/inc/vnodeRead.h +++ b/src/vnode/inc/vnodeRead.h @@ -27,7 +27,7 @@ void vnodeCleanupRead(void); int32_t vnodeWriteToRQueue(void *pVnode, void *pCont, int32_t contLen, int8_t qtype, void *rparam); void vnodeFreeFromRQueue(void *pVnode, SVReadMsg *pRead); int32_t vnodeProcessRead(void *pVnode, SVReadMsg *pRead); -void vnodeWaitReadCompleted(void *pVnode); +void vnodeWaitReadCompleted(SVnodeObj *pVnode); #ifdef __cplusplus } diff --git a/src/vnode/inc/vnodeWrite.h b/src/vnode/inc/vnodeWrite.h index 5238e45b81..e996bc0b06 100644 --- a/src/vnode/inc/vnodeWrite.h +++ b/src/vnode/inc/vnodeWrite.h @@ -27,7 +27,7 @@ void vnodeCleanupWrite(void); int32_t vnodeWriteToWQueue(void *pVnode, void *pHead, int32_t qtype, void *pRpcMsg); void vnodeFreeFromWQueue(void *pVnode, SVWriteMsg *pWrite); int32_t vnodeProcessWrite(void *pVnode, void *pHead, int32_t qtype, void *pRspRet); -void vnodeWaitWriteCompleted(void *pVnode); +void vnodeWaitWriteCompleted(SVnodeObj *pVnode); #ifdef __cplusplus } diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index eb43fba079..5f6f3fe105 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -420,9 +420,6 @@ void vnodeCleanUp(SVnodeObj *pVnode) { vnodeSetClosingStatus(pVnode); - // release local resources only after cutting off outside connections - qQueryMgmtNotifyClosed(pVnode->qMgmt); - // stop replication module if (pVnode->sync > 0) { int64_t sync = pVnode->sync; diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index c864bc995b..acb1fc78f6 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -436,4 +436,9 @@ int32_t vnodeNotifyCurrentQhandle(void *handle, void *qhandle, int32_t vgId) { return rpcReportProgress(handle, (char *)pMsg, sizeof(SRetrieveTableMsg)); } -void vnodeWaitReadCompleted(void *pVnode) {} \ No newline at end of file +void vnodeWaitReadCompleted(SVnodeObj *pVnode) { + while (pVnode->queuedRMsg > 0) { + vTrace("vgId:%d, queued rmsg num:%d", pVnode->vgId, pVnode->queuedRMsg); + taosMsleep(10); + } +} \ No newline at end of file diff --git a/src/vnode/src/vnodeStatus.c b/src/vnode/src/vnodeStatus.c index ce7ddd11b5..6889843530 100644 --- a/src/vnode/src/vnodeStatus.c +++ b/src/vnode/src/vnodeStatus.c @@ -18,6 +18,8 @@ #include "taosmsg.h" #include "query.h" #include "vnodeStatus.h" +#include "vnodeRead.h" +#include "vnodeWrite.h" char* vnodeStatus[] = { "init", @@ -42,8 +44,6 @@ bool vnodeSetReadyStatus(SVnodeObj* pVnode) { pVnode->status == TAOS_VN_STATUS_UPDATING || pVnode->status == TAOS_VN_STATUS_RESET) { pVnode->status = TAOS_VN_STATUS_READY; set = true; - } else { - vDebug("vgId:%d, cannot set status:ready, old:%s", pVnode->vgId, vnodeStatus[pVnode->status]); } qQueryMgmtReOpen(pVnode->qMgmt); @@ -59,8 +59,6 @@ static bool vnodeSetClosingStatusImp(SVnodeObj* pVnode) { if (pVnode->status == TAOS_VN_STATUS_READY || pVnode->status == TAOS_VN_STATUS_INIT) { pVnode->status = TAOS_VN_STATUS_CLOSING; set = true; - } else { - vTrace("vgId:%d, cannot set status:closing, old:%s", pVnode->vgId, vnodeStatus[pVnode->status]); } pthread_mutex_unlock(&pVnode->statusMutex); @@ -68,13 +66,15 @@ static bool vnodeSetClosingStatusImp(SVnodeObj* pVnode) { } bool vnodeSetClosingStatus(SVnodeObj* pVnode) { - int32_t i = 0; while (!vnodeSetClosingStatusImp(pVnode)) { - if (++i % 1000 == 0) { - sched_yield(); - } + taosMsleep(1); } + // release local resources only after cutting off outside connections + qQueryMgmtNotifyClosed(pVnode->qMgmt); + vnodeWaitReadCompleted(pVnode); + vnodeWaitWriteCompleted(pVnode); + return true; } @@ -85,8 +85,6 @@ bool vnodeSetUpdatingStatus(SVnodeObj* pVnode) { if (pVnode->status == TAOS_VN_STATUS_READY) { pVnode->status = TAOS_VN_STATUS_UPDATING; set = true; - } else { - vDebug("vgId:%d, cannot set status:updating, old:%s", pVnode->vgId, vnodeStatus[pVnode->status]); } pthread_mutex_unlock(&pVnode->statusMutex); @@ -100,8 +98,6 @@ static bool vnodeSetResetStatusImp(SVnodeObj* pVnode) { if (pVnode->status == TAOS_VN_STATUS_READY || pVnode->status == TAOS_VN_STATUS_INIT) { pVnode->status = TAOS_VN_STATUS_RESET; set = true; - } else { - vDebug("vgId:%d, cannot set status:reset, old:%s", pVnode->vgId, vnodeStatus[pVnode->status]); } pthread_mutex_unlock(&pVnode->statusMutex); @@ -109,13 +105,15 @@ static bool vnodeSetResetStatusImp(SVnodeObj* pVnode) { } bool vnodeSetResetStatus(SVnodeObj* pVnode) { - int32_t i = 0; while (!vnodeSetResetStatusImp(pVnode)) { - if (++i % 1000 == 0) { - sched_yield(); - } + taosMsleep(1); } + // release local resources only after cutting off outside connections + qQueryMgmtNotifyClosed(pVnode->qMgmt); + vnodeWaitReadCompleted(pVnode); + vnodeWaitWriteCompleted(pVnode); + return true; } @@ -155,18 +153,6 @@ bool vnodeInReadyOrUpdatingStatus(SVnodeObj* pVnode) { return in; } -bool vnodeInClosingStatus(SVnodeObj* pVnode) { - bool in = false; - pthread_mutex_lock(&pVnode->statusMutex); - - if (pVnode->status == TAOS_VN_STATUS_CLOSING) { - in = true; - } - - pthread_mutex_unlock(&pVnode->statusMutex); - return in; -} - bool vnodeInResetStatus(SVnodeObj* pVnode) { bool in = false; pthread_mutex_lock(&pVnode->statusMutex); diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 5c2e871eb6..801d51b3c8 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -52,7 +52,10 @@ int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rpara int32_t code = 0; SVnodeObj *pVnode = vparam; SWalHead * pHead = wparam; - SRspRet * pRspRet = rparam; + SVWriteMsg*pWrite = rparam; + + SRspRet *pRspRet = NULL; + if (pWrite != NULL) pRspRet = &pWrite->rspRet; if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL) { vError("vgId:%d, msg:%s not processed since no handle, qtype:%s hver:%" PRIu64, pVnode->vgId, @@ -85,7 +88,7 @@ int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rpara // forward to peers, even it is WAL/FWD, it shall be called to update version in sync int32_t syncCode = 0; - syncCode = syncForwardToPeer(pVnode->sync, pHead, pRspRet, qtype); + syncCode = syncForwardToPeer(pVnode->sync, pHead, pWrite, qtype); if (syncCode < 0) return syncCode; // write into WAL @@ -230,7 +233,7 @@ static SVWriteMsg *vnodeBuildVWriteMsg(SVnodeObj *pVnode, SWalHead *pHead, int32 pWrite->rpcMsg = *pRpcMsg; } - memcpy(pWrite->pHead, pHead, sizeof(SWalHead) + pHead->len); + memcpy(&pWrite->pHead, pHead, sizeof(SWalHead) + pHead->len); pWrite->pVnode = pVnode; pWrite->qtype = qtype; @@ -305,7 +308,7 @@ static void vnodeFlowCtrlMsgToWQueue(void *param, void *tmrId) { if (pVnode->flowctrlLevel <= 0) code = TSDB_CODE_VND_IS_FLOWCTRL; pWrite->processedCount++; - if (pWrite->processedCount > 100) { + if (pWrite->processedCount >= 100) { vError("vgId:%d, msg:%p, failed to process since %s, retry:%d", pVnode->vgId, pWrite, tstrerror(code), pWrite->processedCount); pWrite->processedCount = 1; @@ -345,4 +348,9 @@ static int32_t vnodePerformFlowCtrl(SVWriteMsg *pWrite) { } } -void vnodeWaitWriteCompleted(void *pVnode) {} \ No newline at end of file +void vnodeWaitWriteCompleted(SVnodeObj *pVnode) { + while (pVnode->queuedWMsg > 0) { + vTrace("vgId:%d, queued wmsg num:%d", pVnode->vgId, pVnode->queuedWMsg); + taosMsleep(10); + } +} diff --git a/src/wal/CMakeLists.txt b/src/wal/CMakeLists.txt index 359e09287a..681bed5425 100644 --- a/src/wal/CMakeLists.txt +++ b/src/wal/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) diff --git a/src/wal/test/CMakeLists.txt b/src/wal/test/CMakeLists.txt index 6c232ce4b9..b8338b1738 100644 --- a/src/wal/test/CMakeLists.txt +++ b/src/wal/test/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_LINUX) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4e7e9a87ea..57fc8b1953 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,7 +3,7 @@ # generate release version: # mkdir release; cd release; cmake -DCMAKE_BUILD_TYPE=Release .. -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) SET(CMAKE_C_STANDARD 11) diff --git a/tests/comparisonTest/tdengine/CMakeLists.txt b/tests/comparisonTest/tdengine/CMakeLists.txt index 990612b8c3..aaa18592ed 100644 --- a/tests/comparisonTest/tdengine/CMakeLists.txt +++ b/tests/comparisonTest/tdengine/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) IF (TD_LINUX) diff --git a/tests/examples/C#/taosdemo/README.md b/tests/examples/C#/taosdemo/README.md index 82a8dc674a..2d125fb140 100644 --- a/tests/examples/C#/taosdemo/README.md +++ b/tests/examples/C#/taosdemo/README.md @@ -10,30 +10,27 @@ run C# version taosdemo === Usage: mono taosdemo.exe [OPTION...] - --help Show usage. + --help Show usage. - -h host, The host to connect to TDengine. Default is localhost. - -p port, The TCP/IP port number to use for the connection. Default is 0. - -u user, The user name to use when connecting to the server. Default is 'root'. - -P password, The password to use when connecting to the server. Default is 'taosdata'. - -d database, Destination database. Default is 'test'. - -a replica, Set the replica parameters of the database, Default 1, min: 1, max: 5. - -m table_prefix, Table prefix name. Default is 't'. - -s sql file, The select sql file. - -M stable, Use super table. - -o outputfile, Direct output to the named file. Default is './output.txt'. - -q query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC. - -b type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'. - -w length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8 - -l num_of_cols_per_record, The number of columns per record. Default is 3. - -T num_of_threads, The number of threads. Default is 10. - -r num_of_records_per_req, The number of records per request. Default is 1000. - -t num_of_tables, The number of tables. Default is 1. - -n num_of_records_per_table, The number of records per table. Default is 1. - -c config_directory, Configuration directory. Default is '/etc/taos/'. - -x flag, Insert only flag. - -O order, Insert mode--0: In order, 1: Out of order. Default is in order. - -R rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50. - -D Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database. - -v Print verbose output - -y Skip read key for continous test, default is not skip + -h host, The host to connect to TDengine. Default is localhost. + -p port, The TCP/IP port number to use for the connection. Default is 0. + -u user, The user name to use when connecting to the server. Default is 'root'. + -P password, The password to use when connecting to the server. Default is 'taosdata'. + -d database, Destination database. Default is 'test'. + -a replica, Set the replica parameters of the database, Default 1, min: 1, max: 5. + -m table_prefix, Table prefix name. Default is 't'. + -M stable, Use super table. + -s stable_prefix, STable prefix name. Default is 'st' + -Q query, Execute query command. set 'DEFAULT' means select * from each table + -T num_of_threads, The number of threads. Default is 10. + -r num_of_records_per_req, The number of records per request. Default is 1000. + -t num_of_tables, The number of tables. Default is 1. + -n num_of_records_per_table, The number of records per table. Default is 1. + -c config_directory, Configuration directory. Default is '/etc/taos/'. + -x flag, Insert only flag. + -O order, Insert mode--0: In order, 1: Out of order. Default is in order. + -R rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50. + -D Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database. + -v Print verbose output + -g Print debug output + -y Skip read key for continous test, default is not skip diff --git a/tests/examples/C#/taosdemo/taosdemo.cs b/tests/examples/C#/taosdemo/taosdemo.cs index 7e7c18db26..df52acc99d 100644 --- a/tests/examples/C#/taosdemo/taosdemo.cs +++ b/tests/examples/C#/taosdemo/taosdemo.cs @@ -34,11 +34,12 @@ namespace TDengineDriver //sql parameters private string dbName = "db"; - private string stableName = "st"; + private string stablePrefix = "st"; private string tablePrefix = "t"; private bool isInsertOnly = false; - private int queryMode = 1; + private string query = "NONE"; + private short queryMode = 1; private long recordsPerTable = 1; private int recordsPerRequest = 1; @@ -52,12 +53,19 @@ namespace TDengineDriver private bool useStable = false; private short methodOfDelete = 0; private long numOfThreads = 1; - private long rateOfOutorder = 0; + private short rateOfOutorder = 10; private bool order = true; private bool skipReadKey = false; private bool verbose = false; + private bool debug = false; + static void HelpPrint(string arg, string desc) + { + string indent = " "; + Console.WriteLine("{0}{1}", indent, arg.PadRight(25)+desc); + } + static void PrintHelp(String[] argv) { for (int i = 0; i < argv.Length; ++i) @@ -66,59 +74,38 @@ namespace TDengineDriver { Console.WriteLine("Usage: mono taosdemo.exe [OPTION...]"); Console.WriteLine(""); - string indent = " "; - Console.WriteLine("{0}{1}", indent, "--help Show usage."); + HelpPrint("--help", "Show usage."); Console.WriteLine(""); - Console.Write("{0}{1}", indent, "-h"); - Console.Write("{0}{1}{2}\n", indent, indent, "host, The host to connect to TDengine. Default is localhost."); - Console.Write("{0}{1}", indent, "-p"); - Console.Write("{0}{1}{2}\n", indent, indent, "port, The TCP/IP port number to use for the connection. Default is 0."); - Console.Write("{0}{1}", indent, "-u"); - Console.Write("{0}{1}{2}\n", indent, indent, "user, The user name to use when connecting to the server. Default is 'root'."); - Console.Write("{0}{1}", indent, "-P"); - Console.Write("{0}{1}{2}\n", indent, indent, "password, The password to use when connecting to the server. Default is 'taosdata'."); - Console.Write("{0}{1}", indent, "-d"); - Console.Write("{0}{1}{2}\n", indent, indent, "database, Destination database. Default is 'test'."); - Console.Write("{0}{1}", indent, "-a"); - Console.Write("{0}{1}{2}\n", indent, indent, "replica, Set the replica parameters of the database, Default 1, min: 1, max: 5."); - Console.Write("{0}{1}", indent, "-m"); - Console.Write("{0}{1}{2}\n", indent, indent, "table_prefix, Table prefix name. Default is 't'."); - Console.Write("{0}{1}", indent, "-s"); - Console.Write("{0}{1}{2}\n", indent, indent, "sql file, The select sql file."); - Console.Write("{0}{1}", indent, "-M"); - Console.Write("{0}{1}{2}\n", indent, indent, "stable, Use super table."); - Console.Write("{0}{1}", indent, "-o"); - Console.Write("{0}{1}{2}\n", indent, indent, "outputfile, Direct output to the named file. Default is './output.txt'."); - Console.Write("{0}{1}", indent, "-q"); - Console.Write("{0}{1}{2}\n", indent, indent, "query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC."); - Console.Write("{0}{1}", indent, "-b"); - Console.Write("{0}{1}{2}\n", indent, indent, "type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."); - Console.Write("{0}{1}", indent, "-w"); - Console.Write("{0}{1}{2}\n", indent, indent, "length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"); - Console.Write("{0}{1}", indent, "-l"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_cols_per_record, The number of columns per record. Default is 3."); - Console.Write("{0}{1}", indent, "-T"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_threads, The number of threads. Default is 10."); - Console.Write("{0}{1}", indent, "-r"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_records_per_req, The number of records per request. Default is 1000."); - Console.Write("{0}{1}", indent, "-t"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_tables, The number of tables. Default is 1."); - Console.Write("{0}{1}", indent, "-n"); - Console.Write("{0}{1}{2}\n", indent, indent, "num_of_records_per_table, The number of records per table. Default is 1."); - Console.Write("{0}{1}", indent, "-c"); - Console.Write("{0}{1}{2}\n", indent, indent, "config_directory, Configuration directory. Default is '/etc/taos/'."); - Console.Write("{0}{1}", indent, "-x"); - Console.Write("{0}{1}{2}\n", indent, indent, "flag, Insert only flag."); - Console.Write("{0}{1}", indent, "-O"); - Console.Write("{0}{1}{2}\n", indent, indent, "order, Insert mode--0: In order, 1: Out of order. Default is in order."); - Console.Write("{0}{1}", indent, "-R"); - Console.Write("{0}{1}{2}\n", indent, indent, "rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."); - Console.Write("{0}{1}", indent, "-D"); - Console.Write("{0}{1}{2}\n", indent, indent, "Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."); - Console.Write("{0}{1}", indent, "-v"); - Console.Write("{0}{1}{2}\n", indent, indent, "Print verbose output"); - Console.Write("{0}{1}", indent, "-y"); - Console.Write("{0}{1}{2}\n", indent, indent, "Skip read key for continous test, default is not skip"); + + HelpPrint("-h ", "host, The host to connect to TDengine. Default is localhost."); + HelpPrint("-p ", "port, The TCP/IP port number to use for the connection. Default is 0."); + HelpPrint("-u ", "user, The user name to use when connecting to the server. Default is 'root'."); + HelpPrint("-P ", "password, The password to use when connecting to the server. Default is 'taosdata'."); + HelpPrint("-d ", "database, Destination database. Default is 'test'."); + HelpPrint("-a ", "replica, Set the replica parameters of the database, Default 1, min: 1, max: 5."); + HelpPrint("-m
", "table_prefix, Table prefix name. Default is 't'."); + HelpPrint("-M", "stable, Use super table."); + HelpPrint("-s ", "stable_prefix, STable prefix name. Default is 'st'"); + HelpPrint("-Q ", "query, Execute query command. set 'DEFAULT' means select * from each table"); + /* NOT SUPPORT SO FAR + HelpPrint("-o", "outputfile, Direct output to the named file. Default is './output.txt'."); + HelpPrint("-q", "query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC."); + HelpPrint("-b", "type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."); + HelpPrint("-w", "length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"); + HelpPrint("-l", "num_of_cols_per_record, The number of columns per record. Default is 3."); + */ + HelpPrint("-T ", "num_of_threads, The number of threads. Default is 10."); + HelpPrint("-r ", "num_of_records_per_req, The number of records per request. Default is 1000."); + HelpPrint("-t ", "num_of_tables, The number of tables. Default is 1."); + HelpPrint("-n ", "num_of_records_per_table, The number of records per table. Default is 1."); + HelpPrint("-c ", "config_directory, Configuration directory. Default is '/etc/taos/'."); + HelpPrint("-x", "flag, Insert only flag."); + HelpPrint("-O", "order, Insert mode--0: In order, 1: Out of order. Default is in order."); + HelpPrint("-R ", "rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."); + HelpPrint("-D ", "Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."); + HelpPrint("-v", "Print verbose output"); + HelpPrint("-g", "Print debug output"); + HelpPrint("-y", "Skip read key for continous test, default is not skip"); System.Environment.Exit(0); } @@ -132,49 +119,56 @@ namespace TDengineDriver user = this.GetArgumentAsString(argv, "-u", "root"); password = this.GetArgumentAsString(argv, "-P", "taosdata"); dbName = this.GetArgumentAsString(argv, "-d", "db"); - stableName = this.GetArgumentAsString(argv, "-s", "st"); + stablePrefix = this.GetArgumentAsString(argv, "-s", "st"); tablePrefix = this.GetArgumentAsString(argv, "-m", "t"); - isInsertOnly = this.GetArgumentAsFlag(argv, "-x"); - queryMode = (int)this.GetArgumentAsLong(argv, "-q", 0, 1, 0); + isInsertOnly = this.GetArgumentAsFlag(argv, "-x", true); + query = this.GetArgumentAsString(argv, "-Q", "NONE"); + queryMode = (short)this.GetArgumentAsLong(argv, "-q", 0, 1, 0); numOfTables = this.GetArgumentAsLong(argv, "-t", 1, 1000000000, 1); batchRows = this.GetArgumentAsLong(argv, "-r", 1, 10000, 1000); recordsPerTable = this.GetArgumentAsLong(argv, "-n", 1, 100000000000, 1); recordsPerRequest = (int)this.GetArgumentAsLong(argv, "-r", 1, 10000, 1); colsPerRecord = (int)this.GetArgumentAsLong(argv, "-l", 1, 1024, 3); configDir = this.GetArgumentAsString(argv, "-c", "C:/TDengine/cfg"); - useStable = this.GetArgumentAsFlag(argv, "-M"); + useStable = this.GetArgumentAsFlag(argv, "-M", true); replica = (short)this.GetArgumentAsLong(argv, "-a", 1, 5, 1); methodOfDelete = (short)this.GetArgumentAsLong(argv, "-D", 0, 3, 0); numOfThreads = (short)this.GetArgumentAsLong(argv, "-T", 1, 10000, 1); - order = this.GetArgumentAsFlag(argv, "-O"); - rateOfOutorder = this.GetArgumentAsLong(argv, "-R", 0, 100, 0); + order = this.GetArgumentAsFlag(argv, "-O", false); + rateOfOutorder = (short)this.GetArgumentAsLong(argv, "-R", 0, 50, 10); - skipReadKey = this.GetArgumentAsFlag(argv, "-y"); - verbose = this.GetArgumentAsFlag(argv, "-v"); + skipReadKey = this.GetArgumentAsFlag(argv, "-y", true); + verbose = this.GetArgumentAsFlag(argv, "-v", true); + debug = this.GetArgumentAsFlag(argv, "-g", true); - Console.Write("###################################################################\n"); - Console.Write("# Server IP: {0}\n", host); - Console.Write("# User: {0}\n", user); - Console.Write("# Password: {0}\n", password); - Console.Write("# Number of Columns per record: {0}\n", colsPerRecord); - Console.Write("# Number of Threads: {0}\n", numOfThreads); - Console.Write("# Number of Tables: {0}\n", numOfTables); - Console.Write("# Number of Data per Table: {0}\n", recordsPerTable); - Console.Write("# Records/Request: {0}\n", recordsPerRequest); - Console.Write("# Database name: {0}\n", dbName); - Console.Write("# Replica: {0}\n", replica); - Console.Write("# Use STable: {0}\n", useStable); - Console.Write("# Table prefix: {0}\n", tablePrefix); - Console.Write("# Data order: {0}\n", order); - Console.Write("# Data out of order rate: {0}\n", rateOfOutorder); - Console.Write("# Delete method: {0}\n", methodOfDelete); - Console.Write("# Query Mode: {0}\n", queryMode); - Console.Write("# Insert Only: {0}\n", isInsertOnly); - Console.Write("# Verbose output {0}\n", verbose); - Console.Write("# Test time: {0}\n", DateTime.Now.ToString("h:mm:ss tt")); + VerbosePrint ("###################################################################\n"); + VerbosePrintFormat ("# Server IP: {0}\n", host); + VerbosePrintFormat ("# User: {0}\n", user); + VerbosePrintFormat ("# Password: {0}\n", password); + VerbosePrintFormat ("# Number of Columns per record: {0}\n", colsPerRecord); + VerbosePrintFormat ("# Number of Threads: {0}\n", numOfThreads); + VerbosePrintFormat ("# Number of Tables: {0}\n", numOfTables); + VerbosePrintFormat ("# Number of records per Table: {0}\n", recordsPerTable); + VerbosePrintFormat ("# Records/Request: {0}\n", recordsPerRequest); + VerbosePrintFormat ("# Database name: {0}\n", dbName); + VerbosePrintFormat ("# Replica: {0}\n", replica); + VerbosePrintFormat ("# Use STable: {0}\n", useStable); + VerbosePrintFormat ("# Table prefix: {0}\n", tablePrefix); + if (useStable == true) + { + VerbosePrintFormat("# STable prefix: {0}\n", stablePrefix); + } + VerbosePrintFormat ("# Data order: {0}\n", order); + VerbosePrintFormat ("# Data out of order rate: {0}\n", rateOfOutorder); + VerbosePrintFormat ("# Delete method: {0}\n", methodOfDelete); + VerbosePrintFormat ("# Query command: {0}\n", query); + VerbosePrintFormat ("# Query Mode: {0}\n", queryMode); + VerbosePrintFormat ("# Insert Only: {0}\n", isInsertOnly); + VerbosePrintFormat ("# Verbose output {0}\n", verbose); + VerbosePrintFormat ("# Test time: {0}\n", DateTime.Now.ToString("h:mm:ss tt")); - Console.Write("###################################################################\n"); + VerbosePrint ("###################################################################\n"); if (skipReadKey == false) { @@ -183,17 +177,17 @@ namespace TDengineDriver } } - public bool GetArgumentAsFlag(String[] argv, String argName) + public bool GetArgumentAsFlag(String[] argv, String argName, bool defaultValue) { int argc = argv.Length; for (int i = 0; i < argc; ++i) { if (argName == argv[i]) { - return true; + return defaultValue; } } - return false; + return !defaultValue; } public long GetArgumentAsLong(String[] argv, String argName, int minVal, long maxVal, int defaultValue) @@ -210,15 +204,15 @@ namespace TDengineDriver String tmp = argv[i + 1]; if (tmp[0] == '-') { - Console.WriteLine("option {0:G} requires an argument", tmp); - ExitProgram(); + Console.WriteLine("option {0:G} requires an argument", argName); + ExitProgram(1); } long tmpVal = Convert.ToInt64(tmp); if (tmpVal < minVal || tmpVal > maxVal) { - Console.WriteLine("option {0:G} should in range [{1:G}, {2:G}]", argName, minVal, maxVal); - ExitProgram(); + Console.WriteLine("option {0:G} value should in range [{1:G}, {2:G}]", argName, minVal, maxVal); + ExitProgram(1); } return tmpVal; @@ -242,8 +236,8 @@ namespace TDengineDriver String tmp = argv[i + 1]; if (tmp[0] == '-') { - Console.WriteLine("option {0:G} requires an argument", tmp); - ExitProgram(); + Console.WriteLine("option {0:G} requires an argument", argName); + ExitProgram(1); } return tmp; } @@ -252,13 +246,18 @@ namespace TDengineDriver return defaultValue; } - static void ExitProgram() + static void CleanAndExitProgram(int ret) { TDengine.Cleanup(); - System.Environment.Exit(0); + System.Environment.Exit(ret); } - private void DebugPrintFormat(string format, params object[] parameters) + static void ExitProgram(int ret) + { + System.Environment.Exit(ret); + } + + private void VerbosePrintFormat(string format, params object[] parameters) { if (verbose == true) { @@ -266,7 +265,7 @@ namespace TDengineDriver } } - private void DebugPrint(string str) + private void VerbosePrint(string str) { if (verbose == true) { @@ -274,28 +273,44 @@ namespace TDengineDriver } } + private void DebugPrintFormat(string format, params object[] parameters) + { + if (debug == true) + { + Console.Write(format, parameters); + } + } + + private void DebugPrint(string str) + { + if (debug == true) + { + Console.Write(str); + } + } + public void InitTDengine() { TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); TDengine.Init(); - DebugPrint("TDengine Initialization finished\n"); + VerbosePrint("TDengine Initialization finished\n"); } public void ConnectTDengine() { string db = ""; - DebugPrintFormat("host:{0} user:{1}, pass:{2}; db:{3}, port:{4}\n", + VerbosePrintFormat("host:{0} user:{1}, pass:{2}; db:{3}, port:{4}\n", this.host, this.user, this.password, db, this.port); this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port); if (this.conn == IntPtr.Zero) { Console.WriteLine("Connect to TDengine failed"); - ExitProgram(); + CleanAndExitProgram(1); } else { - DebugPrint("Connect to TDengine success\n"); + VerbosePrint("Connect to TDengine success\n"); } } @@ -323,12 +338,13 @@ namespace TDengineDriver CreateTableThread createTableThread = new CreateTableThread(); createTableThread.id = i; createTableThread.verbose = verbose; + createTableThread.debug = debug; createTableThread.dbName = this.dbName; createTableThread.tablePrefix = this.tablePrefix; createTableThread.useStable = useStable; if (useStable) { - createTableThread.stableName = stableName; + createTableThread.stablePrefix = stablePrefix; } createTableThread.conn = conn; @@ -356,12 +372,12 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); - ExitProgram(); + CleanAndExitProgram(1); } } @@ -373,12 +389,12 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); - ExitProgram(); + CleanAndExitProgram(1); } TDengine.FreeResult(res); } @@ -389,17 +405,17 @@ namespace TDengineDriver sql.Clear(); sql.Append("CREATE TABLE IF NOT EXISTS "). - Append(this.dbName).Append(".").Append(this.stableName). + Append(this.dbName).Append(".").Append(this.stablePrefix). Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)"); IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res)); - ExitProgram(); + CleanAndExitProgram(1); } TDengine.FreeResult(res); } @@ -431,11 +447,14 @@ namespace TDengineDriver insertThread.batchRows = batchRows; insertThread.numOfTables = numOfTables; insertThread.verbose = verbose; + insertThread.debug = debug; insertThread.dbName = this.dbName; insertThread.tablePrefix = this.tablePrefix; + insertThread.order = this.order; + insertThread.rateOfOutorder = this.rateOfOutorder; if (useStable) { - // insertThread.stableName = stableName; + insertThread.stablePrefix = stablePrefix; } insertThread.conn = conn; @@ -458,33 +477,43 @@ namespace TDengineDriver public void ExecuteQuery() { - // System.DateTime start = new System.DateTime(); long queryRows = 0; - for (int i = 0; i < 1/*this.numOfTables*/; ++i) + for (int i = 0; i < this.numOfTables; ++i) { - String sql = "select * from " + this.dbName + "." + tablePrefix + i; - // Console.WriteLine(sql); + string sql; + + if (query == "DEFAULT") + { + sql = "select * from " + this.dbName + "." + tablePrefix + i; + } + else + { + sql = query; + } + DebugPrintFormat("query: {0}, sql:{1}\n", query, sql); IntPtr res = TDengine.Query(conn, sql); + DebugPrintFormat("res: {0}\n", res); if (res == IntPtr.Zero) { Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res)); - ExitProgram(); + CleanAndExitProgram(1); } int fieldCount = TDengine.FieldCount(res); - // Console.WriteLine("field count: " + fieldCount); + DebugPrint("field count: " + fieldCount + "\n"); List metas = TDengine.FetchFields(res); for (int j = 0; j < metas.Count; j++) { TDengineMeta meta = (TDengineMeta)metas[j]; - // Console.WriteLine("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size); + DebugPrint("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size + "\n"); } IntPtr rowdata; StringBuilder builder = new StringBuilder(); + while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) { queryRows++; @@ -548,10 +577,7 @@ namespace TDengineDriver } builder.Append("---"); - if (queryRows <= 10) - { - Console.WriteLine(builder.ToString()); - } + VerbosePrint(builder.ToString() + "\n"); builder.Clear(); } @@ -563,13 +589,6 @@ namespace TDengineDriver TDengine.FreeResult(res); } - /* - System.DateTime end = new System.DateTime(); - TimeSpan ts = end - start; - - Console.Write("Total {0:G} rows inserted, {1:G} rows query, time spend {2:G} seconds.\n" - , this.rowsInserted, queryRows, ts.TotalSeconds); - */ } public void CloseConnection() @@ -610,13 +629,24 @@ namespace TDengineDriver watch.Stop(); double elapsedMs = watch.Elapsed.TotalMilliseconds; - Console.WriteLine("Spent {0} seconds to insert {1} records with {2} record(s) per request: {3} records/second", + Console.WriteLine("C# taosdemo: Spent {0} seconds to insert {1} records with {2} record(s) per request: {3} records/second", elapsedMs / 1000, tester.recordsPerTable * tester.numOfTables, tester.batchRows, (tester.recordsPerTable * tester.numOfTables * 1000) / elapsedMs); - tester.ExecuteQuery(); + tester.DebugPrintFormat("query command:{0}\n", tester.query); + if (tester.query != "NONE") + { + watch = Stopwatch.StartNew(); + tester.ExecuteQuery(); + watch.Stop(); + elapsedMs = watch.Elapsed.TotalMilliseconds; + Console.WriteLine("C# taosdemo: Spent {0} seconds to query {1} records.\n", + elapsedMs/1000, + tester.recordsPerTable * tester.numOfTables + ); + } tester.CloseConnection(); Console.WriteLine("End."); @@ -630,13 +660,16 @@ namespace TDengineDriver public string dbName { set; get; } public IntPtr conn { set; get; } public string tablePrefix { set; get; } - // public string stableName { set; get; } + public string stablePrefix { set; get; } public long recordsPerTable { set; get; } public long batchRows { set; get; } public long numOfTables { set; get; } public bool verbose { set; get; } + public bool debug { set; get; } + public bool order { set; get; } + public short rateOfOutorder { set; get; } - private void DebugPrintFormat(string format, params object[] parameters) + private void VerbosePrintFormat(string format, params object[] parameters) { if (verbose == true) { @@ -644,7 +677,7 @@ namespace TDengineDriver } } - private void DebugPrint(string str) + private void VerbosePrint(string str) { if (verbose == true) { @@ -652,9 +685,25 @@ namespace TDengineDriver } } + private void DebugPrintFormat(string format, params object[] parameters) + { + if (debug == true) + { + Console.Write(format, parameters); + } + } + + private void DebugPrint(string str) + { + if (debug == true) + { + Console.Write(str); + } + } + public void ThreadMain() { - DebugPrintFormat("InsertDataThread {0} from {1} to {2}\n", id, start, end); + VerbosePrintFormat("InsertDataThread {0} from {1} to {2}\n", id, start, end); StringBuilder sql = new StringBuilder(); DateTime now = DateTime.Now; @@ -663,12 +712,12 @@ namespace TDengineDriver int s = now.Second; long baseTimestamp = 1609430400000; // 2021/01/01 0:0:0 - DebugPrintFormat("beginTime is {0} + {1}h:{2}m:{3}s\n", baseTimestamp, h, m, s); + VerbosePrintFormat("beginTime is {0} + {1}h:{2}m:{3}s\n", baseTimestamp, h, m, s); long beginTimestamp = baseTimestamp + ((h*60 + m) * 60 + s) * 1000; + Random random = new Random(); long rowsInserted = 0; - // System.DateTime startTime = new System.DateTime(); long i = 0; while (i < recordsPerTable) { @@ -686,8 +735,25 @@ namespace TDengineDriver } for (int batch = 0; batch < batchRows; ++batch) { + long writeTimeStamp = beginTimestamp + i + batch; + int rnd = 100; + if (this.order == false) + { + rnd = random.Next(1, 100); + if (rnd <= this.rateOfOutorder) + { + writeTimeStamp = writeTimeStamp + rnd * 10000; + DebugPrint("### "); + } + DebugPrintFormat("order:{0} rnd:{1} timestamp:{2}\n", this.order, rnd, writeTimeStamp); + } + else + { + DebugPrintFormat("order:{0} timestamp:{1}\n", this.order, writeTimeStamp); + } + sql.Append("(") - .Append(beginTimestamp + i + batch) + .Append(writeTimeStamp) .Append(", 1, 2, 3,") .Append(i + batch) .Append(", 5, 6, 7, 'abc', 'def')"); @@ -696,7 +762,7 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res == IntPtr.Zero) { - DebugPrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); + VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); } inserted += this.batchRows; @@ -723,11 +789,12 @@ namespace TDengineDriver public string dbName { set; get; } public IntPtr conn { set; get; } public string tablePrefix { set; get; } - public string stableName { set; get; } + public string stablePrefix { set; get; } public bool verbose { set; get; } + public bool debug { set; get; } public bool useStable { set; get; } - private void DebugPrintFormat(string format, params object[] parameters) + private void VerbosePrintFormat(string format, params object[] parameters) { if (verbose == true) { @@ -735,7 +802,7 @@ namespace TDengineDriver } } - private void DebugPrint(string str) + private void VerbosePrint(string str) { if (verbose == true) { @@ -743,9 +810,17 @@ namespace TDengineDriver } } + private void DebugPrintFormat(string format, params object[] parameters) + { + if (debug == true) + { + Console.Write(format, parameters); + } + } + public void ThreadMain() { - DebugPrintFormat("CreateTable {0} from {1} to {2}\n", id, start, end); + VerbosePrintFormat("CreateTable {0} from {1} to {2}\n", id, start, end); StringBuilder sql = new StringBuilder(); @@ -756,7 +831,7 @@ namespace TDengineDriver Append(this.dbName).Append(".").Append(this.tablePrefix).Append(tableId); if (useStable == true) { - sql = sql.Append(" USING ").Append(this.dbName).Append(".").Append(this.stableName). + sql = sql.Append(" USING ").Append(this.dbName).Append(".").Append(this.stablePrefix). Append(" TAGS(").Append(tableId).Append(")"); } else @@ -766,12 +841,12 @@ namespace TDengineDriver IntPtr res = TDengine.Query(this.conn, sql.ToString()); if (res != IntPtr.Zero) { - DebugPrint(sql.ToString() + " success\n"); + VerbosePrint(sql.ToString() + " success\n"); } else { - DebugPrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); - ExitProgram(); + VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n"); + CleanAndExitProgram(1); } TDengine.FreeResult(res); } diff --git a/tests/pytest/alter/alter_table.py b/tests/pytest/alter/alter_table.py index 6d4f72556b..2982492f65 100644 --- a/tests/pytest/alter/alter_table.py +++ b/tests/pytest/alter/alter_table.py @@ -105,11 +105,11 @@ class TDTestCase: # Create db tdSql.execute("drop database if exists %s" % (db)) tdSql.execute("reset query cache") - tdSql.execute("create database %s maxrows 200 maxtables 4" % (db)) + tdSql.execute("create database %s maxrows 200" % (db)) tdSql.execute("use %s" % (db)) # Create a table with one colunm of int type and insert 300 rows - tdLog.info("Create table tb") + tdLog.info("create table tb") tdSql.execute("create table tb (ts timestamp, c1 int)") tdLog.info("Insert %d rows into tb" % (self.rowNum)) for k in range(1, self.rowNum + 1): @@ -119,20 +119,22 @@ class TDTestCase: # Alter tb and add a column of smallint type, then query tb to see if # all added column are NULL self.addColumnAndCount() - tdDnodes.stop(1) - time.sleep(5) - tdDnodes.start(1) - time.sleep(5) + tdDnodes.stop(1) + tdDnodes.start(1) tdSql.query(self.sqlHead + self.sqlTail) - for i in range(2, len(self.types) + 2): - tdSql.checkData(0, i, self.rowNum * (len(self.types) + 2 - i)) + size = len(self.types) + 2 + for i in range(2, size): + tdSql.checkData(0, i, self.rowNum * (size - i)) - self.dropColumnAndCount() + tdSql.execute("create table st(ts timestamp, c1 int) tags(t1 float)") + tdSql.execute("create table t0 using st tags(null)") + tdSql.execute("alter table t0 set tag t1=2.1") + tdSql.query("show tables") + tdSql.checkRows(2) + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) - -#tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/client/alterDatabase.py b/tests/pytest/client/alterDatabase.py index 8191312cc0..bc8c4fc17e 100644 --- a/tests/pytest/client/alterDatabase.py +++ b/tests/pytest/client/alterDatabase.py @@ -35,10 +35,9 @@ class TDTestCase: tdSql.execute("alter database db keep 365,365,365") tdSql.query("show databases") tdSql.checkData(0, 7, "365,365,365") - - tdSql.execute("alter database db quorum 2") - tdSql.query("show databases") - tdSql.checkData(0, 5, 2) + + tdSql.error("alter database db quorum 2") + tdSql.execute("alter database db blocks 100") tdSql.query("show databases") diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index cb233f85b8..d9bc185b6c 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -190,6 +190,7 @@ python3 ./test.py -f stream/table_n.py #alter table python3 ./test.py -f alter/alter_table_crash.py +python3 ./test.py -f alter/alter_table.py # client python3 ./test.py -f client/client.py diff --git a/tests/pytest/query/query.py b/tests/pytest/query/query.py index d0750ac4a5..756aa0eda9 100644 --- a/tests/pytest/query/query.py +++ b/tests/pytest/query/query.py @@ -23,6 +23,8 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) + self.ts = 1538548685000 + def run(self): tdSql.prepare() @@ -77,7 +79,37 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + ## test case for https://jira.taosdata.com:18080/browse/TD-1930 + tdSql.execute("create table tb(ts timestamp, c1 int, c2 binary(10), c3 nchar(10), c4 float, c5 bool)") + for i in range(10): + tdSql.execute("insert into tb values(%d, %d, 'binary%d', 'nchar%d', %f, %d)" % (self.ts + i, i, i, i, i + 0.1, i % 2)) + + tdSql.error("select * from tb where c2 = binary2") + tdSql.error("select * from tb where c3 = nchar2") + tdSql.query("select * from tb where c2 = 'binary2' ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c3 = 'nchar2' ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c1 = '2' ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c1 = 2 ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c4 = '0.1' ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c4 = 0.1 ") + tdSql.checkRows(1) + + tdSql.query("select * from tb where c5 = true ") + tdSql.checkRows(5) + + tdSql.query("select * from tb where c5 = 'true' ") + tdSql.checkRows(5) def stop(self): tdSql.close() diff --git a/tests/pytest/stream/new.py b/tests/pytest/stream/new.py index 12ec6d4507..70f300e937 100644 --- a/tests/pytest/stream/new.py +++ b/tests/pytest/stream/new.py @@ -43,7 +43,7 @@ class TDTestCase: tdLog.info("=============== step3") start = time.time() tdSql.waitedQuery("select * from st", 1, 120) - delay = int(time.time() - start) + 20 + delay = int(time.time() - start) + 80 v = tdSql.getData(0, 3) if v >= 51: tdLog.exit("value is %d, which is larger than 51" % v) diff --git a/tests/pytest/table/create.py b/tests/pytest/table/create.py index a0991d674a..ecd4d01141 100644 --- a/tests/pytest/table/create.py +++ b/tests/pytest/table/create.py @@ -56,6 +56,12 @@ class TDTestCase: tdSql.query("show stables like 'st%' ") tdSql.checkRows(3) + # case for defect: https://jira.taosdata.com:18080/browse/TD-2693 + tdSql.execute("create database db2") + tdSql.execute("use db2") + tdSql.execute("create table stb(ts timestamp, c int) tags(t int)") + tdSql.error("insert into db2.tb6 using db2.stb tags(1) values(now 1) tb2 using db2. tags( )values(now 2)") + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/script/general/cache/new_metrics.sim b/tests/script/general/cache/new_metrics.sim index 0e304d9acb..84f9e40de3 100644 --- a/tests/script/general/cache/new_metrics.sim +++ b/tests/script/general/cache/new_metrics.sim @@ -3,7 +3,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10 system sh/exec.sh -n dnode1 -s start sleep 3000 diff --git a/tests/script/general/cache/restart_metrics.sim b/tests/script/general/cache/restart_metrics.sim index 18c514acbf..f24768859f 100644 --- a/tests/script/general/cache/restart_metrics.sim +++ b/tests/script/general/cache/restart_metrics.sim @@ -3,7 +3,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -53,7 +52,6 @@ system sh/exec.sh -n dnode1 -s stop sleep 5000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10 system sh/exec.sh -n dnode1 -s start print =============== step3 diff --git a/tests/script/general/cache/restart_table.sim b/tests/script/general/cache/restart_table.sim index c4e6c6f2ac..8697c26bc3 100644 --- a/tests/script/general/cache/restart_table.sim +++ b/tests/script/general/cache/restart_table.sim @@ -3,7 +3,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -37,7 +36,6 @@ system sh/exec.sh -n dnode1 -s stop sleep 5000 system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 10 system sh/exec.sh -n dnode1 -s start print =============== step3 diff --git a/tests/script/general/parser/alter.sim b/tests/script/general/parser/alter.sim index 5c15656f24..eae9b88be9 100644 --- a/tests/script/general/parser/alter.sim +++ b/tests/script/general/parser/alter.sim @@ -2,9 +2,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 3 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = m_alt_db @@ -114,7 +113,7 @@ endi sql drop table tb sql drop table mt -sleep 500 +sleep 100 ### ALTER TABLE WHILE STREAMING [TBASE271] #sql create table tb1 (ts timestamp, c1 int, c2 nchar(5), c3 int) #sql create table strm as select count(*), avg(c1), first(c2), sum(c3) from tb1 interval(2s) @@ -147,7 +146,7 @@ sleep 500 #sql alter table tb1 add column c3 int #sleep 3000 #sql insert into tb1 values (now, 3, 'taos', 3); -#sleep 500 +#sleep 100 #sql select * from strm #if $rows != 3 then # return -1 @@ -186,7 +185,7 @@ sql create database $db sql use $db sql create table mt (ts timestamp, c1 int, c2 nchar(7), c3 int) tags (t1 int) sql create table tb using mt tags(1) -sleep 500 +sleep 100 sql insert into tb values ('2018-11-01 16:30:00.000', 1, 'insert', 1) sql alter table mt drop column c3 diff --git a/tests/script/general/parser/alter1.sim b/tests/script/general/parser/alter1.sim index e013242b82..26ed029050 100644 --- a/tests/script/general/parser/alter1.sim +++ b/tests/script/general/parser/alter1.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect sql reset query cache @@ -87,7 +87,7 @@ if $data13 != NULL then return -1 endi -sleep 500 +sleep 100 print ================== insert values into table sql insert into car1 values (now, 1, 1,1 ) (now +1s, 2,2,2,) car2 values (now, 1,3,3) diff --git a/tests/script/general/parser/alter_stable.sim b/tests/script/general/parser/alter_stable.sim index 6b3f3a8f53..17fc8d984a 100644 --- a/tests/script/general/parser/alter_stable.sim +++ b/tests/script/general/parser/alter_stable.sim @@ -2,9 +2,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 3 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ========== alter_stable.sim diff --git a/tests/script/general/parser/auto_create_tb.sim b/tests/script/general/parser/auto_create_tb.sim index 6deaf92a6c..903f8f9881 100644 --- a/tests/script/general/parser/auto_create_tb.sim +++ b/tests/script/general/parser/auto_create_tb.sim @@ -4,7 +4,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ======================== dnode1 start @@ -212,7 +212,7 @@ sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 sql use $db #### auto create multiple tables diff --git a/tests/script/general/parser/auto_create_tb_drop_tb.sim b/tests/script/general/parser/auto_create_tb_drop_tb.sim index 8a429cf91a..b04d024643 100644 --- a/tests/script/general/parser/auto_create_tb_drop_tb.sim +++ b/tests/script/general/parser/auto_create_tb_drop_tb.sim @@ -4,7 +4,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 system sh/cfg.sh -n dnode1 -c ctime -v 30 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = db @@ -49,7 +49,7 @@ while $t < $tbNum endw print ====== tables created -sleep 500 +sleep 100 sql drop table tb2 $x = 0 diff --git a/tests/script/general/parser/binary_escapeCharacter.sim b/tests/script/general/parser/binary_escapeCharacter.sim index e9e61f35bf..dc54add763 100644 --- a/tests/script/general/parser/binary_escapeCharacter.sim +++ b/tests/script/general/parser/binary_escapeCharacter.sim @@ -2,9 +2,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 3 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect sql drop database if exists ecdb diff --git a/tests/script/general/parser/col_arithmetic_operation.sim b/tests/script/general/parser/col_arithmetic_operation.sim index 0cc02d088b..ae6ecb88e2 100644 --- a/tests/script/general/parser/col_arithmetic_operation.sim +++ b/tests/script/general/parser/col_arithmetic_operation.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect #========================================= setup environment ================================ diff --git a/tests/script/general/parser/columnValue.sim b/tests/script/general/parser/columnValue.sim index 2c03a3552a..4e6c664004 100644 --- a/tests/script/general/parser/columnValue.sim +++ b/tests/script/general/parser/columnValue.sim @@ -3,9 +3,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 3 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ========== columnValues.sim @@ -21,6 +20,7 @@ run general/parser/columnValue_int.sim run general/parser/columnValue_bigint.sim run general/parser/columnValue_float.sim run general/parser/columnValue_double.sim +run general/parser/columnValue_unsign.sim system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/parser/columnValue_bigint.sim b/tests/script/general/parser/columnValue_bigint.sim index 3546ca15ee..0d89d9e61c 100644 --- a/tests/script/general/parser/columnValue_bigint.sim +++ b/tests/script/general/parser/columnValue_bigint.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect sql create database if not exists db sql use db @@ -374,9 +374,9 @@ endi ## case 04: illegal input ################## when overflow, auto set max -sql create table st_bigint_e0 using mt_bigint tags (9223372036854775808) +sql_error create table st_bigint_e0 using mt_bigint tags (9223372036854775808) sql_error create table st_bigint_e0_1 using mt_bigint tags (-9223372036854775808) -sql create table st_bigint_e0_2 using mt_bigint tags (92233720368547758080) +sql_error create table st_bigint_e0_2 using mt_bigint tags (92233720368547758080) sql_error create table st_bigint_e0_3 using mt_bigint tags (-9223372036854775809) #sql_error create table st_bigint_e0 using mt_bigint tags (12.80) truncate integer part #sql_error create table st_bigint_e0 using mt_bigint tags (-11.80) diff --git a/tests/script/general/parser/columnValue_bool.sim b/tests/script/general/parser/columnValue_bool.sim index d68f375900..3a7dcab265 100644 --- a/tests/script/general/parser/columnValue_bool.sim +++ b/tests/script/general/parser/columnValue_bool.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect sql create database if not exists db sql use db diff --git a/tests/script/general/parser/columnValue_double.sim b/tests/script/general/parser/columnValue_double.sim index fd2da37838..e5ba89158b 100644 --- a/tests/script/general/parser/columnValue_double.sim +++ b/tests/script/general/parser/columnValue_double.sim @@ -1,5 +1,5 @@ #### -sleep 500 +sleep 100 sql connect sql create database if not exists db sql use db diff --git a/tests/script/general/parser/columnValue_float.sim b/tests/script/general/parser/columnValue_float.sim index 019cf176d0..c7008d0b13 100644 --- a/tests/script/general/parser/columnValue_float.sim +++ b/tests/script/general/parser/columnValue_float.sim @@ -1,5 +1,5 @@ #### -sleep 500 +sleep 100 sql connect sql create database if not exists db sql use db @@ -211,23 +211,28 @@ if $data01 != NULL then return -1 endi -sql insert into st_float_6 values (now, 3.40282347e+38) +sql_error insert into st_float_6 values (now, 3.40282347e+38) +sql_error insert into st_float_6 values (now, -3.40282347e+38) + +sql insert into st_float_6 values(now, 340282346638528859811704183484516925440.00000) sql select * from st_float_6 if $rows != 1 then return -1 endi -#if $data01 != 340282346638528859811704183484516925440.00000 then -# print ==== data01:$data01, expect:340282346638528859811704183484516925440.00000 -# return -1 -#endi -sql insert into st_float_7 values (now, -3.40282347e+38) + +if $data01 != 340282346638528859811704183484516925440.00000 then + print ==== data01:$data01, expect:340282346638528859811704183484516925440.00000 + return -1 +endi +sql insert into st_float_7 values (now, -340282346638528859811704183484516925440.00000) sql select * from st_float_7 if $rows != 1 then return -1 endi -#if $data01 != -340282346638528859811704183484516925440.00000 then -# return -1 -#endi +if $data01 != -340282346638528859811704183484516925440.00000 then + return -1 +endi + sql insert into st_float_8 values (now, +100.89) sql select * from st_float_8 if $rows != 1 then @@ -343,111 +348,119 @@ sql select * from st_float_21 if $data01 != NULL then return -1 endi -sql insert into st_float_22 using mt_float tags (127) values (now, 3.40282347e+38) + +sql_error insert into st_float_22 using mt_float tags (127) values (now, 3.40282347e+38) + +sql insert into st_float_22 using mt_float tags (127) values (now, 340282346638528859811704183484516925440.00000) sql select tagname from st_float_22 -#if $data00 != 127 then -# return -1 -#endi -sql select * from st_float_22 -#if $data01 != 127 then -# return -1 -#endi -sql insert into st_float_23 using mt_float tags (-127) values (now, -3.40282347e+38) +if $data00 != 127.00000 then + print expect 127.00000, actual: $data00 + return -1 +endi + +sql select tbname, tagname from st_float_22 +if $data01 != 127.00000 then + return -1 +endi + +sql insert into st_float_23 using mt_float tags (-127) values (now, -340282346638528859811704183484516925440.00000) sql select tagname from st_float_23 -#if $data00 != -127 then -# return -1 -#endi -sql select * from st_float_23 -#if $data01 != -127 then -# return -1 -#endi +if $data00 != -127.00000 then + return -1 +endi + sql insert into st_float_24 using mt_float tags (10) values (now, 10) sql select tagname from st_float_24 -#if $data00 != 10 then -# return -1 -#endi +if $data00 != 10.00000 then + return -1 +endi sql select * from st_float_24 -#if $data01 != 10 then -# return -1 -#endi +if $data01 != 10.00000 then + return -1 +endi + sql insert into st_float_25 using mt_float tags ("-0") values (now, "-0") sql select tagname from st_float_25 -#if $data00 != 0 then -# return -1 -#endi +if $data00 != -0.00000 then + print expect -0.00000, actual: $data00 + return -1 +endi sql select * from st_float_25 -#if $data01 != 0 then -# return -1 -#endi +if $data01 != -0.00000 then + return -1 +endi sql insert into st_float_26 using mt_float tags ('123') values (now, '12.3') sql select tagname from st_float_26 -#if $data00 != 123 then -# return -1 -#endi +if $data00 != 123.00000 then + print expect 123.00000, actual: $data00 + return -1 +endi sql select * from st_float_26 -#if $data01 != 123 then -# return -1 -#endi +if $data01 != 12.30000 then + return -1 +endi sql insert into st_float_27 using mt_float tags (+056) values (now, +0005.6) sql select tagname from st_float_27 -#if $data00 != 56 then -# return -1 -#endi +if $data00 != 56.00000 then + print expect 56.00000, actual:$data00 + return -1 +endi sql select * from st_float_27 -#if $data01 != 56 then -# return -1 -#endi +if $data01 != 5.60000 then + return -1 +endi sql insert into st_float_28 using mt_float tags (-056) values (now, -005.6) sql select tagname from st_float_28 -#if $data00 != -56 then -# return -1 -#endi +if $data00 != -56.00000 then + return -1 +endi sql select * from st_float_28 -#if $data01 != -56 then -# return -1 -#endi +if $data01 != -5.60000 then + return -1 +endi ### case 03: alter tag values -#sql alter table st_float_0 set tag tagname=3.40282347e+38 -#sql select tagname from st_float_0 -##if $data00 != 127 then -## return -1 -##endi -#sql alter table st_float_0 set tag tagname=-3.40282347e+38 -#sql select tagname from st_float_0 -##if $data00 != -127 then -## return -1 -##endi -#sql alter table st_float_0 set tag tagname=+10.340 -#sql select tagname from st_float_0 -##if $data00 != 100 then -## return -1 -##endi -#sql alter table st_float_0 set tag tagname=-33.87 -#sql select tagname from st_float_0 -##if $data00 != -33 then -## return -1 -##endi -#sql alter table st_float_0 set tag tagname='+9.8' -#sql select tagname from st_float_0 -##if $data00 != 98 then -## return -1 -##endi -#sql alter table st_float_0 set tag tagname='-07.6' -#sql select tagname from st_float_0 -##if $data00 != -76 then -## return -1 -##endi -#sql alter table st_float_0 set tag tagname=+0012.871 -#sql select tagname from st_float_0 -##if $data00 != 12 then -## return -1 -##endi -#sql alter table st_float_0 set tag tagname=-00063.582 -#sql select tagname from st_float_0 -##if $data00 != -63 then -## return -1 -##endi +sql alter table st_float_0 set tag tagname=340282346638528859811704183484516925440.00000 +sql select tagname from st_float_0 +if $data00 != 340282346638528859811704183484516925440.00000 then + return -1 +endi + +sql alter table st_float_0 set tag tagname=-340282346638528859811704183484516925440.00000 +sql select tagname from st_float_0 +if $data00 != -340282346638528859811704183484516925440.00000 then + return -1 +endi +sql alter table st_float_0 set tag tagname=+10.340 +sql select tagname from st_float_0 +if $data00 != 10.34000 then + return -1 +endi +sql alter table st_float_0 set tag tagname=-33.87 +sql select tagname from st_float_0 +if $data00 != -33.87000 then + return -1 +endi +sql alter table st_float_0 set tag tagname='+9.8' +sql select tagname from st_float_0 +if $data00 != 9.80000 then + return -1 +endi +sql alter table st_float_0 set tag tagname='-07.6' +sql select tagname from st_float_0 +if $data00 != -7.60000 then + return -1 +endi +sql alter table st_float_0 set tag tagname=+0012.871 +sql select tagname from st_float_0 +if $data00 != 12.87100 then + return -1 +endi +sql alter table st_float_0 set tag tagname=-00063.582 +sql select tagname from st_float_0 +if $data00 != -63.58200 then + return -1 +endi ## case 04: illegal input sql_error create table st_float_e0 using mt_float tags (3.50282347e+38) diff --git a/tests/script/general/parser/columnValue_int.sim b/tests/script/general/parser/columnValue_int.sim index 1f84df5ca0..5536293ed2 100644 --- a/tests/script/general/parser/columnValue_int.sim +++ b/tests/script/general/parser/columnValue_int.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect sql create database if not exists db sql use db diff --git a/tests/script/general/parser/columnValue_smallint.sim b/tests/script/general/parser/columnValue_smallint.sim index af5c581871..98b83fd0e1 100644 --- a/tests/script/general/parser/columnValue_smallint.sim +++ b/tests/script/general/parser/columnValue_smallint.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect sql create database if not exists db sql use db diff --git a/tests/script/general/parser/columnValue_tinyint.sim b/tests/script/general/parser/columnValue_tinyint.sim index 3efe52cc91..7b0cad23df 100644 --- a/tests/script/general/parser/columnValue_tinyint.sim +++ b/tests/script/general/parser/columnValue_tinyint.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect sql create database if not exists db sql use db diff --git a/tests/script/general/parser/columnValue_unsign.sim b/tests/script/general/parser/columnValue_unsign.sim new file mode 100644 index 0000000000..895b13961e --- /dev/null +++ b/tests/script/general/parser/columnValue_unsign.sim @@ -0,0 +1,175 @@ +sleep 100 +sql connect +sql create database if not exists db +sql use db + +sql drop table if exists mt_unsigned; + +sql create table mt_unsigned (ts timestamp, a tinyint unsigned, b smallint unsigned, c int unsigned, d bigint unsigned, e tinyint, f smallint, g int, h bigint, j bool) tags (t1 tinyint unsigned, t2 smallint unsigned, t3 int unsigned, t4 bigint unsigned, t5 tinyint, t6 smallint, t7 int, t8 bigint); +sql create table mt_unsigned_1 using mt_unsigned tags(0, 0, 0, 0, 0, 0, 0, 0); + +sql alter table mt_unsigned_1 set tag t1=138; +sql alter table mt_unsigned_1 set tag t2=32769; +sql alter table mt_unsigned_1 set tag t3=294967295; +sql alter table mt_unsigned_1 set tag t4=446744073709551615; +sql select t1,t2,t3,t4 from mt_unsigned_1 +if $rows != 1 then + return -1 +endi + +print $data00, $data01, $data02, $data03 + +if $data00 != 138 then + print expect 138, actual: $data00 + return -1 +endi + +if $data01 != 32769 then +return -1 +endi + +if $data02 != 294967295 then +return -1 +endi + +if $data03 != 446744073709551615 then +return -1 +endi + +sql_error sql alter table mt_unsigned_1 set tag t1 = 999; +sql_error sql alter table mt_unsigned_1 set tag t2 = 95535; +sql_error sql alter table mt_unsigned_1 set tag t3 = 8294967295l; +sql_error sql alter table mt_unsigned_1 set tag t4 = 19446744073709551615; + +sql_error create table mt_unsigned_2 using mt_unsigned tags(-1, 0, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_3 using mt_unsigned tags(0, -1, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, -1, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, -1, 0, 0, 0, 0); + +sql_error create table mt_unsigned_2 using mt_unsigned tags(255, 0, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_3 using mt_unsigned tags(0, 65535, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, 4294967295, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, 18446744073709551615, 0, 0, 0, 0); + +sql_error create table mt_unsigned_2 using mt_unsigned tags(999, 0, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_3 using mt_unsigned tags(0, 95535, 0, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_4 using mt_unsigned tags(0, 0, 5294967295l, 0, 0, 0, 0, 0); +sql_error create table mt_unsigned_5 using mt_unsigned tags(0, 0, 0, 28446744073709551615u, 0, 0, 0, 0); + +sql alter table mt_unsigned_1 set tag t1=NULL; +sql alter table mt_unsigned_1 set tag t2=NULL; +sql alter table mt_unsigned_1 set tag t3=NULL; +sql alter table mt_unsigned_1 set tag t4=NULL; +sql select t1,t2,t3,t4 from mt_unsigned_1 +if $rows != 1 then + return -1; +endi + +if $data00 != NULL then + print expect NULL, actual: $data00 + return -1 +endi + +if $data01 != NULL then + return -1 +endi + +if $data02 != NULL then + return -1 +endi + +if $data03 != NULL then + return -1 +endi + +sql insert into mt_unsigned_1 values(now, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql insert into mt_unsigned_1 values(now, 1, 2, 3, 4, 5, 6, 7, 8, 9); + +sql_error insert into mt_unsigned_1 values(now, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, NULL, NULL, -1, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, 255, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, 65535, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, NULL, 4294967295, NULL, NULL, NULL, NULL, NULL, NULL); +sql_error insert into mt_unsigned_1 values(now, NULL, NULL, NULL, 18446744073709551615, NULL, NULL, NULL, NULL, NULL); +sql select count(a),count(b),count(c),count(d), count(e) from mt_unsigned_1 +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +sql select a+b+c from mt_unsigned_1 where a is null; +if $rows != 1 then + return -1 +endi + +if $data00 != 6.000000000 then + return -1 +endi + +sql select count(*), a from mt_unsigned_1 group by a; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 1 then + return -1 +endi + +sql select count(*), b from mt_unsigned_1 group by b; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 2 then + return -1 +endi + +sql select count(*), c from mt_unsigned_1 group by c; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 3 then + return -1 +endi + +sql select count(*), d from mt_unsigned_1 group by d; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data01 != 4 then + return -1 +endi + +// todo insert more rows and chec it +sql select first(a),count(b),last(c),sum(b),spread(d),avg(c),min(b),max(a),stddev(a) from mt_unsigned_1; +if $rows != 1 then + return -1 +endi + diff --git a/tests/script/general/parser/commit.sim b/tests/script/general/parser/commit.sim index c798bf9d7c..67d98de207 100644 --- a/tests/script/general/parser/commit.sim +++ b/tests/script/general/parser/commit.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxTablesperVnode -v 100 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = sc_db @@ -84,10 +84,10 @@ print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 print ================== server restart completed sql connect -sleep 500 +sleep 100 print ====== select from table and check num of rows returned sql use $db diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim index 3b7f24b6d9..6cf08a5ac4 100644 --- a/tests/script/general/parser/create_db.sim +++ b/tests/script/general/parser/create_db.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ======================== dnode1 start diff --git a/tests/script/general/parser/create_mt.sim b/tests/script/general/parser/create_mt.sim index e11f322761..9278fbfba4 100644 --- a/tests/script/general/parser/create_mt.sim +++ b/tests/script/general/parser/create_mt.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ======================== dnode1 start diff --git a/tests/script/general/parser/create_tb.sim b/tests/script/general/parser/create_tb.sim index 609aad2adb..48b7a0fb19 100644 --- a/tests/script/general/parser/create_tb.sim +++ b/tests/script/general/parser/create_tb.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ======================== dnode1 start diff --git a/tests/script/general/parser/dbtbnameValidate.sim b/tests/script/general/parser/dbtbnameValidate.sim index fd40ecc3f7..072fd740d4 100644 --- a/tests/script/general/parser/dbtbnameValidate.sim +++ b/tests/script/general/parser/dbtbnameValidate.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ========== db name and table name check in create and drop, describe diff --git a/tests/script/general/parser/fill.sim b/tests/script/general/parser/fill.sim index 405a805312..aac79e1a3c 100644 --- a/tests/script/general/parser/fill.sim +++ b/tests/script/general/parser/fill.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = m_fl_db diff --git a/tests/script/general/parser/fill_stb.sim b/tests/script/general/parser/fill_stb.sim index 83eb98c465..a9547b8a94 100644 --- a/tests/script/general/parser/fill_stb.sim +++ b/tests/script/general/parser/fill_stb.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = fl1_db diff --git a/tests/script/general/parser/fill_us.sim b/tests/script/general/parser/fill_us.sim index dc8ee8659d..a429df059b 100644 --- a/tests/script/general/parser/fill_us.sim +++ b/tests/script/general/parser/fill_us.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = m_fl_db diff --git a/tests/script/general/parser/first_last.sim b/tests/script/general/parser/first_last.sim index df9a4598e0..a16b5b1e07 100644 --- a/tests/script/general/parser/first_last.sim +++ b/tests/script/general/parser/first_last.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxTablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = first_db @@ -81,7 +81,7 @@ sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 run general/parser/first_last_query.sim @@ -110,7 +110,7 @@ sleep 1000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 sql use test sql select count(*), last(ts) from tm0 interval(1s) diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim index 9537b417f3..2d08759f3f 100644 --- a/tests/script/general/parser/first_last_query.sim +++ b/tests/script/general/parser/first_last_query.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = first_db diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim index a358ca7fce..7d702e989e 100644 --- a/tests/script/general/parser/function.sim +++ b/tests/script/general/parser/function.sim @@ -2,9 +2,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 3 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = m_func_db @@ -228,7 +227,7 @@ sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts< sql select twa(k),avg(k),count(1) from t1 where ts>='2015-8-18 00:00:00' and ts<='2015-8-18 00:30:00' interval(10m) order by ts desc -#todo add test case while column filter exists. +#todo add test case while column filter exists for twa query #sql select count(*),TWA(k) from tm0 where ts>='1970-1-1 13:43:00' and ts<='1970-1-1 13:44:10' interval(9s) @@ -274,7 +273,7 @@ sleep 1000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 sql use m_func_db0 @@ -373,3 +372,14 @@ sql select twa(k) from tm2 where ts='2020-12-29 18:46:19.109' if $rows != 0 then return -1 endi + +print ========================> TD-1787 +sql create table cars(ts timestamp, c int) tags(id int); +sql create table car1 using cars tags(1); +sql create table car2 using cars tags(2); +sql insert into car1 (ts, c) values (now,1) car2(ts, c) values(now, 2); +sql drop table cars; +sql create table cars(ts timestamp, c int) tags(id int); +sql create table car1 using cars tags(1); +sql create table car2 using cars tags(2); +sql insert into car1 (ts, c) values (now,1) car2(ts, c) values(now, 2); \ No newline at end of file diff --git a/tests/script/general/parser/groupby.sim b/tests/script/general/parser/groupby.sim index 606ad444d1..19b14e327c 100644 --- a/tests/script/general/parser/groupby.sim +++ b/tests/script/general/parser/groupby.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = group_db diff --git a/tests/script/general/parser/import.sim b/tests/script/general/parser/import.sim index 6da2483738..83751dc616 100644 --- a/tests/script/general/parser/import.sim +++ b/tests/script/general/parser/import.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = impt_db @@ -64,7 +64,7 @@ sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 sql use $db sql select * from tb diff --git a/tests/script/general/parser/import_commit1.sim b/tests/script/general/parser/import_commit1.sim index 9c5144a630..eb49be947c 100644 --- a/tests/script/general/parser/import_commit1.sim +++ b/tests/script/general/parser/import_commit1.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c ctime -v 30 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = ic_db diff --git a/tests/script/general/parser/import_commit2.sim b/tests/script/general/parser/import_commit2.sim index 000394386e..7222a5412b 100644 --- a/tests/script/general/parser/import_commit2.sim +++ b/tests/script/general/parser/import_commit2.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c ctime -v 30 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = ic_db diff --git a/tests/script/general/parser/import_commit3.sim b/tests/script/general/parser/import_commit3.sim index 997a4a22aa..ea9980930a 100644 --- a/tests/script/general/parser/import_commit3.sim +++ b/tests/script/general/parser/import_commit3.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c ctime -v 30 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = ic_db diff --git a/tests/script/general/parser/insert_multiTbl.sim b/tests/script/general/parser/insert_multiTbl.sim index 887f97a198..39223d84e3 100644 --- a/tests/script/general/parser/insert_multiTbl.sim +++ b/tests/script/general/parser/insert_multiTbl.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start sleep 2000 sql connect -sleep 500 +sleep 100 print ======================== dnode1 start sql create database mul_db diff --git a/tests/script/general/parser/insert_tb.sim b/tests/script/general/parser/insert_tb.sim index 0a9eb9f678..f212325f26 100644 --- a/tests/script/general/parser/insert_tb.sim +++ b/tests/script/general/parser/insert_tb.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ======================== dnode1 start @@ -103,7 +103,7 @@ if $rows != 1 then endi sql drop database $db -sleep 500 +sleep 100 sql create database $db sql use $db sql create table stb1 (ts timestamp, c1 int) tags(t1 int) @@ -136,7 +136,7 @@ if $data21 != 1.000000000 then endi sql drop database $db -sleep 500 +sleep 100 sql create database $db sql use $db sql create table stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 nchar(10), c6 binary(20)) tags(t1 int, t2 bigint, t3 double, t4 float, t5 nchar(10)) diff --git a/tests/script/general/parser/interp.sim b/tests/script/general/parser/interp.sim index 0d5c1804dd..4078fc1ead 100644 --- a/tests/script/general/parser/interp.sim +++ b/tests/script/general/parser/interp.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = intp_db diff --git a/tests/script/general/parser/interp_test.sim b/tests/script/general/parser/interp_test.sim index 42738a8bd1..819e5741d3 100644 --- a/tests/script/general/parser/interp_test.sim +++ b/tests/script/general/parser/interp_test.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = intp_db diff --git a/tests/script/general/parser/join.sim b/tests/script/general/parser/join.sim index 3ee90cda35..d18a3d7676 100644 --- a/tests/script/general/parser/join.sim +++ b/tests/script/general/parser/join.sim @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = join_db diff --git a/tests/script/general/parser/join_multivnode.sim b/tests/script/general/parser/join_multivnode.sim index 1c901dd2e3..9d7cdfe3d7 100644 --- a/tests/script/general/parser/join_multivnode.sim +++ b/tests/script/general/parser/join_multivnode.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start sql connect -sleep 500 +sleep 100 $dbPrefix = join_m_db $tbPrefix = join_tb diff --git a/tests/script/general/parser/lastrow.sim b/tests/script/general/parser/lastrow.sim index cc71123a77..f997dc504f 100644 --- a/tests/script/general/parser/lastrow.sim +++ b/tests/script/general/parser/lastrow.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = lr_db @@ -66,7 +66,7 @@ sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 run general/parser/lastrow_query.sim diff --git a/tests/script/general/parser/lastrow_query.sim b/tests/script/general/parser/lastrow_query.sim index 5b9c8b60c3..a87b3cc646 100644 --- a/tests/script/general/parser/lastrow_query.sim +++ b/tests/script/general/parser/lastrow_query.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = lr_db diff --git a/tests/script/general/parser/limit.sim b/tests/script/general/parser/limit.sim index 2089cd3d2a..682b449ca3 100644 --- a/tests/script/general/parser/limit.sim +++ b/tests/script/general/parser/limit.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = lm_db @@ -70,7 +70,7 @@ sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 run general/parser/limit_tb.sim run general/parser/limit_stb.sim diff --git a/tests/script/general/parser/limit1.sim b/tests/script/general/parser/limit1.sim index 7236421ec2..c047dc2844 100644 --- a/tests/script/general/parser/limit1.sim +++ b/tests/script/general/parser/limit1.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = lm1_db diff --git a/tests/script/general/parser/limit1_stb.sim b/tests/script/general/parser/limit1_stb.sim index 7d61a826aa..a0e3a45d2f 100644 --- a/tests/script/general/parser/limit1_stb.sim +++ b/tests/script/general/parser/limit1_stb.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = lm1_db diff --git a/tests/script/general/parser/limit1_tb.sim b/tests/script/general/parser/limit1_tb.sim index 72b63256db..300af7ac7b 100644 --- a/tests/script/general/parser/limit1_tb.sim +++ b/tests/script/general/parser/limit1_tb.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = lm1_db diff --git a/tests/script/general/parser/limit1_tblocks100.sim b/tests/script/general/parser/limit1_tblocks100.sim index 9a123e645c..039a171ad7 100644 --- a/tests/script/general/parser/limit1_tblocks100.sim +++ b/tests/script/general/parser/limit1_tblocks100.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = lm1_db diff --git a/tests/script/general/parser/limit2.sim b/tests/script/general/parser/limit2.sim index 47c3eb6d08..f9b46f5c3e 100644 --- a/tests/script/general/parser/limit2.sim +++ b/tests/script/general/parser/limit2.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c rowsInFileBlock -v 255 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = lm2_db diff --git a/tests/script/general/parser/limit2_query.sim b/tests/script/general/parser/limit2_query.sim index f9a1dd8e4b..1e8077d26e 100644 --- a/tests/script/general/parser/limit2_query.sim +++ b/tests/script/general/parser/limit2_query.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = lm2_db diff --git a/tests/script/general/parser/limit2_tblocks100.sim b/tests/script/general/parser/limit2_tblocks100.sim index 1aaa8e885a..19cea74e70 100644 --- a/tests/script/general/parser/limit2_tblocks100.sim +++ b/tests/script/general/parser/limit2_tblocks100.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c rowsInFileBlock -v 255 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = lm2_db @@ -69,7 +69,7 @@ print ====== tables created print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 500 +sleep 100 system sh/exec.sh -n dnode1 -s start print ================== server restart completed diff --git a/tests/script/general/parser/limit_stb.sim b/tests/script/general/parser/limit_stb.sim index d929810817..ec7c0e0f13 100644 --- a/tests/script/general/parser/limit_stb.sim +++ b/tests/script/general/parser/limit_stb.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = lm_db diff --git a/tests/script/general/parser/limit_tb.sim b/tests/script/general/parser/limit_tb.sim index 45f5541208..0c987d88c9 100644 --- a/tests/script/general/parser/limit_tb.sim +++ b/tests/script/general/parser/limit_tb.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = lm_db diff --git a/tests/script/general/parser/mixed_blocks.sim b/tests/script/general/parser/mixed_blocks.sim index 946dbe8835..772dc1db59 100644 --- a/tests/script/general/parser/mixed_blocks.sim +++ b/tests/script/general/parser/mixed_blocks.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = mb_db diff --git a/tests/script/general/parser/nchar.sim b/tests/script/general/parser/nchar.sim index ab4ed2607a..3dcfca7503 100644 --- a/tests/script/general/parser/nchar.sim +++ b/tests/script/general/parser/nchar.sim @@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ======================== dnode1 start diff --git a/tests/script/general/parser/null_char.sim b/tests/script/general/parser/null_char.sim index 7b1c81a295..4e7c8ab354 100644 --- a/tests/script/general/parser/null_char.sim +++ b/tests/script/general/parser/null_char.sim @@ -3,10 +3,9 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 3 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect print ========== NULL_char.sim @@ -251,7 +250,7 @@ endi ################### nchar sql alter table st41 set tag tag_nchar = "��˼����" sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 -#sleep 500 +#sleep 100 #if $data01 != ��˼���� then # print ==== expect ��˼����, actually $data01 # return -1 @@ -451,11 +450,8 @@ sql select tag_bigint, tag_smallint, tag_tinyint from st51 if $data00 != 9223372036854775807 then return -1 endi -sql alter table st51 set tag tag_bigint = 9223372036854775808 -sql select tag_bigint, tag_smallint, tag_tinyint from st51 -if $data00 != 9223372036854775807 then - return -1 -endi +sql_error alter table st51 set tag tag_bigint = 9223372036854775808 + sql alter table st51 set tag tag_bigint = -9223372036854775807 sql select tag_bigint, tag_smallint, tag_tinyint from st51 if $data00 != -9223372036854775807 then diff --git a/tests/script/general/parser/projection_limit_offset.sim b/tests/script/general/parser/projection_limit_offset.sim index fc2ce16123..df5be140f6 100644 --- a/tests/script/general/parser/projection_limit_offset.sim +++ b/tests/script/general/parser/projection_limit_offset.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = group_db diff --git a/tests/script/general/parser/selectResNum.sim b/tests/script/general/parser/selectResNum.sim index 464f363222..071dd87bc9 100644 --- a/tests/script/general/parser/selectResNum.sim +++ b/tests/script/general/parser/selectResNum.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 200 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = sc_db @@ -121,9 +121,9 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 3000 system sh/exec.sh -n dnode1 -s start print ====== server restart completed -sleep 500 +sleep 100 sql connect -sleep 500 +sleep 100 sql use $db ##### repeat test after server restart diff --git a/tests/script/general/parser/select_across_vnodes.sim b/tests/script/general/parser/select_across_vnodes.sim index 44e5576dac..6c473a35d1 100644 --- a/tests/script/general/parser/select_across_vnodes.sim +++ b/tests/script/general/parser/select_across_vnodes.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = sav_db diff --git a/tests/script/general/parser/select_from_cache_disk.sim b/tests/script/general/parser/select_from_cache_disk.sim index 0fa0848144..5feae91905 100644 --- a/tests/script/general/parser/select_from_cache_disk.sim +++ b/tests/script/general/parser/select_from_cache_disk.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = scd_db @@ -39,7 +39,7 @@ sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 sql use $db # generate some data in cache diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim index c254d31ffc..5428f98593 100644 --- a/tests/script/general/parser/select_with_tags.sim +++ b/tests/script/general/parser/select_with_tags.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = select_tags_db diff --git a/tests/script/general/parser/set_tag_vals.sim b/tests/script/general/parser/set_tag_vals.sim index bf29fe3902..0b8ffd946f 100644 --- a/tests/script/general/parser/set_tag_vals.sim +++ b/tests/script/general/parser/set_tag_vals.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = db diff --git a/tests/script/general/parser/single_row_in_tb.sim b/tests/script/general/parser/single_row_in_tb.sim index fe1edb1f73..6f1535c390 100644 --- a/tests/script/general/parser/single_row_in_tb.sim +++ b/tests/script/general/parser/single_row_in_tb.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = sr_db diff --git a/tests/script/general/parser/single_row_in_tb_query.sim b/tests/script/general/parser/single_row_in_tb_query.sim index 9e90b91220..1f9cb8b558 100644 --- a/tests/script/general/parser/single_row_in_tb_query.sim +++ b/tests/script/general/parser/single_row_in_tb_query.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = sr_db diff --git a/tests/script/general/parser/sliding.sim b/tests/script/general/parser/sliding.sim index 4283421169..be33c905a1 100644 --- a/tests/script/general/parser/sliding.sim +++ b/tests/script/general/parser/sliding.sim @@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c debugFlag -v 135 system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = sliding_db diff --git a/tests/script/general/parser/slimit.sim b/tests/script/general/parser/slimit.sim index f7a23019cf..9aaf4a35ca 100644 --- a/tests/script/general/parser/slimit.sim +++ b/tests/script/general/parser/slimit.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = slm_db @@ -101,7 +101,7 @@ sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 run general/parser/slimit_query.sim diff --git a/tests/script/general/parser/slimit1.sim b/tests/script/general/parser/slimit1.sim index 7a2511eb76..2c8fa28d32 100644 --- a/tests/script/general/parser/slimit1.sim +++ b/tests/script/general/parser/slimit1.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = slm_alt_tg_db @@ -60,7 +60,7 @@ sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 run general/parser/slimit1_query.sim diff --git a/tests/script/general/parser/slimit1_query.sim b/tests/script/general/parser/slimit1_query.sim index c205d45689..8e3a61bee6 100644 --- a/tests/script/general/parser/slimit1_query.sim +++ b/tests/script/general/parser/slimit1_query.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = slm_alt_tg_db diff --git a/tests/script/general/parser/slimit_alter_tags.sim b/tests/script/general/parser/slimit_alter_tags.sim index 1072f9ccb4..3fe40dbe2e 100644 --- a/tests/script/general/parser/slimit_alter_tags.sim +++ b/tests/script/general/parser/slimit_alter_tags.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = slm_alt_tg_db @@ -175,7 +175,7 @@ sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 sql use $db ### repeat above queries diff --git a/tests/script/general/parser/slimit_query.sim b/tests/script/general/parser/slimit_query.sim index 3020f80472..0a793f0611 100644 --- a/tests/script/general/parser/slimit_query.sim +++ b/tests/script/general/parser/slimit_query.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = slm_db diff --git a/tests/script/general/parser/tags_dynamically_specifiy.sim b/tests/script/general/parser/tags_dynamically_specifiy.sim index 8303a9c86d..87b278da09 100644 --- a/tests/script/general/parser/tags_dynamically_specifiy.sim +++ b/tests/script/general/parser/tags_dynamically_specifiy.sim @@ -3,9 +3,9 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect -sleep 500 +sleep 100 $db = dytag_db $tbNum = 10 diff --git a/tests/script/general/parser/tags_filter.sim b/tests/script/general/parser/tags_filter.sim index d775815828..f0ac3bdcba 100644 --- a/tests/script/general/parser/tags_filter.sim +++ b/tests/script/general/parser/tags_filter.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $db = tf_db diff --git a/tests/script/general/parser/tbnameIn.sim b/tests/script/general/parser/tbnameIn.sim index d0f74ae53d..e1d200e716 100644 --- a/tests/script/general/parser/tbnameIn.sim +++ b/tests/script/general/parser/tbnameIn.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = ti_db diff --git a/tests/script/general/parser/tbnameIn_query.sim b/tests/script/general/parser/tbnameIn_query.sim index ad7456f557..65bb89d549 100644 --- a/tests/script/general/parser/tbnameIn_query.sim +++ b/tests/script/general/parser/tbnameIn_query.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = ti_db diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim index cddd28817e..2d77cb15d2 100644 --- a/tests/script/general/parser/testSuite.sim +++ b/tests/script/general/parser/testSuite.sim @@ -1,107 +1,107 @@ #run general/parser/alter.sim -#sleep 500 +#sleep 100 #run general/parser/alter1.sim -#sleep 500 +#sleep 100 #run general/parser/alter_stable.sim -#sleep 500 +#sleep 100 #run general/parser/auto_create_tb.sim -#sleep 500 +#sleep 100 #run general/parser/auto_create_tb_drop_tb.sim -#sleep 500 +#sleep 100 #run general/parser/col_arithmetic_operation.sim -#sleep 500 +#sleep 100 #run general/parser/columnValue.sim -#sleep 500 +#sleep 100 #run general/parser/commit.sim -#sleep 500 +#sleep 100 #run general/parser/create_db.sim -#sleep 500 +#sleep 100 #run general/parser/create_mt.sim -#sleep 500 +#sleep 100 #run general/parser/create_tb.sim -#sleep 500 +#sleep 100 #run general/parser/dbtbnameValidate.sim -#sleep 500 +#sleep 100 #run general/parser/fill.sim -#sleep 500 +#sleep 100 #run general/parser/fill_stb.sim -#sleep 500 +#sleep 100 ##run general/parser/fill_us.sim # -#sleep 500 +#sleep 100 #run general/parser/first_last.sim -#sleep 500 +#sleep 100 #run general/parser/import_commit1.sim -#sleep 500 +#sleep 100 #run general/parser/import_commit2.sim -#sleep 500 +#sleep 100 #run general/parser/import_commit3.sim -#sleep 500 +#sleep 100 ##run general/parser/import_file.sim -#sleep 500 +#sleep 100 #run general/parser/insert_tb.sim -#sleep 500 +#sleep 100 #run general/parser/tags_dynamically_specifiy.sim -#sleep 500 +#sleep 100 #run general/parser/interp.sim -#sleep 500 +#sleep 100 #run general/parser/lastrow.sim -sleep 500 -run general/parser/limit.sim -sleep 500 -run general/parser/limit1.sim -sleep 500 -run general/parser/limit1_tblocks100.sim -sleep 500 -run general/parser/limit2.sim -sleep 500 -run general/parser/mixed_blocks.sim -sleep 500 -run general/parser/nchar.sim -sleep 500 -run general/parser/null_char.sim -sleep 500 +#sleep 100 +#run general/parser/limit.sim +#sleep 100 +#run general/parser/limit1.sim +#sleep 100 +#run general/parser/limit1_tblocks100.sim +#sleep 100 +#run general/parser/limit2.sim +#sleep 100 +#run general/parser/mixed_blocks.sim +#sleep 100 +#run general/parser/nchar.sim +#sleep 100 +#run general/parser/null_char.sim +sleep 100 run general/parser/selectResNum.sim -sleep 500 +sleep 100 run general/parser/select_across_vnodes.sim -sleep 500 +sleep 100 run general/parser/select_from_cache_disk.sim -sleep 500 +sleep 100 run general/parser/set_tag_vals.sim -sleep 500 +sleep 100 run general/parser/single_row_in_tb.sim -sleep 500 +sleep 100 run general/parser/slimit.sim -sleep 500 +sleep 100 run general/parser/slimit1.sim -sleep 500 +sleep 100 run general/parser/slimit_alter_tags.sim -sleep 500 +sleep 100 run general/parser/tbnameIn.sim -sleep 500 +sleep 100 run general/parser/slimit_alter_tags.sim # persistent failed -sleep 500 +sleep 100 run general/parser/join.sim -sleep 500 +sleep 100 run general/parser/join_multivnode.sim -sleep 500 +sleep 100 run general/parser/projection_limit_offset.sim -sleep 500 +sleep 100 run general/parser/select_with_tags.sim -sleep 500 +sleep 100 run general/parser/groupby.sim -sleep 500 +sleep 100 run general/parser/tags_filter.sim -sleep 500 +sleep 100 run general/parser/topbot.sim -sleep 500 +sleep 100 run general/parser/union.sim -sleep 500 +sleep 100 run general/parser/constCol.sim -sleep 500 +sleep 100 run general/parser/where.sim -sleep 500 +sleep 100 run general/parser/timestamp.sim -sleep 500 +sleep 100 run general/parser/sliding.sim -sleep 500 +sleep 100 run general/parser/function.sim diff --git a/tests/script/general/parser/timestamp.sim b/tests/script/general/parser/timestamp.sim index 72966459d0..7d7362bcb5 100644 --- a/tests/script/general/parser/timestamp.sim +++ b/tests/script/general/parser/timestamp.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = ts_db @@ -59,10 +59,10 @@ run general/parser/timestamp_query.sim print ================== restart server to commit data into disk system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 500 +sleep 100 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 run general/parser/timestamp_query.sim diff --git a/tests/script/general/parser/timestamp_query.sim b/tests/script/general/parser/timestamp_query.sim index 056e8bba6b..4e553c73f4 100644 --- a/tests/script/general/parser/timestamp_query.sim +++ b/tests/script/general/parser/timestamp_query.sim @@ -1,4 +1,4 @@ -sleep 500 +sleep 100 sql connect $dbPrefix = ts_db diff --git a/tests/script/general/parser/topbot.sim b/tests/script/general/parser/topbot.sim index 08e2f6ab00..6188f42ff5 100644 --- a/tests/script/general/parser/topbot.sim +++ b/tests/script/general/parser/topbot.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 200 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = tb_db @@ -132,7 +132,7 @@ sleep 3000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed sql connect -sleep 500 +sleep 100 sql select count(*) from t1.test where ts>10000 and ts<90000 interval(5000a) if $rows != 3 then @@ -169,7 +169,7 @@ endw system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start sql connect -sleep 500 +sleep 100 sql use db; $ts = 1000 @@ -221,7 +221,7 @@ sql insert into t2 values('2020-2-2 1:1:1', 1); system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start sql connect -sleep 500 +sleep 100 sql use db sql select count(*), first(ts), last(ts) from t2 interval(1d); diff --git a/tests/script/general/parser/union.sim b/tests/script/general/parser/union.sim index cb46ac6b0d..1b184245c3 100644 --- a/tests/script/general/parser/union.sim +++ b/tests/script/general/parser/union.sim @@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = union_db @@ -103,7 +103,7 @@ while $i < $tbNum endw print sleep 1sec. -sleep 500 +sleep 100 $i = 1 $tb = $tbPrefix . $i diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim index c5b600b514..1f148cbb2c 100644 --- a/tests/script/general/parser/where.sim +++ b/tests/script/general/parser/where.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 system sh/exec.sh -n dnode1 -s start -sleep 500 +sleep 100 sql connect $dbPrefix = wh_db diff --git a/tests/script/general/stream/restart_stream.sim b/tests/script/general/stream/restart_stream.sim index 138e2a6e2e..b5a2038d9b 100644 --- a/tests/script/general/stream/restart_stream.sim +++ b/tests/script/general/stream/restart_stream.sim @@ -3,7 +3,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 1 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -98,7 +97,6 @@ print =============== step4 system sh/exec.sh -n dnode1 -s stop system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 1 system sh/exec.sh -n dnode1 -s start print =============== step5 diff --git a/tests/script/issue/TD-2677.sim b/tests/script/issue/TD-2677.sim new file mode 100644 index 0000000000..8d2058a385 --- /dev/null +++ b/tests/script/issue/TD-2677.sim @@ -0,0 +1,111 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 + +print ============== deploy + +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +print =============== step1 +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +$mnode1Role = $data2_1 +print mnode1Role $mnode1Role +$mnode2Role = $data2_2 +print mnode2Role $mnode2Role +$mnode3Role = $data2_3 +print mnode3Role $mnode3Role + +if $mnode1Role != master then + goto step1 +endi +if $mnode2Role != slave then + goto step1 +endi +if $mnode3Role != slave then + goto step1 +endi + +$x = 1 +show2: + +print =============== step1 +sql create database d1 replica 2 quorum 2 +sql create table d1.t1 (ts timestamp, i int) +sql_error create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) +sql select * from d1.t1; +if $rows != 1 then + return -1 +endi + +print =============== step2 +sql create database d2 replica 3 quorum 2 +sql create table d2.t1 (ts timestamp, i int) +sql_error create table d2.t1 (ts timestamp, i int) +sql insert into d2.t1 values(now, 1) +sql select * from d2.t1; +if $rows != 1 then + return -1 +endi + +print =============== step3 +sql create database d4 replica 1 quorum 1 +sql_error create database d5 replica 1 quorum 2 +sql_error create database d6 replica 1 quorum 3 +sql_error create database d7 replica 1 quorum 4 +sql_error create database d8 replica 1 quorum 0 +sql create database d9 replica 2 quorum 1 +sql create database d10 replica 2 quorum 2 +sql_error create database d11 replica 2 quorum 3 +sql_error create database d12 replica 2 quorum 4 +sql_error create database d12 replica 2 quorum 0 +sql create database d13 replica 3 quorum 1 +sql create database d14 replica 3 quorum 2 +sql_error create database d15 replica 3 quorum 3 +sql_error create database d16 replica 3 quorum 4 +sql_error create database d17 replica 3 quorum 0 + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/issue/TD-2680.sim b/tests/script/issue/TD-2680.sim new file mode 100644 index 0000000000..631332160f --- /dev/null +++ b/tests/script/issue/TD-2680.sim @@ -0,0 +1,202 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0 +system sh/exec_tarbitrator.sh -s start + +print ============== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi + +print ============== step2 +sql show dnodes +if $rows != 4 then + return -1 +endi + +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 +print $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 + +if $data30 != 0 then + return -1 +endi + +if $data32 != 0 then + return -1 +endi + +if $data33 != 0 then + return -1 +endi + +if $data34 != ready then + return -1 +endi + +if $data35 != arb then + return -1 +endi + +if $data37 != - then + return -1 +endi + +print ============== step4 +system sh/exec_tarbitrator.sh -s stop + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +if $rows != 4 then + return -1 +endi + +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 +print $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 + +if $data30 != 0 then + return -1 +endi + +if $data32 != 0 then + return -1 +endi + +if $data33 != 0 then + return -1 +endi + +if $data34 != offline then + goto step4 +endi + +if $data35 != arb then + return -1 +endi + +if $data37 != - then + return -1 +endi + +print ============== step5 +system sh/exec_tarbitrator.sh -s start + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 20 then + return -1 + endi + +sql show dnodes +if $rows != 4 then + return -1 +endi + +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 +print $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 + +if $data30 != 0 then + return -1 +endi + +if $data32 != 0 then + return -1 +endi + +if $data33 != 0 then + return -1 +endi + +if $data34 != ready then + goto step5 +endi + +if $data35 != arb then + return -1 +endi + +if $data37 != - then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/issue/TD-2713.sim b/tests/script/issue/TD-2713.sim new file mode 100644 index 0000000000..b66c55b9b9 --- /dev/null +++ b/tests/script/issue/TD-2713.sim @@ -0,0 +1,145 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode2 -c wallevel -v 2 +system sh/cfg.sh -n dnode3 -c wallevel -v 2 +system sh/cfg.sh -n dnode4 -c wallevel -v 2 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 +system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 + +system sh/cfg.sh -n dnode1 -c slaveQuery -v 1 +system sh/cfg.sh -n dnode2 -c slaveQuery -v 1 +system sh/cfg.sh -n dnode3 -c slaveQuery -v 1 +system sh/cfg.sh -n dnode4 -c slaveQuery -v 1 + +print ========= step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes +print mnode1 $data2_1 +print mnode1 $data2_2 +print mnode1 $data2_3 +if $data2_1 != master then + goto step1 +endi +if $data2_2 != slave then + goto step1 +endi +if $data2_3 != slave then + goto step1 +endi + +print ========= step2 +sql create database d1 replica 3 +sql create table d1.t1 (ts timestamp, i int) +sql insert into d1.t1 values(now, 1) + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show d1.vgroups +print online vgroups: $data03 +if $data03 != 3 then + goto step2 +endi +sleep 1000 + +print ========= step3 +$i = 0 +while $i < 100 + $i = $i + 1 + sql select * from d1.t1 + print d1.t1 rows: $rows + if $rows != 1 then + return -1 + endi +endw + +print ========= step4 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT + +system rm -rf ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/* +system rm -rf ../../../sim/dnode3/data/vnode/vnode2/version.json + +system sh/exec.sh -n dnode1 -s start -x SIGINT +system sh/exec.sh -n dnode2 -s start -x SIGINT +system sh/exec.sh -n dnode3 -s start -x SIGINT + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + +sql show d1.vgroups +print online vgroups: $data03 +if $data03 != 3 then + goto step4 +endi +sleep 1000 + +print ========= step5 +$i = 0 +while $i < 100 + $i = $i + 1 + sql select * from d1.t1 + if $rows != 1 then + return -1 + endi + print d1.t1 rows: $rows +endw + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 733b01f895..90d01b7215 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -1,6 +1,10 @@ cd ../../../debug; cmake .. cd ../../../debug; make +./test.sh -f issue/TD-2677.sim +./test.sh -f issue/TD-2680.sim +./test.sh -f issue/TD-2713.sim + ./test.sh -f general/alter/cached_schema_after_alter.sim ./test.sh -f general/alter/count.sim ./test.sh -f general/alter/dnode.sim diff --git a/tests/script/test.sh b/tests/script/test.sh index a68ac4736d..1c7a7527ab 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -113,7 +113,6 @@ echo "rpcDebugFlag 143" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG echo "cDebugFlag 143" >> $TAOS_CFG echo "udebugFlag 143" >> $TAOS_CFG -echo "tablemetakeeptimer 5" >> $TAOS_CFG echo "wal 0" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG diff --git a/tests/script/tmp/mnodes.sim b/tests/script/tmp/mnodes.sim index e11140028d..23f59d1d00 100644 --- a/tests/script/tmp/mnodes.sim +++ b/tests/script/tmp/mnodes.sim @@ -35,7 +35,6 @@ system sh/cfg.sh -n dnode3 -c replica -v 3 print ============== deploy system sh/exec.sh -n dnode1 -s start -sleep 5001 sql connect sql create dnode $hostname2 @@ -45,13 +44,29 @@ system sh/exec.sh -n dnode3 -s start print =============== step1 $x = 0 -show1: +step1: $x = $x + 1 - sleep 2000 - if $x == 5 then - return -1 + sleep 1000 + if $x == 10 then + return -1 endi -sql show mnodes -x show1 + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi + +sql show mnodes $mnode1Role = $data2_1 print mnode1Role $mnode1Role $mnode2Role = $data2_2 @@ -60,13 +75,13 @@ $mnode3Role = $data2_3 print mnode3Role $mnode3Role if $mnode1Role != master then - goto show1 + goto step1 endi if $mnode2Role != slave then - goto show1 + goto step1 endi if $mnode3Role != slave then - goto show1 + goto step1 endi $x = 1 @@ -75,9 +90,21 @@ show2: print =============== step $x sql show mnodes print $data0_1 $data2_1 -print $data0_2 $data2_2 -print $data0_3 $data2_3 +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step1 +endi +if $data4_2 != ready then + goto step1 +endi +if $data4_3 != ready then + goto step1 +endi $x = $x + 1 sleep 5000 diff --git a/tests/script/unique/arbitrator/check_cluster_cfg_para.sim b/tests/script/unique/arbitrator/check_cluster_cfg_para.sim index 1b22db9d82..915fef47da 100644 --- a/tests/script/unique/arbitrator/check_cluster_cfg_para.sim +++ b/tests/script/unique/arbitrator/check_cluster_cfg_para.sim @@ -115,7 +115,7 @@ if $loopCnt == 10 then return -1 endi sql show dnodes -if $rows != 7 then +if $rows != 8 then sleep 2000 goto wait_dnode_created endi @@ -172,7 +172,7 @@ print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode_offline_overtime_dropped endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim index aaf0da8553..318a89f96b 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim @@ -103,7 +103,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode3_offline_0 endi @@ -170,7 +170,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode3_reready endi @@ -237,7 +237,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode2_offline endi @@ -282,7 +282,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode2_reready endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim index c9c85cb45d..9fc19d588a 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim @@ -105,7 +105,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -172,7 +172,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_reready endi @@ -239,7 +239,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode23_offline endi @@ -283,7 +283,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode23_reready endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim b/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim index dd868e9eed..08d2db207b 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim @@ -107,7 +107,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_dropped endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim index 3582a3b7b2..df41e4df36 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim @@ -106,7 +106,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -167,7 +167,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_reready endi @@ -227,7 +227,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode3_offline endi @@ -267,7 +267,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode3_reready endi @@ -343,7 +343,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode2_offline endi @@ -383,7 +383,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode2_reready endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim index 4040318801..d814398d06 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim @@ -107,7 +107,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode3_offline_0 endi @@ -198,7 +198,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode3_reready endi @@ -276,7 +276,7 @@ if $loopCnt == 10 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode2_offline_0 endi @@ -357,7 +357,7 @@ if $loopCnt == 10 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode23_reready_2 endi diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim index b3bd853ffc..8f2cd9169b 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim @@ -110,7 +110,7 @@ if $loopCnt == 10 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -219,7 +219,7 @@ if $loopCnt == 10 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode3_offline_0 endi diff --git a/tests/script/unique/arbitrator/insert_duplicationTs.sim b/tests/script/unique/arbitrator/insert_duplicationTs.sim index 7c6c6e6e92..d58f903dcf 100644 --- a/tests/script/unique/arbitrator/insert_duplicationTs.sim +++ b/tests/script/unique/arbitrator/insert_duplicationTs.sim @@ -132,7 +132,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode2_offline endi @@ -190,7 +190,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode2_ready endi diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim index c11bfa62f9..9527d230e4 100644 --- a/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim @@ -108,7 +108,7 @@ if $loopCnt == 10 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -174,7 +174,7 @@ if $loopCnt == 10 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_ready endi diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim index bed5cefa76..1da8d749d5 100644 --- a/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -204,7 +204,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_ready endi diff --git a/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim index 9fdb70142b..791ba76a8d 100644 --- a/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -190,7 +190,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_ready endi diff --git a/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim index 6752e0345d..0d5abb2b91 100644 --- a/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim index 1280cfe7a0..0c59ee8525 100644 --- a/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -176,7 +176,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_ready endi diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim index 27c2ba4328..ce7151f78e 100644 --- a/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -178,7 +178,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_ready endi diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim index 86fb51cfa9..e29f8267c3 100644 --- a/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -204,7 +204,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_ready endi diff --git a/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim index 4dcc5977f3..8f8b996c09 100644 --- a/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim @@ -108,7 +108,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -191,7 +191,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_ready endi diff --git a/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim index 4f4cf6a263..f3779cf20a 100644 --- a/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim index 98946c4b7c..f70ef1fc8c 100644 --- a/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi @@ -176,7 +176,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_ready endi diff --git a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim index 3715be5fa9..8d1a508ef0 100644 --- a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim +++ b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim @@ -115,7 +115,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode2_ready endi @@ -161,7 +161,7 @@ if $cnt == 10 then return -1 endi sql show dnodes -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode_ready endi diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim index dc8b1d015d..12db84cbb3 100644 --- a/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim @@ -107,7 +107,7 @@ if $cnt == 10 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim index d2c82f98ff..06d67a1cc9 100644 --- a/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim index 96aec2dcf8..b388bc73a6 100644 --- a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim @@ -107,7 +107,7 @@ if $cnt == 10 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim index a1d7d18c94..2e20d7b5d4 100644 --- a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim +++ b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim @@ -107,7 +107,7 @@ if $cnt == 10 then return -1 endi sql show dnodes -if $rows != 3 then +if $rows != 4 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim index d4eb360efb..69cdb9f942 100644 --- a/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim @@ -107,7 +107,7 @@ if $cnt == 10 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim index 9b918acc8e..491b858500 100644 --- a/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim @@ -107,7 +107,7 @@ if $cnt == 20 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim index 4c7bb3d26c..7a5966f60c 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim @@ -107,7 +107,7 @@ if $cnt == 10 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim index 7ac424666a..abd2d8a788 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim @@ -107,7 +107,7 @@ if $cnt == 10 then return -1 endi sql show dnodes -if $rows != 4 then +if $rows != 5 then sleep 2000 goto wait_dnode4_offline_0 endi diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim index 9b02933cbf..e5f2928748 100644 --- a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim @@ -112,7 +112,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode1_offline endi @@ -159,7 +159,7 @@ if $loopCnt == 20 then endi sql show dnodes -x wait_dnode1_ready -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode1_ready endi @@ -238,7 +238,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode2_offline endi diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim index 90183949e7..8d063020e7 100644 --- a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim @@ -112,7 +112,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode1_offline endi @@ -161,7 +161,7 @@ if $loopCnt == 20 then endi sql show dnodes -x wait_dnode1_ready -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode1_ready endi @@ -234,7 +234,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode2_offline endi diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim index 691b2cb568..69e83a2c00 100644 --- a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim @@ -126,7 +126,7 @@ if $loopCnt == 20 then endi sql show dnodes -x wait_dnode1_ready -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode1_ready endi diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim index 02e2cd02e1..6c9e92502c 100644 --- a/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim @@ -112,7 +112,7 @@ if $loopCnt == 10 then endi sql show dnodes -if $rows != 2 then +if $rows != 3 then sleep 2000 goto wait_dnode1_offline endi diff --git a/tests/script/unique/stream/metrics_balance.sim b/tests/script/unique/stream/metrics_balance.sim index 36086fe4b8..3cb0d73ab8 100644 --- a/tests/script/unique/stream/metrics_balance.sim +++ b/tests/script/unique/stream/metrics_balance.sim @@ -14,8 +14,6 @@ system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 -system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 5 -system sh/cfg.sh -n dnode2 -c tableMetaKeepTimer -v 5 system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index 2eb8ee1614..33e1528b70 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 0323f6ca68..a23dff13be 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -746,15 +746,27 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { case TSDB_DATA_TYPE_TINYINT: sprintf(value, "%d", *((int8_t *)row[i])); break; + case TSDB_DATA_TYPE_UTINYINT: + sprintf(value, "%u", *((uint8_t*)row[i])); + break; case TSDB_DATA_TYPE_SMALLINT: sprintf(value, "%d", *((int16_t *)row[i])); break; + case TSDB_DATA_TYPE_USMALLINT: + sprintf(value, "%u", *((uint16_t *)row[i])); + break; case TSDB_DATA_TYPE_INT: sprintf(value, "%d", *((int32_t *)row[i])); break; + case TSDB_DATA_TYPE_UINT: + sprintf(value, "%u", *((uint32_t *)row[i])); + break; case TSDB_DATA_TYPE_BIGINT: sprintf(value, "%" PRId64, *((int64_t *)row[i])); break; + case TSDB_DATA_TYPE_UBIGINT: + sprintf(value, "%" PRIu64, *((uint64_t *)row[i])); + break; case TSDB_DATA_TYPE_FLOAT: sprintf(value, "%.5f", GET_FLOAT_VAL(row[i])); break;