Merge branch 'main' of https://github.com/taosdata/TDengine
This commit is contained in:
commit
8e434ba0e4
|
@ -190,6 +190,7 @@ ROUND(expr[, digits])
|
|||
- `digits` less than zero means discarding the decimal places and rounding the number to the left of the decimal point by `digits` places. If the number of places to the left of the decimal point is less than `digits`, returns 0.
|
||||
- Since the DECIMAL type is not yet supported, this function will use DOUBLE and FLOAT to represent results containing decimals, but DOUBLE and FLOAT have precision limits, and using this function may be meaningless when there are too many digits.
|
||||
- Can only be used with regular columns, selection (Selection), projection (Projection) functions, and cannot be used with aggregation (Aggregation) functions.
|
||||
- `digits` is supported from version 3.3.3.0.
|
||||
|
||||
**Example**:
|
||||
|
||||
|
@ -249,6 +250,8 @@ TAN(expr)
|
|||
|
||||
**Function Description**: Obtains the tangent result of the specified field.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Type**: DOUBLE.
|
||||
|
||||
**Applicable Data Types**: Numeric types.
|
||||
|
@ -297,6 +300,8 @@ TRUNCATE(expr, digits)
|
|||
|
||||
**Function Description**: Gets the truncated value of the specified field to the specified number of digits.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: Consistent with the original data type of the `expr` field.
|
||||
|
||||
**Applicable Data Types**:
|
||||
|
@ -340,6 +345,8 @@ EXP(expr)
|
|||
|
||||
**Function Description**: Returns the value of e (the base of natural logarithms) raised to the specified power.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: DOUBLE.
|
||||
|
||||
**Applicable Data Types**: Numeric type.
|
||||
|
@ -370,6 +377,8 @@ LN(expr)
|
|||
|
||||
**Function Description**: Returns the natural logarithm of the specified parameter.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: DOUBLE.
|
||||
|
||||
**Applicable Data Types**: Numeric type.
|
||||
|
@ -401,6 +410,8 @@ MOD(expr1, expr2)
|
|||
|
||||
**Function Description**: Calculates the result of expr1 % expr2.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: DOUBLE.
|
||||
|
||||
**Applicable Data Types**: Numeric type.
|
||||
|
@ -437,6 +448,8 @@ RAND([seed])
|
|||
|
||||
**Function Description**: Returns a uniformly distributed random number from 0 to 1.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Type**: DOUBLE.
|
||||
|
||||
**Applicable Data Types**:
|
||||
|
@ -484,6 +497,8 @@ SIGN(expr)
|
|||
|
||||
**Function Description**: Returns the sign of the specified parameter.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Type**: Consistent with the original data type of the specified field.
|
||||
|
||||
**Applicable Data Types**: Numeric types.
|
||||
|
@ -527,6 +542,8 @@ DEGREES(expr)
|
|||
|
||||
**Function Description**: Calculates the value of the specified parameter converted from radians to degrees.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Type**: DOUBLE.
|
||||
|
||||
**Applicable Data Types**: Numeric types.
|
||||
|
@ -558,6 +575,8 @@ RADIANS(expr)
|
|||
|
||||
**Function Description**: Calculates the value of the specified parameter converted from degrees to radians.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: DOUBLE.
|
||||
|
||||
**Applicable Data Types**: Numeric types.
|
||||
|
@ -729,6 +748,8 @@ TRIM([remstr FROM] expr)
|
|||
|
||||
**Function Description**: Returns the string expr with all prefixes or suffixes of remstr removed.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Type**: Same as the original type of the input field expr.
|
||||
|
||||
**Applicable Data Types**:
|
||||
|
@ -807,6 +828,8 @@ SUBSTRING/SUBSTR(expr FROM pos [FOR len])
|
|||
- If `len` is less than 1, returns an empty string.
|
||||
- `pos` is 1-based; if `pos` is 0, returns an empty string.
|
||||
- If `pos` + `len` exceeds `len(expr)`, returns the substring from `pos` to the end of the string, equivalent to executing `substring(expr, pos)`.
|
||||
- Function `SUBSTRING` is equal to `SUBSTR`, supported from ver-3.3.3.0.
|
||||
- Syntax `SUBSTRING/SUBSTR(expr FROM pos [FOR len])` is supported from ver-3.3.3.0.
|
||||
|
||||
**Examples**:
|
||||
|
||||
|
@ -845,6 +868,8 @@ SUBSTRING_INDEX(expr, delim, count)
|
|||
|
||||
**Function Description**: Returns a substring of `expr` cut at the position where the delimiter appears the specified number of times.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Type**: Same as the original type of the input field `expr`.
|
||||
|
||||
**Applicable Data Types**:
|
||||
|
@ -902,6 +927,8 @@ CHAR(expr1 [, expr2] [, expr3] ...)
|
|||
|
||||
**Function Description**: Treats the input parameters as integers and returns the characters corresponding to these integers in ASCII encoding.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Type**: VARCHAR.
|
||||
|
||||
**Applicable Data Types**: Integer types, VARCHAR, NCHAR.
|
||||
|
@ -949,6 +976,8 @@ ASCII(expr)
|
|||
|
||||
**Function Description**: Returns the ASCII code of the first character of the string.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Data Type**: BIGINT.
|
||||
|
||||
**Applicable Data Types**: VARCHAR, NCHAR.
|
||||
|
@ -979,6 +1008,8 @@ POSITION(expr1 IN expr2)
|
|||
|
||||
**Function Description**: Calculates the position of string `expr1` in string `expr2`.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Type**: BIGINT.
|
||||
|
||||
**Applicable Data Types**:
|
||||
|
@ -1026,6 +1057,8 @@ REPLACE(expr, from_str, to_str)
|
|||
|
||||
**Function Description**: Replaces all occurrences of `from_str` in the string with `to_str`.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: Same as the original type of the input field `expr`.
|
||||
|
||||
**Applicable Data Types**:
|
||||
|
@ -1061,6 +1094,8 @@ REPEAT(expr, count)
|
|||
|
||||
**Function Description**: Returns a string that repeats the string `expr` a specified number of times.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: Same as the original type of the input field `expr`.
|
||||
|
||||
**Applicable Data Types**:
|
||||
|
@ -1319,6 +1354,7 @@ TIMEDIFF(expr1, expr2 [, time_unit])
|
|||
- `expr1`: BIGINT, TIMESTAMP types representing timestamps, or VARCHAR, NCHAR types in ISO8601/RFC3339 standard date-time format.
|
||||
- `expr2`: BIGINT, TIMESTAMP types representing timestamps, or VARCHAR, NCHAR types in ISO8601/RFC3339 standard date-time format.
|
||||
- `time_unit`: See usage instructions.
|
||||
- `timediff` return the absolute value of the difference between timestamp `expr1` and `expr2` before ver-3.3.3.0.
|
||||
|
||||
**Nested Subquery Support**: Applicable to both inner and outer queries.
|
||||
|
||||
|
@ -1423,6 +1459,8 @@ WEEK(expr [, mode])
|
|||
|
||||
**Function Description**: Returns the week number of the input date.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Result Type**: BIGINT.
|
||||
|
||||
**Applicable Data Types**:
|
||||
|
@ -1490,6 +1528,8 @@ WEEKOFYEAR(expr)
|
|||
|
||||
**Function Description**: Returns the week number of the input date.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: BIGINT.
|
||||
|
||||
**Applicable Data Types**: BIGINT, TIMESTAMP types representing timestamps, or VARCHAR, NCHAR types in ISO8601/RFC3339 date-time format.
|
||||
|
@ -1521,6 +1561,8 @@ WEEKDAY(expr)
|
|||
|
||||
**Function Description**: Returns the weekday of the input date.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: BIGINT.
|
||||
|
||||
**Applicable Data Types**: BIGINT, TIMESTAMP types representing timestamps, or VARCHAR, NCHAR types in ISO8601/RFC3339 date-time format.
|
||||
|
@ -1552,6 +1594,8 @@ DAYOFWEEK(expr)
|
|||
|
||||
**Function Description**: Returns the weekday of the input date.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Type**: BIGINT.
|
||||
|
||||
**Applicable Data Types**: BIGINT, TIMESTAMP types representing timestamps, or VARCHAR, NCHAR types in ISO8601/RFC3339 date-time format.
|
||||
|
@ -1707,6 +1751,9 @@ STDDEV/STDDEV_POP(expr)
|
|||
|
||||
**Applicable to**: Tables and supertables.
|
||||
|
||||
**Description**:
|
||||
- Function `STDDEV_POP` equals `STDDEV` and is supported from ver-3.3.3.0.
|
||||
|
||||
**Example**:
|
||||
|
||||
```sql
|
||||
|
@ -1733,6 +1780,8 @@ VAR_POP(expr)
|
|||
|
||||
**Function Description**: Calculates the population variance of a column in a table.
|
||||
|
||||
**Version**: ver-3.3.3.0
|
||||
|
||||
**Return Data Type**: DOUBLE.
|
||||
|
||||
**Applicable Data Types**: Numeric types.
|
||||
|
@ -1975,7 +2024,8 @@ MAX(expr)
|
|||
|
||||
**Applicable to**: Tables and supertables.
|
||||
|
||||
**Usage Instructions**: The max function can accept strings as input parameters, and when the input parameter is a string type, it returns the largest string value.
|
||||
**Usage Instructions**:
|
||||
- The max function can accept strings as input parameters, and when the input parameter is a string type, it returns the largest string value(supported from ver-3.3.3.0, function `max` only accept numeric parameter before ver-3.3.3.0).
|
||||
|
||||
### MIN
|
||||
|
||||
|
@ -1991,7 +2041,8 @@ MIN(expr)
|
|||
|
||||
**Applicable to**: Tables and supertables.
|
||||
|
||||
**Usage Instructions**: The min function can accept strings as input parameters, and when the input parameter is a string type, it returns the largest string value.
|
||||
**Usage Instructions**:
|
||||
- The min function can accept strings as input parameters, and when the input parameter is a string type, it returns the largest string value(supported from ver-3.3.3.0, function `min` only accept numeric parameter before ver-3.3.3.0).
|
||||
|
||||
### MODE
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ ROUND(expr[, digits])
|
|||
- `digits` 小于零表示丢掉小数位,并将数字四舍五入到小数点左侧 `digits` 位。若小数点左侧的位数小于 `digits`位,返回 0。
|
||||
- 由于暂未支持 DECIMAL 类型,所以该函数会用 DOUBLE 和 FLOAT 来表示包含小数的结果,但是 DOUBLE 和 FLOAT 是有精度上限的,当位数太多时使用该函数可能没有意义。
|
||||
- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。
|
||||
- `digits` 从 ver-3.3.3.0 开始支持。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
|
@ -268,6 +269,8 @@ PI()
|
|||
|
||||
**功能说明**:返回圆周率 π 的值。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:无。
|
||||
|
@ -295,6 +298,8 @@ TRUNCATE(expr, digits)
|
|||
|
||||
**功能说明**:获得指定字段按照指定位数截断的值。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:与 `expr` 字段的原始数据类型一致。
|
||||
|
||||
**适用数据类型**:
|
||||
|
@ -333,6 +338,8 @@ EXP(expr)
|
|||
```
|
||||
**功能说明**:返回 e(自然对数的底)的指定乘方后的值。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
@ -360,6 +367,8 @@ LN(expr)
|
|||
|
||||
**功能说明**:返回指定参数的自然对数。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
@ -388,6 +397,8 @@ MOD(expr1, expr2)
|
|||
|
||||
**功能说明**:计算 expr1 % expr2 的结果。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
@ -421,6 +432,8 @@ RAND([seed])
|
|||
|
||||
**功能说明**:返回一个从0到1均匀分布的随机数。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:
|
||||
|
@ -464,6 +477,8 @@ SIGN(expr)
|
|||
|
||||
**功能说明**:返回指定参数的符号。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:与指定字段的原始数据类型一致。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
@ -504,6 +519,8 @@ DEGREES(expr)
|
|||
|
||||
**功能说明**:计算指定参数由弧度值转为角度后的值。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
@ -532,6 +549,8 @@ RADIANS(expr)
|
|||
|
||||
**功能说明**:计算指定参数由角度值转为弧度后的值。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
@ -702,6 +721,8 @@ TRIM([remstr FROM] expr)
|
|||
|
||||
**功能说明**:返回去掉了所有 remstr 前缀或后缀的字符串 epxr 。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:与输入字段 epxr 的原始类型相同。
|
||||
|
||||
**适用数据类型**:
|
||||
|
@ -773,6 +794,8 @@ SUBSTRING/SUBSTR(expr FROM pos [FOR len])
|
|||
- 若 `len` 小于 1,返回空串。
|
||||
- `pos` 是 1-base 的,若 `pos` 为 0,返回空串。
|
||||
- 若 `pos` + `len` 大于 `len(expr)`,返回从 `pos` 开始到字符串结尾的子串,等同于执行 `substring(expr, pos)`。
|
||||
- `SUBSTRING` 函数等价于 `SUBSTR`, 从 ver-3.3.3.0 开始支持。
|
||||
- `SUBSTRING/SUBSTR(expr FROM pos [FOR len])` 语法从 ver-3.3.3.0 开始支持。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
|
@ -809,6 +832,8 @@ SUBSTRING_INDEX(expr, delim, count)
|
|||
|
||||
**功能说明**:返回字符串 `expr` 在出现指定次数分隔符的位置截取的子串。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:与输入字段 `expr` 的原始类型相同。
|
||||
|
||||
**适用数据类型**:
|
||||
|
@ -862,6 +887,8 @@ CHAR(expr1 [, expr2] [, epxr3] ...)
|
|||
|
||||
**功能说明**:将输入参数当作整数,并返回这些整数在 ASCII 编码中对应的字符。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:VARCHAR。
|
||||
|
||||
**适用数据类型**:整数类型,VARCHAR,NCHAR。
|
||||
|
@ -906,6 +933,8 @@ ASCII(expr)
|
|||
|
||||
**功能说明**:返回字符串第一个字符的 ASCII 码。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果数据类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:VARCHAR, NCHAR。
|
||||
|
@ -933,6 +962,8 @@ POSITION(expr1 IN expr2)
|
|||
|
||||
**功能说明**:计算字符串 `expr1` 在字符串 `expr2` 中的位置。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:
|
||||
|
@ -975,6 +1006,8 @@ REPLACE(expr, from_str, to_str)
|
|||
```
|
||||
**功能说明**:将字符串中的 `from_str` 全部替换为 `to_str`。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:与输入字段 `expr` 的原始类型相同。
|
||||
|
||||
**适用数据类型**:
|
||||
|
@ -1005,6 +1038,8 @@ REPEAT(expr, count)
|
|||
```
|
||||
**功能说明**:返回将字符串重复指定次数得到的字符串。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:与输入字段 `expr` 的原始类型相同。
|
||||
|
||||
**适用数据类型**:
|
||||
|
@ -1260,6 +1295,7 @@ TIMEDIFF(expr1, expr2 [, time_unit])
|
|||
- `expr1`:表示时间戳的 BIGINT, TIMESTAMP 类型,或符合 ISO8601/RFC3339 标准的日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
- `expr2`:表示时间戳的 BIGINT, TIMESTAMP 类型,或符合 ISO8601/RFC3339 标准的日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
- `time_unit`:见使用说明。
|
||||
- ver-3.3.3.0 之前该函数结果为时间戳 `expr1` 和 `expr2` 的差值的绝对值,结果为正数。
|
||||
|
||||
**嵌套子查询支持**:适用于内层查询和外层查询。
|
||||
|
||||
|
@ -1361,6 +1397,8 @@ WEEK(expr [, mode])
|
|||
```
|
||||
**功能说明**:返回输入日期的周数。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:
|
||||
|
@ -1422,6 +1460,8 @@ WEEKOFYEAR(expr)
|
|||
```
|
||||
**功能说明**:返回输入日期的周数。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:表示时间戳的 BIGINT, TIMESTAMP 类型,或符合 ISO8601/RFC3339 标准的日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
|
@ -1449,6 +1489,8 @@ WEEKDAY(expr)
|
|||
```
|
||||
**功能说明**:返回输入日期是周几。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:表示 表示时间戳的 BIGINT, TIMESTAMP 类型,或符合 ISO8601/RFC3339 标准的日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
|
@ -1476,6 +1518,8 @@ DAYOFWEEK(expr)
|
|||
```
|
||||
**功能说明**:返回输入日期是周几。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回结果类型**:BIGINT。
|
||||
|
||||
**适用数据类型**:表示时间戳的 BIGINT, TIMESTAMP 类型,或符合 ISO8601/RFC3339 标准的日期时间格式的 VARCHAR, NCHAR 类型。
|
||||
|
@ -1633,6 +1677,9 @@ STDDEV/STDDEV_POP(expr)
|
|||
|
||||
**适用于**:表和超级表。
|
||||
|
||||
**说明**:
|
||||
- `STDDEV_POP` 函数等价于 `STDDEV` 函数,从 ver-3.3.3.0 开始支持。
|
||||
|
||||
**举例**:
|
||||
```sql
|
||||
taos> select id from test_stddev;
|
||||
|
@ -1656,6 +1703,8 @@ VAR_POP(expr)
|
|||
|
||||
**功能说明**:统计表中某列的总体方差。
|
||||
|
||||
**版本**: ver-3.3.3.0
|
||||
|
||||
**返回数据类型**:DOUBLE。
|
||||
|
||||
**适用数据类型**:数值类型。
|
||||
|
@ -1898,7 +1947,8 @@ MAX(expr)
|
|||
|
||||
**适用于**:表和超级表。
|
||||
|
||||
**使用说明**:max 函数可以接受字符串作为输入参数,当输入参数为字符串类型时,返回最大的字符串值。
|
||||
**使用说明**:
|
||||
- max 函数可以接受字符串作为输入参数,当输入参数为字符串类型时,返回最大的字符串值,从 ver-3.3.3.0 开始支持,之前的版本不支持字符串参数。
|
||||
|
||||
### MIN
|
||||
|
||||
|
@ -1914,7 +1964,8 @@ MIN(expr)
|
|||
|
||||
**适用于**:表和超级表。
|
||||
|
||||
**使用说明**:min 函数可以接受字符串作为输入参数,当输入参数为字符串类型时,返回最大的字符串值。
|
||||
**使用说明**:
|
||||
- min 函数可以接受字符串作为输入参数,当输入参数为字符串类型时,返回最大的字符串值,从 ver-3.3.3.0 开始支持,之前的版本不支持字符串参数。
|
||||
|
||||
### MODE
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct SCryptOpts {
|
|||
char* source;
|
||||
char* result;
|
||||
int32_t unitLen;
|
||||
char key[17];
|
||||
char key[ENCRYPT_KEY_LEN + 1];
|
||||
} SCryptOpts;
|
||||
|
||||
int32_t CBC_Decrypt(SCryptOpts* opts);
|
||||
|
|
|
@ -39,7 +39,7 @@ static FORCE_INLINE int32_t stmtAllocQNodeFromBuf(STableBufInfo* pTblBuf, void**
|
|||
}
|
||||
|
||||
static bool stmtDequeue(STscStmt2* pStmt, SStmtQNode** param) {
|
||||
while (0 == atomic_load_64(&pStmt->queue.qRemainNum)) {
|
||||
while (0 == atomic_load_64((int64_t*)&pStmt->queue.qRemainNum)) {
|
||||
taosUsleep(1);
|
||||
return false;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ static bool stmtDequeue(STscStmt2* pStmt, SStmtQNode** param) {
|
|||
|
||||
*param = node;
|
||||
|
||||
(void)atomic_sub_fetch_64(&pStmt->queue.qRemainNum, 1);
|
||||
(void)atomic_sub_fetch_64((int64_t*)&pStmt->queue.qRemainNum, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ static void stmtEnqueue(STscStmt2* pStmt, SStmtQNode* param) {
|
|||
pStmt->queue.tail = param;
|
||||
|
||||
pStmt->stat.bindDataNum++;
|
||||
(void)atomic_add_fetch_64(&pStmt->queue.qRemainNum, 1);
|
||||
(void)atomic_add_fetch_64((int64_t*)&pStmt->queue.qRemainNum, 1);
|
||||
}
|
||||
|
||||
static int32_t stmtCreateRequest(STscStmt2* pStmt) {
|
||||
|
|
|
@ -788,6 +788,8 @@ TEST(clientCase, insert_test) {
|
|||
}
|
||||
|
||||
TEST(clientCase, projection_query_tables) {
|
||||
taos_options(TSDB_OPTION_CONFIGDIR, "/home/lisa/first/cfg");
|
||||
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
|
@ -796,6 +798,12 @@ TEST(clientCase, projection_query_tables) {
|
|||
pRes= taos_query(pConn, "use abc1");
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "select forecast(k,'algo=arima,wncheck=0') from t1 where ts<='2024-11-15 1:7:44'");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
(void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table tu using st2 tags(2)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
(void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "tcompression.h"
|
||||
|
||||
const int32_t TYPE_BYTES[21] = {
|
||||
-1, // TSDB_DATA_TYPE_NULL
|
||||
2, // TSDB_DATA_TYPE_NULL
|
||||
CHAR_BYTES, // TSDB_DATA_TYPE_BOOL
|
||||
CHAR_BYTES, // TSDB_DATA_TYPE_TINYINT
|
||||
SHORT_BYTES, // TSDB_DATA_TYPE_SMALLINT
|
||||
|
@ -42,7 +42,7 @@ const int32_t TYPE_BYTES[21] = {
|
|||
};
|
||||
|
||||
tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX] = {
|
||||
{TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", 0, 0, NULL, NULL},
|
||||
{TSDB_DATA_TYPE_NULL, 6, 2, "NOTYPE", 0, 0, NULL, NULL},
|
||||
{TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", false, true, tsCompressBool, tsDecompressBool},
|
||||
{TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", INT8_MIN, INT8_MAX, tsCompressTinyint, tsDecompressTinyint},
|
||||
{TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", INT16_MIN, INT16_MAX, tsCompressSmallint,
|
||||
|
|
|
@ -211,7 +211,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
#if defined(TD_ENTERPRISE)
|
||||
pCfg->tdbEncryptAlgorithm = pCreate->encryptAlgorithm;
|
||||
if (pCfg->tdbEncryptAlgorithm == DND_CA_SM4) {
|
||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
#else
|
||||
pCfg->tdbEncryptAlgorithm = 0;
|
||||
|
|
|
@ -327,7 +327,7 @@ struct SVnodeCfg {
|
|||
int16_t hashSuffix;
|
||||
int32_t tsdbPageSize;
|
||||
int32_t tdbEncryptAlgorithm;
|
||||
char tdbEncryptKey[ENCRYPT_KEY_LEN];
|
||||
char tdbEncryptKey[ENCRYPT_KEY_LEN + 1];
|
||||
int32_t s3ChunkSize;
|
||||
int32_t s3KeepLocal;
|
||||
int8_t s3Compact;
|
||||
|
|
|
@ -104,7 +104,7 @@ int32_t tsdbOpenFile(const char *path, STsdb *pTsdb, int32_t flag, STsdbFD **ppF
|
|||
}
|
||||
|
||||
pFD->path = (char *)&pFD[1];
|
||||
tstrncpy(pFD->path, path, strlen(path) + 1);
|
||||
memcpy(pFD->path, path, strlen(path) + 1);
|
||||
pFD->szPage = szPage;
|
||||
pFD->flag = flag;
|
||||
pFD->szPage = szPage;
|
||||
|
|
|
@ -330,7 +330,7 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) {
|
|||
return terrno;
|
||||
}
|
||||
|
||||
tstrncpy((char *)((*async) + 1), label, strlen(label) + 1);
|
||||
memcpy((char *)((*async) + 1), label, strlen(label) + 1);
|
||||
(*async)->label = (const char *)((*async) + 1);
|
||||
|
||||
(void)taosThreadMutexInit(&(*async)->mutex, NULL);
|
||||
|
|
|
@ -303,7 +303,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
if (tsEncryptKey[0] == 0) {
|
||||
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
|
||||
} else {
|
||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
|
||||
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -417,7 +417,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
|||
}
|
||||
|
||||
pVnode->path = (char *)&pVnode[1];
|
||||
tstrncpy(pVnode->path, path, strlen(path) + 1);
|
||||
memcpy(pVnode->path, path, strlen(path) + 1);
|
||||
pVnode->config = info.config;
|
||||
pVnode->state.committed = info.state.committed;
|
||||
pVnode->state.commitTerm = info.state.commitTerm;
|
||||
|
|
|
@ -830,7 +830,7 @@ int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
|
||||
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||
vTrace("message in vnode query queue is processing");
|
||||
if ((pMsg->msgType == TDMT_SCH_QUERY || pMsg->msgType == TDMT_VND_TMQ_CONSUME) && !syncIsReadyForRead(pVnode->sync)) {
|
||||
if (pMsg->msgType == TDMT_VND_TMQ_CONSUME && !syncIsReadyForRead(pVnode->sync)) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg, terrno);
|
||||
return 0;
|
||||
}
|
||||
|
@ -842,9 +842,21 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
|
||||
SReadHandle handle = {.vnode = pVnode, .pMsgCb = &pVnode->msgCb, .pWorkerCb = pInfo->workerCb};
|
||||
initStorageAPI(&handle.api);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
bool redirected = false;
|
||||
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_SCH_QUERY:
|
||||
if (!syncIsReadyForRead(pVnode->sync)) {
|
||||
pMsg->code = (terrno) ? terrno : TSDB_CODE_SYN_NOT_LEADER;
|
||||
redirected = true;
|
||||
}
|
||||
code = qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||
if (redirected) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg, pMsg->code);
|
||||
return 0;
|
||||
}
|
||||
return code;
|
||||
case TDMT_SCH_MERGE_QUERY:
|
||||
return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg, 0);
|
||||
case TDMT_SCH_QUERY_CONTINUE:
|
||||
|
|
|
@ -497,6 +497,8 @@ typedef struct SCtgAsyncFps {
|
|||
ctgDumpTaskResFp dumpResFp;
|
||||
ctgCompTaskFp compFp;
|
||||
ctgCloneTaskResFp cloneFp;
|
||||
int32_t subTaskFactor; // to indicate how many sub tasks this task will generate by ctgLaunchSubTask
|
||||
// default to 1, means no sub task, 2 means 1 sub task, 3 means 2 sub tasks...
|
||||
} SCtgAsyncFps;
|
||||
|
||||
typedef struct SCtgApiStat {
|
||||
|
|
|
@ -861,6 +861,16 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
|
|||
|
||||
int32_t taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + svrVerNum + dbCfgNum + indexNum +
|
||||
userNum + dbInfoNum + tbIndexNum + tbCfgNum + tbTagNum + viewNum + tbTsmaNum + tbNameNum;
|
||||
int32_t taskNumWithSubTasks = tbMetaNum * gCtgAsyncFps[CTG_TASK_GET_TB_META].subTaskFactor + dbVgNum * gCtgAsyncFps[CTG_TASK_GET_DB_VGROUP].subTaskFactor +
|
||||
udfNum * gCtgAsyncFps[CTG_TASK_GET_UDF].subTaskFactor + tbHashNum * gCtgAsyncFps[CTG_TASK_GET_TB_HASH].subTaskFactor +
|
||||
qnodeNum * gCtgAsyncFps[CTG_TASK_GET_QNODE].subTaskFactor + dnodeNum * gCtgAsyncFps[CTG_TASK_GET_DNODE].subTaskFactor +
|
||||
svrVerNum * gCtgAsyncFps[CTG_TASK_GET_SVR_VER].subTaskFactor + dbCfgNum * gCtgAsyncFps[CTG_TASK_GET_DB_CFG].subTaskFactor +
|
||||
indexNum * gCtgAsyncFps[CTG_TASK_GET_INDEX_INFO].subTaskFactor + userNum * gCtgAsyncFps[CTG_TASK_GET_USER].subTaskFactor +
|
||||
dbInfoNum * gCtgAsyncFps[CTG_TASK_GET_DB_INFO].subTaskFactor + tbIndexNum * gCtgAsyncFps[CTG_TASK_GET_TB_SMA_INDEX].subTaskFactor +
|
||||
tbCfgNum * gCtgAsyncFps[CTG_TASK_GET_TB_CFG].subTaskFactor + tbTagNum * gCtgAsyncFps[CTG_TASK_GET_TB_TAG].subTaskFactor +
|
||||
viewNum * gCtgAsyncFps[CTG_TASK_GET_VIEW].subTaskFactor + tbTsmaNum * gCtgAsyncFps[CTG_TASK_GET_TB_TSMA].subTaskFactor +
|
||||
tsmaNum * gCtgAsyncFps[CTG_TASK_GET_TSMA].subTaskFactor + tbNameNum * gCtgAsyncFps[CTG_TASK_GET_TB_NAME].subTaskFactor;
|
||||
|
||||
*job = taosMemoryCalloc(1, sizeof(SCtgJob));
|
||||
if (NULL == *job) {
|
||||
ctgError("failed to calloc, size:%d,QID:0x%" PRIx64, (int32_t)sizeof(SCtgJob), pConn->requestId);
|
||||
|
@ -905,7 +915,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
|
|||
}
|
||||
#endif
|
||||
|
||||
pJob->pTasks = taosArrayInit(taskNum, sizeof(SCtgTask));
|
||||
pJob->pTasks = taosArrayInit(taskNumWithSubTasks, sizeof(SCtgTask));
|
||||
if (NULL == pJob->pTasks) {
|
||||
ctgError("taosArrayInit %d tasks failed", taskNum);
|
||||
CTG_ERR_JRET(terrno);
|
||||
|
@ -4178,27 +4188,27 @@ int32_t ctgCloneDbVg(SCtgTask* pTask, void** pRes) {
|
|||
}
|
||||
|
||||
SCtgAsyncFps gCtgAsyncFps[] = {
|
||||
{ctgInitGetQnodeTask, ctgLaunchGetQnodeTask, ctgHandleGetQnodeRsp, ctgDumpQnodeRes, NULL, NULL},
|
||||
{ctgInitGetDnodeTask, ctgLaunchGetDnodeTask, ctgHandleGetDnodeRsp, ctgDumpDnodeRes, NULL, NULL},
|
||||
{ctgInitGetDbVgTask, ctgLaunchGetDbVgTask, ctgHandleGetDbVgRsp, ctgDumpDbVgRes, ctgCompDbVgTasks, ctgCloneDbVg},
|
||||
{ctgInitGetDbCfgTask, ctgLaunchGetDbCfgTask, ctgHandleGetDbCfgRsp, ctgDumpDbCfgRes, NULL, NULL},
|
||||
{ctgInitGetDbInfoTask, ctgLaunchGetDbInfoTask, ctgHandleGetDbInfoRsp, ctgDumpDbInfoRes, NULL, NULL},
|
||||
{ctgInitGetQnodeTask, ctgLaunchGetQnodeTask, ctgHandleGetQnodeRsp, ctgDumpQnodeRes, NULL, NULL, 1},
|
||||
{ctgInitGetDnodeTask, ctgLaunchGetDnodeTask, ctgHandleGetDnodeRsp, ctgDumpDnodeRes, NULL, NULL, 1},
|
||||
{ctgInitGetDbVgTask, ctgLaunchGetDbVgTask, ctgHandleGetDbVgRsp, ctgDumpDbVgRes, ctgCompDbVgTasks, ctgCloneDbVg, 1},
|
||||
{ctgInitGetDbCfgTask, ctgLaunchGetDbCfgTask, ctgHandleGetDbCfgRsp, ctgDumpDbCfgRes, NULL, NULL, 1},
|
||||
{ctgInitGetDbInfoTask, ctgLaunchGetDbInfoTask, ctgHandleGetDbInfoRsp, ctgDumpDbInfoRes, NULL, NULL, 1},
|
||||
{ctgInitGetTbMetaTask, ctgLaunchGetTbMetaTask, ctgHandleGetTbMetaRsp, ctgDumpTbMetaRes, ctgCompTbMetaTasks,
|
||||
ctgCloneTbMeta},
|
||||
{ctgInitGetTbHashTask, ctgLaunchGetTbHashTask, ctgHandleGetTbHashRsp, ctgDumpTbHashRes, NULL, NULL},
|
||||
{ctgInitGetTbIndexTask, ctgLaunchGetTbIndexTask, ctgHandleGetTbIndexRsp, ctgDumpTbIndexRes, NULL, NULL},
|
||||
{ctgInitGetTbCfgTask, ctgLaunchGetTbCfgTask, ctgHandleGetTbCfgRsp, ctgDumpTbCfgRes, NULL, NULL},
|
||||
{ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL},
|
||||
{ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL},
|
||||
{ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL},
|
||||
{ctgInitGetSvrVerTask, ctgLaunchGetSvrVerTask, ctgHandleGetSvrVerRsp, ctgDumpSvrVer, NULL, NULL},
|
||||
{ctgInitGetTbMetasTask, ctgLaunchGetTbMetasTask, ctgHandleGetTbMetasRsp, ctgDumpTbMetasRes, NULL, NULL},
|
||||
{ctgInitGetTbHashsTask, ctgLaunchGetTbHashsTask, ctgHandleGetTbHashsRsp, ctgDumpTbHashsRes, NULL, NULL},
|
||||
{ctgInitGetTbTagTask, ctgLaunchGetTbTagTask, ctgHandleGetTbTagRsp, ctgDumpTbTagRes, NULL, NULL},
|
||||
{ctgInitGetViewsTask, ctgLaunchGetViewsTask, ctgHandleGetViewsRsp, ctgDumpViewsRes, NULL, NULL},
|
||||
{ctgInitGetTbTSMATask, ctgLaunchGetTbTSMATask, ctgHandleGetTbTSMARsp, ctgDumpTbTSMARes, NULL, NULL},
|
||||
{ctgInitGetTSMATask, ctgLaunchGetTSMATask, ctgHandleGetTSMARsp, ctgDumpTSMARes, NULL, NULL},
|
||||
{ctgInitGetTbNamesTask, ctgLaunchGetTbNamesTask, ctgHandleGetTbNamesRsp, ctgDumpTbNamesRes, NULL, NULL},
|
||||
ctgCloneTbMeta, 1},
|
||||
{ctgInitGetTbHashTask, ctgLaunchGetTbHashTask, ctgHandleGetTbHashRsp, ctgDumpTbHashRes, NULL, NULL, 1},
|
||||
{ctgInitGetTbIndexTask, ctgLaunchGetTbIndexTask, ctgHandleGetTbIndexRsp, ctgDumpTbIndexRes, NULL, NULL, 1},
|
||||
{ctgInitGetTbCfgTask, ctgLaunchGetTbCfgTask, ctgHandleGetTbCfgRsp, ctgDumpTbCfgRes, NULL, NULL, 2},
|
||||
{ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL, 1},
|
||||
{ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL, 1},
|
||||
{ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL, 2},
|
||||
{ctgInitGetSvrVerTask, ctgLaunchGetSvrVerTask, ctgHandleGetSvrVerRsp, ctgDumpSvrVer, NULL, NULL, 1},
|
||||
{ctgInitGetTbMetasTask, ctgLaunchGetTbMetasTask, ctgHandleGetTbMetasRsp, ctgDumpTbMetasRes, NULL, NULL, 1},
|
||||
{ctgInitGetTbHashsTask, ctgLaunchGetTbHashsTask, ctgHandleGetTbHashsRsp, ctgDumpTbHashsRes, NULL, NULL, 1},
|
||||
{ctgInitGetTbTagTask, ctgLaunchGetTbTagTask, ctgHandleGetTbTagRsp, ctgDumpTbTagRes, NULL, NULL, 2},
|
||||
{ctgInitGetViewsTask, ctgLaunchGetViewsTask, ctgHandleGetViewsRsp, ctgDumpViewsRes, NULL, NULL, 1},
|
||||
{ctgInitGetTbTSMATask, ctgLaunchGetTbTSMATask, ctgHandleGetTbTSMARsp, ctgDumpTbTSMARes, NULL, NULL, 1},
|
||||
{ctgInitGetTSMATask, ctgLaunchGetTSMATask, ctgHandleGetTSMARsp, ctgDumpTSMARes, NULL, NULL, 1},
|
||||
{ctgInitGetTbNamesTask, ctgLaunchGetTbNamesTask, ctgHandleGetTbNamesRsp, ctgDumpTbNamesRes, NULL, NULL, 1},
|
||||
};
|
||||
|
||||
int32_t ctgMakeAsyncRes(SCtgJob* pJob) {
|
||||
|
|
|
@ -611,7 +611,12 @@ static void resetProjectNullType(SNode* pStmt) {
|
|||
resetProjectNullTypeImpl(((SSelectStmt*)pStmt)->pProjectionList);
|
||||
break;
|
||||
case QUERY_NODE_SET_OPERATOR: {
|
||||
resetProjectNullTypeImpl(((SSetOperator*)pStmt)->pProjectionList);
|
||||
SSetOperator* pSetOp = (SSetOperator*)pStmt;
|
||||
resetProjectNullTypeImpl(pSetOp->pProjectionList);
|
||||
if (pSetOp->pLeft)
|
||||
resetProjectNullType(pSetOp->pLeft);
|
||||
if (pSetOp->pRight)
|
||||
resetProjectNullType(pSetOp->pRight);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -2270,6 +2270,7 @@ static bool dataTypeEqual(const SDataType* l, const SDataType* r) {
|
|||
|
||||
// 0 means equal, 1 means the left shall prevail, -1 means the right shall prevail
|
||||
static int32_t dataTypeComp(const SDataType* l, const SDataType* r) {
|
||||
if (l->type == TSDB_DATA_TYPE_NULL) return -1;
|
||||
if (l->type != r->type) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -320,9 +320,8 @@ extern SQueryMgmt gQueryMgmt;
|
|||
case QW_PHASE_POST_QUERY: \
|
||||
case QW_PHASE_PRE_CQUERY: \
|
||||
case QW_PHASE_POST_CQUERY: \
|
||||
atomic_store_8(&(ctx)->phase, _value); \
|
||||
break; \
|
||||
default: \
|
||||
atomic_store_8(&(ctx)->phase, _value); \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
|
@ -83,13 +83,16 @@ void qwDestroySession(QW_FPARAMS_DEF, SQWJobInfo *pJobInfo, void* session) {
|
|||
|
||||
taosMemPoolDestroySession(gMemPoolHandle, session);
|
||||
|
||||
QW_LOCK(QW_WRITE, &pJobInfo->lock);
|
||||
int32_t remainSessions = atomic_sub_fetch_32(&pJobInfo->memInfo->remainSession, 1);
|
||||
|
||||
if (remainSessions != 0) {
|
||||
QW_UNLOCK(QW_WRITE, &pJobInfo->lock);
|
||||
}
|
||||
|
||||
QW_TASK_DLOG("task session destoryed, remainSessions:%d", remainSessions);
|
||||
|
||||
if (0 == remainSessions) {
|
||||
QW_LOCK(QW_WRITE, &pJobInfo->lock);
|
||||
if (/*0 == taosHashGetSize(pJobInfo->pSessions) && */0 == atomic_load_32(&pJobInfo->memInfo->remainSession)) {
|
||||
// if (/*0 == taosHashGetSize(pJobInfo->pSessions) && */0 == atomic_load_32(&pJobInfo->memInfo->remainSession)) {
|
||||
atomic_store_8(&pJobInfo->destroyed, 1);
|
||||
QW_UNLOCK(QW_WRITE, &pJobInfo->lock);
|
||||
|
||||
|
@ -98,10 +101,10 @@ void qwDestroySession(QW_FPARAMS_DEF, SQWJobInfo *pJobInfo, void* session) {
|
|||
TAOS_UNUSED(taosHashRemove(gQueryMgmt.pJobInfo, id2, sizeof(id2)));
|
||||
|
||||
QW_TASK_DLOG_E("the whole query job removed");
|
||||
} else {
|
||||
QW_TASK_DLOG("job not removed, remainSessions:%d, %d", taosHashGetSize(pJobInfo->pSessions), pJobInfo->memInfo->remainSession);
|
||||
QW_UNLOCK(QW_WRITE, &pJobInfo->lock);
|
||||
}
|
||||
// } else {
|
||||
// QW_TASK_DLOG("job not removed, remainSessions:%d, %d", taosHashGetSize(pJobInfo->pSessions), pJobInfo->memInfo->remainSession);
|
||||
// QW_UNLOCK(QW_WRITE, &pJobInfo->lock);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,12 +150,14 @@ int32_t qwRetrieveJobInfo(QW_FPARAMS_DEF, SQWJobInfo** ppJob) {
|
|||
}
|
||||
|
||||
QW_LOCK(QW_READ, &pJob->lock);
|
||||
|
||||
if (atomic_load_8(&pJob->destroyed)) {
|
||||
QW_UNLOCK(QW_READ, &pJob->lock);
|
||||
continue;
|
||||
}
|
||||
|
||||
(void)atomic_add_fetch_32(&pJob->memInfo->remainSession, 1);
|
||||
|
||||
QW_UNLOCK(QW_READ, &pJob->lock);
|
||||
|
||||
break;
|
||||
|
|
|
@ -498,14 +498,14 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
|
|||
int64_t rId = msg.refId;
|
||||
int32_t eId = msg.execId;
|
||||
|
||||
SQWMsg qwMsg = {.node = node, .msg = msg.msg, .msgLen = msg.msgLen, .connInfo = pMsg->info, .msgType = pMsg->msgType};
|
||||
SQWMsg qwMsg = {.node = node, .msg = msg.msg, .msgLen = msg.msgLen, .connInfo = pMsg->info, .msgType = pMsg->msgType, .code = pMsg->code};
|
||||
qwMsg.msgInfo.explain = msg.explain;
|
||||
qwMsg.msgInfo.taskType = msg.taskType;
|
||||
qwMsg.msgInfo.needFetch = msg.needFetch;
|
||||
qwMsg.msgInfo.compressMsg = msg.compress;
|
||||
|
||||
QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, compress:%d, handle:%p, SQL:%s", node, TMSG_INFO(pMsg->msgType),
|
||||
msg.compress, pMsg->info.handle, msg.sql);
|
||||
QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, compress:%d, handle:%p, SQL:%s, code:0x%x", node, TMSG_INFO(pMsg->msgType),
|
||||
msg.compress, pMsg->info.handle, msg.sql, qwMsg.code);
|
||||
|
||||
code = qwProcessQuery(QW_FPARAMS(), &qwMsg, msg.sql);
|
||||
msg.sql = NULL;
|
||||
|
|
|
@ -567,6 +567,14 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu
|
|||
QW_ERR_JRET(ctx->rspCode);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != input->code) {
|
||||
QW_TASK_ELOG("task already failed at phase %s, code:0x%x", qwPhaseStr(phase), input->code);
|
||||
ctx->ctrlConnInfo.handle = NULL;
|
||||
(void)qwDropTask(QW_FPARAMS());
|
||||
|
||||
QW_ERR_JRET(input->code);
|
||||
}
|
||||
|
||||
QW_ERR_JRET(qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_EXEC, ctx->dynamicTask));
|
||||
break;
|
||||
}
|
||||
|
@ -631,6 +639,10 @@ _return:
|
|||
if (ctx) {
|
||||
QW_UPDATE_RSP_CODE(ctx, code);
|
||||
|
||||
if (QW_PHASE_PRE_CQUERY == phase && code) {
|
||||
QW_SET_PHASE(ctx, QW_PHASE_POST_CQUERY);
|
||||
}
|
||||
|
||||
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
||||
qwReleaseTaskCtx(mgmt, ctx);
|
||||
}
|
||||
|
@ -767,7 +779,7 @@ _return:
|
|||
int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) {
|
||||
int32_t code = 0;
|
||||
SSubplan *plan = NULL;
|
||||
SQWPhaseInput input = {0};
|
||||
SQWPhaseInput input = {.code = qwMsg->code};
|
||||
qTaskInfo_t pTaskInfo = NULL;
|
||||
DataSinkHandle sinkHandle = NULL;
|
||||
SQWTaskCtx *ctx = NULL;
|
||||
|
@ -808,10 +820,10 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) {
|
|||
QW_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
atomic_add_fetch_64(&gQueryMgmt.stat.taskRunNum, 1);
|
||||
(void)atomic_add_fetch_64(&gQueryMgmt.stat.taskRunNum, 1);
|
||||
|
||||
uint64_t flags = 0;
|
||||
dsGetSinkFlags(sinkHandle, &flags);
|
||||
(void)dsGetSinkFlags(sinkHandle, &flags);
|
||||
|
||||
ctx->level = plan->level;
|
||||
ctx->dynamicTask = qIsDynamicExecTask(pTaskInfo);
|
||||
|
@ -1342,7 +1354,7 @@ int32_t qwProcessDelete(QW_FPARAMS_DEF, SQWMsg *qwMsg, SDeleteRes *pRes) {
|
|||
ctx.sinkHandle = sinkHandle;
|
||||
|
||||
uint64_t flags = 0;
|
||||
dsGetSinkFlags(sinkHandle, &flags);
|
||||
(void)dsGetSinkFlags(sinkHandle, &flags);
|
||||
|
||||
ctx.sinkWithMemPool = flags & DS_FLAG_USE_MEMPOOL;
|
||||
|
||||
|
|
|
@ -1361,14 +1361,14 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
taosMemoryFree(msg);
|
||||
SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask));
|
||||
} else {
|
||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) {
|
||||
SCH_ERR_JRET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId));
|
||||
}
|
||||
|
||||
SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)};
|
||||
code = schAsyncSendMsg(pJob, pTask, &trans, addr, msgType, msg, (uint32_t)msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL));
|
||||
msg = NULL;
|
||||
SCH_ERR_JRET(code);
|
||||
|
||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY) {
|
||||
SCH_ERR_RET(schAppendTaskExecNode(pJob, pTask, addr, pTask->execId));
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -244,6 +244,8 @@ int32_t flushStateDataInExecutor(SStreamTask* pTask, SStreamQueueItem* pCheckpoi
|
|||
int32_t streamCreateSinkResTrigger(SStreamTrigger** pTrigger);
|
||||
int32_t streamCreateForcewindowTrigger(SStreamTrigger** pTrigger, int32_t trigger, SInterval* pInterval,
|
||||
STimeWindow* pLatestWindow, const char* id);
|
||||
// inject stream errors
|
||||
void chkptFailedByRetrieveReqToSource(SStreamTask* pTask, int64_t checkpointId);
|
||||
|
||||
// inject stream errors
|
||||
void chkptFailedByRetrieveReqToSource(SStreamTask* pTask, int64_t checkpointId);
|
||||
|
|
|
@ -254,5 +254,7 @@ if $rows <= 0 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system taos -P7100 -d db -s " show create table db.t0"
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||
|
|
|
@ -436,6 +436,29 @@ class TDTestCase:
|
|||
tdSql.query(sql, queryTimes=1)
|
||||
tdSql.checkRows(49)
|
||||
|
||||
sql = "select null union select null"
|
||||
tdSql.query(sql, queryTimes=1)
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0, 0, None)
|
||||
|
||||
sql = "select null union all select null"
|
||||
tdSql.query(sql, queryTimes=1)
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1, 0, None)
|
||||
|
||||
sql = "select null union select 1"
|
||||
tdSql.query(sql, queryTimes=1)
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1, 0, 1)
|
||||
|
||||
sql = "select null union select 'asd'"
|
||||
tdSql.query(sql, queryTimes=1)
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1, 0, 'asd')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
|
Loading…
Reference in New Issue